summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-26 15:43:00 (UTC)
committer zautrix <zautrix>2005-07-26 15:43:00 (UTC)
commitd0fe94073aa3209532952c944b41bccfb4341a8d (patch) (unidiff)
treeabab8e118a2661847c65715b9c68e5d3b9ac97e6
parente1d72bb77c51ff7313b390f263bc1f10d20123b0 (diff)
downloadkdepimpi-d0fe94073aa3209532952c944b41bccfb4341a8d.zip
kdepimpi-d0fe94073aa3209532952c944b41bccfb4341a8d.tar.gz
kdepimpi-d0fe94073aa3209532952c944b41bccfb4341a8d.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp21
-rw-r--r--korganizer/mainwindow.cpp12
2 files changed, 21 insertions, 12 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 3ab4bb4..a76f2ed 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -325,97 +325,97 @@ class KOCatPrefs : public QDialog
325 addCatBut->setChecked( true ); 325 addCatBut->setChecked( true );
326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); 326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this );
327 lay->addWidget( ok ); 327 lay->addWidget( ok );
328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
329 lay->addWidget( cancel ); 329 lay->addWidget( cancel );
330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
332 resize( 200, 200 ); 332 resize( 200, 200 );
333 } 333 }
334 334
335 bool addCat() { return addCatBut->isChecked(); } 335 bool addCat() { return addCatBut->isChecked(); }
336private: 336private:
337 QRadioButton* addCatBut; 337 QRadioButton* addCatBut;
338}; 338};
339 339
340 340
341 341
342CalendarView::CalendarView( CalendarResources *calendar, 342CalendarView::CalendarView( CalendarResources *calendar,
343 QWidget *parent, const char *name ) 343 QWidget *parent, const char *name )
344 : CalendarViewBase( parent, name ), 344 : CalendarViewBase( parent, name ),
345 mCalendar( calendar ), 345 mCalendar( calendar ),
346 mResourceManager( calendar->resourceManager() ) 346 mResourceManager( calendar->resourceManager() )
347{ 347{
348 348
349 mEventEditor = 0; 349 mEventEditor = 0;
350 mTodoEditor = 0; 350 mTodoEditor = 0;
351 351
352 init(); 352 init();
353} 353}
354 354
355CalendarView::CalendarView( Calendar *calendar, 355CalendarView::CalendarView( Calendar *calendar,
356 QWidget *parent, const char *name ) 356 QWidget *parent, const char *name )
357 : CalendarViewBase( parent, name ), 357 : CalendarViewBase( parent, name ),
358 mCalendar( calendar ), 358 mCalendar( calendar ),
359 mResourceManager( 0 ) 359 mResourceManager( 0 )
360{ 360{
361 361
362 mEventEditor = 0; 362 mEventEditor = 0;
363 mTodoEditor = 0; 363 mTodoEditor = 0;
364 init(); 364 init();
365} 365}
366 366
367void CalendarView::init() 367void CalendarView::init()
368{ 368{
369 mNextAlarmDateTime = QDateTime::currentDateTime(); 369 mNextAlarmDateTime = QDateTime::currentDateTime();
370 setFocusPolicy (NoFocus ); 370 setFocusPolicy (NoFocus );
371 mViewerCallerIsSearchDialog = false; 371 mViewerCallerIsSearchDialog = false;
372 mBlockShowDates = false; 372 mBlockShowDates = false;
373 373 mConflictingEvent = 0;
374 mDatePickerMode = 0; 374 mDatePickerMode = 0;
375 mCurrentSyncDevice = ""; 375 mCurrentSyncDevice = "";
376 mViewManager = new KOViewManager( this ); 376 mViewManager = new KOViewManager( this );
377 mDialogManager = new KODialogManager( this ); 377 mDialogManager = new KODialogManager( this );
378 mEventViewerDialog = 0; 378 mEventViewerDialog = 0;
379 mModified = false; 379 mModified = false;
380 mReadOnly = false; 380 mReadOnly = false;
381 mSelectedIncidence = 0; 381 mSelectedIncidence = 0;
382 mCalPrinter = 0; 382 mCalPrinter = 0;
383 mFilters.setAutoDelete(true); 383 mFilters.setAutoDelete(true);
384 384
385 mCalendar->registerObserver( this ); 385 mCalendar->registerObserver( this );
386 // TODO: Make sure that view is updated, when calendar is changed. 386 // TODO: Make sure that view is updated, when calendar is changed.
387 387
388 mStorage = new FileStorage( mCalendar ); 388 mStorage = new FileStorage( mCalendar );
389 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 389 mNavigator = new DateNavigator( this, "datevav", mViewManager );
390 390
391 QBoxLayout *topLayout = (QBoxLayout*)layout(); 391 QBoxLayout *topLayout = (QBoxLayout*)layout();
392#ifndef KORG_NOSPLITTER 392#ifndef KORG_NOSPLITTER
393 // create the main layout frames. 393 // create the main layout frames.
394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
395 topLayout->addWidget(mPanner); 395 topLayout->addWidget(mPanner);
396 396
397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
398 "CalendarView::LeftFrame"); 398 "CalendarView::LeftFrame");
399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
400 400
401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
402 "CalendarView::DateNavigator" ); 402 "CalendarView::DateNavigator" );
403 403
404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
406 mTodoList->setNavigator( mNavigator ); 406 mTodoList->setNavigator( mNavigator );
407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
408 408
409#ifdef KORG_NORESOURCEVIEW 409#ifdef KORG_NORESOURCEVIEW
410 mResourceView = 0; 410 mResourceView = 0;
411#else 411#else
412 if ( mResourceManager ) { 412 if ( mResourceManager ) {
413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
414 mResourceView->updateView(); 414 mResourceView->updateView();
415 connect( mResourceView, SIGNAL( resourcesChanged() ), 415 connect( mResourceView, SIGNAL( resourcesChanged() ),
416 SLOT( updateView() ) ); 416 SLOT( updateView() ) );
417 } else { 417 } else {
418 mResourceView = 0; 418 mResourceView = 0;
419 } 419 }
420#endif 420#endif
421 QWidget *rightBox = new QWidget( mPanner ); 421 QWidget *rightBox = new QWidget( mPanner );
@@ -2748,149 +2748,149 @@ void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2748 mEventViewerDialog->hide(); 2748 mEventViewerDialog->hide();
2749 } 2749 }
2750 else 2750 else
2751 mCalendar->checkAlarmForIncidence( which , false ); 2751 mCalendar->checkAlarmForIncidence( which , false );
2752} 2752}
2753 2753
2754// most of the changeEventDisplays() right now just call the view's 2754// most of the changeEventDisplays() right now just call the view's
2755// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2755// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2756void CalendarView::changeEventDisplay(Event *which, int action) 2756void CalendarView::changeEventDisplay(Event *which, int action)
2757{ 2757{
2758 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2758 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2759 changeIncidenceDisplay((Incidence *)which, action); 2759 changeIncidenceDisplay((Incidence *)which, action);
2760 static bool clearallviews = false; 2760 static bool clearallviews = false;
2761 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2761 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2762 if ( clearallviews ) { 2762 if ( clearallviews ) {
2763 clearAllViews(); 2763 clearAllViews();
2764 clearallviews = false; 2764 clearallviews = false;
2765 } 2765 }
2766 return; 2766 return;
2767 } 2767 }
2768 clearallviews = true; 2768 clearallviews = true;
2769 mDateNavigator->updateView(); 2769 mDateNavigator->updateView();
2770 //mDialogManager->updateSearchDialog(); 2770 //mDialogManager->updateSearchDialog();
2771 if (which) { 2771 if (which) {
2772 // If there is an event view visible update the display 2772 // If there is an event view visible update the display
2773 mViewManager->currentView()->changeEventDisplay(which,action); 2773 mViewManager->currentView()->changeEventDisplay(which,action);
2774 // TODO: check, if update needed 2774 // TODO: check, if update needed
2775 // if (which->getTodoStatus()) { 2775 // if (which->getTodoStatus()) {
2776 mTodoList->updateView(); 2776 mTodoList->updateView();
2777 if ( action != KOGlobals::EVENTDELETED ) { 2777 if ( action != KOGlobals::EVENTDELETED ) {
2778 mConflictingEvent = which ; 2778 mConflictingEvent = which ;
2779 int time = 1000; 2779 int time = 1000;
2780#ifdef DESKTOP_VERSION 2780#ifdef DESKTOP_VERSION
2781 time = 500; 2781 time = 500;
2782#endif 2782#endif
2783 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); 2783 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) );
2784 } 2784 }
2785 // } 2785 // }
2786 } else { 2786 } else {
2787 mViewManager->currentView()->updateView(); 2787 mViewManager->currentView()->updateView();
2788 } 2788 }
2789} 2789}
2790void CalendarView::checkConflictForEvent() 2790void CalendarView::checkConflictForEvent()
2791{ 2791{
2792 2792
2793 if (!KOPrefs::instance()->mConfirm) 2793 if (!KOPrefs::instance()->mConfirm)
2794 return; 2794 return;
2795 if ( ! mConflictingEvent ) return; 2795 if ( ! mConflictingEvent ) return;
2796 Event * conflictingEvent = mConflictingEvent;
2797 mConflictingEvent = 0;
2796 QDateTime current = QDateTime::currentDateTime(); 2798 QDateTime current = QDateTime::currentDateTime();
2797 if ( ! mConflictingEvent->matchTime( &current, 0 ) ) { 2799 if ( ! conflictingEvent->matchTime( &current, 0 ) ) {
2798 mConflictingEvent = 0;
2799 return; 2800 return;
2800 } 2801 }
2801 QPtrList<Event> testlist = mCalendar->events(); 2802 QPtrList<Event> testlist = mCalendar->events();
2802 Event * test = testlist.first(); 2803 Event * test = testlist.first();
2803 QDateTime conflict; 2804 QDateTime conflict;
2804 QDateTime retVal; 2805 QDateTime retVal;
2805 bool found = false; 2806 bool found = false;
2806 Event * cE = 0; 2807 Event * cE = 0;
2807 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 2808 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
2808 while ( test ) { 2809 while ( test ) {
2809 qApp->processEvents(); 2810 qApp->processEvents();
2810 bool skip = false; 2811 bool skip = false;
2811 if ( found ) 2812 if ( found )
2812 skip = !test->matchTime( &current, &conflict ); 2813 skip = !test->matchTime( &current, &conflict );
2813 else 2814 else
2814 skip = !test->matchTime( &current, 0 ); 2815 skip = !test->matchTime( &current, 0 );
2815 if ( !skip && !test->doesFloat() ) { 2816 if ( !skip && !test->doesFloat() ) {
2816 if ( mConflictingEvent->isOverlapping ( test, &retVal, &current ) ) { 2817 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) {
2817 if ( ! found ) { 2818 if ( ! found ) {
2818 conflict = retVal; 2819 conflict = retVal;
2819 cE = test; 2820 cE = test;
2820 } else { 2821 } else {
2821 if ( retVal < conflict ) { 2822 if ( retVal < conflict ) {
2822 conflict = retVal; 2823 conflict = retVal;
2823 cE = test; 2824 cE = test;
2824 } 2825 }
2825 } 2826 }
2826 found = true; 2827 found = true;
2827 } 2828 }
2828 } 2829 }
2829 test = testlist.next(); 2830 test = testlist.next();
2830 } 2831 }
2831 topLevelWidget()->setCaption( i18n("KO/Pi") ); 2832 topLevelWidget()->setCaption( i18n("KO/Pi") );
2832 if ( found ) { 2833 if ( found ) {
2833 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; 2834 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ;
2834 qApp->processEvents(); 2835 qApp->processEvents();
2835 int km = KMessageBox::warningContinueCancel(this,mess, 2836 int km = KMessageBox::warningContinueCancel(this,mess,
2836 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); 2837 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!"));
2837 if ( km != KMessageBox::Continue ) { 2838 if ( km != KMessageBox::Continue ) {
2838 return; 2839 return;
2839 } 2840 }
2840 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 2841 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
2841 mViewManager->showDayView(); 2842 mViewManager->showDayView();
2842 mNavigator->slotDaySelect( conflict.date() ); 2843 mNavigator->slotDaySelect( conflict.date() );
2843 int hour = conflict.time().hour(); 2844 int hour = conflict.time().hour();
2844 mViewManager->agendaView()->setStartHour( hour ); 2845 mViewManager->agendaView()->setStartHour( hour );
2845 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); 2846 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
2846 } else 2847 } else
2847 topLevelWidget()->setCaption( i18n("No conflict found") ); 2848 topLevelWidget()->setCaption( i18n("No conflict found") );
2848 mConflictingEvent = 0;
2849 return; 2849 return;
2850 2850
2851} 2851}
2852 2852
2853void CalendarView::updateTodoViews() 2853void CalendarView::updateTodoViews()
2854{ 2854{
2855 mTodoList->updateView(); 2855 mTodoList->updateView();
2856 mViewManager->currentView()->updateView(); 2856 mViewManager->currentView()->updateView();
2857 2857
2858} 2858}
2859 2859
2860 2860
2861 2861
2862void CalendarView::clearAllViews() 2862void CalendarView::clearAllViews()
2863{ 2863{
2864 mTodoList->clearList(); 2864 mTodoList->clearList();
2865 mViewManager->clearAllViews(); 2865 mViewManager->clearAllViews();
2866 SearchDialog * sd = mDialogManager->getSearchDialog(); 2866 SearchDialog * sd = mDialogManager->getSearchDialog();
2867 if ( sd ) { 2867 if ( sd ) {
2868 KOListView* kol = sd->listview(); 2868 KOListView* kol = sd->listview();
2869 if ( kol ) 2869 if ( kol )
2870 kol->clearList(); 2870 kol->clearList();
2871 } 2871 }
2872} 2872}
2873void CalendarView::updateView() 2873void CalendarView::updateView()
2874{ 2874{
2875 static bool clearallviews = false; 2875 static bool clearallviews = false;
2876 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2876 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2877 if ( clearallviews ) { 2877 if ( clearallviews ) {
2878 clearAllViews(); 2878 clearAllViews();
2879 clearallviews = false; 2879 clearallviews = false;
2880 } 2880 }
2881 return; 2881 return;
2882 } 2882 }
2883 clearallviews = true; 2883 clearallviews = true;
2884 DateList tmpList = mNavigator->selectedDates(); 2884 DateList tmpList = mNavigator->selectedDates();
2885 2885
2886 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2886 if ( KOPrefs::instance()->mHideNonStartedTodos )
2887 mTodoList->updateView(); 2887 mTodoList->updateView();
2888 // We assume that the navigator only selects consecutive days. 2888 // We assume that the navigator only selects consecutive days.
2889 updateView( tmpList.first(), tmpList.last() ); 2889 updateView( tmpList.first(), tmpList.last() );
2890} 2890}
2891 2891
2892void CalendarView::updateUnmanagedViews() 2892void CalendarView::updateUnmanagedViews()
2893{ 2893{
2894 mDateNavigator->updateDayMatrix(); 2894 mDateNavigator->updateDayMatrix();
2895} 2895}
2896 2896
@@ -4047,102 +4047,103 @@ void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
4047 } 4047 }
4048 4048
4049 Event *ev = 0; 4049 Event *ev = 0;
4050 if (event) ev = new Event(*event); 4050 if (event) ev = new Event(*event);
4051 Todo *to = 0; 4051 Todo *to = 0;
4052 if (todo) to = new Todo(*todo); 4052 if (todo) to = new Todo(*todo);
4053 4053
4054 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 4054 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
4055 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 4055 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
4056 if (!me) { 4056 if (!me) {
4057 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 4057 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
4058 return; 4058 return;
4059 } 4059 }
4060 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 4060 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
4061 StatusDialog *statdlg = new StatusDialog(this); 4061 StatusDialog *statdlg = new StatusDialog(this);
4062 if (!statdlg->exec()==QDialog::Accepted) return; 4062 if (!statdlg->exec()==QDialog::Accepted) return;
4063 me->setStatus( statdlg->status() ); 4063 me->setStatus( statdlg->status() );
4064 delete(statdlg); 4064 delete(statdlg);
4065 } 4065 }
4066 Attendee *menew = new Attendee(*me); 4066 Attendee *menew = new Attendee(*me);
4067 if (ev) { 4067 if (ev) {
4068 ev->clearAttendees(); 4068 ev->clearAttendees();
4069 ev->addAttendee(menew,false); 4069 ev->addAttendee(menew,false);
4070 } else { 4070 } else {
4071 if (to) { 4071 if (to) {
4072 todo->clearAttendees(); 4072 todo->clearAttendees();
4073 todo->addAttendee(menew,false); 4073 todo->addAttendee(menew,false);
4074 } 4074 }
4075 } 4075 }
4076 } 4076 }
4077 4077
4078 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4078 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4079 if (ev) { 4079 if (ev) {
4080 if ( !dlg->addMessage(ev,method) ) delete(ev); 4080 if ( !dlg->addMessage(ev,method) ) delete(ev);
4081 } else { 4081 } else {
4082 if (to) { 4082 if (to) {
4083 if ( !dlg->addMessage(to,method) ) delete(to); 4083 if ( !dlg->addMessage(to,method) ) delete(to);
4084 } 4084 }
4085 } 4085 }
4086} 4086}
4087 4087
4088void CalendarView::openAddressbook() 4088void CalendarView::openAddressbook()
4089{ 4089{
4090 KRun::runCommand("kaddressbook"); 4090 KRun::runCommand("kaddressbook");
4091} 4091}
4092 4092
4093void CalendarView::setModified(bool modified) 4093void CalendarView::setModified(bool modified)
4094{ 4094{
4095 //qDebug("CalendarView::setModified %d ", modified);
4095 if ( modified ) 4096 if ( modified )
4096 emit signalmodified(); 4097 emit signalmodified();
4097 if (mModified != modified) { 4098 mModified = modified;
4098 mModified = modified; 4099 if ( mModified )
4099 emit modifiedChanged(mModified); 4100 emit modifiedChanged(mModified);
4100 } 4101
4101} 4102}
4102 4103
4103bool CalendarView::isReadOnly() 4104bool CalendarView::isReadOnly()
4104{ 4105{
4105 return mReadOnly; 4106 return mReadOnly;
4106} 4107}
4107 4108
4108void CalendarView::setReadOnly(bool readOnly) 4109void CalendarView::setReadOnly(bool readOnly)
4109{ 4110{
4110 if (mReadOnly != readOnly) { 4111 if (mReadOnly != readOnly) {
4111 mReadOnly = readOnly; 4112 mReadOnly = readOnly;
4112 emit readOnlyChanged(mReadOnly); 4113 emit readOnlyChanged(mReadOnly);
4113 } 4114 }
4114} 4115}
4115 4116
4116bool CalendarView::isModified() 4117bool CalendarView::isModified()
4117{ 4118{
4118 return mModified; 4119 return mModified;
4119} 4120}
4120void CalendarView::slotprintSelInc() 4121void CalendarView::slotprintSelInc()
4121{ 4122{
4122 if ( currentSelection() == 0 ) { 4123 if ( currentSelection() == 0 ) {
4123 KMessageBox::sorry(this,i18n("There is nothing selected!")); 4124 KMessageBox::sorry(this,i18n("There is nothing selected!"));
4124 return; 4125 return;
4125 } 4126 }
4126 showIncidence(); 4127 showIncidence();
4127 getEventViewerDialog()->print(); 4128 getEventViewerDialog()->print();
4128 4129
4129} 4130}
4130void CalendarView::printSetup() 4131void CalendarView::printSetup()
4131{ 4132{
4132#ifndef KORG_NOPRINTER 4133#ifndef KORG_NOPRINTER
4133 createPrinter(); 4134 createPrinter();
4134 4135
4135 mCalPrinter->setupPrinter(); 4136 mCalPrinter->setupPrinter();
4136#endif 4137#endif
4137} 4138}
4138 4139
4139void CalendarView::print() 4140void CalendarView::print()
4140{ 4141{
4141#ifndef KORG_NOPRINTER 4142#ifndef KORG_NOPRINTER
4142 createPrinter(); 4143 createPrinter();
4143 4144
4144 DateList tmpDateList = mNavigator->selectedDates(); 4145 DateList tmpDateList = mNavigator->selectedDates();
4145 mCalPrinter->print(CalPrinter::Month, 4146 mCalPrinter->print(CalPrinter::Month,
4146 tmpDateList.first(), tmpDateList.last()); 4147 tmpDateList.first(), tmpDateList.last());
4147#endif 4148#endif
4148} 4149}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 279955f..77d0ac8 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1869,185 +1869,193 @@ void MainWindow::saveOnClose()
1869 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1869 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1870 if ( p->mToolBarHorV ) 1870 if ( p->mToolBarHorV )
1871 p->mToolBarUpV = myP.y() > height()/2; 1871 p->mToolBarUpV = myP.y() > height()/2;
1872 else 1872 else
1873 p->mToolBarUpV = myP.x() > width()/2 ; 1873 p->mToolBarUpV = myP.x() > width()/2 ;
1874 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1874 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1875 if ( p->mToolBarHorN ) 1875 if ( p->mToolBarHorN )
1876 p->mToolBarUpN = myP.y() > height()/2; 1876 p->mToolBarUpN = myP.y() > height()/2;
1877 else 1877 else
1878 p->mToolBarUpN = myP.x() > width()/2 ; 1878 p->mToolBarUpN = myP.x() > width()/2 ;
1879 if ( filterToolBar ) { 1879 if ( filterToolBar ) {
1880 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1880 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1881 if ( p->mToolBarHorF ) 1881 if ( p->mToolBarHorF )
1882 p->mToolBarUpF = myP.y() > height()/2; 1882 p->mToolBarUpF = myP.y() > height()/2;
1883 else 1883 else
1884 p->mToolBarUpF = myP.x() > width()/2 ; 1884 p->mToolBarUpF = myP.x() > width()/2 ;
1885 } 1885 }
1886#else 1886#else
1887 if ( p->mToolBarHor ) 1887 if ( p->mToolBarHor )
1888 p->mToolBarUp = iconToolBar->y() > height()/2; 1888 p->mToolBarUp = iconToolBar->y() > height()/2;
1889 else 1889 else
1890 p->mToolBarUp = iconToolBar->x() > width()/2; 1890 p->mToolBarUp = iconToolBar->x() > width()/2;
1891 if ( p->mToolBarHorV ) 1891 if ( p->mToolBarHorV )
1892 p->mToolBarUpV = viewToolBar->y() > height()/2; 1892 p->mToolBarUpV = viewToolBar->y() > height()/2;
1893 else 1893 else
1894 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1894 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1895 1895
1896 if ( p->mToolBarHorN ) 1896 if ( p->mToolBarHorN )
1897 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1897 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1898 else 1898 else
1899 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1899 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1900 if ( filterToolBar ) { 1900 if ( filterToolBar ) {
1901 if ( p->mToolBarHorF ) 1901 if ( p->mToolBarHorF )
1902 p->mToolBarUpF = filterToolBar->y() > height()/2; 1902 p->mToolBarUpF = filterToolBar->y() > height()/2;
1903 else 1903 else
1904 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1904 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1905 } 1905 }
1906#endif 1906#endif
1907 save(); 1907 save();
1908 mView->writeSettings(); 1908 mView->writeSettings();
1909 mView->checkSuspendAlarm(); 1909 mView->checkSuspendAlarm();
1910} 1910}
1911void MainWindow::slotModifiedChanged( bool ) 1911void MainWindow::slotModifiedChanged( bool )
1912{ 1912{
1913 if ( mBlockAtStartup ) 1913 if ( mBlockAtStartup )
1914 return; 1914 return;
1915 1915
1916 int msec; 1916 int msec;
1917 if ( mCalendarModifiedFlag ) {
1918 //qDebug(" MainWindow timer is running ");
1919 return;
1920 }
1917 // we store the changes after 1 minute, 1921 // we store the changes after 1 minute,
1918 // and for safety reasons after 10 minutes again 1922 // and for safety reasons after 10 minutes again
1919 if ( !mSyncManager->blockSave() ) 1923 if ( !mSyncManager->blockSave() )
1920 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1924 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1921 else 1925 else
1922 msec = 1000 * 600; 1926 msec = 1000 * 600;
1923 mSaveTimer.start( msec, true ); // 1 minute 1927 mSaveTimer.start( msec, true ); // 1 minute
1924 qDebug("KO: Saving File in %d secs!", msec/1000); 1928 qDebug("KO: Saving File in %d secs!", msec/1000);
1925 mCalendarModifiedFlag = true; 1929 mCalendarModifiedFlag = true;
1926} 1930}
1927void MainWindow::saveStopTimer() 1931void MainWindow::saveStopTimer()
1928{ 1932{
1929 mSaveTimer.stop(); 1933 mSaveTimer.stop();
1930} 1934}
1931void MainWindow::backupAllFiles() 1935void MainWindow::backupAllFiles()
1932{ 1936{
1933 QDate reference ( 2000,1,1); 1937 QDate reference ( 2000,1,1);
1934 int daysTo = reference.daysTo ( QDate::currentDate() ); 1938 int daysTo = reference.daysTo ( QDate::currentDate() );
1935 setCaption(i18n("Creating backup ... please wait ..." )); 1939 setCaption(i18n("Creating backup ... please wait ..." ));
1936 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1940 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1937 // we need the file path, the backup dir and the number of bups as param 1941 // we need the file path, the backup dir and the number of bups as param
1938 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1942 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1939 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1943 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1940 bupDir = KGlobalSettings::backupDataDir(); 1944 bupDir = KGlobalSettings::backupDataDir();
1941 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1945 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1942 if ( retval == 0 ) { 1946 if ( retval == 0 ) {
1943 setCaption(i18n("Backup cancelled" )); 1947 setCaption(i18n("Backup cancelled" ));
1944 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1948 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1945 // retval == 0 : backup skipped for today, try again tomorrow 1949 // retval == 0 : backup skipped for today, try again tomorrow
1946 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1950 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1947 } else if ( retval == 1 ){ 1951 } else if ( retval == 1 ){
1948 qDebug("KO: Backup created."); 1952 qDebug("KO: Backup created.");
1949 // backup ok 1953 // backup ok
1950 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1954 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1951 KopiCalendarFile * cal = calendars.first(); 1955 KopiCalendarFile * cal = calendars.first();
1952 cal = calendars.next(); 1956 cal = calendars.next();
1953 while ( cal ) { 1957 while ( cal ) {
1954 if ( !cal->mErrorOnLoad ) { 1958 if ( !cal->mErrorOnLoad ) {
1955 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1959 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1956 } 1960 }
1957 cal = calendars.next(); 1961 cal = calendars.next();
1958 } 1962 }
1959 KOPrefs::instance()->mLastBackupDate = daysTo; 1963 KOPrefs::instance()->mLastBackupDate = daysTo;
1960 setCaption(i18n("Backup succesfully finished" )); 1964 setCaption(i18n("Backup succesfully finished" ));
1961 } else if ( retval == 2 ){ 1965 } else if ( retval == 2 ){
1962 setCaption(i18n("Backup globally disabled" )); 1966 setCaption(i18n("Backup globally disabled" ));
1963 qDebug("KO: Backup globally cancelled."); 1967 qDebug("KO: Backup globally cancelled.");
1964 // backup globally cancelled 1968 // backup globally cancelled
1965 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1969 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1966 } 1970 }
1967 // retval == 3: do nothing, try again later 1971 // retval == 3: do nothing, try again later
1968} 1972}
1969void MainWindow::save() 1973void MainWindow::save()
1970{ 1974{
1971 1975
1972 if ( mView->viewManager()->journalView() ) 1976 if ( mView->viewManager()->journalView() )
1973 mView->viewManager()->journalView()->checkModified(); 1977 mView->viewManager()->journalView()->checkModified();
1974 if ( !mCalendarModifiedFlag ) { 1978 if ( !mCalendarModifiedFlag ) {
1975 qDebug("KO: Calendar not modified. Nothing saved."); 1979 qDebug("KO: Calendar not modified. Nothing saved.");
1976 return; 1980 return;
1977 } 1981 }
1978 if ( mSyncManager->blockSave() ) 1982 if ( mSyncManager->blockSave() ) {
1979 return; 1983 return;
1984 }
1980 mSyncManager->setBlockSave(true); 1985 mSyncManager->setBlockSave(true);
1981 if ( mView->checkAllFileVersions() ) { 1986 if ( mView->checkAllFileVersions() ) {
1982 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 1987 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1983 QDate reference ( 2000,1,1); 1988 QDate reference ( 2000,1,1);
1984 int daysTo = reference.daysTo ( QDate::currentDate() ); 1989 int daysTo = reference.daysTo ( QDate::currentDate() );
1985 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 1990 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1986 backupAllFiles(); 1991 backupAllFiles();
1987 } 1992 }
1988 ; // KPimGlobalPrefs::instance()->mLastBackupDate 1993 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1989 } 1994 }
1990 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1995 QTime neededSaveTime = QDateTime::currentDateTime().time();
1991 if ( !isMinimized () ) 1996 if ( !isMinimized () )
1992 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1997 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1993 qDebug("KO: Start saving data to file!"); 1998 qDebug("KO: Start saving data to file!");
1994 mView->saveCalendars(); 1999 mView->saveCalendars();
1995 mCalendarModifiedFlag = false; 2000 mCalendarModifiedFlag = false;
1996 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 2001 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1997 qDebug("KO: Needed %d ms for saving.",msNeeded ); 2002 qDebug("KO: Needed %d ms for saving.",msNeeded );
1998 QString savemes; 2003 QString savemes;
1999 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 2004 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
2000 if ( !isMinimized () ) 2005 if ( !isMinimized () )
2001 setCaption(savemes); 2006 setCaption(savemes);
2002 else 2007 else
2003 qDebug(savemes); 2008 qDebug(savemes);
2004 } else 2009 } else {
2005 setCaption(i18n("Saving cancelled!")); 2010 setCaption(i18n("Saving cancelled!"));
2011 mCalendarModifiedFlag = false;
2012 slotModifiedChanged( true );
2013 }
2006 mSyncManager->setBlockSave( false ); 2014 mSyncManager->setBlockSave( false );
2007} 2015}
2008 2016
2009void MainWindow::keyReleaseEvent ( QKeyEvent * e) 2017void MainWindow::keyReleaseEvent ( QKeyEvent * e)
2010{ 2018{
2011 if ( !e->isAutoRepeat() ) { 2019 if ( !e->isAutoRepeat() ) {
2012 mFlagKeyPressed = false; 2020 mFlagKeyPressed = false;
2013 } 2021 }
2014} 2022}
2015void MainWindow::keyPressEvent ( QKeyEvent * e ) 2023void MainWindow::keyPressEvent ( QKeyEvent * e )
2016{ 2024{
2017 qApp->processEvents(); 2025 qApp->processEvents();
2018 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 2026 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
2019 e->ignore(); 2027 e->ignore();
2020 // qDebug(" ignore %d",e->isAutoRepeat() ); 2028 // qDebug(" ignore %d",e->isAutoRepeat() );
2021 return; 2029 return;
2022 } 2030 }
2023 if (! e->isAutoRepeat() ) 2031 if (! e->isAutoRepeat() )
2024 mFlagKeyPressed = true; 2032 mFlagKeyPressed = true;
2025 KOPrefs *p = KOPrefs::instance(); 2033 KOPrefs *p = KOPrefs::instance();
2026 bool showSelectedDates = false; 2034 bool showSelectedDates = false;
2027 int size; 2035 int size;
2028 int pro = 0; 2036 int pro = 0;
2029 //qDebug("MainWindow::keyPressEvent "); 2037 //qDebug("MainWindow::keyPressEvent ");
2030 switch ( e->key() ) { 2038 switch ( e->key() ) {
2031 case Qt::Key_Right: 2039 case Qt::Key_Right:
2032 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2040 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2033 mView->goNextMonth(); 2041 mView->goNextMonth();
2034 else 2042 else
2035 mView->goNext(); 2043 mView->goNext();
2036 showSelectedDates = true; 2044 showSelectedDates = true;
2037 break; 2045 break;
2038 case Qt::Key_Left: 2046 case Qt::Key_Left:
2039 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2047 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2040 mView->goPreviousMonth(); 2048 mView->goPreviousMonth();
2041 else 2049 else
2042 mView->goPrevious(); 2050 mView->goPrevious();
2043 showSelectedDates = true; 2051 showSelectedDates = true;
2044 break; 2052 break;
2045 case Qt::Key_Down: 2053 case Qt::Key_Down:
2046 mView->viewManager()->agendaView()->scrollOneHourDown(); 2054 mView->viewManager()->agendaView()->scrollOneHourDown();
2047 break; 2055 break;
2048 case Qt::Key_Up: 2056 case Qt::Key_Up:
2049 mView->viewManager()->agendaView()->scrollOneHourUp(); 2057 mView->viewManager()->agendaView()->scrollOneHourUp();
2050 break; 2058 break;
2051 case Qt::Key_K: 2059 case Qt::Key_K:
2052 mView->viewManager()->showMonthViewWeek(); 2060 mView->viewManager()->showMonthViewWeek();
2053 break; 2061 break;