Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 59 |
1 files changed, 34 insertions, 25 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 ) a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); a->addTo( sub_bar ); a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); a->addTo( settings ); QPopupMenu *default_view = new QPopupMenu(this); settings->insertItem( tr( "Default View" ),default_view ); default_view->setCheckable(TRUE); - Config config("DateBook"); config.setGroup("Main"); int current=config.readNumEntry("defaultview", DAY); QActionGroup *ag = new QActionGroup(this); a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); if (current==DAY) a->setOn(true), viewDay(); ag->insert(a); a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); if (current==WEEK) a->setOn(true), viewWeek(); ag->insert(a); a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); @@ -303,62 +302,75 @@ QDate DateBook::currentDate() d = dayView->date(); } else if ( weekView && views->visibleWidget() == weekView ) { d = weekView->date(); } else if ( weekLstView && views->visibleWidget() == weekLstView ) { d = weekLstView->date(); } else if ( monthView && views->visibleWidget() == monthView ) { d = monthView->selectedDate(); } return d; } -void DateBook::viewDay() -{ +void DateBook::view(int v, const QDate &d) { + if (v==DAY) { initDay(); dayAction->setOn( TRUE ); - QDate d = currentDate(); dayView->setDate( d ); views->raiseWidget( dayView ); dayView->redraw(); -} - -void DateBook::viewWeek() -{ + } else if (v==WEEK) { initWeek(); weekAction->setOn( TRUE ); - QDate d = currentDate(); weekView->setDate( d ); views->raiseWidget( weekView ); weekView->redraw(); -} - -void DateBook::viewWeekLst() { + } else if (v==WEEKLST) { initWeekLst(); weekLstAction->setOn( TRUE ); - QDate d=currentDate(); weekLstView->setDate(d); views->raiseWidget( weekLstView ); weekLstView->redraw(); -} - -void DateBook::viewMonth() -{ + } else if (v==MONTH) { initMonth(); monthAction->setOn( TRUE ); - QDate d = currentDate(); monthView->setDate( d.year(), d.month(), d.day() ); views->raiseWidget( monthView ); monthView->redraw(); } +} + +void DateBook::viewDefault(const QDate &d) { + Config config("DateBook"); + config.setGroup("Main"); + int current=config.readNumEntry("defaultview", DAY); + + view(current,d); +} + +void DateBook::viewDay() { + view(DAY,currentDate()); +} + +void DateBook::viewWeek() { + view(WEEK,currentDate()); +} + +void DateBook::viewWeekLst() { + view(WEEKLST,currentDate()); +} + +void DateBook::viewMonth() { + view(MONTH,currentDate()); +} void DateBook::editEvent( const Event &e ) { if (syncing) { QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); return; } // workaround added for text input. QDialog editDlg( this, 0, TRUE ); DateEntry *entry; @@ -409,28 +421,26 @@ void DateBook::removeEvent( const Event &e ) dayView->redraw(); } void DateBook::addEvent( const Event &e ) { QDate d = e.start().date(); initDay(); dayView->setDate( d ); } void DateBook::showDay( int year, int month, int day ) { - initDay(); - dayView->setDate( year, month, day ); - views->raiseWidget( dayView ); - dayAction->setOn( TRUE ); + QDate d(year, month, day); + view(DAY,d); } void DateBook::initDay() { if ( !dayView ) { dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); views->addWidget( dayView, DAY ); dayView->setStartViewTime( startTime ); connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); @@ -680,27 +690,26 @@ void DateBook::changeClock( bool newClock ) if (weekLstView) weekLstView->redraw(); } void DateBook::changeWeek( bool m ) { /* no need to redraw, each widget catches. Do need to store though for widgets we haven't made yet */ onMonday = m; } void DateBook::slotToday() { - // we need to view today - QDate dt = QDate::currentDate(); - showDay( dt.year(), dt.month(), dt.day() ); + // we need to view today using default view + viewDefault(QDate::currentDate()); } void DateBook::closeEvent( QCloseEvent *e ) { if(syncing) { /* no need to save, did that at flush */ e->accept(); return; } // save settings will generate it's own error messages, no // need to do checking ourselves. |