-rw-r--r-- | core/pim/datebook/datebook.cpp | 12 | ||||
-rw-r--r-- | core/pim/datebook/dateentryimpl.cpp | 2 | ||||
-rw-r--r-- | core/pim/datebook/timepicker.cpp | 1 |
3 files changed, 9 insertions, 6 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 2deb96f..97c305c 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -85,447 +85,447 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
85 | QTime t; | 85 | QTime t; |
86 | t.start(); | 86 | t.start(); |
87 | db = new DateBookDB; | 87 | db = new DateBookDB; |
88 | qDebug("loading db t=%d", t.elapsed() ); | 88 | qDebug("loading db t=%d", t.elapsed() ); |
89 | loadSettings(); | 89 | loadSettings(); |
90 | setCaption( tr("Calendar") ); | 90 | setCaption( tr("Calendar") ); |
91 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); | 91 | setIcon( Resource::loadPixmap( "datebook_icon" ) ); |
92 | 92 | ||
93 | setToolBarsMovable( FALSE ); | 93 | setToolBarsMovable( FALSE ); |
94 | 94 | ||
95 | views = new QWidgetStack( this ); | 95 | views = new QWidgetStack( this ); |
96 | setCentralWidget( views ); | 96 | setCentralWidget( views ); |
97 | 97 | ||
98 | dayView = 0; | 98 | dayView = 0; |
99 | weekView = 0; | 99 | weekView = 0; |
100 | weekLstView = 0; | 100 | weekLstView = 0; |
101 | monthView = 0; | 101 | monthView = 0; |
102 | 102 | ||
103 | QPEToolBar *bar = new QPEToolBar( this ); | 103 | QPEToolBar *bar = new QPEToolBar( this ); |
104 | bar->setHorizontalStretchable( TRUE ); | 104 | bar->setHorizontalStretchable( TRUE ); |
105 | 105 | ||
106 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 106 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
107 | mb->setMargin( 0 ); | 107 | mb->setMargin( 0 ); |
108 | 108 | ||
109 | QPEToolBar *sub_bar = new QPEToolBar(this); | 109 | QPEToolBar *sub_bar = new QPEToolBar(this); |
110 | 110 | ||
111 | QPopupMenu *view = new QPopupMenu( this ); | 111 | QPopupMenu *view = new QPopupMenu( this ); |
112 | QPopupMenu *settings = new QPopupMenu( this ); | 112 | QPopupMenu *settings = new QPopupMenu( this ); |
113 | 113 | ||
114 | mb->insertItem( tr( "View" ), view ); | 114 | mb->insertItem( tr( "View" ), view ); |
115 | mb->insertItem( tr( "Settings" ), settings ); | 115 | mb->insertItem( tr( "Settings" ), settings ); |
116 | 116 | ||
117 | QActionGroup *g = new QActionGroup( this ); | 117 | QActionGroup *g = new QActionGroup( this ); |
118 | g->setExclusive( TRUE ); | 118 | g->setExclusive( TRUE ); |
119 | 119 | ||
120 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 120 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), |
121 | QString::null, 0, this, 0 ); | 121 | QString::null, 0, this, 0 ); |
122 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 122 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
123 | a->addTo( sub_bar ); | 123 | a->addTo( sub_bar ); |
124 | 124 | ||
125 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 ); | 125 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 ); |
126 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | 126 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); |
127 | a->addTo( sub_bar ); | 127 | a->addTo( sub_bar ); |
128 | a->addTo( view ); | 128 | a->addTo( view ); |
129 | 129 | ||
130 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); | 130 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); |
131 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); | 131 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); |
132 | a->addTo( sub_bar ); | 132 | a->addTo( sub_bar ); |
133 | a->addTo( view ); | 133 | a->addTo( view ); |
134 | a->setToggleAction( TRUE ); | 134 | a->setToggleAction( TRUE ); |
135 | a->setOn( TRUE ); | 135 | a->setOn( TRUE ); |
136 | dayAction = a; | 136 | dayAction = a; |
137 | 137 | ||
138 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); | 138 | a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); |
139 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); | 139 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); |
140 | a->addTo( sub_bar ); | 140 | a->addTo( sub_bar ); |
141 | a->addTo( view ); | 141 | a->addTo( view ); |
142 | a->setToggleAction( TRUE ); | 142 | a->setToggleAction( TRUE ); |
143 | weekAction = a; | 143 | weekAction = a; |
144 | 144 | ||
145 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 ); | 145 | a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 ); |
146 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); | 146 | connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); |
147 | a->addTo( sub_bar ); | 147 | a->addTo( sub_bar ); |
148 | a->addTo( view ); | 148 | a->addTo( view ); |
149 | a->setToggleAction( TRUE ); | 149 | a->setToggleAction( TRUE ); |
150 | weekLstAction = a; | 150 | weekLstAction = a; |
151 | 151 | ||
152 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); | 152 | a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); |
153 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); | 153 | connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); |
154 | a->addTo( sub_bar ); | 154 | a->addTo( sub_bar ); |
155 | a->addTo( view ); | 155 | a->addTo( view ); |
156 | a->setToggleAction( TRUE ); | 156 | a->setToggleAction( TRUE ); |
157 | monthAction = a; | 157 | monthAction = a; |
158 | 158 | ||
159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); | 159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, g, 0 ); |
160 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 160 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
161 | a->addTo( sub_bar ); | 161 | a->addTo( sub_bar ); |
162 | 162 | ||
163 | a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); | 163 | a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); |
164 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 164 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
165 | a->addTo( settings ); | 165 | a->addTo( settings ); |
166 | 166 | ||
167 | QPopupMenu *default_view = new QPopupMenu(this); | 167 | QPopupMenu *default_view = new QPopupMenu(this); |
168 | settings->insertItem( tr( "Default View" ),default_view ); | 168 | settings->insertItem( tr( "Default View" ),default_view ); |
169 | default_view->setCheckable(TRUE); | 169 | default_view->setCheckable(TRUE); |
170 | 170 | ||
171 | Config config("DateBook"); | 171 | Config config("DateBook"); |
172 | config.setGroup("Main"); | 172 | config.setGroup("Main"); |
173 | int current=config.readNumEntry("defaultview", DAY); | 173 | int current=config.readNumEntry("defaultview", DAY); |
174 | 174 | ||
175 | QActionGroup *ag = new QActionGroup(this); | 175 | QActionGroup *ag = new QActionGroup(this); |
176 | a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); | 176 | a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); |
177 | if (current==DAY) a->setOn(true), viewDay(); | 177 | if (current==DAY) a->setOn(true), viewDay(); |
178 | ag->insert(a); | 178 | ag->insert(a); |
179 | a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); | 179 | a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); |
180 | if (current==WEEK) a->setOn(true), viewWeek(); | 180 | if (current==WEEK) a->setOn(true), viewWeek(); |
181 | ag->insert(a); | 181 | ag->insert(a); |
182 | a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); | 182 | a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); |
183 | if (current==WEEKLST) a->setOn(true), viewWeekLst(); | 183 | if (current==WEEKLST) a->setOn(true), viewWeekLst(); |
184 | ag->insert(a); | 184 | ag->insert(a); |
185 | a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); | 185 | a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); |
186 | if (current==MONTH) a->setOn(true), viewMonth(); | 186 | if (current==MONTH) a->setOn(true), viewMonth(); |
187 | ag->insert(a); | 187 | ag->insert(a); |
188 | 188 | ||
189 | ag->addTo(default_view); | 189 | ag->addTo(default_view); |
190 | connect(ag, SIGNAL( selected ( QAction * ) ), | 190 | connect(ag, SIGNAL( selected ( QAction * ) ), |
191 | this, SLOT( newDefaultView(QAction *) ) | 191 | this, SLOT( newDefaultView(QAction *) ) |
192 | ); | 192 | ); |
193 | 193 | ||
194 | connect( qApp, SIGNAL(clockChanged(bool)), | 194 | connect( qApp, SIGNAL(clockChanged(bool)), |
195 | this, SLOT(changeClock(bool)) ); | 195 | this, SLOT(changeClock(bool)) ); |
196 | connect( qApp, SIGNAL(weekChanged(bool)), | 196 | connect( qApp, SIGNAL(weekChanged(bool)), |
197 | this, SLOT(changeWeek(bool)) ); | 197 | this, SLOT(changeWeek(bool)) ); |
198 | 198 | ||
199 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 199 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
200 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | 200 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), |
201 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); | 201 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); |
202 | #endif | 202 | #endif |
203 | 203 | ||
204 | // listen on QPE/System | 204 | // listen on QPE/System |
205 | #if defined(Q_WS_QWS) | 205 | #if defined(Q_WS_QWS) |
206 | #if !defined(QT_NO_COP) | 206 | #if !defined(QT_NO_COP) |
207 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 207 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
208 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 208 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
209 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 209 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
210 | channel = new QCopChannel( "QPE/Datebook", this ); | 210 | channel = new QCopChannel( "QPE/Datebook", this ); |
211 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 211 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
212 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 212 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
213 | qDebug("olle\n"); | ||
213 | #endif | 214 | #endif |
214 | #endif | 215 | #endif |
215 | 216 | ||
216 | qDebug("done t=%d", t.elapsed() ); | 217 | qDebug("done t=%d", t.elapsed() ); |
217 | 218 | ||
218 | } | 219 | } |
219 | 220 | ||
220 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 221 | void DateBook::receive( const QCString &msg, const QByteArray &data ) |
221 | { | 222 | { |
222 | QDataStream stream( data, IO_ReadOnly ); | 223 | QDataStream stream( data, IO_ReadOnly ); |
223 | if ( msg == "timeChange(QString)" ) { | 224 | if ( msg == "timeChange(QString)" ) { |
224 | // update active view! | 225 | // update active view! |
225 | if ( dayAction->isOn() ) | 226 | if ( dayAction->isOn() ) |
226 | viewDay(); | 227 | viewDay(); |
227 | else if ( weekAction->isOn() ) | 228 | else if ( weekAction->isOn() ) |
228 | viewWeek(); | 229 | viewWeek(); |
229 | else if ( monthAction->isOn() ) | 230 | else if ( monthAction->isOn() ) |
230 | viewMonth(); | 231 | viewMonth(); |
231 | } | 232 | } |
232 | else if (msg == "editEvent(int)") { | 233 | else if (msg == "editEvent(int)") { |
233 | /* Not yet working... | 234 | int uid; |
234 | int uid; | 235 | stream >> uid; |
235 | stream >> uid; | 236 | Event e=db->getEvent(uid); |
236 | Event e=db->getEvent(uid); | 237 | editEvent(e); |
237 | editEvent(e); | ||
238 | */ | ||
239 | } | 238 | } |
240 | } | 239 | } |
241 | 240 | ||
242 | DateBook::~DateBook() | 241 | DateBook::~DateBook() |
243 | { | 242 | { |
244 | } | 243 | } |
245 | 244 | ||
246 | void DateBook::slotSettings() | 245 | void DateBook::slotSettings() |
247 | { | 246 | { |
248 | DateBookSettings frmSettings( ampm, this ); | 247 | DateBookSettings frmSettings( ampm, this ); |
249 | frmSettings.setStartTime( startTime ); | 248 | frmSettings.setStartTime( startTime ); |
250 | frmSettings.setAlarmPreset( aPreset, presetTime ); | 249 | frmSettings.setAlarmPreset( aPreset, presetTime ); |
251 | #if defined (Q_WS_QWS) || defined(_WS_QWS_) | 250 | #if defined (Q_WS_QWS) || defined(_WS_QWS_) |
252 | frmSettings.showMaximized(); | 251 | frmSettings.showMaximized(); |
253 | #endif | 252 | #endif |
254 | 253 | ||
255 | if ( frmSettings.exec() ) { | 254 | if ( frmSettings.exec() ) { |
256 | aPreset = frmSettings.alarmPreset(); | 255 | aPreset = frmSettings.alarmPreset(); |
257 | presetTime = frmSettings.presetTime(); | 256 | presetTime = frmSettings.presetTime(); |
258 | startTime = frmSettings.startTime(); | 257 | startTime = frmSettings.startTime(); |
259 | if ( dayView ) | 258 | if ( dayView ) |
260 | dayView->setStartViewTime( startTime ); | 259 | dayView->setStartViewTime( startTime ); |
261 | if ( weekView ) | 260 | if ( weekView ) |
262 | weekView->setStartViewTime( startTime ); | 261 | weekView->setStartViewTime( startTime ); |
263 | saveSettings(); | 262 | saveSettings(); |
264 | 263 | ||
265 | // make the change obvious | 264 | // make the change obvious |
266 | if ( views->visibleWidget() ) { | 265 | if ( views->visibleWidget() ) { |
267 | if ( views->visibleWidget() == dayView ) | 266 | if ( views->visibleWidget() == dayView ) |
268 | dayView->redraw(); | 267 | dayView->redraw(); |
269 | else if ( views->visibleWidget() == weekView ) | 268 | else if ( views->visibleWidget() == weekView ) |
270 | weekView->redraw(); | 269 | weekView->redraw(); |
271 | } | 270 | } |
272 | } | 271 | } |
273 | } | 272 | } |
274 | 273 | ||
275 | void DateBook::fileNew() | 274 | void DateBook::fileNew() |
276 | { | 275 | { |
277 | slotNewEventFromKey(""); | 276 | slotNewEventFromKey(""); |
278 | } | 277 | } |
279 | 278 | ||
280 | QString DateBook::checkEvent(const Event &e) | 279 | QString DateBook::checkEvent(const Event &e) |
281 | { | 280 | { |
282 | /* check if overlaps with itself */ | 281 | /* check if overlaps with itself */ |
283 | bool checkFailed = FALSE; | 282 | bool checkFailed = FALSE; |
284 | 283 | ||
285 | /* check the next 12 repeats. should catch most problems */ | 284 | /* check the next 12 repeats. should catch most problems */ |
286 | QDate current_date = e.start().date(); | 285 | QDate current_date = e.start().date(); |
287 | Event previous = e; | 286 | Event previous = e; |
288 | for(int i = 0; i < 12; i++) | 287 | for(int i = 0; i < 12; i++) |
289 | { | 288 | { |
290 | QDateTime next; | 289 | QDateTime next; |
291 | if (!nextOccurance(previous, current_date.addDays(1), next)) { | 290 | if (!nextOccurance(previous, current_date.addDays(1), next)) { |
292 | break; // no more repeats | 291 | break; // no more repeats |
293 | } | 292 | } |
294 | if(next < previous.end()) { | 293 | if(next < previous.end()) { |
295 | checkFailed = TRUE; | 294 | checkFailed = TRUE; |
296 | break; | 295 | break; |
297 | } | 296 | } |
298 | current_date = next.date(); | 297 | current_date = next.date(); |
299 | } | 298 | } |
300 | 299 | ||
301 | if(checkFailed) | 300 | if(checkFailed) |
302 | return tr("Event duration is potentially longer\n" | 301 | return tr("Event duration is potentially longer\n" |
303 | "than interval between repeats."); | 302 | "than interval between repeats."); |
304 | 303 | ||
305 | return QString::null; | 304 | return QString::null; |
306 | } | 305 | } |
307 | 306 | ||
308 | QDate DateBook::currentDate() | 307 | QDate DateBook::currentDate() |
309 | { | 308 | { |
310 | QDate d = QDate::currentDate(); | 309 | QDate d = QDate::currentDate(); |
311 | 310 | ||
312 | if ( dayView && views->visibleWidget() == dayView ) { | 311 | if ( dayView && views->visibleWidget() == dayView ) { |
313 | d = dayView->date(); | 312 | d = dayView->date(); |
314 | } else if ( weekView && views->visibleWidget() == weekView ) { | 313 | } else if ( weekView && views->visibleWidget() == weekView ) { |
315 | d = weekView->date(); | 314 | d = weekView->date(); |
316 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { | 315 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { |
317 | d = weekLstView->date(); | 316 | d = weekLstView->date(); |
318 | } else if ( monthView && views->visibleWidget() == monthView ) { | 317 | } else if ( monthView && views->visibleWidget() == monthView ) { |
319 | d = monthView->selectedDate(); | 318 | d = monthView->selectedDate(); |
320 | } | 319 | } |
321 | 320 | ||
322 | return d; | 321 | return d; |
323 | } | 322 | } |
324 | 323 | ||
325 | void DateBook::view(int v, const QDate &d) { | 324 | void DateBook::view(int v, const QDate &d) { |
326 | if (v==DAY) { | 325 | if (v==DAY) { |
327 | initDay(); | 326 | initDay(); |
328 | dayAction->setOn( TRUE ); | 327 | dayAction->setOn( TRUE ); |
329 | dayView->setDate( d ); | 328 | dayView->setDate( d ); |
330 | views->raiseWidget( dayView ); | 329 | views->raiseWidget( dayView ); |
331 | dayView->redraw(); | 330 | dayView->redraw(); |
332 | } else if (v==WEEK) { | 331 | } else if (v==WEEK) { |
333 | initWeek(); | 332 | initWeek(); |
334 | weekAction->setOn( TRUE ); | 333 | weekAction->setOn( TRUE ); |
335 | weekView->setDate( d ); | 334 | weekView->setDate( d ); |
336 | views->raiseWidget( weekView ); | 335 | views->raiseWidget( weekView ); |
337 | weekView->redraw(); | 336 | weekView->redraw(); |
338 | } else if (v==WEEKLST) { | 337 | } else if (v==WEEKLST) { |
339 | initWeekLst(); | 338 | initWeekLst(); |
340 | weekLstAction->setOn( TRUE ); | 339 | weekLstAction->setOn( TRUE ); |
341 | weekLstView->setDate(d); | 340 | weekLstView->setDate(d); |
342 | views->raiseWidget( weekLstView ); | 341 | views->raiseWidget( weekLstView ); |
343 | weekLstView->redraw(); | 342 | weekLstView->redraw(); |
344 | } else if (v==MONTH) { | 343 | } else if (v==MONTH) { |
345 | initMonth(); | 344 | initMonth(); |
346 | monthAction->setOn( TRUE ); | 345 | monthAction->setOn( TRUE ); |
347 | monthView->setDate( d.year(), d.month(), d.day() ); | 346 | monthView->setDate( d.year(), d.month(), d.day() ); |
348 | views->raiseWidget( monthView ); | 347 | views->raiseWidget( monthView ); |
349 | monthView->redraw(); | 348 | monthView->redraw(); |
350 | } | 349 | } |
351 | } | 350 | } |
352 | 351 | ||
353 | void DateBook::viewDefault(const QDate &d) { | 352 | void DateBook::viewDefault(const QDate &d) { |
354 | Config config("DateBook"); | 353 | Config config("DateBook"); |
355 | config.setGroup("Main"); | 354 | config.setGroup("Main"); |
356 | int current=config.readNumEntry("defaultview", DAY); | 355 | int current=config.readNumEntry("defaultview", DAY); |
357 | 356 | ||
358 | view(current,d); | 357 | view(current,d); |
359 | } | 358 | } |
360 | 359 | ||
361 | void DateBook::viewDay() { | 360 | void DateBook::viewDay() { |
362 | view(DAY,currentDate()); | 361 | view(DAY,currentDate()); |
363 | } | 362 | } |
364 | 363 | ||
365 | void DateBook::viewWeek() { | 364 | void DateBook::viewWeek() { |
366 | view(WEEK,currentDate()); | 365 | view(WEEK,currentDate()); |
367 | } | 366 | } |
368 | 367 | ||
369 | void DateBook::viewWeekLst() { | 368 | void DateBook::viewWeekLst() { |
370 | view(WEEKLST,currentDate()); | 369 | view(WEEKLST,currentDate()); |
371 | } | 370 | } |
372 | 371 | ||
373 | void DateBook::viewMonth() { | 372 | void DateBook::viewMonth() { |
374 | view(MONTH,currentDate()); | 373 | view(MONTH,currentDate()); |
375 | } | 374 | } |
376 | 375 | ||
377 | void DateBook::editEvent( const Event &e ) | 376 | void DateBook::editEvent( const Event &e ) |
378 | { | 377 | { |
379 | if (syncing) { | 378 | if (syncing) { |
380 | QMessageBox::warning( this, tr("Calendar"), | 379 | QMessageBox::warning( this, tr("Calendar"), |
381 | tr( "Can not edit data, currently syncing") ); | 380 | tr( "Can not edit data, currently syncing") ); |
382 | return; | 381 | return; |
383 | } | 382 | } |
384 | 383 | ||
385 | // workaround added for text input. | 384 | // workaround added for text input. |
386 | QDialog editDlg( this, 0, TRUE ); | 385 | QDialog editDlg( this, 0, TRUE ); |
387 | DateEntry *entry; | 386 | DateEntry *entry; |
388 | editDlg.setCaption( tr("Edit Event") ); | 387 | editDlg.setCaption( tr("Edit Event") ); |
389 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 388 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
390 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 389 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
391 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 390 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
392 | // KLUDGE!!! | 391 | // KLUDGE!!! |
393 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 392 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
394 | vb->addWidget( sv ); | 393 | vb->addWidget( sv ); |
395 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); | 394 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); |
396 | entry->timezone->setEnabled( FALSE ); | 395 | entry->timezone->setEnabled( FALSE ); |
397 | sv->addChild( entry ); | 396 | sv->addChild( entry ); |
398 | 397 | ||
399 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 398 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
400 | editDlg.showMaximized(); | 399 | editDlg.showMaximized(); |
401 | #endif | 400 | #endif |
402 | while (editDlg.exec() ) { | 401 | while (editDlg.exec() ) { |
403 | Event newEv = entry->event(); | 402 | Event newEv = entry->event(); |
403 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid | ||
404 | QString error = checkEvent(newEv); | 404 | QString error = checkEvent(newEv); |
405 | if (!error.isNull()) { | 405 | if (!error.isNull()) { |
406 | if (QMessageBox::warning(this, "error box", | 406 | if (QMessageBox::warning(this, "error box", |
407 | error, "Fix it", "Continue", | 407 | error, "Fix it", "Continue", |
408 | 0, 0, 1) == 0) | 408 | 0, 0, 1) == 0) |
409 | continue; | 409 | continue; |
410 | } | 410 | } |
411 | db->editEvent(e, newEv); | 411 | db->editEvent(e, newEv); |
412 | emit newEvent(); | 412 | emit newEvent(); |
413 | break; | 413 | break; |
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | void DateBook::removeEvent( const Event &e ) | 417 | void DateBook::removeEvent( const Event &e ) |
418 | { | 418 | { |
419 | if (syncing) { | 419 | if (syncing) { |
420 | QMessageBox::warning( this, tr("Calendar"), | 420 | QMessageBox::warning( this, tr("Calendar"), |
421 | tr( "Can not edit data, currently syncing") ); | 421 | tr( "Can not edit data, currently syncing") ); |
422 | return; | 422 | return; |
423 | } | 423 | } |
424 | 424 | ||
425 | QString strName = e.description(); | 425 | QString strName = e.description(); |
426 | 426 | ||
427 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) | 427 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) |
428 | return; | 428 | return; |
429 | 429 | ||
430 | db->removeEvent( e ); | 430 | db->removeEvent( e ); |
431 | if ( views->visibleWidget() == dayView && dayView ) | 431 | if ( views->visibleWidget() == dayView && dayView ) |
432 | dayView->redraw(); | 432 | dayView->redraw(); |
433 | } | 433 | } |
434 | 434 | ||
435 | void DateBook::addEvent( const Event &e ) | 435 | void DateBook::addEvent( const Event &e ) |
436 | { | 436 | { |
437 | QDate d = e.start().date(); | 437 | QDate d = e.start().date(); |
438 | initDay(); | 438 | initDay(); |
439 | dayView->setDate( d ); | 439 | dayView->setDate( d ); |
440 | } | 440 | } |
441 | 441 | ||
442 | void DateBook::showDay( int year, int month, int day ) | 442 | void DateBook::showDay( int year, int month, int day ) |
443 | { | 443 | { |
444 | QDate d(year, month, day); | 444 | QDate d(year, month, day); |
445 | view(DAY,d); | 445 | view(DAY,d); |
446 | } | 446 | } |
447 | 447 | ||
448 | void DateBook::initDay() | 448 | void DateBook::initDay() |
449 | { | 449 | { |
450 | if ( !dayView ) { | 450 | if ( !dayView ) { |
451 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); | 451 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); |
452 | views->addWidget( dayView, DAY ); | 452 | views->addWidget( dayView, DAY ); |
453 | dayView->setStartViewTime( startTime ); | 453 | dayView->setStartViewTime( startTime ); |
454 | connect( this, SIGNAL( newEvent() ), | 454 | connect( this, SIGNAL( newEvent() ), |
455 | dayView, SLOT( redraw() ) ); | 455 | dayView, SLOT( redraw() ) ); |
456 | connect( dayView, SIGNAL( newEvent() ), | 456 | connect( dayView, SIGNAL( newEvent() ), |
457 | this, SLOT( fileNew() ) ); | 457 | this, SLOT( fileNew() ) ); |
458 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), | 458 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), |
459 | this, SLOT( removeEvent( const Event & ) ) ); | 459 | this, SLOT( removeEvent( const Event & ) ) ); |
460 | connect( dayView, SIGNAL( editEvent( const Event & ) ), | 460 | connect( dayView, SIGNAL( editEvent( const Event & ) ), |
461 | this, SLOT( editEvent( const Event & ) ) ); | 461 | this, SLOT( editEvent( const Event & ) ) ); |
462 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), | 462 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), |
463 | this, SLOT( beamEvent( const Event & ) ) ); | 463 | this, SLOT( beamEvent( const Event & ) ) ); |
464 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), | 464 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), |
465 | this, SLOT(slotNewEventFromKey(const QString &)) ); | 465 | this, SLOT(slotNewEventFromKey(const QString &)) ); |
466 | } | 466 | } |
467 | } | 467 | } |
468 | 468 | ||
469 | void DateBook::initWeek() | 469 | void DateBook::initWeek() |
470 | { | 470 | { |
471 | if ( !weekView ) { | 471 | if ( !weekView ) { |
472 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); | 472 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); |
473 | weekView->setStartViewTime( startTime ); | 473 | weekView->setStartViewTime( startTime ); |
474 | views->addWidget( weekView, WEEK ); | 474 | views->addWidget( weekView, WEEK ); |
475 | connect( weekView, SIGNAL( showDate( int, int, int ) ), | 475 | connect( weekView, SIGNAL( showDate( int, int, int ) ), |
476 | this, SLOT( showDay( int, int, int ) ) ); | 476 | this, SLOT( showDay( int, int, int ) ) ); |
477 | connect( this, SIGNAL( newEvent() ), | 477 | connect( this, SIGNAL( newEvent() ), |
478 | weekView, SLOT( redraw() ) ); | 478 | weekView, SLOT( redraw() ) ); |
479 | } | 479 | } |
480 | //But also get it right: the year that we display can be different | 480 | //But also get it right: the year that we display can be different |
481 | //from the year of the current date. So, first find the year | 481 | //from the year of the current date. So, first find the year |
482 | //number of the current week. | 482 | //number of the current week. |
483 | 483 | ||
484 | int yearNumber, totWeeks; | 484 | int yearNumber, totWeeks; |
485 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); | 485 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); |
486 | 486 | ||
487 | QDate d = QDate( yearNumber, 12, 31 ); | 487 | QDate d = QDate( yearNumber, 12, 31 ); |
488 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 488 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
489 | 489 | ||
490 | while ( totWeeks == 1 ) { | 490 | while ( totWeeks == 1 ) { |
491 | d = d.addDays( -1 ); | 491 | d = d.addDays( -1 ); |
492 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 492 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
493 | } | 493 | } |
494 | if ( totWeeks != weekView->totalWeeks() ) | 494 | if ( totWeeks != weekView->totalWeeks() ) |
495 | weekView->setTotalWeeks( totWeeks ); | 495 | weekView->setTotalWeeks( totWeeks ); |
496 | } | 496 | } |
497 | void DateBook::initWeekLst() { | 497 | void DateBook::initWeekLst() { |
498 | if ( !weekLstView ) { | 498 | if ( !weekLstView ) { |
499 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, | 499 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, |
500 | views, "weeklst view" ); | 500 | views, "weeklst view" ); |
501 | views->addWidget( weekLstView, WEEKLST ); | 501 | views->addWidget( weekLstView, WEEKLST ); |
502 | 502 | ||
503 | //weekLstView->setStartViewTime( startTime ); | 503 | //weekLstView->setStartViewTime( startTime ); |
504 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), | 504 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), |
505 | this, SLOT( showDay( int, int, int ) ) ); | 505 | this, SLOT( showDay( int, int, int ) ) ); |
506 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, | 506 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, |
507 | const QDateTime &, | 507 | const QDateTime &, |
508 | const QString & ) ), | 508 | const QString & ) ), |
509 | this, SLOT( slotNewEntry( const QDateTime &, | 509 | this, SLOT( slotNewEntry( const QDateTime &, |
510 | const QDateTime &, | 510 | const QDateTime &, |
511 | const QString & ) ) ); | 511 | const QString & ) ) ); |
512 | connect( this, SIGNAL( newEvent() ), | 512 | connect( this, SIGNAL( newEvent() ), |
513 | weekLstView, SLOT( redraw() ) ); | 513 | weekLstView, SLOT( redraw() ) ); |
514 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), | 514 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), |
515 | this, SLOT( editEvent( const Event & ) ) ); | 515 | this, SLOT( editEvent( const Event & ) ) ); |
516 | } | 516 | } |
517 | } | 517 | } |
518 | 518 | ||
519 | 519 | ||
520 | void DateBook::initMonth() | 520 | void DateBook::initMonth() |
521 | { | 521 | { |
522 | if ( !monthView ) { | 522 | if ( !monthView ) { |
523 | monthView = new DateBookMonth( views, "month view", FALSE, db ); | 523 | monthView = new DateBookMonth( views, "month view", FALSE, db ); |
524 | views->addWidget( monthView, MONTH ); | 524 | views->addWidget( monthView, MONTH ); |
525 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), | 525 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), |
526 | this, SLOT( showDay( int, int, int ) ) ); | 526 | this, SLOT( showDay( int, int, int ) ) ); |
527 | connect( this, SIGNAL( newEvent() ), | 527 | connect( this, SIGNAL( newEvent() ), |
528 | monthView, SLOT( redraw() ) ); | 528 | monthView, SLOT( redraw() ) ); |
529 | qApp->processEvents(); | 529 | qApp->processEvents(); |
530 | } | 530 | } |
531 | } | 531 | } |
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp index 1c43363..e563db0 100644 --- a/core/pim/datebook/dateentryimpl.cpp +++ b/core/pim/datebook/dateentryimpl.cpp | |||
@@ -1,245 +1,247 @@ | |||
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 | 20 | ||
21 | #include "dateentryimpl.h" | 21 | #include "dateentryimpl.h" |
22 | #include "repeatentry.h" | 22 | #include "repeatentry.h" |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/categoryselect.h> | 25 | #include <qpe/categoryselect.h> |
26 | #include <qpe/datebookmonth.h> | 26 | #include <qpe/datebookmonth.h> |
27 | #include <qpe/global.h> | 27 | #include <qpe/global.h> |
28 | #include <qpe/timeconversion.h> | 28 | #include <qpe/timeconversion.h> |
29 | #include <qpe/timestring.h> | 29 | #include <qpe/timestring.h> |
30 | #include <qpe/tzselect.h> | 30 | #include <qpe/tzselect.h> |
31 | 31 | ||
32 | #include <qcheckbox.h> | 32 | #include <qcheckbox.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
36 | #include <qmultilineedit.h> | 36 | #include <qmultilineedit.h> |
37 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
38 | #include <qscrollview.h> | 38 | #include <qscrollview.h> |
39 | #include <qspinbox.h> | 39 | #include <qspinbox.h> |
40 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
41 | 41 | ||
42 | #include "timepicker.h" | 42 | #include "timepicker.h" |
43 | 43 | ||
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | 45 | ||
46 | #include <stdiostream.h> | 46 | #include <stdiostream.h> |
47 | 47 | ||
48 | /* | 48 | /* |
49 | * Constructs a DateEntry which is a child of 'parent', with the | 49 | * Constructs a DateEntry which is a child of 'parent', with the |
50 | * name 'name' and widget flags set to 'f' | 50 | * name 'name' and widget flags set to 'f' |
51 | * | 51 | * |
52 | * The dialog will by default be modeless, unless you set 'modal' to | 52 | * The dialog will by default be modeless, unless you set 'modal' to |
53 | * TRUE to construct a modal dialog. | 53 | * TRUE to construct a modal dialog. |
54 | */ | 54 | */ |
55 | 55 | ||
56 | DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, | 56 | DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, |
57 | const QDateTime &end, bool whichClock, QWidget* parent, | 57 | const QDateTime &end, bool whichClock, QWidget* parent, |
58 | const char* name ) | 58 | const char* name ) |
59 | : DateEntryBase( parent, name ), | 59 | : DateEntryBase( parent, name ), |
60 | ampm( whichClock ), | 60 | ampm( whichClock ), |
61 | startWeekOnMonday( startOnMonday ) | 61 | startWeekOnMonday( startOnMonday ) |
62 | { | 62 | { |
63 | init(); | 63 | init(); |
64 | setDates(start,end); | 64 | setDates(start,end); |
65 | setFocusProxy(comboDescription); | 65 | setFocusProxy(comboDescription); |
66 | } | 66 | } |
67 | 67 | ||
68 | static void addOrPick( QComboBox* combo, const QString& t ) | 68 | static void addOrPick( QComboBox* combo, const QString& t ) |
69 | { | 69 | { |
70 | // Pick an item if one excists | 70 | // Pick an item if one excists |
71 | for (int i=0; i<combo->count(); i++) { | 71 | for (int i=0; i<combo->count(); i++) { |
72 | if ( combo->text(i) == t ) { | 72 | if ( combo->text(i) == t ) { |
73 | combo->setCurrentItem(i); | 73 | combo->setCurrentItem(i); |
74 | return; | 74 | return; |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | // Else add one | 78 | // Else add one |
79 | combo->insertItem(t); | 79 | combo->insertItem(t); |
80 | combo->setCurrentItem(combo->count()-1); | 80 | combo->setCurrentItem(combo->count()-1); |
81 | } | 81 | } |
82 | 82 | ||
83 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, | 83 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, |
84 | QWidget* parent, const char* name ) | 84 | QWidget* parent, const char* name ) |
85 | : DateEntryBase( parent, name ), | 85 | : DateEntryBase( parent, name ), |
86 | ampm( whichClock ), | 86 | ampm( whichClock ), |
87 | startWeekOnMonday( startOnMonday ) | 87 | startWeekOnMonday( startOnMonday ) |
88 | { | 88 | { |
89 | init(); | 89 | init(); |
90 | setDates(event.start(),event.end()); | 90 | setDates(event.start(),event.end()); |
91 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); | 91 | comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); |
92 | if(!event.description().isEmpty()) | 92 | if(!event.description().isEmpty()) |
93 | addOrPick( comboDescription, event.description() ); | 93 | addOrPick( comboDescription, event.description() ); |
94 | if(!event.location().isEmpty()) | 94 | if(!event.location().isEmpty()) |
95 | addOrPick( comboLocation, event.location() ); | 95 | addOrPick( comboLocation, event.location() ); |
96 | checkAlarm->setChecked( event.hasAlarm() ); | 96 | checkAlarm->setChecked( event.hasAlarm() ); |
97 | checkAllDay->setChecked( event.type() == Event::AllDay ); | 97 | checkAllDay->setChecked( event.type() == Event::AllDay ); |
98 | if(!event.notes().isEmpty()) | 98 | if(!event.notes().isEmpty()) |
99 | editNote->setText(event.notes()); | 99 | editNote->setText(event.notes()); |
100 | spinAlarm->setValue(event.alarmTime()); | 100 | spinAlarm->setValue(event.alarmTime()); |
101 | if ( event.alarmSound() != Event::Silent ) | 101 | if ( event.alarmSound() != Event::Silent ) |
102 | comboSound->setCurrentItem( 1 ); | 102 | comboSound->setCurrentItem( 1 ); |
103 | if ( event.hasRepeat() ) { | 103 | if ( event.hasRepeat() ) { |
104 | rp = event.repeatPattern(); | 104 | rp = event.repeatPattern(); |
105 | cmdRepeat->setText( tr("Repeat...") ); | 105 | cmdRepeat->setText( tr("Repeat...") ); |
106 | } | 106 | } |
107 | setRepeatLabel(); | 107 | setRepeatLabel(); |
108 | } | 108 | } |
109 | 109 | ||
110 | void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | 110 | void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) |
111 | { | 111 | { |
112 | startDate = s.date(); | 112 | startDate = s.date(); |
113 | endDate = e.date(); | 113 | endDate = e.date(); |
114 | startTime = s.time(); | 114 | startTime = s.time(); |
115 | endTime = e.time(); | 115 | endTime = e.time(); |
116 | |||
116 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); | 117 | startDateChanged( s.date().year(), s.date().month(), s.date().day() ); |
117 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); | 118 | endDateChanged( e.date().year(), e.date().month(), e.date().day() ); |
119 | |||
118 | updateTimeEdit(true,true); | 120 | updateTimeEdit(true,true); |
119 | } | 121 | } |
120 | 122 | ||
121 | void DateEntry::updateTimeEdit(bool s, bool e) { | 123 | void DateEntry::updateTimeEdit(bool s, bool e) { |
122 | 124 | ||
123 | // Comboboxes | 125 | // Comboboxes |
124 | QString strStart, strEnd; | 126 | QString strStart, strEnd; |
125 | int shour, ehour; | 127 | int shour, ehour; |
126 | if ( ampm ) { | 128 | if ( ampm ) { |
127 | shour = startTime.hour(); | 129 | shour = startTime.hour(); |
128 | ehour = endTime.hour(); | 130 | ehour = endTime.hour(); |
129 | if ( shour >= 12 ) { | 131 | if ( shour >= 12 ) { |
130 | if ( shour > 12 ) | 132 | if ( shour > 12 ) |
131 | shour -= 12; | 133 | shour -= 12; |
132 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); | 134 | strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); |
133 | } else { | 135 | } else { |
134 | if ( shour == 0 ) | 136 | if ( shour == 0 ) |
135 | shour = 12; | 137 | shour = 12; |
136 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); | 138 | strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); |
137 | } | 139 | } |
138 | if ( ehour == 24 && endTime.minute() == 0 ) { | 140 | if ( ehour == 24 && endTime.minute() == 0 ) { |
139 | strEnd = "11:59 PM"; // or "midnight" | 141 | strEnd = "11:59 PM"; // or "midnight" |
140 | } else if ( ehour >= 12 ) { | 142 | } else if ( ehour >= 12 ) { |
141 | if ( ehour > 12 ) | 143 | if ( ehour > 12 ) |
142 | ehour -= 12; | 144 | ehour -= 12; |
143 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); | 145 | strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); |
144 | } else { | 146 | } else { |
145 | if ( ehour == 0 ) | 147 | if ( ehour == 0 ) |
146 | ehour = 12; | 148 | ehour = 12; |
147 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); | 149 | strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); |
148 | } | 150 | } |
149 | } else { | 151 | } else { |
150 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); | 152 | strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); |
151 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); | 153 | strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); |
152 | } | 154 | } |
153 | 155 | ||
154 | if (s) comboStart->setText(strStart); | 156 | if (s) comboStart->setText(strStart); |
155 | if (e) comboEnd->setText(strEnd); | 157 | if (e) comboEnd->setText(strEnd); |
156 | } | 158 | } |
157 | 159 | ||
158 | void DateEntry::init() | 160 | void DateEntry::init() |
159 | { | 161 | { |
160 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); | 162 | comboDescription->setInsertionPolicy(QComboBox::AtCurrent); |
161 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); | 163 | comboLocation->setInsertionPolicy(QComboBox::AtCurrent); |
162 | 164 | ||
163 | initCombos(); | 165 | initCombos(); |
164 | QPopupMenu *m1 = new QPopupMenu( this ); | 166 | QPopupMenu *m1 = new QPopupMenu( this ); |
165 | startPicker = new DateBookMonth( m1, 0, TRUE ); | 167 | startPicker = new DateBookMonth( m1, 0, TRUE ); |
166 | m1->insertItem( startPicker ); | 168 | m1->insertItem( startPicker ); |
167 | buttonStart->setPopup( m1 ); | 169 | buttonStart->setPopup( m1 ); |
168 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), | 170 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), |
169 | this, SLOT( startDateChanged( int, int, int ) ) ); | 171 | this, SLOT( startDateChanged( int, int, int ) ) ); |
170 | 172 | ||
171 | //Let start button change both start and end dates | 173 | //Let start button change both start and end dates |
172 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), | 174 | connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), |
173 | this, SLOT( endDateChanged( int, int, int ) ) ); | 175 | this, SLOT( endDateChanged( int, int, int ) ) ); |
174 | connect( qApp, SIGNAL( clockChanged( bool ) ), | 176 | connect( qApp, SIGNAL( clockChanged( bool ) ), |
175 | this, SLOT( slotChangeClock( bool ) ) ); | 177 | this, SLOT( slotChangeClock( bool ) ) ); |
176 | connect( qApp, SIGNAL(weekChanged(bool)), | 178 | connect( qApp, SIGNAL(weekChanged(bool)), |
177 | this, SLOT(slotChangeStartOfWeek(bool)) ); | 179 | this, SLOT(slotChangeStartOfWeek(bool)) ); |
178 | 180 | ||
179 | QPopupMenu *m2 = new QPopupMenu( this ); | 181 | QPopupMenu *m2 = new QPopupMenu( this ); |
180 | endPicker = new DateBookMonth( m2, 0, TRUE ); | 182 | endPicker = new DateBookMonth( m2, 0, TRUE ); |
181 | m2->insertItem( endPicker ); | 183 | m2->insertItem( endPicker ); |
182 | buttonEnd->setPopup( m2 ); | 184 | buttonEnd->setPopup( m2 ); |
183 | connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), | 185 | connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), |
184 | this, SLOT( endDateChanged( int, int, int ) ) ); | 186 | this, SLOT( endDateChanged( int, int, int ) ) ); |
185 | 187 | ||
186 | connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), | 188 | connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), |
187 | this, SLOT( startTimePicked(const QTime &) )); | 189 | this, SLOT( startTimePicked(const QTime &) )); |
188 | editNote->setFixedVisibleLines(3); | 190 | editNote->setFixedVisibleLines(3); |
189 | } | 191 | } |
190 | 192 | ||
191 | /* | 193 | /* |
192 | * Destroys the object and frees any allocated resources | 194 | * Destroys the object and frees any allocated resources |
193 | */ | 195 | */ |
194 | DateEntry::~DateEntry() | 196 | DateEntry::~DateEntry() |
195 | { | 197 | { |
196 | // no need to delete child widgets, Qt does it all for us | 198 | // no need to delete child widgets, Qt does it all for us |
197 | //cout << "Del: " << comboStart->currentText() << endl; | 199 | //cout << "Del: " << comboStart->currentText() << endl; |
198 | } | 200 | } |
199 | 201 | ||
200 | /* | 202 | /* |
201 | * public slot | 203 | * public slot |
202 | */ | 204 | */ |
203 | void DateEntry::endDateChanged( int y, int m, int d ) | 205 | void DateEntry::endDateChanged( int y, int m, int d ) |
204 | { | 206 | { |
205 | endDate.setYMD( y, m, d ); | 207 | endDate.setYMD( y, m, d ); |
206 | if ( endDate < startDate ) { | 208 | if ( endDate < startDate ) { |
207 | endDate = startDate; | 209 | endDate = startDate; |
208 | } | 210 | } |
209 | 211 | ||
210 | buttonEnd->setText( TimeString::shortDate( endDate ) ); | 212 | buttonEnd->setText( TimeString::shortDate( endDate ) ); |
211 | 213 | ||
212 | endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); | 214 | endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); |
213 | } | 215 | } |
214 | 216 | ||
215 | static QTime parseTime( const QString& s, bool ampm ) | 217 | static QTime parseTime( const QString& s, bool ampm ) |
216 | { | 218 | { |
217 | QTime tmpTime; | 219 | QTime tmpTime; |
218 | QStringList l = QStringList::split( ':', s ); | 220 | QStringList l = QStringList::split( ':', s ); |
219 | int hour = l[0].toInt(); | 221 | int hour = l[0].toInt(); |
220 | if ( ampm ) { | 222 | if ( ampm ) { |
221 | int i=0; | 223 | int i=0; |
222 | while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') | 224 | while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') |
223 | i++; | 225 | i++; |
224 | QString digits = l[1].left(i); | 226 | QString digits = l[1].left(i); |
225 | if ( l[1].contains( "PM", FALSE ) ) { | 227 | if ( l[1].contains( "PM", FALSE ) ) { |
226 | if ( hour != 12 ) | 228 | if ( hour != 12 ) |
227 | hour += 12; | 229 | hour += 12; |
228 | } else { | 230 | } else { |
229 | if ( hour == 12 ) | 231 | if ( hour == 12 ) |
230 | hour = 0; | 232 | hour = 0; |
231 | } | 233 | } |
232 | l[1] = digits; | 234 | l[1] = digits; |
233 | } | 235 | } |
234 | int minute = l[1].toInt(); | 236 | int minute = l[1].toInt(); |
235 | if ( minute > 59 ) | 237 | if ( minute > 59 ) |
236 | minute = 59; | 238 | minute = 59; |
237 | else if ( minute < 0 ) | 239 | else if ( minute < 0 ) |
238 | minute = 0; | 240 | minute = 0; |
239 | if ( hour > 23 ) { | 241 | if ( hour > 23 ) { |
240 | hour = 23; | 242 | hour = 23; |
241 | minute = 59; | 243 | minute = 59; |
242 | } else if ( hour < 0 ) | 244 | } else if ( hour < 0 ) |
243 | hour = 0; | 245 | hour = 0; |
244 | tmpTime.setHMS( hour, minute, 0 ); | 246 | tmpTime.setHMS( hour, minute, 0 ); |
245 | return tmpTime; | 247 | return tmpTime; |
diff --git a/core/pim/datebook/timepicker.cpp b/core/pim/datebook/timepicker.cpp index 5f08a05..9097e1b 100644 --- a/core/pim/datebook/timepicker.cpp +++ b/core/pim/datebook/timepicker.cpp | |||
@@ -1,119 +1,120 @@ | |||
1 | #include "timepicker.h" | 1 | #include "timepicker.h" |
2 | 2 | ||
3 | #include <qbuttongroup.h> | 3 | #include <qbuttongroup.h> |
4 | #include <qtoolbutton.h> | 4 | #include <qtoolbutton.h> |
5 | #include <qlayout.h> | 5 | #include <qlayout.h> |
6 | #include "clickablelabel.h" | 6 | #include "clickablelabel.h" |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | #include <stdio.h> | ||
8 | 9 | ||
9 | TimePicker::TimePicker(QWidget* parent = 0, const char* name = 0, | 10 | TimePicker::TimePicker(QWidget* parent = 0, const char* name = 0, |
10 | WFlags fl = 0) : | 11 | WFlags fl = 0) : |
11 | QWidget(parent,name,fl) | 12 | QWidget(parent,name,fl) |
12 | { | 13 | { |
13 | QVBoxLayout *vbox=new QVBoxLayout(this); | 14 | QVBoxLayout *vbox=new QVBoxLayout(this); |
14 | 15 | ||
15 | ClickableLabel *r; | 16 | ClickableLabel *r; |
16 | QString s; | 17 | QString s; |
17 | 18 | ||
18 | // Hour Row | 19 | // Hour Row |
19 | QWidget *row=new QWidget(this); | 20 | QWidget *row=new QWidget(this); |
20 | QHBoxLayout *l=new QHBoxLayout(row); | 21 | QHBoxLayout *l=new QHBoxLayout(row); |
21 | vbox->addWidget(row); | 22 | vbox->addWidget(row); |
22 | 23 | ||
23 | 24 | ||
24 | for (int i=0; i<24; i++) { | 25 | for (int i=0; i<24; i++) { |
25 | r=new ClickableLabel(row); | 26 | r=new ClickableLabel(row); |
26 | hourLst.append(r); | 27 | hourLst.append(r); |
27 | s.sprintf("%.2d",i); | 28 | s.sprintf("%.2d",i); |
28 | r->setText(s); | 29 | r->setText(s); |
29 | r->setToggleButton(true); | 30 | r->setToggleButton(true); |
30 | r->setAlignment(AlignHCenter | AlignVCenter); | 31 | r->setAlignment(AlignHCenter | AlignVCenter); |
31 | l->addWidget(r); | 32 | l->addWidget(r); |
32 | connect(r, SIGNAL(toggled(bool)), | 33 | connect(r, SIGNAL(toggled(bool)), |
33 | this, SLOT(slotHour(bool))); | 34 | this, SLOT(slotHour(bool))); |
34 | 35 | ||
35 | if (i==11) { // Second row | 36 | if (i==11) { // Second row |
36 | row=new QWidget(this); | 37 | row=new QWidget(this); |
37 | l=new QHBoxLayout(row); | 38 | l=new QHBoxLayout(row); |
38 | vbox->addWidget(row); | 39 | vbox->addWidget(row); |
39 | } | 40 | } |
40 | } | 41 | } |
41 | 42 | ||
42 | // Minute Row | 43 | // Minute Row |
43 | row=new QWidget(this); | 44 | row=new QWidget(this); |
44 | l=new QHBoxLayout(row); | 45 | l=new QHBoxLayout(row); |
45 | vbox->addWidget(row); | 46 | vbox->addWidget(row); |
46 | 47 | ||
47 | for (int i=0; i<60; i+=5) { | 48 | for (int i=0; i<60; i+=5) { |
48 | r=new ClickableLabel(row); | 49 | r=new ClickableLabel(row); |
49 | minuteLst.append(r); | 50 | minuteLst.append(r); |
50 | s.sprintf("%.2d",i); | 51 | s.sprintf("%.2d",i); |
51 | r->setText(s); | 52 | r->setText(s); |
52 | r->setToggleButton(true); | 53 | r->setToggleButton(true); |
53 | r->setAlignment(AlignHCenter | AlignVCenter); | 54 | r->setAlignment(AlignHCenter | AlignVCenter); |
54 | l->addWidget(r); | 55 | l->addWidget(r); |
55 | connect(r, SIGNAL(toggled(bool)), | 56 | connect(r, SIGNAL(toggled(bool)), |
56 | this, SLOT(slotMinute(bool))); | 57 | this, SLOT(slotMinute(bool))); |
57 | } | 58 | } |
58 | } | 59 | } |
59 | 60 | ||
60 | void TimePicker::slotHour(bool b) { | 61 | void TimePicker::slotHour(bool b) { |
61 | 62 | ||
62 | ClickableLabel *r = (ClickableLabel *) sender(); | 63 | ClickableLabel *r = (ClickableLabel *) sender(); |
63 | 64 | ||
64 | if (b) { | 65 | if (b) { |
65 | QValueListIterator<ClickableLabel *> it; | 66 | QValueListIterator<ClickableLabel *> it; |
66 | for (it=hourLst.begin(); it!=hourLst.end(); it++) { | 67 | for (it=hourLst.begin(); it!=hourLst.end(); it++) { |
67 | if (*it != r) (*it)->setOn(false); | 68 | if (*it != r) (*it)->setOn(false); |
68 | else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); | 69 | else tm.setHMS((*it)->text().toInt(), tm.minute(), 0); |
69 | } | 70 | } |
70 | emit timeChanged(tm); | 71 | emit timeChanged(tm); |
71 | } else { | 72 | } else { |
72 | r->setOn(true); | 73 | r->setOn(true); |
73 | } | 74 | } |
74 | 75 | ||
75 | } | 76 | } |
76 | 77 | ||
77 | void TimePicker::slotMinute(bool b) { | 78 | void TimePicker::slotMinute(bool b) { |
78 | 79 | ||
79 | ClickableLabel *r = (ClickableLabel *) sender(); | 80 | ClickableLabel *r = (ClickableLabel *) sender(); |
80 | 81 | ||
81 | if (b) { | 82 | if (b) { |
82 | QValueListIterator<ClickableLabel *> it; | 83 | QValueListIterator<ClickableLabel *> it; |
83 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { | 84 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { |
84 | if (*it != r) (*it)->setOn(false); | 85 | if (*it != r) (*it)->setOn(false); |
85 | else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); | 86 | else tm.setHMS(tm.hour(),(*it)->text().toInt(), 0); |
86 | } | 87 | } |
87 | emit timeChanged(tm); | 88 | emit timeChanged(tm); |
88 | } else { | 89 | } else { |
89 | r->setOn(true); | 90 | r->setOn(true); |
90 | } | 91 | } |
91 | 92 | ||
92 | } | 93 | } |
93 | 94 | ||
94 | void TimePicker::setMinute(int m) { | 95 | void TimePicker::setMinute(int m) { |
95 | 96 | ||
96 | QString minute; | 97 | QString minute; |
97 | minute.sprintf("%.2d",m); | 98 | minute.sprintf("%.2d",m); |
98 | 99 | ||
99 | QValueListIterator<ClickableLabel *> it; | 100 | QValueListIterator<ClickableLabel *> it; |
100 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { | 101 | for (it=minuteLst.begin(); it!=minuteLst.end(); it++) { |
101 | if ((*it)->text() == minute) (*it)->setOn(true); | 102 | if ((*it)->text() == minute) (*it)->setOn(true); |
102 | else (*it)->setOn(false); | 103 | else (*it)->setOn(false); |
103 | } | 104 | } |
104 | 105 | ||
105 | tm.setHMS(tm.hour(),m,0); | 106 | tm.setHMS(tm.hour(),m,0); |
106 | } | 107 | } |
107 | 108 | ||
108 | void TimePicker::setHour(int h) { | 109 | void TimePicker::setHour(int h) { |
109 | 110 | ||
110 | QString hour; | 111 | QString hour; |
111 | hour.sprintf("%.2d",h); | 112 | hour.sprintf("%.2d",h); |
112 | 113 | ||
113 | QValueListIterator<ClickableLabel *> it; | 114 | QValueListIterator<ClickableLabel *> it; |
114 | for (it=hourLst.begin(); it!=hourLst.end(); it++) { | 115 | for (it=hourLst.begin(); it!=hourLst.end(); it++) { |
115 | if ((*it)->text() == hour) (*it)->setOn(true); | 116 | if ((*it)->text() == hour) (*it)->setOn(true); |
116 | else (*it)->setOn(false); | 117 | else (*it)->setOn(false); |
117 | } | 118 | } |
118 | tm.setHMS(h,tm.minute(),0); | 119 | tm.setHMS(h,tm.minute(),0); |
119 | } | 120 | } |