Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 85 |
1 files changed, 47 insertions, 38 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 9880e2d..92dbdc8 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -159,25 +159,24 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); | 159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); |
160 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 160 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
161 | a->addTo( sub_bar ); | 161 | a->addTo( sub_bar ); |
162 | 162 | ||
163 | a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); | 163 | a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); |
164 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 164 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
165 | a->addTo( settings ); | 165 | a->addTo( settings ); |
166 | 166 | ||
167 | QPopupMenu *default_view = new QPopupMenu(this); | 167 | QPopupMenu *default_view = new QPopupMenu(this); |
168 | settings->insertItem( tr( "Default View" ),default_view ); | 168 | settings->insertItem( tr( "Default View" ),default_view ); |
169 | default_view->setCheckable(TRUE); | 169 | default_view->setCheckable(TRUE); |
170 | 170 | ||
171 | |||
172 | Config config("DateBook"); | 171 | Config config("DateBook"); |
173 | config.setGroup("Main"); | 172 | config.setGroup("Main"); |
174 | int current=config.readNumEntry("defaultview", DAY); | 173 | int current=config.readNumEntry("defaultview", DAY); |
175 | 174 | ||
176 | QActionGroup *ag = new QActionGroup(this); | 175 | QActionGroup *ag = new QActionGroup(this); |
177 | a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); | 176 | a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); |
178 | if (current==DAY) a->setOn(true), viewDay(); | 177 | if (current==DAY) a->setOn(true), viewDay(); |
179 | ag->insert(a); | 178 | ag->insert(a); |
180 | a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); | 179 | a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); |
181 | if (current==WEEK) a->setOn(true), viewWeek(); | 180 | if (current==WEEK) a->setOn(true), viewWeek(); |
182 | ag->insert(a); | 181 | ag->insert(a); |
183 | a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); | 182 | a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); |
@@ -303,61 +302,74 @@ QDate DateBook::currentDate() | |||
303 | d = dayView->date(); | 302 | d = dayView->date(); |
304 | } else if ( weekView && views->visibleWidget() == weekView ) { | 303 | } else if ( weekView && views->visibleWidget() == weekView ) { |
305 | d = weekView->date(); | 304 | d = weekView->date(); |
306 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { | 305 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { |
307 | d = weekLstView->date(); | 306 | d = weekLstView->date(); |
308 | } else if ( monthView && views->visibleWidget() == monthView ) { | 307 | } else if ( monthView && views->visibleWidget() == monthView ) { |
309 | d = monthView->selectedDate(); | 308 | d = monthView->selectedDate(); |
310 | } | 309 | } |
311 | 310 | ||
312 | return d; | 311 | return d; |
313 | } | 312 | } |
314 | 313 | ||
315 | void DateBook::viewDay() | 314 | void DateBook::view(int v, const QDate &d) { |
316 | { | 315 | if (v==DAY) { |
317 | initDay(); | 316 | initDay(); |
318 | dayAction->setOn( TRUE ); | 317 | dayAction->setOn( TRUE ); |
319 | QDate d = currentDate(); | 318 | dayView->setDate( d ); |
320 | dayView->setDate( d ); | 319 | views->raiseWidget( dayView ); |
321 | views->raiseWidget( dayView ); | 320 | dayView->redraw(); |
322 | dayView->redraw(); | 321 | } else if (v==WEEK) { |
322 | initWeek(); | ||
323 | weekAction->setOn( TRUE ); | ||
324 | weekView->setDate( d ); | ||
325 | views->raiseWidget( weekView ); | ||
326 | weekView->redraw(); | ||
327 | } else if (v==WEEKLST) { | ||
328 | initWeekLst(); | ||
329 | weekLstAction->setOn( TRUE ); | ||
330 | weekLstView->setDate(d); | ||
331 | views->raiseWidget( weekLstView ); | ||
332 | weekLstView->redraw(); | ||
333 | } else if (v==MONTH) { | ||
334 | initMonth(); | ||
335 | monthAction->setOn( TRUE ); | ||
336 | monthView->setDate( d.year(), d.month(), d.day() ); | ||
337 | views->raiseWidget( monthView ); | ||
338 | monthView->redraw(); | ||
339 | } | ||
323 | } | 340 | } |
324 | 341 | ||
325 | void DateBook::viewWeek() | 342 | void DateBook::viewDefault(const QDate &d) { |
326 | { | 343 | Config config("DateBook"); |
327 | initWeek(); | 344 | config.setGroup("Main"); |
328 | weekAction->setOn( TRUE ); | 345 | int current=config.readNumEntry("defaultview", DAY); |
329 | QDate d = currentDate(); | 346 | |
330 | weekView->setDate( d ); | 347 | view(current,d); |
331 | views->raiseWidget( weekView ); | 348 | } |
332 | weekView->redraw(); | 349 | |
350 | void DateBook::viewDay() { | ||
351 | view(DAY,currentDate()); | ||
352 | } | ||
353 | |||
354 | void DateBook::viewWeek() { | ||
355 | view(WEEK,currentDate()); | ||
333 | } | 356 | } |
334 | 357 | ||
335 | void DateBook::viewWeekLst() { | 358 | void DateBook::viewWeekLst() { |
336 | initWeekLst(); | 359 | view(WEEKLST,currentDate()); |
337 | weekLstAction->setOn( TRUE ); | ||
338 | QDate d=currentDate(); | ||
339 | weekLstView->setDate(d); | ||
340 | views->raiseWidget( weekLstView ); | ||
341 | weekLstView->redraw(); | ||
342 | } | 360 | } |
343 | 361 | ||
344 | void DateBook::viewMonth() | 362 | void DateBook::viewMonth() { |
345 | { | 363 | view(MONTH,currentDate()); |
346 | initMonth(); | ||
347 | monthAction->setOn( TRUE ); | ||
348 | QDate d = currentDate(); | ||
349 | monthView->setDate( d.year(), d.month(), d.day() ); | ||
350 | views->raiseWidget( monthView ); | ||
351 | monthView->redraw(); | ||
352 | } | 364 | } |
353 | 365 | ||
354 | void DateBook::editEvent( const Event &e ) | 366 | void DateBook::editEvent( const Event &e ) |
355 | { | 367 | { |
356 | if (syncing) { | 368 | if (syncing) { |
357 | QMessageBox::warning( this, tr("Calendar"), | 369 | QMessageBox::warning( this, tr("Calendar"), |
358 | tr( "Can not edit data, currently syncing") ); | 370 | tr( "Can not edit data, currently syncing") ); |
359 | return; | 371 | return; |
360 | } | 372 | } |
361 | 373 | ||
362 | // workaround added for text input. | 374 | // workaround added for text input. |
363 | QDialog editDlg( this, 0, TRUE ); | 375 | QDialog editDlg( this, 0, TRUE ); |
@@ -409,28 +421,26 @@ void DateBook::removeEvent( const Event &e ) | |||
409 | dayView->redraw(); | 421 | dayView->redraw(); |
410 | } | 422 | } |
411 | 423 | ||
412 | void DateBook::addEvent( const Event &e ) | 424 | void DateBook::addEvent( const Event &e ) |
413 | { | 425 | { |
414 | QDate d = e.start().date(); | 426 | QDate d = e.start().date(); |
415 | initDay(); | 427 | initDay(); |
416 | dayView->setDate( d ); | 428 | dayView->setDate( d ); |
417 | } | 429 | } |
418 | 430 | ||
419 | void DateBook::showDay( int year, int month, int day ) | 431 | void DateBook::showDay( int year, int month, int day ) |
420 | { | 432 | { |
421 | initDay(); | 433 | QDate d(year, month, day); |
422 | dayView->setDate( year, month, day ); | 434 | view(DAY,d); |
423 | views->raiseWidget( dayView ); | ||
424 | dayAction->setOn( TRUE ); | ||
425 | } | 435 | } |
426 | 436 | ||
427 | void DateBook::initDay() | 437 | void DateBook::initDay() |
428 | { | 438 | { |
429 | if ( !dayView ) { | 439 | if ( !dayView ) { |
430 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); | 440 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); |
431 | views->addWidget( dayView, DAY ); | 441 | views->addWidget( dayView, DAY ); |
432 | dayView->setStartViewTime( startTime ); | 442 | dayView->setStartViewTime( startTime ); |
433 | connect( this, SIGNAL( newEvent() ), | 443 | connect( this, SIGNAL( newEvent() ), |
434 | dayView, SLOT( redraw() ) ); | 444 | dayView, SLOT( redraw() ) ); |
435 | connect( dayView, SIGNAL( newEvent() ), | 445 | connect( dayView, SIGNAL( newEvent() ), |
436 | this, SLOT( fileNew() ) ); | 446 | this, SLOT( fileNew() ) ); |
@@ -680,27 +690,26 @@ void DateBook::changeClock( bool newClock ) | |||
680 | if (weekLstView) weekLstView->redraw(); | 690 | if (weekLstView) weekLstView->redraw(); |
681 | } | 691 | } |
682 | 692 | ||
683 | void DateBook::changeWeek( bool m ) | 693 | void DateBook::changeWeek( bool m ) |
684 | { | 694 | { |
685 | /* no need to redraw, each widget catches. Do need to | 695 | /* no need to redraw, each widget catches. Do need to |
686 | store though for widgets we haven't made yet */ | 696 | store though for widgets we haven't made yet */ |
687 | onMonday = m; | 697 | onMonday = m; |
688 | } | 698 | } |
689 | 699 | ||
690 | void DateBook::slotToday() | 700 | void DateBook::slotToday() |
691 | { | 701 | { |
692 | // we need to view today | 702 | // we need to view today using default view |
693 | QDate dt = QDate::currentDate(); | 703 | viewDefault(QDate::currentDate()); |
694 | showDay( dt.year(), dt.month(), dt.day() ); | ||
695 | } | 704 | } |
696 | 705 | ||
697 | void DateBook::closeEvent( QCloseEvent *e ) | 706 | void DateBook::closeEvent( QCloseEvent *e ) |
698 | { | 707 | { |
699 | if(syncing) { | 708 | if(syncing) { |
700 | /* no need to save, did that at flush */ | 709 | /* no need to save, did that at flush */ |
701 | e->accept(); | 710 | e->accept(); |
702 | return; | 711 | return; |
703 | } | 712 | } |
704 | 713 | ||
705 | // save settings will generate it's own error messages, no | 714 | // save settings will generate it's own error messages, no |
706 | // need to do checking ourselves. | 715 | // need to do checking ourselves. |