-rw-r--r-- | core/pim/datebook/datebook.cpp | 5 | ||||
-rw-r--r-- | core/pim/datebook/datebook.h | 4 | ||||
-rw-r--r-- | core/pim/datebook/datebook.pro | 2 | ||||
-rw-r--r-- | core/pim/datebook/modules/monthview/odatebookmonth.cpp | 392 | ||||
-rw-r--r-- | core/pim/datebook/modules/monthview/odatebookmonth.h | 132 |
5 files changed, 531 insertions, 4 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 0579279..cc7bf4b 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -6,57 +6,58 @@ | |||
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | ** $Id$ | 19 | ** $Id$ |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | 22 | ||
23 | #define QTOPIA_INTERNAL_FD | 23 | #define QTOPIA_INTERNAL_FD |
24 | 24 | ||
25 | #include "datebook.h" | 25 | #include "datebook.h" |
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 "modules/weeklst/datebookweeklst.h" | 29 | #include "modules/weeklst/datebookweeklst.h" |
30 | #include "modules/monthview/odatebookmonth.h" | ||
30 | #include "dateentryimpl.h" | 31 | #include "dateentryimpl.h" |
31 | 32 | ||
32 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
33 | #include <opie2/oholidaypluginif.h> | 34 | #include <opie2/oholidaypluginif.h> |
34 | #include <opie2/oholidayplugin.h> | 35 | #include <opie2/oholidayplugin.h> |
35 | #include <opie2/opluginloader.h> | 36 | #include <opie2/opluginloader.h> |
36 | #include <opie2/todayplugininterface.h> | 37 | #include <opie2/todayplugininterface.h> |
37 | 38 | ||
38 | #include <qpe/datebookmonth.h> | 39 | //#include <qpe/datebookmonth.h> |
39 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
40 | #include <qpe/config.h> | 41 | #include <qpe/config.h> |
41 | #include <qpe/finddialog.h> | 42 | #include <qpe/finddialog.h> |
42 | #include <qpe/ir.h> | 43 | #include <qpe/ir.h> |
43 | #include <qpe/qpemessagebox.h> | 44 | #include <qpe/qpemessagebox.h> |
44 | #include <qpe/resource.h> | 45 | #include <qpe/resource.h> |
45 | #include <qpe/sound.h> | 46 | #include <qpe/sound.h> |
46 | #include <qpe/tzselect.h> | 47 | #include <qpe/tzselect.h> |
47 | #include <qtopia/qlibrary.h> | 48 | #include <qtopia/qlibrary.h> |
48 | 49 | ||
49 | #include <qaction.h> | 50 | #include <qaction.h> |
50 | #include <qcopchannel_qws.h> | 51 | #include <qcopchannel_qws.h> |
51 | #include <qlayout.h> | 52 | #include <qlayout.h> |
52 | #include <qmessagebox.h> | 53 | #include <qmessagebox.h> |
53 | #include <qtimer.h> | 54 | #include <qtimer.h> |
54 | #include <qtl.h> | 55 | #include <qtl.h> |
55 | #include <qtoolbar.h> | 56 | #include <qtoolbar.h> |
56 | #include <qwidgetstack.h> | 57 | #include <qwidgetstack.h> |
57 | #include <qdir.h> | 58 | #include <qdir.h> |
58 | #include <qlabel.h> | 59 | #include <qlabel.h> |
59 | 60 | ||
60 | #include <sys/stat.h> | 61 | #include <sys/stat.h> |
61 | #include <sys/types.h> | 62 | #include <sys/types.h> |
62 | #include <fcntl.h> | 63 | #include <fcntl.h> |
@@ -568,49 +569,49 @@ void DateBook::initWeek() | |||
568 | } | 569 | } |
569 | } | 570 | } |
570 | 571 | ||
571 | void DateBook::initWeekLst() { | 572 | void DateBook::initWeekLst() { |
572 | if ( !weekLstView ) { | 573 | if ( !weekLstView ) { |
573 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); | 574 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); |
574 | views->addWidget( weekLstView, WEEKLST ); | 575 | views->addWidget( weekLstView, WEEKLST ); |
575 | 576 | ||
576 | //weekLstView->setStartViewTime( startTime ); | 577 | //weekLstView->setStartViewTime( startTime ); |
577 | connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); | 578 | connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); |
578 | connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), | 579 | connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ), |
579 | this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); | 580 | this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) ); |
580 | connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); | 581 | connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); |
581 | connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); | 582 | connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); |
582 | connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); | 583 | connect( weekLstView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); |
583 | connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); | 584 | connect( weekLstView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); |
584 | connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); | 585 | connect( weekLstView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); |
585 | } | 586 | } |
586 | } | 587 | } |
587 | 588 | ||
588 | 589 | ||
589 | void DateBook::initMonth() | 590 | void DateBook::initMonth() |
590 | { | 591 | { |
591 | if ( !monthView ) { | 592 | if ( !monthView ) { |
592 | monthView = new DateBookMonth( views, "month view", FALSE, db ); | 593 | monthView = new ODateBookMonth( views, "month view", FALSE, db ); |
593 | views->addWidget( monthView, MONTH ); | 594 | views->addWidget( monthView, MONTH ); |
594 | connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); | 595 | connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); |
595 | connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); | 596 | connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); |
596 | qApp->processEvents(); | 597 | qApp->processEvents(); |
597 | } | 598 | } |
598 | } | 599 | } |
599 | 600 | ||
600 | void DateBook::loadSettings() | 601 | void DateBook::loadSettings() |
601 | { | 602 | { |
602 | Config qpeconfig( "qpe" ); | 603 | Config qpeconfig( "qpe" ); |
603 | qpeconfig.setGroup("Time"); | 604 | qpeconfig.setGroup("Time"); |
604 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); | 605 | ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); |
605 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); | 606 | onMonday = qpeconfig.readBoolEntry( "MONDAY" ); |
606 | 607 | ||
607 | Config config("DateBook"); | 608 | Config config("DateBook"); |
608 | config.setGroup("Main"); | 609 | config.setGroup("Main"); |
609 | startTime = config.readNumEntry("startviewtime", 8); | 610 | startTime = config.readNumEntry("startviewtime", 8); |
610 | aPreset = config.readBoolEntry("alarmpreset"); | 611 | aPreset = config.readBoolEntry("alarmpreset"); |
611 | presetTime = config.readNumEntry("presettime"); | 612 | presetTime = config.readNumEntry("presettime"); |
612 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); | 613 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); |
613 | rowStyle = config.readNumEntry("rowstyle"); | 614 | rowStyle = config.readNumEntry("rowstyle"); |
614 | defaultView = config.readNumEntry("defaultview",DAY); | 615 | defaultView = config.readNumEntry("defaultview",DAY); |
615 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); | 616 | weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); |
616 | 617 | ||
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index fb8b083..05ab781 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h | |||
@@ -10,49 +10,49 @@ | |||
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef DATEBOOK_H | 20 | #ifndef DATEBOOK_H |
21 | #define DATEBOOK_H | 21 | #define DATEBOOK_H |
22 | 22 | ||
23 | #include "datebooktypes.h" | 23 | #include "datebooktypes.h" |
24 | 24 | ||
25 | #include <qpe/datebookdb.h> | 25 | #include <qpe/datebookdb.h> |
26 | 26 | ||
27 | #include <qmainwindow.h> | 27 | #include <qmainwindow.h> |
28 | 28 | ||
29 | class QAction; | 29 | class QAction; |
30 | class QWidgetStack; | 30 | class QWidgetStack; |
31 | class DateBookDay; | 31 | class DateBookDay; |
32 | class DateBookWeek; | 32 | class DateBookWeek; |
33 | class DateBookWeekLst; | 33 | class DateBookWeekLst; |
34 | class DateBookMonth; | 34 | class ODateBookMonth; |
35 | class Event; | 35 | class Event; |
36 | class QDate; | 36 | class QDate; |
37 | class Ir; | 37 | class Ir; |
38 | 38 | ||
39 | class DateBook : public QMainWindow | 39 | class DateBook : public QMainWindow |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
44 | static QString appName() { return QString::fromLatin1("datebook"); } | 44 | static QString appName() { return QString::fromLatin1("datebook"); } |
45 | DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 45 | DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
46 | ~DateBook(); | 46 | ~DateBook(); |
47 | 47 | ||
48 | signals: | 48 | signals: |
49 | void newEvent(); | 49 | void newEvent(); |
50 | void signalNotFound(); | 50 | void signalNotFound(); |
51 | void signalWrapAround(); | 51 | void signalWrapAround(); |
52 | 52 | ||
53 | protected: | 53 | protected: |
54 | QDate currentDate(); | 54 | QDate currentDate(); |
55 | void timerEvent( QTimerEvent *e ); | 55 | void timerEvent( QTimerEvent *e ); |
56 | void closeEvent( QCloseEvent *e ); | 56 | void closeEvent( QCloseEvent *e ); |
57 | 57 | ||
58 | void view(int v, const QDate &d); | 58 | void view(int v, const QDate &d); |
@@ -87,48 +87,48 @@ private slots: | |||
87 | void editEvent( const Event &e ); | 87 | void editEvent( const Event &e ); |
88 | void duplicateEvent( const Event &e ); | 88 | void duplicateEvent( const Event &e ); |
89 | void removeEvent( const Event &e ); | 89 | void removeEvent( const Event &e ); |
90 | 90 | ||
91 | void receive( const QCString &msg, const QByteArray &data ); | 91 | void receive( const QCString &msg, const QByteArray &data ); |
92 | void setDocument( const QString & ); | 92 | void setDocument( const QString & ); |
93 | void beamEvent( const Event &e ); | 93 | void beamEvent( const Event &e ); |
94 | void beamDone( Ir *ir ); | 94 | void beamDone( Ir *ir ); |
95 | 95 | ||
96 | private: | 96 | private: |
97 | void addEvent( const Event &e ); | 97 | void addEvent( const Event &e ); |
98 | void initDay(); | 98 | void initDay(); |
99 | void initWeek(); | 99 | void initWeek(); |
100 | void initWeekLst(); | 100 | void initWeekLst(); |
101 | void initMonth(); | 101 | void initMonth(); |
102 | void loadSettings(); | 102 | void loadSettings(); |
103 | void saveSettings(); | 103 | void saveSettings(); |
104 | 104 | ||
105 | private: | 105 | private: |
106 | DateBookDBHoliday *db; | 106 | DateBookDBHoliday *db; |
107 | DateBookHoliday*db_holiday; | 107 | DateBookHoliday*db_holiday; |
108 | QWidgetStack *views; | 108 | QWidgetStack *views; |
109 | DateBookDay *dayView; | 109 | DateBookDay *dayView; |
110 | DateBookWeek *weekView; | 110 | DateBookWeek *weekView; |
111 | DateBookMonth *monthView; | 111 | ODateBookMonth *monthView; |
112 | DateBookWeekLst *weekLstView; | 112 | DateBookWeekLst *weekLstView; |
113 | QAction *dayAction, *weekAction, *weekLstAction, *monthAction; | 113 | QAction *dayAction, *weekAction, *weekLstAction, *monthAction; |
114 | int weeklistviewconfig; | 114 | int weeklistviewconfig; |
115 | bool aPreset; // have everything set to alarm? | 115 | bool aPreset; // have everything set to alarm? |
116 | int presetTime; // the standard time for the alarm | 116 | int presetTime; // the standard time for the alarm |
117 | int startTime; | 117 | int startTime; |
118 | int rowStyle; | 118 | int rowStyle; |
119 | int defaultView; | 119 | int defaultView; |
120 | QArray<int> defaultCategories; | 120 | QArray<int> defaultCategories; |
121 | QString defaultLocation; | 121 | QString defaultLocation; |
122 | bool bJumpToCurTime; //should jump to current time in dayview? | 122 | bool bJumpToCurTime; //should jump to current time in dayview? |
123 | bool ampm; | 123 | bool ampm; |
124 | bool onMonday; | 124 | bool onMonday; |
125 | 125 | ||
126 | bool syncing; | 126 | bool syncing; |
127 | bool inSearch; | 127 | bool inSearch; |
128 | 128 | ||
129 | int alarmCounter; | 129 | int alarmCounter; |
130 | 130 | ||
131 | QString checkEvent(const Event &); | 131 | QString checkEvent(const Event &); |
132 | }; | 132 | }; |
133 | 133 | ||
134 | #endif | 134 | #endif |
diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro index 26f4d8d..7813673 100644 --- a/core/pim/datebook/datebook.pro +++ b/core/pim/datebook/datebook.pro | |||
@@ -1,52 +1,54 @@ | |||
1 | CONFIG += qt warn_on quick-app | 1 | CONFIG += qt warn_on quick-app |
2 | HEADERS= datebookday.h \ | 2 | HEADERS= datebookday.h \ |
3 | datebook.h \ | 3 | datebook.h \ |
4 | dateentryimpl.h \ | 4 | dateentryimpl.h \ |
5 | datebookdayheaderimpl.h \ | 5 | datebookdayheaderimpl.h \ |
6 | datebooksettings.h \ | 6 | datebooksettings.h \ |
7 | datebookweek.h \ | 7 | datebookweek.h \ |
8 | modules/weeklst/datebookweeklst.h \ | 8 | modules/weeklst/datebookweeklst.h \ |
9 | modules/weeklst/datebookweeklstdayhdr.h \ | 9 | modules/weeklst/datebookweeklstdayhdr.h \ |
10 | modules/weeklst/datebookweeklstheader.h \ | 10 | modules/weeklst/datebookweeklstheader.h \ |
11 | modules/weeklst/datebookweeklstevent.h \ | 11 | modules/weeklst/datebookweeklstevent.h \ |
12 | modules/weeklst/datebookweeklstview.h \ | 12 | modules/weeklst/datebookweeklstview.h \ |
13 | modules/weeklst/datebookweeklstdblview.h \ | 13 | modules/weeklst/datebookweeklstdblview.h \ |
14 | modules/monthview/odatebookmonth.h \ | ||
14 | datebookweekheaderimpl.h \ | 15 | datebookweekheaderimpl.h \ |
15 | repeatentry.h \ | 16 | repeatentry.h \ |
16 | noteentryimpl.h \ | 17 | noteentryimpl.h \ |
17 | onoteedit.h \ | 18 | onoteedit.h \ |
18 | datebookdayallday.h \ | 19 | datebookdayallday.h \ |
19 | namespace_hack.h \ | 20 | namespace_hack.h \ |
20 | datebooktypes.h | 21 | datebooktypes.h |
21 | SOURCES= main.cpp \ | 22 | SOURCES= main.cpp \ |
22 | datebookday.cpp \ | 23 | datebookday.cpp \ |
23 | datebook.cpp \ | 24 | datebook.cpp \ |
24 | dateentryimpl.cpp \ | 25 | dateentryimpl.cpp \ |
25 | datebookdayheaderimpl.cpp \ | 26 | datebookdayheaderimpl.cpp \ |
26 | datebooksettings.cpp \ | 27 | datebooksettings.cpp \ |
27 | datebookweek.cpp \ | 28 | datebookweek.cpp \ |
28 | modules/weeklst/datebookweeklst.cpp \ | 29 | modules/weeklst/datebookweeklst.cpp \ |
29 | modules/weeklst/datebookweeklstdayhdr.cpp \ | 30 | modules/weeklst/datebookweeklstdayhdr.cpp \ |
30 | modules/weeklst/datebookweeklstheader.cpp \ | 31 | modules/weeklst/datebookweeklstheader.cpp \ |
31 | modules/weeklst/datebookweeklstevent.cpp \ | 32 | modules/weeklst/datebookweeklstevent.cpp \ |
32 | modules/weeklst/datebookweeklstview.cpp \ | 33 | modules/weeklst/datebookweeklstview.cpp \ |
33 | modules/weeklst/datebookweeklstdblview.cpp \ | 34 | modules/weeklst/datebookweeklstdblview.cpp \ |
35 | modules/monthview/odatebookmonth.cpp \ | ||
34 | datebookweekheaderimpl.cpp \ | 36 | datebookweekheaderimpl.cpp \ |
35 | repeatentry.cpp \ | 37 | repeatentry.cpp \ |
36 | noteentryimpl.cpp \ | 38 | noteentryimpl.cpp \ |
37 | onoteedit.cpp \ | 39 | onoteedit.cpp \ |
38 | datebookdayallday.cpp | 40 | datebookdayallday.cpp |
39 | INTERFACES= dateentry.ui \ | 41 | INTERFACES= dateentry.ui \ |
40 | datebookdayheader.ui \ | 42 | datebookdayheader.ui \ |
41 | datebookweekheader.ui \ | 43 | datebookweekheader.ui \ |
42 | modules/weeklst/datebookweeklstheaderbase.ui \ | 44 | modules/weeklst/datebookweeklstheaderbase.ui \ |
43 | modules/weeklst/datebookweeklstdayhdrbase.ui \ | 45 | modules/weeklst/datebookweeklstdayhdrbase.ui \ |
44 | repeatentrybase.ui \ | 46 | repeatentrybase.ui \ |
45 | datebooksettingsbase.ui \ | 47 | datebooksettingsbase.ui \ |
46 | noteentry.ui | 48 | noteentry.ui |
47 | INCLUDEPATH += $(OPIEDIR)/include | 49 | INCLUDEPATH += $(OPIEDIR)/include |
48 | DEPENDPATH+= $(OPIEDIR)/include | 50 | DEPENDPATH+= $(OPIEDIR)/include |
49 | LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 | 51 | LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 |
50 | TARGET = datebook | 52 | TARGET = datebook |
51 | 53 | ||
52 | include( $(OPIEDIR)/include.pro ) | 54 | include( $(OPIEDIR)/include.pro ) |
diff --git a/core/pim/datebook/modules/monthview/odatebookmonth.cpp b/core/pim/datebook/modules/monthview/odatebookmonth.cpp new file mode 100644 index 0000000..5e2f1bb --- a/dev/null +++ b/core/pim/datebook/modules/monthview/odatebookmonth.cpp | |||
@@ -0,0 +1,392 @@ | |||
1 | /* this is a straight copy of datemonthview. We can not make child of | ||
2 | * it 'cause the origin view isn't virtual in any form. | ||
3 | */ | ||
4 | /********************************************************************** | ||
5 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
6 | ** | ||
7 | ** This file is part of the Qtopia Environment. | ||
8 | ** | ||
9 | ** This file may be distributed and/or modified under the terms of the | ||
10 | ** GNU General Public License version 2 as published by the Free Software | ||
11 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
12 | ** packaging of this file. | ||
13 | ** | ||
14 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
15 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
16 | ** | ||
17 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
18 | ** | ||
19 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
20 | ** not clear to you. | ||
21 | ** | ||
22 | **********************************************************************/ | ||
23 | #include "odatebookmonth.h" | ||
24 | #include "datebooktypes.h" | ||
25 | |||
26 | #include <qpe/config.h> | ||
27 | #include <qpe/datebookmonth.h> | ||
28 | |||
29 | #include <qpe/resource.h> | ||
30 | #include <qpe/qpeapplication.h> | ||
31 | |||
32 | #include <qtoolbutton.h> | ||
33 | #include <qspinbox.h> | ||
34 | #include <qcombobox.h> | ||
35 | #include <qvaluestack.h> | ||
36 | #include <qwhatsthis.h> | ||
37 | |||
38 | |||
39 | //--------------------------------------------------------------------------- | ||
40 | |||
41 | class ODateBookMonthTablePrivate | ||
42 | { | ||
43 | public: | ||
44 | ODateBookMonthTablePrivate() {}; | ||
45 | ~ODateBookMonthTablePrivate() { mMonthEvents.clear(); }; | ||
46 | |||
47 | QValueList<EffectiveEvent> mMonthEvents; | ||
48 | bool onMonday; | ||
49 | }; | ||
50 | |||
51 | ODateBookMonthTable::ODateBookMonthTable( QWidget *parent, const char *name, | ||
52 | DateBookDBHoliday *newDb ) | ||
53 | : QTable( 6, 7, parent, name ), | ||
54 | db( newDb ) | ||
55 | { | ||
56 | d = new ODateBookMonthTablePrivate(); | ||
57 | selYear = -1; | ||
58 | selMonth = -1; | ||
59 | selDay = -1; | ||
60 | |||
61 | /* init these as well make valgrind happy and be consistent with Qtopia1.6 -zecke */ | ||
62 | year = -1; | ||
63 | month = -1; | ||
64 | day = -1; | ||
65 | |||
66 | Config cfg( "qpe" ); | ||
67 | cfg.setGroup( "Time" ); | ||
68 | d->onMonday = cfg.readBoolEntry( "MONDAY" ); | ||
69 | |||
70 | horizontalHeader()->setResizeEnabled( FALSE ); | ||
71 | // we have to do this here... or suffer the consequences later... | ||
72 | for ( int i = 0; i < 7; i++ ){ | ||
73 | horizontalHeader()->resizeSection( i, 30 ); | ||
74 | setColumnStretchable( i, TRUE ); | ||
75 | } | ||
76 | setupLabels(); | ||
77 | |||
78 | verticalHeader()->hide(); | ||
79 | setLeftMargin( 0 ); | ||
80 | for ( int i = 0; i < 6; ++i ) | ||
81 | setRowStretchable( i, TRUE ); | ||
82 | |||
83 | setSelectionMode( NoSelection ); | ||
84 | |||
85 | connect( this, SIGNAL( clicked(int,int,int,const QPoint&) ), | ||
86 | this, SLOT( dayClicked(int,int) ) ); | ||
87 | connect( this, SIGNAL( currentChanged(int,int) ), | ||
88 | this, SLOT( dragDay(int,int) ) ); | ||
89 | setVScrollBarMode( AlwaysOff ); | ||
90 | setHScrollBarMode( AlwaysOff ); | ||
91 | } | ||
92 | |||
93 | ODateBookMonthTable::~ODateBookMonthTable() | ||
94 | { | ||
95 | monthsEvents.clear(); | ||
96 | delete d; | ||
97 | } | ||
98 | |||
99 | void ODateBookMonthTable::setDate(int y, int m, int d) | ||
100 | { | ||
101 | if (month == m && year == y) { | ||
102 | if ( selYear == -1 ) | ||
103 | year = selYear; | ||
104 | if ( selMonth == -1 ) | ||
105 | month = selMonth; | ||
106 | int r1, c1, r2, c2; | ||
107 | findDay(selDay, r1, c1); | ||
108 | selDay = day = d; | ||
109 | findDay(selDay, r2, c2); | ||
110 | setCurrentCell( r2, c2 ); | ||
111 | //updateCell(r1,c1); | ||
112 | //updateCell(r2,c2); | ||
113 | } else { | ||
114 | selYear = year = y; | ||
115 | selMonth = month = m; | ||
116 | selDay = day = d; | ||
117 | setupTable(); | ||
118 | } | ||
119 | } | ||
120 | |||
121 | void ODateBookMonthTable::redraw() | ||
122 | { | ||
123 | setupLabels(); | ||
124 | setupTable(); | ||
125 | } | ||
126 | |||
127 | void ODateBookMonthTable::setWeekStart( bool onMonday ) | ||
128 | { | ||
129 | d->onMonday = onMonday; | ||
130 | setupLabels(); | ||
131 | setupTable(); | ||
132 | } | ||
133 | |||
134 | void ODateBookMonthTable::setupTable() | ||
135 | { | ||
136 | QValueList<Calendar::Day> days = Calendar::daysOfMonth( year, month, d->onMonday ); | ||
137 | QValueList<Calendar::Day>::Iterator it = days.begin(); | ||
138 | int row = 0, col = 0; | ||
139 | int crow = 0; | ||
140 | int ccol = 0; | ||
141 | for ( ; it != days.end(); ++it ) { | ||
142 | DayItemMonth *i = (DayItemMonth *)item( row, col ); | ||
143 | if ( !i ) { | ||
144 | i = new DayItemMonth( this, QTableItem::Never, "" ); | ||
145 | setItem( row, col, i ); | ||
146 | } | ||
147 | Calendar::Day calDay = *it; | ||
148 | i->clearEffEvents(); | ||
149 | i->setDay( calDay.date ); | ||
150 | i->setType( calDay.type ); | ||
151 | if ( i->day() == day && calDay.type == Calendar::Day::ThisMonth ) { | ||
152 | crow = row; | ||
153 | ccol = col; | ||
154 | } | ||
155 | |||
156 | updateCell( row, col ); | ||
157 | |||
158 | if ( col == 6 ) { | ||
159 | ++row; | ||
160 | col = 0; | ||
161 | } else { | ||
162 | ++col; | ||
163 | } | ||
164 | } | ||
165 | setCurrentCell( crow, ccol ); | ||
166 | getEvents(); | ||
167 | } | ||
168 | |||
169 | void ODateBookMonthTable::findDay( int day, int &row, int &col ) | ||
170 | { | ||
171 | QDate dtBegin( year, month, 1 ); | ||
172 | int skips = dtBegin.dayOfWeek(); | ||
173 | int effective_day = day + skips - 1; // row/columns begin at 0 | ||
174 | // make an extra adjustment if we start on Mondays. | ||
175 | if ( d->onMonday ) | ||
176 | effective_day--; | ||
177 | row = effective_day / 7; | ||
178 | col = effective_day % 7; | ||
179 | } | ||
180 | |||
181 | void ODateBookMonthTable::dayClicked( int row, int col ) | ||
182 | { | ||
183 | changeDaySelection( row, col ); | ||
184 | emit dateClicked( selYear, selMonth, selDay ); | ||
185 | } | ||
186 | |||
187 | void ODateBookMonthTable::dragDay( int row, int col ) | ||
188 | { | ||
189 | changeDaySelection( row, col ); | ||
190 | } | ||
191 | |||
192 | void ODateBookMonthTable::changeDaySelection( int row, int col ) | ||
193 | { | ||
194 | DayItemMonth *i = (DayItemMonth*)item( row, col ); | ||
195 | if ( !i ) | ||
196 | return; | ||
197 | switch ( i->type() ) { | ||
198 | case Calendar::Day::ThisMonth: | ||
199 | selMonth = month; | ||
200 | break; | ||
201 | case Calendar::Day::PrevMonth: | ||
202 | selMonth = month-1; | ||
203 | break; | ||
204 | default: | ||
205 | selMonth = month+1; | ||
206 | } | ||
207 | |||
208 | selYear = year; | ||
209 | if ( selMonth <= 0 ) { | ||
210 | selMonth = 12; | ||
211 | selYear--; | ||
212 | } else if ( selMonth > 12 ) { | ||
213 | selMonth = 1; | ||
214 | selYear++; | ||
215 | } | ||
216 | selDay = i->day(); | ||
217 | } | ||
218 | |||
219 | |||
220 | void ODateBookMonthTable::viewportMouseReleaseEvent( QMouseEvent * ) | ||
221 | { | ||
222 | dayClicked( currentRow(), currentColumn() ); | ||
223 | } | ||
224 | |||
225 | void ODateBookMonthTable::getEvents() | ||
226 | { | ||
227 | if ( !db ) | ||
228 | return; | ||
229 | |||
230 | QDate dtStart( year, month, 1 ); | ||
231 | d->mMonthEvents = db->getEffectiveEvents( dtStart, | ||
232 | QDate( year, month, | ||
233 | dtStart.daysInMonth() ) ); | ||
234 | QValueListIterator<EffectiveEvent> it = d->mMonthEvents.begin(); | ||
235 | // now that the events are sorted, basically go through the list, make | ||
236 | // a small list for every day and set it for each item... | ||
237 | // clear all the items... | ||
238 | while ( it != d->mMonthEvents.end() ) { | ||
239 | QValueList<EffectiveEvent> dayEvent; | ||
240 | EffectiveEvent e = *it; | ||
241 | ++it; | ||
242 | dayEvent.append( e ); | ||
243 | while ( it != d->mMonthEvents.end() | ||
244 | && e.date() == (*it).date() ) { | ||
245 | dayEvent.append( *it ); | ||
246 | ++it; | ||
247 | } | ||
248 | int row, col; | ||
249 | findDay( e.date().day(), row, col ); | ||
250 | DayItemMonth* w = static_cast<DayItemMonth*>( item( row, col ) ); | ||
251 | w->setEvents( dayEvent ); | ||
252 | updateCell( row, col ); | ||
253 | dayEvent.clear(); | ||
254 | } | ||
255 | } | ||
256 | |||
257 | |||
258 | void ODateBookMonthTable::setupLabels() | ||
259 | { | ||
260 | for ( int i = 0; i < 7; ++i ) { | ||
261 | // horizontalHeader()->resizeSection( i, 30 ); | ||
262 | // setColumnStretchable( i, TRUE ); | ||
263 | if ( d->onMonday ) | ||
264 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i + 1 ) ); | ||
265 | else { | ||
266 | if ( i == 0 ) | ||
267 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( 7 ) ); | ||
268 | else | ||
269 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i ) ); | ||
270 | } | ||
271 | } | ||
272 | } | ||
273 | |||
274 | |||
275 | //--------------------------------------------------------------------------- | ||
276 | |||
277 | ODateBookMonth::ODateBookMonth( QWidget *parent, const char *name, bool ac, | ||
278 | DateBookDBHoliday *data ) | ||
279 | : QVBox( parent, name ), | ||
280 | autoClose( ac ) | ||
281 | { | ||
282 | setFocusPolicy(StrongFocus); | ||
283 | year = QDate::currentDate().year(); | ||
284 | month = QDate::currentDate().month(); | ||
285 | day = QDate::currentDate().day(); | ||
286 | header = new DateBookMonthHeader( this, "DateBookMonthHeader" ); | ||
287 | table = new ODateBookMonthTable( this, "DateBookMonthTable", data ); | ||
288 | header->setDate( year, month ); | ||
289 | table->setDate( year, month, QDate::currentDate().day() ); | ||
290 | header->setFocusPolicy(NoFocus); | ||
291 | table->setFocusPolicy(NoFocus); | ||
292 | connect( header, SIGNAL( dateChanged(int,int) ), | ||
293 | this, SLOT( setDate(int,int) ) ); | ||
294 | connect( table, SIGNAL( dateClicked(int,int,int) ), | ||
295 | this, SLOT( finalDate(int,int,int) ) ); | ||
296 | connect( qApp, SIGNAL(weekChanged(bool)), this, | ||
297 | SLOT(slotWeekChange(bool)) ); | ||
298 | table->setFocus(); | ||
299 | } | ||
300 | |||
301 | ODateBookMonth::~ODateBookMonth() | ||
302 | { | ||
303 | |||
304 | } | ||
305 | |||
306 | void ODateBookMonth::setDate( int y, int m ) | ||
307 | { | ||
308 | /* only change the date if this is a different date, | ||
309 | * other wise we may mistakenly overide the day */ | ||
310 | if ( (y != year) || (m != month) ) { | ||
311 | year = y; | ||
312 | month = m; | ||
313 | QDate nd( y, m, 1 ); | ||
314 | if ( nd.daysInMonth() < day ) | ||
315 | day = nd.daysInMonth(); | ||
316 | table->setDate( year, month, day ); | ||
317 | } | ||
318 | } | ||
319 | |||
320 | void ODateBookMonth::setDate( int y, int m, int d ) | ||
321 | { | ||
322 | header->setDate( y, m); | ||
323 | table->setDate( y, m, d); | ||
324 | year = y; | ||
325 | month = m; | ||
326 | day = d; | ||
327 | } | ||
328 | |||
329 | /* called when we wish to close or pass back the date */ | ||
330 | void ODateBookMonth::finalDate(int y, int m, int d) | ||
331 | { | ||
332 | setDate( y, m, d ); | ||
333 | |||
334 | emit dateClicked(y, m, d); | ||
335 | // emit dateClicked(QDate(y, m, d).toString()); | ||
336 | |||
337 | if ( autoClose && parentWidget() ) | ||
338 | parentWidget()->close(); | ||
339 | } | ||
340 | |||
341 | void ODateBookMonth::setDate( QDate d) | ||
342 | { | ||
343 | setDate(d.year(), d.month(), d.day()); | ||
344 | } | ||
345 | |||
346 | void ODateBookMonth::redraw() | ||
347 | { | ||
348 | table->setDate( year, month, day ); | ||
349 | table->redraw(); | ||
350 | } | ||
351 | |||
352 | QDate ODateBookMonth::selectedDate() const | ||
353 | { | ||
354 | if ( !table ) | ||
355 | return QDate::currentDate(); | ||
356 | int y, m, d; | ||
357 | table->getDate( y, m, d ); | ||
358 | return QDate( y, m, d ); | ||
359 | } | ||
360 | |||
361 | void ODateBookMonth::slotWeekChange( bool startOnMonday ) | ||
362 | { | ||
363 | table->setWeekStart( startOnMonday ); | ||
364 | } | ||
365 | |||
366 | void ODateBookMonth::keyPressEvent( QKeyEvent *e ) | ||
367 | { | ||
368 | switch(e->key()) { | ||
369 | case Key_Up: | ||
370 | setDate(QDate(year, month, day).addDays(-7)); | ||
371 | break; | ||
372 | case Key_Down: | ||
373 | setDate(QDate(year, month, day).addDays(7)); | ||
374 | break; | ||
375 | case Key_Left: | ||
376 | setDate(QDate(year, month, day).addDays(-1)); | ||
377 | break; | ||
378 | case Key_Right: | ||
379 | setDate(QDate(year, month, day).addDays(1)); | ||
380 | break; | ||
381 | case Key_Space: | ||
382 | qWarning("space"); | ||
383 | emit dateClicked(year, month, day); | ||
384 | if ( autoClose && parentWidget() ) | ||
385 | parentWidget()->close(); | ||
386 | break; | ||
387 | default: | ||
388 | qWarning("ignore"); | ||
389 | e->ignore(); | ||
390 | break; | ||
391 | } | ||
392 | } | ||
diff --git a/core/pim/datebook/modules/monthview/odatebookmonth.h b/core/pim/datebook/modules/monthview/odatebookmonth.h new file mode 100644 index 0000000..e967abe --- a/dev/null +++ b/core/pim/datebook/modules/monthview/odatebookmonth.h | |||
@@ -0,0 +1,132 @@ | |||
1 | /* this is a straight copy of datemonthview. We can not make child of | ||
2 | * it 'cause the origin view isn't virtual in any form. | ||
3 | */ | ||
4 | /********************************************************************** | ||
5 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
6 | ** | ||
7 | ** This file is part of the Qtopia Environment. | ||
8 | ** | ||
9 | ** This file may be distributed and/or modified under the terms of the | ||
10 | ** GNU General Public License version 2 as published by the Free Software | ||
11 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
12 | ** packaging of this file. | ||
13 | ** | ||
14 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
15 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
16 | ** | ||
17 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
18 | ** | ||
19 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
20 | ** not clear to you. | ||
21 | ** | ||
22 | **********************************************************************/ | ||
23 | #ifndef ODATEBOOKMONTH | ||
24 | #define ODATEBOOKMONTH | ||
25 | |||
26 | #include <qtopia/private/event.h> | ||
27 | #include <qpe/datebookmonth.h> | ||
28 | |||
29 | #include <qvbox.h> | ||
30 | #include <qhbox.h> | ||
31 | #include <qdatetime.h> | ||
32 | #include <qvaluelist.h> | ||
33 | #include <qtable.h> | ||
34 | #include <qpushbutton.h> | ||
35 | #include <qpopupmenu.h> | ||
36 | |||
37 | #include <qpe/calendar.h> | ||
38 | #include <qpe/timestring.h> | ||
39 | |||
40 | class QToolButton; | ||
41 | class QComboBox; | ||
42 | class QSpinBox; | ||
43 | class Event; | ||
44 | class DateBookDB; | ||
45 | class DateBookDBHoliday; | ||
46 | |||
47 | class ODateBookMonthTablePrivate; | ||
48 | class ODateBookMonthTable : public QTable | ||
49 | { | ||
50 | Q_OBJECT | ||
51 | |||
52 | public: | ||
53 | ODateBookMonthTable( QWidget *parent = 0, const char *name = 0, | ||
54 | DateBookDBHoliday *newDb = 0 ); | ||
55 | virtual ~ODateBookMonthTable(); | ||
56 | void setDate( int y, int m, int d ); | ||
57 | void redraw(); | ||
58 | |||
59 | QSize minimumSizeHint() const { return sizeHint(); } | ||
60 | QSize minimumSize() const { return sizeHint(); } | ||
61 | void getDate( int& y, int &m, int &d ) const {y=selYear;m=selMonth;d=selDay;} | ||
62 | void setWeekStart( bool onMonday ); | ||
63 | signals: | ||
64 | void dateClicked( int year, int month, int day ); | ||
65 | |||
66 | protected: | ||
67 | virtual void viewportMouseReleaseEvent( QMouseEvent * ); | ||
68 | |||
69 | protected slots: | ||
70 | |||
71 | virtual void keyPressEvent(QKeyEvent *e ) { | ||
72 | e->ignore(); | ||
73 | } | ||
74 | |||
75 | private slots: | ||
76 | void dayClicked( int row, int col ); | ||
77 | void dragDay( int row, int col ); | ||
78 | |||
79 | private: | ||
80 | void setupTable(); | ||
81 | void setupLabels(); | ||
82 | |||
83 | void findDay( int day, int &row, int &col ); | ||
84 | void getEvents(); | ||
85 | void changeDaySelection( int row, int col ); | ||
86 | |||
87 | int year, month, day; | ||
88 | int selYear, selMonth, selDay; | ||
89 | QValueList<Event> monthsEvents; // not used anymore... | ||
90 | DateBookDBHoliday *db; | ||
91 | ODateBookMonthTablePrivate *d; | ||
92 | }; | ||
93 | |||
94 | class ODateBookMonthPrivate; | ||
95 | class ODateBookMonth : public QVBox | ||
96 | { | ||
97 | Q_OBJECT | ||
98 | |||
99 | public: | ||
100 | /* ac = Auto Close */ | ||
101 | ODateBookMonth( QWidget *parent = 0, const char *name = 0, bool ac = FALSE, | ||
102 | DateBookDBHoliday *data = 0 ); | ||
103 | virtual ~ODateBookMonth(); | ||
104 | QDate selectedDate() const; | ||
105 | |||
106 | signals: | ||
107 | /* ### FIXME add a signal with QDate -zecke */ | ||
108 | void dateClicked( int year, int month, int day ); | ||
109 | |||
110 | public slots: | ||
111 | void setDate( int y, int m ); | ||
112 | void setDate( int y, int m, int d ); | ||
113 | void setDate( QDate ); | ||
114 | void redraw(); | ||
115 | void slotWeekChange( bool ); | ||
116 | |||
117 | protected slots: | ||
118 | virtual void keyPressEvent(QKeyEvent *e); | ||
119 | |||
120 | private slots: | ||
121 | void forwardDateClicked( int y, int m, int d ) { emit dateClicked( y, m, d ); } | ||
122 | void finalDate(int, int, int); | ||
123 | |||
124 | private: | ||
125 | DateBookMonthHeader *header; | ||
126 | ODateBookMonthTable *table; | ||
127 | int year, month, day; | ||
128 | bool autoClose; | ||
129 | class ODateBookMonthPrivate *d; | ||
130 | }; | ||
131 | |||
132 | #endif | ||