author | hakan <hakan> | 2002-03-09 13:07:57 (UTC) |
---|---|---|
committer | hakan <hakan> | 2002-03-09 13:07:57 (UTC) |
commit | 62c21e8bdbb365a64f05dd363a98abd7fc1f0558 (patch) (unidiff) | |
tree | bde5aec77cc0c22a4240b16f0fc4acc41b2d162f /core/pim/datebook | |
parent | 603e969bb8cef91534a1785e27106ba71eb03ba6 (diff) | |
download | opie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.zip opie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.tar.gz opie-62c21e8bdbb365a64f05dd363a98abd7fc1f0558.tar.bz2 |
Fixed today-button to show default view
-rw-r--r-- | core/pim/datebook/datebook.cpp | 59 | ||||
-rw-r--r-- | core/pim/datebook/datebook.h | 4 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 4 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.h | 4 |
4 files changed, 42 insertions, 29 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 | |||
@@ -165,13 +165,12 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
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 ); |
@@ -309,50 +308,63 @@ QDate DateBook::currentDate() | |||
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(); | ||
320 | dayView->setDate( d ); | 318 | dayView->setDate( d ); |
321 | views->raiseWidget( dayView ); | 319 | views->raiseWidget( dayView ); |
322 | dayView->redraw(); | 320 | dayView->redraw(); |
323 | } | 321 | } else if (v==WEEK) { |
324 | |||
325 | void DateBook::viewWeek() | ||
326 | { | ||
327 | initWeek(); | 322 | initWeek(); |
328 | weekAction->setOn( TRUE ); | 323 | weekAction->setOn( TRUE ); |
329 | QDate d = currentDate(); | ||
330 | weekView->setDate( d ); | 324 | weekView->setDate( d ); |
331 | views->raiseWidget( weekView ); | 325 | views->raiseWidget( weekView ); |
332 | weekView->redraw(); | 326 | weekView->redraw(); |
333 | } | 327 | } else if (v==WEEKLST) { |
334 | |||
335 | void DateBook::viewWeekLst() { | ||
336 | initWeekLst(); | 328 | initWeekLst(); |
337 | weekLstAction->setOn( TRUE ); | 329 | weekLstAction->setOn( TRUE ); |
338 | QDate d=currentDate(); | ||
339 | weekLstView->setDate(d); | 330 | weekLstView->setDate(d); |
340 | views->raiseWidget( weekLstView ); | 331 | views->raiseWidget( weekLstView ); |
341 | weekLstView->redraw(); | 332 | weekLstView->redraw(); |
342 | } | 333 | } else if (v==MONTH) { |
343 | |||
344 | void DateBook::viewMonth() | ||
345 | { | ||
346 | initMonth(); | 334 | initMonth(); |
347 | monthAction->setOn( TRUE ); | 335 | monthAction->setOn( TRUE ); |
348 | QDate d = currentDate(); | ||
349 | monthView->setDate( d.year(), d.month(), d.day() ); | 336 | monthView->setDate( d.year(), d.month(), d.day() ); |
350 | views->raiseWidget( monthView ); | 337 | views->raiseWidget( monthView ); |
351 | monthView->redraw(); | 338 | monthView->redraw(); |
352 | } | 339 | } |
340 | } | ||
341 | |||
342 | void DateBook::viewDefault(const QDate &d) { | ||
343 | Config config("DateBook"); | ||
344 | config.setGroup("Main"); | ||
345 | int current=config.readNumEntry("defaultview", DAY); | ||
346 | |||
347 | view(current,d); | ||
348 | } | ||
349 | |||
350 | void DateBook::viewDay() { | ||
351 | view(DAY,currentDate()); | ||
352 | } | ||
353 | |||
354 | void DateBook::viewWeek() { | ||
355 | view(WEEK,currentDate()); | ||
356 | } | ||
357 | |||
358 | void DateBook::viewWeekLst() { | ||
359 | view(WEEKLST,currentDate()); | ||
360 | } | ||
361 | |||
362 | void DateBook::viewMonth() { | ||
363 | view(MONTH,currentDate()); | ||
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") ); |
@@ -415,16 +427,14 @@ void DateBook::addEvent( const Event &e ) | |||
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" ); |
@@ -686,15 +696,14 @@ void DateBook::changeWeek( bool m ) | |||
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 */ |
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index fcdbfec..2ffcdbe 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h | |||
@@ -49,12 +49,14 @@ signals: | |||
49 | 49 | ||
50 | protected: | 50 | protected: |
51 | QDate currentDate(); | 51 | QDate currentDate(); |
52 | void timerEvent( QTimerEvent *e ); | 52 | void timerEvent( QTimerEvent *e ); |
53 | void closeEvent( QCloseEvent *e ); | 53 | void closeEvent( QCloseEvent *e ); |
54 | 54 | ||
55 | void view(int v, const QDate &d); | ||
56 | |||
55 | public slots: | 57 | public slots: |
56 | void flush(); | 58 | void flush(); |
57 | void reload(); | 59 | void reload(); |
58 | 60 | ||
59 | private slots: | 61 | private slots: |
60 | void fileNew(); | 62 | void fileNew(); |
@@ -67,12 +69,14 @@ private slots: | |||
67 | void appMessage(const QCString& msg, const QByteArray& data); | 69 | void appMessage(const QCString& msg, const QByteArray& data); |
68 | // handle key events in the day view... | 70 | // handle key events in the day view... |
69 | void slotNewEventFromKey( const QString &str ); | 71 | void slotNewEventFromKey( const QString &str ); |
70 | void slotFind(); | 72 | void slotFind(); |
71 | void slotDoFind( const QString &, const QDate &, bool, bool, int ); | 73 | void slotDoFind( const QString &, const QDate &, bool, bool, int ); |
72 | 74 | ||
75 | void viewDefault(const QDate &d); | ||
76 | |||
73 | void viewDay(); | 77 | void viewDay(); |
74 | void viewWeek(); | 78 | void viewWeek(); |
75 | void viewWeekLst(); | 79 | void viewWeekLst(); |
76 | void viewMonth(); | 80 | void viewMonth(); |
77 | 81 | ||
78 | void showDay( int y, int m, int d ); | 82 | void showDay( int y, int m, int d ); |
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 05e36be..dc141c0 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp | |||
@@ -43,13 +43,13 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, | |||
43 | connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); | 43 | connect(back, SIGNAL(clicked()), this, SLOT(prevWeek())); |
44 | connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); | 44 | connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek())); |
45 | connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); | 45 | connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate())); |
46 | onMonday=onM; | 46 | onMonday=onM; |
47 | } | 47 | } |
48 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} | 48 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} |
49 | void DateBookWeekLstHeader::setDate(QDate d) { | 49 | void DateBookWeekLstHeader::setDate(const QDate &d) { |
50 | date=d; | 50 | date=d; |
51 | 51 | ||
52 | int year,week; | 52 | int year,week; |
53 | calcWeek(d,week,year,onMonday); | 53 | calcWeek(d,week,year,onMonday); |
54 | labelWeek->setText("W: " + QString::number(week)); | 54 | labelWeek->setText("W: " + QString::number(week)); |
55 | 55 | ||
@@ -239,13 +239,13 @@ DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | |||
239 | layout->addWidget(scroll); | 239 | layout->addWidget(scroll); |
240 | 240 | ||
241 | view=NULL; | 241 | view=NULL; |
242 | } | 242 | } |
243 | 243 | ||
244 | 244 | ||
245 | void DateBookWeekLst::setDate( QDate &d ) { | 245 | void DateBookWeekLst::setDate(const QDate &d) { |
246 | int w,y; | 246 | int w,y; |
247 | calcWeek(d,w,y,onMonday); | 247 | calcWeek(d,w,y,onMonday); |
248 | year=y; | 248 | year=y; |
249 | _week=w; | 249 | _week=w; |
250 | header->setDate(date()); | 250 | header->setDate(date()); |
251 | } | 251 | } |
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h index d2a07cc..39c956d 100644 --- a/core/pim/datebook/datebookweeklst.h +++ b/core/pim/datebook/datebookweeklst.h | |||
@@ -19,13 +19,13 @@ class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase | |||
19 | { | 19 | { |
20 | Q_OBJECT | 20 | Q_OBJECT |
21 | public: | 21 | public: |
22 | DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, | 22 | DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0, |
23 | WFlags fl = 0 ); | 23 | WFlags fl = 0 ); |
24 | ~DateBookWeekLstHeader(); | 24 | ~DateBookWeekLstHeader(); |
25 | void setDate(QDate d); | 25 | void setDate(const QDate &d); |
26 | 26 | ||
27 | public slots: | 27 | public slots: |
28 | void nextWeek(); | 28 | void nextWeek(); |
29 | void prevWeek(); | 29 | void prevWeek(); |
30 | void pickDate(); | 30 | void pickDate(); |
31 | void setDate(int y, int m, int d); | 31 | void setDate(int y, int m, int d); |
@@ -94,13 +94,13 @@ class DateBookWeekLst : public QWidget | |||
94 | 94 | ||
95 | public: | 95 | public: |
96 | DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, | 96 | DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB, |
97 | QWidget *parent = 0, | 97 | QWidget *parent = 0, |
98 | const char *name = 0 ); | 98 | const char *name = 0 ); |
99 | void setDate( int y, int w ); | 99 | void setDate( int y, int w ); |
100 | void setDate( QDate &d ); | 100 | void setDate(const QDate &d ); |
101 | int week() const { return _week; }; | 101 | int week() const { return _week; }; |
102 | QDate date() const; | 102 | QDate date() const; |
103 | 103 | ||
104 | public slots: | 104 | public slots: |
105 | void redraw(); | 105 | void redraw(); |
106 | void dateChanged(int y, int w); | 106 | void dateChanged(int y, int w); |