summaryrefslogtreecommitdiffabout
path: root/korganizer/koviewmanager.cpp
Unidiff
Diffstat (limited to 'korganizer/koviewmanager.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koviewmanager.cpp50
1 files changed, 45 insertions, 5 deletions
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index f8f6c1d..e22f096 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -59,65 +59,70 @@ int globalFlagBlockAgendaItemUpdate = 1;
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 64
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") showMonthView(); 91 else if (view == "Month") {
92 if ( KOPrefs::instance()->mMonthViewWeek )
93 showMonthView();
94 else
95 showMonthViewWeek();
96 }
92 else if (view == "List") showListView(); 97 else if (view == "List") showListView();
93 else if (view == "Journal") showJournalView(); 98 else if (view == "Journal") showJournalView();
94 else if (view == "TimeSpan") showTimeSpanView(); 99 else if (view == "TimeSpan") showTimeSpanView();
95 else if (view == "Todo") showTodoView(); 100 else if (view == "Todo") showTodoView();
96 else { 101 else {
97 config->setGroup( "Views" ); 102 config->setGroup( "Views" );
98 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
99 mCurrentAgendaView = dateCount; 104 mCurrentAgendaView = dateCount;
100 showAgendaView(); 105 showAgendaView();
101 mCurrentAgendaView = dateCount; 106 mCurrentAgendaView = dateCount;
102#ifdef DESKTOP_VERSION 107#ifdef DESKTOP_VERSION
103 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); 108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) );
104#endif 109#endif
105 } 110 }
106} 111}
107 112
108void KOViewManager::showDateView( int view, QDate date) 113void KOViewManager::showDateView( int view, QDate date)
109{ 114{
110 static int lastMode = 0; 115 static int lastMode = 0;
111 static int lastCount = 0; 116 static int lastCount = 0;
112 static bool lastNDMode = false; 117 static bool lastNDMode = false;
113 static QDate lastDate; 118 static QDate lastDate;
114 //qDebug("date %d %s", view, date.toString().latin1()); 119 //qDebug("date %d %s", view, date.toString().latin1());
115 120
116 if (view != 9) 121 if (view != 9)
117 lastMode = 0; 122 lastMode = 0;
118 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
119 bool savemFlagShowNextxDays = mFlagShowNextxDays; 124 bool savemFlagShowNextxDays = mFlagShowNextxDays;
120 mFlagShowNextxDays = false; 125 mFlagShowNextxDays = false;
121 if ( view == 3 ) { 126 if ( view == 3 ) {
122 //mCurrentAgendaView = 1 ; 127 //mCurrentAgendaView = 1 ;
123 lastDate = mMainView->dateNavigator()->selectedDates().first(); 128 lastDate = mMainView->dateNavigator()->selectedDates().first();
@@ -178,64 +183,65 @@ void KOViewManager::writeSettings(KConfig *config)
178 else view = "Agenda"; 183 else view = "Agenda";
179 184
180 config->writeEntry("Current View",view); 185 config->writeEntry("Current View",view);
181 186
182 if (mAgendaView) { 187 if (mAgendaView) {
183 mAgendaView->writeSettings(config); 188 mAgendaView->writeSettings(config);
184 } 189 }
185 if (mTimeSpanView) { 190 if (mTimeSpanView) {
186 mTimeSpanView->writeSettings(config); 191 mTimeSpanView->writeSettings(config);
187 } 192 }
188 if (mListView) { 193 if (mListView) {
189 mListView->writeSettings(config); 194 mListView->writeSettings(config);
190 } 195 }
191 if (mTodoView) { 196 if (mTodoView) {
192 mTodoView->saveLayout(config,"Todo View"); 197 mTodoView->saveLayout(config,"Todo View");
193 } 198 }
194} 199}
195 200
196void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 201void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
197{ 202{
198 203
199 //mFlagShowNextxDays = false; 204 //mFlagShowNextxDays = false;
200 //if(view == mCurrentView) return; 205 //if(view == mCurrentView) return;
201 if ( view == 0 ) { 206 if ( view == 0 ) {
202 view = mCurrentView; 207 view = mCurrentView;
203 if ( view == 0 ) 208 if ( view == 0 )
204 return; 209 return;
205 } 210 }
206 bool full = fullScreen; 211 bool full = fullScreen;
207 if(view == mCurrentView && view != mWhatsNextView ) { 212 if(view == mCurrentView && view != mWhatsNextView ) {
208 if ( mCurrentAgendaView < 0 ) 213 if ( mCurrentAgendaView < 0 )
209 return; 214 return;
215 if ( view != mMonthView )
210 full = mMainView->leftFrame()->isVisible(); 216 full = mMainView->leftFrame()->isVisible();
211 } else { 217 } else {
212 if ( view == mMonthView && mMonthView) 218 if ( view == mMonthView && mMonthView)
213 ;//mMonthView->skipResize = true ; 219 ;//mMonthView->skipResize = true ;
214 mCurrentView = view; 220 mCurrentView = view;
215 // bool full = fullScreen; 221 // bool full = fullScreen;
216 bool isFull = !mMainView->leftFrame()->isVisible(); 222 bool isFull = !mMainView->leftFrame()->isVisible();
217 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 223 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
218 full = true; 224 full = true;
219 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 225 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
220 full = false; 226 full = false;
221 } 227 }
222 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 228 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
223 //raiseCurrentView( full ); 229 //raiseCurrentView( full );
224 mMainView->processIncidenceSelection( 0 ); 230 mMainView->processIncidenceSelection( 0 );
225 //mMainView->updateView(); 231 //mMainView->updateView();
226 raiseCurrentView( full, true ); 232 raiseCurrentView( full, true );
227 mMainView->adaptNavigationUnits(); 233 mMainView->adaptNavigationUnits();
228} 234}
229 235
230void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 236void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
231{ 237{
232 mCurrentAgendaView = 0; 238 mCurrentAgendaView = 0;
233 if ( fullScreen ) { 239 if ( fullScreen ) {
234 mMainView->leftFrame()->hide(); 240 mMainView->leftFrame()->hide();
235 } else { 241 } else {
236 mMainView->leftFrame()->show(); 242 mMainView->leftFrame()->show();
237 } 243 }
238 emit signalFullScreen( !fullScreen ); 244 emit signalFullScreen( !fullScreen );
239 if ( callUpdateView ) 245 if ( callUpdateView )
240 mMainView->updateView(); 246 mMainView->updateView();
241 247
@@ -457,129 +463,163 @@ void KOViewManager::showWeekView()
457 463
458 464
459 mFlagShowNextxDays = false; 465 mFlagShowNextxDays = false;
460 globalFlagBlockAgenda = 1; 466 globalFlagBlockAgenda = 1;
461 globalFlagBlockLabel = 1; 467 globalFlagBlockLabel = 1;
462 if ( mCurrentAgendaView != 7 ) 468 if ( mCurrentAgendaView != 7 )
463 mCurrentAgendaView = -1; 469 mCurrentAgendaView = -1;
464 showAgendaView(); 470 showAgendaView();
465 qApp->processEvents(); 471 qApp->processEvents();
466 globalFlagBlockAgenda = 2; 472 globalFlagBlockAgenda = 2;
467 globalFlagBlockLabel = 0; 473 globalFlagBlockLabel = 0;
468 mMainView->dateNavigator()->selectWeek(); 474 mMainView->dateNavigator()->selectWeek();
469 mCurrentAgendaView = 7 ; 475 mCurrentAgendaView = 7 ;
470} 476}
471 477
472void KOViewManager::showNextXView() 478void KOViewManager::showNextXView()
473{ 479{
474 480
475 globalFlagBlockAgenda = 1; 481 globalFlagBlockAgenda = 1;
476 if ( mCurrentAgendaView != 3 ) 482 if ( mCurrentAgendaView != 3 )
477 mCurrentAgendaView = -1; 483 mCurrentAgendaView = -1;
478 showAgendaView(KOPrefs::instance()->mFullViewMonth); 484 showAgendaView(KOPrefs::instance()->mFullViewMonth);
479 globalFlagBlockAgenda = 2; 485 globalFlagBlockAgenda = 2;
480 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 486 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
481 KOPrefs::instance()->mNextXDays ); 487 KOPrefs::instance()->mNextXDays );
482 mFlagShowNextxDays = true; 488 mFlagShowNextxDays = true;
483 mCurrentAgendaView = 3 ; 489 mCurrentAgendaView = 3 ;
484} 490}
485bool KOViewManager::showsNextDays() 491bool KOViewManager::showsNextDays()
486{ 492{
487 return mFlagShowNextxDays; 493 return mFlagShowNextxDays;
488} 494}
489void KOViewManager::showMonthView() 495void KOViewManager::createMonthView()
490 { 496 {
491 if (!mMonthView) { 497 if (!mMonthView) {
492 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 498 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
493 499
494 addView(mMonthView); 500 addView(mMonthView);
495 // mMonthView->show(); 501 // mMonthView->show();
496 // SIGNALS/SLOTS FOR MONTH VIEW 502 // SIGNALS/SLOTS FOR MONTH VIEW
497 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 503 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
498 mMainView, SLOT(newEvent(QDateTime))); 504 mMainView, SLOT(newEvent(QDateTime)));
499 505
500 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 506 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
501 mMainView, SLOT(showIncidence(Incidence *))); 507 mMainView, SLOT(showIncidence(Incidence *)));
502 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 508 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
503 mMainView, SLOT(editIncidence(Incidence *))); 509 mMainView, SLOT(editIncidence(Incidence *)));
504 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 510 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
505 mMainView, SLOT(deleteIncidence(Incidence *))); 511 mMainView, SLOT(deleteIncidence(Incidence *)));
506 512
507 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 513 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
508 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 514 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
509 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 515 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
510 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 516 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
511 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 517 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
512 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 518 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
513 519
514 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 520 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
515 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 521 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
516 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 522 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
517 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 523 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
518 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 524 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
519 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); 525 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) );
526 connect( mMonthView, SIGNAL( selectMonth() ),
527 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) );
520 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 528 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
521 mMainView, SLOT ( showDay( QDate ) ) ); 529 mMainView, SLOT ( showDay( QDate ) ) );
522 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 530 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
523 connect( mMonthView, SIGNAL(nextMonth() ), 531 connect( mMonthView, SIGNAL(nextMonth() ),
524 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); 532 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) );
525 connect( mMonthView, SIGNAL(prevMonth() ), 533 connect( mMonthView, SIGNAL(prevMonth() ),
526 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 534 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) );
527 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), 535 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ),
528 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); 536 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) );
529 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), 537 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ),
530 mMainView->dateNavigator(), SLOT( selectNextYear() ) ); 538 mMainView->dateNavigator(), SLOT( selectNextYear() ) );
531 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), 539 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ),
532 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); 540 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) );
533 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), 541 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ),
534 mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); 542 mMainView->dateNavigator(), SLOT( selectNextMonth() ) );
543 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ),
544 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) );
545 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ),
546 mMainView->dateNavigator(), SLOT( selectNextWeek() ) );
535 547
536 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 548 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
537 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); 549 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) );
538 550
539 551
540 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), 552 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ),
541 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); 553 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) );
542 554
543 } 555 }
556}
557void KOViewManager::showMonthViewWeek()
558{
559 createMonthView();
560 bool full = true;
561 if ( mCurrentView == mMonthView)
562 full = mMainView->leftFrame()->isVisible();
563 if ( !KOPrefs::instance()->mMonthViewWeek ) {
564 mMonthView->switchView();
565 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
566 full = false;
567 else
568 full = true;
569 }
570 mMainView->dateNavigator()->selectWeek();
571 showView(mMonthView, full );
572}
573
574void KOViewManager::showMonthView()
575 {
544 576
577 createMonthView();
545 globalFlagBlockAgenda = 1; 578 globalFlagBlockAgenda = 1;
546 //mFlagShowNextxDays = false; 579 //mFlagShowNextxDays = false;
580 bool full = true;
581 if ( mCurrentView == mMonthView)
582 full = mMainView->leftFrame()->isVisible();
547 // if(mMonthView == mCurrentView) return; 583 // if(mMonthView == mCurrentView) return;
548 if ( KOPrefs::instance()->mMonthViewWeek ) 584 if ( KOPrefs::instance()->mMonthViewWeek ) {
549 mMainView->dateNavigator()->selectWeek(); 585 mMonthView->switchView();
586 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
587 full = false;
550 else 588 else
589 full = true;
590 }
551 mMainView->dateNavigator()->selectMonth(); 591 mMainView->dateNavigator()->selectMonth();
552 592
553 showView(mMonthView, true ); 593 showView(mMonthView, full );
554 594
555} 595}
556 596
557void KOViewManager::showTodoView() 597void KOViewManager::showTodoView()
558{ 598{
559 //mFlagShowNextxDays = false; 599 //mFlagShowNextxDays = false;
560 if ( !mTodoView ) { 600 if ( !mTodoView ) {
561 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 601 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
562 "KOViewManager::TodoView" ); 602 "KOViewManager::TodoView" );
563 603
564 addView( mTodoView ); 604 addView( mTodoView );
565 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 605 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
566 606
567 // SIGNALS/SLOTS FOR TODO VIEW 607 // SIGNALS/SLOTS FOR TODO VIEW
568 connect( mTodoView, SIGNAL( newTodoSignal() ), 608 connect( mTodoView, SIGNAL( newTodoSignal() ),
569 mMainView, SLOT( newTodo() ) ); 609 mMainView, SLOT( newTodo() ) );
570 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 610 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
571 mMainView, SLOT( newSubTodo( Todo *) ) ); 611 mMainView, SLOT( newSubTodo( Todo *) ) );
572 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 612 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
573 mMainView, SLOT( showTodo( Todo * ) ) ); 613 mMainView, SLOT( showTodo( Todo * ) ) );
574 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 614 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
575 mMainView, SLOT( editTodo( Todo * ) ) ); 615 mMainView, SLOT( editTodo( Todo * ) ) );
576 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 616 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
577 mMainView, SLOT( deleteTodo( Todo * ) ) ); 617 mMainView, SLOT( deleteTodo( Todo * ) ) );
578 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 618 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
579 mMainView, SLOT( purgeCompleted() ) ); 619 mMainView, SLOT( purgeCompleted() ) );
580 620
581 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 621 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
582 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 622 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
583 623
584 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 624 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
585 SLOT( updateConfig() ) ); 625 SLOT( updateConfig() ) );