summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp67
-rw-r--r--core/pim/datebook/datebook.h3
-rw-r--r--core/pim/datebook/datebookday.cpp29
-rw-r--r--core/pim/datebook/datebookday.h2
4 files changed, 86 insertions, 15 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index fa509d9..47be523 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -373,64 +373,121 @@ void DateBook::view(int v, const QDate &d) {
373 initMonth(); 373 initMonth();
374 monthAction->setOn( TRUE ); 374 monthAction->setOn( TRUE );
375 monthView->setDate( d.year(), d.month(), d.day() ); 375 monthView->setDate( d.year(), d.month(), d.day() );
376 views->raiseWidget( monthView ); 376 views->raiseWidget( monthView );
377 monthView->redraw(); 377 monthView->redraw();
378 } 378 }
379} 379}
380 380
381void DateBook::viewDefault(const QDate &d) { 381void DateBook::viewDefault(const QDate &d) {
382 Config config("DateBook"); 382 Config config("DateBook");
383 config.setGroup("Main"); 383 config.setGroup("Main");
384 int current=config.readNumEntry("defaultview", DAY); 384 int current=config.readNumEntry("defaultview", DAY);
385 385
386 view(current,d); 386 view(current,d);
387} 387}
388 388
389void DateBook::viewDay() { 389void DateBook::viewDay() {
390 view(DAY,currentDate()); 390 view(DAY,currentDate());
391} 391}
392 392
393void DateBook::viewWeek() { 393void DateBook::viewWeek() {
394 view(WEEK,currentDate()); 394 view(WEEK,currentDate());
395} 395}
396 396
397void DateBook::viewWeekLst() { 397void DateBook::viewWeekLst() {
398 view(WEEKLST,currentDate()); 398 view(WEEKLST,currentDate());
399} 399}
400 400
401void DateBook::viewMonth() { 401void DateBook::viewMonth() {
402 view(MONTH,currentDate()); 402 view(MONTH,currentDate());
403} 403}
404 404
405void DateBook::duplicateEvent( const Event &e )
406{
407 qWarning("Hmmm...");
408 // Alot of code duplication, as this is almost like editEvent();
409 if (syncing) {
410 QMessageBox::warning( this, tr("Calendar"),
411 tr( "Can not edit data, currently syncing") );
412 return;
413 }
414
415 Event dupevent;
416 dupevent.setStart(e.start());
417 dupevent.setEnd(e.end());
418 dupevent.setDescription(e.description());
419 dupevent.setLocation(e.location());
420 // dupevent.setCategory(e.category());// how is this done??
421 dupevent.setNotes(e.notes());
422 dupevent.setAllDay(e.isAllDay());
423 dupevent.setTimeZone(e.timeZone());
424 if(e.hasAlarm()) dupevent.setAlarm(e.alarmDelay(),e.alarmSound());
425 if(e.hasRepeat()) dupevent.setRepeat(e.repeatPattern());
426
427 // workaround added for text input.
428 QDialog editDlg( this, 0, TRUE );
429 DateEntry *entry;
430 editDlg.setCaption( tr("Duplicate Event") );
431 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
432 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
433 sv->setResizePolicy( QScrollView::AutoOneFit );
434 // KLUDGE!!!
435 sv->setHScrollBarMode( QScrollView::AlwaysOff );
436 vb->addWidget( sv );
437 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
438 entry->timezone->setEnabled( FALSE );
439 sv->addChild( entry );
440
441#if defined(Q_WS_QWS) || defined(_WS_QWS_)
442 editDlg.showMaximized();
443#endif
444 while (editDlg.exec() ) {
445 Event newEv = entry->event();
446 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
447 break;
448 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
449 QString error = checkEvent(newEv);
450 if (!error.isNull()) {
451 if (QMessageBox::warning(this, "error box",
452 error, "Fix it", "Continue",
453 0, 0, 1) == 0)
454 continue;
455 }
456 db->addEvent(newEv);
457 emit newEvent();
458 break;
459 }
460}
461
405void DateBook::editEvent( const Event &e ) 462void DateBook::editEvent( const Event &e )
406{ 463{
407 if (syncing) { 464 if (syncing) {
408 QMessageBox::warning( this, tr("Calendar"), 465 QMessageBox::warning( this, tr("Calendar"),
409 tr( "Can not edit data, currently syncing") ); 466 tr( "Can not edit data, currently syncing") );
410 return; 467 return;
411 } 468 }
412 469
413 // workaround added for text input. 470 // workaround added for text input.
414 QDialog editDlg( this, 0, TRUE ); 471 QDialog editDlg( this, 0, TRUE );
415 DateEntry *entry; 472 DateEntry *entry;
416 editDlg.setCaption( tr("Edit Event") ); 473 editDlg.setCaption( tr("Edit Event") );
417 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 474 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
418 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 475 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
419 sv->setResizePolicy( QScrollView::AutoOneFit ); 476 sv->setResizePolicy( QScrollView::AutoOneFit );
420 // KLUDGE!!! 477 // KLUDGE!!!
421 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 478 sv->setHScrollBarMode( QScrollView::AlwaysOff );
422 vb->addWidget( sv ); 479 vb->addWidget( sv );
423 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 480 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
424 entry->timezone->setEnabled( FALSE ); 481 entry->timezone->setEnabled( FALSE );
425 sv->addChild( entry ); 482 sv->addChild( entry );
426 483
427#if defined(Q_WS_QWS) || defined(_WS_QWS_) 484#if defined(Q_WS_QWS) || defined(_WS_QWS_)
428 editDlg.showMaximized(); 485 editDlg.showMaximized();
429#endif 486#endif
430 while (editDlg.exec() ) { 487 while (editDlg.exec() ) {
431 Event newEv = entry->event(); 488 Event newEv = entry->event();
432 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 489 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
433 break; 490 break;
434 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 491 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
435 QString error = checkEvent(newEv); 492 QString error = checkEvent(newEv);
436 if (!error.isNull()) { 493 if (!error.isNull()) {
@@ -463,64 +520,66 @@ void DateBook::removeEvent( const Event &e )
463 dayView->redraw(); 520 dayView->redraw();
464} 521}
465 522
466void DateBook::addEvent( const Event &e ) 523void DateBook::addEvent( const Event &e )
467{ 524{
468 QDate d = e.start().date(); 525 QDate d = e.start().date();
469 initDay(); 526 initDay();
470 dayView->setDate( d ); 527 dayView->setDate( d );
471} 528}
472 529
473void DateBook::showDay( int year, int month, int day ) 530void DateBook::showDay( int year, int month, int day )
474{ 531{
475 QDate d(year, month, day); 532 QDate d(year, month, day);
476 view(DAY,d); 533 view(DAY,d);
477} 534}
478 535
479void DateBook::initDay() 536void DateBook::initDay()
480{ 537{
481 if ( !dayView ) { 538 if ( !dayView ) {
482 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 539 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
483 views->addWidget( dayView, DAY ); 540 views->addWidget( dayView, DAY );
484 dayView->setStartViewTime( startTime ); 541 dayView->setStartViewTime( startTime );
485 dayView->setJumpToCurTime( bJumpToCurTime ); 542 dayView->setJumpToCurTime( bJumpToCurTime );
486 dayView->setRowStyle( rowStyle ); 543 dayView->setRowStyle( rowStyle );
487 connect( this, SIGNAL( newEvent() ), 544 connect( this, SIGNAL( newEvent() ),
488 dayView, SLOT( redraw() ) ); 545 dayView, SLOT( redraw() ) );
489 connect( dayView, SIGNAL( newEvent() ), 546 connect( dayView, SIGNAL( newEvent() ),
490 this, SLOT( fileNew() ) ); 547 this, SLOT( fileNew() ) );
491 connect( dayView, SIGNAL( removeEvent( const Event & ) ), 548 connect( dayView, SIGNAL( removeEvent( const Event & ) ),
492 this, SLOT( removeEvent( const Event & ) ) ); 549 this, SLOT( removeEvent( const Event & ) ) );
493 connect( dayView, SIGNAL( editEvent( const Event & ) ), 550 connect( dayView, SIGNAL( editEvent( const Event & ) ),
494 this, SLOT( editEvent( const Event & ) ) ); 551 this, SLOT( editEvent( const Event & ) ) );
552 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ),
553 this, SLOT( duplicateEvent( const Event & ) ) );
495 connect( dayView, SIGNAL( beamEvent( const Event & ) ), 554 connect( dayView, SIGNAL( beamEvent( const Event & ) ),
496 this, SLOT( beamEvent( const Event & ) ) ); 555 this, SLOT( beamEvent( const Event & ) ) );
497 connect( dayView, SIGNAL(sigNewEvent(const QString &)), 556 connect( dayView, SIGNAL(sigNewEvent(const QString &)),
498 this, SLOT(slotNewEventFromKey(const QString &)) ); 557 this, SLOT(slotNewEventFromKey(const QString &)) );
499 } 558 }
500} 559}
501 560
502void DateBook::initWeek() 561void DateBook::initWeek()
503{ 562{
504 if ( !weekView ) { 563 if ( !weekView ) {
505 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 564 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
506 weekView->setStartViewTime( startTime ); 565 weekView->setStartViewTime( startTime );
507 views->addWidget( weekView, WEEK ); 566 views->addWidget( weekView, WEEK );
508 connect( weekView, SIGNAL( showDate( int, int, int ) ), 567 connect( weekView, SIGNAL( showDate( int, int, int ) ),
509 this, SLOT( showDay( int, int, int ) ) ); 568 this, SLOT( showDay( int, int, int ) ) );
510 connect( this, SIGNAL( newEvent() ), 569 connect( this, SIGNAL( newEvent() ),
511 weekView, SLOT( redraw() ) ); 570 weekView, SLOT( redraw() ) );
512 } 571 }
513 //But also get it right: the year that we display can be different 572 //But also get it right: the year that we display can be different
514 //from the year of the current date. So, first find the year 573 //from the year of the current date. So, first find the year
515 //number of the current week. 574 //number of the current week.
516 575
517 int yearNumber, totWeeks; 576 int yearNumber, totWeeks;
518 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 577 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
519 578
520 QDate d = QDate( yearNumber, 12, 31 ); 579 QDate d = QDate( yearNumber, 12, 31 );
521 calcWeek( d, totWeeks, yearNumber, onMonday ); 580 calcWeek( d, totWeeks, yearNumber, onMonday );
522 581
523 while ( totWeeks == 1 ) { 582 while ( totWeeks == 1 ) {
524 d = d.addDays( -1 ); 583 d = d.addDays( -1 );
525 calcWeek( d, totWeeks, yearNumber, onMonday ); 584 calcWeek( d, totWeeks, yearNumber, onMonday );
526 } 585 }
@@ -787,81 +846,85 @@ void DateBook::closeEvent( QCloseEvent *e )
787void DateBook::slotNewEventFromKey( const QString &str ) 846void DateBook::slotNewEventFromKey( const QString &str )
788{ 847{
789 if (syncing) { 848 if (syncing) {
790 QMessageBox::warning( this, tr("Calendar"), 849 QMessageBox::warning( this, tr("Calendar"),
791 tr( "Can not edit data, currently syncing") ); 850 tr( "Can not edit data, currently syncing") );
792 return; 851 return;
793 } 852 }
794 853
795 // We get to here from a key pressed in the Day View 854 // We get to here from a key pressed in the Day View
796 // So we can assume some things. We want the string 855 // So we can assume some things. We want the string
797 // passed in to be part of the description. 856 // passed in to be part of the description.
798 QDateTime start, end; 857 QDateTime start, end;
799 if ( views->visibleWidget() == dayView ) { 858 if ( views->visibleWidget() == dayView ) {
800 dayView->selectedDates( start, end ); 859 dayView->selectedDates( start, end );
801 } else if ( views->visibleWidget() == monthView ) { 860 } else if ( views->visibleWidget() == monthView ) {
802 QDate d = monthView->selectedDate(); 861 QDate d = monthView->selectedDate();
803 start = end = d; 862 start = end = d;
804 start.setTime( QTime( 10, 0 ) ); 863 start.setTime( QTime( 10, 0 ) );
805 end.setTime( QTime( 12, 0 ) ); 864 end.setTime( QTime( 12, 0 ) );
806 } else if ( views->visibleWidget() == weekView ) { 865 } else if ( views->visibleWidget() == weekView ) {
807 QDate d = weekView->date(); 866 QDate d = weekView->date();
808 start = end = d; 867 start = end = d;
809 start.setTime( QTime( 10, 0 ) ); 868 start.setTime( QTime( 10, 0 ) );
810 end.setTime( QTime( 12, 0 ) ); 869 end.setTime( QTime( 12, 0 ) );
811 } else if ( views->visibleWidget() == weekLstView ) { 870 } else if ( views->visibleWidget() == weekLstView ) {
812 QDate d = weekLstView->date(); 871 QDate d = weekLstView->date();
813 start = end = d; 872 start = end = d;
814 start.setTime( QTime( 10, 0 ) ); 873 start.setTime( QTime( 10, 0 ) );
815 end.setTime( QTime( 12, 0 ) ); 874 end.setTime( QTime( 12, 0 ) );
816 } 875 }
817 slotNewEntry(start, end, str); 876 slotNewEntry(start, end, str);
818} 877}
819void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { 878void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
820 // argh! This really needs to be encapsulated in a class 879 // argh! This really needs to be encapsulated in a class
821 // or function. 880 // or function.
822 QDialog newDlg( this, 0, TRUE ); 881 QDialog newDlg( this, 0, TRUE );
823 newDlg.setCaption( DateEntryBase::tr("New Event") ); 882 newDlg.setCaption( DateEntryBase::tr("New Event") );
824 DateEntry *e; 883 DateEntry *e;
825 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 884 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
826 QScrollView *sv = new QScrollView( &newDlg ); 885 QScrollView *sv = new QScrollView( &newDlg );
827 sv->setResizePolicy( QScrollView::AutoOneFit ); 886 sv->setResizePolicy( QScrollView::AutoOneFit );
828 sv->setFrameStyle( QFrame::NoFrame ); 887 sv->setFrameStyle( QFrame::NoFrame );
829 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 888 sv->setHScrollBarMode( QScrollView::AlwaysOff );
830 vb->addWidget( sv ); 889 vb->addWidget( sv );
831 890
832 Event ev; 891 Event ev;
833 ev.setDescription( str ); 892 ev.setDescription( str );
834 // When the new gui comes in, change this... 893 // When the new gui comes in, change this...
835 ev.setLocation( tr("(Unknown)") ); 894 if(location==0) {
895 ev.setLocation( tr("(Unknown)") );
896 } else {
897 ev.setLocation(location);
898 }
836 ev.setStart( start ); 899 ev.setStart( start );
837 ev.setEnd( end ); 900 ev.setEnd( end );
838 901
839 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 902 e = new DateEntry( onMonday, ev, ampm, &newDlg );
840 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 903 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
841 sv->addChild( e ); 904 sv->addChild( e );
842#if defined(Q_WS_QWS) || defined(_WS_QWS_) 905#if defined(Q_WS_QWS) || defined(_WS_QWS_)
843 newDlg.showMaximized(); 906 newDlg.showMaximized();
844#endif 907#endif
845 while (newDlg.exec()) { 908 while (newDlg.exec()) {
846 ev = e->event(); 909 ev = e->event();
847 ev.assignUid(); 910 ev.assignUid();
848 QString error = checkEvent( ev ); 911 QString error = checkEvent( ev );
849 if ( !error.isNull() ) { 912 if ( !error.isNull() ) {
850 if ( QMessageBox::warning( this, tr("Error!"), 913 if ( QMessageBox::warning( this, tr("Error!"),
851 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 914 error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
852 continue; 915 continue;
853 } 916 }
854 db->addEvent( ev ); 917 db->addEvent( ev );
855 emit newEvent(); 918 emit newEvent();
856 break; 919 break;
857 } 920 }
858} 921}
859 922
860void DateBook::setDocument( const QString &filename ) 923void DateBook::setDocument( const QString &filename )
861{ 924{
862 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 925 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
863 926
864 QValueList<Event> tl = Event::readVCalendar( filename ); 927 QValueList<Event> tl = Event::readVCalendar( filename );
865 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 928 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
866 db->addEvent( *it ); 929 db->addEvent( *it );
867 } 930 }
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index ba8f97e..623862b 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -36,86 +36,87 @@ class Ir;
36 36
37class DateBookDBHack : public DateBookDB { 37class DateBookDBHack : public DateBookDB {
38 public: 38 public:
39 Event eventByUID(int id); 39 Event eventByUID(int id);
40}; 40};
41 41
42class DateBook : public QMainWindow 42class DateBook : public QMainWindow
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46public: 46public:
47 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 47 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
48 ~DateBook(); 48 ~DateBook();
49 49
50signals: 50signals:
51 void newEvent(); 51 void newEvent();
52 void signalNotFound(); 52 void signalNotFound();
53 void signalWrapAround(); 53 void signalWrapAround();
54 54
55protected: 55protected:
56 QDate currentDate(); 56 QDate currentDate();
57 void timerEvent( QTimerEvent *e ); 57 void timerEvent( QTimerEvent *e );
58 void closeEvent( QCloseEvent *e ); 58 void closeEvent( QCloseEvent *e );
59 59
60 void view(int v, const QDate &d); 60 void view(int v, const QDate &d);
61 61
62public slots: 62public slots:
63 void flush(); 63 void flush();
64 void reload(); 64 void reload();
65 65
66private slots: 66private slots:
67 void fileNew(); 67 void fileNew();
68 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str); 68 void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location=0);
69 void slotSettings(); 69 void slotSettings();
70 void newDefaultView(QAction *a); 70 void newDefaultView(QAction *a);
71 void slotToday();// view today 71 void slotToday();// view today
72 void changeClock( bool newClock ); 72 void changeClock( bool newClock );
73 void changeWeek( bool newDay ); 73 void changeWeek( bool newDay );
74 void appMessage(const QCString& msg, const QByteArray& data); 74 void appMessage(const QCString& msg, const QByteArray& data);
75 // handle key events in the day view... 75 // handle key events in the day view...
76 void slotNewEventFromKey( const QString &str ); 76 void slotNewEventFromKey( const QString &str );
77 void slotFind(); 77 void slotFind();
78 void slotDoFind( const QString &, const QDate &, bool, bool, int ); 78 void slotDoFind( const QString &, const QDate &, bool, bool, int );
79 79
80 void viewDefault(const QDate &d); 80 void viewDefault(const QDate &d);
81 81
82 void viewDay(); 82 void viewDay();
83 void viewWeek(); 83 void viewWeek();
84 void viewWeekLst(); 84 void viewWeekLst();
85 void viewMonth(); 85 void viewMonth();
86 86
87 void showDay( int y, int m, int d ); 87 void showDay( int y, int m, int d );
88 88
89 void editEvent( const Event &e ); 89 void editEvent( const Event &e );
90 void duplicateEvent( const Event &e );
90 void removeEvent( const Event &e ); 91 void removeEvent( const Event &e );
91 92
92 void receive( const QCString &msg, const QByteArray &data ); 93 void receive( const QCString &msg, const QByteArray &data );
93 void setDocument( const QString & ); 94 void setDocument( const QString & );
94 void beamEvent( const Event &e ); 95 void beamEvent( const Event &e );
95 void beamDone( Ir *ir ); 96 void beamDone( Ir *ir );
96 97
97private: 98private:
98 void addEvent( const Event &e ); 99 void addEvent( const Event &e );
99 void initDay(); 100 void initDay();
100 void initWeek(); 101 void initWeek();
101 void initWeekLst(); 102 void initWeekLst();
102 void initMonth(); 103 void initMonth();
103 void loadSettings(); 104 void loadSettings();
104 void saveSettings(); 105 void saveSettings();
105 106
106private: 107private:
107 DateBookDBHack *db; 108 DateBookDBHack *db;
108 QWidgetStack *views; 109 QWidgetStack *views;
109 DateBookDay *dayView; 110 DateBookDay *dayView;
110 DateBookWeek *weekView; 111 DateBookWeek *weekView;
111 DateBookMonth *monthView; 112 DateBookMonth *monthView;
112 DateBookWeekLst *weekLstView; 113 DateBookWeekLst *weekLstView;
113 QAction *dayAction, *weekAction, *weekLstAction, *monthAction; 114 QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
114 bool aPreset; // have everything set to alarm? 115 bool aPreset; // have everything set to alarm?
115 int presetTime; // the standard time for the alarm 116 int presetTime; // the standard time for the alarm
116 int startTime; 117 int startTime;
117 int rowStyle; 118 int rowStyle;
118 bool bJumpToCurTime; //should jump to current time in dayview? 119 bool bJumpToCurTime; //should jump to current time in dayview?
119 bool ampm; 120 bool ampm;
120 bool onMonday; 121 bool onMonday;
121 122
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index 42f026a..5d472a6 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -284,64 +284,66 @@ void DateBookDay::dateChanged( int y, int m, int d )
284 ts.init( QTime::currentTime().hour(), 0); 284 ts.init( QTime::currentTime().hour(), 0);
285 ts.expandTo( QTime::currentTime().hour(), 0); 285 ts.expandTo( QTime::currentTime().hour(), 0);
286 } else 286 } else
287 { 287 {
288 ts.init( startTime, 0 ); 288 ts.init( startTime, 0 );
289 ts.expandTo( startTime, 0 ); 289 ts.expandTo( startTime, 0 );
290 } 290 }
291 291
292 dayView()->addSelection( ts ); 292 dayView()->addSelection( ts );
293 293
294 selectedWidget = 0; 294 selectedWidget = 0;
295 295
296} 296}
297 297
298void DateBookDay::redraw() 298void DateBookDay::redraw()
299{ 299{
300 if ( isUpdatesEnabled() ) 300 if ( isUpdatesEnabled() )
301 relayoutPage(); 301 relayoutPage();
302} 302}
303 303
304void DateBookDay::getEvents() 304void DateBookDay::getEvents()
305{ 305{
306 widgetList.clear(); 306 widgetList.clear();
307 307
308 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); 308 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate );
309 QValueListIterator<EffectiveEvent> it; 309 QValueListIterator<EffectiveEvent> it;
310 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 310 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
311 EffectiveEvent ev=*it; 311 EffectiveEvent ev=*it;
312 if(!(ev.end().hour()==ev.start().hour() && ev.end().minute()==ev.start().minute())) {// Skip effective events with no duration. (i.e ending at 00:00) 312 if(!(ev.end().hour()==ev.start().hour() && ev.end().minute()==ev.start().minute())) {// Skip effective events with no duration. (i.e ending at 00:00)
313 DateBookDayWidget* w = new DateBookDayWidget( *it, this ); 313 DateBookDayWidget* w = new DateBookDayWidget( *it, this );
314 connect( w, SIGNAL( deleteMe( const Event & ) ), 314 connect( w, SIGNAL( deleteMe( const Event & ) ),
315 this, SIGNAL( removeEvent( const Event & ) ) ); 315 this, SIGNAL( removeEvent( const Event & ) ) );
316 connect( w, SIGNAL( duplicateMe( const Event & ) ),
317 this, SIGNAL( duplicateEvent( const Event & ) ) );
316 connect( w, SIGNAL( editMe( const Event & ) ), 318 connect( w, SIGNAL( editMe( const Event & ) ),
317 this, SIGNAL( editEvent( const Event & ) ) ); 319 this, SIGNAL( editEvent( const Event & ) ) );
318 connect( w, SIGNAL( beamMe( const Event & ) ), 320 connect( w, SIGNAL( beamMe( const Event & ) ),
319 this, SIGNAL( beamEvent( const Event & ) ) ); 321 this, SIGNAL( beamEvent( const Event & ) ) );
320 widgetList.append( w ); 322 widgetList.append( w );
321 } 323 }
322 } 324 }
323 325
324} 326}
325 327
326static int place( const DateBookDayWidget *item, bool *used, int maxn ) 328static int place( const DateBookDayWidget *item, bool *used, int maxn )
327{ 329{
328 int place = 0; 330 int place = 0;
329 int start = item->event().start().hour(); 331 int start = item->event().start().hour();
330 QTime e = item->event().end(); 332 QTime e = item->event().end();
331 int end = e.hour(); 333 int end = e.hour();
332 if ( e.minute() < 5 ) 334 if ( e.minute() < 5 )
333 end--; 335 end--;
334 if ( end < start ) 336 if ( end < start )
335 end = start; 337 end = start;
336 while ( place < maxn ) { 338 while ( place < maxn ) {
337 bool free = TRUE; 339 bool free = TRUE;
338 int s = start; 340 int s = start;
339 while( s <= end ) { 341 while( s <= end ) {
340 if ( used[10*s+place] ) { 342 if ( used[10*s+place] ) {
341 free = FALSE; 343 free = FALSE;
342 break; 344 break;
343 } 345 }
344 s++; 346 s++;
345 } 347 }
346 if ( free ) break; 348 if ( free ) break;
347 place++; 349 place++;
@@ -691,76 +693,79 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e )
691 693
692 int y = 0; 694 int y = 0;
693 int d = 0; 695 int d = 0;
694 696
695 if ( ev.event().hasAlarm() ) { 697 if ( ev.event().hasAlarm() ) {
696 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); 698 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) );
697 y = 20; 699 y = 20;
698 d = 20; 700 d = 20;
699 } 701 }
700 702
701 if ( ev.event().hasRepeat() ) { 703 if ( ev.event().hasRepeat() ) {
702 p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); 704 p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) );
703 d = 20; 705 d = 20;
704 y += 20; 706 y += 20;
705 } 707 }
706 708
707 QSimpleRichText rt( text, font() ); 709 QSimpleRichText rt( text, font() );
708 rt.setWidth( geom.width() - d - 6 ); 710 rt.setWidth( geom.width() - d - 6 );
709 rt.draw( &p, 7, 0, e->region(), colorGroup() ); 711 rt.draw( &p, 7, 0, e->region(), colorGroup() );
710} 712}
711 713
712void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) 714void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
713{ 715{
714 DateBookDayWidget *item; 716 DateBookDayWidget *item;
715 717
716 item = dateBook->getSelectedWidget(); 718 item = dateBook->getSelectedWidget();
717 if (item) item->update(); 719 if (item) item->update();
718 720
719 dateBook->setSelectedWidget(this); 721 dateBook->setSelectedWidget(this);
720 update(); 722 update();
721 dateBook->repaint(); 723 dateBook->repaint();
722 724
723 QPopupMenu m; 725 QPopupMenu m;
724 m.insertItem( tr( "Edit" ), 1 ); 726 m.insertItem( tr( "Edit" ), 1 );
725 m.insertItem( tr( "Delete" ), 2 ); 727 m.insertItem( tr( "Duplicate" ), 4 );
726 if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); 728 m.insertItem( tr( "Delete" ), 2 );
727 int r = m.exec( e->globalPos() ); 729 if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 );
728 if ( r == 1 ) { 730 int r = m.exec( e->globalPos() );
729 emit editMe( ev.event() ); 731 if ( r == 1 ) {
730 } else if ( r == 2 ) { 732 emit editMe( ev.event() );
731 emit deleteMe( ev.event() ); 733 } else if ( r == 2 ) {
732 } else if ( r == 3 ) { 734 emit deleteMe( ev.event() );
733 emit beamMe( ev.event() ); 735 } else if ( r == 3 ) {
734 } 736 emit beamMe( ev.event() );
737 } else if ( r == 4 ) {
738 emit duplicateMe( ev.event() );
739 }
735} 740}
736 741
737void DateBookDayWidget::setGeometry( const QRect &r ) 742void DateBookDayWidget::setGeometry( const QRect &r )
738{ 743{
739 geom = r; 744 geom = r;
740 setFixedSize( r.width()+1, r.height()+1 ); 745 setFixedSize( r.width()+1, r.height()+1 );
741 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); 746 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 );
742 show(); 747 show();
743} 748}
744 749
745 750
746//--------------------------------------------------------------------------------------------- 751//---------------------------------------------------------------------------------------------
747//--------------------------------------------------------------------------------------------- 752//---------------------------------------------------------------------------------------------
748 753
749 754
750DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) 755DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db )
751 : QWidget( db->dayView()->viewport() ), dateBook( db ) 756 : QWidget( db->dayView()->viewport() ), dateBook( db )
752{ 757{
753 setBackgroundMode( PaletteBase ); 758 setBackgroundMode( PaletteBase );
754} 759}
755 760
756DateBookDayTimeMarker::~DateBookDayTimeMarker() 761DateBookDayTimeMarker::~DateBookDayTimeMarker()
757{ 762{
758} 763}
759 764
760void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) 765void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ )
761{ 766{
762 QPainter p( this ); 767 QPainter p( this );
763 p.setBrush( QColor( 255, 0, 0 ) ); 768 p.setBrush( QColor( 255, 0, 0 ) );
764 769
765 QPen pen; 770 QPen pen;
766 pen.setStyle(NoPen); 771 pen.setStyle(NoPen);
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h
index db1cd04..2faf24e 100644
--- a/core/pim/datebook/datebookday.h
+++ b/core/pim/datebook/datebookday.h
@@ -50,64 +50,65 @@ public slots:
50signals: 50signals:
51 void sigColWidthChanged(); 51 void sigColWidthChanged();
52 void sigCapturedKey( const QString &txt ); 52 void sigCapturedKey( const QString &txt );
53protected slots: 53protected slots:
54 void slotChangeClock( bool ); 54 void slotChangeClock( bool );
55protected: 55protected:
56 virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); 56 virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected );
57 virtual void paintFocus( QPainter *p, const QRect &cr ); 57 virtual void paintFocus( QPainter *p, const QRect &cr );
58 58
59 virtual void resizeEvent( QResizeEvent *e ); 59 virtual void resizeEvent( QResizeEvent *e );
60 void keyPressEvent( QKeyEvent *e ); 60 void keyPressEvent( QKeyEvent *e );
61 void initHeader(); 61 void initHeader();
62private: 62private:
63 bool ampm; 63 bool ampm;
64}; 64};
65 65
66class DateBookDay; 66class DateBookDay;
67class DateBookDayWidget : public QWidget 67class DateBookDayWidget : public QWidget
68{ 68{
69 Q_OBJECT 69 Q_OBJECT
70 70
71public: 71public:
72 DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ); 72 DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db );
73 ~DateBookDayWidget(); 73 ~DateBookDayWidget();
74 74
75 const QRect &geometry() { return geom; } 75 const QRect &geometry() { return geom; }
76 void setGeometry( const QRect &r ); 76 void setGeometry( const QRect &r );
77 77
78 const EffectiveEvent &event() const { return ev; } 78 const EffectiveEvent &event() const { return ev; }
79 79
80signals: 80signals:
81 void deleteMe( const Event &e ); 81 void deleteMe( const Event &e );
82 void duplicateMe( const Event &e );
82 void editMe( const Event &e ); 83 void editMe( const Event &e );
83 void beamMe( const Event &e ); 84 void beamMe( const Event &e );
84 85
85protected: 86protected:
86 void paintEvent( QPaintEvent *e ); 87 void paintEvent( QPaintEvent *e );
87 void mousePressEvent( QMouseEvent *e ); 88 void mousePressEvent( QMouseEvent *e );
88 89
89private: 90private:
90 /** 91 /**
91 * Sets the text for an all day Event 92 * Sets the text for an all day Event
92 * All day events have no time associated 93 * All day events have no time associated
93 */ 94 */
94 void setAllDayText( QString& text ); 95 void setAllDayText( QString& text );
95 96
96 /** 97 /**
97 * Sets the EventText 98 * Sets the EventText
98 * it got a start and an end Time 99 * it got a start and an end Time
99 */ 100 */
100 void setEventText( QString& text ); 101 void setEventText( QString& text );
101 const EffectiveEvent ev; 102 const EffectiveEvent ev;
102 DateBookDay *dateBook; 103 DateBookDay *dateBook;
103 QString text; 104 QString text;
104 QRect geom; 105 QRect geom;
105}; 106};
106 107
107//Marker for current time in the dayview 108//Marker for current time in the dayview
108class DateBookDayTimeMarker : public QWidget 109class DateBookDayTimeMarker : public QWidget
109{ 110{
110 Q_OBJECT 111 Q_OBJECT
111 112
112public: 113public:
113 DateBookDayTimeMarker( DateBookDay *db ); 114 DateBookDayTimeMarker( DateBookDay *db );
@@ -146,60 +147,61 @@ class WidgetListClass : public QList<DateBookDayWidget>
146 } 147 }
147 148
148 149
149}; 150};
150 151
151class DateBookDay : public QVBox 152class DateBookDay : public QVBox
152{ 153{
153 Q_OBJECT 154 Q_OBJECT
154 155
155public: 156public:
156 DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, 157 DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb,
157 QWidget *parent, const char *name ); 158 QWidget *parent, const char *name );
158 void selectedDates( QDateTime &start, QDateTime &end ); 159 void selectedDates( QDateTime &start, QDateTime &end );
159 QDate date() const; 160 QDate date() const;
160 DateBookDayView *dayView() const { return view; } 161 DateBookDayView *dayView() const { return view; }
161 void setStartViewTime( int startHere ); 162 void setStartViewTime( int startHere );
162 int startViewTime() const; 163 int startViewTime() const;
163 void setSelectedWidget( DateBookDayWidget * ); 164 void setSelectedWidget( DateBookDayWidget * );
164 DateBookDayWidget * getSelectedWidget( void ); 165 DateBookDayWidget * getSelectedWidget( void );
165 void setJumpToCurTime( bool bJump ); 166 void setJumpToCurTime( bool bJump );
166 void setRowStyle( int style ); 167 void setRowStyle( int style );
167 168
168public slots: 169public slots:
169 void setDate( int y, int m, int d ); 170 void setDate( int y, int m, int d );
170 void setDate( QDate ); 171 void setDate( QDate );
171 void redraw(); 172 void redraw();
172 void slotWeekChanged( bool bStartOnMonday ); 173 void slotWeekChanged( bool bStartOnMonday );
173 void updateView();//updates TimeMarker and DayWidget-colors 174 void updateView();//updates TimeMarker and DayWidget-colors
174 175
175signals: 176signals:
176 void removeEvent( const Event& ); 177 void removeEvent( const Event& );
177 void editEvent( const Event& ); 178 void editEvent( const Event& );
179 void duplicateEvent( const Event& );
178 void beamEvent( const Event& ); 180 void beamEvent( const Event& );
179 void newEvent(); 181 void newEvent();
180 void sigNewEvent( const QString & ); 182 void sigNewEvent( const QString & );
181 183
182protected slots: 184protected slots:
183 void keyPressEvent(QKeyEvent *); 185 void keyPressEvent(QKeyEvent *);
184 186
185private slots: 187private slots:
186 void dateChanged( int y, int m, int d ); 188 void dateChanged( int y, int m, int d );
187 void slotColWidthChanged() { relayoutPage(); }; 189 void slotColWidthChanged() { relayoutPage(); };
188 190
189private: 191private:
190 void getEvents(); 192 void getEvents();
191 void relayoutPage( bool fromResize = false ); 193 void relayoutPage( bool fromResize = false );
192 DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom ); 194 DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom );
193 QDate currDate; 195 QDate currDate;
194 DateBookDayView *view; 196 DateBookDayView *view;
195 DateBookDayHeader *header; 197 DateBookDayHeader *header;
196 DateBookDB *db; 198 DateBookDB *db;
197 WidgetListClass widgetList;//reimplemented QList for sorting widgets by height 199 WidgetListClass widgetList;//reimplemented QList for sorting widgets by height
198 int startTime; 200 int startTime;
199 bool jumpToCurTime;//should we jump to current time in dayview? 201 bool jumpToCurTime;//should we jump to current time in dayview?
200 int rowStyle; 202 int rowStyle;
201 DateBookDayWidget *selectedWidget; //actual selected widget (obviously) 203 DateBookDayWidget *selectedWidget; //actual selected widget (obviously)
202 DateBookDayTimeMarker *timeMarker;//marker for current time 204 DateBookDayTimeMarker *timeMarker;//marker for current time
203}; 205};
204 206
205#endif 207#endif