summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookweek.cpp
authoreilers <eilers>2003-08-01 14:19:44 (UTC)
committer eilers <eilers>2003-08-01 14:19:44 (UTC)
commit34991bac7d96b1c17601be6a5607819342571e0c (patch) (unidiff)
tree65d0bc2db22bcc1dc1b5eafdafd53b9cb08a6395 /core/pim/datebook/datebookweek.cpp
parent5346424fc26bde232a15aa34fbb720f86218b26f (diff)
downloadopie-34991bac7d96b1c17601be6a5607819342571e0c.zip
opie-34991bac7d96b1c17601be6a5607819342571e0c.tar.gz
opie-34991bac7d96b1c17601be6a5607819342571e0c.tar.bz2
Merging changes from BRANCH_1_0 to HEAD..
Diffstat (limited to 'core/pim/datebook/datebookweek.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweek.cpp65
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
@@ -20,21 +20,14 @@
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
@@ -89,44 +82,37 @@ DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday,
89 82
90void DateBookWeekView::initNames() 83void 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}
@@ -402,7 +388,8 @@ void DateBookWeek::showDay( int day )
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--;
@@ -575,6 +562,8 @@ QDate DateBookWeek::weekDate() const
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}