summaryrefslogtreecommitdiff
authorzecke <zecke>2002-06-25 19:55:53 (UTC)
committer zecke <zecke>2002-06-25 19:55:53 (UTC)
commitaf4a3940dd672423da28b54e5d955cc5d33cecda (patch) (unidiff)
treecb5fcfe4835c86353e9d54b1050c7dfb23898bf1
parent8635f264c15b05152fc1a44f798c154472a4b227 (diff)
downloadopie-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.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookday.cpp52
-rw-r--r--core/pim/datebook/datebookday.h31
-rw-r--r--core/pim/datebook/datebookweek.cpp52
-rw-r--r--core/pim/datebook/datebookweek.h16
-rw-r--r--core/pim/datebook/datebookweeklst.cpp5
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
@@ -537,187 +537,199 @@ int DateBookDay::startViewTime() const
537void DateBookDay::slotWeekChanged( bool bStartOnMonday ) 537void DateBookDay::slotWeekChanged( bool bStartOnMonday )
538{ 538{
539 header->setStartOfWeek( bStartOnMonday ); 539 header->setStartOfWeek( bStartOnMonday );
540 // redraw(); 540 // redraw();
541} 541}
542 542
543void DateBookDay::keyPressEvent(QKeyEvent *e) 543void DateBookDay::keyPressEvent(QKeyEvent *e)
544{ 544{
545 switch(e->key()) { 545 switch(e->key()) {
546 case Key_Up: 546 case Key_Up:
547 view->moveUp(); 547 view->moveUp();
548 break; 548 break;
549 case Key_Down: 549 case Key_Down:
550 view->moveDown(); 550 view->moveDown();
551 break; 551 break;
552 case Key_Left: 552 case Key_Left:
553 setDate(QDate(currDate).addDays(-1)); 553 setDate(QDate(currDate).addDays(-1));
554 break; 554 break;
555 case Key_Right: 555 case Key_Right:
556 setDate(QDate(currDate).addDays(1)); 556 setDate(QDate(currDate).addDays(1));
557 break; 557 break;
558 default: 558 default:
559 e->ignore(); 559 e->ignore();
560 } 560 }
561} 561}
562 562
563//=========================================================================== 563//===========================================================================
564 564
565DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, 565DateBookDayWidget::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 ) {
576 strDesc.remove( where, 1 ); 576 strDesc.remove( where, 1 );
577 strDesc.insert( where, "&#60;" ); 577 strDesc.insert( where, "&#60;" );
578 where = strDesc.find( "<", where ); 578 where = strDesc.find( "<", where );
579 } 579 }
580 580
581 QString strCat; 581 QString strCat;
582 // ### Fix later... 582 // ### Fix later...
583// QString strCat = ev.category(); 583// QString strCat = ev.category();
584// where = strCat.find( "<" ); 584// where = strCat.find( "<" );
585// while ( where != -1 ) { 585// while ( where != -1 ) {
586 // strCat.remove( where, 1 ); 586 // strCat.remove( where, 1 );
587 // strCat.insert( where, "&#60;" ); 587 // strCat.insert( where, "&#60;" );
588 // where = strCat.find( "<", where ); 588 // where = strCat.find( "<", where );
589// } 589// }
590 590
591 QString strNote = ev.notes(); 591 QString strNote = ev.notes();
592 where = strNote.find( "<" ); 592 where = strNote.find( "<" );
593 while ( where != -1 ) { 593 while ( where != -1 ) {
594 strNote.remove( where, 1 ); 594 strNote.remove( where, 1 );
595 strNote.insert( where, "&#60;" ); 595 strNote.insert( where, "&#60;" );
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;
627 int rh = dateBook->dayView()->rowHeight(0); 614 int rh = dateBook->dayView()->rowHeight(0);
628 y = y*rh/60; 615 y = y*rh/60;
629 h = h*rh/60; 616 h = h*rh/60;
630 if ( h < 3 ) 617 if ( h < 3 )
631 h = 3; 618 h = 3;
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}
625void DateBookDayWidget::setAllDayText( QString &text ) {
626 text += "<b>" + tr("This is an all day event.") + "</b><br>";
627}
628void 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
639DateBookDayWidget::~DateBookDayWidget() 650DateBookDayWidget::~DateBookDayWidget()
640{ 651{
641} 652}
642 653
643void DateBookDayWidget::paintEvent( QPaintEvent *e ) 654void DateBookDayWidget::paintEvent( QPaintEvent *e )
644{ 655{
645 QPainter p( this ); 656 QPainter p( this );
646 657
647 if (dateBook->getSelectedWidget() == this) 658 if (dateBook->getSelectedWidget() == this)
648 { 659 {
649 p.setBrush( QColor( 155, 240, 230 ) ); // selected item 660 p.setBrush( QColor( 155, 240, 230 ) ); // selected item
650 } else 661 } else
651 { 662 {
652 if (dateBook->date() == QDate::currentDate()) 663 if (dateBook->date() == QDate::currentDate())
653 { 664 {
654 QTime curTime = QTime::currentTime(); 665 QTime curTime = QTime::currentTime();
655 666
656 if (ev.end() < curTime) 667 if (ev.end() < curTime)
657 { 668 {
658 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive 669 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive
659 } else 670 } else
660 { 671 {
661 //change color in dependence of the time till the event starts 672 //change color in dependence of the time till the event starts
662 int duration = curTime.secsTo(ev.start()); 673 int duration = curTime.secsTo(ev.start());
663 if (duration < 0) duration = 0; 674 if (duration < 0) duration = 0;
664 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift 675 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift
665 676
666 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue 677 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue
667 } 678 }
668 } else 679 } else
669 { 680 {
670 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) 681 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date)
671 //perhaps make a distinction between future/past dates 682 //perhaps make a distinction between future/past dates
672 } 683 }
673 } 684 }
674 685
675 p.setPen( QColor(100, 100, 100) ); 686 p.setPen( QColor(100, 100, 100) );
676 p.drawRect(rect()); 687 p.drawRect(rect());
677 688
678 // p.drawRect(0,0, 5, height()); 689 // p.drawRect(0,0, 5, height());
679 690
680 int y = 0; 691 int y = 0;
681 int d = 0; 692 int d = 0;
682 693
683 if ( ev.event().hasAlarm() ) { 694 if ( ev.event().hasAlarm() ) {
684 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); 695 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) );
685 y = 20; 696 y = 20;
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}
698 710
699void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) 711void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
700{ 712{
701 DateBookDayWidget *item; 713 DateBookDayWidget *item;
702 714
703 item = dateBook->getSelectedWidget(); 715 item = dateBook->getSelectedWidget();
704 if (item) item->update(); 716 if (item) item->update();
705 717
706 dateBook->setSelectedWidget(this); 718 dateBook->setSelectedWidget(this);
707 update(); 719 update();
708 dateBook->repaint(); 720 dateBook->repaint();
709 721
710 QPopupMenu m; 722 QPopupMenu m;
711 m.insertItem( tr( "Edit" ), 1 ); 723 m.insertItem( tr( "Edit" ), 1 );
712 m.insertItem( tr( "Delete" ), 2 ); 724 m.insertItem( tr( "Delete" ), 2 );
713 m.insertItem( tr( "Beam" ), 3 ); 725 m.insertItem( tr( "Beam" ), 3 );
714 int r = m.exec( e->globalPos() ); 726 int r = m.exec( e->globalPos() );
715 if ( r == 1 ) { 727 if ( r == 1 ) {
716 emit editMe( ev.event() ); 728 emit editMe( ev.event() );
717 } else if ( r == 2 ) { 729 } else if ( r == 2 ) {
718 emit deleteMe( ev.event() ); 730 emit deleteMe( ev.event() );
719 } else if ( r == 3 ) { 731 } else if ( r == 3 ) {
720 emit beamMe( ev.event() ); 732 emit beamMe( ev.event() );
721 } 733 }
722} 734}
723 735
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
@@ -11,158 +11,169 @@
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
30class DateBookDayHeader; 30class DateBookDayHeader;
31class DateBookDB; 31class DateBookDB;
32class QDateTime; 32class QDateTime;
33class QMouseEvent; 33class QMouseEvent;
34class QPaintEvent; 34class QPaintEvent;
35class QResizeEvent; 35class QResizeEvent;
36 36
37class DateBookDayView : public QTable 37class DateBookDayView : public QTable
38{ 38{
39 Q_OBJECT 39 Q_OBJECT
40public: 40public:
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
46public slots: 46public slots:
47 void moveUp(); 47 void moveUp();
48 void moveDown(); 48 void moveDown();
49 49
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 editMe( const Event &e ); 82 void editMe( const Event &e );
83 void beamMe( const Event &e ); 83 void beamMe( const Event &e );
84 84
85protected: 85protected:
86 void paintEvent( QPaintEvent *e ); 86 void paintEvent( QPaintEvent *e );
87 void mousePressEvent( QMouseEvent *e ); 87 void mousePressEvent( QMouseEvent *e );
88 88
89private: 89private:
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
96//Marker for current time in the dayview 107//Marker for current time in the dayview
97class DateBookDayTimeMarker : public QWidget 108class DateBookDayTimeMarker : public QWidget
98{ 109{
99 Q_OBJECT 110 Q_OBJECT
100 111
101public: 112public:
102 DateBookDayTimeMarker( DateBookDay *db ); 113 DateBookDayTimeMarker( DateBookDay *db );
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
109signals: 120signals:
110 121
111protected: 122protected:
112 void paintEvent( QPaintEvent *e ); 123 void paintEvent( QPaintEvent *e );
113 124
114private: 125private:
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
121class WidgetListClass : public QList<DateBookDayWidget> 132class 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
140class DateBookDay : public QVBox 151class DateBookDay : public QVBox
141{ 152{
142 Q_OBJECT 153 Q_OBJECT
143 154
144public: 155public:
145 DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, 156 DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb,
146 QWidget *parent, const char *name ); 157 QWidget *parent, const char *name );
147 void selectedDates( QDateTime &start, QDateTime &end ); 158 void selectedDates( QDateTime &start, QDateTime &end );
148 QDate date() const; 159 QDate date() const;
149 DateBookDayView *dayView() const { return view; } 160 DateBookDayView *dayView() const { return view; }
150 void setStartViewTime( int startHere ); 161 void setStartViewTime( int startHere );
151 int startViewTime() const; 162 int startViewTime() const;
152 void setSelectedWidget( DateBookDayWidget * ); 163 void setSelectedWidget( DateBookDayWidget * );
153 DateBookDayWidget * getSelectedWidget( void ); 164 DateBookDayWidget * getSelectedWidget( void );
154 void setJumpToCurTime( bool bJump ); 165 void setJumpToCurTime( bool bJump );
155 void setRowStyle( int style ); 166 void setRowStyle( int style );
156 167
157public slots: 168public slots:
158 void setDate( int y, int m, int d ); 169 void setDate( int y, int m, int d );
159 void setDate( QDate ); 170 void setDate( QDate );
160 void redraw(); 171 void redraw();
161 void slotWeekChanged( bool bStartOnMonday ); 172 void slotWeekChanged( bool bStartOnMonday );
162 void updateView();//updates TimeMarker and DayWidget-colors 173 void updateView();//updates TimeMarker and DayWidget-colors
163 174
164signals: 175signals:
165 void removeEvent( const Event& ); 176 void removeEvent( const Event& );
166 void editEvent( const Event& ); 177 void editEvent( const Event& );
167 void beamEvent( const Event& ); 178 void beamEvent( const Event& );
168 void newEvent(); 179 void newEvent();
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
@@ -432,118 +432,134 @@ void DateBookWeek::dateChanged( int y, int w )
432{ 432{
433 year = y; 433 year = y;
434 _week = w; 434 _week = w;
435 getEvents(); 435 getEvents();
436} 436}
437 437
438QDate DateBookWeek::date() const 438QDate DateBookWeek::date() const
439{ 439{
440 QDate d; 440 QDate d;
441 d = dateFromWeek( _week - 1, year, bStartOnMonday ); 441 d = dateFromWeek( _week - 1, year, bStartOnMonday );
442 if ( bStartOnMonday ) 442 if ( bStartOnMonday )
443 d = d.addDays( 7 + dow - 1 ); 443 d = d.addDays( 7 + dow - 1 );
444 else { 444 else {
445 if ( dow == 7 ) 445 if ( dow == 7 )
446 d = d.addDays( dow ); 446 d = d.addDays( dow );
447 else 447 else
448 d = d.addDays( 7 + dow ); 448 d = d.addDays( 7 + dow );
449 } 449 }
450 return d; 450 return d;
451} 451}
452 452
453void DateBookWeek::getEvents() 453void DateBookWeek::getEvents()
454{ 454{
455 QDate startWeek = weekDate(); 455 QDate startWeek = weekDate();
456 456
457 QDate endWeek = startWeek.addDays( 6 ); 457 QDate endWeek = startWeek.addDays( 6 );
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
464void DateBookWeek::generateAllDayTooltext( QString& text ) {
465 text += "<b>" + tr("This is an all day event.") + "</b><br>";
466}
467
468void 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
464void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) 491void 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...
470 // I wonder what other things may be messed up... 497 // I wonder what other things may be messed up...
471 QString strDesc = ev.description(); 498 QString strDesc = ev.description();
472 int where = strDesc.find( "<" ); 499 int where = strDesc.find( "<" );
473 while ( where != -1 ) { 500 while ( where != -1 ) {
474 strDesc.remove( where, 1 ); 501 strDesc.remove( where, 1 );
475 strDesc.insert( where, "&#60;" ); 502 strDesc.insert( where, "&#60;" );
476 where = strDesc.find( "<", where ); 503 where = strDesc.find( "<", where );
477 } 504 }
478 505
479 QString strCat; 506 QString strCat;
480 // ### FIX later... 507 // ### FIX later...
481// QString strCat = ev.category(); 508// QString strCat = ev.category();
482// where = strCat.find( "<" ); 509// where = strCat.find( "<" );
483// while ( where != -1 ) { 510// while ( where != -1 ) {
484 // strCat.remove( where, 1 ); 511 // strCat.remove( where, 1 );
485 // strCat.insert( where, "&#60;" ); 512 // strCat.insert( where, "&#60;" );
486 // where = strCat.find( "<", where ); 513 // where = strCat.find( "<", where );
487// } 514// }
488 515
489 QString strNote = ev.notes(); 516 QString strNote = ev.notes();
490 where = strNote.find( "<" ); 517 where = strNote.find( "<" );
491 while ( where != -1 ) { 518 while ( where != -1 ) {
492 strNote.remove( where, 1 ); 519 strNote.remove( where, 1 );
493 strNote.insert( where, "&#60;" ); 520 strNote.insert( where, "&#60;" );
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 );
524 lblDesc->show(); 540 lblDesc->show();
525} 541}
526 542
527void DateBookWeek::slotHideEvent() 543void DateBookWeek::slotHideEvent()
528{ 544{
529 tHide->start( 2000, true ); 545 tHide->start( 2000, true );
530} 546}
531 547
532void DateBookWeek::setStartViewTime( int startHere ) 548void DateBookWeek::setStartViewTime( int startHere )
533{ 549{
534 startTime = startHere; 550 startTime = startHere;
535 view->moveToHour( startTime ); 551 view->moveToHour( startTime );
536} 552}
537 553
538int DateBookWeek::startViewTime() const 554int DateBookWeek::startViewTime() const
539{ 555{
540 return startTime; 556 return startTime;
541} 557}
542 558
543void DateBookWeek::redraw() 559void DateBookWeek::redraw()
544{ 560{
545 getEvents(); 561 getEvents();
546} 562}
547 563
548void DateBookWeek::slotYearChanged( int y ) 564void DateBookWeek::slotYearChanged( int y )
549{ 565{
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
@@ -104,49 +104,65 @@ public:
104 QWidget *parent = 0, const char *name = 0 ); 104 QWidget *parent = 0, const char *name = 0 );
105 void setDate( int y, int m, int d ); 105 void setDate( int y, int m, int d );
106 void setDate( QDate d ); 106 void setDate( QDate d );
107 QDate date() const; 107 QDate date() const;
108 DateBookWeekView *weekView() const { return view; } 108 DateBookWeekView *weekView() const { return view; }
109 void setStartViewTime( int startHere ); 109 void setStartViewTime( int startHere );
110 int startViewTime() const; 110 int startViewTime() const;
111 int week() const { return _week; }; 111 int week() const { return _week; };
112 void setTotalWeeks( int totalWeeks ); 112 void setTotalWeeks( int totalWeeks );
113 int totalWeeks() const; 113 int totalWeeks() const;
114 QDate weekDate() const; 114 QDate weekDate() const;
115 115
116public slots: 116public slots:
117 void redraw(); 117 void redraw();
118 void slotWeekChanged( bool bStartOnMonday ); 118 void slotWeekChanged( bool bStartOnMonday );
119 void slotClockChanged( bool a ); 119 void slotClockChanged( bool a );
120 120
121signals: 121signals:
122 void showDate( int y, int m, int d ); 122 void showDate( int y, int m, int d );
123 123
124protected slots: 124protected slots:
125 void keyPressEvent(QKeyEvent *); 125 void keyPressEvent(QKeyEvent *);
126 126
127private slots: 127private slots:
128 void showDay( int day ); 128 void showDay( int day );
129 void dateChanged( int y, int w ); 129 void dateChanged( int y, int w );
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
134private: 134private:
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;
142 QLabel *lblDesc; 158 QLabel *lblDesc;
143 QTimer *tHide; 159 QTimer *tHide;
144 int startTime; 160 int startTime;
145 bool ampm; 161 bool ampm;
146 bool bStartOnMonday; 162 bool bStartOnMonday;
147}; 163};
148 164
149 165
150bool calcWeek( const QDate &d, int &week, int &year, 166bool calcWeek( const QDate &d, int &week, int &year,
151 bool startOnMonday = false ); 167 bool startOnMonday = false );
152#endif 168#endif
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
@@ -125,65 +125,68 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/,
125 125
126 126
127 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 127 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
128 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 128 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
129} 129}
130 130
131void DateBookWeekLstDayHdr::showDay() { 131void DateBookWeekLstDayHdr::showDay() {
132 emit showDate(date.year(), date.month(), date.day()); 132 emit showDate(date.year(), date.month(), date.day());
133} 133}
134void DateBookWeekLstDayHdr::newEvent() { 134void DateBookWeekLstDayHdr::newEvent() {
135 QDateTime start, stop; 135 QDateTime start, stop;
136 start=stop=date; 136 start=stop=date;
137 start.setTime(QTime(10,0)); 137 start.setTime(QTime(10,0));
138 stop.setTime(QTime(12,0)); 138 stop.setTime(QTime(12,0));
139 139
140 emit addEvent(start,stop,""); 140 emit addEvent(start,stop,"");
141} 141}
142DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 142DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
143 QWidget* parent, 143 QWidget* parent,
144 const char* name, 144 const char* name,
145 WFlags fl) : 145 WFlags fl) :
146 OClickableLabel(parent,name,fl), 146 OClickableLabel(parent,name,fl),
147 event(ev) 147 event(ev)
148{ 148{
149 char s[10]; 149 char s[10];
150 if ( ev.startDate() != ev.date() ) { // multiday event (not first day) 150 if ( ev.startDate() != ev.date() ) { // multiday event (not first day)
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}
163void DateBookWeekLstEvent::editMe() { 166void DateBookWeekLstEvent::editMe() {
164 emit editEvent(event.event()); 167 emit editEvent(event.event());
165} 168}
166 169
167 170
168DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 171DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
169 const QDate &d, bool onM, 172 const QDate &d, bool onM,
170 QWidget* parent, 173 QWidget* parent,
171 const char* name, WFlags fl) 174 const char* name, WFlags fl)
172 : QWidget( parent, name, fl ) 175 : QWidget( parent, name, fl )
173{ 176{
174 onMonday=onM; 177 onMonday=onM;
175 setPalette(white); 178 setPalette(white);
176 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 179 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
177 180
178 QVBoxLayout *layout = new QVBoxLayout( this ); 181 QVBoxLayout *layout = new QVBoxLayout( this );
179 182
180 qBubbleSort(ev); 183 qBubbleSort(ev);
181 QValueListIterator<EffectiveEvent> it; 184 QValueListIterator<EffectiveEvent> it;
182 it=ev.begin(); 185 it=ev.begin();
183 186
184 int dayOrder[7]; 187 int dayOrder[7];
185 if (onMonday) 188 if (onMonday)
186 for (int d=0; d<7; d++) dayOrder[d]=d+1; 189 for (int d=0; d<7; d++) dayOrder[d]=d+1;
187 else { 190 else {
188 for (int d=0; d<7; d++) dayOrder[d]=d; 191 for (int d=0; d<7; d++) dayOrder[d]=d;
189 dayOrder[0]=7; 192 dayOrder[0]=7;