author | hakan <hakan> | 2002-03-09 11:39:21 (UTC) |
---|---|---|
committer | hakan <hakan> | 2002-03-09 11:39:21 (UTC) |
commit | 603e969bb8cef91534a1785e27106ba71eb03ba6 (patch) (unidiff) | |
tree | 20642ed29acb08ab0cecc1dffd1d63baa8914ae2 /core/pim/datebook/datebook.cpp | |
parent | 3d03d0e3f679578080bbbf7d8b7f9eba1b9560db (diff) | |
download | opie-603e969bb8cef91534a1785e27106ba71eb03ba6.zip opie-603e969bb8cef91534a1785e27106ba71eb03ba6.tar.gz opie-603e969bb8cef91534a1785e27106ba71eb03ba6.tar.bz2 |
Added a WeekLst view showing an entire week and appointment descriptions and made default view configurable
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 | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "datebookday.h" | 26 | #include "datebookday.h" |
27 | #include "datebooksettings.h" | 27 | #include "datebooksettings.h" |
28 | #include "datebookweek.h" | 28 | #include "datebookweek.h" |
29 | #include "datebookweeklst.h" | ||
29 | #include "dateentryimpl.h" | 30 | #include "dateentryimpl.h" |
30 | 31 | ||
31 | #include <qpe/datebookmonth.h> | 32 | #include <qpe/datebookmonth.h> |
@@ -69,6 +70,7 @@ | |||
69 | 70 | ||
70 | #define DAY 1 | 71 | #define DAY 1 |
71 | #define WEEK 2 | 72 | #define WEEK 2 |
73 | #define WEEKLST 4 | ||
72 | #define MONTH 3 | 74 | #define MONTH 3 |
73 | 75 | ||
74 | 76 | ||
@@ -90,6 +92,14 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
90 | 92 | ||
91 | setToolBarsMovable( FALSE ); | 93 | setToolBarsMovable( FALSE ); |
92 | 94 | ||
95 | views = new QWidgetStack( this ); | ||
96 | setCentralWidget( views ); | ||
97 | |||
98 | dayView = 0; | ||
99 | weekView = 0; | ||
100 | weekLstView = 0; | ||
101 | monthView = 0; | ||
102 | |||
93 | QPEToolBar *bar = new QPEToolBar( this ); | 103 | QPEToolBar *bar = new QPEToolBar( this ); |
94 | bar->setHorizontalStretchable( TRUE ); | 104 | bar->setHorizontalStretchable( TRUE ); |
95 | 105 | ||
@@ -124,12 +134,21 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
124 | a->setToggleAction( TRUE ); | 134 | a->setToggleAction( TRUE ); |
125 | a->setOn( TRUE ); | 135 | a->setOn( TRUE ); |
126 | dayAction = a; | 136 | dayAction = a; |
137 | |||
127 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); | 138 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); |
128 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); | 139 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); |
129 | a->addTo( sub_bar ); | 140 | a->addTo( sub_bar ); |
130 | a->addTo( view ); | 141 | a->addTo( view ); |
131 | a->setToggleAction( TRUE ); | 142 | a->setToggleAction( TRUE ); |
132 | weekAction = a; | 143 | weekAction = a; |
144 | |||
145 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 ); | ||
146 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); | ||
147 | a->addTo( sub_bar ); | ||
148 | a->addTo( view ); | ||
149 | a->setToggleAction( TRUE ); | ||
150 | weekLstAction = a; | ||
151 | |||
133 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); | 152 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); |
134 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); | 153 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); |
135 | a->addTo( sub_bar ); | 154 | a->addTo( sub_bar ); |
@@ -145,14 +164,34 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
145 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 164 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
146 | a->addTo( settings ); | 165 | a->addTo( settings ); |
147 | 166 | ||
148 | views = new QWidgetStack( this ); | 167 | QPopupMenu *default_view = new QPopupMenu(this); |
149 | setCentralWidget( views ); | 168 | settings->insertItem( tr( "Default View" ),default_view ); |
169 | default_view->setCheckable(TRUE); | ||
150 | 170 | ||
151 | dayView = 0; | ||
152 | weekView = 0; | ||
153 | monthView = 0; | ||
154 | 171 | ||
155 | viewDay(); | 172 | Config config("DateBook"); |
173 | config.setGroup("Main"); | ||
174 | int current=config.readNumEntry("defaultview", DAY); | ||
175 | |||
176 | QActionGroup *ag = new QActionGroup(this); | ||
177 | a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); | ||
178 | if (current==DAY) a->setOn(true), viewDay(); | ||
179 | ag->insert(a); | ||
180 | a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); | ||
181 | if (current==WEEK) a->setOn(true), viewWeek(); | ||
182 | ag->insert(a); | ||
183 | a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); | ||
184 | if (current==WEEKLST) a->setOn(true), viewWeekLst(); | ||
185 | ag->insert(a); | ||
186 | a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); | ||
187 | if (current==MONTH) a->setOn(true), viewMonth(); | ||
188 | ag->insert(a); | ||
189 | |||
190 | ag->addTo(default_view); | ||
191 | connect(ag, SIGNAL( selected ( QAction * ) ), | ||
192 | this, SLOT( newDefaultView(QAction *) ) | ||
193 | ); | ||
194 | |||
156 | connect( qApp, SIGNAL(clockChanged(bool)), | 195 | connect( qApp, SIGNAL(clockChanged(bool)), |
157 | this, SLOT(changeClock(bool)) ); | 196 | this, SLOT(changeClock(bool)) ); |
158 | connect( qApp, SIGNAL(weekChanged(bool)), | 197 | connect( qApp, SIGNAL(weekChanged(bool)), |
@@ -264,6 +303,8 @@ QDate DateBook::currentDate() | |||
264 | d = dayView->date(); | 303 | d = dayView->date(); |
265 | } else if ( weekView && views->visibleWidget() == weekView ) { | 304 | } else if ( weekView && views->visibleWidget() == weekView ) { |
266 | d = weekView->date(); | 305 | d = weekView->date(); |
306 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { | ||
307 | d = weekLstView->date(); | ||
267 | } else if ( monthView && views->visibleWidget() == monthView ) { | 308 | } else if ( monthView && views->visibleWidget() == monthView ) { |
268 | d = monthView->selectedDate(); | 309 | d = monthView->selectedDate(); |
269 | } | 310 | } |
@@ -291,6 +332,15 @@ void DateBook::viewWeek() | |||
291 | weekView->redraw(); | 332 | weekView->redraw(); |
292 | } | 333 | } |
293 | 334 | ||
335 | void DateBook::viewWeekLst() { | ||
336 | initWeekLst(); | ||
337 | weekLstAction->setOn( TRUE ); | ||
338 | QDate d=currentDate(); | ||
339 | weekLstView->setDate(d); | ||
340 | views->raiseWidget( weekLstView ); | ||
341 | weekLstView->redraw(); | ||
342 | } | ||
343 | |||
294 | void DateBook::viewMonth() | 344 | void DateBook::viewMonth() |
295 | { | 345 | { |
296 | initMonth(); | 346 | initMonth(); |
@@ -331,7 +381,8 @@ void DateBook::editEvent( const Event &e ) | |||
331 | QString error = checkEvent(newEv); | 381 | QString error = checkEvent(newEv); |
332 | if (!error.isNull()) { | 382 | if (!error.isNull()) { |
333 | if (QMessageBox::warning(this, "error box", | 383 | if (QMessageBox::warning(this, "error box", |
334 | error, "Fix it", "Continue", 0, 0, 1) == 0) | 384 | error, "Fix it", "Continue", |
385 | 0, 0, 1) == 0) | ||
335 | continue; | 386 | continue; |
336 | } | 387 | } |
337 | db->editEvent(e, newEv); | 388 | db->editEvent(e, newEv); |
@@ -422,6 +473,28 @@ void DateBook::initWeek() | |||
422 | if ( totWeeks != weekView->totalWeeks() ) | 473 | if ( totWeeks != weekView->totalWeeks() ) |
423 | weekView->setTotalWeeks( totWeeks ); | 474 | weekView->setTotalWeeks( totWeeks ); |
424 | } | 475 | } |
476 | void DateBook::initWeekLst() { | ||
477 | if ( !weekLstView ) { | ||
478 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, | ||
479 | views, "weeklst view" ); | ||
480 | views->addWidget( weekLstView, WEEKLST ); | ||
481 | |||
482 | //weekLstView->setStartViewTime( startTime ); | ||
483 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), | ||
484 | this, SLOT( showDay( int, int, int ) ) ); | ||
485 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, | ||
486 | const QDateTime &, | ||
487 | const QString & ) ), | ||
488 | this, SLOT( slotNewEntry( const QDateTime &, | ||
489 | const QDateTime &, | ||
490 | const QString & ) ) ); | ||
491 | connect( this, SIGNAL( newEvent() ), | ||
492 | weekLstView, SLOT( redraw() ) ); | ||
493 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), | ||
494 | this, SLOT( editEvent( const Event & ) ) ); | ||
495 | } | ||
496 | } | ||
497 | |||
425 | 498 | ||
426 | void DateBook::initMonth() | 499 | void DateBook::initMonth() |
427 | { | 500 | { |
@@ -464,6 +537,18 @@ void DateBook::saveSettings() | |||
464 | configDB.writeEntry("presettime",presetTime); | 537 | configDB.writeEntry("presettime",presetTime); |
465 | } | 538 | } |
466 | 539 | ||
540 | void DateBook::newDefaultView(QAction *a) { | ||
541 | int val=DAY; | ||
542 | if (a->text() == "Day") val=DAY; | ||
543 | if (a->text() == "Week") val=WEEK; | ||
544 | if (a->text() == "WeekLst") val=WEEKLST; | ||
545 | if (a->text() == "Month") val=MONTH; | ||
546 | |||
547 | Config configDB( "DateBook" ); | ||
548 | configDB.setGroup( "Main" ); | ||
549 | configDB.writeEntry("defaultview",val); | ||
550 | } | ||
551 | |||
467 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) | 552 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) |
468 | { | 553 | { |
469 | bool needShow = FALSE; | 554 | bool needShow = FALSE; |
@@ -536,6 +621,8 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data) | |||
536 | if ( cur == dayView ) | 621 | if ( cur == dayView ) |
537 | viewWeek(); | 622 | viewWeek(); |
538 | else if ( cur == weekView ) | 623 | else if ( cur == weekView ) |
624 | viewWeekLst(); | ||
625 | else if ( cur == weekLstView ) | ||
539 | viewMonth(); | 626 | viewMonth(); |
540 | else if ( cur == monthView ) | 627 | else if ( cur == monthView ) |
541 | viewDay(); | 628 | viewDay(); |
@@ -590,6 +677,7 @@ void DateBook::changeClock( bool newClock ) | |||
590 | // repaint the affected objects... | 677 | // repaint the affected objects... |
591 | if (dayView) dayView->redraw(); | 678 | if (dayView) dayView->redraw(); |
592 | if (weekView) weekView->redraw(); | 679 | if (weekView) weekView->redraw(); |
680 | if (weekLstView) weekLstView->redraw(); | ||
593 | } | 681 | } |
594 | 682 | ||
595 | void DateBook::changeWeek( bool m ) | 683 | void DateBook::changeWeek( bool m ) |
@@ -660,7 +748,9 @@ void DateBook::slotNewEventFromKey( const QString &str ) | |||
660 | start.setTime( QTime( 10, 0 ) ); | 748 | start.setTime( QTime( 10, 0 ) ); |
661 | end.setTime( QTime( 12, 0 ) ); | 749 | end.setTime( QTime( 12, 0 ) ); |
662 | } | 750 | } |
663 | 751 | slotNewEntry(start, end, str); | |
752 | } | ||
753 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { | ||
664 | // argh! This really needs to be encapsulated in a class | 754 | // argh! This really needs to be encapsulated in a class |
665 | // or function. | 755 | // or function. |
666 | QDialog newDlg( this, 0, TRUE ); | 756 | QDialog newDlg( this, 0, TRUE ); |