Diffstat (limited to 'core/pim/datebook/datebookweek.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 65 |
1 files changed, 27 insertions, 38 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index 2ad7aa9..ab7e963 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp | |||
@@ -17,27 +17,20 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "datebookweek.h" | 20 | #include "datebookweek.h" |
21 | #include "datebookweekheaderimpl.h" | 21 | #include "datebookweekheaderimpl.h" |
22 | 22 | ||
23 | #include <qpe/calendar.h> | ||
24 | #include <qpe/datebookdb.h> | 23 | #include <qpe/datebookdb.h> |
25 | #include <qpe/event.h> | ||
26 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/timestring.h> | 25 | #include <qpe/calendar.h> |
28 | 26 | ||
29 | #include <qdatetime.h> | ||
30 | #include <qheader.h> | 27 | #include <qheader.h> |
31 | #include <qlabel.h> | 28 | #include <qlabel.h> |
32 | #include <qlayout.h> | 29 | #include <qlayout.h> |
33 | #include <qpainter.h> | ||
34 | #include <qpopupmenu.h> | ||
35 | #include <qtimer.h> | 30 | #include <qtimer.h> |
36 | #include <qspinbox.h> | ||
37 | #include <qstyle.h> | ||
38 | 31 | ||
39 | //----------------------------------------------------------------- | 32 | //----------------------------------------------------------------- |
40 | 33 | ||
41 | 34 | ||
42 | DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e ) | 35 | DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e ) |
43 | : ev( e ) | 36 | : ev( e ) |
@@ -86,50 +79,43 @@ DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday, | |||
86 | 79 | ||
87 | resizeContents( width(), 24*rowHeight ); | 80 | resizeContents( width(), 24*rowHeight ); |
88 | } | 81 | } |
89 | 82 | ||
90 | void DateBookWeekView::initNames() | 83 | void DateBookWeekView::initNames() |
91 | { | 84 | { |
85 | #warning Please review this ! (eilers) | ||
86 | |||
87 | // Ok, I am Mr. Pedantic, but shouldn't we count until 6 instead of 7, if bOnMonday is false ? (eilers) | ||
88 | |||
92 | static bool bFirst = true; | 89 | static bool bFirst = true; |
93 | if ( bFirst ) { | 90 | if ( bFirst ) { |
94 | if ( bOnMonday ) { | 91 | if ( bOnMonday ) { |
95 | header->addLabel( tr("Mo", "Monday" ) ); | 92 | for ( int i = 1; i<=7; i++ ) { |
96 | header->addLabel( tr("Tu", "Tuesday") ); | 93 | header->addLabel( Calendar::nameOfDay( i ) ); |
97 | header->addLabel( tr("We", "Wednesday" ) ); | 94 | } |
98 | header->addLabel( tr("Th", "Thursday" ) ); | 95 | |
99 | header->addLabel( tr("Fr", "Friday" ) ); | ||
100 | header->addLabel( tr("Sa", "Saturday" ) ); | ||
101 | header->addLabel( tr("Su", "Sunday" ) ); | ||
102 | } else { | 96 | } else { |
103 | header->addLabel( tr("Su", "Sunday" ) ); | 97 | header->addLabel( Calendar::nameOfDay( 7 ) ); |
104 | header->addLabel( tr("Mo", "Monday") ); | 98 | for ( int i = 1; i<7; i++ ) { |
105 | header->addLabel( tr("Tu", "Tuesday") ); | 99 | header->addLabel( Calendar::nameOfDay( i ) ); |
106 | header->addLabel( tr("We", "Wednesday" ) ); | 100 | } |
107 | header->addLabel( tr("Th", "Thursday" ) ); | 101 | } |
108 | header->addLabel( tr("Fr", "Friday" ) ); | ||
109 | header->addLabel( tr("Sa", "Saturday" ) ); | ||
110 | } | ||
111 | bFirst = false; | 102 | bFirst = false; |
112 | } else { | 103 | } else { |
113 | // we are change things... | 104 | // we are change things... |
114 | if ( bOnMonday ) { | 105 | if ( bOnMonday ) { |
115 | header->setLabel( 1, tr("Mo", "Monday") ); | 106 | for ( int i = 1; i<=7; i++ ) { |
116 | header->setLabel( 2, tr("Tu", "Tuesday") ); | 107 | header->setLabel( i, Calendar::nameOfDay( i ) ); |
117 | header->setLabel( 3, tr("We", "Wednesday" ) ); | 108 | } |
118 | header->setLabel( 4, tr("Th", "Thursday" ) ); | 109 | |
119 | header->setLabel( 5, tr("Fr", "Friday" ) ); | ||
120 | header->setLabel( 6, tr("Sa", "Saturday" ) ); | ||
121 | header->setLabel( 7, tr("Su", "Sunday" ) ); | ||
122 | } else { | 110 | } else { |
123 | header->setLabel( 1, tr("Su", "Sunday" ) ); | 111 | header->setLabel( 1, Calendar::nameOfDay( 7 ) ); |
124 | header->setLabel( 2, tr("Mo", "Monday") ); | 112 | for ( int i = 1; i<7; i++ ) { |
125 | header->setLabel( 3, tr("Tu", "Tuesday") ); | 113 | header->setLabel( i+1, Calendar::nameOfDay( i ) ); |
126 | header->setLabel( 4, tr("We", "Wednesday" ) ); | 114 | } |
127 | header->setLabel( 5, tr("Th", "Thursday" ) ); | 115 | |
128 | header->setLabel( 6, tr("Fr", "Friday" ) ); | ||
129 | header->setLabel( 7, tr("Sa", "Saturday" ) ); | ||
130 | } | 116 | } |
131 | } | 117 | } |
132 | } | 118 | } |
133 | 119 | ||
134 | 120 | ||
135 | 121 | ||
@@ -399,13 +385,14 @@ void DateBookWeek::keyPressEvent(QKeyEvent *e) | |||
399 | 385 | ||
400 | void DateBookWeek::showDay( int day ) | 386 | void DateBookWeek::showDay( int day ) |
401 | { | 387 | { |
402 | QDate d=bdate; | 388 | QDate d=bdate; |
403 | 389 | ||
404 | // Calculate offset to first day of week. | 390 | // Calculate offset to first day of week. |
405 | int dayoffset=d.dayOfWeek(); | 391 | int dayoffset=d.dayOfWeek() % 7; |
392 | |||
406 | if(bStartOnMonday) dayoffset--; | 393 | if(bStartOnMonday) dayoffset--; |
407 | 394 | ||
408 | day--; | 395 | day--; |
409 | d=d.addDays(day-dayoffset); | 396 | d=d.addDays(day-dayoffset); |
410 | emit showDate( d.year(), d.month(), d.day() ); | 397 | emit showDate( d.year(), d.month(), d.day() ); |
411 | } | 398 | } |
@@ -572,12 +559,14 @@ QDate DateBookWeek::weekDate() const | |||
572 | { | 559 | { |
573 | QDate d=bdate; | 560 | QDate d=bdate; |
574 | 561 | ||
575 | // Calculate offset to first day of week. | 562 | // Calculate offset to first day of week. |
576 | int dayoffset=d.dayOfWeek(); | 563 | int dayoffset=d.dayOfWeek(); |
577 | if(bStartOnMonday) dayoffset--; | 564 | if(bStartOnMonday) dayoffset--; |
565 | else if( dayoffset == 7 ) | ||
566 | dayoffset = 0; | ||
578 | 567 | ||
579 | return d.addDays(-dayoffset); | 568 | return d.addDays(-dayoffset); |
580 | } | 569 | } |
581 | 570 | ||
582 | // this used to only be needed by datebook.cpp, but now we need it inside | 571 | // this used to only be needed by datebook.cpp, but now we need it inside |
583 | // week view since | 572 | // week view since |