author | zecke <zecke> | 2002-06-25 19:55:53 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-25 19:55:53 (UTC) |
commit | af4a3940dd672423da28b54e5d955cc5d33cecda (patch) (unidiff) | |
tree | cb5fcfe4835c86353e9d54b1050c7dfb23898bf1 | |
parent | 8635f264c15b05152fc1a44f798c154472a4b227 (diff) | |
download | opie-af4a3940dd672423da28b54e5d955cc5d33cecda.zip opie-af4a3940dd672423da28b54e5d955cc5d33cecda.tar.gz opie-af4a3940dd672423da28b54e5d955cc5d33cecda.tar.bz2 |
All day events are not from 00:00 to 23:59 they're all day now.
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 52 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.h | 31 | ||||
-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 52 | ||||
-rw-r--r-- | core/pim/datebook/datebookweek.h | 16 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 5 |
5 files changed, 107 insertions, 49 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index 9cc5fcd..5474cfc 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -563,13 +563,13 @@ void DateBookDay::keyPressEvent(QKeyEvent *e) | |||
563 | //=========================================================================== | 563 | //=========================================================================== |
564 | 564 | ||
565 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | 565 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, |
566 | DateBookDay *db ) | 566 | DateBookDay *db ) |
567 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) | 567 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) |
568 | { | 568 | { |
569 | bool whichClock = db->dayView()->whichClock(); | 569 | |
570 | 570 | ||
571 | // why would someone use "<"? Oh well, fix it up... | 571 | // why would someone use "<"? Oh well, fix it up... |
572 | // I wonder what other things may be messed up... | 572 | // I wonder what other things may be messed up... |
573 | QString strDesc = ev.description(); | 573 | QString strDesc = ev.description(); |
574 | int where = strDesc.find( "<" ); | 574 | int where = strDesc.find( "<" ); |
575 | while ( where != -1 ) { | 575 | while ( where != -1 ) { |
@@ -594,33 +594,20 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | |||
594 | strNote.remove( where, 1 ); | 594 | strNote.remove( where, 1 ); |
595 | strNote.insert( where, "<" ); | 595 | strNote.insert( where, "<" ); |
596 | where = strNote.find( "<", where ); | 596 | where = strNote.find( "<", where ); |
597 | } | 597 | } |
598 | 598 | ||
599 | text = "<b>" + strDesc + "</b><br>" + "<i>" | 599 | text = "<b>" + strDesc + "</b><br>" + "<i>" |
600 | + strCat + "</i>" | 600 | + strCat + "</i><br>"; |
601 | + "<br><b>" + tr("Start") + "</b>: "; | 601 | if (ev.event().type() == Event::Normal ) |
602 | 602 | setEventText( text ); | |
603 | 603 | else | |
604 | if ( e.startDate() != ev.date() ) { | 604 | setAllDayText( text ); |
605 | // multi-day event. Show start date | ||
606 | text += TimeString::longDateString( e.startDate() ); | ||
607 | } else { | ||
608 | // Show start time. | ||
609 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); | ||
610 | } | ||
611 | 605 | ||
612 | text += "<br><b>" + tr("End") + "</b>: "; | ||
613 | if ( e.endDate() != ev.date() ) { | ||
614 | // multi-day event. Show end date | ||
615 | text += TimeString::longDateString( e.endDate() ); | ||
616 | } else { | ||
617 | // Show end time. | ||
618 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); | ||
619 | } | ||
620 | text += "<br><br>" + strNote; | 606 | text += "<br><br>" + strNote; |
607 | |||
621 | setBackgroundMode( PaletteBase ); | 608 | setBackgroundMode( PaletteBase ); |
622 | 609 | ||
623 | QTime start = ev.start(); | 610 | QTime start = ev.start(); |
624 | QTime end = ev.end(); | 611 | QTime end = ev.end(); |
625 | int y = start.hour()*60+start.minute(); | 612 | int y = start.hour()*60+start.minute(); |
626 | int h = end.hour()*60+end.minute()-y; | 613 | int h = end.hour()*60+end.minute()-y; |
@@ -632,12 +619,36 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | |||
632 | geom.setY( y ); | 619 | geom.setY( y ); |
633 | geom.setHeight( h ); | 620 | geom.setHeight( h ); |
634 | geom.setX( 0 ); | 621 | geom.setX( 0 ); |
635 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); | 622 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); |
636 | 623 | ||
637 | } | 624 | } |
625 | void DateBookDayWidget::setAllDayText( QString &text ) { | ||
626 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; | ||
627 | } | ||
628 | void DateBookDayWidget::setEventText( QString& text ) { | ||
629 | bool whichClock = dateBook->dayView()->whichClock(); | ||
630 | text += "<b>" + tr("Start") + "</b>: "; | ||
631 | if ( ev.startDate() != ev.date() ) { | ||
632 | // multi-day event. Show start date | ||
633 | text += TimeString::longDateString( ev.startDate() ); | ||
634 | } else { | ||
635 | // Show start time. | ||
636 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); | ||
637 | } | ||
638 | |||
639 | text += "<br><b>" + tr("End") + "</b>: "; | ||
640 | if ( ev.endDate() != ev.date() ) { | ||
641 | // multi-day event. Show end date | ||
642 | text += TimeString::longDateString( ev.endDate() ); | ||
643 | } else { | ||
644 | // Show end time. | ||
645 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); | ||
646 | } | ||
647 | |||
648 | } | ||
638 | 649 | ||
639 | DateBookDayWidget::~DateBookDayWidget() | 650 | DateBookDayWidget::~DateBookDayWidget() |
640 | { | 651 | { |
641 | } | 652 | } |
642 | 653 | ||
643 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) | 654 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) |
@@ -686,12 +697,13 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e ) | |||
686 | d = 20; | 697 | d = 20; |
687 | } | 698 | } |
688 | 699 | ||
689 | if ( ev.event().hasRepeat() ) { | 700 | if ( ev.event().hasRepeat() ) { |
690 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); | 701 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); |
691 | d = 20; | 702 | d = 20; |
703 | y += 20; | ||
692 | } | 704 | } |
693 | 705 | ||
694 | QSimpleRichText rt( text, font() ); | 706 | QSimpleRichText rt( text, font() ); |
695 | rt.setWidth( geom.width() - d - 6 ); | 707 | rt.setWidth( geom.width() - d - 6 ); |
696 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); | 708 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); |
697 | } | 709 | } |
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h index be7cc45..db1cd04 100644 --- a/core/pim/datebook/datebookday.h +++ b/core/pim/datebook/datebookday.h | |||
@@ -37,13 +37,13 @@ class QResizeEvent; | |||
37 | class DateBookDayView : public QTable | 37 | class DateBookDayView : public QTable |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | public: | 40 | public: |
41 | DateBookDayView( bool hourClock, QWidget *parent, const char *name ); | 41 | DateBookDayView( bool hourClock, QWidget *parent, const char *name ); |
42 | bool whichClock() const; | 42 | bool whichClock() const; |
43 | 43 | ||
44 | void setRowStyle( int style ); | 44 | void setRowStyle( int style ); |
45 | 45 | ||
46 | public slots: | 46 | public slots: |
47 | void moveUp(); | 47 | void moveUp(); |
48 | void moveDown(); | 48 | void moveDown(); |
49 | 49 | ||
@@ -52,13 +52,13 @@ signals: | |||
52 | void sigCapturedKey( const QString &txt ); | 52 | void sigCapturedKey( const QString &txt ); |
53 | protected slots: | 53 | protected slots: |
54 | void slotChangeClock( bool ); | 54 | void slotChangeClock( bool ); |
55 | protected: | 55 | protected: |
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(); |
62 | private: | 62 | private: |
63 | bool ampm; | 63 | bool ampm; |
64 | }; | 64 | }; |
@@ -73,23 +73,34 @@ public: | |||
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 | ||
80 | signals: | 80 | signals: |
81 | void deleteMe( const Event &e ); | 81 | void deleteMe( const Event &e ); |
82 | void editMe( const Event &e ); | 82 | void editMe( const Event &e ); |
83 | void beamMe( const Event &e ); | 83 | void beamMe( const Event &e ); |
84 | 84 | ||
85 | protected: | 85 | protected: |
86 | void paintEvent( QPaintEvent *e ); | 86 | void paintEvent( QPaintEvent *e ); |
87 | void mousePressEvent( QMouseEvent *e ); | 87 | void mousePressEvent( QMouseEvent *e ); |
88 | 88 | ||
89 | private: | 89 | private: |
90 | /** | ||
91 | * Sets the text for an all day Event | ||
92 | * All day events have no time associated | ||
93 | */ | ||
94 | void setAllDayText( QString& text ); | ||
95 | |||
96 | /** | ||
97 | * Sets the EventText | ||
98 | * it got a start and an end Time | ||
99 | */ | ||
100 | void setEventText( QString& text ); | ||
90 | const EffectiveEvent ev; | 101 | const EffectiveEvent ev; |
91 | DateBookDay *dateBook; | 102 | DateBookDay *dateBook; |
92 | QString text; | 103 | QString text; |
93 | QRect geom; | 104 | QRect geom; |
94 | }; | 105 | }; |
95 | 106 | ||
@@ -103,40 +114,40 @@ public: | |||
103 | ~DateBookDayTimeMarker(); | 114 | ~DateBookDayTimeMarker(); |
104 | 115 | ||
105 | const QRect &geometry() { return geom; } | 116 | const QRect &geometry() { return geom; } |
106 | void setGeometry( const QRect &r ); | 117 | void setGeometry( const QRect &r ); |
107 | void setTime( const QTime &t ); | 118 | void setTime( const QTime &t ); |
108 | 119 | ||
109 | signals: | 120 | signals: |
110 | 121 | ||
111 | protected: | 122 | protected: |
112 | void paintEvent( QPaintEvent *e ); | 123 | void paintEvent( QPaintEvent *e ); |
113 | 124 | ||
114 | private: | 125 | private: |
115 | QRect geom; | 126 | QRect geom; |
116 | QTime time; | 127 | QTime time; |
117 | DateBookDay *dateBook; | 128 | DateBookDay *dateBook; |
118 | }; | 129 | }; |
119 | 130 | ||
120 | //reimplemented the compareItems function so that it sorts DayWidgets by geometry heights | 131 | //reimplemented the compareItems function so that it sorts DayWidgets by geometry heights |
121 | class WidgetListClass : public QList<DateBookDayWidget> | 132 | class WidgetListClass : public QList<DateBookDayWidget> |
122 | { | 133 | { |
123 | private: | 134 | private: |
124 | 135 | ||
125 | int compareItems( QCollection::Item s1, QCollection::Item s2 ) | 136 | int compareItems( QCollection::Item s1, QCollection::Item s2 ) |
126 | { | 137 | { |
127 | //hmm, don't punish me for that ;) | 138 | //hmm, don't punish me for that ;) |
128 | if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height()) | 139 | if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height()) |
129 | { | 140 | { |
130 | return -1; | 141 | return -1; |
131 | } else | 142 | } else |
132 | { | 143 | { |
133 | return 1; | 144 | return 1; |
134 | } | 145 | } |
135 | } | 146 | } |
136 | 147 | ||
137 | 148 | ||
138 | }; | 149 | }; |
139 | 150 | ||
140 | class DateBookDay : public QVBox | 151 | class DateBookDay : public QVBox |
141 | { | 152 | { |
142 | Q_OBJECT | 153 | Q_OBJECT |
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index 6532ba4..e16f516 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp | |||
@@ -458,12 +458,39 @@ void DateBookWeek::getEvents() | |||
458 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, | 458 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, |
459 | endWeek); | 459 | endWeek); |
460 | view->showEvents( eventList ); | 460 | view->showEvents( eventList ); |
461 | view->moveToHour( startTime ); | 461 | view->moveToHour( startTime ); |
462 | } | 462 | } |
463 | 463 | ||
464 | void DateBookWeek::generateAllDayTooltext( QString& text ) { | ||
465 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; | ||
466 | } | ||
467 | |||
468 | void DateBookWeek::generateNormalTooltext( QString& str, | ||
469 | const EffectiveEvent &ev ) { | ||
470 | str += "<b>" + QObject::tr("Start") + "</b>: "; | ||
471 | |||
472 | if ( ev.startDate() != ev.date() ) { | ||
473 | // multi-day event. Show start date | ||
474 | str += TimeString::longDateString( ev.startDate() ); | ||
475 | } else { | ||
476 | // Show start time. | ||
477 | str += TimeString::timeString(ev.start(), ampm, FALSE ); | ||
478 | } | ||
479 | |||
480 | |||
481 | str += "<br><b>" + QObject::tr("End") + "</b>: "; | ||
482 | if ( ev.endDate() != ev.date() ) { | ||
483 | // multi-day event. Show end date | ||
484 | str += TimeString::longDateString( ev.endDate() ); | ||
485 | } else { | ||
486 | // Show end time. | ||
487 | str += TimeString::timeString( ev.end(), ampm, FALSE ); | ||
488 | } | ||
489 | } | ||
490 | |||
464 | void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) | 491 | void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) |
465 | { | 492 | { |
466 | if ( tHide->isActive() ) | 493 | if ( tHide->isActive() ) |
467 | tHide->stop(); | 494 | tHide->stop(); |
468 | 495 | ||
469 | // why would someone use "<"? Oh well, fix it up... | 496 | // why would someone use "<"? Oh well, fix it up... |
@@ -492,32 +519,21 @@ void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) | |||
492 | strNote.remove( where, 1 ); | 519 | strNote.remove( where, 1 ); |
493 | strNote.insert( where, "<" ); | 520 | strNote.insert( where, "<" ); |
494 | where = strNote.find( "<", where ); | 521 | where = strNote.find( "<", where ); |
495 | } | 522 | } |
496 | 523 | ||
497 | QString str = "<b>" + strDesc + "</b><br>" + "<i>" | 524 | QString str = "<b>" + strDesc + "</b><br>" + "<i>" |
498 | + strCat + "</i>" | 525 | + strCat + "</i>" |
499 | + "<br>" + TimeString::longDateString( ev.date() ) | 526 | + "<br>" + TimeString::longDateString( ev.date() ) |
500 | + "<br><b>" + QObject::tr("Start") + "</b>: "; | 527 | + "<br>"; |
501 | 528 | ||
502 | if ( ev.startDate() != ev.date() ) { | 529 | if (ev.event().type() == Event::Normal ) |
503 | // multi-day event. Show start date | 530 | generateNormalTooltext( str, ev ); |
504 | str += TimeString::longDateString( ev.startDate() ); | 531 | else |
505 | } else { | 532 | generateAllDayTooltext( str ); |
506 | // Show start time. | ||
507 | str += TimeString::timeString(ev.start(), ampm, FALSE ); | ||
508 | } | ||
509 | 533 | ||
510 | str += "<br><b>" + QObject::tr("End") + "</b>: "; | ||
511 | if ( ev.endDate() != ev.date() ) { | ||
512 | // multi-day event. Show end date | ||
513 | str += TimeString::longDateString( ev.endDate() ); | ||
514 | } else { | ||
515 | // Show end time. | ||
516 | str += TimeString::timeString( ev.end(), ampm, FALSE ); | ||
517 | } | ||
518 | str += "<br><br>" + strNote; | 534 | str += "<br><br>" + strNote; |
519 | 535 | ||
520 | lblDesc->setText( str ); | 536 | lblDesc->setText( str ); |
521 | lblDesc->resize( lblDesc->sizeHint() ); | 537 | lblDesc->resize( lblDesc->sizeHint() ); |
522 | // move the label so it is "centerd" horizontally... | 538 | // move the label so it is "centerd" horizontally... |
523 | lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 ); | 539 | lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 ); |
diff --git a/core/pim/datebook/datebookweek.h b/core/pim/datebook/datebookweek.h index 6e675f1..acbc2c7 100644 --- a/core/pim/datebook/datebookweek.h +++ b/core/pim/datebook/datebookweek.h | |||
@@ -130,12 +130,28 @@ private slots: | |||
130 | void slotShowEvent( const EffectiveEvent & ); | 130 | void slotShowEvent( const EffectiveEvent & ); |
131 | void slotHideEvent(); | 131 | void slotHideEvent(); |
132 | void slotYearChanged( int ); | 132 | void slotYearChanged( int ); |
133 | 133 | ||
134 | private: | 134 | private: |
135 | void getEvents(); | 135 | void getEvents(); |
136 | |||
137 | /** | ||
138 | * Wow that's a hell lot of code duplication | ||
139 | * in datebook. I vote for a common base class | ||
140 | * but never the less. This add a note | ||
141 | * that the Event is an all day event | ||
142 | * | ||
143 | */ | ||
144 | void generateAllDayTooltext( QString& text ); | ||
145 | |||
146 | /** | ||
147 | * This will add the times to the text | ||
148 | * It will be shown in the Tooltip bubble | ||
149 | */ | ||
150 | void generateNormalTooltext( QString& text, | ||
151 | const EffectiveEvent &ev); | ||
136 | int year; | 152 | int year; |
137 | int _week; | 153 | int _week; |
138 | int dow; | 154 | int dow; |
139 | DateBookWeekHeader *header; | 155 | DateBookWeekHeader *header; |
140 | DateBookWeekView *view; | 156 | DateBookWeekView *view; |
141 | DateBookDB *db; | 157 | DateBookDB *db; |
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 29519c1..5eefc27 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp | |||
@@ -151,13 +151,16 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | |||
151 | if ( ev.endDate() == ev.date() ) { // last day | 151 | if ( ev.endDate() == ev.date() ) { // last day |
152 | strcpy(s, "__|__"); | 152 | strcpy(s, "__|__"); |
153 | } else { | 153 | } else { |
154 | strcpy(s, " |---"); | 154 | strcpy(s, " |---"); |
155 | } | 155 | } |
156 | } else { | 156 | } else { |
157 | sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); | 157 | if(ev.event().type() == Event::Normal ) |
158 | sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); | ||
159 | else | ||
160 | sprintf(s," "); | ||
158 | } | 161 | } |
159 | setText(QString(s) + " " + ev.description()); | 162 | setText(QString(s) + " " + ev.description()); |
160 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 163 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
161 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 164 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
162 | } | 165 | } |
163 | void DateBookWeekLstEvent::editMe() { | 166 | void DateBookWeekLstEvent::editMe() { |