author | umopapisdn <umopapisdn> | 2003-04-13 21:41:19 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-04-13 21:41:19 (UTC) |
commit | 1745c6565e18506d5cb5631ae13cfc5fab060fee (patch) (unidiff) | |
tree | 4206eaf78b396c31e7e8729886b0c9c32bae9855 | |
parent | 6f610544d3db6198c90105b70fab1cc84f5a1fbd (diff) | |
download | opie-1745c6565e18506d5cb5631ae13cfc5fab060fee.zip opie-1745c6565e18506d5cb5631ae13cfc5fab060fee.tar.gz opie-1745c6565e18506d5cb5631ae13cfc5fab060fee.tar.bz2 |
New feature: Added the possibility to add "quick entries" in dayview merely by clicking on the calendar, which overlays a qlineedit.
Right now it adds 1 hour events, this will soon be adressed.
-rw-r--r-- | core/pim/datebook/datebook.cpp | 7 | ||||
-rw-r--r-- | core/pim/datebook/datebook.h | 3 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 863 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.h | 25 |
4 files changed, 469 insertions, 429 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 4fbcb10..6dd8918 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -290,192 +290,199 @@ QString DateBook::checkEvent(const Event &e) | |||
290 | 290 | ||
291 | /* check the next 12 repeats. should catch most problems */ | 291 | /* check the next 12 repeats. should catch most problems */ |
292 | QDate current_date = e.start().date(); | 292 | QDate current_date = e.start().date(); |
293 | Event previous = e; | 293 | Event previous = e; |
294 | for(int i = 0; i < 12; i++) | 294 | for(int i = 0; i < 12; i++) |
295 | { | 295 | { |
296 | QDateTime next; | 296 | QDateTime next; |
297 | if (!nextOccurance(previous, current_date.addDays(1), next)) { | 297 | if (!nextOccurance(previous, current_date.addDays(1), next)) { |
298 | break; // no more repeats | 298 | break; // no more repeats |
299 | } | 299 | } |
300 | if(next < previous.end()) { | 300 | if(next < previous.end()) { |
301 | checkFailed = TRUE; | 301 | checkFailed = TRUE; |
302 | break; | 302 | break; |
303 | } | 303 | } |
304 | current_date = next.date(); | 304 | current_date = next.date(); |
305 | } | 305 | } |
306 | 306 | ||
307 | if(checkFailed) | 307 | if(checkFailed) |
308 | return tr("Event duration is potentially longer\n" | 308 | return tr("Event duration is potentially longer\n" |
309 | "than interval between repeats."); | 309 | "than interval between repeats."); |
310 | 310 | ||
311 | return QString::null; | 311 | return QString::null; |
312 | } | 312 | } |
313 | 313 | ||
314 | QDate DateBook::currentDate() | 314 | QDate DateBook::currentDate() |
315 | { | 315 | { |
316 | QDate d = QDate::currentDate(); | 316 | QDate d = QDate::currentDate(); |
317 | 317 | ||
318 | if ( dayView && views->visibleWidget() == dayView ) { | 318 | if ( dayView && views->visibleWidget() == dayView ) { |
319 | d = dayView->date(); | 319 | d = dayView->date(); |
320 | } else if ( weekView && views->visibleWidget() == weekView ) { | 320 | } else if ( weekView && views->visibleWidget() == weekView ) { |
321 | d = weekView->date(); | 321 | d = weekView->date(); |
322 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { | 322 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { |
323 | d = weekLstView->date(); | 323 | d = weekLstView->date(); |
324 | } else if ( monthView && views->visibleWidget() == monthView ) { | 324 | } else if ( monthView && views->visibleWidget() == monthView ) { |
325 | d = monthView->selectedDate(); | 325 | d = monthView->selectedDate(); |
326 | } | 326 | } |
327 | 327 | ||
328 | return d; | 328 | return d; |
329 | } | 329 | } |
330 | 330 | ||
331 | void DateBook::view(int v, const QDate &d) { | 331 | void DateBook::view(int v, const QDate &d) { |
332 | if (v==DAY) { | 332 | if (v==DAY) { |
333 | initDay(); | 333 | initDay(); |
334 | dayAction->setOn( TRUE ); | 334 | dayAction->setOn( TRUE ); |
335 | dayView->setDate( d ); | 335 | dayView->setDate( d ); |
336 | views->raiseWidget( dayView ); | 336 | views->raiseWidget( dayView ); |
337 | dayView->redraw(); | 337 | dayView->redraw(); |
338 | } else if (v==WEEK) { | 338 | } else if (v==WEEK) { |
339 | initWeek(); | 339 | initWeek(); |
340 | weekAction->setOn( TRUE ); | 340 | weekAction->setOn( TRUE ); |
341 | weekView->setDate( d ); | 341 | weekView->setDate( d ); |
342 | views->raiseWidget( weekView ); | 342 | views->raiseWidget( weekView ); |
343 | weekView->redraw(); | 343 | weekView->redraw(); |
344 | } else if (v==WEEKLST) { | 344 | } else if (v==WEEKLST) { |
345 | initWeekLst(); | 345 | initWeekLst(); |
346 | weekLstAction->setOn( TRUE ); | 346 | weekLstAction->setOn( TRUE ); |
347 | weekLstView->setDate(d); | 347 | weekLstView->setDate(d); |
348 | views->raiseWidget( weekLstView ); | 348 | views->raiseWidget( weekLstView ); |
349 | weekLstView->redraw(); | 349 | weekLstView->redraw(); |
350 | } else if (v==MONTH) { | 350 | } else if (v==MONTH) { |
351 | initMonth(); | 351 | initMonth(); |
352 | monthAction->setOn( TRUE ); | 352 | monthAction->setOn( TRUE ); |
353 | monthView->setDate( d.year(), d.month(), d.day() ); | 353 | monthView->setDate( d.year(), d.month(), d.day() ); |
354 | views->raiseWidget( monthView ); | 354 | views->raiseWidget( monthView ); |
355 | monthView->redraw(); | 355 | monthView->redraw(); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | 358 | ||
359 | void DateBook::viewDefault(const QDate &d) { | 359 | void DateBook::viewDefault(const QDate &d) { |
360 | /* | 360 | /* |
361 | Config config("DateBook"); | 361 | Config config("DateBook"); |
362 | config.setGroup("Main"); | 362 | config.setGroup("Main"); |
363 | int current=config.readNumEntry("defaultview", DAY); | 363 | int current=config.readNumEntry("defaultview", DAY); |
364 | 364 | ||
365 | view(current,d); | 365 | view(current,d); |
366 | */ | 366 | */ |
367 | view(defaultView,d); | 367 | view(defaultView,d); |
368 | } | 368 | } |
369 | 369 | ||
370 | void DateBook::viewDay() { | 370 | void DateBook::viewDay() { |
371 | view(DAY,currentDate()); | 371 | view(DAY,currentDate()); |
372 | } | 372 | } |
373 | 373 | ||
374 | void DateBook::viewWeek() { | 374 | void DateBook::viewWeek() { |
375 | view(WEEK,currentDate()); | 375 | view(WEEK,currentDate()); |
376 | } | 376 | } |
377 | 377 | ||
378 | void DateBook::viewWeekLst() { | 378 | void DateBook::viewWeekLst() { |
379 | view(WEEKLST,currentDate()); | 379 | view(WEEKLST,currentDate()); |
380 | } | 380 | } |
381 | 381 | ||
382 | void DateBook::viewMonth() { | 382 | void DateBook::viewMonth() { |
383 | view(MONTH,currentDate()); | 383 | view(MONTH,currentDate()); |
384 | } | 384 | } |
385 | 385 | ||
386 | void DateBook::insertEvent( const Event &e ) | ||
387 | { | ||
388 | qWarning("Adding Event!"); | ||
389 | db->addEvent(e); | ||
390 | emit newEvent(); | ||
391 | } | ||
392 | |||
386 | void DateBook::duplicateEvent( const Event &e ) | 393 | void DateBook::duplicateEvent( const Event &e ) |
387 | { | 394 | { |
388 | qWarning("Hmmm..."); | 395 | qWarning("Hmmm..."); |
389 | // Alot of code duplication, as this is almost like editEvent(); | 396 | // Alot of code duplication, as this is almost like editEvent(); |
390 | if (syncing) { | 397 | if (syncing) { |
391 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 398 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
392 | return; | 399 | return; |
393 | } | 400 | } |
394 | 401 | ||
395 | Event dupevent(e);// Make a duplicate. | 402 | Event dupevent(e);// Make a duplicate. |
396 | 403 | ||
397 | // workaround added for text input. | 404 | // workaround added for text input. |
398 | QDialog editDlg( this, 0, TRUE ); | 405 | QDialog editDlg( this, 0, TRUE ); |
399 | DateEntry *entry; | 406 | DateEntry *entry; |
400 | editDlg.setCaption( tr("Duplicate Event") ); | 407 | editDlg.setCaption( tr("Duplicate Event") ); |
401 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 408 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
402 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 409 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
403 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 410 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
404 | // KLUDGE!!! | 411 | // KLUDGE!!! |
405 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 412 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
406 | vb->addWidget( sv ); | 413 | vb->addWidget( sv ); |
407 | entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); | 414 | entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); |
408 | entry->timezone->setEnabled( FALSE ); | 415 | entry->timezone->setEnabled( FALSE ); |
409 | sv->addChild( entry ); | 416 | sv->addChild( entry ); |
410 | 417 | ||
411 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 418 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
412 | editDlg.showMaximized(); | 419 | editDlg.showMaximized(); |
413 | #endif | 420 | #endif |
414 | while (editDlg.exec() ) { | 421 | while (editDlg.exec() ) { |
415 | Event newEv = entry->event(); | 422 | Event newEv = entry->event(); |
416 | QString error = checkEvent(newEv); | 423 | QString error = checkEvent(newEv); |
417 | if (!error.isNull()) { | 424 | if (!error.isNull()) { |
418 | if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) | 425 | if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) |
419 | continue; | 426 | continue; |
420 | } | 427 | } |
421 | db->addEvent(newEv); | 428 | db->addEvent(newEv); |
422 | emit newEvent(); | 429 | emit newEvent(); |
423 | break; | 430 | break; |
424 | } | 431 | } |
425 | } | 432 | } |
426 | 433 | ||
427 | void DateBook::editEvent( const Event &e ) | 434 | void DateBook::editEvent( const Event &e ) |
428 | { | 435 | { |
429 | if (syncing) { | 436 | if (syncing) { |
430 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 437 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
431 | return; | 438 | return; |
432 | } | 439 | } |
433 | 440 | ||
434 | // workaround added for text input. | 441 | // workaround added for text input. |
435 | QDialog editDlg( this, 0, TRUE ); | 442 | QDialog editDlg( this, 0, TRUE ); |
436 | DateEntry *entry; | 443 | DateEntry *entry; |
437 | editDlg.setCaption( tr("Edit Event") ); | 444 | editDlg.setCaption( tr("Edit Event") ); |
438 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 445 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
439 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 446 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
440 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 447 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
441 | // KLUDGE!!! | 448 | // KLUDGE!!! |
442 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 449 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
443 | vb->addWidget( sv ); | 450 | vb->addWidget( sv ); |
444 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); | 451 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); |
445 | entry->timezone->setEnabled( FALSE ); | 452 | entry->timezone->setEnabled( FALSE ); |
446 | sv->addChild( entry ); | 453 | sv->addChild( entry ); |
447 | 454 | ||
448 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 455 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
449 | editDlg.showMaximized(); | 456 | editDlg.showMaximized(); |
450 | #endif | 457 | #endif |
451 | while (editDlg.exec() ) { | 458 | while (editDlg.exec() ) { |
452 | Event newEv = entry->event(); | 459 | Event newEv = entry->event(); |
453 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) | 460 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) |
454 | break; | 461 | break; |
455 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid | 462 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid |
456 | QString error = checkEvent(newEv); | 463 | QString error = checkEvent(newEv); |
457 | if (!error.isNull()) { | 464 | if (!error.isNull()) { |
458 | if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue; | 465 | if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue; |
459 | } | 466 | } |
460 | db->editEvent(e, newEv); | 467 | db->editEvent(e, newEv); |
461 | emit newEvent(); | 468 | emit newEvent(); |
462 | break; | 469 | break; |
463 | } | 470 | } |
464 | } | 471 | } |
465 | 472 | ||
466 | void DateBook::removeEvent( const Event &e ) | 473 | void DateBook::removeEvent( const Event &e ) |
467 | { | 474 | { |
468 | if (syncing) { | 475 | if (syncing) { |
469 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); | 476 | QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); |
470 | return; | 477 | return; |
471 | } | 478 | } |
472 | 479 | ||
473 | QString strName = e.description(); | 480 | QString strName = e.description(); |
474 | 481 | ||
475 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) | 482 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) |
476 | return; | 483 | return; |
477 | 484 | ||
478 | db->removeEvent( e ); | 485 | db->removeEvent( e ); |
479 | if ( views->visibleWidget() == dayView && dayView ) | 486 | if ( views->visibleWidget() == dayView && dayView ) |
480 | dayView->redraw(); | 487 | dayView->redraw(); |
481 | } | 488 | } |
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h index 5216770..3f57d4a 100644 --- a/core/pim/datebook/datebook.h +++ b/core/pim/datebook/datebook.h | |||
@@ -1,135 +1,136 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef DATEBOOK_H | 20 | #ifndef DATEBOOK_H |
21 | #define DATEBOOK_H | 21 | #define DATEBOOK_H |
22 | 22 | ||
23 | #include <qpe/datebookdb.h> | 23 | #include <qpe/datebookdb.h> |
24 | 24 | ||
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | 26 | ||
27 | enum { DAY=1,WEEK,WEEKLST,MONTH };// defaultView values | 27 | enum { DAY=1,WEEK,WEEKLST,MONTH };// defaultView values |
28 | enum { NONE=0,NORMAL,EXTENDED };// WeekLstView's modes. | 28 | enum { NONE=0,NORMAL,EXTENDED };// WeekLstView's modes. |
29 | 29 | ||
30 | class QAction; | 30 | class QAction; |
31 | class QWidgetStack; | 31 | class QWidgetStack; |
32 | class DateBookDay; | 32 | class DateBookDay; |
33 | class DateBookWeek; | 33 | class DateBookWeek; |
34 | class DateBookWeekLst; | 34 | class DateBookWeekLst; |
35 | class DateBookMonth; | 35 | class DateBookMonth; |
36 | class Event; | 36 | class Event; |
37 | class QDate; | 37 | class QDate; |
38 | class Ir; | 38 | class Ir; |
39 | 39 | ||
40 | class DateBookDBHack : public DateBookDB { | 40 | class DateBookDBHack : public DateBookDB { |
41 | public: | 41 | public: |
42 | Event eventByUID(int id); | 42 | Event eventByUID(int id); |
43 | }; | 43 | }; |
44 | 44 | ||
45 | class DateBook : public QMainWindow | 45 | class DateBook : public QMainWindow |
46 | { | 46 | { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | 48 | ||
49 | public: | 49 | public: |
50 | DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 50 | DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
51 | ~DateBook(); | 51 | ~DateBook(); |
52 | 52 | ||
53 | signals: | 53 | signals: |
54 | void newEvent(); | 54 | void newEvent(); |
55 | void signalNotFound(); | 55 | void signalNotFound(); |
56 | void signalWrapAround(); | 56 | void signalWrapAround(); |
57 | 57 | ||
58 | protected: | 58 | protected: |
59 | QDate currentDate(); | 59 | QDate currentDate(); |
60 | void timerEvent( QTimerEvent *e ); | 60 | void timerEvent( QTimerEvent *e ); |
61 | void closeEvent( QCloseEvent *e ); | 61 | void closeEvent( QCloseEvent *e ); |
62 | 62 | ||
63 | void view(int v, const QDate &d); | 63 | void view(int v, const QDate &d); |
64 | 64 | ||
65 | public slots: | 65 | public slots: |
66 | void flush(); | 66 | void flush(); |
67 | void reload(); | 67 | void reload(); |
68 | 68 | ||
69 | private slots: | 69 | private slots: |
70 | void fileNew(); | 70 | void fileNew(); |
71 | void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); | 71 | void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0); |
72 | void slotSettings(); | 72 | void slotSettings(); |
73 | void slotToday();// view today | 73 | void slotToday();// view today |
74 | void changeClock( bool newClock ); | 74 | void changeClock( bool newClock ); |
75 | void changeWeek( bool newDay ); | 75 | void changeWeek( bool newDay ); |
76 | void appMessage(const QCString& msg, const QByteArray& data); | 76 | void appMessage(const QCString& msg, const QByteArray& data); |
77 | // handle key events in the day view... | 77 | // handle key events in the day view... |
78 | void slotNewEventFromKey( const QString &str ); | 78 | void slotNewEventFromKey( const QString &str ); |
79 | void slotFind(); | 79 | void slotFind(); |
80 | void slotDoFind( const QString &, const QDate &, bool, bool, int ); | 80 | void slotDoFind( const QString &, const QDate &, bool, bool, int ); |
81 | 81 | ||
82 | void viewDefault(const QDate &d); | 82 | void viewDefault(const QDate &d); |
83 | 83 | ||
84 | void viewDay(); | 84 | void viewDay(); |
85 | void viewWeek(); | 85 | void viewWeek(); |
86 | void viewWeekLst(); | 86 | void viewWeekLst(); |
87 | void viewMonth(); | 87 | void viewMonth(); |
88 | 88 | ||
89 | void showDay( int y, int m, int d ); | 89 | void showDay( int y, int m, int d ); |
90 | 90 | ||
91 | void editEvent( const Event &e ); | 91 | void insertEvent( const Event &e ); |
92 | void editEvent( const Event &e ); | ||
92 | void duplicateEvent( const Event &e ); | 93 | void duplicateEvent( const Event &e ); |
93 | void removeEvent( const Event &e ); | 94 | void removeEvent( const Event &e ); |
94 | 95 | ||
95 | void receive( const QCString &msg, const QByteArray &data ); | 96 | void receive( const QCString &msg, const QByteArray &data ); |
96 | void setDocument( const QString & ); | 97 | void setDocument( const QString & ); |
97 | void beamEvent( const Event &e ); | 98 | void beamEvent( const Event &e ); |
98 | void beamDone( Ir *ir ); | 99 | void beamDone( Ir *ir ); |
99 | 100 | ||
100 | private: | 101 | private: |
101 | void addEvent( const Event &e ); | 102 | void addEvent( const Event &e ); |
102 | void initDay(); | 103 | void initDay(); |
103 | void initWeek(); | 104 | void initWeek(); |
104 | void initWeekLst(); | 105 | void initWeekLst(); |
105 | void initMonth(); | 106 | void initMonth(); |
106 | void loadSettings(); | 107 | void loadSettings(); |
107 | void saveSettings(); | 108 | void saveSettings(); |
108 | 109 | ||
109 | private: | 110 | private: |
110 | DateBookDBHack *db; | 111 | DateBookDBHack *db; |
111 | QWidgetStack *views; | 112 | QWidgetStack *views; |
112 | DateBookDay *dayView; | 113 | DateBookDay *dayView; |
113 | DateBookWeek *weekView; | 114 | DateBookWeek *weekView; |
114 | DateBookMonth *monthView; | 115 | DateBookMonth *monthView; |
115 | DateBookWeekLst *weekLstView; | 116 | DateBookWeekLst *weekLstView; |
116 | QAction *dayAction, *weekAction, *weekLstAction, *monthAction; | 117 | QAction *dayAction, *weekAction, *weekLstAction, *monthAction; |
117 | int weeklistviewconfig; | 118 | int weeklistviewconfig; |
118 | bool aPreset; // have everything set to alarm? | 119 | bool aPreset; // have everything set to alarm? |
119 | int presetTime; // the standard time for the alarm | 120 | int presetTime; // the standard time for the alarm |
120 | int startTime; | 121 | int startTime; |
121 | int rowStyle; | 122 | int rowStyle; |
122 | int defaultView; | 123 | int defaultView; |
123 | bool bJumpToCurTime; //should jump to current time in dayview? | 124 | bool bJumpToCurTime; //should jump to current time in dayview? |
124 | bool ampm; | 125 | bool ampm; |
125 | bool onMonday; | 126 | bool onMonday; |
126 | 127 | ||
127 | bool syncing; | 128 | bool syncing; |
128 | bool inSearch; | 129 | bool inSearch; |
129 | 130 | ||
130 | int alarmCounter; | 131 | int alarmCounter; |
131 | 132 | ||
132 | QString checkEvent(const Event &); | 133 | QString checkEvent(const Event &); |
133 | }; | 134 | }; |
134 | 135 | ||
135 | #endif | 136 | #endif |
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index db4c2fd..0a40ea9 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -1,802 +1,811 @@ | |||
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 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | 21 | ||
22 | #include "datebookday.h" | 22 | #include "datebookday.h" |
23 | #include "datebookdayheaderimpl.h" | 23 | #include "datebookdayheaderimpl.h" |
24 | 24 | ||
25 | #include <qpe/datebookdb.h> | 25 | #include <qpe/datebookdb.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/event.h> | 27 | #include <qpe/event.h> |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #include <qpe/timestring.h> | 29 | #include <qpe/timestring.h> |
30 | #include <qpe/qpedebug.h> | 30 | #include <qpe/qpedebug.h> |
31 | #include <qpe/ir.h> | 31 | #include <qpe/ir.h> |
32 | 32 | ||
33 | #include <qheader.h> | 33 | #include <qheader.h> |
34 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qsimplerichtext.h> | 36 | #include <qsimplerichtext.h> |
37 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
38 | #include <qtextcodec.h> | 38 | #include <qtextcodec.h> |
39 | #include <qpalette.h> | 39 | #include <qpalette.h> |
40 | 40 | ||
41 | #include <qlineedit.h> | ||
42 | |||
41 | #include <qtimer.h> | 43 | #include <qtimer.h> |
42 | 44 | ||
43 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, | 45 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name ) |
44 | const char *name ) | 46 | : QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() ) |
45 | : QTable( 24, 1, parent, name ), | 47 | { |
46 | ampm( whichClock ) | 48 | enableClipper(TRUE); |
47 | { | 49 | setTopMargin( 0 ); |
48 | enableClipper(TRUE); | 50 | horizontalHeader()->hide(); |
49 | setTopMargin( 0 ); | 51 | setLeftMargin(38); |
50 | horizontalHeader()->hide(); | 52 | setColumnStretchable( 0, TRUE ); |
51 | setLeftMargin(38); | 53 | setHScrollBarMode( QScrollView::AlwaysOff ); |
52 | setColumnStretchable( 0, TRUE ); | 54 | verticalHeader()->setPalette(white); |
53 | setHScrollBarMode( QScrollView::AlwaysOff ); | 55 | verticalHeader()->setResizeEnabled(FALSE); |
54 | verticalHeader()->setPalette(white); | 56 | setSelectionMode( Single ); |
55 | verticalHeader()->setResizeEnabled(FALSE); | 57 | |
56 | setSelectionMode( Single ); | 58 | // get rid of being able to edit things... |
57 | 59 | QTableItem *tmp; | |
58 | // get rid of being able to edit things... | 60 | int row; |
59 | QTableItem *tmp; | 61 | for ( row = 0; row < numRows(); row++ ) { |
60 | int row; | 62 | tmp = new QTableItem( this, QTableItem::Never, QString::null); |
61 | for ( row = 0; row < numRows(); row++ ) { | 63 | setItem( row, 0, tmp ); |
62 | tmp = new QTableItem( this, QTableItem::Never, QString::null); | 64 | //setRowHeight( row, 40); |
63 | setItem( row, 0, tmp ); | 65 | } |
64 | //setRowHeight( row, 40); | 66 | |
65 | } | 67 | initHeader(); |
66 | initHeader(); | 68 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool)) ); |
67 | QObject::connect( qApp, SIGNAL(clockChanged(bool)), | ||
68 | this, SLOT(slotChangeClock(bool)) ); | ||
69 | } | 69 | } |
70 | 70 | ||
71 | void DateBookDayView::initHeader() | 71 | void DateBookDayView::initHeader() |
72 | { | 72 | { |
73 | QString strTmp; | 73 | QString strTmp; |
74 | for ( int i = 0; i < 24; ++i ) { | 74 | for ( int i = 0; i < 24; ++i ) { |
75 | if ( ampm ) { | 75 | if ( ampm ) { |
76 | if ( i == 0 ) | 76 | if ( i == 0 ) |
77 | strTmp = QString::number(12) + ":00"; | 77 | strTmp = QString::number(12) + ":00"; |
78 | else if ( i == 12 ) | 78 | else if ( i == 12 ) |
79 | strTmp = QString::number(12) + tr(":00p"); | 79 | strTmp = QString::number(12) + tr(":00p"); |
80 | else if ( i > 12 ) | 80 | else if ( i > 12 ) |
81 | strTmp = QString::number( i - 12 ) + tr(":00p"); | 81 | strTmp = QString::number( i - 12 ) + tr(":00p"); |
82 | else | 82 | else |
83 | strTmp = QString::number(i) + ":00"; | 83 | strTmp = QString::number(i) + ":00"; |
84 | } else { | 84 | } else { |
85 | if ( i < 10 ) | 85 | if ( i < 10 ) |
86 | strTmp = "0" + QString::number(i) + ":00"; | 86 | strTmp = "0" + QString::number(i) + ":00"; |
87 | else | 87 | else |
88 | strTmp = QString::number(i) + ":00"; | 88 | strTmp = QString::number(i) + ":00"; |
89 | } | ||
90 | strTmp = strTmp.rightJustify( 6, ' ' ); | ||
91 | verticalHeader()->setLabel( i, strTmp ); | ||
92 | setRowStretchable( i, FALSE ); | ||
89 | } | 93 | } |
90 | strTmp = strTmp.rightJustify( 6, ' ' ); | 94 | } |
91 | verticalHeader()->setLabel( i, strTmp ); | 95 | |
92 | setRowStretchable( i, FALSE ); | 96 | void DateBookDayView::slotDateChanged( int y, int m, int d ) |
93 | } | 97 | { |
98 | currDate.setYMD(y,m,d); | ||
94 | } | 99 | } |
95 | 100 | ||
96 | void DateBookDayView::slotChangeClock( bool newClock ) | 101 | void DateBookDayView::slotChangeClock( bool newClock ) |
97 | { | 102 | { |
98 | ampm = newClock; | 103 | ampm = newClock; |
99 | initHeader(); | 104 | initHeader(); |
100 | } | 105 | } |
101 | 106 | ||
102 | bool DateBookDayView::whichClock() const | 107 | bool DateBookDayView::whichClock() const |
103 | { | 108 | { |
104 | return ampm; | 109 | return ampm; |
105 | } | 110 | } |
106 | 111 | ||
107 | void DateBookDayView::moveUp() | 112 | void DateBookDayView::moveUp() |
108 | { | 113 | { |
109 | scrollBy(0, -20); | 114 | scrollBy(0, -20); |
110 | } | 115 | } |
111 | 116 | ||
112 | void DateBookDayView::moveDown() | 117 | void DateBookDayView::moveDown() |
113 | { | 118 | { |
114 | scrollBy(0, 20); | 119 | scrollBy(0, 20); |
115 | } | 120 | } |
116 | 121 | ||
117 | void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) | 122 | void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) |
118 | { | 123 | { |
119 | int w = cr.width(); | 124 | int w = cr.width(); |
120 | int h = cr.height(); | 125 | int h = cr.height(); |
121 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); | 126 | p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); |
122 | if ( showGrid() ) { | 127 | if ( showGrid() ) { |
123 | // Draw our lines | 128 | // Draw our lines |
124 | int x2 = w - 1; | 129 | int x2 = w - 1; |
125 | int y2 = h - 1; | 130 | int y2 = h - 1; |
126 | QPen pen( p->pen() ); | 131 | QPen pen( p->pen() ); |
127 | p->setPen( colorGroup().dark() ); | 132 | p->setPen( colorGroup().dark() ); |
128 | p->drawLine( x2, 0, x2, y2 ); | 133 | p->drawLine( x2, 0, x2, y2 ); |
129 | p->drawLine( 0, y2, x2, y2 ); | 134 | p->drawLine( 0, y2, x2, y2 ); |
130 | 135 | ||
131 | p->setPen( colorGroup().midlight() ); | 136 | p->setPen( colorGroup().midlight() ); |
132 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); | 137 | p->drawLine( 0, y2 - h/2, x2, y2 - h/2); |
133 | 138 | ||
134 | p->setPen( pen ); | 139 | p->setPen( pen ); |
135 | } | 140 | } |
136 | } | 141 | } |
137 | 142 | ||
138 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) | 143 | void DateBookDayView::paintFocus( QPainter *, const QRect & ) |
139 | { | 144 | { |
140 | } | 145 | } |
141 | 146 | ||
142 | |||
143 | void DateBookDayView::resizeEvent( QResizeEvent *e ) | 147 | void DateBookDayView::resizeEvent( QResizeEvent *e ) |
144 | { | 148 | { |
145 | QTable::resizeEvent( e ); | 149 | QTable::resizeEvent( e ); |
146 | columnWidthChanged( 0 ); | 150 | columnWidthChanged( 0 ); |
147 | emit sigColWidthChanged(); | 151 | emit sigColWidthChanged(); |
148 | } | 152 | } |
149 | 153 | ||
150 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) | 154 | void DateBookDayView::keyPressEvent( QKeyEvent *e ) |
151 | { | 155 | { |
152 | QString txt = e->text(); | 156 | QString txt = e->text(); |
153 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { | 157 | if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { |
154 | // we this is some sort of thing we know about... | 158 | // we this is some sort of thing we know about... |
155 | e->accept(); | 159 | e->accept(); |
156 | emit sigCapturedKey( txt ); | 160 | emit sigCapturedKey( txt ); |
157 | } else { | 161 | } else { |
158 | // I don't know what this key is, do you? | 162 | // I don't know what this key is, do you? |
159 | e->ignore(); | 163 | e->ignore(); |
160 | } | 164 | } |
161 | } | 165 | } |
162 | 166 | ||
163 | void DateBookDayView::setRowStyle( int style ) | 167 | void DateBookDayView::setRowStyle( int style ) |
164 | { | 168 | { |
165 | if (style<0) style = 0; | 169 | if (style<0) style = 0; |
166 | 170 | ||
167 | for (int i=0; i<numRows(); i++) | 171 | for (int i=0; i<numRows(); i++) |
168 | setRowHeight(i, style*10+20); | 172 | setRowHeight(i, style*10+20); |
169 | } | 173 | } |
170 | 174 | ||
175 | void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent *e ) | ||
176 | { | ||
177 | int y=e->y(); | ||
178 | int diff=y%(this->rowHeight(0)); | ||
179 | int hour=y/this->rowHeight(0); | ||
180 | quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(hour,0,0,0)),QDateTime(currDate,QTime(hour,59,0,0)),this->viewport(),"quickedit"); | ||
181 | quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); | ||
182 | this->moveChild(quickLineEdit,0,y-diff); | ||
183 | quickLineEdit->setFocus(); | ||
184 | quickLineEdit->show(); | ||
185 | } | ||
186 | |||
171 | //=========================================================================== | 187 | //=========================================================================== |
172 | 188 | ||
173 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, | 189 | DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0) : QLineEdit(parent,name) |
174 | DateBookDB *newDb, QWidget *parent, | ||
175 | const char *name ) | ||
176 | : QVBox( parent, name ), | ||
177 | currDate( QDate::currentDate() ), | ||
178 | db( newDb ), | ||
179 | startTime( 0 ) | ||
180 | { | 190 | { |
181 | widgetList.setAutoDelete( true ); | 191 | active=1; |
182 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); | 192 | quickEvent.setStart(start); |
183 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); | 193 | quickEvent.setEnd(end); |
184 | view = new DateBookDayView( ampm, this, "day view" ); | 194 | connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); |
195 | } | ||
185 | 196 | ||
186 | connect( header, SIGNAL( dateChanged( int, int, int ) ), | 197 | void DateBookDayViewQuickLineEdit::slotReturnPressed() |
187 | this, SLOT( dateChanged( int, int, int ) ) ); | 198 | { |
188 | connect( view, SIGNAL( sigColWidthChanged() ), | 199 | if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. |
189 | this, SLOT( slotColWidthChanged() ) ); | 200 | quickEvent.setDescription(this->text()); |
190 | connect( qApp, SIGNAL(weekChanged(bool)), | 201 | connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &))); |
191 | this, SLOT(slotWeekChanged(bool)) ); | 202 | emit(insertEvent(quickEvent)); |
192 | connect( view, SIGNAL(sigCapturedKey(const QString &)), | 203 | active=0; |
193 | this, SIGNAL(sigNewEvent(const QString&)) ); | 204 | } |
205 | this->close(true);// Close and also delete this widget | ||
206 | } | ||
194 | 207 | ||
195 | QTimer *timer = new QTimer( this ); | 208 | void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent * e ) |
209 | { | ||
210 | slotReturnPressed(); // Reuse code to add event and close this widget. | ||
211 | } | ||
196 | 212 | ||
197 | connect( timer, SIGNAL(timeout()), | 213 | //=========================================================================== |
198 | this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors | ||
199 | timer->start( 1000*60*5, FALSE ); //update every 5min | ||
200 | 214 | ||
201 | selectedWidget = 0; | 215 | DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) |
216 | : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) | ||
217 | { | ||
218 | widgetList.setAutoDelete( true ); | ||
219 | header = new DateBookDayHeader( startOnMonday, this, "day header" ); | ||
220 | header->setDate( currDate.year(), currDate.month(), currDate.day() ); | ||
221 | view = new DateBookDayView( ampm, this, "day view" ); | ||
222 | |||
223 | connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); | ||
224 | connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) ); | ||
225 | connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); | ||
226 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); | ||
227 | connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) ); | ||
228 | |||
229 | QTimer *timer = new QTimer( this ); | ||
230 | |||
231 | connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors | ||
232 | timer->start( 1000*60*5, FALSE ); //update every 5min | ||
202 | 233 | ||
203 | timeMarker = new DateBookDayTimeMarker( this ); | 234 | selectedWidget = 0; |
204 | timeMarker->setTime( QTime::currentTime() ); | 235 | |
205 | rowStyle = -1; // initialize with bogus values | 236 | timeMarker = new DateBookDayTimeMarker( this ); |
237 | timeMarker->setTime( QTime::currentTime() ); | ||
238 | rowStyle = -1; // initialize with bogus values | ||
206 | } | 239 | } |
207 | 240 | ||
208 | void DateBookDay::setJumpToCurTime( bool bJump ) | 241 | void DateBookDay::setJumpToCurTime( bool bJump ) |
209 | { | 242 | { |
210 | jumpToCurTime = bJump; | 243 | jumpToCurTime = bJump; |
211 | } | 244 | } |
212 | 245 | ||
213 | void DateBookDay::setRowStyle( int style ) | 246 | void DateBookDay::setRowStyle( int style ) |
214 | { | 247 | { |
215 | if (rowStyle != style) view->setRowStyle( style ); | 248 | if (rowStyle != style) view->setRowStyle( style ); |
216 | rowStyle = style; | 249 | rowStyle = style; |
217 | } | 250 | } |
218 | 251 | ||
219 | void DateBookDay::updateView( void ) | 252 | void DateBookDay::updateView( void ) |
220 | { | 253 | { |
221 | timeMarker->setTime( QTime::currentTime() ); | 254 | timeMarker->setTime( QTime::currentTime() ); |
222 | //need to find a way to update all DateBookDayWidgets | 255 | //need to find a way to update all DateBookDayWidgets |
223 | } | 256 | } |
224 | 257 | ||
225 | void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) | 258 | void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) |
226 | { | 259 | { |
227 | selectedWidget = w; | 260 | selectedWidget = w; |
228 | } | 261 | } |
229 | 262 | ||
230 | DateBookDayWidget * DateBookDay::getSelectedWidget( void ) | 263 | DateBookDayWidget * DateBookDay::getSelectedWidget( void ) |
231 | { | 264 | { |
232 | return selectedWidget; | 265 | return selectedWidget; |
233 | } | 266 | } |
234 | 267 | ||
235 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) | 268 | void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) |
236 | { | 269 | { |
237 | start.setDate( currDate ); | 270 | start.setDate( currDate ); |
238 | end.setDate( currDate ); | 271 | end.setDate( currDate ); |
239 | 272 | ||
240 | int sh=99,eh=-1; | 273 | int sh=99,eh=-1; |
241 | 274 | ||
242 | int n = dayView()->numSelections(); | 275 | int n = dayView()->numSelections(); |
243 | 276 | ||
244 | for (int i=0; i<n; i++) { | 277 | for (int i=0; i<n; i++) { |
245 | QTableSelection sel = dayView()->selection( i ); | 278 | QTableSelection sel = dayView()->selection( i ); |
246 | sh = QMIN(sh,sel.topRow()); | 279 | sh = QMIN(sh,sel.topRow()); |
247 | eh = QMAX(sh,sel.bottomRow()+1); | 280 | eh = QMAX(sh,sel.bottomRow()+1); |
248 | } | 281 | } |
249 | if (sh > 23 || eh < 1) { | 282 | |
250 | sh=8; | 283 | if (sh > 23 || eh < 1) { |
251 | eh=9; | 284 | sh=8; |
252 | } | 285 | eh=9; |
286 | } | ||
253 | 287 | ||
254 | start.setTime( QTime( sh, 0, 0 ) ); | 288 | start.setTime( QTime( sh, 0, 0 ) ); |
255 | end.setTime( QTime( eh, 0, 0 ) ); | 289 | end.setTime( QTime( eh, 0, 0 ) ); |
256 | } | 290 | } |
257 | 291 | ||
258 | void DateBookDay::setDate( int y, int m, int d ) | 292 | void DateBookDay::setDate( int y, int m, int d ) |
259 | { | 293 | { |
260 | header->setDate( y, m, d ); | 294 | header->setDate( y, m, d ); |
261 | 295 | selectedWidget = 0; | |
262 | selectedWidget = 0; | ||
263 | } | 296 | } |
264 | 297 | ||
265 | void DateBookDay::setDate( QDate d) | 298 | void DateBookDay::setDate( QDate d) |
266 | { | 299 | { |
267 | header->setDate( d.year(), d.month(), d.day() ); | 300 | header->setDate( d.year(), d.month(), d.day() ); |
268 | 301 | selectedWidget = 0; | |
269 | selectedWidget = 0; | ||
270 | } | 302 | } |
271 | 303 | ||
272 | void DateBookDay::dateChanged( int y, int m, int d ) | 304 | void DateBookDay::dateChanged( int y, int m, int d ) |
273 | { | 305 | { |
274 | QDate date( y, m, d ); | 306 | QDate date( y, m, d ); |
275 | if ( currDate == date ) | 307 | if ( currDate == date ) |
276 | return; | 308 | return; |
277 | currDate.setYMD( y, m, d ); | 309 | currDate.setYMD( y, m, d ); |
278 | relayoutPage(); | 310 | relayoutPage(); |
279 | dayView()->clearSelection(); | 311 | dayView()->clearSelection(); |
280 | QTableSelection ts; | 312 | QTableSelection ts; |
281 | |||
282 | if (jumpToCurTime && this->date() == QDate::currentDate()) | ||
283 | { | ||
284 | ts.init( QTime::currentTime().hour(), 0); | ||
285 | ts.expandTo( QTime::currentTime().hour(), 0); | ||
286 | } else | ||
287 | { | ||
288 | ts.init( startTime, 0 ); | ||
289 | ts.expandTo( startTime, 0 ); | ||
290 | } | ||
291 | |||
292 | dayView()->addSelection( ts ); | ||
293 | 313 | ||
294 | selectedWidget = 0; | 314 | if (jumpToCurTime && this->date() == QDate::currentDate()) |
315 | { | ||
316 | ts.init( QTime::currentTime().hour(), 0); | ||
317 | ts.expandTo( QTime::currentTime().hour(), 0); | ||
318 | } else { | ||
319 | ts.init( startTime, 0 ); | ||
320 | ts.expandTo( startTime, 0 ); | ||
321 | } | ||
295 | 322 | ||
323 | dayView()->addSelection( ts ); | ||
324 | selectedWidget = 0; | ||
296 | } | 325 | } |
297 | 326 | ||
298 | void DateBookDay::redraw() | 327 | void DateBookDay::redraw() |
299 | { | 328 | { |
300 | if ( isUpdatesEnabled() ) | 329 | if ( isUpdatesEnabled() ) |
301 | relayoutPage(); | 330 | relayoutPage(); |
302 | } | 331 | } |
303 | 332 | ||
304 | void DateBookDay::getEvents() | 333 | void DateBookDay::getEvents() |
305 | { | 334 | { |
306 | widgetList.clear(); | 335 | widgetList.clear(); |
307 | 336 | ||
308 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); | 337 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); |
309 | QValueListIterator<EffectiveEvent> it; | 338 | QValueListIterator<EffectiveEvent> it; |
310 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { | 339 | for ( it = eventList.begin(); it != eventList.end(); ++it ) { |
311 | EffectiveEvent ev=*it; | 340 | EffectiveEvent ev=*it; |
312 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. | 341 | if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. |
313 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); | 342 | DateBookDayWidget* w = new DateBookDayWidget( *it, this ); |
314 | connect( w, SIGNAL( deleteMe( const Event & ) ), | 343 | connect( w, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); |
315 | this, SIGNAL( removeEvent( const Event & ) ) ); | 344 | connect( w, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); |
316 | connect( w, SIGNAL( duplicateMe( const Event & ) ), | 345 | connect( w, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); |
317 | this, SIGNAL( duplicateEvent( const Event & ) ) ); | 346 | connect( w, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); |
318 | connect( w, SIGNAL( editMe( const Event & ) ), | ||
319 | this, SIGNAL( editEvent( const Event & ) ) ); | ||
320 | connect( w, SIGNAL( beamMe( const Event & ) ), | ||
321 | this, SIGNAL( beamEvent( const Event & ) ) ); | ||
322 | widgetList.append( w ); | 347 | widgetList.append( w ); |
323 | } | 348 | } |
324 | } | 349 | } |
325 | |||
326 | } | 350 | } |
327 | 351 | ||
328 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) | 352 | static int place( const DateBookDayWidget *item, bool *used, int maxn ) |
329 | { | 353 | { |
330 | int place = 0; | 354 | int place = 0; |
331 | int start = item->event().start().hour(); | 355 | int start = item->event().start().hour(); |
332 | QTime e = item->event().end(); | 356 | QTime e = item->event().end(); |
333 | int end = e.hour(); | 357 | int end = e.hour(); |
334 | if ( e.minute() < 5 ) | 358 | if ( e.minute() < 5 ) |
335 | end--; | 359 | end--; |
336 | if ( end < start ) | 360 | if ( end < start ) |
337 | end = start; | 361 | end = start; |
338 | while ( place < maxn ) { | 362 | while ( place < maxn ) { |
339 | bool free = TRUE; | 363 | bool free = TRUE; |
340 | int s = start; | 364 | int s = start; |
341 | while( s <= end ) { | 365 | while( s <= end ) { |
342 | if ( used[10*s+place] ) { | 366 | if ( used[10*s+place] ) { |
343 | free = FALSE; | 367 | free = FALSE; |
344 | break; | 368 | break; |
345 | } | 369 | } |
346 | s++; | 370 | s++; |
371 | } | ||
372 | if ( free ) | ||
373 | break; | ||
374 | place++; | ||
347 | } | 375 | } |
348 | if ( free ) break; | 376 | if ( place == maxn ) { |
349 | place++; | 377 | return -1; |
350 | } | 378 | } |
351 | if ( place == maxn ) { | 379 | while( start <= end ) { |
352 | return -1; | 380 | used[10*start+place] = TRUE; |
353 | } | 381 | start++; |
354 | while( start <= end ) { | 382 | } |
355 | used[10*start+place] = TRUE; | 383 | return place; |
356 | start++; | ||
357 | } | ||
358 | return place; | ||
359 | } | 384 | } |
360 | 385 | ||
361 | 386 | ||
362 | void DateBookDay::relayoutPage( bool fromResize ) | 387 | void DateBookDay::relayoutPage( bool fromResize ) |
363 | { | 388 | { |
364 | setUpdatesEnabled( FALSE ); | 389 | setUpdatesEnabled( FALSE ); |
365 | if ( !fromResize ) | 390 | if ( !fromResize ) |
366 | getEvents(); // no need we already have them! | 391 | getEvents(); // no need we already have them! |
367 | 392 | ||
368 | widgetList.sort(); | 393 | widgetList.sort(); |
369 | //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning | 394 | //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning |
370 | //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view | 395 | //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view |
371 | 396 | ||
372 | int wCount = widgetList.count(); | 397 | int wCount = widgetList.count(); |
373 | int wid = view->columnWidth(0)-1; | 398 | int wid = view->columnWidth(0)-1; |
374 | int wd; | 399 | int wd; |
375 | int n = 1; | 400 | int n = 1; |
376 | 401 | ||
377 | QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget | 402 | QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget |
378 | 403 | ||
379 | for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); | 404 | for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); |
380 | 405 | ||
381 | if ( wCount < 20 ) { | 406 | if ( wCount < 20 ) { |
382 | 407 | ||
383 | QArray<QRect> geometries(wCount); | 408 | QArray<QRect> geometries(wCount); |
384 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector | 409 | for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector |
385 | 410 | ||
386 | for ( int i = 0; i < wCount; i++) | 411 | for ( int i = 0; i < wCount; i++) { |
387 | { | 412 | QValueList<int> intersectedWidgets; |
388 | QValueList<int> intersectedWidgets; | 413 | |
389 | 414 | //find all widgets intersecting with widgetList.at(i) | |
390 | //find all widgets intersecting with widgetList.at(i) | 415 | for ( int j = 0; j < wCount; j++) { |
391 | for ( int j = 0; j < wCount; j++) | 416 | if (i != j) |
392 | if (i != j) | 417 | if (geometries[j].intersects(geometries[i])) |
393 | if (geometries[j].intersects(geometries[i])) | 418 | intersectedWidgets.append(j); |
394 | intersectedWidgets.append(j); | 419 | } |
395 | 420 | ||
396 | //for each of these intersecting widgets find out how many widgets are they intersecting with | 421 | //for each of these intersecting widgets find out how many widgets are they intersecting with |
397 | for ( uint j = 0; j < intersectedWidgets.count(); j++) | 422 | for ( uint j = 0; j < intersectedWidgets.count(); j++) |
398 | { | 423 | { |
399 | QArray<int> inter(wCount); | 424 | QArray<int> inter(wCount); |
400 | inter[j]=1; | 425 | inter[j]=1; |
401 | 426 | ||
402 | if (intersectedWidgets[j] != -1) | 427 | if (intersectedWidgets[j] != -1) |
403 | for ( uint k = j; k < intersectedWidgets.count(); k++) | 428 | for ( uint k = j; k < intersectedWidgets.count(); k++) { |
404 | if (j != k && intersectedWidgets[k] != -1) | 429 | if (j != k && intersectedWidgets[k] != -1) |
405 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) | 430 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { |
406 | { | 431 | inter[j]++; |
407 | inter[j]++; | 432 | intersectedWidgets[k] = -1; |
408 | intersectedWidgets[k] = -1; | 433 | } |
409 | } | 434 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; |
410 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; | 435 | } |
436 | } | ||
437 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; | ||
411 | } | 438 | } |
412 | 439 | ||
413 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; | ||
414 | } | ||
415 | |||
416 | |||
417 | for ( int i = 0; i < wCount; i++) { | ||
418 | DateBookDayWidget *w = widgetList.at(i); | ||
419 | QRect geom = w->geometry(); | ||
420 | |||
421 | geom.setX( 0 ); | ||
422 | |||
423 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); | ||
424 | 440 | ||
425 | geom.setWidth( wd ); | 441 | for ( int i = 0; i < wCount; i++) { |
426 | 442 | DateBookDayWidget *w = widgetList.at(i); | |
427 | while ( intersects( w, geom ) ) { | 443 | QRect geom = w->geometry(); |
428 | geom.moveBy( wd + 2 + 1, 0 ); | 444 | geom.setX( 0 ); |
429 | } | 445 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); |
430 | w->setGeometry( geom ); | 446 | geom.setWidth( wd ); |
431 | } | 447 | while ( intersects( w, geom ) ) { |
432 | 448 | geom.moveBy( wd + 2 + 1, 0 ); | |
433 | if (jumpToCurTime && this->date() == QDate::currentDate()) | 449 | } |
434 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 450 | w->setGeometry( geom ); |
435 | else | 451 | } |
436 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | ||
437 | |||
438 | |||
439 | } else { | ||
440 | 452 | ||
453 | if (jumpToCurTime && this->date() == QDate::currentDate()) { | ||
454 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | ||
455 | } else { | ||
456 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | ||
457 | } | ||
458 | } else { | ||
459 | int hours[24]; | ||
460 | memset( hours, 0, 24*sizeof( int ) ); | ||
461 | bool overFlow = FALSE; | ||
462 | for ( int i = 0; i < wCount; i++ ) { | ||
463 | DateBookDayWidget *w = widgetList.at(i); | ||
464 | int start = w->event().start().hour(); | ||
465 | QTime e = w->event().end(); | ||
466 | int end = e.hour(); | ||
467 | if ( e.minute() < 5 ) | ||
468 | end--; | ||
469 | if ( end < start ) | ||
470 | end = start; | ||
471 | while( start <= end ) { | ||
472 | hours[start]++; | ||
473 | if ( hours[start] >= 10 ) | ||
474 | overFlow = TRUE; | ||
475 | ++start; | ||
476 | } | ||
477 | if ( overFlow ) | ||
478 | break; | ||
479 | } | ||
480 | for ( int i = 0; i < 24; i++ ) { | ||
481 | n = QMAX( n, hours[i] ); | ||
482 | } | ||
483 | wid = ( view->columnWidth(0)-1 ) / n; | ||
484 | |||
485 | bool used[24*10]; | ||
486 | memset( used, FALSE, 24*10*sizeof( bool ) ); | ||
487 | |||
488 | for ( int i = 0; i < wCount; i++ ) { | ||
489 | DateBookDayWidget *w = widgetList.at(i); | ||
490 | int xp = place( w, used, n ); | ||
491 | if ( xp != -1 ) { | ||
492 | QRect geom = w->geometry(); | ||
493 | geom.setX( xp*(wid+2) ); | ||
494 | geom.setWidth( wid ); | ||
495 | w->setGeometry( geom ); | ||
496 | } | ||
497 | } | ||
441 | 498 | ||
442 | int hours[24]; | 499 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
443 | memset( hours, 0, 24*sizeof( int ) ); | 500 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
444 | bool overFlow = FALSE; | 501 | } else { |
445 | for ( int i = 0; i < wCount; i++ ) { | 502 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
446 | DateBookDayWidget *w = widgetList.at(i); | 503 | } |
447 | int start = w->event().start().hour(); | ||
448 | QTime e = w->event().end(); | ||
449 | int end = e.hour(); | ||
450 | if ( e.minute() < 5 ) | ||
451 | end--; | ||
452 | if ( end < start ) | ||
453 | end = start; | ||
454 | while( start <= end ) { | ||
455 | hours[start]++; | ||
456 | if ( hours[start] >= 10 ) | ||
457 | overFlow = TRUE; | ||
458 | ++start; | ||
459 | } | ||
460 | if ( overFlow ) | ||
461 | break; | ||
462 | } | ||
463 | for ( int i = 0; i < 24; i++ ) { | ||
464 | n = QMAX( n, hours[i] ); | ||
465 | } | ||
466 | wid = ( view->columnWidth(0)-1 ) / n; | ||
467 | |||
468 | bool used[24*10]; | ||
469 | memset( used, FALSE, 24*10*sizeof( bool ) ); | ||
470 | |||
471 | for ( int i = 0; i < wCount; i++ ) { | ||
472 | DateBookDayWidget *w = widgetList.at(i); | ||
473 | int xp = place( w, used, n ); | ||
474 | if ( xp != -1 ) { | ||
475 | QRect geom = w->geometry(); | ||
476 | geom.setX( xp*(wid+2) ); | ||
477 | geom.setWidth( wid ); | ||
478 | w->setGeometry( geom ); | ||
479 | } | ||
480 | } | 504 | } |
481 | 505 | ||
482 | if (jumpToCurTime && this->date() == QDate::currentDate()) | 506 | timeMarker->setTime( QTime::currentTime() );//display timeMarker |
483 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 507 | timeMarker->raise(); //on top of all widgets |
484 | else | 508 | if (this->date() == QDate::currentDate()) //only show timeMarker on current day |
485 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 509 | timeMarker->show(); else timeMarker->hide(); |
486 | } | ||
487 | |||
488 | timeMarker->setTime( QTime::currentTime() );//display timeMarker | ||
489 | timeMarker->raise(); //on top of all widgets | ||
490 | if (this->date() == QDate::currentDate()) //only show timeMarker on current day | ||
491 | timeMarker->show(); else timeMarker->hide(); | ||
492 | 510 | ||
493 | setUpdatesEnabled( TRUE ); | 511 | setUpdatesEnabled( TRUE ); |
494 | return; | 512 | return; |
495 | } | 513 | } |
496 | 514 | ||
497 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) | 515 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) |
498 | { | 516 | { |
499 | int i = 0; | 517 | int i = 0; |
500 | DateBookDayWidget *w = widgetList.at(i); | 518 | DateBookDayWidget *w = widgetList.at(i); |
501 | int wCount = widgetList.count(); | 519 | int wCount = widgetList.count(); |
502 | while ( i < wCount && w != item ) { | 520 | while ( i < wCount && w != item ) { |
503 | if ( w->geometry().intersects( geom ) ) { | 521 | if ( w->geometry().intersects( geom ) ) { |
504 | return w; | 522 | return w; |
523 | } | ||
524 | w = widgetList.at(++i); | ||
505 | } | 525 | } |
506 | w = widgetList.at(++i); | ||
507 | } | ||
508 | 526 | ||
509 | return 0; | 527 | return 0; |
510 | } | 528 | } |
511 | 529 | ||
512 | 530 | ||
513 | QDate DateBookDay::date() const | 531 | QDate DateBookDay::date() const |
514 | { | 532 | { |
515 | return currDate; | 533 | return currDate; |
516 | } | 534 | } |
517 | 535 | ||
518 | void DateBookDay::setStartViewTime( int startHere ) | 536 | void DateBookDay::setStartViewTime( int startHere ) |
519 | { | 537 | { |
520 | startTime = startHere; | 538 | startTime = startHere; |
521 | dayView()->clearSelection(); | 539 | dayView()->clearSelection(); |
522 | QTableSelection ts; | 540 | QTableSelection ts; |
523 | 541 | ||
524 | if (jumpToCurTime && this->date() == QDate::currentDate())//this should probably be in datebook.cpp where it's called? | 542 | if (jumpToCurTime && this->date() == QDate::currentDate()) {//this should probably be in datebook.cpp where it's called? |
525 | { | 543 | ts.init( QTime::currentTime().hour(), 0); |
526 | ts.init( QTime::currentTime().hour(), 0); | 544 | ts.expandTo( QTime::currentTime().hour(), 0); |
527 | ts.expandTo( QTime::currentTime().hour(), 0); | 545 | } else { |
528 | } else | 546 | ts.init( startTime, 0 ); |
529 | { | 547 | ts.expandTo( startTime, 0 ); |
530 | ts.init( startTime, 0 ); | 548 | } |
531 | ts.expandTo( startTime, 0 ); | ||
532 | } | ||
533 | 549 | ||
534 | dayView()->addSelection( ts ); | 550 | dayView()->addSelection( ts ); |
535 | } | 551 | } |
536 | 552 | ||
537 | int DateBookDay::startViewTime() const | 553 | int DateBookDay::startViewTime() const |
538 | { | 554 | { |
539 | return startTime; | 555 | return startTime; |
540 | } | 556 | } |
541 | 557 | ||
542 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) | 558 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) |
543 | { | 559 | { |
544 | header->setStartOfWeek( bStartOnMonday ); | 560 | header->setStartOfWeek( bStartOnMonday ); |
545 | // redraw(); | 561 | //redraw(); |
546 | } | 562 | } |
547 | 563 | ||
548 | void DateBookDay::keyPressEvent(QKeyEvent *e) | 564 | void DateBookDay::keyPressEvent(QKeyEvent *e) |
549 | { | 565 | { |
550 | switch(e->key()) { | 566 | switch(e->key()) { |
551 | case Key_Up: | 567 | case Key_Up: |
552 | view->moveUp(); | 568 | view->moveUp(); |
553 | break; | 569 | break; |
554 | case Key_Down: | 570 | case Key_Down: |
555 | view->moveDown(); | 571 | view->moveDown(); |
556 | break; | 572 | break; |
557 | case Key_Left: | 573 | case Key_Left: |
558 | setDate(QDate(currDate).addDays(-1)); | 574 | setDate(QDate(currDate).addDays(-1)); |
559 | break; | 575 | break; |
560 | case Key_Right: | 576 | case Key_Right: |
561 | setDate(QDate(currDate).addDays(1)); | 577 | setDate(QDate(currDate).addDays(1)); |
562 | break; | 578 | break; |
563 | default: | 579 | default: |
564 | e->ignore(); | 580 | e->ignore(); |
565 | } | 581 | } |
566 | } | 582 | } |
567 | 583 | ||
568 | //=========================================================================== | 584 | //=========================================================================== |
569 | 585 | ||
570 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | 586 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) |
571 | DateBookDay *db ) | 587 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) |
572 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) | ||
573 | { | 588 | { |
574 | |||
575 | |||
576 | // why would someone use "<"? Oh well, fix it up... | 589 | // why would someone use "<"? Oh well, fix it up... |
577 | // I wonder what other things may be messed up... | 590 | // I wonder what other things may be messed up... |
578 | QString strDesc = ev.description(); | 591 | QString strDesc = ev.description(); |
579 | int where = strDesc.find( "<" ); | 592 | int where = strDesc.find( "<" ); |
580 | while ( where != -1 ) { | 593 | while ( where != -1 ) { |
581 | strDesc.remove( where, 1 ); | 594 | strDesc.remove( where, 1 ); |
582 | strDesc.insert( where, "<" ); | 595 | strDesc.insert( where, "<" ); |
583 | where = strDesc.find( "<", where ); | 596 | where = strDesc.find( "<", where ); |
584 | } | 597 | } |
585 | 598 | ||
586 | QString strCat; | 599 | QString strCat; |
587 | // ### Fix later... | 600 | // ### Fix later... |
588 | // QString strCat = ev.category(); | 601 | // QString strCat = ev.category(); |
589 | // where = strCat.find( "<" ); | 602 | // where = strCat.find( "<" ); |
590 | // while ( where != -1 ) { | 603 | // while ( where != -1 ) { |
591 | // strCat.remove( where, 1 ); | 604 | // strCat.remove( where, 1 ); |
592 | // strCat.insert( where, "<" ); | 605 | // strCat.insert( where, "<" ); |
593 | // where = strCat.find( "<", where ); | 606 | // where = strCat.find( "<", where ); |
594 | // } | 607 | // } |
595 | 608 | ||
596 | QString strNote = ev.notes(); | 609 | QString strNote = ev.notes(); |
597 | where = strNote.find( "<" ); | 610 | where = strNote.find( "<" ); |
598 | while ( where != -1 ) { | 611 | while ( where != -1 ) { |
599 | strNote.remove( where, 1 ); | 612 | strNote.remove( where, 1 ); |
600 | strNote.insert( where, "<" ); | 613 | strNote.insert( where, "<" ); |
601 | where = strNote.find( "<", where ); | 614 | where = strNote.find( "<", where ); |
602 | } | 615 | } |
603 | 616 | ||
604 | text = "<b>" + strDesc + "</b><br>" + "<i>"; | 617 | text = "<b>" + strDesc + "</b><br>" + "<i>"; |
605 | if ( !strCat.isEmpty() ) { | 618 | if ( !strCat.isEmpty() ) { |
606 | text += strCat + "</i><br>"; | 619 | text += strCat + "</i><br>"; |
607 | } | 620 | } |
608 | if (ev.event().type() == Event::Normal ) | 621 | if (ev.event().type() == Event::Normal ) { |
609 | setEventText( text ); | 622 | setEventText( text ); |
610 | else | 623 | } else { |
611 | setAllDayText( text ); | 624 | setAllDayText( text ); |
625 | } | ||
612 | 626 | ||
613 | text += "<br><br>" + strNote; | 627 | text += "<br><br>" + strNote; |
614 | 628 | ||
615 | setBackgroundMode( PaletteBase ); | 629 | setBackgroundMode( PaletteBase ); |
616 | 630 | ||
617 | QTime start = ev.start(); | 631 | QTime start = ev.start(); |
618 | QTime end = ev.end(); | 632 | QTime end = ev.end(); |
619 | int y = start.hour()*60+start.minute(); | 633 | int y = start.hour()*60+start.minute(); |
620 | int h = end.hour()*60+end.minute()-y; | 634 | int h = end.hour()*60+end.minute()-y; |
621 | int rh = dateBook->dayView()->rowHeight(0); | 635 | int rh = dateBook->dayView()->rowHeight(0); |
622 | y = y*rh/60; | 636 | y = y*rh/60; |
623 | h = h*rh/60; | 637 | h = h*rh/60; |
624 | 638 | ||
625 | if ( h < 12 ) h = 12;// Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line. | 639 | if ( h < 12 ) h = 12;// Make sure the widget is no smaller than 12 pixels high, so that it's possible to read atleast the first line. |
626 | if ( y > ((24*rh)-12) ) y=(24*rh)-12;// Make sure the widget fits inside the dayview. | 640 | if ( y > ((24*rh)-12) ) y=(24*rh)-12;// Make sure the widget fits inside the dayview. |
627 | geom.setY( y ); | 641 | geom.setY( y ); |
628 | geom.setHeight( h ); | 642 | geom.setHeight( h ); |
629 | geom.setX( 0 ); | 643 | geom.setX( 0 ); |
630 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); | 644 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); |
631 | 645 | ||
632 | } | 646 | } |
647 | |||
633 | void DateBookDayWidget::setAllDayText( QString &text ) { | 648 | void DateBookDayWidget::setAllDayText( QString &text ) { |
634 | text += "<b>" + tr("This is an all day event.") + "</b>"; | 649 | text += "<b>" + tr("This is an all day event.") + "</b>"; |
635 | } | 650 | } |
651 | |||
636 | void DateBookDayWidget::setEventText( QString& text ) { | 652 | void DateBookDayWidget::setEventText( QString& text ) { |
637 | bool whichClock = dateBook->dayView()->whichClock(); | 653 | bool whichClock = dateBook->dayView()->whichClock(); |
638 | if ( ev.startDate() != ev.endDate() ) { | 654 | if ( ev.startDate() != ev.endDate() ) { |
639 | text += "<b>" + tr("Start") + "</b>: "; | 655 | text += "<b>" + tr("Start") + "</b>: "; |
640 | text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); | 656 | text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); |
641 | text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; | 657 | text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; |
642 | text += "<b>" + tr("End") + "</b>: "; | 658 | text += "<b>" + tr("End") + "</b>: "; |
643 | text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); | 659 | text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); |
644 | text += " - " + TimeString::longDateString( ev.endDate() ); | 660 | text += " - " + TimeString::longDateString( ev.endDate() ); |
645 | } else { | 661 | } else { |
646 | text += "<b>" + tr("Time") + "</b>: "; | 662 | text += "<b>" + tr("Time") + "</b>: "; |
647 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); | 663 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); |
648 | text += "<b>" + tr(" - ") + "</b>"; | 664 | text += "<b>" + tr(" - ") + "</b>"; |
649 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); | 665 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); |
650 | } | 666 | } |
651 | } | 667 | } |
652 | 668 | ||
653 | DateBookDayWidget::~DateBookDayWidget() | 669 | DateBookDayWidget::~DateBookDayWidget() |
654 | { | 670 | { |
655 | } | 671 | } |
656 | 672 | ||
657 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) | 673 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) |
658 | { | 674 | { |
659 | QPainter p( this ); | 675 | QPainter p( this ); |
660 | 676 | ||
661 | if (dateBook->getSelectedWidget() == this) | 677 | if (dateBook->getSelectedWidget() == this) { |
662 | { | 678 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item |
663 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item | 679 | } else { |
664 | } else | 680 | if (dateBook->date() == QDate::currentDate()) { |
665 | { | 681 | QTime curTime = QTime::currentTime(); |
666 | if (dateBook->date() == QDate::currentDate()) | 682 | if (ev.end() < curTime) { |
667 | { | 683 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive |
668 | QTime curTime = QTime::currentTime(); | 684 | } else { |
669 | 685 | //change color in dependence of the time till the event starts | |
670 | if (ev.end() < curTime) | 686 | int duration = curTime.secsTo(ev.start()); |
671 | { | 687 | if (duration < 0) duration = 0; |
672 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive | 688 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift |
673 | } else | 689 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue |
674 | { | 690 | } |
675 | //change color in dependence of the time till the event starts | 691 | } else { |
676 | int duration = curTime.secsTo(ev.start()); | 692 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) |
677 | if (duration < 0) duration = 0; | 693 | //perhaps make a distinction between future/past dates |
678 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift | 694 | } |
679 | 695 | } | |
680 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue | ||
681 | } | ||
682 | } else | ||
683 | { | ||
684 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) | ||
685 | //perhaps make a distinction between future/past dates | ||
686 | } | ||
687 | } | ||
688 | 696 | ||
689 | p.setPen( QColor(100, 100, 100) ); | 697 | p.setPen( QColor(100, 100, 100) ); |
690 | p.drawRect(rect()); | 698 | p.drawRect(rect()); |
691 | 699 | ||
692 | // p.drawRect(0,0, 5, height()); | 700 | // p.drawRect(0,0, 5, height()); |
693 | 701 | ||
694 | int y = 0; | 702 | int y = 0; |
695 | int d = 0; | 703 | int d = 0; |
696 | 704 | ||
697 | if ( ev.event().hasAlarm() ) { | 705 | if ( ev.event().hasAlarm() ) { |
698 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); | 706 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); |
699 | y = 20; | 707 | y = 20; |
700 | d = 20; | 708 | d = 20; |
701 | } | 709 | } |
702 | 710 | ||
703 | if ( ev.event().hasRepeat() ) { | 711 | if ( ev.event().hasRepeat() ) { |
704 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); | 712 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); |
705 | d = 20; | 713 | d = 20; |
706 | y += 20; | 714 | y += 20; |
707 | } | 715 | } |
708 | 716 | ||
709 | QSimpleRichText rt( text, font() ); | 717 | QSimpleRichText rt( text, font() ); |
710 | rt.setWidth( geom.width() - d - 6 ); | 718 | rt.setWidth( geom.width() - d - 6 ); |
711 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); | 719 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); |
712 | } | 720 | } |
713 | 721 | ||
714 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) | 722 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) |
715 | { | 723 | { |
716 | DateBookDayWidget *item; | 724 | DateBookDayWidget *item; |
717 | 725 | ||
718 | item = dateBook->getSelectedWidget(); | 726 | item = dateBook->getSelectedWidget(); |
719 | if (item) item->update(); | 727 | if (item) |
728 | item->update(); | ||
720 | 729 | ||
721 | dateBook->setSelectedWidget(this); | 730 | dateBook->setSelectedWidget(this); |
722 | update(); | 731 | update(); |
723 | dateBook->repaint(); | 732 | dateBook->repaint(); |
724 | 733 | ||
725 | QPopupMenu m; | 734 | QPopupMenu m; |
726 | m.insertItem( tr( "Edit" ), 1 ); | 735 | m.insertItem( tr( "Edit" ), 1 ); |
727 | m.insertItem( tr( "Duplicate" ), 4 ); | 736 | m.insertItem( tr( "Duplicate" ), 4 ); |
728 | m.insertItem( tr( "Delete" ), 2 ); | 737 | m.insertItem( tr( "Delete" ), 2 ); |
729 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); | 738 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); |
730 | int r = m.exec( e->globalPos() ); | 739 | int r = m.exec( e->globalPos() ); |
731 | if ( r == 1 ) { | 740 | if ( r == 1 ) { |
732 | emit editMe( ev.event() ); | 741 | emit editMe( ev.event() ); |
733 | } else if ( r == 2 ) { | 742 | } else if ( r == 2 ) { |
734 | emit deleteMe( ev.event() ); | 743 | emit deleteMe( ev.event() ); |
735 | } else if ( r == 3 ) { | 744 | } else if ( r == 3 ) { |
736 | emit beamMe( ev.event() ); | 745 | emit beamMe( ev.event() ); |
737 | } else if ( r == 4 ) { | 746 | } else if ( r == 4 ) { |
738 | emit duplicateMe( ev.event() ); | 747 | emit duplicateMe( ev.event() ); |
739 | } | 748 | } |
740 | } | 749 | } |
741 | 750 | ||
742 | void DateBookDayWidget::setGeometry( const QRect &r ) | 751 | void DateBookDayWidget::setGeometry( const QRect &r ) |
743 | { | 752 | { |
744 | geom = r; | 753 | geom = r; |
745 | setFixedSize( r.width()+1, r.height()+1 ); | 754 | setFixedSize( r.width()+1, r.height()+1 ); |
746 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 755 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
747 | show(); | 756 | show(); |
748 | } | 757 | } |
749 | 758 | ||
750 | 759 | ||
751 | //--------------------------------------------------------------------------------------------- | 760 | //--------------------------------------------------------------------------------------------- |
752 | //--------------------------------------------------------------------------------------------- | 761 | //--------------------------------------------------------------------------------------------- |
753 | 762 | ||
754 | 763 | ||
755 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) | 764 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) |
756 | : QWidget( db->dayView()->viewport() ), dateBook( db ) | 765 | : QWidget( db->dayView()->viewport() ), dateBook( db ) |
757 | { | 766 | { |
758 | setBackgroundMode( PaletteBase ); | 767 | setBackgroundMode( PaletteBase ); |
759 | } | 768 | } |
760 | 769 | ||
761 | DateBookDayTimeMarker::~DateBookDayTimeMarker() | 770 | DateBookDayTimeMarker::~DateBookDayTimeMarker() |
762 | { | 771 | { |
763 | } | 772 | } |
764 | 773 | ||
765 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) | 774 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) |
766 | { | 775 | { |
767 | QPainter p( this ); | 776 | QPainter p( this ); |
768 | p.setBrush( QColor( 255, 0, 0 ) ); | 777 | p.setBrush( QColor( 255, 0, 0 ) ); |
769 | 778 | ||
770 | QPen pen; | 779 | QPen pen; |
771 | pen.setStyle(NoPen); | 780 | pen.setStyle(NoPen); |
772 | 781 | ||
773 | p.setPen( pen ); | 782 | p.setPen( pen ); |
774 | p.drawRect(rect()); | 783 | p.drawRect(rect()); |
775 | } | 784 | } |
776 | 785 | ||
777 | void DateBookDayTimeMarker::setTime( const QTime &t ) | 786 | void DateBookDayTimeMarker::setTime( const QTime &t ) |
778 | { | 787 | { |
779 | int y = t.hour()*60+t.minute(); | 788 | int y = t.hour()*60+t.minute(); |
780 | int rh = dateBook->dayView()->rowHeight(0); | 789 | int rh = dateBook->dayView()->rowHeight(0); |
781 | y = y*rh/60; | 790 | y = y*rh/60; |
782 | 791 | ||
783 | geom.setX( 0 ); | 792 | geom.setX( 0 ); |
784 | 793 | ||
785 | int x = dateBook->dayView()->columnWidth(0)-1; | 794 | int x = dateBook->dayView()->columnWidth(0)-1; |
786 | geom.setWidth( x ); | 795 | geom.setWidth( x ); |
787 | 796 | ||
788 | geom.setY( y ); | 797 | geom.setY( y ); |
789 | geom.setHeight( 1 ); | 798 | geom.setHeight( 1 ); |
790 | 799 | ||
791 | setGeometry( geom ); | 800 | setGeometry( geom ); |
792 | 801 | ||
793 | time = t; | 802 | time = t; |
794 | } | 803 | } |
795 | 804 | ||
796 | void DateBookDayTimeMarker::setGeometry( const QRect &r ) | 805 | void DateBookDayTimeMarker::setGeometry( const QRect &r ) |
797 | { | 806 | { |
798 | geom = r; | 807 | geom = r; |
799 | setFixedSize( r.width()+1, r.height()+1 ); | 808 | setFixedSize( r.width()+1, r.height()+1 ); |
800 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 809 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
801 | show(); | 810 | show(); |
802 | } | 811 | } |
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h index 2faf24e..961f60f 100644 --- a/core/pim/datebook/datebookday.h +++ b/core/pim/datebook/datebookday.h | |||
@@ -1,159 +1,182 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef DATEBOOKDAY_H | 20 | #ifndef DATEBOOKDAY_H |
21 | #define DATEBOOKDAY_H | 21 | #define DATEBOOKDAY_H |
22 | 22 | ||
23 | #include <qpe/event.h> | 23 | #include <qpe/event.h> |
24 | 24 | ||
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qtable.h> | 26 | #include <qtable.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qlist.h> | 28 | #include <qlist.h> |
29 | 29 | ||
30 | #include "datebook.h" | ||
31 | #include <qlineedit.h> | ||
32 | |||
30 | class DateBookDayHeader; | 33 | class DateBookDayHeader; |
31 | class DateBookDB; | 34 | class DateBookDB; |
32 | class QDateTime; | 35 | class QDateTime; |
33 | class QMouseEvent; | 36 | class QMouseEvent; |
34 | class QPaintEvent; | 37 | class QPaintEvent; |
35 | class QResizeEvent; | 38 | class QResizeEvent; |
36 | 39 | ||
40 | class DateBookDayViewQuickLineEdit : public QLineEdit | ||
41 | { | ||
42 | Q_OBJECT | ||
43 | public: | ||
44 | DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0); | ||
45 | protected: | ||
46 | Event quickEvent; | ||
47 | int active; | ||
48 | void focusOutEvent( QFocusEvent *e ); | ||
49 | protected slots: | ||
50 | void slotReturnPressed(void); | ||
51 | signals: | ||
52 | void insertEvent(const Event &e); | ||
53 | }; | ||
54 | |||
55 | |||
37 | class DateBookDayView : public QTable | 56 | class DateBookDayView : public QTable |
38 | { | 57 | { |
39 | Q_OBJECT | 58 | Q_OBJECT |
40 | public: | 59 | public: |
41 | DateBookDayView( bool hourClock, QWidget *parent, const char *name ); | 60 | DateBookDayView( bool hourClock, QWidget *parent, const char *name ); |
42 | bool whichClock() const; | 61 | bool whichClock() const; |
43 | 62 | ||
44 | void setRowStyle( int style ); | 63 | void setRowStyle( int style ); |
45 | 64 | ||
46 | public slots: | 65 | public slots: |
47 | void moveUp(); | 66 | void moveUp(); |
48 | void moveDown(); | 67 | void moveDown(); |
68 | void slotDateChanged( int year, int month, int day ); | ||
49 | 69 | ||
50 | signals: | 70 | signals: |
51 | void sigColWidthChanged(); | 71 | void sigColWidthChanged(); |
52 | void sigCapturedKey( const QString &txt ); | 72 | void sigCapturedKey( const QString &txt ); |
53 | protected slots: | 73 | protected slots: |
54 | void slotChangeClock( bool ); | 74 | void slotChangeClock( bool ); |
55 | protected: | 75 | protected: |
56 | virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); | 76 | virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); |
57 | virtual void paintFocus( QPainter *p, const QRect &cr ); | 77 | virtual void paintFocus( QPainter *p, const QRect &cr ); |
58 | 78 | ||
59 | virtual void resizeEvent( QResizeEvent *e ); | 79 | virtual void resizeEvent( QResizeEvent *e ); |
60 | void keyPressEvent( QKeyEvent *e ); | 80 | void keyPressEvent( QKeyEvent *e ); |
81 | void contentsMouseReleaseEvent( QMouseEvent *e ); | ||
61 | void initHeader(); | 82 | void initHeader(); |
62 | private: | 83 | private: |
63 | bool ampm; | 84 | bool ampm; |
85 | QDate currDate; | ||
86 | DateBookDayViewQuickLineEdit *quickLineEdit; | ||
64 | }; | 87 | }; |
65 | 88 | ||
66 | class DateBookDay; | 89 | class DateBookDay; |
67 | class DateBookDayWidget : public QWidget | 90 | class DateBookDayWidget : public QWidget |
68 | { | 91 | { |
69 | Q_OBJECT | 92 | Q_OBJECT |
70 | 93 | ||
71 | public: | 94 | public: |
72 | DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ); | 95 | DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ); |
73 | ~DateBookDayWidget(); | 96 | ~DateBookDayWidget(); |
74 | 97 | ||
75 | const QRect &geometry() { return geom; } | 98 | const QRect &geometry() { return geom; } |
76 | void setGeometry( const QRect &r ); | 99 | void setGeometry( const QRect &r ); |
77 | 100 | ||
78 | const EffectiveEvent &event() const { return ev; } | 101 | const EffectiveEvent &event() const { return ev; } |
79 | 102 | ||
80 | signals: | 103 | signals: |
81 | void deleteMe( const Event &e ); | 104 | void deleteMe( const Event &e ); |
82 | void duplicateMe( const Event &e ); | 105 | void duplicateMe( const Event &e ); |
83 | void editMe( const Event &e ); | 106 | void editMe( const Event &e ); |
84 | void beamMe( const Event &e ); | 107 | void beamMe( const Event &e ); |
85 | 108 | ||
86 | protected: | 109 | protected: |
87 | void paintEvent( QPaintEvent *e ); | 110 | void paintEvent( QPaintEvent *e ); |
88 | void mousePressEvent( QMouseEvent *e ); | 111 | void mousePressEvent( QMouseEvent *e ); |
89 | 112 | ||
90 | private: | 113 | private: |
91 | /** | 114 | /** |
92 | * Sets the text for an all day Event | 115 | * Sets the text for an all day Event |
93 | * All day events have no time associated | 116 | * All day events have no time associated |
94 | */ | 117 | */ |
95 | void setAllDayText( QString& text ); | 118 | void setAllDayText( QString& text ); |
96 | 119 | ||
97 | /** | 120 | /** |
98 | * Sets the EventText | 121 | * Sets the EventText |
99 | * it got a start and an end Time | 122 | * it got a start and an end Time |
100 | */ | 123 | */ |
101 | void setEventText( QString& text ); | 124 | void setEventText( QString& text ); |
102 | const EffectiveEvent ev; | 125 | const EffectiveEvent ev; |
103 | DateBookDay *dateBook; | 126 | DateBookDay *dateBook; |
104 | QString text; | 127 | QString text; |
105 | QRect geom; | 128 | QRect geom; |
106 | }; | 129 | }; |
107 | 130 | ||
108 | //Marker for current time in the dayview | 131 | //Marker for current time in the dayview |
109 | class DateBookDayTimeMarker : public QWidget | 132 | class DateBookDayTimeMarker : public QWidget |
110 | { | 133 | { |
111 | Q_OBJECT | 134 | Q_OBJECT |
112 | 135 | ||
113 | public: | 136 | public: |
114 | DateBookDayTimeMarker( DateBookDay *db ); | 137 | DateBookDayTimeMarker( DateBookDay *db ); |
115 | ~DateBookDayTimeMarker(); | 138 | ~DateBookDayTimeMarker(); |
116 | 139 | ||
117 | const QRect &geometry() { return geom; } | 140 | const QRect &geometry() { return geom; } |
118 | void setGeometry( const QRect &r ); | 141 | void setGeometry( const QRect &r ); |
119 | void setTime( const QTime &t ); | 142 | void setTime( const QTime &t ); |
120 | 143 | ||
121 | signals: | 144 | signals: |
122 | 145 | ||
123 | protected: | 146 | protected: |
124 | void paintEvent( QPaintEvent *e ); | 147 | void paintEvent( QPaintEvent *e ); |
125 | 148 | ||
126 | private: | 149 | private: |
127 | QRect geom; | 150 | QRect geom; |
128 | QTime time; | 151 | QTime time; |
129 | DateBookDay *dateBook; | 152 | DateBookDay *dateBook; |
130 | }; | 153 | }; |
131 | 154 | ||
132 | //reimplemented the compareItems function so that it sorts DayWidgets by geometry heights | 155 | //reimplemented the compareItems function so that it sorts DayWidgets by geometry heights |
133 | class WidgetListClass : public QList<DateBookDayWidget> | 156 | class WidgetListClass : public QList<DateBookDayWidget> |
134 | { | 157 | { |
135 | private: | 158 | private: |
136 | 159 | ||
137 | int compareItems( QCollection::Item s1, QCollection::Item s2 ) | 160 | int compareItems( QCollection::Item s1, QCollection::Item s2 ) |
138 | { | 161 | { |
139 | //hmm, don't punish me for that ;) | 162 | //hmm, don't punish me for that ;) |
140 | if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height()) | 163 | if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height()) |
141 | { | 164 | { |
142 | return -1; | 165 | return -1; |
143 | } else | 166 | } else |
144 | { | 167 | { |
145 | return 1; | 168 | return 1; |
146 | } | 169 | } |
147 | } | 170 | } |
148 | 171 | ||
149 | 172 | ||
150 | }; | 173 | }; |
151 | 174 | ||
152 | class DateBookDay : public QVBox | 175 | class DateBookDay : public QVBox |
153 | { | 176 | { |
154 | Q_OBJECT | 177 | Q_OBJECT |
155 | 178 | ||
156 | public: | 179 | public: |
157 | DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, | 180 | DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, |
158 | QWidget *parent, const char *name ); | 181 | QWidget *parent, const char *name ); |
159 | void selectedDates( QDateTime &start, QDateTime &end ); | 182 | void selectedDates( QDateTime &start, QDateTime &end ); |