-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 | |||
@@ -1,1213 +1,1214 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
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> |
63 | #include <unistd.h> | 64 | #include <unistd.h> |
64 | 65 | ||
65 | #include <stdlib.h> | 66 | #include <stdlib.h> |
66 | 67 | ||
67 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | 68 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) |
68 | : QMainWindow( parent, "datebook", f ), | 69 | : QMainWindow( parent, "datebook", f ), |
69 | aPreset( FALSE ), | 70 | aPreset( FALSE ), |
70 | presetTime( -1 ), | 71 | presetTime( -1 ), |
71 | startTime( 8 ), // an acceptable default | 72 | startTime( 8 ), // an acceptable default |
72 | rowStyle( 0 ), | 73 | rowStyle( 0 ), |
73 | bJumpToCurTime(FALSE), | 74 | bJumpToCurTime(FALSE), |
74 | syncing(FALSE), | 75 | syncing(FALSE), |
75 | inSearch(FALSE), | 76 | inSearch(FALSE), |
76 | alarmCounter(0) | 77 | alarmCounter(0) |
77 | { | 78 | { |
78 | bool needEvilHack= false; // if we need an Evil Hack | 79 | bool needEvilHack= false; // if we need an Evil Hack |
79 | QTime t; | 80 | QTime t; |
80 | t.start(); | 81 | t.start(); |
81 | db = new DateBookDBHoliday; | 82 | db = new DateBookDBHoliday; |
82 | odebug << "loading db t=" << t.elapsed() << oendl; | 83 | odebug << "loading db t=" << t.elapsed() << oendl; |
83 | db_holiday = new DateBookHoliday(); | 84 | db_holiday = new DateBookHoliday(); |
84 | db->db_holiday=db_holiday; | 85 | db->db_holiday=db_holiday; |
85 | 86 | ||
86 | loadSettings(); | 87 | loadSettings(); |
87 | setCaption( tr("Calendar") ); | 88 | setCaption( tr("Calendar") ); |
88 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | 89 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); |
89 | 90 | ||
90 | setToolBarsMovable( FALSE ); | 91 | setToolBarsMovable( FALSE ); |
91 | 92 | ||
92 | views = new QWidgetStack( this ); | 93 | views = new QWidgetStack( this ); |
93 | setCentralWidget( views ); | 94 | setCentralWidget( views ); |
94 | 95 | ||
95 | dayView = 0; | 96 | dayView = 0; |
96 | weekView = 0; | 97 | weekView = 0; |
97 | weekLstView = 0; | 98 | weekLstView = 0; |
98 | monthView = 0; | 99 | monthView = 0; |
99 | 100 | ||
100 | // QToolBar *bar = new QToolBar( this ); | 101 | // QToolBar *bar = new QToolBar( this ); |
101 | // bar->setHorizontalStretchable( TRUE ); | 102 | // bar->setHorizontalStretchable( TRUE ); |
102 | 103 | ||
103 | // QMenuBar *mb = new QMenuBar( bar ); | 104 | // QMenuBar *mb = new QMenuBar( bar ); |
104 | // mb->setMargin( 0 ); | 105 | // mb->setMargin( 0 ); |
105 | 106 | ||
106 | // QPopupMenu *view = new QPopupMenu( this ); | 107 | // QPopupMenu *view = new QPopupMenu( this ); |
107 | // mb->insertItem( tr( "View" ), view ); | 108 | // mb->insertItem( tr( "View" ), view ); |
108 | 109 | ||
109 | QToolBar *sub_bar = new QToolBar(this); | 110 | QToolBar *sub_bar = new QToolBar(this); |
110 | sub_bar->setHorizontalStretchable(TRUE); | 111 | sub_bar->setHorizontalStretchable(TRUE); |
111 | 112 | ||
112 | QActionGroup *g = new QActionGroup( this ); | 113 | QActionGroup *g = new QActionGroup( this ); |
113 | g->setExclusive( TRUE ); | 114 | g->setExclusive( TRUE ); |
114 | 115 | ||
115 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 116 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
116 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 117 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
117 | a->addTo( sub_bar ); | 118 | a->addTo( sub_bar ); |
118 | 119 | ||
119 | sub_bar->addSeparator(); | 120 | sub_bar->addSeparator(); |
120 | 121 | ||
121 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); | 122 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); |
122 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | 123 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); |
123 | a->addTo( sub_bar ); | 124 | a->addTo( sub_bar ); |
124 | // a->addTo( view ); | 125 | // a->addTo( view ); |
125 | 126 | ||
126 | sub_bar->addSeparator(); | 127 | sub_bar->addSeparator(); |
127 | 128 | ||
128 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); | 129 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); |
129 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); | 130 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); |
130 | a->addTo( sub_bar ); | 131 | a->addTo( sub_bar ); |
131 | // a->addTo( view ); | 132 | // a->addTo( view ); |
132 | a->setToggleAction( TRUE ); | 133 | a->setToggleAction( TRUE ); |
133 | a->setOn( TRUE ); | 134 | a->setOn( TRUE ); |
134 | dayAction = a; | 135 | dayAction = a; |
135 | 136 | ||
136 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); | 137 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); |
137 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); | 138 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); |
138 | a->addTo( sub_bar ); | 139 | a->addTo( sub_bar ); |
139 | // a->addTo( view ); | 140 | // a->addTo( view ); |
140 | a->setToggleAction( TRUE ); | 141 | a->setToggleAction( TRUE ); |
141 | weekAction = a; | 142 | weekAction = a; |
142 | 143 | ||
143 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); | 144 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); |
144 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); | 145 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); |
145 | a->addTo( sub_bar ); | 146 | a->addTo( sub_bar ); |
146 | // a->addTo( view ); | 147 | // a->addTo( view ); |
147 | a->setToggleAction( TRUE ); | 148 | a->setToggleAction( TRUE ); |
148 | weekLstAction = a; | 149 | weekLstAction = a; |
149 | 150 | ||
150 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); | 151 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); |
151 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); | 152 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); |
152 | a->addTo( sub_bar ); | 153 | a->addTo( sub_bar ); |
153 | // a->addTo( view ); | 154 | // a->addTo( view ); |
154 | a->setToggleAction( TRUE ); | 155 | a->setToggleAction( TRUE ); |
155 | monthAction = a; | 156 | monthAction = a; |
156 | 157 | ||
157 | sub_bar->addSeparator(); | 158 | sub_bar->addSeparator(); |
158 | 159 | ||
159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | 160 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); |
160 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 161 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
161 | a->addTo( sub_bar ); | 162 | a->addTo( sub_bar ); |
162 | 163 | ||
163 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); | 164 | a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); |
164 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 165 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
165 | a->addTo( sub_bar ); | 166 | a->addTo( sub_bar ); |
166 | 167 | ||
167 | if(defaultView==DAY) viewDay(); | 168 | if(defaultView==DAY) viewDay(); |
168 | if(defaultView==WEEK) needEvilHack=true; // viewWeek(); | 169 | if(defaultView==WEEK) needEvilHack=true; // viewWeek(); |
169 | if(defaultView==WEEKLST) viewWeekLst(); | 170 | if(defaultView==WEEKLST) viewWeekLst(); |
170 | if(defaultView==MONTH) viewMonth(); | 171 | if(defaultView==MONTH) viewMonth(); |
171 | 172 | ||
172 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); | 173 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); |
173 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); | 174 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); |
174 | 175 | ||
175 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 176 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
176 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); | 177 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); |
177 | #endif | 178 | #endif |
178 | 179 | ||
179 | // listen on QPE/System | 180 | // listen on QPE/System |
180 | #if defined(Q_WS_QWS) | 181 | #if defined(Q_WS_QWS) |
181 | #if !defined(QT_NO_COP) | 182 | #if !defined(QT_NO_COP) |
182 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 183 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
183 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); | 184 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); |
184 | channel = new QCopChannel( "QPE/Datebook", this ); | 185 | channel = new QCopChannel( "QPE/Datebook", this ); |
185 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); | 186 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); |
186 | #endif | 187 | #endif |
187 | #endif | 188 | #endif |
188 | 189 | ||
189 | odebug << "done t=" << t.elapsed() << oendl; | 190 | odebug << "done t=" << t.elapsed() << oendl; |
190 | 191 | ||
191 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); | 192 | connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); |
192 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); | 193 | connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); |
193 | /* | 194 | /* |
194 | * Here is a problem description: | 195 | * Here is a problem description: |
195 | * When Weekview is the default view | 196 | * When Weekview is the default view |
196 | * a DateBookWeekView get's created | 197 | * a DateBookWeekView get's created |
197 | * redraw() get's called. So what? | 198 | * redraw() get's called. So what? |
198 | * Remember that we're still in the c'tor | 199 | * Remember that we're still in the c'tor |
199 | * and no final layout has happened? Ok | 200 | * and no final layout has happened? Ok |
200 | * now all Events get arranged. Their x | 201 | * now all Events get arranged. Their x |
201 | * position get's determined by a QHeader | 202 | * position get's determined by a QHeader |
202 | * position. But the QHeader isn't layouted or | 203 | * position. But the QHeader isn't layouted or |
203 | * at the right position. redraw() is a slot | 204 | * at the right position. redraw() is a slot |
204 | * so we'll call it then via a singleShot | 205 | * so we'll call it then via a singleShot |
205 | * from view() | 206 | * from view() |
206 | */ | 207 | */ |
207 | if( needEvilHack ){ | 208 | if( needEvilHack ){ |
208 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); | 209 | QTimer::singleShot( 500, this, SLOT(viewWeek()) ); |
209 | } | 210 | } |
210 | } | 211 | } |
211 | 212 | ||
212 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 213 | void DateBook::receive( const QCString &msg, const QByteArray &data ) |
213 | { | 214 | { |
214 | QDataStream stream( data, IO_ReadOnly ); | 215 | QDataStream stream( data, IO_ReadOnly ); |
215 | if ( msg == "timeChange(QString)" ) { | 216 | if ( msg == "timeChange(QString)" ) { |
216 | // update active view! | 217 | // update active view! |
217 | if ( dayAction->isOn() ) | 218 | if ( dayAction->isOn() ) |
218 | viewDay(); | 219 | viewDay(); |
219 | else if ( weekAction->isOn() ) | 220 | else if ( weekAction->isOn() ) |
220 | viewWeek(); | 221 | viewWeek(); |
221 | else if ( monthAction->isOn() ) | 222 | else if ( monthAction->isOn() ) |
222 | viewMonth(); | 223 | viewMonth(); |
223 | } | 224 | } |
224 | else if (msg == "editEvent(int)") { | 225 | else if (msg == "editEvent(int)") { |
225 | int uid; | 226 | int uid; |
226 | stream >> uid; | 227 | stream >> uid; |
227 | Event e=db->eventByUID(uid); | 228 | Event e=db->eventByUID(uid); |
228 | editEvent(e); | 229 | editEvent(e); |
229 | }else if (msg == "viewDefault(QDate)"){ | 230 | }else if (msg == "viewDefault(QDate)"){ |
230 | QDate day; | 231 | QDate day; |
231 | stream >> day; | 232 | stream >> day; |
232 | viewDefault(day); | 233 | viewDefault(day); |
233 | } | 234 | } |
234 | } | 235 | } |
235 | 236 | ||
236 | DateBook::~DateBook() | 237 | DateBook::~DateBook() |
237 | { | 238 | { |
238 | delete db_holiday; | 239 | delete db_holiday; |
239 | } | 240 | } |
240 | 241 | ||
241 | void DateBook::slotSettings() | 242 | void DateBook::slotSettings() |
242 | { | 243 | { |
243 | DateBookSettings frmSettings( ampm, this ); | 244 | DateBookSettings frmSettings( ampm, this ); |
244 | frmSettings.setStartTime( startTime ); | 245 | frmSettings.setStartTime( startTime ); |
245 | frmSettings.setAlarmPreset( aPreset, presetTime ); | 246 | frmSettings.setAlarmPreset( aPreset, presetTime ); |
246 | frmSettings.setJumpToCurTime( bJumpToCurTime ); | 247 | frmSettings.setJumpToCurTime( bJumpToCurTime ); |
247 | frmSettings.setRowStyle( rowStyle ); | 248 | frmSettings.setRowStyle( rowStyle ); |
248 | frmSettings.comboDefaultView->setCurrentItem(defaultView-1); | 249 | frmSettings.comboDefaultView->setCurrentItem(defaultView-1); |
249 | frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); | 250 | frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); |
250 | frmSettings.setPluginList(db_holiday->pluginManager(),db_holiday->pluginLoader()); | 251 | frmSettings.setPluginList(db_holiday->pluginManager(),db_holiday->pluginLoader()); |
251 | 252 | ||
252 | bool found=false; | 253 | bool found=false; |
253 | for (int i=0; i<(frmSettings.comboLocation->count()); i++) { | 254 | for (int i=0; i<(frmSettings.comboLocation->count()); i++) { |
254 | if ( frmSettings.comboLocation->text(i) == defaultLocation ) { | 255 | if ( frmSettings.comboLocation->text(i) == defaultLocation ) { |
255 | frmSettings.comboLocation->setCurrentItem(i); | 256 | frmSettings.comboLocation->setCurrentItem(i); |
256 | found=true; | 257 | found=true; |
257 | break; | 258 | break; |
258 | } | 259 | } |
259 | } | 260 | } |
260 | if(!found) { | 261 | if(!found) { |
261 | frmSettings.comboLocation->insertItem(defaultLocation); | 262 | frmSettings.comboLocation->insertItem(defaultLocation); |
262 | frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); | 263 | frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); |
263 | } | 264 | } |
264 | frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); | 265 | frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); |
265 | 266 | ||
266 | if ( QPEApplication::execDialog( &frmSettings ) ) { | 267 | if ( QPEApplication::execDialog( &frmSettings ) ) { |
267 | frmSettings.savePlugins(); | 268 | frmSettings.savePlugins(); |
268 | db_holiday->pluginManager()->save(); | 269 | db_holiday->pluginManager()->save(); |
269 | db_holiday->reloadPlugins(); | 270 | db_holiday->reloadPlugins(); |
270 | 271 | ||
271 | aPreset = frmSettings.alarmPreset(); | 272 | aPreset = frmSettings.alarmPreset(); |
272 | presetTime = frmSettings.presetTime(); | 273 | presetTime = frmSettings.presetTime(); |
273 | startTime = frmSettings.startTime(); | 274 | startTime = frmSettings.startTime(); |
274 | bJumpToCurTime = frmSettings.jumpToCurTime(); | 275 | bJumpToCurTime = frmSettings.jumpToCurTime(); |
275 | rowStyle = frmSettings.rowStyle(); | 276 | rowStyle = frmSettings.rowStyle(); |
276 | defaultView=frmSettings.comboDefaultView->currentItem()+1; | 277 | defaultView=frmSettings.comboDefaultView->currentItem()+1; |
277 | weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); | 278 | weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); |
278 | defaultLocation=frmSettings.comboLocation->currentText(); | 279 | defaultLocation=frmSettings.comboLocation->currentText(); |
279 | defaultCategories=frmSettings.comboCategory->currentCategories(); | 280 | defaultCategories=frmSettings.comboCategory->currentCategories(); |
280 | 281 | ||
281 | if ( dayView ) { | 282 | if ( dayView ) { |
282 | dayView->setStartViewTime( startTime ); | 283 | dayView->setStartViewTime( startTime ); |
283 | dayView->setJumpToCurTime( bJumpToCurTime ); | 284 | dayView->setJumpToCurTime( bJumpToCurTime ); |
284 | dayView->setRowStyle( rowStyle ); | 285 | dayView->setRowStyle( rowStyle ); |
285 | } | 286 | } |
286 | if ( weekView ) { | 287 | if ( weekView ) { |
287 | weekView->setStartViewTime( startTime ); | 288 | weekView->setStartViewTime( startTime ); |
288 | } | 289 | } |
289 | saveSettings(); | 290 | saveSettings(); |
290 | 291 | ||
291 | // make the change obvious | 292 | // make the change obvious |
292 | if ( views->visibleWidget() ) { | 293 | if ( views->visibleWidget() ) { |
293 | if ( views->visibleWidget() == dayView ) | 294 | if ( views->visibleWidget() == dayView ) |
294 | dayView->redraw(); | 295 | dayView->redraw(); |
295 | else if ( views->visibleWidget() == weekView ) | 296 | else if ( views->visibleWidget() == weekView ) |
296 | weekView->redraw(); | 297 | weekView->redraw(); |
297 | else if ( views->visibleWidget() == weekLstView ) | 298 | else if ( views->visibleWidget() == weekLstView ) |
298 | weekLstView->redraw(); | 299 | weekLstView->redraw(); |
299 | } | 300 | } |
300 | } | 301 | } |
301 | } | 302 | } |
302 | 303 | ||
303 | void DateBook::fileNew() | 304 | void DateBook::fileNew() |
304 | { | 305 | { |
305 | slotNewEventFromKey(""); | 306 | slotNewEventFromKey(""); |
306 | } | 307 | } |
307 | 308 | ||
308 | QString DateBook::checkEvent(const Event &e) | 309 | QString DateBook::checkEvent(const Event &e) |
309 | { | 310 | { |
310 | /* check if overlaps with itself */ | 311 | /* check if overlaps with itself */ |
311 | bool checkFailed = FALSE; | 312 | bool checkFailed = FALSE; |
312 | 313 | ||
313 | /* check the next 12 repeats. should catch most problems */ | 314 | /* check the next 12 repeats. should catch most problems */ |
314 | QDate current_date = e.start().date(); | 315 | QDate current_date = e.start().date(); |
315 | Event previous = e; | 316 | Event previous = e; |
316 | for(int i = 0; i < 12; i++) | 317 | for(int i = 0; i < 12; i++) |
317 | { | 318 | { |
318 | QDateTime next; | 319 | QDateTime next; |
319 | if (!nextOccurance(previous, current_date.addDays(1), next)) { | 320 | if (!nextOccurance(previous, current_date.addDays(1), next)) { |
320 | break; // no more repeats | 321 | break; // no more repeats |
321 | } | 322 | } |
322 | if(next < previous.end()) { | 323 | if(next < previous.end()) { |
323 | checkFailed = TRUE; | 324 | checkFailed = TRUE; |
324 | break; | 325 | break; |
325 | } | 326 | } |
326 | current_date = next.date(); | 327 | current_date = next.date(); |
327 | } | 328 | } |
328 | 329 | ||
329 | if(checkFailed) | 330 | if(checkFailed) |
330 | return tr("Event duration is potentially longer\n" | 331 | return tr("Event duration is potentially longer\n" |
331 | "than interval between repeats."); | 332 | "than interval between repeats."); |
332 | 333 | ||
333 | return QString::null; | 334 | return QString::null; |
334 | } | 335 | } |
335 | 336 | ||
336 | QDate DateBook::currentDate() | 337 | QDate DateBook::currentDate() |
337 | { | 338 | { |
338 | QDate d = QDate::currentDate(); | 339 | QDate d = QDate::currentDate(); |
339 | 340 | ||
340 | if ( dayView && views->visibleWidget() == dayView ) { | 341 | if ( dayView && views->visibleWidget() == dayView ) { |
341 | d = dayView->date(); | 342 | d = dayView->date(); |
342 | } else if ( weekView && views->visibleWidget() == weekView ) { | 343 | } else if ( weekView && views->visibleWidget() == weekView ) { |
343 | d = weekView->date(); | 344 | d = weekView->date(); |
344 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { | 345 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { |
345 | d = weekLstView->date(); | 346 | d = weekLstView->date(); |
346 | } else if ( monthView && views->visibleWidget() == monthView ) { | 347 | } else if ( monthView && views->visibleWidget() == monthView ) { |
347 | d = monthView->selectedDate(); | 348 | d = monthView->selectedDate(); |
348 | } | 349 | } |
349 | 350 | ||
350 | return d; | 351 | return d; |
351 | } | 352 | } |
352 | 353 | ||
353 | void DateBook::view(int v, const QDate &d) { | 354 | void DateBook::view(int v, const QDate &d) { |
354 | if (v==DAY) { | 355 | if (v==DAY) { |
355 | initDay(); | 356 | initDay(); |
356 | dayAction->setOn( TRUE ); | 357 | dayAction->setOn( TRUE ); |
357 | dayView->setDate( d ); | 358 | dayView->setDate( d ); |
358 | views->raiseWidget( dayView ); | 359 | views->raiseWidget( dayView ); |
359 | dayView->redraw(); | 360 | dayView->redraw(); |
360 | } else if (v==WEEK) { | 361 | } else if (v==WEEK) { |
361 | initWeek(); | 362 | initWeek(); |
362 | weekAction->setOn( TRUE ); | 363 | weekAction->setOn( TRUE ); |
363 | weekView->setDate( d ); | 364 | weekView->setDate( d ); |
364 | views->raiseWidget( weekView ); | 365 | views->raiseWidget( weekView ); |
365 | weekView->redraw(); | 366 | weekView->redraw(); |
366 | } else if (v==WEEKLST) { | 367 | } else if (v==WEEKLST) { |
367 | initWeekLst(); | 368 | initWeekLst(); |
368 | weekLstAction->setOn( TRUE ); | 369 | weekLstAction->setOn( TRUE ); |
369 | weekLstView->setDate(d); | 370 | weekLstView->setDate(d); |
370 | views->raiseWidget( weekLstView ); | 371 | views->raiseWidget( weekLstView ); |
371 | weekLstView->redraw(); | 372 | weekLstView->redraw(); |
372 | } else if (v==MONTH) { | 373 | } else if (v==MONTH) { |
373 | initMonth(); | 374 | initMonth(); |
374 | monthAction->setOn( TRUE ); | 375 | monthAction->setOn( TRUE ); |
375 | monthView->setDate( d.year(), d.month(), d.day() ); | 376 | monthView->setDate( d.year(), d.month(), d.day() ); |
376 | views->raiseWidget( monthView ); | 377 | views->raiseWidget( monthView ); |
377 | monthView->redraw(); | 378 | monthView->redraw(); |
378 | } | 379 | } |
379 | } | 380 | } |
380 | 381 | ||
381 | void DateBook::viewDefault(const QDate &d) { | 382 | void DateBook::viewDefault(const QDate &d) { |
382 | view(defaultView,d); | 383 | view(defaultView,d); |
383 | } | 384 | } |
384 | 385 | ||
385 | void DateBook::viewDay() { | 386 | void DateBook::viewDay() { |
386 | view(DAY,currentDate()); | 387 | view(DAY,currentDate()); |
387 | } | 388 | } |
388 | 389 | ||
389 | void DateBook::viewWeek() { | 390 | void DateBook::viewWeek() { |
390 | view(WEEK,currentDate()); | 391 | view(WEEK,currentDate()); |
391 | } | 392 | } |
392 | 393 | ||
393 | void DateBook::viewWeekLst() { | 394 | void DateBook::viewWeekLst() { |
394 | view(WEEKLST,currentDate()); | 395 | view(WEEKLST,currentDate()); |
395 | } | 396 | } |
396 | 397 | ||
397 | void DateBook::viewMonth() { | 398 | void DateBook::viewMonth() { |
398 | view(MONTH,currentDate()); | 399 | view(MONTH,currentDate()); |
399 | } | 400 | } |
400 | 401 | ||
401 | void DateBook::insertEvent( const Event &e ) | 402 | void DateBook::insertEvent( const Event &e ) |
402 | { | 403 | { |
403 | Event dupEvent=e; | 404 | Event dupEvent=e; |
404 | if(!dupEvent.isValidUid() ) // tkcRom seems to be different | 405 | if(!dupEvent.isValidUid() ) // tkcRom seems to be different |
405 | dupEvent.assignUid(); | 406 | dupEvent.assignUid(); |
406 | dupEvent.setLocation(defaultLocation); | 407 | dupEvent.setLocation(defaultLocation); |
407 | dupEvent.setCategories(defaultCategories); | 408 | dupEvent.setCategories(defaultCategories); |
408 | db->addEvent(dupEvent); | 409 | db->addEvent(dupEvent); |
409 | emit newEvent(); | 410 | emit newEvent(); |
410 | } | 411 | } |
411 | 412 | ||
412 | void DateBook::duplicateEvent( const Event &e ) | 413 | void DateBook::duplicateEvent( const Event &e ) |
413 | { | 414 | { |
414 | // Alot of code duplication, as this is almost like editEvent(); | 415 | // Alot of code duplication, as this is almost like editEvent(); |
415 | if (syncing) { | 416 | if (syncing) { |
416 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 417 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
417 | return; | 418 | return; |
418 | } | 419 | } |
419 | 420 | ||
420 | Event dupevent(e); // Make a duplicate. | 421 | Event dupevent(e); // Make a duplicate. |
421 | 422 | ||
422 | // workaround added for text input. | 423 | // workaround added for text input. |
423 | QDialog editDlg( this, 0, TRUE ); | 424 | QDialog editDlg( this, 0, TRUE ); |
424 | DateEntry *entry; | 425 | DateEntry *entry; |
425 | editDlg.setCaption( tr("Duplicate Event") ); | 426 | editDlg.setCaption( tr("Duplicate Event") ); |
426 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 427 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
427 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 428 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
428 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 429 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
429 | // KLUDGE!!! | 430 | // KLUDGE!!! |
430 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 431 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
431 | vb->addWidget( sv ); | 432 | vb->addWidget( sv ); |
432 | entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); | 433 | entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); |
433 | entry->timezone->setEnabled( FALSE ); | 434 | entry->timezone->setEnabled( FALSE ); |
434 | sv->addChild( entry ); | 435 | sv->addChild( entry ); |
435 | 436 | ||
436 | while ( QPEApplication::execDialog( &editDlg ) ) { | 437 | while ( QPEApplication::execDialog( &editDlg ) ) { |
437 | Event newEv = entry->event(); | 438 | Event newEv = entry->event(); |
438 | QString error = checkEvent(newEv); | 439 | QString error = checkEvent(newEv); |
439 | if (!error.isNull()) { | 440 | if (!error.isNull()) { |
440 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) | 441 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) |
441 | continue; | 442 | continue; |
442 | } | 443 | } |
443 | /* | 444 | /* |
444 | * The problem: | 445 | * The problem: |
445 | * DateBookDB does remove repeating events not by uid but by the time | 446 | * DateBookDB does remove repeating events not by uid but by the time |
446 | * the recurrence was created | 447 | * the recurrence was created |
447 | * so we need to update that time as well | 448 | * so we need to update that time as well |
448 | */ | 449 | */ |
449 | Event::RepeatPattern rp = newEv.repeatPattern(); | 450 | Event::RepeatPattern rp = newEv.repeatPattern(); |
450 | rp.createTime = ::time( NULL ); | 451 | rp.createTime = ::time( NULL ); |
451 | newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... | 452 | newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... |
452 | if( newEv.uid() == e.uid() || !newEv.isValidUid() ) | 453 | if( newEv.uid() == e.uid() || !newEv.isValidUid() ) |
453 | newEv.assignUid(); | 454 | newEv.assignUid(); |
454 | 455 | ||
455 | db->addEvent(newEv); | 456 | db->addEvent(newEv); |
456 | emit newEvent(); | 457 | emit newEvent(); |
457 | break; | 458 | break; |
458 | } | 459 | } |
459 | } | 460 | } |
460 | 461 | ||
461 | void DateBook::editEvent( const Event &e ) | 462 | void DateBook::editEvent( const Event &e ) |
462 | { | 463 | { |
463 | if (syncing) { | 464 | if (syncing) { |
464 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 465 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
465 | return; | 466 | return; |
466 | } | 467 | } |
467 | 468 | ||
468 | // workaround added for text input. | 469 | // workaround added for text input. |
469 | QDialog editDlg( this, 0, TRUE ); | 470 | QDialog editDlg( this, 0, TRUE ); |
470 | DateEntry *entry; | 471 | DateEntry *entry; |
471 | editDlg.setCaption( tr("Edit Event") ); | 472 | editDlg.setCaption( tr("Edit Event") ); |
472 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 473 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
473 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 474 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
474 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 475 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
475 | // KLUDGE!!! | 476 | // KLUDGE!!! |
476 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 477 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
477 | vb->addWidget( sv ); | 478 | vb->addWidget( sv ); |
478 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); | 479 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); |
479 | entry->timezone->setEnabled( FALSE ); | 480 | entry->timezone->setEnabled( FALSE ); |
480 | sv->addChild( entry ); | 481 | sv->addChild( entry ); |
481 | 482 | ||
482 | while ( QPEApplication::execDialog( &editDlg ) ) { | 483 | while ( QPEApplication::execDialog( &editDlg ) ) { |
483 | Event newEv = entry->event(); | 484 | Event newEv = entry->event(); |
484 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) | 485 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) |
485 | break; | 486 | break; |
486 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid | 487 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid |
487 | QString error = checkEvent(newEv); | 488 | QString error = checkEvent(newEv); |
488 | if (!error.isNull()) { | 489 | if (!error.isNull()) { |
489 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; | 490 | if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; |
490 | } | 491 | } |
491 | db->editEvent(e, newEv); | 492 | db->editEvent(e, newEv); |
492 | emit newEvent(); | 493 | emit newEvent(); |
493 | break; | 494 | break; |
494 | } | 495 | } |
495 | } | 496 | } |
496 | 497 | ||
497 | void DateBook::removeEvent( const Event &e ) | 498 | void DateBook::removeEvent( const Event &e ) |
498 | { | 499 | { |
499 | if (syncing) { | 500 | if (syncing) { |
500 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 501 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
501 | return; | 502 | return; |
502 | } | 503 | } |
503 | 504 | ||
504 | QString strName = e.description(); | 505 | QString strName = e.description(); |
505 | 506 | ||
506 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) | 507 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) |
507 | return; | 508 | return; |
508 | 509 | ||
509 | db->removeEvent( e ); | 510 | db->removeEvent( e ); |
510 | if ( views->visibleWidget() == dayView && dayView ) | 511 | if ( views->visibleWidget() == dayView && dayView ) |
511 | dayView->redraw(); | 512 | dayView->redraw(); |
512 | 513 | ||
513 | } | 514 | } |
514 | 515 | ||
515 | void DateBook::addEvent( const Event &e ) | 516 | void DateBook::addEvent( const Event &e ) |
516 | { | 517 | { |
517 | QDate d = e.start().date(); | 518 | QDate d = e.start().date(); |
518 | initDay(); | 519 | initDay(); |
519 | dayView->setDate( d ); | 520 | dayView->setDate( d ); |
520 | } | 521 | } |
521 | 522 | ||
522 | void DateBook::showDay( int year, int month, int day ) | 523 | void DateBook::showDay( int year, int month, int day ) |
523 | { | 524 | { |
524 | QDate d(year, month, day); | 525 | QDate d(year, month, day); |
525 | view(DAY,d); | 526 | view(DAY,d); |
526 | } | 527 | } |
527 | 528 | ||
528 | void DateBook::initDay() | 529 | void DateBook::initDay() |
529 | { | 530 | { |
530 | if ( !dayView ) { | 531 | if ( !dayView ) { |
531 | dayView = new DateBookDay( ampm, onMonday, db, db_holiday, views, "day view" ); | 532 | dayView = new DateBookDay( ampm, onMonday, db, db_holiday, views, "day view" ); |
532 | views->addWidget( dayView, DAY ); | 533 | views->addWidget( dayView, DAY ); |
533 | dayView->setJumpToCurTime( bJumpToCurTime ); | 534 | dayView->setJumpToCurTime( bJumpToCurTime ); |
534 | dayView->setStartViewTime( startTime ); | 535 | dayView->setStartViewTime( startTime ); |
535 | dayView->setRowStyle( rowStyle ); | 536 | dayView->setRowStyle( rowStyle ); |
536 | connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); | 537 | connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); |
537 | connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); | 538 | connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); |
538 | connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) ); | 539 | connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) ); |
539 | connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); | 540 | connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) ); |
540 | connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) ); | 541 | connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) ); |
541 | connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); | 542 | connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) ); |
542 | connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) ); | 543 | connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) ); |
543 | } | 544 | } |
544 | } | 545 | } |
545 | 546 | ||
546 | void DateBook::initWeek() | 547 | void DateBook::initWeek() |
547 | { | 548 | { |
548 | if ( !weekView ) { | 549 | if ( !weekView ) { |
549 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); | 550 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); |
550 | weekView->setStartViewTime( startTime ); | 551 | weekView->setStartViewTime( startTime ); |
551 | views->addWidget( weekView, WEEK ); | 552 | views->addWidget( weekView, WEEK ); |
552 | connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); | 553 | connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) ); |
553 | connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); | 554 | connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); |
554 | } | 555 | } |
555 | 556 | ||
556 | //But also get it right: the year that we display can be different | 557 | //But also get it right: the year that we display can be different |
557 | //from the year of the current date. So, first find the year | 558 | //from the year of the current date. So, first find the year |
558 | //number of the current week. | 559 | //number of the current week. |
559 | int yearNumber, totWeeks; | 560 | int yearNumber, totWeeks; |
560 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); | 561 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); |
561 | 562 | ||
562 | QDate d = QDate( yearNumber, 12, 31 ); | 563 | QDate d = QDate( yearNumber, 12, 31 ); |
563 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 564 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
564 | 565 | ||
565 | while ( totWeeks == 1 ) { | 566 | while ( totWeeks == 1 ) { |
566 | d = d.addDays( -1 ); | 567 | d = d.addDays( -1 ); |
567 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 568 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
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 | ||
617 | defaultLocation=config.readEntry("defaultLocation"); | 618 | defaultLocation=config.readEntry("defaultLocation"); |
618 | QString tmpString=config.readEntry("defaultCategories"); | 619 | QString tmpString=config.readEntry("defaultCategories"); |
619 | QStringList tmpStringList=QStringList::split(",",tmpString); | 620 | QStringList tmpStringList=QStringList::split(",",tmpString); |
620 | defaultCategories.truncate(0); | 621 | defaultCategories.truncate(0); |
621 | 622 | ||
622 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { | 623 | for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { |
623 | defaultCategories.resize(defaultCategories.count()+1); | 624 | defaultCategories.resize(defaultCategories.count()+1); |
624 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); | 625 | defaultCategories[defaultCategories.count()-1]=(*i).toInt(); |
625 | } | 626 | } |
626 | } | 627 | } |
627 | 628 | ||
628 | void DateBook::saveSettings() | 629 | void DateBook::saveSettings() |
629 | { | 630 | { |
630 | Config config( "qpe" ); | 631 | Config config( "qpe" ); |
631 | Config configDB( "DateBook" ); | 632 | Config configDB( "DateBook" ); |
632 | configDB.setGroup( "Main" ); | 633 | configDB.setGroup( "Main" ); |
633 | configDB.writeEntry("startviewtime",startTime); | 634 | configDB.writeEntry("startviewtime",startTime); |
634 | configDB.writeEntry("alarmpreset",aPreset); | 635 | configDB.writeEntry("alarmpreset",aPreset); |
635 | configDB.writeEntry("presettime",presetTime); | 636 | configDB.writeEntry("presettime",presetTime); |
636 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); | 637 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); |
637 | configDB.writeEntry("rowstyle", rowStyle); | 638 | configDB.writeEntry("rowstyle", rowStyle); |
638 | configDB.writeEntry("defaultview",defaultView); | 639 | configDB.writeEntry("defaultview",defaultView); |
639 | configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); | 640 | configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); |
640 | 641 | ||
641 | configDB.writeEntry("defaultLocation",defaultLocation); | 642 | configDB.writeEntry("defaultLocation",defaultLocation); |
642 | QStringList tmpStringList; | 643 | QStringList tmpStringList; |
643 | for( uint i=0; i<defaultCategories.count(); i++) { | 644 | for( uint i=0; i<defaultCategories.count(); i++) { |
644 | tmpStringList << QString::number(defaultCategories[i]); | 645 | tmpStringList << QString::number(defaultCategories[i]); |
645 | } | 646 | } |
646 | configDB.writeEntry("defaultCategories",tmpStringList.join(",")); | 647 | configDB.writeEntry("defaultCategories",tmpStringList.join(",")); |
647 | } | 648 | } |
648 | 649 | ||
649 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) | 650 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) |
650 | { | 651 | { |
651 | bool needShow = FALSE; | 652 | bool needShow = FALSE; |
652 | if ( msg == "alarm(QDateTime,int)" ) { | 653 | if ( msg == "alarm(QDateTime,int)" ) { |
653 | QDataStream ds(data,IO_ReadOnly); | 654 | QDataStream ds(data,IO_ReadOnly); |
654 | QDateTime when; int warn; | 655 | QDateTime when; int warn; |
655 | ds >> when >> warn; | 656 | ds >> when >> warn; |
656 | 657 | ||
657 | // check to make it's okay to continue, | 658 | // check to make it's okay to continue, |
658 | // this is the case that the time was set ahead, and | 659 | // this is the case that the time was set ahead, and |
659 | // we are forced given a stale alarm... | 660 | // we are forced given a stale alarm... |
660 | QDateTime current = QDateTime::currentDateTime(); | 661 | QDateTime current = QDateTime::currentDateTime(); |
661 | if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) | 662 | if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) |
662 | return; | 663 | return; |
663 | 664 | ||
664 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); | 665 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); |
665 | if ( list.count() > 0 ) { | 666 | if ( list.count() > 0 ) { |
666 | QString msg; | 667 | QString msg; |
667 | bool bSound = FALSE; | 668 | bool bSound = FALSE; |
668 | int stopTimer = 0; | 669 | int stopTimer = 0; |
669 | bool found = FALSE; | 670 | bool found = FALSE; |
670 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { | 671 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { |
671 | if ( (*it).event().hasAlarm() ) { | 672 | if ( (*it).event().hasAlarm() ) { |
672 | found = TRUE; | 673 | found = TRUE; |
673 | msg += "<CENTER><B>" + (*it).description() + "</B>" | 674 | msg += "<CENTER><B>" + (*it).description() + "</B>" |
674 | + "<BR>" + (*it).location() + "<BR>" | 675 | + "<BR>" + (*it).location() + "<BR>" |
675 | + TimeString::dateString((*it).event().start(),ampm) | 676 | + TimeString::dateString((*it).event().start(),ampm) |
676 | + (warn | 677 | + (warn |
677 | ? tr(" (in " + QString::number(warn) | 678 | ? tr(" (in " + QString::number(warn) |
678 | + tr(" minutes)")) | 679 | + tr(" minutes)")) |
679 | : QString("")) | 680 | : QString("")) |
680 | + "<BR>" | 681 | + "<BR>" |
681 | + (*it).notes() + "</CENTER>"; | 682 | + (*it).notes() + "</CENTER>"; |
682 | if ( (*it).event().alarmSound() != Event::Silent ) { | 683 | if ( (*it).event().alarmSound() != Event::Silent ) { |
683 | bSound = TRUE; | 684 | bSound = TRUE; |
684 | } | 685 | } |
685 | } | 686 | } |
686 | } | 687 | } |
687 | if ( found ) { | 688 | if ( found ) { |
688 | if ( bSound ) { | 689 | if ( bSound ) { |
689 | Sound::soundAlarm(); | 690 | Sound::soundAlarm(); |
690 | alarmCounter = 0; | 691 | alarmCounter = 0; |
691 | stopTimer = startTimer( 5000 ); | 692 | stopTimer = startTimer( 5000 ); |
692 | } | 693 | } |
693 | QDialog dlg( this, 0, TRUE ); | 694 | QDialog dlg( this, 0, TRUE ); |
694 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); | 695 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); |
695 | QScrollView *view = new QScrollView( &dlg, "scrollView"); | 696 | QScrollView *view = new QScrollView( &dlg, "scrollView"); |
696 | view->setResizePolicy( QScrollView::AutoOneFit ); | 697 | view->setResizePolicy( QScrollView::AutoOneFit ); |
697 | vb->addWidget( view ); | 698 | vb->addWidget( view ); |
698 | QLabel *lblMsg = new QLabel( msg, &dlg ); | 699 | QLabel *lblMsg = new QLabel( msg, &dlg ); |
699 | view->addChild( lblMsg ); | 700 | view->addChild( lblMsg ); |
700 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); | 701 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); |
701 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); | 702 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); |
702 | vb->addWidget( cmdOk ); | 703 | vb->addWidget( cmdOk ); |
703 | 704 | ||
704 | needShow = QPEApplication::execDialog( &dlg ); | 705 | needShow = QPEApplication::execDialog( &dlg ); |
705 | 706 | ||
706 | if ( bSound ) | 707 | if ( bSound ) |
707 | killTimer( stopTimer ); | 708 | killTimer( stopTimer ); |
708 | } | 709 | } |
709 | } | 710 | } |
710 | } else if ( msg == "nextView()" ) { | 711 | } else if ( msg == "nextView()" ) { |
711 | needShow = true; | 712 | needShow = true; |
712 | if ( !qApp-> activeWindow ( )) { | 713 | if ( !qApp-> activeWindow ( )) { |
713 | needShow = TRUE; | 714 | needShow = TRUE; |
714 | } else { | 715 | } else { |
715 | QWidget* cur = views->visibleWidget(); | 716 | QWidget* cur = views->visibleWidget(); |
716 | if ( cur ) { | 717 | if ( cur ) { |
717 | if ( cur == dayView ) | 718 | if ( cur == dayView ) |
718 | viewWeek(); | 719 | viewWeek(); |
719 | else if ( cur == weekView ) | 720 | else if ( cur == weekView ) |
720 | viewWeekLst(); | 721 | viewWeekLst(); |
721 | else if ( cur == weekLstView ) | 722 | else if ( cur == weekLstView ) |
722 | viewMonth(); | 723 | viewMonth(); |
723 | else if ( cur == monthView ) | 724 | else if ( cur == monthView ) |
724 | viewDay(); | 725 | viewDay(); |
725 | needShow = TRUE; | 726 | needShow = TRUE; |
726 | } | 727 | } |
727 | } | 728 | } |
728 | } else if (msg == "editEvent(int)") { | 729 | } else if (msg == "editEvent(int)") { |
729 | /* simple copy from receive */ | 730 | /* simple copy from receive */ |
730 | QDataStream stream(data,IO_ReadOnly); | 731 | QDataStream stream(data,IO_ReadOnly); |
731 | int uid; | 732 | int uid; |
732 | stream >> uid; | 733 | stream >> uid; |
733 | Event e=db->eventByUID(uid); | 734 | Event e=db->eventByUID(uid); |
734 | editEvent(e); | 735 | editEvent(e); |
735 | } else if (msg == "viewDefault(QDate)"){ | 736 | } else if (msg == "viewDefault(QDate)"){ |
736 | /* simple copy from receive */ | 737 | /* simple copy from receive */ |
737 | QDataStream stream(data,IO_ReadOnly); | 738 | QDataStream stream(data,IO_ReadOnly); |
738 | QDate day; | 739 | QDate day; |
739 | stream >> day; | 740 | stream >> day; |
740 | viewDefault(day); | 741 | viewDefault(day); |
741 | needShow = true; | 742 | needShow = true; |
742 | } | 743 | } |
743 | 744 | ||
744 | if ( needShow ) { | 745 | if ( needShow ) { |
745 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 746 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
746 | // showMaximized(); | 747 | // showMaximized(); |
747 | #else | 748 | #else |
748 | // show(); | 749 | // show(); |
749 | #endif | 750 | #endif |
750 | // raise(); | 751 | // raise(); |
751 | QPEApplication::setKeepRunning(); | 752 | QPEApplication::setKeepRunning(); |
752 | // setActiveWindow(); | 753 | // setActiveWindow(); |
753 | } | 754 | } |
754 | } | 755 | } |
755 | 756 | ||
756 | void DateBook::reload() | 757 | void DateBook::reload() |
757 | { | 758 | { |
758 | db->reload(); | 759 | db->reload(); |
759 | if ( dayAction->isOn() ) viewDay(); | 760 | if ( dayAction->isOn() ) viewDay(); |
760 | else if ( weekAction->isOn() ) viewWeek(); | 761 | else if ( weekAction->isOn() ) viewWeek(); |
761 | else if ( monthAction->isOn() ) viewMonth(); | 762 | else if ( monthAction->isOn() ) viewMonth(); |
762 | syncing = FALSE; | 763 | syncing = FALSE; |
763 | } | 764 | } |
764 | 765 | ||
765 | void DateBook::flush() | 766 | void DateBook::flush() |
766 | { | 767 | { |
767 | syncing = TRUE; | 768 | syncing = TRUE; |
768 | db->save(); | 769 | db->save(); |
769 | } | 770 | } |
770 | 771 | ||
771 | void DateBook::timerEvent( QTimerEvent *e ) | 772 | void DateBook::timerEvent( QTimerEvent *e ) |
772 | { | 773 | { |
773 | if ( alarmCounter < 10 ) { | 774 | if ( alarmCounter < 10 ) { |
774 | alarmCounter++; | 775 | alarmCounter++; |
775 | Sound::soundAlarm(); | 776 | Sound::soundAlarm(); |
776 | } else { | 777 | } else { |
777 | killTimer( e->timerId() ); | 778 | killTimer( e->timerId() ); |
778 | } | 779 | } |
779 | } | 780 | } |
780 | 781 | ||
781 | void DateBook::changeClock( bool newClock ) | 782 | void DateBook::changeClock( bool newClock ) |
782 | { | 783 | { |
783 | ampm = newClock; | 784 | ampm = newClock; |
784 | // repaint the affected objects... | 785 | // repaint the affected objects... |
785 | if (dayView) dayView->redraw(); | 786 | if (dayView) dayView->redraw(); |
786 | if (weekView) weekView->redraw(); | 787 | if (weekView) weekView->redraw(); |
787 | if (weekLstView) weekLstView->redraw(); | 788 | if (weekLstView) weekLstView->redraw(); |
788 | } | 789 | } |
789 | 790 | ||
790 | void DateBook::changeWeek( bool m ) | 791 | void DateBook::changeWeek( bool m ) |
791 | { | 792 | { |
792 | /* no need to redraw, each widget catches. Do need to | 793 | /* no need to redraw, each widget catches. Do need to |
793 | store though for widgets we haven't made yet */ | 794 | store though for widgets we haven't made yet */ |
794 | onMonday = m; | 795 | onMonday = m; |
795 | } | 796 | } |
796 | 797 | ||
797 | void DateBook::slotToday() | 798 | void DateBook::slotToday() |
798 | { | 799 | { |
799 | // we need to view today using default view | 800 | // we need to view today using default view |
800 | view(defaultView,QDate::currentDate()); | 801 | view(defaultView,QDate::currentDate()); |
801 | } | 802 | } |
802 | 803 | ||
803 | void DateBook::closeEvent( QCloseEvent *e ) | 804 | void DateBook::closeEvent( QCloseEvent *e ) |
804 | { | 805 | { |
805 | if(syncing) { | 806 | if(syncing) { |
806 | /* no need to save, did that at flush */ | 807 | /* no need to save, did that at flush */ |
807 | e->accept(); | 808 | e->accept(); |
808 | return; | 809 | return; |
809 | } | 810 | } |
810 | 811 | ||
811 | // save settings will generate it's own error messages, no | 812 | // save settings will generate it's own error messages, no |
812 | // need to do checking ourselves. | 813 | // need to do checking ourselves. |
813 | saveSettings(); | 814 | saveSettings(); |
814 | if ( db->save() ) { | 815 | if ( db->save() ) { |
815 | e->accept(); | 816 | e->accept(); |
816 | } else { | 817 | } else { |
817 | if ( QMessageBox::critical( this, tr( "Out of space" ), | 818 | if ( QMessageBox::critical( this, tr( "Out of space" ), |
818 | tr("Calendar was unable to save\n" | 819 | tr("Calendar was unable to save\n" |
819 | "your changes.\n" | 820 | "your changes.\n" |
820 | "Free up some space and try again.\n" | 821 | "Free up some space and try again.\n" |
821 | "\nQuit anyway?"), | 822 | "\nQuit anyway?"), |
822 | QMessageBox::Yes|QMessageBox::Escape, | 823 | QMessageBox::Yes|QMessageBox::Escape, |
823 | QMessageBox::No|QMessageBox::Default ) | 824 | QMessageBox::No|QMessageBox::Default ) |
824 | != QMessageBox::No ) | 825 | != QMessageBox::No ) |
825 | e->accept(); | 826 | e->accept(); |
826 | else | 827 | else |
827 | e->ignore(); | 828 | e->ignore(); |
828 | } | 829 | } |
829 | } | 830 | } |
830 | 831 | ||
831 | // Entering directly from the "keyboard" | 832 | // Entering directly from the "keyboard" |
832 | void DateBook::slotNewEventFromKey( const QString &str ) | 833 | void DateBook::slotNewEventFromKey( const QString &str ) |
833 | { | 834 | { |
834 | if (syncing) { | 835 | if (syncing) { |
835 | QMessageBox::warning( this, tr("Calendar"), | 836 | QMessageBox::warning( this, tr("Calendar"), |
836 | tr( "Can not edit data, currently syncing") ); | 837 | tr( "Can not edit data, currently syncing") ); |
837 | return; | 838 | return; |
838 | } | 839 | } |
839 | 840 | ||
840 | // We get to here from a key pressed in the Day View | 841 | // We get to here from a key pressed in the Day View |
841 | // So we can assume some things. We want the string | 842 | // So we can assume some things. We want the string |
842 | // passed in to be part of the description. | 843 | // passed in to be part of the description. |
843 | QDateTime start, end; | 844 | QDateTime start, end; |
844 | if ( views->visibleWidget() == dayView ) { | 845 | if ( views->visibleWidget() == dayView ) { |
845 | dayView->selectedDates( start, end ); | 846 | dayView->selectedDates( start, end ); |
846 | } else if ( views->visibleWidget() == monthView ) { | 847 | } else if ( views->visibleWidget() == monthView ) { |
847 | QDate d = monthView->selectedDate(); | 848 | QDate d = monthView->selectedDate(); |
848 | start = end = d; | 849 | start = end = d; |
849 | start.setTime( QTime( 10, 0 ) ); | 850 | start.setTime( QTime( 10, 0 ) ); |
850 | end.setTime( QTime( 12, 0 ) ); | 851 | end.setTime( QTime( 12, 0 ) ); |
851 | } else if ( views->visibleWidget() == weekView ) { | 852 | } else if ( views->visibleWidget() == weekView ) { |
852 | QDate d = weekView->date(); | 853 | QDate d = weekView->date(); |
853 | start = end = d; | 854 | start = end = d; |
854 | start.setTime( QTime( 10, 0 ) ); | 855 | start.setTime( QTime( 10, 0 ) ); |
855 | end.setTime( QTime( 12, 0 ) ); | 856 | end.setTime( QTime( 12, 0 ) ); |
856 | } else if ( views->visibleWidget() == weekLstView ) { | 857 | } else if ( views->visibleWidget() == weekLstView ) { |
857 | QDate d = weekLstView->date(); | 858 | QDate d = weekLstView->date(); |
858 | start = end = d; | 859 | start = end = d; |
859 | start.setTime( QTime( 10, 0 ) ); | 860 | start.setTime( QTime( 10, 0 ) ); |
860 | end.setTime( QTime( 12, 0 ) ); | 861 | end.setTime( QTime( 12, 0 ) ); |
861 | } | 862 | } |
862 | slotNewEntry(start, end, str); | 863 | slotNewEntry(start, end, str); |
863 | } | 864 | } |
864 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { | 865 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { |
865 | // argh! This really needs to be encapsulated in a class | 866 | // argh! This really needs to be encapsulated in a class |
866 | // or function. | 867 | // or function. |
867 | QDialog newDlg( this, 0, TRUE ); | 868 | QDialog newDlg( this, 0, TRUE ); |
868 | newDlg.setCaption( DateEntryBase::tr("New Event") ); | 869 | newDlg.setCaption( DateEntryBase::tr("New Event") ); |
869 | DateEntry *e; | 870 | DateEntry *e; |
870 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); | 871 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); |
871 | QScrollView *sv = new QScrollView( &newDlg ); | 872 | QScrollView *sv = new QScrollView( &newDlg ); |
872 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 873 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
873 | sv->setFrameStyle( QFrame::NoFrame ); | 874 | sv->setFrameStyle( QFrame::NoFrame ); |
874 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 875 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
875 | vb->addWidget( sv ); | 876 | vb->addWidget( sv ); |
876 | 877 | ||
877 | Event ev; | 878 | Event ev; |
878 | ev.setDescription( str ); | 879 | ev.setDescription( str ); |
879 | // When the new gui comes in, change this... | 880 | // When the new gui comes in, change this... |
880 | if(location==0) { | 881 | if(location==0) { |
881 | if(defaultLocation.isEmpty()) { | 882 | if(defaultLocation.isEmpty()) { |
882 | ev.setLocation(tr("(Unknown)")); | 883 | ev.setLocation(tr("(Unknown)")); |
883 | } else { | 884 | } else { |
884 | ev.setLocation( defaultLocation ); | 885 | ev.setLocation( defaultLocation ); |
885 | } | 886 | } |
886 | } else { | 887 | } else { |
887 | ev.setLocation(location); | 888 | ev.setLocation(location); |
888 | } | 889 | } |
889 | ev.setCategories(defaultCategories); | 890 | ev.setCategories(defaultCategories); |
890 | ev.setStart( start ); | 891 | ev.setStart( start ); |
891 | ev.setEnd( end ); | 892 | ev.setEnd( end ); |
892 | 893 | ||
893 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); | 894 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); |
894 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); | 895 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); |
895 | sv->addChild( e ); | 896 | sv->addChild( e ); |
896 | while ( QPEApplication::execDialog( &newDlg ) ) { | 897 | while ( QPEApplication::execDialog( &newDlg ) ) { |
897 | ev = e->event(); | 898 | ev = e->event(); |
898 | ev.assignUid(); | 899 | ev.assignUid(); |
899 | QString error = checkEvent( ev ); | 900 | QString error = checkEvent( ev ); |
900 | if ( !error.isNull() ) { | 901 | if ( !error.isNull() ) { |
901 | if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) | 902 | if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) |
902 | continue; | 903 | continue; |
903 | } | 904 | } |
904 | db->addEvent( ev ); | 905 | db->addEvent( ev ); |
905 | emit newEvent(); | 906 | emit newEvent(); |
906 | break; | 907 | break; |
907 | } | 908 | } |
908 | } | 909 | } |
909 | 910 | ||
910 | void DateBook::setDocument( const QString &filename ) | 911 | void DateBook::setDocument( const QString &filename ) |
911 | { | 912 | { |
912 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; | 913 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; |
913 | 914 | ||
914 | QValueList<Event> tl = Event::readVCalendar( filename ); | 915 | QValueList<Event> tl = Event::readVCalendar( filename ); |
915 | for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { | 916 | for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { |
916 | db->addEvent( *it ); | 917 | db->addEvent( *it ); |
917 | } | 918 | } |
918 | } | 919 | } |
919 | 920 | ||
920 | static const char * beamfile = "/tmp/obex/event.vcs"; | 921 | static const char * beamfile = "/tmp/obex/event.vcs"; |
921 | 922 | ||
922 | void DateBook::beamEvent( const Event &e ) | 923 | void DateBook::beamEvent( const Event &e ) |
923 | { | 924 | { |
924 | odebug << "trying to beam" << oendl; | 925 | odebug << "trying to beam" << oendl; |
925 | unlink( beamfile ); // delete if exists | 926 | unlink( beamfile ); // delete if exists |
926 | mkdir("/tmp/obex/", 0755); | 927 | mkdir("/tmp/obex/", 0755); |
927 | Event::writeVCalendar( beamfile, e ); | 928 | Event::writeVCalendar( beamfile, e ); |
928 | Ir *ir = new Ir( this ); | 929 | Ir *ir = new Ir( this ); |
929 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 930 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
930 | QString description = e.description(); | 931 | QString description = e.description(); |
931 | ir->send( beamfile, description, "text/x-vCalendar" ); | 932 | ir->send( beamfile, description, "text/x-vCalendar" ); |
932 | } | 933 | } |
933 | 934 | ||
934 | void DateBook::beamDone( Ir *ir ) | 935 | void DateBook::beamDone( Ir *ir ) |
935 | { | 936 | { |
936 | delete ir; | 937 | delete ir; |
937 | unlink( beamfile ); | 938 | unlink( beamfile ); |
938 | } | 939 | } |
939 | 940 | ||
940 | void DateBook::slotFind() | 941 | void DateBook::slotFind() |
941 | { | 942 | { |
942 | // move it to the day view... | 943 | // move it to the day view... |
943 | viewDay(); | 944 | viewDay(); |
944 | FindDialog frmFind( "Calendar", this ); // no tr needed | 945 | FindDialog frmFind( "Calendar", this ); // no tr needed |
945 | frmFind.setUseDate( true ); | 946 | frmFind.setUseDate( true ); |
946 | frmFind.setDate( currentDate() ); | 947 | frmFind.setDate( currentDate() ); |
947 | QObject::connect( &frmFind, | 948 | QObject::connect( &frmFind, |
948 | SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)), | 949 | SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)), |
949 | this, | 950 | this, |
950 | SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) ); | 951 | SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) ); |
951 | QObject::connect( this, | 952 | QObject::connect( this, |
952 | SIGNAL(signalNotFound()), | 953 | SIGNAL(signalNotFound()), |
953 | &frmFind, | 954 | &frmFind, |
954 | SLOT(slotNotFound()) ); | 955 | SLOT(slotNotFound()) ); |
955 | QObject::connect( this, | 956 | QObject::connect( this, |
956 | SIGNAL(signalWrapAround()), | 957 | SIGNAL(signalWrapAround()), |
957 | &frmFind, | 958 | &frmFind, |
958 | SLOT(slotWrapAround()) ); | 959 | SLOT(slotWrapAround()) ); |
959 | frmFind.move(0,0); | 960 | frmFind.move(0,0); |
960 | frmFind.exec(); | 961 | frmFind.exec(); |
961 | inSearch = false; | 962 | inSearch = false; |
962 | } | 963 | } |
963 | 964 | ||
964 | bool catComp( QArray<int> cats, int category ) | 965 | bool catComp( QArray<int> cats, int category ) |
965 | { | 966 | { |
966 | bool returnMe; | 967 | bool returnMe; |
967 | int i, | 968 | int i, |
968 | count; | 969 | count; |
969 | 970 | ||
970 | count = int(cats.count()); | 971 | count = int(cats.count()); |
971 | returnMe = false; | 972 | returnMe = false; |
972 | if ( (category == -1 && count == 0) || category == -2 ) | 973 | if ( (category == -1 && count == 0) || category == -2 ) |
973 | returnMe = true; | 974 | returnMe = true; |
974 | else { | 975 | else { |
975 | for ( i = 0; i < count; i++ ) { | 976 | for ( i = 0; i < count; i++ ) { |
976 | if ( category == cats[i] ) { | 977 | if ( category == cats[i] ) { |
977 | returnMe = true; | 978 | returnMe = true; |
978 | break; | 979 | break; |
979 | } | 980 | } |
980 | } | 981 | } |
981 | } | 982 | } |
982 | return returnMe; | 983 | return returnMe; |
983 | } | 984 | } |
984 | 985 | ||
985 | 986 | ||
986 | void DateBook::slotDoFind( const QString& txt, const QDate &dt, | 987 | void DateBook::slotDoFind( const QString& txt, const QDate &dt, |
987 | bool caseSensitive, bool /*backwards*/, | 988 | bool caseSensitive, bool /*backwards*/, |
988 | int category ) | 989 | int category ) |
989 | { | 990 | { |
990 | QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), | 991 | QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), |
991 | next; | 992 | next; |
992 | 993 | ||
993 | QRegExp r( txt ); | 994 | QRegExp r( txt ); |
994 | r.setCaseSensitive( caseSensitive ); | 995 | r.setCaseSensitive( caseSensitive ); |
995 | 996 | ||
996 | 997 | ||
997 | static Event rev, nonrev; | 998 | static Event rev, nonrev; |
998 | if ( !inSearch ) { | 999 | if ( !inSearch ) { |
999 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); | 1000 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); |
1000 | nonrev.setStart( rev.start() ); | 1001 | nonrev.setStart( rev.start() ); |
1001 | inSearch = true; | 1002 | inSearch = true; |
1002 | } | 1003 | } |
1003 | static QDate searchDate = dt; | 1004 | static QDate searchDate = dt; |
1004 | // if true at the end we will start at the begin again and afterwards | 1005 | // if true at the end we will start at the begin again and afterwards |
1005 | // we will emit string not found | 1006 | // we will emit string not found |
1006 | static bool wrapAround = true; | 1007 | static bool wrapAround = true; |
1007 | bool candidtate; | 1008 | bool candidtate; |
1008 | candidtate = false; | 1009 | candidtate = false; |
1009 | 1010 | ||
1010 | QValueList<Event> repeats = db->getRawRepeats(); | 1011 | QValueList<Event> repeats = db->getRawRepeats(); |
1011 | 1012 | ||
1012 | // find the candidate for the first repeat that matches... | 1013 | // find the candidate for the first repeat that matches... |
1013 | // first check if there can ever be a match and then compute | 1014 | // first check if there can ever be a match and then compute |
1014 | // the next occurence from start. See if this event is closer | 1015 | // the next occurence from start. See if this event is closer |
1015 | // to the beginning (start. next < dtEnd) and not smaller then the last | 1016 | // to the beginning (start. next < dtEnd) and not smaller then the last |
1016 | // result. If we find a canditate we set the dtEnd to the time | 1017 | // result. If we find a canditate we set the dtEnd to the time |
1017 | // of the ocurrence and rev to this occurence. | 1018 | // of the ocurrence and rev to this occurence. |
1018 | // set wrap around to true because there might be more events coming | 1019 | // set wrap around to true because there might be more events coming |
1019 | // and we're not at the end. | 1020 | // and we're not at the end. |
1020 | QValueListConstIterator<Event> it; | 1021 | QValueListConstIterator<Event> it; |
1021 | QDate start = dt; | 1022 | QDate start = dt; |
1022 | for ( it = repeats.begin(); it != repeats.end(); ++it ) { | 1023 | for ( it = repeats.begin(); it != repeats.end(); ++it ) { |
1023 | if ( catComp( (*it).categories(), category ) ) { | 1024 | if ( catComp( (*it).categories(), category ) ) { |
1024 | if ( (*it).match( r ) ) { | 1025 | if ( (*it).match( r ) ) { |
1025 | if ( nextOccurance( *it, start, next ) ) { | 1026 | if ( nextOccurance( *it, start, next ) ) { |
1026 | if ( next < dtEnd && !(next <= rev.start() ) ) { | 1027 | if ( next < dtEnd && !(next <= rev.start() ) ) { |
1027 | rev = *it; | 1028 | rev = *it; |
1028 | dtEnd = next; | 1029 | dtEnd = next; |
1029 | rev.setStart( next ); | 1030 | rev.setStart( next ); |
1030 | candidtate = true; | 1031 | candidtate = true; |
1031 | wrapAround = true; | 1032 | wrapAround = true; |
1032 | } | 1033 | } |
1033 | } | 1034 | } |
1034 | } | 1035 | } |
1035 | } | 1036 | } |
1036 | } | 1037 | } |
1037 | 1038 | ||
1038 | // now the for first non repeat... | 1039 | // now the for first non repeat... |
1039 | // dtEnd is set by the previous iteration of repeatingEvents | 1040 | // dtEnd is set by the previous iteration of repeatingEvents |
1040 | // check if we find a closer item. Also set dtEnd to find even | 1041 | // check if we find a closer item. Also set dtEnd to find even |
1041 | // more close occurrence | 1042 | // more close occurrence |
1042 | QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); | 1043 | QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); |
1043 | qHeapSort( nonRepeats.begin(), nonRepeats.end() ); | 1044 | qHeapSort( nonRepeats.begin(), nonRepeats.end() ); |
1044 | for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { | 1045 | for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { |
1045 | if ( catComp( (*it).categories(), category ) ) { | 1046 | if ( catComp( (*it).categories(), category ) ) { |
1046 | if ( (*it).start() < dtEnd ) { | 1047 | if ( (*it).start() < dtEnd ) { |
1047 | if ( (*it).match( r ) && !(*it <= nonrev) ) { | 1048 | if ( (*it).match( r ) && !(*it <= nonrev) ) { |
1048 | nonrev = *it; | 1049 | nonrev = *it; |
1049 | dtEnd = nonrev.start(); | 1050 | dtEnd = nonrev.start(); |
1050 | candidtate = true; | 1051 | candidtate = true; |
1051 | wrapAround = true; | 1052 | wrapAround = true; |
1052 | break; | 1053 | break; |
1053 | } | 1054 | } |
1054 | } | 1055 | } |
1055 | } | 1056 | } |
1056 | } | 1057 | } |
1057 | if ( candidtate ) { | 1058 | if ( candidtate ) { |
1058 | dayView->setStartViewTime( dtEnd.time().hour() ); | 1059 | dayView->setStartViewTime( dtEnd.time().hour() ); |
1059 | dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), | 1060 | dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), |
1060 | dtEnd.date().day() ); | 1061 | dtEnd.date().day() ); |
1061 | } else { | 1062 | } else { |
1062 | if ( wrapAround ) { | 1063 | if ( wrapAround ) { |
1063 | emit signalWrapAround(); | 1064 | emit signalWrapAround(); |
1064 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); | 1065 | rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); |
1065 | nonrev.setStart( rev.start() ); | 1066 | nonrev.setStart( rev.start() ); |
1066 | } else | 1067 | } else |
1067 | emit signalNotFound(); | 1068 | emit signalNotFound(); |
1068 | wrapAround = !wrapAround; | 1069 | wrapAround = !wrapAround; |
1069 | } | 1070 | } |
1070 | } | 1071 | } |
1071 | 1072 | ||
1072 | Event DateBookDBHack::eventByUID(int uid) { | 1073 | Event DateBookDBHack::eventByUID(int uid) { |
1073 | 1074 | ||
1074 | // FIXME: Dirty Hacks to get hold of the private event lists | 1075 | // FIXME: Dirty Hacks to get hold of the private event lists |
1075 | QDate start; | 1076 | QDate start; |
1076 | QDate end=start.addDays(-1); | 1077 | QDate end=start.addDays(-1); |
1077 | QValueList<Event> myEventList=getNonRepeatingEvents(start,end); | 1078 | QValueList<Event> myEventList=getNonRepeatingEvents(start,end); |
1078 | QValueList<Event> myRepeatEvents=getRawRepeats(); | 1079 | QValueList<Event> myRepeatEvents=getRawRepeats(); |
1079 | 1080 | ||
1080 | QValueList<Event>::ConstIterator it; | 1081 | QValueList<Event>::ConstIterator it; |
1081 | 1082 | ||
1082 | for (it = myEventList.begin(); it != myEventList.end(); it++) { | 1083 | for (it = myEventList.begin(); it != myEventList.end(); it++) { |
1083 | if ((*it).uid() == uid) return *it; | 1084 | if ((*it).uid() == uid) return *it; |
1084 | } | 1085 | } |
1085 | for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { | 1086 | for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { |
1086 | if ((*it).uid() == uid) return *it; | 1087 | if ((*it).uid() == uid) return *it; |
1087 | } | 1088 | } |
1088 | 1089 | ||
1089 | Event ev; | 1090 | Event ev; |
1090 | return ev; // return at least | 1091 | return ev; // return at least |
1091 | } | 1092 | } |
1092 | 1093 | ||
1093 | DateBookHoliday::DateBookHoliday() | 1094 | DateBookHoliday::DateBookHoliday() |
1094 | { | 1095 | { |
1095 | _pluginlist.clear(); | 1096 | _pluginlist.clear(); |
1096 | m_pluginLoader = new Opie::Core::OPluginLoader("holidays",false); | 1097 | m_pluginLoader = new Opie::Core::OPluginLoader("holidays",false); |
1097 | m_pluginLoader->setAutoDelete(true); | 1098 | m_pluginLoader->setAutoDelete(true); |
1098 | m_pluginManager = new Opie::Core::OPluginManager(m_pluginLoader); | 1099 | m_pluginManager = new Opie::Core::OPluginManager(m_pluginLoader); |
1099 | m_pluginManager->load(); | 1100 | m_pluginManager->load(); |
1100 | 1101 | ||
1101 | init(); | 1102 | init(); |
1102 | } | 1103 | } |
1103 | 1104 | ||
1104 | void DateBookHoliday::reloadPlugins() | 1105 | void DateBookHoliday::reloadPlugins() |
1105 | { | 1106 | { |
1106 | deinit(); | 1107 | deinit(); |
1107 | init(); | 1108 | init(); |
1108 | } | 1109 | } |
1109 | 1110 | ||
1110 | DateBookHoliday::~DateBookHoliday() | 1111 | DateBookHoliday::~DateBookHoliday() |
1111 | { | 1112 | { |
1112 | deinit(); | 1113 | deinit(); |
1113 | delete m_pluginLoader; | 1114 | delete m_pluginLoader; |
1114 | delete m_pluginManager; | 1115 | delete m_pluginManager; |
1115 | } | 1116 | } |
1116 | 1117 | ||
1117 | void DateBookHoliday::deinit() | 1118 | void DateBookHoliday::deinit() |
1118 | { | 1119 | { |
1119 | QValueList<HPlugin*>::Iterator it; | 1120 | QValueList<HPlugin*>::Iterator it; |
1120 | for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { | 1121 | for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { |
1121 | HPlugin*_pl = *it; | 1122 | HPlugin*_pl = *it; |
1122 | *it = 0; | 1123 | *it = 0; |
1123 | delete _pl; | 1124 | delete _pl; |
1124 | } | 1125 | } |
1125 | _pluginlist.clear(); | 1126 | _pluginlist.clear(); |
1126 | } | 1127 | } |
1127 | 1128 | ||
1128 | #if 0 | 1129 | #if 0 |
1129 | void debugLst( const Opie::Core::OPluginItem::List& lst ) { | 1130 | void debugLst( const Opie::Core::OPluginItem::List& lst ) { |
1130 | for ( Opie::Core::OPluginItem::List::ConstIterator it = lst.begin(); it != lst.end(); ++it ) | 1131 | for ( Opie::Core::OPluginItem::List::ConstIterator it = lst.begin(); it != lst.end(); ++it ) |
1131 | odebug << "Name " << (*it).name() << " " << (*it).path() << " " << (*it).position() << oendl; | 1132 | odebug << "Name " << (*it).name() << " " << (*it).path() << " " << (*it).position() << oendl; |
1132 | } | 1133 | } |
1133 | #endif | 1134 | #endif |
1134 | 1135 | ||
1135 | void DateBookHoliday::init() | 1136 | void DateBookHoliday::init() |
1136 | { | 1137 | { |
1137 | deinit(); | 1138 | deinit(); |
1138 | 1139 | ||
1139 | Opie::Core::OPluginItem::List lst = m_pluginLoader->filtered(true); | 1140 | Opie::Core::OPluginItem::List lst = m_pluginLoader->filtered(true); |
1140 | // debugLst( lst ); | 1141 | // debugLst( lst ); |
1141 | for( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ){ | 1142 | for( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ){ |
1142 | Opie::Datebook::HolidayPluginIf*hif = m_pluginLoader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN); | 1143 | Opie::Datebook::HolidayPluginIf*hif = m_pluginLoader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN); |
1143 | if (hif) { | 1144 | if (hif) { |
1144 | Opie::Datebook::HolidayPlugin*pl = hif->plugin(); | 1145 | Opie::Datebook::HolidayPlugin*pl = hif->plugin(); |
1145 | if (pl) { | 1146 | if (pl) { |
1146 | HPlugin*_pl=new HPlugin; | 1147 | HPlugin*_pl=new HPlugin; |
1147 | _pl->_plugin = pl; | 1148 | _pl->_plugin = pl; |
1148 | odebug << "Found holiday " << pl->description()<<oendl; | 1149 | odebug << "Found holiday " << pl->description()<<oendl; |
1149 | _pluginlist.append(_pl); | 1150 | _pluginlist.append(_pl); |
1150 | //_pl->_if = hif; | 1151 | //_pl->_if = hif; |
1151 | } | 1152 | } |
1152 | } | 1153 | } |
1153 | } | 1154 | } |
1154 | } | 1155 | } |
1155 | 1156 | ||
1156 | QStringList DateBookHoliday::holidaylist(const QDate&aDate) | 1157 | QStringList DateBookHoliday::holidaylist(const QDate&aDate) |
1157 | { | 1158 | { |
1158 | QStringList ret; | 1159 | QStringList ret; |
1159 | QValueList<HPlugin*>::Iterator it; | 1160 | QValueList<HPlugin*>::Iterator it; |
1160 | for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { | 1161 | for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { |
1161 | HPlugin*_pl = *it; | 1162 | HPlugin*_pl = *it; |
1162 | ret+=_pl->_plugin->entries(aDate); | 1163 | ret+=_pl->_plugin->entries(aDate); |
1163 | } | 1164 | } |
1164 | return ret; | 1165 | return ret; |
1165 | } | 1166 | } |
1166 | 1167 | ||
1167 | QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day) | 1168 | QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day) |
1168 | { | 1169 | { |
1169 | return holidaylist(QDate(year,month,day)); | 1170 | return holidaylist(QDate(year,month,day)); |
1170 | } | 1171 | } |
1171 | 1172 | ||
1172 | QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) | 1173 | QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) |
1173 | { | 1174 | { |
1174 | QValueList<EffectiveEvent> ret; | 1175 | QValueList<EffectiveEvent> ret; |
1175 | QValueList<HPlugin*>::Iterator it; | 1176 | QValueList<HPlugin*>::Iterator it; |
1176 | for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { | 1177 | for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { |
1177 | HPlugin*_pl = *it; | 1178 | HPlugin*_pl = *it; |
1178 | ret+=_pl->_plugin->events(from,to); | 1179 | ret+=_pl->_plugin->events(from,to); |
1179 | } | 1180 | } |
1180 | return ret; | 1181 | return ret; |
1181 | } | 1182 | } |
1182 | 1183 | ||
1183 | QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDate &from,const QDate &to ) | 1184 | QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDate &from,const QDate &to ) |
1184 | { | 1185 | { |
1185 | return DateBookDBHack::getEffectiveEvents(from,to); | 1186 | return DateBookDBHack::getEffectiveEvents(from,to); |
1186 | } | 1187 | } |
1187 | 1188 | ||
1188 | QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDateTime &start) | 1189 | QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDateTime &start) |
1189 | { | 1190 | { |
1190 | return DateBookDBHack::getEffectiveEvents(start); | 1191 | return DateBookDBHack::getEffectiveEvents(start); |
1191 | } | 1192 | } |
1192 | 1193 | ||
1193 | QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDateTime &start) | 1194 | QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDateTime &start) |
1194 | { | 1195 | { |
1195 | return getEffectiveEvents(start.date(),start.date()); | 1196 | return getEffectiveEvents(start.date(),start.date()); |
1196 | } | 1197 | } |
1197 | 1198 | ||
1198 | QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) | 1199 | QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) |
1199 | { | 1200 | { |
1200 | QValueList<EffectiveEvent> ret; | 1201 | QValueList<EffectiveEvent> ret; |
1201 | odebug << "Ueberlagert 1" << oendl; | 1202 | odebug << "Ueberlagert 1" << oendl; |
1202 | if (db_holiday) { | 1203 | if (db_holiday) { |
1203 | ret+=db_holiday->getEffectiveEvents(from,to); | 1204 | ret+=db_holiday->getEffectiveEvents(from,to); |
1204 | } | 1205 | } |
1205 | ret+=getEffectiveEventsNoHoliday(from,to); | 1206 | ret+=getEffectiveEventsNoHoliday(from,to); |
1206 | return ret; | 1207 | return ret; |
1207 | } | 1208 | } |
1208 | 1209 | ||
1209 | QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents( const QDateTime &start) | 1210 | QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents( const QDateTime &start) |
1210 | { | 1211 | { |
1211 | odebug << "Ueberlagert 2" << oendl; | 1212 | odebug << "Ueberlagert 2" << oendl; |
1212 | return DateBookDBHack::getEffectiveEvents(start); | 1213 | return DateBookDBHack::getEffectiveEvents(start); |
1213 | } | 1214 | } |
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 | |||
@@ -1,134 +1,134 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
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 | **********************************************************************/ | 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); |
59 | 59 | ||
60 | public slots: | 60 | public slots: |
61 | void flush(); | 61 | void flush(); |
62 | void reload(); | 62 | void reload(); |
63 | 63 | ||
64 | private slots: | 64 | private slots: |
65 | void fileNew(); | 65 | void fileNew(); |
66 | void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); | 66 | void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); |
67 | void slotSettings(); | 67 | void slotSettings(); |
68 | void slotToday(); // view today | 68 | void slotToday(); // view today |
69 | void changeClock( bool newClock ); | 69 | void changeClock( bool newClock ); |
70 | void changeWeek( bool newDay ); | 70 | void changeWeek( bool newDay ); |
71 | void appMessage(const QCString& msg, const QByteArray& data); | 71 | void appMessage(const QCString& msg, const QByteArray& data); |
72 | // handle key events in the day view... | 72 | // handle key events in the day view... |
73 | void slotNewEventFromKey( const QString &str ); | 73 | void slotNewEventFromKey( const QString &str ); |
74 | void slotFind(); | 74 | void slotFind(); |
75 | void slotDoFind( const QString &, const QDate &, bool, bool, int ); | 75 | void slotDoFind( const QString &, const QDate &, bool, bool, int ); |
76 | 76 | ||
77 | void viewDefault(const QDate &d); | 77 | void viewDefault(const QDate &d); |
78 | 78 | ||
79 | void viewDay(); | 79 | void viewDay(); |
80 | void viewWeek(); | 80 | void viewWeek(); |
81 | void viewWeekLst(); | 81 | void viewWeekLst(); |
82 | void viewMonth(); | 82 | void viewMonth(); |
83 | 83 | ||
84 | void showDay( int y, int m, int d ); | 84 | void showDay( int y, int m, int d ); |
85 | 85 | ||
86 | void insertEvent( const Event &e ); | 86 | void insertEvent( const Event &e ); |
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 | ||