Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 106 |
1 files changed, 98 insertions, 8 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index e8d808f..9880e2d 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -28,2 +28,3 @@ #include "datebookweek.h" +#include "datebookweeklst.h" #include "dateentryimpl.h" @@ -71,2 +72,3 @@ #define WEEK 2 +#define WEEKLST 4 #define MONTH 3 @@ -92,2 +94,10 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) + views = new QWidgetStack( this ); + setCentralWidget( views ); + + dayView = 0; + weekView = 0; + weekLstView = 0; + monthView = 0; + QPEToolBar *bar = new QPEToolBar( this ); @@ -126,2 +136,3 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) dayAction = a; + a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); @@ -132,2 +143,10 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) weekAction = a; + + a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 ); + connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); + a->addTo( sub_bar ); + a->addTo( view ); + a->setToggleAction( TRUE ); + weekLstAction = a; + a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); @@ -147,10 +166,30 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) - views = new QWidgetStack( this ); - setCentralWidget( views ); + QPopupMenu *default_view = new QPopupMenu(this); + settings->insertItem( tr( "Default View" ),default_view ); + default_view->setCheckable(TRUE); - dayView = 0; - weekView = 0; - monthView = 0; - viewDay(); + 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 ); + if (current==WEEKLST) a->setOn(true), viewWeekLst(); + ag->insert(a); + a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); + if (current==MONTH) a->setOn(true), viewMonth(); + ag->insert(a); + + ag->addTo(default_view); + connect(ag, SIGNAL( selected ( QAction * ) ), + this, SLOT( newDefaultView(QAction *) ) + ); + connect( qApp, SIGNAL(clockChanged(bool)), @@ -266,2 +305,4 @@ QDate DateBook::currentDate() d = weekView->date(); + } else if ( weekLstView && views->visibleWidget() == weekLstView ) { + d = weekLstView->date(); } else if ( monthView && views->visibleWidget() == monthView ) { @@ -293,2 +334,11 @@ void DateBook::viewWeek() +void DateBook::viewWeekLst() { + initWeekLst(); + weekLstAction->setOn( TRUE ); + QDate d=currentDate(); + weekLstView->setDate(d); + views->raiseWidget( weekLstView ); + weekLstView->redraw(); +} + void DateBook::viewMonth() @@ -333,3 +383,4 @@ void DateBook::editEvent( const Event &e ) if (QMessageBox::warning(this, "error box", - error, "Fix it", "Continue", 0, 0, 1) == 0) + error, "Fix it", "Continue", + 0, 0, 1) == 0) continue; @@ -424,2 +475,24 @@ void DateBook::initWeek() } +void DateBook::initWeekLst() { + if ( !weekLstView ) { + weekLstView = new DateBookWeekLst( ampm, onMonday, db, + views, "weeklst view" ); + views->addWidget( weekLstView, WEEKLST ); + + //weekLstView->setStartViewTime( startTime ); + connect( weekLstView, SIGNAL( showDate( int, int, int ) ), + this, SLOT( showDay( int, int, int ) ) ); + connect( weekLstView, SIGNAL( addEvent( const QDateTime &, + const QDateTime &, + const QString & ) ), + this, SLOT( slotNewEntry( const QDateTime &, + const QDateTime &, + const QString & ) ) ); + connect( this, SIGNAL( newEvent() ), + weekLstView, SLOT( redraw() ) ); + connect( weekLstView, SIGNAL( editEvent( const Event & ) ), + this, SLOT( editEvent( const Event & ) ) ); + } +} + @@ -466,2 +539,14 @@ void DateBook::saveSettings() +void DateBook::newDefaultView(QAction *a) { + int val=DAY; + if (a->text() == "Day") val=DAY; + if (a->text() == "Week") val=WEEK; + if (a->text() == "WeekLst") val=WEEKLST; + if (a->text() == "Month") val=MONTH; + + Config configDB( "DateBook" ); + configDB.setGroup( "Main" ); + configDB.writeEntry("defaultview",val); +} + void DateBook::appMessage(const QCString& msg, const QByteArray& data) @@ -538,2 +623,4 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data) else if ( cur == weekView ) + viewWeekLst(); + else if ( cur == weekLstView ) viewMonth(); @@ -592,2 +679,3 @@ void DateBook::changeClock( bool newClock ) if (weekView) weekView->redraw(); + if (weekLstView) weekLstView->redraw(); } @@ -662,3 +750,5 @@ void DateBook::slotNewEventFromKey( const QString &str ) } - + slotNewEntry(start, end, str); +} +void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { // argh! This really needs to be encapsulated in a class |