summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookweekheaderimpl.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/datebookweekheaderimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp93
1 files changed, 26 insertions, 67 deletions
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index 5f555d5..fd792e2 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -34,4 +34,3 @@
34 */ 34 */
35DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, 35DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl )
36 const char* name, WFlags fl )
37 : DateBookWeekHeaderBase( parent, name, fl ), 36 : DateBookWeekHeaderBase( parent, name, fl ),
@@ -41,3 +40,2 @@ DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent,
41 labelDate->setBackgroundMode( PaletteButton ); 40 labelDate->setBackgroundMode( PaletteButton );
42
43 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 41 backmonth->setPixmap( Resource::loadPixmap("fastback") );
@@ -46,4 +44,2 @@ DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent,
46 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 44 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
47 spinYear->hide();
48 spinWeek->hide();
49} 45}
@@ -62,3 +58,2 @@ void DateBookWeekHeader::pickDate()
62 static DateBookMonth *picker = 0; 58 static DateBookMonth *picker = 0;
63 QDate currDate = dateFromWeek( week, year, bStartOnMonday );
64 if ( !m1 ) { 59 if ( !m1 ) {
@@ -67,8 +62,6 @@ void DateBookWeekHeader::pickDate()
67 m1->insertItem( picker ); 62 m1->insertItem( picker );
68 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 63 connect( picker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( setDate( int, int, int ) ) );
69 this, SLOT( setDate( int, int, int ) ) ); 64 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) );
70 // connect( m1, SIGNAL( aboutToHide() ),
71 // this, SLOT( gotHide() ) );
72 } 65 }
73 picker->setDate( currDate.year(), currDate.month(), currDate.day() ); 66 picker->setDate( date.year(), date.month(), date.day() );
74 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 67 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
@@ -76,14 +69,6 @@ void DateBookWeekHeader::pickDate()
76} 69}
77/* 70
78 * public slot
79 */
80void DateBookWeekHeader::yearChanged( int y )
81{
82 setDate( y, week );
83}
84void DateBookWeekHeader::nextMonth() 71void DateBookWeekHeader::nextMonth()
85{ 72{
86 QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week 73 setDate(date.addDays(28));
87 calcWeek( mydate.addDays(28), week, year, bStartOnMonday ); // Add 4 weeks.
88 setDate( year, week ); // update view
89} 74}
@@ -91,34 +76,11 @@ void DateBookWeekHeader::prevMonth()
91{ 76{
92 QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week 77 setDate(date.addDays(-28));
93 calcWeek( mydate.addDays(-28), week, year, bStartOnMonday ); // Subtract 4 weeks
94 setDate( year, week ); // update view
95} 78}
96/*
97 * public slot
98 */
99void DateBookWeekHeader::nextWeek() 79void DateBookWeekHeader::nextWeek()
100{ 80{
101 QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week 81 setDate(date.addDays(7));
102 calcWeek( mydate.addDays(7), week, year, bStartOnMonday); // Add 1 week
103// if ( week < 52 )
104 //week++;
105 setDate( year, week );
106} 82}
107/*
108 * public slot
109 */
110void DateBookWeekHeader::prevWeek() 83void DateBookWeekHeader::prevWeek()
111{ 84{
112 QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week 85 setDate(date.addDays(-7));
113 calcWeek( mydate.addDays(-7), week, year, bStartOnMonday); // Add 1 week
114// if ( week > 1 )
115 //week--;
116 setDate( year, week );
117}
118/*
119 * public slot
120 */
121void DateBookWeekHeader::weekChanged( int w )
122{
123 setDate( year, w );
124} 86}
@@ -127,23 +89,21 @@ void DateBookWeekHeader::setDate( int y, int m, int d )
127{ 89{
128 calcWeek( QDate(y,m,d), week, year, bStartOnMonday ); 90 setDate(QDate(y,m,d));
129 setDate( year, week );
130} 91}
131 92
132void DateBookWeekHeader::setDate( int y, int w ) 93void DateBookWeekHeader::setDate(const QDate &d) {
133{ 94 int year,week,dayofweek;
134 year = y; 95 date=d;
135 week = w; 96 dayofweek=d.dayOfWeek();
136 spinYear->setValue( y ); 97 if(bStartOnMonday) dayofweek--;
137 spinWeek->setValue( w ); 98 date=date.addDays(-dayofweek);
138
139 QDate d = dateFromWeek( week, year, bStartOnMonday );
140 99
141 QString s = QString::number( d.day() ) + ". " + d.monthName( d.month() ) 100 calcWeek(date,week,year,bStartOnMonday);
142 + "-"; 101 QDate start=date;
143 d = d.addDays( 6 ); 102 QDate stop=start.addDays(6);
144 s += QString::number( d.day() ) + ". " + d.monthName( d.month() ); 103 labelDate->setText( QString::number(start.day()) + "." +
145 s += " ("+tr("week")+":"+QString::number( w )+")"; 104 start.monthName(start.month()) + "-" +
146 labelDate->setText( s ); 105 QString::number(stop.day()) + "." +
147 106 start.monthName(stop.month()) +" ("+
148 emit dateChanged( y, w ); 107 tr("w")+":"+QString::number( week ) +")");
108 emit dateChanged(year,week);
149} 109}
@@ -153,3 +113,3 @@ void DateBookWeekHeader::setStartOfWeek( bool onMonday )
153 bStartOnMonday = onMonday; 113 bStartOnMonday = onMonday;
154 setDate( year, week ); 114 setDate( date );
155} 115}
@@ -158,3 +118,2 @@ void DateBookWeekHeader::setStartOfWeek( bool onMonday )
158// compute the date from the week in the year 118// compute the date from the week in the year
159
160QDate dateFromWeek( int week, int year, bool startOnMonday ) 119QDate dateFromWeek( int week, int year, bool startOnMonday )