-rw-r--r-- | bin/kdepim/WhatsNew.txt | 5 | ||||
-rw-r--r-- | korganizer/koeditorgeneralevent.cpp | 17 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.cpp | 12 | ||||
-rw-r--r-- | korganizer/ktimeedit.cpp | 106 | ||||
-rw-r--r-- | korganizer/ktimeedit.h | 3 | ||||
-rw-r--r-- | microkde/kdecore/klocale.cpp | 4 |
6 files changed, 33 insertions, 114 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index c8293b2..5d8ef41 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,114 +1,119 @@ | |||
1 | Info about the changes in new versions of KDE-Pim/Pi | 1 | Info about the changes in new versions of KDE-Pim/Pi |
2 | 2 | ||
3 | ********** VERSION 1.9.18 ************ | 3 | ********** VERSION 1.9.18 ************ |
4 | 4 | ||
5 | FYI: The VERSION 1.9.17 was a testing release only. | 5 | FYI: The VERSION 1.9.17 was a testing release only. |
6 | Please read the changelog of VERSION 1.9.17 as well. | 6 | Please read the changelog of VERSION 1.9.17 as well. |
7 | 7 | ||
8 | Cleaned up the syncing config dialog. | 8 | Cleaned up the syncing config dialog. |
9 | Added sync config options for date range for events. | 9 | Added sync config options for date range for events. |
10 | Added sync config options for filters on incoming data. | 10 | Added sync config options for filters on incoming data. |
11 | Added sync config options for filters on outgoing data. | 11 | Added sync config options for filters on outgoing data. |
12 | Please read the updated SyncHowTo about the new filter settings. | 12 | Please read the updated SyncHowTo about the new filter settings. |
13 | These filter settings make it now possible to sync with shared | 13 | These filter settings make it now possible to sync with shared |
14 | calendars without writing back private or confidential data | 14 | calendars without writing back private or confidential data |
15 | (via the outgoing filters). | 15 | (via the outgoing filters). |
16 | To sync only with particular parts of a shared calendar, | 16 | To sync only with particular parts of a shared calendar, |
17 | the incoming filter settings can be used. | 17 | the incoming filter settings can be used. |
18 | An example can be found in the SyncHowTo. | 18 | An example can be found in the SyncHowTo. |
19 | |||
20 | KO/Pi: | ||
21 | The timeedit input has a pulldown list for times. | ||
22 | If opened, this pulldown list should now has the right time highlighted. | ||
23 | |||
19 | 24 | ||
20 | 25 | ||
21 | ********** VERSION 1.9.17 ************ | 26 | ********** VERSION 1.9.17 ************ |
22 | 27 | ||
23 | KO/Pi: | 28 | KO/Pi: |
24 | Fixed that tooltips were not updated after moving an item in agenda view. | 29 | Fixed that tooltips were not updated after moving an item in agenda view. |
25 | Fixed a bug in sorting start date for recurring events in list view. | 30 | Fixed a bug in sorting start date for recurring events in list view. |
26 | Changed the left button in todo viewer from "Agenda" to "Set completed". | 31 | Changed the left button in todo viewer from "Agenda" to "Set completed". |
27 | This makes it possible to change a todo in the What's Next View quickly to the completed state without leaving the What's Next View. | 32 | This makes it possible to change a todo in the What's Next View quickly to the completed state without leaving the What's Next View. |
28 | Added more info in the todo viewer: Startdate, parent/sub todos. | 33 | Added more info in the todo viewer: Startdate, parent/sub todos. |
29 | 34 | ||
30 | 35 | ||
31 | KA/Pi: | 36 | KA/Pi: |
32 | All fields search does now actually search all the (possible) fields, | 37 | All fields search does now actually search all the (possible) fields, |
33 | not only those listed in the contact list. | 38 | not only those listed in the contact list. |
34 | Made is possible to inline a picture in a vcard on the Z. | 39 | Made is possible to inline a picture in a vcard on the Z. |
35 | This was only possible on the desktop, now is it possible on the Z as well. | 40 | This was only possible on the desktop, now is it possible on the Z as well. |
36 | Fixed of missing save settings after filter configuration. | 41 | Fixed of missing save settings after filter configuration. |
37 | Made saving of addressbook much faster. | 42 | Made saving of addressbook much faster. |
38 | Fixed extension widget layout problem. | 43 | Fixed extension widget layout problem. |
39 | Fixed saving of default formatted name settings. | 44 | Fixed saving of default formatted name settings. |
40 | Fixed formatted name handling in edit dialog. | 45 | Fixed formatted name handling in edit dialog. |
41 | Added an option for changing formatted names of many contacts | 46 | Added an option for changing formatted names of many contacts |
42 | (menu: File - Change - Set formatted name). | 47 | (menu: File - Change - Set formatted name). |
43 | 48 | ||
44 | QWhatsThis was not working on the Z ( only black rectangle was shown). | 49 | QWhatsThis was not working on the Z ( only black rectangle was shown). |
45 | This is Fixed. | 50 | This is Fixed. |
46 | 51 | ||
47 | KDE-Sync: | 52 | KDE-Sync: |
48 | Now readonly KDE resources are synced as well. | 53 | Now readonly KDE resources are synced as well. |
49 | (They are not changed in KDE itself, of course). | 54 | (They are not changed in KDE itself, of course). |
50 | 55 | ||
51 | 56 | ||
52 | 57 | ||
53 | ********** VERSION 1.9.16 ************ | 58 | ********** VERSION 1.9.16 ************ |
54 | 59 | ||
55 | KO/Pi: | 60 | KO/Pi: |
56 | Fixed search dialog size on Z 6000 (480x640 display). | 61 | Fixed search dialog size on Z 6000 (480x640 display). |
57 | Added setting to hide/show time in agenda items. | 62 | Added setting to hide/show time in agenda items. |
58 | Added setting to hide not running todos in todo view. | 63 | Added setting to hide not running todos in todo view. |
59 | Added columns for start date/time in todo view. | 64 | Added columns for start date/time in todo view. |
60 | Replaced the solid half-hour lines in agenda view by dot lines. | 65 | Replaced the solid half-hour lines in agenda view by dot lines. |
61 | Added possibility of printing the What's Next View on the desktop | 66 | Added possibility of printing the What's Next View on the desktop |
62 | (i.e. Windows and Linux). | 67 | (i.e. Windows and Linux). |
63 | Fixed a crash in KO/Pi when starting KO/Pi with What's Next view. | 68 | Fixed a crash in KO/Pi when starting KO/Pi with What's Next view. |
64 | Added tooltips in month view.(Tooltips only available on desktop) | 69 | Added tooltips in month view.(Tooltips only available on desktop) |
65 | 70 | ||
66 | Fixed a strange problem in KO/Pi alarm applet. | 71 | Fixed a strange problem in KO/Pi alarm applet. |
67 | Did not find the actual problem, | 72 | Did not find the actual problem, |
68 | such that now Qtopia reboots again if deinstalling the alarm applet. | 73 | such that now Qtopia reboots again if deinstalling the alarm applet. |
69 | But the alarm applet should work again. | 74 | But the alarm applet should work again. |
70 | 75 | ||
71 | KA/Pi: | 76 | KA/Pi: |
72 | Fixed the problem, that internal pictures were not saved. | 77 | Fixed the problem, that internal pictures were not saved. |
73 | 78 | ||
74 | Fixed a problem in the pi-sync mode by increasing the timeout for data transfer from 20 seconds to 5 minutes. | 79 | Fixed a problem in the pi-sync mode by increasing the timeout for data transfer from 20 seconds to 5 minutes. |
75 | 80 | ||
76 | Fixed some minor problems. (Like word wrap in help text windows). | 81 | Fixed some minor problems. (Like word wrap in help text windows). |
77 | 82 | ||
78 | Fixed a compiling problem in microkde/kresources. | 83 | Fixed a compiling problem in microkde/kresources. |
79 | 84 | ||
80 | KO/Pi is using zdbat (renamed to db2file) for syncing with Sharp DTM. | 85 | KO/Pi is using zdbat (renamed to db2file) for syncing with Sharp DTM. |
81 | This version now includes zdbat 1.0.0 (old version was zdbat 0.2.9) | 86 | This version now includes zdbat 1.0.0 (old version was zdbat 0.2.9) |
82 | such that now syncing KO/Pi with Sharp DTM should work on the | 87 | such that now syncing KO/Pi with Sharp DTM should work on the |
83 | Zaurus C 3000 model. | 88 | Zaurus C 3000 model. |
84 | 89 | ||
85 | ********** VERSION 1.9.15 ************ | 90 | ********** VERSION 1.9.15 ************ |
86 | 91 | ||
87 | Usebilty enhancements in KO/Pi: | 92 | Usebilty enhancements in KO/Pi: |
88 | When clicking on the date in a month view cell, the day view is shown. | 93 | When clicking on the date in a month view cell, the day view is shown. |
89 | Old behaviour was, that the "new event" dialog popped up. | 94 | Old behaviour was, that the "new event" dialog popped up. |
90 | 95 | ||
91 | Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu). | 96 | Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu). |
92 | That means, you can restore the latest | 97 | That means, you can restore the latest |
93 | event/todo/journal you have deleted. | 98 | event/todo/journal you have deleted. |
94 | A journal is deleted, if you clear all the text of the journal. | 99 | A journal is deleted, if you clear all the text of the journal. |
95 | 100 | ||
96 | Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14. | 101 | Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14. |
97 | 102 | ||
98 | KA/Pi starting in 480x640 resolution: | 103 | KA/Pi starting in 480x640 resolution: |
99 | Hide the filter action in toolbar | 104 | Hide the filter action in toolbar |
100 | and added icons for undo/delete/redo in toolbar. | 105 | and added icons for undo/delete/redo in toolbar. |
101 | 106 | ||
102 | Change in OM/Pi ViewMail dialog: | 107 | Change in OM/Pi ViewMail dialog: |
103 | When clicking on the "delete" icon the mail is deleted after confirmation as usual. | 108 | When clicking on the "delete" icon the mail is deleted after confirmation as usual. |
104 | But the edit dialog is not closed as before, now the next mail in the folder is shown automatically (if there is any). | 109 | But the edit dialog is not closed as before, now the next mail in the folder is shown automatically (if there is any). |
105 | 110 | ||
106 | Fixed a crash when deleting mail-accounts in OM/Pi. | 111 | Fixed a crash when deleting mail-accounts in OM/Pi. |
107 | 112 | ||
108 | 113 | ||
109 | ********** VERSION 1.9.14 ************ | 114 | ********** VERSION 1.9.14 ************ |
110 | 115 | ||
111 | Fixed some problems with the dialog sizes when switching | 116 | Fixed some problems with the dialog sizes when switching |
112 | portrait/landscape mode on 640x480 PDA display. | 117 | portrait/landscape mode on 640x480 PDA display. |
113 | 118 | ||
114 | Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi. | 119 | Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi. |
diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp index fc5be71..30b792b 100644 --- a/korganizer/koeditorgeneralevent.cpp +++ b/korganizer/koeditorgeneralevent.cpp | |||
@@ -301,144 +301,127 @@ void KOEditorGeneralEvent::writeEvent(Event *event) | |||
301 | if (mNoTimeButton->isChecked()) { | 301 | if (mNoTimeButton->isChecked()) { |
302 | event->setFloats(true); | 302 | event->setFloats(true); |
303 | // need to change this. | 303 | // need to change this. |
304 | tmpDate = mStartDateEdit->date(); | 304 | tmpDate = mStartDateEdit->date(); |
305 | tmpTime.setHMS(0,0,0); | 305 | tmpTime.setHMS(0,0,0); |
306 | tmpDT.setDate(tmpDate); | 306 | tmpDT.setDate(tmpDate); |
307 | tmpDT.setTime(tmpTime); | 307 | tmpDT.setTime(tmpTime); |
308 | event->setDtStart(tmpDT); | 308 | event->setDtStart(tmpDT); |
309 | 309 | ||
310 | tmpDate = mEndDateEdit->date(); | 310 | tmpDate = mEndDateEdit->date(); |
311 | tmpTime.setHMS(0,0,0); | 311 | tmpTime.setHMS(0,0,0); |
312 | tmpDT.setDate(tmpDate); | 312 | tmpDT.setDate(tmpDate); |
313 | tmpDT.setTime(tmpTime); | 313 | tmpDT.setTime(tmpTime); |
314 | event->setDtEnd(tmpDT); | 314 | event->setDtEnd(tmpDT); |
315 | } else { | 315 | } else { |
316 | event->setFloats(false); | 316 | event->setFloats(false); |
317 | 317 | ||
318 | // set date/time end | 318 | // set date/time end |
319 | tmpDate = mEndDateEdit->date(); | 319 | tmpDate = mEndDateEdit->date(); |
320 | tmpTime = mEndTimeEdit->getTime(); | 320 | tmpTime = mEndTimeEdit->getTime(); |
321 | tmpDT.setDate(tmpDate); | 321 | tmpDT.setDate(tmpDate); |
322 | tmpDT.setTime(tmpTime); | 322 | tmpDT.setTime(tmpTime); |
323 | event->setDtEnd(tmpDT); | 323 | event->setDtEnd(tmpDT); |
324 | 324 | ||
325 | // set date/time start | 325 | // set date/time start |
326 | tmpDate = mStartDateEdit->date(); | 326 | tmpDate = mStartDateEdit->date(); |
327 | tmpTime = mStartTimeEdit->getTime(); | 327 | tmpTime = mStartTimeEdit->getTime(); |
328 | tmpDT.setDate(tmpDate); | 328 | tmpDT.setDate(tmpDate); |
329 | tmpDT.setTime(tmpTime); | 329 | tmpDT.setTime(tmpTime); |
330 | event->setDtStart(tmpDT); | 330 | event->setDtStart(tmpDT); |
331 | } // check for float | 331 | } // check for float |
332 | mSummaryEdit->save(KOLocationBox::SUMMARYEVENT); | 332 | mSummaryEdit->save(KOLocationBox::SUMMARYEVENT); |
333 | 333 | ||
334 | event->setTransparency(mFreeTimeCombo->currentItem() > 0 | 334 | event->setTransparency(mFreeTimeCombo->currentItem() > 0 |
335 | ? KCal::Event::Transparent | 335 | ? KCal::Event::Transparent |
336 | : KCal::Event::Opaque); | 336 | : KCal::Event::Opaque); |
337 | 337 | ||
338 | // kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl; | 338 | // kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl; |
339 | } | 339 | } |
340 | 340 | ||
341 | void KOEditorGeneralEvent::setDuration() | 341 | void KOEditorGeneralEvent::setDuration() |
342 | { | 342 | { |
343 | QString tmpStr = "", catStr; | 343 | QString tmpStr = "", catStr; |
344 | int hourdiff, minutediff; | 344 | int hourdiff, minutediff; |
345 | // end<date is an accepted temporary state while typing, but don't show | 345 | // end<date is an accepted temporary state while typing, but don't show |
346 | // any duration if this happens | 346 | // any duration if this happens |
347 | if(mCurrEndDateTime >= mCurrStartDateTime) { | 347 | if(mCurrEndDateTime >= mCurrStartDateTime) { |
348 | 348 | ||
349 | if (mNoTimeButton->isChecked()) { | 349 | if (mNoTimeButton->isChecked()) { |
350 | int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1; | 350 | int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1; |
351 | tmpStr = i18n("Duration: "); | 351 | tmpStr = i18n("Duration: "); |
352 | tmpStr.append(i18n("1 Day","%n Days",daydiff)); | 352 | tmpStr.append(i18n("1 Day","%n Days",daydiff)); |
353 | } else { | 353 | } else { |
354 | int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime ); | 354 | int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime ); |
355 | hourdiff = secto / 3600; | 355 | hourdiff = secto / 3600; |
356 | minutediff = (secto/60 ) % 60; | 356 | minutediff = (secto/60 ) % 60; |
357 | if (hourdiff || minutediff){ | 357 | if (hourdiff || minutediff){ |
358 | tmpStr = i18n("Duration: "); | 358 | tmpStr = i18n("Duration: "); |
359 | if (hourdiff){ | 359 | if (hourdiff){ |
360 | catStr = i18n("1 h","%n h",hourdiff); | 360 | catStr = i18n("1 h","%n h",hourdiff); |
361 | tmpStr.append(catStr); | 361 | tmpStr.append(catStr); |
362 | } | 362 | } |
363 | if (hourdiff && minutediff){ | 363 | if (hourdiff && minutediff){ |
364 | tmpStr += i18n(", "); | 364 | tmpStr += i18n(", "); |
365 | } | 365 | } |
366 | if (minutediff){ | 366 | if (minutediff){ |
367 | catStr = i18n("1 min","%n min",minutediff); | 367 | catStr = i18n("1 min","%n min",minutediff); |
368 | tmpStr += catStr; | 368 | tmpStr += catStr; |
369 | } | 369 | } |
370 | } else tmpStr = ""; | 370 | } else tmpStr = ""; |
371 | } | 371 | } |
372 | } | 372 | } |
373 | mDurationLabel->setText(tmpStr); | 373 | mDurationLabel->setText(tmpStr); |
374 | } | 374 | } |
375 | 375 | ||
376 | void KOEditorGeneralEvent::emitDateTimeStr() | 376 | void KOEditorGeneralEvent::emitDateTimeStr() |
377 | { | 377 | { |
378 | KLocale *l = KGlobal::locale(); | 378 | KLocale *l = KGlobal::locale(); |
379 | 379 | ||
380 | QString from,to; | 380 | QString from,to; |
381 | if (mNoTimeButton->isChecked()) { | 381 | if (mNoTimeButton->isChecked()) { |
382 | from = l->formatDate(mCurrStartDateTime.date()); | 382 | from = l->formatDate(mCurrStartDateTime.date()); |
383 | to = l->formatDate(mCurrEndDateTime.date()); | 383 | to = l->formatDate(mCurrEndDateTime.date()); |
384 | } else { | 384 | } else { |
385 | from = l->formatDateTime(mCurrStartDateTime); | 385 | from = l->formatDateTime(mCurrStartDateTime); |
386 | to = l->formatDateTime(mCurrEndDateTime); | 386 | to = l->formatDateTime(mCurrEndDateTime); |
387 | } | 387 | } |
388 | 388 | ||
389 | QString str = i18n("From: %1 To: %2 %3").arg(from).arg(to) | 389 | QString str = i18n("From: %1 To: %2 %3").arg(from).arg(to) |
390 | .arg(mDurationLabel->text()); | 390 | .arg(mDurationLabel->text()); |
391 | 391 | ||
392 | emit dateTimeStrChanged(str); | 392 | emit dateTimeStrChanged(str); |
393 | } | 393 | } |
394 | 394 | ||
395 | bool KOEditorGeneralEvent::validateInput() | 395 | bool KOEditorGeneralEvent::validateInput() |
396 | { | 396 | { |
397 | // kdDebug() << "KOEditorGeneralEvent::validateInput()" << endl; | ||
398 | |||
399 | if (!mNoTimeButton->isChecked()) { | ||
400 | if (!mStartTimeEdit->inputIsValid()) { | ||
401 | KMessageBox::sorry( 0, | ||
402 | i18n("Please specify a valid start time, for example '%1'.") | ||
403 | .arg( KGlobal::locale()->formatTime( QTime::currentTime() ) ) ); | ||
404 | return false; | ||
405 | } | ||
406 | |||
407 | if (!mEndTimeEdit->inputIsValid()) { | ||
408 | KMessageBox::sorry( 0, | ||
409 | i18n("Please specify a valid end time, for example '%1'.") | ||
410 | .arg( KGlobal::locale()->formatTime( QTime::currentTime() ) ) ); | ||
411 | return false; | ||
412 | } | ||
413 | } | ||
414 | 397 | ||
415 | if (!mStartDateEdit->inputIsValid()) { | 398 | if (!mStartDateEdit->inputIsValid()) { |
416 | KMessageBox::sorry( 0, | 399 | KMessageBox::sorry( 0, |
417 | i18n("Please specify a valid start date, for example '%1'.") | 400 | i18n("Please specify a valid start date, for example '%1'.") |
418 | .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) ); | 401 | .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) ); |
419 | return false; | 402 | return false; |
420 | } | 403 | } |
421 | 404 | ||
422 | if (!mEndDateEdit->inputIsValid()) { | 405 | if (!mEndDateEdit->inputIsValid()) { |
423 | KMessageBox::sorry( 0, | 406 | KMessageBox::sorry( 0, |
424 | i18n("Please specify a valid end date, for example '%1'.") | 407 | i18n("Please specify a valid end date, for example '%1'.") |
425 | .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) ); | 408 | .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) ); |
426 | return false; | 409 | return false; |
427 | } | 410 | } |
428 | 411 | ||
429 | QDateTime startDt,endDt; | 412 | QDateTime startDt,endDt; |
430 | startDt.setDate(mStartDateEdit->date()); | 413 | startDt.setDate(mStartDateEdit->date()); |
431 | endDt.setDate(mEndDateEdit->date()); | 414 | endDt.setDate(mEndDateEdit->date()); |
432 | if (!mNoTimeButton->isChecked()) { | 415 | if (!mNoTimeButton->isChecked()) { |
433 | startDt.setTime(mStartTimeEdit->getTime()); | 416 | startDt.setTime(mStartTimeEdit->getTime()); |
434 | endDt.setTime(mEndTimeEdit->getTime()); | 417 | endDt.setTime(mEndTimeEdit->getTime()); |
435 | } | 418 | } |
436 | 419 | ||
437 | if (startDt > endDt) { | 420 | if (startDt > endDt) { |
438 | KMessageBox::sorry(0,i18n("The event ends before it starts.\n" | 421 | KMessageBox::sorry(0,i18n("The event ends before it starts.\n" |
439 | "Please correct dates and times.")); | 422 | "Please correct dates and times.")); |
440 | return false; | 423 | return false; |
441 | } | 424 | } |
442 | 425 | ||
443 | return KOEditorGeneral::validateInput(); | 426 | return KOEditorGeneral::validateInput(); |
444 | } | 427 | } |
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index 7db7da0..158a7d3 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp | |||
@@ -291,176 +291,164 @@ void KOEditorGeneralTodo::writeTodo(Todo *todo) | |||
291 | tmpDT.setDate(tmpDate); | 291 | tmpDT.setDate(tmpDate); |
292 | tmpDT.setTime(tmpTime); | 292 | tmpDT.setTime(tmpTime); |
293 | todo->setDtStart(tmpDT); | 293 | todo->setDtStart(tmpDT); |
294 | } else { | 294 | } else { |
295 | todo->setFloats(true); | 295 | todo->setFloats(true); |
296 | 296 | ||
297 | // need to change this. | 297 | // need to change this. |
298 | tmpDate = mDueDateEdit->date(); | 298 | tmpDate = mDueDateEdit->date(); |
299 | tmpTime.setHMS(0,0,0); | 299 | tmpTime.setHMS(0,0,0); |
300 | tmpDT.setDate(tmpDate); | 300 | tmpDT.setDate(tmpDate); |
301 | tmpDT.setTime(tmpTime); | 301 | tmpDT.setTime(tmpTime); |
302 | todo->setDtDue(tmpDT); | 302 | todo->setDtDue(tmpDT); |
303 | 303 | ||
304 | tmpDate = mStartDateEdit->date(); | 304 | tmpDate = mStartDateEdit->date(); |
305 | tmpTime.setHMS(0,0,0); | 305 | tmpTime.setHMS(0,0,0); |
306 | tmpDT.setDate(tmpDate); | 306 | tmpDT.setDate(tmpDate); |
307 | tmpDT.setTime(tmpTime); | 307 | tmpDT.setTime(tmpTime); |
308 | todo->setDtStart(tmpDT); | 308 | todo->setDtStart(tmpDT); |
309 | } | 309 | } |
310 | 310 | ||
311 | todo->setPriority(mPriorityCombo->currentItem()+1); | 311 | todo->setPriority(mPriorityCombo->currentItem()+1); |
312 | 312 | ||
313 | // set completion state | 313 | // set completion state |
314 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); | 314 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); |
315 | 315 | ||
316 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { | 316 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { |
317 | todo->setCompleted(mCompleted); | 317 | todo->setCompleted(mCompleted); |
318 | } | 318 | } |
319 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); | 319 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); |
320 | } | 320 | } |
321 | 321 | ||
322 | void KOEditorGeneralTodo::enableDueEdit(bool enable) | 322 | void KOEditorGeneralTodo::enableDueEdit(bool enable) |
323 | { | 323 | { |
324 | mDueDateEdit->setEnabled( enable ); | 324 | mDueDateEdit->setEnabled( enable ); |
325 | 325 | ||
326 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 326 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
327 | mTimeButton->setEnabled(true); | 327 | mTimeButton->setEnabled(true); |
328 | } | 328 | } |
329 | else { | 329 | else { |
330 | mTimeButton->setEnabled(false); | 330 | mTimeButton->setEnabled(false); |
331 | mTimeButton->setChecked(false); | 331 | mTimeButton->setChecked(false); |
332 | } | 332 | } |
333 | 333 | ||
334 | if (enable) { | 334 | if (enable) { |
335 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); | 335 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); |
336 | } else { | 336 | } else { |
337 | mDueTimeEdit->setEnabled( false ); | 337 | mDueTimeEdit->setEnabled( false ); |
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) | 341 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) |
342 | { | 342 | { |
343 | mStartDateEdit->setEnabled( enable ); | 343 | mStartDateEdit->setEnabled( enable ); |
344 | 344 | ||
345 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 345 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
346 | mTimeButton->setEnabled(true); | 346 | mTimeButton->setEnabled(true); |
347 | } | 347 | } |
348 | else { | 348 | else { |
349 | mTimeButton->setEnabled(false); | 349 | mTimeButton->setEnabled(false); |
350 | mTimeButton->setChecked(false); | 350 | mTimeButton->setChecked(false); |
351 | } | 351 | } |
352 | 352 | ||
353 | if (enable) { | 353 | if (enable) { |
354 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); | 354 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); |
355 | } else { | 355 | } else { |
356 | mStartTimeEdit->setEnabled( false ); | 356 | mStartTimeEdit->setEnabled( false ); |
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) | 360 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) |
361 | { | 361 | { |
362 | if(mStartCheck->isChecked()) { | 362 | if(mStartCheck->isChecked()) { |
363 | mStartTimeEdit->setEnabled( enable ); | 363 | mStartTimeEdit->setEnabled( enable ); |
364 | } | 364 | } |
365 | if(mDueCheck->isChecked()) { | 365 | if(mDueCheck->isChecked()) { |
366 | mDueTimeEdit->setEnabled( enable ); | 366 | mDueTimeEdit->setEnabled( enable ); |
367 | } | 367 | } |
368 | } | 368 | } |
369 | 369 | ||
370 | void KOEditorGeneralTodo::showAlarm() | 370 | void KOEditorGeneralTodo::showAlarm() |
371 | { | 371 | { |
372 | if ( mDueCheck->isChecked() ) { | 372 | if ( mDueCheck->isChecked() ) { |
373 | alarmDisable(false); | 373 | alarmDisable(false); |
374 | } | 374 | } |
375 | else { | 375 | else { |
376 | alarmDisable(true); | 376 | alarmDisable(true); |
377 | } | 377 | } |
378 | } | 378 | } |
379 | 379 | ||
380 | bool KOEditorGeneralTodo::validateInput() | 380 | bool KOEditorGeneralTodo::validateInput() |
381 | { | 381 | { |
382 | if (mDueCheck->isChecked()) { | 382 | if (mDueCheck->isChecked()) { |
383 | if (!mDueDateEdit->inputIsValid()) { | 383 | if (!mDueDateEdit->inputIsValid()) { |
384 | KMessageBox::sorry(0,i18n("Please specify a valid due date.")); | 384 | KMessageBox::sorry(0,i18n("Please specify a valid due date.")); |
385 | return false; | 385 | return false; |
386 | } | 386 | } |
387 | if (mTimeButton->isChecked()) { | ||
388 | if (!mDueTimeEdit->inputIsValid()) { | ||
389 | KMessageBox::sorry(0,i18n("Please specify a valid due time.")); | ||
390 | return false; | ||
391 | } | ||
392 | } | ||
393 | } | 387 | } |
394 | 388 | ||
395 | if (mStartCheck->isChecked()) { | 389 | if (mStartCheck->isChecked()) { |
396 | if (!mStartDateEdit->inputIsValid()) { | 390 | if (!mStartDateEdit->inputIsValid()) { |
397 | KMessageBox::sorry(0,i18n("Please specify a valid start date.")); | 391 | KMessageBox::sorry(0,i18n("Please specify a valid start date.")); |
398 | return false; | 392 | return false; |
399 | } | 393 | } |
400 | if (mTimeButton->isChecked()) { | ||
401 | if (!mStartTimeEdit->inputIsValid()) { | ||
402 | KMessageBox::sorry(0,i18n("Please specify a valid start time.")); | ||
403 | return false; | ||
404 | } | ||
405 | } | ||
406 | } | 394 | } |
407 | 395 | ||
408 | if (mStartCheck->isChecked() && mDueCheck->isChecked()) { | 396 | if (mStartCheck->isChecked() && mDueCheck->isChecked()) { |
409 | QDateTime startDate; | 397 | QDateTime startDate; |
410 | QDateTime dueDate; | 398 | QDateTime dueDate; |
411 | startDate.setDate(mStartDateEdit->date()); | 399 | startDate.setDate(mStartDateEdit->date()); |
412 | dueDate.setDate(mDueDateEdit->date()); | 400 | dueDate.setDate(mDueDateEdit->date()); |
413 | if (mTimeButton->isChecked()) { | 401 | if (mTimeButton->isChecked()) { |
414 | startDate.setTime(mStartTimeEdit->getTime()); | 402 | startDate.setTime(mStartTimeEdit->getTime()); |
415 | dueDate.setTime(mDueTimeEdit->getTime()); | 403 | dueDate.setTime(mDueTimeEdit->getTime()); |
416 | } | 404 | } |
417 | if (startDate > dueDate) { | 405 | if (startDate > dueDate) { |
418 | KMessageBox::sorry(0, | 406 | KMessageBox::sorry(0, |
419 | i18n("The start date cannot be after the due date.")); | 407 | i18n("The start date cannot be after the due date.")); |
420 | return false; | 408 | return false; |
421 | } | 409 | } |
422 | } | 410 | } |
423 | 411 | ||
424 | return KOEditorGeneral::validateInput(); | 412 | return KOEditorGeneral::validateInput(); |
425 | } | 413 | } |
426 | 414 | ||
427 | void KOEditorGeneralTodo::completedChanged(int index) | 415 | void KOEditorGeneralTodo::completedChanged(int index) |
428 | { | 416 | { |
429 | if (index == 5) { | 417 | if (index == 5) { |
430 | mCompleted = QDateTime::currentDateTime(); | 418 | mCompleted = QDateTime::currentDateTime(); |
431 | } | 419 | } |
432 | setCompletedDate(); | 420 | setCompletedDate(); |
433 | } | 421 | } |
434 | 422 | ||
435 | void KOEditorGeneralTodo::setCompletedDate() | 423 | void KOEditorGeneralTodo::setCompletedDate() |
436 | { | 424 | { |
437 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { | 425 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { |
438 | mCompletedLabel->setText(i18n("completed on %1") | 426 | mCompletedLabel->setText(i18n("completed on %1") |
439 | .arg(KGlobal::locale()->formatDateTime(mCompleted))); | 427 | .arg(KGlobal::locale()->formatDateTime(mCompleted))); |
440 | } else { | 428 | } else { |
441 | mCompletedLabel->setText(i18n("completed")); | 429 | mCompletedLabel->setText(i18n("completed")); |
442 | } | 430 | } |
443 | } | 431 | } |
444 | 432 | ||
445 | void KOEditorGeneralTodo::modified (Todo* todo, int modification) | 433 | void KOEditorGeneralTodo::modified (Todo* todo, int modification) |
446 | { | 434 | { |
447 | switch (modification) { | 435 | switch (modification) { |
448 | case KOGlobals::PRIORITY_MODIFIED: | 436 | case KOGlobals::PRIORITY_MODIFIED: |
449 | mPriorityCombo->setCurrentItem(todo->priority()-1); | 437 | mPriorityCombo->setCurrentItem(todo->priority()-1); |
450 | break; | 438 | break; |
451 | case KOGlobals::COMPLETION_MODIFIED: | 439 | case KOGlobals::COMPLETION_MODIFIED: |
452 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); | 440 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); |
453 | if (todo->isCompleted() && todo->hasCompletedDate()) { | 441 | if (todo->isCompleted() && todo->hasCompletedDate()) { |
454 | mCompleted = todo->completed(); | 442 | mCompleted = todo->completed(); |
455 | } | 443 | } |
456 | setCompletedDate(); | 444 | setCompletedDate(); |
457 | break; | 445 | break; |
458 | case KOGlobals::CATEGORY_MODIFIED: | 446 | case KOGlobals::CATEGORY_MODIFIED: |
459 | setCategories (todo->categoriesStr ()); | 447 | setCategories (todo->categoriesStr ()); |
460 | break; | 448 | break; |
461 | case KOGlobals::UNKNOWN_MODIFIED: // fall through | 449 | case KOGlobals::UNKNOWN_MODIFIED: // fall through |
462 | default: | 450 | default: |
463 | readTodo( todo ); | 451 | readTodo( todo ); |
464 | break; | 452 | break; |
465 | } | 453 | } |
466 | } | 454 | } |
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp index f5a1c50..5222ac9 100644 --- a/korganizer/ktimeedit.cpp +++ b/korganizer/ktimeedit.cpp | |||
@@ -1,265 +1,221 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1999 Preston Brown, Ian Dawes | 3 | Copyright (c) 1999 Preston Brown, Ian Dawes |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qkeycode.h> | 24 | #include <qkeycode.h> |
25 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qlineedit.h> | 27 | #include <qlineedit.h> |
28 | #include <qlistbox.h> | ||
28 | #include <qapplication.h> | 29 | #include <qapplication.h> |
29 | 30 | ||
30 | #include <kmessagebox.h> | 31 | #include <kmessagebox.h> |
31 | #include <kglobal.h> | 32 | #include <kglobal.h> |
32 | #include <kdebug.h> | 33 | #include <kdebug.h> |
33 | #include <klocale.h> | 34 | #include <klocale.h> |
34 | #include <kpimglobalprefs.h> | 35 | #include <kpimglobalprefs.h> |
35 | 36 | ||
36 | #include "ktimeedit.h" | 37 | #include "ktimeedit.h" |
37 | #include "koprefs.h" | 38 | #include "koprefs.h" |
38 | #include <qvalidator.h> | 39 | #include <qvalidator.h> |
39 | 40 | ||
40 | // Validator for a time value with only hours and minutes (no seconds) | 41 | // Validator for a time value with only hours and minutes (no seconds) |
41 | // Mostly locale aware. Author: David Faure <faure@kde.org> | 42 | // Mostly locale aware. Author: David Faure <faure@kde.org> |
42 | class KOTimeValidator : public QValidator | ||
43 | { | ||
44 | public: | ||
45 | KOTimeValidator(QWidget* parent, const char* name=0) : QValidator(parent, name) {} | ||
46 | |||
47 | virtual State validate(QString& str, int& /*cursorPos*/) const | ||
48 | { | ||
49 | return Acceptable; | ||
50 | bool ok = false; | ||
51 | // TODO use KLocale::WithoutSeconds in HEAD | ||
52 | /*QTime time =*/ KGlobal::locale()->readTime(str, &ok); | ||
53 | if ( ok ) | ||
54 | return Acceptable; | ||
55 | // readTime doesn't help knowing when the string is "Intermediate". | ||
56 | int length = str.length(); | ||
57 | if ( !str ) // empty string? | ||
58 | return Invalid; // there should always be a ':' in it, right? | ||
59 | // HACK. Not fully locale aware etc. (esp. the separator is '.' in sv_SE...) | ||
60 | QChar sep = ':'; | ||
61 | // I want to allow "HH:", ":MM" and ":" to make editing easier | ||
62 | if ( str[0] == sep ) | ||
63 | { | ||
64 | if ( length == 1 ) // just ":" | ||
65 | return Intermediate; | ||
66 | QString minutes = str.mid(1); | ||
67 | int m = minutes.toInt(&ok); | ||
68 | if ( ok && m >= 0 && m < 60 ) | ||
69 | return Intermediate; | ||
70 | } else if ( str.at(str.length()-1) == sep ) | ||
71 | { | ||
72 | QString hours = str.left(length-1); | ||
73 | int h = hours.toInt(&ok); | ||
74 | if ( ok && h >= 0 && h < 24 ) | ||
75 | return Intermediate; | ||
76 | } | ||
77 | return Invalid; | ||
78 | } | ||
79 | }; | ||
80 | 43 | ||
81 | // KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox. | 44 | // KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox. |
82 | // Difficult to get all in one... | 45 | // Difficult to get all in one... |
83 | // But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help. | 46 | // But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help. |
84 | KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) | 47 | KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) |
85 | : QComboBox(TRUE, parent, name) | 48 | : QComboBox(TRUE, parent, name) |
86 | { | 49 | { |
87 | setInsertionPolicy(NoInsertion); | 50 | setInsertionPolicy(NoInsertion); |
88 | setValidator( new KOTimeValidator( this ) ); | ||
89 | mFlagKeyPressed = false; | 51 | mFlagKeyPressed = false; |
90 | 52 | ||
91 | if ( QApplication::desktop()->width() < 650 ) | 53 | if ( QApplication::desktop()->width() < 650 ) |
92 | setSizeLimit ( 6 ); | 54 | setSizeLimit ( 6 ); |
93 | mTime = qt; | 55 | mTime = qt; |
94 | 56 | ||
95 | // mNoTimeString = i18n("No Time"); | 57 | // mNoTimeString = i18n("No Time"); |
96 | // insertItem( mNoTimeString ); | 58 | // insertItem( mNoTimeString ); |
97 | 59 | ||
98 | // Fill combo box with selection of times in localized format. | 60 | // Fill combo box with selection of times in localized format. |
99 | QTime timeEntry(0,0,0); | 61 | QTime timeEntry(0,0,0); |
100 | do { | 62 | do { |
101 | insertItem(KGlobal::locale()->formatTime(timeEntry)); | 63 | insertItem(KGlobal::locale()->formatTime(timeEntry)); |
102 | timeEntry = timeEntry.addSecs(60*15); | 64 | timeEntry = timeEntry.addSecs(60*15); |
103 | } while (!timeEntry.isNull()); | 65 | } while (!timeEntry.isNull()); |
104 | // Add end of day. | 66 | // Add end of day. |
105 | insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) ); | 67 | insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) ); |
106 | 68 | ||
107 | updateText(); | 69 | updateText(); |
108 | setFocusPolicy(QWidget::StrongFocus); | 70 | setFocusPolicy(QWidget::StrongFocus); |
109 | 71 | ||
110 | connect(this, SIGNAL(activated(int)), this, SLOT(activ(int))); | 72 | connect(this, SIGNAL(activated(int)), this, SLOT(activ(int))); |
111 | connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int))); | 73 | connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int))); |
112 | connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); | 74 | connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); |
113 | QFontMetrics fm ( font() ); | 75 | QFontMetrics fm ( font() ); |
114 | QString timeString = "24:00"; | 76 | QString timeString = "24:00"; |
115 | if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ) | 77 | if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ) |
116 | timeString = "02:00pm"; | 78 | timeString = "02:00pm"; |
117 | int addSpace = 32; | 79 | int addSpace = 32; |
118 | if ( QApplication::desktop()->width() > 320 ) | 80 | if ( QApplication::desktop()->width() > 320 ) |
119 | timeString += ":00"; | 81 | timeString += ":00"; |
120 | setFixedWidth(fm.width( timeString ) + 32 ); | 82 | setFixedWidth(fm.width( timeString ) + 32 ); |
121 | 83 | ||
122 | // Highlight Background and Textcolor change from default | 84 | // Highlight Background and Textcolor change from default |
123 | QPalette palette = QWidget::palette(); | 85 | QPalette palette = QWidget::palette(); |
124 | unsigned char red, green, blue; | 86 | unsigned char red, green, blue; |
125 | red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; | 87 | red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; |
126 | green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; | 88 | green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; |
127 | blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; | 89 | blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; |
128 | palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); | 90 | palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); |
129 | palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); | 91 | palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); |
130 | setPalette( palette ); | 92 | setPalette( palette ); |
131 | } | 93 | } |
132 | 94 | ||
133 | KOTimeEdit::~KOTimeEdit() | 95 | KOTimeEdit::~KOTimeEdit() |
134 | { | 96 | { |
135 | } | 97 | } |
136 | 98 | ||
137 | bool KOTimeEdit::hasTime() const | 99 | bool KOTimeEdit::hasTime() const |
138 | { | 100 | { |
139 | // Can't happen | 101 | // Can't happen |
140 | if ( currentText().isEmpty() ) return false; | 102 | if ( currentText().isEmpty() ) return false; |
141 | //if ( currentText() == mNoTimeString ) return false; | 103 | //if ( currentText() == mNoTimeString ) return false; |
142 | 104 | ||
143 | return true; // always | 105 | return true; // always |
144 | } | 106 | } |
145 | 107 | ||
146 | QTime KOTimeEdit::getTime() const | 108 | QTime KOTimeEdit::getTime() const |
147 | { | 109 | { |
148 | //kdDebug(5850) << "KOTimeEdit::getTime(), currentText() = " << currentText() << endl; | 110 | return KGlobal::locale()->readTime(currentText()); |
149 | // TODO use KLocale::WithoutSeconds in HEAD | ||
150 | QTime time = KGlobal::locale()->readTime(currentText()); | ||
151 | // kdDebug(5850) << "KOTimeEdit::getTime(): " << time.toString() << endl; | ||
152 | return time; | ||
153 | } | 111 | } |
154 | /* | 112 | /* |
155 | QSizePolicy KOTimeEdit::sizePolicy() const | 113 | QSizePolicy KOTimeEdit::sizePolicy() const |
156 | { | 114 | { |
157 | // Set size policy to Fixed, because edit cannot contain more text than the | 115 | // Set size policy to Fixed, because edit cannot contain more text than the |
158 | // string representing the time. It doesn't make sense to provide more space. | 116 | // string representing the time. It doesn't make sense to provide more space. |
159 | QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); | 117 | QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); |
160 | 118 | ||
161 | return sizePolicy; | 119 | return sizePolicy; |
162 | } | 120 | } |
163 | */ | 121 | */ |
164 | void KOTimeEdit::setTime(QTime newTime) | 122 | void KOTimeEdit::setTime(QTime newTime) |
165 | { | 123 | { |
166 | if ( mTime != newTime ) | 124 | if ( mTime != newTime ) |
167 | { | 125 | { |
168 | kdDebug(5850) << "KOTimeEdit::setTime(): " << newTime.toString() << endl; | ||
169 | |||
170 | mTime = newTime; | 126 | mTime = newTime; |
171 | updateText(); | 127 | updateText(); |
172 | } | 128 | } |
173 | 129 | ||
174 | } | 130 | } |
175 | 131 | ||
176 | void KOTimeEdit::activ(int i) | 132 | void KOTimeEdit::activ(int i) |
177 | { | 133 | { |
178 | // The last entry, 23:59, is a special case | 134 | // The last entry, 23:59, is a special case |
179 | if( i == count() - 1 ) | 135 | if( i == count() - 1 ) |
180 | mTime = QTime( 23, 59, 0 ); | 136 | mTime = QTime( 23, 59, 0 ); |
181 | else | 137 | else |
182 | mTime = QTime(0,0,0).addSecs(i*15*60); | 138 | mTime = QTime(0,0,0).addSecs(i*15*60); |
183 | emit timeChanged(mTime); | 139 | emit timeChanged(mTime); |
184 | } | 140 | } |
185 | 141 | ||
186 | void KOTimeEdit::hilit(int ) | 142 | void KOTimeEdit::hilit(int ) |
187 | { | 143 | { |
188 | // we don't currently need to do anything here. | 144 | // we don't currently need to do anything here. |
189 | } | 145 | } |
190 | 146 | ||
191 | void KOTimeEdit::addTime(QTime qt, bool update) | 147 | void KOTimeEdit::addTime(QTime qt, bool update) |
192 | { | 148 | { |
193 | // Calculate the new time. | 149 | // Calculate the new time. |
194 | //qDebug("add h %d min %d ", qt.hour(),qt.minute() ); | 150 | //qDebug("add h %d min %d ", qt.hour(),qt.minute() ); |
195 | mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600); | 151 | mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600); |
196 | // if ( update ) | 152 | // if ( update ) |
197 | updateText(); | 153 | updateText(); |
198 | emit timeChanged(mTime); | 154 | emit timeChanged(mTime); |
199 | } | 155 | } |
200 | 156 | ||
201 | void KOTimeEdit::subTime(QTime qt, bool update) | 157 | void KOTimeEdit::subTime(QTime qt, bool update) |
202 | { | 158 | { |
203 | int h, m; | 159 | int h, m; |
204 | //qDebug("sub h %d min %d ", qt.hour(),qt.minute() ); | 160 | //qDebug("sub h %d min %d ", qt.hour(),qt.minute() ); |
205 | 161 | ||
206 | mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600)); | 162 | mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600)); |
207 | // store the newly calculated time. | 163 | // store the newly calculated time. |
208 | // mTime.setHMS(h, m, 0); | 164 | // mTime.setHMS(h, m, 0); |
209 | //if ( update ) | 165 | //if ( update ) |
210 | updateText(); | 166 | updateText(); |
211 | emit timeChanged(mTime); | 167 | emit timeChanged(mTime); |
212 | } | 168 | } |
213 | 169 | ||
214 | // void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * ) | 170 | // void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * ) |
215 | // { | 171 | // { |
216 | // qDebug("mouseReleaseEvent ( QMouseEvent * ) "); | 172 | // qDebug("mouseReleaseEvent ( QMouseEvent * ) "); |
217 | // } | 173 | // } |
218 | 174 | ||
219 | // void KOTimeEdit::focusInEvent ( QFocusEvent * ) | 175 | // void KOTimeEdit::focusInEvent ( QFocusEvent * ) |
220 | // { | 176 | // { |
221 | // qDebug("focusInEvent ( QFocusEvent * ) "); | 177 | // qDebug("focusInEvent ( QFocusEvent * ) "); |
222 | // } | 178 | // } |
223 | 179 | ||
224 | void KOTimeEdit::keyReleaseEvent(QKeyEvent *e) | 180 | void KOTimeEdit::keyReleaseEvent(QKeyEvent *e) |
225 | { | 181 | { |
226 | if ( !e->isAutoRepeat() ) { | 182 | if ( !e->isAutoRepeat() ) { |
227 | mFlagKeyPressed = false; | 183 | mFlagKeyPressed = false; |
228 | } | 184 | } |
229 | 185 | ||
230 | } | 186 | } |
231 | void KOTimeEdit::setSelect( int from, int to ) | 187 | void KOTimeEdit::setSelect( int from, int to ) |
232 | { | 188 | { |
233 | if ( KOPrefs::instance()->mHightlightDateTimeEdit) | 189 | if ( KOPrefs::instance()->mHightlightDateTimeEdit) |
234 | lineEdit()->setSelection( from , to ); | 190 | lineEdit()->setSelection( from , to ); |
235 | } | 191 | } |
236 | 192 | ||
237 | 193 | ||
238 | void KOTimeEdit::keyPressEvent(QKeyEvent *e) | 194 | void KOTimeEdit::keyPressEvent(QKeyEvent *e) |
239 | { | 195 | { |
240 | 196 | ||
241 | qApp->processEvents(); | 197 | qApp->processEvents(); |
242 | bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ); | 198 | bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ); |
243 | int maxpos = hour12Format?7:5; | 199 | int maxpos = hour12Format?7:5; |
244 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 200 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
245 | e->ignore(); | 201 | e->ignore(); |
246 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 202 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
247 | return; | 203 | return; |
248 | } | 204 | } |
249 | if (! e->isAutoRepeat() ) { | 205 | if (! e->isAutoRepeat() ) { |
250 | mFlagKeyPressed = true; | 206 | mFlagKeyPressed = true; |
251 | } | 207 | } |
252 | // Tap -> Focus Next Widget | 208 | // Tap -> Focus Next Widget |
253 | if ( e->key() == Key_Tab ) { | 209 | if ( e->key() == Key_Tab ) { |
254 | QComboBox::keyPressEvent(e); | 210 | QComboBox::keyPressEvent(e); |
255 | return; | 211 | return; |
256 | } | 212 | } |
257 | 213 | ||
258 | // save Text from QLineEdit and CursorPosition | 214 | // save Text from QLineEdit and CursorPosition |
259 | QString text = lineEdit()->text(); | 215 | QString text = lineEdit()->text(); |
260 | int cpos = lineEdit()->cursorPosition(); | 216 | int cpos = lineEdit()->cursorPosition(); |
261 | // qDebug("cpos %d ", cpos); | 217 | // qDebug("cpos %d ", cpos); |
262 | 218 | ||
263 | // Switch for arrows, backspace and escape | 219 | // Switch for arrows, backspace and escape |
264 | switch(e->key()) { | 220 | switch(e->key()) { |
265 | case Key_Escape: | 221 | case Key_Escape: |
@@ -286,243 +242,233 @@ void KOTimeEdit::keyPressEvent(QKeyEvent *e) | |||
286 | case 6: | 242 | case 6: |
287 | case 5: | 243 | case 5: |
288 | if(!hour12Format) { | 244 | if(!hour12Format) { |
289 | lineEdit()->setCursorPosition(cpos = 4); | 245 | lineEdit()->setCursorPosition(cpos = 4); |
290 | } else { | 246 | } else { |
291 | addTime(QTime(12,0,0), false ); | 247 | addTime(QTime(12,0,0), false ); |
292 | setSelect ( 5 , 2 ); | 248 | setSelect ( 5 , 2 ); |
293 | break; | 249 | break; |
294 | } | 250 | } |
295 | case 4: | 251 | case 4: |
296 | addTime(QTime(0,1,0), false ); | 252 | addTime(QTime(0,1,0), false ); |
297 | setSelect ( cpos , 1 ); | 253 | setSelect ( cpos , 1 ); |
298 | break; | 254 | break; |
299 | case 3: | 255 | case 3: |
300 | addTime(QTime(0,10,0), false ); | 256 | addTime(QTime(0,10,0), false ); |
301 | setSelect ( cpos , 1 ); | 257 | setSelect ( cpos , 1 ); |
302 | break; | 258 | break; |
303 | case 2: | 259 | case 2: |
304 | lineEdit()->setCursorPosition(--cpos); | 260 | lineEdit()->setCursorPosition(--cpos); |
305 | case 1: | 261 | case 1: |
306 | case 0: | 262 | case 0: |
307 | addTime(QTime(1,0,0), false ); | 263 | addTime(QTime(1,0,0), false ); |
308 | setSelect ( 0, 2 ); | 264 | setSelect ( 0, 2 ); |
309 | break; | 265 | break; |
310 | } | 266 | } |
311 | break; | 267 | break; |
312 | case Key_Down: | 268 | case Key_Down: |
313 | if ( e->state () == Qt::ControlButton ) { | 269 | if ( e->state () == Qt::ControlButton ) { |
314 | subTime(QTime(0,15,0), false ); | 270 | subTime(QTime(0,15,0), false ); |
315 | lineEdit()->setCursorPosition(3); | 271 | lineEdit()->setCursorPosition(3); |
316 | setSelect( 3 , 2 ); | 272 | setSelect( 3 , 2 ); |
317 | } | 273 | } |
318 | else | 274 | else |
319 | if ( e->state () == Qt::ShiftButton ) { | 275 | if ( e->state () == Qt::ShiftButton ) { |
320 | subTime(QTime(1,0,0), false ); | 276 | subTime(QTime(1,0,0), false ); |
321 | lineEdit()->setCursorPosition(0); | 277 | lineEdit()->setCursorPosition(0); |
322 | setSelect( 0 , 2 ); | 278 | setSelect( 0 , 2 ); |
323 | } | 279 | } |
324 | else | 280 | else |
325 | // switch time down, cursor location depend | 281 | // switch time down, cursor location depend |
326 | switch (cpos) { | 282 | switch (cpos) { |
327 | case 7: | 283 | case 7: |
328 | case 6: | 284 | case 6: |
329 | case 5: | 285 | case 5: |
330 | if(!hour12Format) { | 286 | if(!hour12Format) { |
331 | lineEdit()->setCursorPosition(cpos = 4); | 287 | lineEdit()->setCursorPosition(cpos = 4); |
332 | } else { | 288 | } else { |
333 | subTime(QTime(12,0,0), false ); | 289 | subTime(QTime(12,0,0), false ); |
334 | setSelect ( 5 , 2 ); | 290 | setSelect ( 5 , 2 ); |
335 | break; | 291 | break; |
336 | } | 292 | } |
337 | case 4: | 293 | case 4: |
338 | subTime(QTime(0,1,0), false ); | 294 | subTime(QTime(0,1,0), false ); |
339 | setSelect ( cpos , 1 ); | 295 | setSelect ( cpos , 1 ); |
340 | break; | 296 | break; |
341 | case 3: | 297 | case 3: |
342 | subTime(QTime(0,10,0), false ); | 298 | subTime(QTime(0,10,0), false ); |
343 | setSelect ( cpos , 1 ); | 299 | setSelect ( cpos , 1 ); |
344 | break; | 300 | break; |
345 | case 2: | 301 | case 2: |
346 | lineEdit()->setCursorPosition(--cpos); | 302 | lineEdit()->setCursorPosition(--cpos); |
347 | case 1: | 303 | case 1: |
348 | case 0: | 304 | case 0: |
349 | subTime(QTime(1,0,0), false ); | 305 | subTime(QTime(1,0,0), false ); |
350 | setSelect ( 0 , 2 ); | 306 | setSelect ( 0 , 2 ); |
351 | break; | 307 | break; |
352 | } | 308 | } |
353 | break; | 309 | break; |
354 | // set cursor to correct place | 310 | // set cursor to correct place |
355 | case Key_Left: | 311 | case Key_Left: |
356 | if ( cpos == 3 ) | 312 | if ( cpos == 3 ) |
357 | --cpos; | 313 | --cpos; |
358 | if ( cpos > 0) { | 314 | if ( cpos > 0) { |
359 | lineEdit()->setCursorPosition(--cpos); | 315 | lineEdit()->setCursorPosition(--cpos); |
360 | setSelect ( cpos , 1 ); | 316 | setSelect ( cpos , 1 ); |
361 | } | 317 | } |
362 | else | 318 | else |
363 | setSelect ( 0 , 1 ); | 319 | setSelect ( 0 , 1 ); |
364 | break; | 320 | break; |
365 | // set cursor to correct place | 321 | // set cursor to correct place |
366 | case Key_Right: | 322 | case Key_Right: |
367 | if ( cpos == 1 ) | 323 | if ( cpos == 1 ) |
368 | ++cpos; | 324 | ++cpos; |
369 | if ( cpos < maxpos ) { | 325 | if ( cpos < maxpos ) { |
370 | lineEdit()->setCursorPosition(++cpos); | 326 | lineEdit()->setCursorPosition(++cpos); |
371 | setSelect ( cpos , 1 ); | 327 | setSelect ( cpos , 1 ); |
372 | } | 328 | } |
373 | break; | 329 | break; |
374 | // rest | 330 | // rest |
375 | case Key_Prior: | 331 | case Key_Prior: |
376 | subTime(QTime(1,0,0)); | 332 | subTime(QTime(1,0,0)); |
377 | break; | 333 | break; |
378 | case Key_Next: | 334 | case Key_Next: |
379 | addTime(QTime(1,0,0)); | 335 | addTime(QTime(1,0,0)); |
380 | break; | 336 | break; |
381 | case Key_Backspace: | 337 | case Key_Backspace: |
338 | qDebug("+++++++++++back "); | ||
382 | if ( cpos > 0) { | 339 | if ( cpos > 0) { |
383 | if ( cpos == 3 ) | 340 | if ( cpos == 3 ) |
384 | --cpos; | 341 | --cpos; |
385 | if ( cpos > 5) | 342 | if ( cpos > 5) |
386 | cpos = 5; | 343 | cpos = 5; |
387 | text.at( cpos-1 ) = '0'; | 344 | text.at( cpos-1 ) = '0'; |
388 | lineEdit()->setText( text ); | 345 | lineEdit()->setText( text ); |
389 | lineEdit()->setCursorPosition(--cpos); | 346 | lineEdit()->setCursorPosition(--cpos); |
390 | setSelect ( cpos , 1 ); | 347 | setSelect ( cpos , 1 ); |
391 | changedText(); | 348 | changedText(); |
349 | qDebug("---------back "); | ||
392 | } | 350 | } |
393 | break; | 351 | break; |
394 | } // switch arrows | 352 | } // switch arrows |
395 | 353 | ||
396 | // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos | 354 | // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos |
397 | if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) { | 355 | if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) { |
398 | lineEdit()->deselect(); | 356 | lineEdit()->deselect(); |
399 | cpos = 0; | 357 | cpos = 0; |
400 | lineEdit()->setCursorPosition(cpos); | 358 | lineEdit()->setCursorPosition(cpos); |
401 | setSelect(cpos , 1); | 359 | setSelect(cpos , 1); |
402 | } | 360 | } |
403 | 361 | ||
404 | if ( cpos == 2 ) { | 362 | if ( cpos == 2 ) { |
405 | lineEdit()->setCursorPosition(++cpos); | 363 | lineEdit()->setCursorPosition(++cpos); |
406 | } | 364 | } |
407 | 365 | ||
408 | // num keys when cursorPos preEnd | 366 | // num keys when cursorPos preEnd |
409 | if ( cpos < 5 ) { | 367 | if ( cpos < 5 ) { |
410 | // switch another keys | 368 | // switch another keys |
411 | switch(e->key()) { | 369 | switch(e->key()) { |
412 | case Key_Delete: | 370 | case Key_Delete: |
413 | text.at( cpos ) = '0'; | 371 | text.at( cpos ) = '0'; |
414 | lineEdit()->setText( text ); | 372 | lineEdit()->setText( text ); |
415 | lineEdit()->setCursorPosition(cpos); | 373 | lineEdit()->setCursorPosition(cpos); |
416 | setSelect ( cpos , 1 ); | 374 | setSelect ( cpos , 1 ); |
417 | changedText(); | 375 | changedText(); |
418 | break; | 376 | break; |
419 | case Key_9: | 377 | case Key_9: |
420 | case Key_8: | 378 | case Key_8: |
421 | case Key_7: | 379 | case Key_7: |
422 | case Key_6: | 380 | case Key_6: |
423 | if ( !(cpos == 1 || cpos == 4) ) | 381 | if ( !(cpos == 1 || cpos == 4) ) |
424 | return; | 382 | return; |
425 | if ( cpos == 1 && text.at( 0 ) > '1') | 383 | if ( cpos == 1 && text.at( 0 ) > '1') |
426 | text.at( 0 ) = '1'; | 384 | text.at( 0 ) = '1'; |
427 | case Key_5: | 385 | case Key_5: |
428 | case Key_4: | 386 | case Key_4: |
429 | case Key_3: | 387 | case Key_3: |
430 | if ( cpos < 1 ) | 388 | if ( cpos < 1 ) |
431 | return; | 389 | return; |
432 | if ( hour12Format && cpos == 1 ) | 390 | if ( hour12Format && cpos == 1 ) |
433 | return; | 391 | return; |
434 | case Key_2: | 392 | case Key_2: |
435 | if ( hour12Format && cpos == 0 ) | 393 | if ( hour12Format && cpos == 0 ) |
436 | return; | 394 | return; |
437 | if ( cpos == 0 && text.at( 1 ) > '3') | 395 | if ( cpos == 0 && text.at( 1 ) > '3') |
438 | text.at( 1 ) = '3'; | 396 | text.at( 1 ) = '3'; |
439 | case Key_1: | 397 | case Key_1: |
440 | case Key_0: | 398 | case Key_0: |
441 | if ( hour12Format ) { | 399 | if ( hour12Format ) { |
442 | if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' ) | 400 | if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' ) |
443 | return; | 401 | return; |
444 | if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' ) | 402 | if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' ) |
445 | text.at( 1 ) = '1'; | 403 | text.at( 1 ) = '1'; |
446 | } | 404 | } |
447 | text.at( cpos ) = QChar ( e->key() ); | 405 | text.at( cpos ) = QChar ( e->key() ); |
448 | lineEdit()->setText( text ); | 406 | lineEdit()->setText( text ); |
449 | if ( cpos == 1 ) | 407 | if ( cpos == 1 ) |
450 | ++cpos; | 408 | ++cpos; |
451 | if ( cpos < 5) | 409 | if ( cpos < 5) |
452 | lineEdit()->setCursorPosition(++cpos); | 410 | lineEdit()->setCursorPosition(++cpos); |
453 | setSelect( cpos , 1 ); | 411 | setSelect( cpos , 1 ); |
454 | changedText(); | 412 | changedText(); |
455 | break; | 413 | break; |
456 | case Key_Home: | 414 | case Key_Home: |
457 | lineEdit()->setCursorPosition(0); | 415 | lineEdit()->setCursorPosition(0); |
458 | setSelect( cpos , 1 ); | 416 | setSelect( cpos , 1 ); |
459 | break; | 417 | break; |
460 | case Key_End: | 418 | case Key_End: |
461 | lineEdit()->setCursorPosition(5); | 419 | lineEdit()->setCursorPosition(5); |
462 | lineEdit()->deselect(); | 420 | lineEdit()->deselect(); |
463 | break; | 421 | break; |
464 | default: | 422 | default: |
465 | // QComboBox::keyPressEvent(e); | 423 | // QComboBox::keyPressEvent(e); |
466 | break; | 424 | break; |
467 | } // switch num keys | 425 | } // switch num keys |
468 | } else if ( cpos == 5 ) {// if cpos < 5 | 426 | } else if ( cpos == 5 ) {// if cpos < 5 |
469 | if ( hour12Format ) { | 427 | if ( hour12Format ) { |
470 | if ( e->key() == Key_A ) { | 428 | if ( e->key() == Key_A ) { |
471 | text.at( 5 ) = 'a'; | 429 | text.at( 5 ) = 'a'; |
472 | lineEdit()->setText( text ); | 430 | lineEdit()->setText( text ); |
473 | lineEdit()->setCursorPosition(5); | 431 | lineEdit()->setCursorPosition(5); |
474 | 432 | ||
475 | } else if ( e->key() == Key_P ) { | 433 | } else if ( e->key() == Key_P ) { |
476 | text.at( 5 ) = 'p'; | 434 | text.at( 5 ) = 'p'; |
477 | lineEdit()->setText( text ); | 435 | lineEdit()->setText( text ); |
478 | lineEdit()->setCursorPosition(5); | 436 | lineEdit()->setCursorPosition(5); |
479 | 437 | ||
480 | } | 438 | } |
481 | } | 439 | } |
482 | } | 440 | } |
483 | 441 | ||
484 | 442 | ||
485 | } | 443 | } |
486 | 444 | ||
487 | void KOTimeEdit::updateText() | 445 | void KOTimeEdit::updateText() |
488 | { | 446 | { |
489 | // kdDebug(5850) << "KOTimeEdit::updateText() " << endl | 447 | listBox()->blockSignals( true ); |
490 | QString s = KGlobal::locale()->formatTime(mTime); | 448 | blockSignals( true ); |
491 | // Set the text but without emitting signals, nor losing the cursor position | 449 | QString s = KGlobal::locale()->formatTime(mTime); |
492 | QLineEdit *line = lineEdit(); | 450 | // Set the text but without emitting signals, nor losing the cursor position |
493 | line->blockSignals(true); | 451 | QLineEdit *line = lineEdit(); |
494 | int pos = line->cursorPosition(); | 452 | line->blockSignals(true); |
495 | // qDebug(" settext *%s* ", s.latin1()); | 453 | int pos = line->cursorPosition(); |
496 | line->setText(s); | ||
497 | // line->setCursorPosition(pos); | ||
498 | // line->blockSignals(false); | ||
499 | |||
500 | // kdDebug(5850) << "KOTimeEdit::updateText(): " << s << endl; | ||
501 | |||
502 | if (!mTime.minute() % 15) { | ||
503 | setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); | 454 | setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); |
504 | } | 455 | line->setText(s); |
505 | line->setCursorPosition(pos); | 456 | line->setCursorPosition(pos); |
506 | line->blockSignals(false); | 457 | line->blockSignals(false); |
507 | 458 | blockSignals( false ); | |
508 | } | 459 | listBox()->blockSignals( false ); |
509 | 460 | ||
510 | bool KOTimeEdit::inputIsValid() const | ||
511 | { | ||
512 | int cursorPos = lineEdit()->cursorPosition(); | ||
513 | QString str = currentText(); | ||
514 | return validator()->validate( str, cursorPos ) == QValidator::Acceptable; | ||
515 | } | 461 | } |
516 | 462 | ||
517 | void KOTimeEdit::changedText() | 463 | void KOTimeEdit::changedText() |
518 | { | 464 | { |
519 | //kdDebug(5850) << "KOTimeEdit::changedText()" << endl; | 465 | int pos = lineEdit()->cursorPosition(); |
520 | if ( inputIsValid() ) | 466 | mTime = getTime(); |
521 | { | 467 | blockSignals( true ); |
522 | int pos = lineEdit()->cursorPosition(); | 468 | QString text = lineEdit()->text(); |
523 | mTime = getTime(); | 469 | setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); |
524 | // updateText(); | 470 | lineEdit()->setText(text); |
525 | emit timeChanged(mTime); | 471 | blockSignals( false ); |
526 | lineEdit()->setCursorPosition(pos); | 472 | emit timeChanged(mTime); |
527 | } | 473 | lineEdit()->setCursorPosition(pos); |
528 | } | 474 | } |
diff --git a/korganizer/ktimeedit.h b/korganizer/ktimeedit.h index 7923070..b3d842d 100644 --- a/korganizer/ktimeedit.h +++ b/korganizer/ktimeedit.h | |||
@@ -1,97 +1,94 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1999 Preston Brown, Ian Dawes | 3 | Copyright (c) 1999 Preston Brown, Ian Dawes |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KTIMEEDIT_H | 23 | #ifndef _KTIMEEDIT_H |
24 | #define _KTIMEEDIT_H | 24 | #define _KTIMEEDIT_H |
25 | 25 | ||
26 | #include <qevent.h> | 26 | #include <qevent.h> |
27 | #include <qkeycode.h> | 27 | #include <qkeycode.h> |
28 | #include <qstring.h> | 28 | #include <qstring.h> |
29 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | 31 | ||
32 | #include <kapplication.h> | 32 | #include <kapplication.h> |
33 | 33 | ||
34 | /** | 34 | /** |
35 | This is a class that provides an easy, user friendly way to edit times. | 35 | This is a class that provides an easy, user friendly way to edit times. |
36 | up/down/ increase or decrease time, respectively. | 36 | up/down/ increase or decrease time, respectively. |
37 | 37 | ||
38 | @short Provides a way to edit times in a user-friendly manner. | 38 | @short Provides a way to edit times in a user-friendly manner. |
39 | @author Preston Brown, Ian Dawes | 39 | @author Preston Brown, Ian Dawes |
40 | */ | 40 | */ |
41 | class KOTimeEdit : public QComboBox | 41 | class KOTimeEdit : public QComboBox |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | /** constructs a new time edit. */ | 45 | /** constructs a new time edit. */ |
46 | KOTimeEdit(QWidget *parent=0, QTime qt=QTime(12,0), const char *name=0); | 46 | KOTimeEdit(QWidget *parent=0, QTime qt=QTime(12,0), const char *name=0); |
47 | 47 | ||
48 | virtual ~KOTimeEdit(); | 48 | virtual ~KOTimeEdit(); |
49 | 49 | ||
50 | /** | 50 | /** |
51 | Returns, if a time is selected. Can not return false anymore.... | 51 | Returns, if a time is selected. Can not return false anymore.... |
52 | */ | 52 | */ |
53 | bool hasTime() const; | 53 | bool hasTime() const; |
54 | 54 | ||
55 | /** returns the time that is currently set in the timeLineEdit. */ | 55 | /** returns the time that is currently set in the timeLineEdit. */ |
56 | QTime getTime() const; | 56 | QTime getTime() const; |
57 | 57 | ||
58 | /** returns the prefered size policy of the KOTimeEdit */ | 58 | /** returns the prefered size policy of the KOTimeEdit */ |
59 | //QSizePolicy sizePolicy() const; | 59 | //QSizePolicy sizePolicy() const; |
60 | 60 | ||
61 | /** return true if input is a valid time and false if not */ | ||
62 | bool inputIsValid() const; | ||
63 | |||
64 | signals: | 61 | signals: |
65 | /** | 62 | /** |
66 | Emitted every time the time displayed changes. "newt" is the new | 63 | Emitted every time the time displayed changes. "newt" is the new |
67 | time. | 64 | time. |
68 | */ | 65 | */ |
69 | void timeChanged(QTime newt); | 66 | void timeChanged(QTime newt); |
70 | 67 | ||
71 | public slots: | 68 | public slots: |
72 | /** used to set the time which is displayed to a specific value. */ | 69 | /** used to set the time which is displayed to a specific value. */ |
73 | void setTime(QTime qt); | 70 | void setTime(QTime qt); |
74 | 71 | ||
75 | protected slots: | 72 | protected slots: |
76 | void activ(int); | 73 | void activ(int); |
77 | void hilit(int); | 74 | void hilit(int); |
78 | void changedText(); | 75 | void changedText(); |
79 | 76 | ||
80 | protected: | 77 | protected: |
81 | void keyPressEvent(QKeyEvent *qke); | 78 | void keyPressEvent(QKeyEvent *qke); |
82 | void keyReleaseEvent(QKeyEvent *qke); | 79 | void keyReleaseEvent(QKeyEvent *qke); |
83 | void setSelect ( int, int ); | 80 | void setSelect ( int, int ); |
84 | bool mFlagKeyPressed; | 81 | bool mFlagKeyPressed; |
85 | void addTime(QTime qt, bool update = true ); | 82 | void addTime(QTime qt, bool update = true ); |
86 | void subTime(QTime qt, bool update = true ); | 83 | void subTime(QTime qt, bool update = true ); |
87 | // Update the lineedit text from mTime | 84 | // Update the lineedit text from mTime |
88 | void updateText(); | 85 | void updateText(); |
89 | // void mouseReleaseEvent ( QMouseEvent * ) ; | 86 | // void mouseReleaseEvent ( QMouseEvent * ) ; |
90 | //void focusInEvent ( QFocusEvent * ) ; | 87 | //void focusInEvent ( QFocusEvent * ) ; |
91 | 88 | ||
92 | private: | 89 | private: |
93 | QTime mTime; // the widget's displayed time. | 90 | QTime mTime; // the widget's displayed time. |
94 | //QString mNoTimeString; | 91 | //QString mNoTimeString; |
95 | }; | 92 | }; |
96 | 93 | ||
97 | #endif | 94 | #endif |
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index d7e384c..7f31ab1 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp | |||
@@ -469,195 +469,195 @@ QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) con | |||
469 | int year = QDate::currentDate().year(); | 469 | int year = QDate::currentDate().year(); |
470 | uint strpos = 0; | 470 | uint strpos = 0; |
471 | uint fmtpos = 0; | 471 | uint fmtpos = 0; |
472 | 472 | ||
473 | while (fmt.length() > fmtpos || str.length() > strpos) | 473 | while (fmt.length() > fmtpos || str.length() > strpos) |
474 | { | 474 | { |
475 | if ( !(fmt.length() > fmtpos && str.length() > strpos) ) | 475 | if ( !(fmt.length() > fmtpos && str.length() > strpos) ) |
476 | goto error; | 476 | goto error; |
477 | 477 | ||
478 | QChar c = fmt.at(fmtpos++); | 478 | QChar c = fmt.at(fmtpos++); |
479 | 479 | ||
480 | if (c != '%') { | 480 | if (c != '%') { |
481 | if (c.isSpace()) | 481 | if (c.isSpace()) |
482 | strpos++; | 482 | strpos++; |
483 | else if (c != str.at(strpos++)) | 483 | else if (c != str.at(strpos++)) |
484 | goto error; | 484 | goto error; |
485 | continue; | 485 | continue; |
486 | } | 486 | } |
487 | 487 | ||
488 | // remove space at the begining | 488 | // remove space at the begining |
489 | if (str.length() > strpos && str.at(strpos).isSpace()) | 489 | if (str.length() > strpos && str.at(strpos).isSpace()) |
490 | strpos++; | 490 | strpos++; |
491 | 491 | ||
492 | c = fmt.at(fmtpos++); | 492 | c = fmt.at(fmtpos++); |
493 | switch (c) | 493 | switch (c) |
494 | { | 494 | { |
495 | case 'a': | 495 | case 'a': |
496 | case 'A': | 496 | case 'A': |
497 | // this will just be ignored | 497 | // this will just be ignored |
498 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition | 498 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition |
499 | for (int j = 1; j < 8; j++) { | 499 | for (int j = 1; j < 8; j++) { |
500 | QString s = weekDayName(j, c == 'a').lower(); | 500 | QString s = weekDayName(j, c == 'a').lower(); |
501 | int len = s.length(); | 501 | int len = s.length(); |
502 | if (str.mid(strpos, len) == s) | 502 | if (str.mid(strpos, len) == s) |
503 | strpos += len; | 503 | strpos += len; |
504 | } | 504 | } |
505 | break; | 505 | break; |
506 | } | 506 | } |
507 | case 'b': | 507 | case 'b': |
508 | case 'B': | 508 | case 'B': |
509 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition | 509 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition |
510 | for (int j = 1; j < 13; j++) { | 510 | for (int j = 1; j < 13; j++) { |
511 | QString s = monthName(j, c == 'b').lower(); | 511 | QString s = monthName(j, c == 'b').lower(); |
512 | int len = s.length(); | 512 | int len = s.length(); |
513 | if (str.mid(strpos, len) == s) { | 513 | if (str.mid(strpos, len) == s) { |
514 | month = j; | 514 | month = j; |
515 | strpos += len; | 515 | strpos += len; |
516 | } | 516 | } |
517 | } | 517 | } |
518 | break; | 518 | break; |
519 | } | 519 | } |
520 | case 'd': | 520 | case 'd': |
521 | case 'e': | 521 | case 'e': |
522 | day = readInt(str, strpos); | 522 | day = readInt(str, strpos); |
523 | if (day < 1 || day > 31) | 523 | if (day < 1 || day > 31) |
524 | goto error; | 524 | goto error; |
525 | 525 | ||
526 | break; | 526 | break; |
527 | 527 | ||
528 | case 'n': | 528 | case 'n': |
529 | case 'm': | 529 | case 'm': |
530 | month = readInt(str, strpos); | 530 | month = readInt(str, strpos); |
531 | if (month < 1 || month > 12) | 531 | if (month < 1 || month > 12) |
532 | goto error; | 532 | goto error; |
533 | 533 | ||
534 | break; | 534 | break; |
535 | 535 | ||
536 | case 'Y': | 536 | case 'Y': |
537 | case 'y': | 537 | case 'y': |
538 | year = readInt(str, strpos); | 538 | year = readInt(str, strpos); |
539 | if (year < 0) | 539 | if (year < 0) |
540 | goto error; | 540 | goto error; |
541 | // Qt treats a year in the range 0-100 as 1900-1999. | 541 | // Qt treats a year in the range 0-100 as 1900-1999. |
542 | // It is nicer for the user if we treat 0-68 as 2000-2068 | 542 | // It is nicer for the user if we treat 0-68 as 2000-2068 |
543 | if (year < 69) | 543 | if (year < 69) |
544 | year += 2000; | 544 | year += 2000; |
545 | else if (c == 'y') | 545 | else if (c == 'y') |
546 | year += 1900; | 546 | year += 1900; |
547 | 547 | ||
548 | break; | 548 | break; |
549 | } | 549 | } |
550 | } | 550 | } |
551 | //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; | 551 | //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; |
552 | if ( year != -1 && month != -1 && day != -1 ) | 552 | if ( year != -1 && month != -1 && day != -1 ) |
553 | { | 553 | { |
554 | if (ok) *ok = true; | 554 | if (ok) *ok = true; |
555 | return QDate(year, month, day); | 555 | return QDate(year, month, day); |
556 | } | 556 | } |
557 | error: | 557 | error: |
558 | if (ok) *ok = false; | 558 | if (ok) *ok = false; |
559 | return QDate(); // invalid date | 559 | return QDate(); // invalid date |
560 | } | 560 | } |
561 | 561 | ||
562 | QTime KLocale::readTime(const QString &intstr, bool *ok) const | 562 | QTime KLocale::readTime(const QString &intstr, bool *ok) const |
563 | { | 563 | { |
564 | QTime _time; | 564 | QTime _time; |
565 | _time = readTime(intstr, true, ok); | 565 | _time = readTime(intstr, false, ok); |
566 | if (_time.isValid()) return _time; | 566 | if (_time.isValid()) return _time; |
567 | return readTime(intstr, false, ok); | 567 | return readTime(intstr, true, ok); |
568 | } | 568 | } |
569 | 569 | ||
570 | QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const | 570 | QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const |
571 | { | 571 | { |
572 | QString str = intstr.simplifyWhiteSpace().lower(); | 572 | QString str = intstr.simplifyWhiteSpace().lower(); |
573 | QString Format = timeFormat().simplifyWhiteSpace(); | 573 | QString Format = timeFormat().simplifyWhiteSpace(); |
574 | if (!seconds) | 574 | if (!seconds) |
575 | Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); | 575 | Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); |
576 | 576 | ||
577 | int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds | 577 | int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds |
578 | 578 | ||
579 | bool g_12h = false; | 579 | bool g_12h = false; |
580 | bool pm = false; | 580 | bool pm = false; |
581 | uint strpos = 0; | 581 | uint strpos = 0; |
582 | uint Formatpos = 0; | 582 | uint Formatpos = 0; |
583 | 583 | ||
584 | while (Format.length() > Formatpos || str.length() > strpos) | 584 | while (Format.length() > Formatpos || str.length() > strpos) |
585 | { | 585 | { |
586 | if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; | 586 | if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; |
587 | 587 | ||
588 | QChar c = Format.at(Formatpos++); | 588 | QChar c = Format.at(Formatpos++); |
589 | 589 | ||
590 | if (c != '%') | 590 | if (c != '%') |
591 | { | 591 | { |
592 | if (c.isSpace()) | 592 | if (c.isSpace()) |
593 | strpos++; | 593 | strpos++; |
594 | else if (c != str.at(strpos++)) | 594 | else if (c != str.at(strpos++)) |
595 | goto error; | 595 | goto error; |
596 | continue; | 596 | continue; |
597 | } | 597 | } |
598 | 598 | ||
599 | // remove space at the begining | 599 | // remove space at the begining |
600 | if (str.length() > strpos && str.at(strpos).isSpace()) | 600 | if (str.length() > strpos && str.at(strpos).isSpace()) |
601 | strpos++; | 601 | strpos++; |
602 | 602 | ||
603 | c = Format.at(Formatpos++); | 603 | c = Format.at(Formatpos++); |
604 | switch (c) | 604 | switch (c) |
605 | { | 605 | { |
606 | case 'p': | 606 | case 'p': |
607 | { | 607 | { |
608 | QString s; | 608 | QString s; |
609 | s = i18n("pm").lower(); | 609 | s = i18n("pm").lower(); |
610 | int len = s.length(); | 610 | int len = s.length(); |
611 | if (str.mid(strpos, len) == s) | 611 | if (str.mid(strpos, len) == s) |
612 | { | 612 | { |
613 | pm = true; | 613 | pm = true; |
614 | strpos += len; | 614 | strpos += len; |
615 | } | 615 | } |
616 | else | 616 | else |
617 | { | 617 | { |
618 | s = i18n("am").lower(); | 618 | s = i18n("am").lower(); |
619 | len = s.length(); | 619 | len = s.length(); |
620 | if (str.mid(strpos, len) == s) { | 620 | if (str.mid(strpos, len) == s) { |
621 | pm = false; | 621 | pm = false; |
622 | strpos += len; | 622 | strpos += len; |
623 | } | 623 | } |
624 | else | 624 | else |
625 | goto error; | 625 | goto error; |
626 | } | 626 | } |
627 | } | 627 | } |
628 | break; | 628 | break; |
629 | 629 | ||
630 | case 'k': | 630 | case 'k': |
631 | case 'H': | 631 | case 'H': |
632 | g_12h = false; | 632 | g_12h = false; |
633 | hour = readInt(str, strpos); | 633 | hour = readInt(str, strpos); |
634 | if (hour < 0 || hour > 23) | 634 | if (hour < 0 || hour > 23) |
635 | goto error; | 635 | goto error; |
636 | 636 | ||
637 | break; | 637 | break; |
638 | 638 | ||
639 | case 'l': | 639 | case 'l': |
640 | case 'I': | 640 | case 'I': |
641 | g_12h = true; | 641 | g_12h = true; |
642 | hour = readInt(str, strpos); | 642 | hour = readInt(str, strpos); |
643 | if (hour < 1 || hour > 12) | 643 | if (hour < 1 || hour > 12) |
644 | goto error; | 644 | goto error; |
645 | 645 | ||
646 | break; | 646 | break; |
647 | 647 | ||
648 | case 'M': | 648 | case 'M': |
649 | minute = readInt(str, strpos); | 649 | minute = readInt(str, strpos); |
650 | if (minute < 0 || minute > 59) | 650 | if (minute < 0 || minute > 59) |
651 | goto error; | 651 | goto error; |
652 | 652 | ||
653 | break; | 653 | break; |
654 | 654 | ||
655 | case 'S': | 655 | case 'S': |
656 | second = readInt(str, strpos); | 656 | second = readInt(str, strpos); |
657 | if (second < 0 || second > 59) | 657 | if (second < 0 || second > 59) |
658 | goto error; | 658 | goto error; |
659 | 659 | ||
660 | break; | 660 | break; |
661 | } | 661 | } |
662 | } | 662 | } |
663 | if (g_12h) | 663 | if (g_12h) |