summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweekheader.ui198
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp64
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.h12
3 files changed, 252 insertions, 22 deletions
diff --git a/core/pim/datebook/datebookweekheader.ui b/core/pim/datebook/datebookweekheader.ui
index f7b20f8..591b625 100644
--- a/core/pim/datebook/datebookweekheader.ui
+++ b/core/pim/datebook/datebookweekheader.ui
@@ -17,52 +17,122 @@
17** 17**
18** Contact info@trolltech.com if any conditions of this licensing are 18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you. 19** not clear to you.
20** 20**
21*********************************************************************</comment> 21*********************************************************************</comment>
22<widget> 22<widget>
23 <class>QWidget</class> 23 <class>QWidget</class>
24 <property stdset="1"> 24 <property stdset="1">
25 <name>name</name> 25 <name>name</name>
26 <cstring>DateBookWeekHeaderBase</cstring> 26 <cstring>DateBookWeekHeaderBase</cstring>
27 </property> 27 </property>
28 <property stdset="1"> 28 <property stdset="1">
29 <name>geometry</name> 29 <name>geometry</name>
30 <rect> 30 <rect>
31 <x>0</x> 31 <x>0</x>
32 <y>0</y> 32 <y>0</y>
33 <width>281</width> 33 <width>249</width>
34 <height>30</height> 34 <height>26</height>
35 </rect> 35 </rect>
36 </property> 36 </property>
37 <property> 37 <property>
38 <name>layoutMargin</name> 38 <name>layoutMargin</name>
39 </property> 39 </property>
40 <property> 40 <property>
41 <name>layoutSpacing</name> 41 <name>layoutSpacing</name>
42 </property> 42 </property>
43 <hbox> 43 <hbox>
44 <property stdset="1"> 44 <property stdset="1">
45 <name>margin</name> 45 <name>margin</name>
46 <number>0</number> 46 <number>0</number>
47 </property> 47 </property>
48 <property stdset="1"> 48 <property stdset="1">
49 <name>spacing</name> 49 <name>spacing</name>
50 <number>6</number> 50 <number>0</number>
51 </property> 51 </property>
52 <widget> 52 <widget>
53 <class>QToolButton</class>
54 <property stdset="1">
55 <name>name</name>
56 <cstring>backmonth</cstring>
57 </property>
58 <property stdset="1">
59 <name>text</name>
60 <string></string>
61 </property>
62 <property stdset="1">
63 <name>pixmap</name>
64 <pixmap></pixmap>
65 </property>
66 <property stdset="1">
67 <name>toggleButton</name>
68 <bool>false</bool>
69 </property>
70 <property stdset="1">
71 <name>autoRepeat</name>
72 <bool>true</bool>
73 </property>
74 <property stdset="1">
75 <name>autoRaise</name>
76 <bool>true</bool>
77 </property>
78 <property stdset="1">
79 <name>toggleButton</name>
80 <bool>false</bool>
81 </property>
82 <property>
83 <name>toolTip</name>
84 <string></string>
85 </property>
86 </widget>
87 <widget>
88 <class>QToolButton</class>
89 <property stdset="1">
90 <name>name</name>
91 <cstring>backweek</cstring>
92 </property>
93 <property stdset="1">
94 <name>text</name>
95 <string></string>
96 </property>
97 <property stdset="1">
98 <name>pixmap</name>
99 <pixmap></pixmap>
100 </property>
101 <property stdset="1">
102 <name>toggleButton</name>
103 <bool>false</bool>
104 </property>
105 <property stdset="1">
106 <name>autoRepeat</name>
107 <bool>true</bool>
108 </property>
109 <property stdset="1">
110 <name>autoRaise</name>
111 <bool>true</bool>
112 </property>
113 <property stdset="1">
114 <name>toggleButton</name>
115 <bool>false</bool>
116 </property>
117 <property>
118 <name>toolTip</name>
119 <string></string>
120 </property>
121 </widget>
122 <widget>
53 <class>QSpinBox</class> 123 <class>QSpinBox</class>
54 <property stdset="1"> 124 <property stdset="1">
55 <name>name</name> 125 <name>name</name>
56 <cstring>spinYear</cstring> 126 <cstring>spinYear</cstring>
57 </property> 127 </property>
58 <property stdset="1"> 128 <property stdset="1">
59 <name>sizePolicy</name> 129 <name>sizePolicy</name>
60 <sizepolicy> 130 <sizepolicy>
61 <hsizetype>0</hsizetype> 131 <hsizetype>0</hsizetype>
62 <vsizetype>0</vsizetype> 132 <vsizetype>0</vsizetype>
63 </sizepolicy> 133 </sizepolicy>
64 </property> 134 </property>
65 <property stdset="1"> 135 <property stdset="1">
66 <name>prefix</name> 136 <name>prefix</name>
67 <string>Y: </string> 137 <string>Y: </string>
68 </property> 138 </property>
@@ -96,68 +166,170 @@
96 <name>prefix</name> 166 <name>prefix</name>
97 <string>W: </string> 167 <string>W: </string>
98 </property> 168 </property>
99 <property stdset="1"> 169 <property stdset="1">
100 <name>maxValue</name> 170 <name>maxValue</name>
101 <number>52</number> 171 <number>52</number>
102 </property> 172 </property>
103 <property stdset="1"> 173 <property stdset="1">
104 <name>minValue</name> 174 <name>minValue</name>
105 <number>1</number> 175 <number>1</number>
106 </property> 176 </property>
107 <property stdset="1"> 177 <property stdset="1">
108 <name>value</name> 178 <name>value</name>
109 <number>1</number> 179 <number>1</number>
110 </property> 180 </property>
111 </widget> 181 </widget>
182 <spacer>
183 <property>
184 <name>name</name>
185 <cstring>Spacer1_1</cstring>
186 </property>
187 <property stdset="1">
188 <name>orientation</name>
189 <enum>Horizontal</enum>
190 </property>
191 <property stdset="1">
192 <name>sizeType</name>
193 <enum>Expanding</enum>
194 </property>
195 <property>
196 <name>sizeHint</name>
197 <size>
198 <width>20</width>
199 <height>20</height>
200 </size>
201 </property>
202 </spacer>
112 <widget> 203 <widget>
113 <class>QLabel</class> 204 <class>QToolButton</class>
114 <property stdset="1"> 205 <property stdset="1">
115 <name>name</name> 206 <name>name</name>
116 <cstring>labelDate</cstring> 207 <cstring>labelDate</cstring>
117 </property> 208 </property>
118 <property stdset="1"> 209 <property stdset="1">
119 <name>sizePolicy</name> 210 <name>sizePolicy</name>
120 <sizepolicy> 211 <sizepolicy>
121 <hsizetype>3</hsizetype> 212 <hsizetype>3</hsizetype>
122 <vsizetype>1</vsizetype> 213 <vsizetype>1</vsizetype>
123 </sizepolicy> 214 </sizepolicy>
124 </property> 215 </property>
125 <property stdset="1"> 216 <property stdset="1">
126 <name>font</name> 217 <name>font</name>
127 <font> 218 <font>
128 <bold>1</bold> 219 <bold>1</bold>
129 </font> 220 </font>
130 </property> 221 </property>
131 <property stdset="1"> 222 <property stdset="1">
132 <name>text</name> 223 <name>text</name>
133 <string>00. Jan-00. Jan</string> 224 <string>00. Jan-00. Jan</string>
134 </property> 225 </property>
226 </widget>
227 <spacer>
228 <property>
229 <name>name</name>
230 <cstring>Spacer1_2</cstring>
231 </property>
232 <property stdset="1">
233 <name>orientation</name>
234 <enum>Horizontal</enum>
235 </property>
135 <property stdset="1"> 236 <property stdset="1">
136 <name>alignment</name> 237 <name>sizeType</name>
137 <set>AlignCenter</set> 238 <enum>Expanding</enum>
138 </property> 239 </property>
139 <property> 240 <property>
140 <name>hAlign</name> 241 <name>sizeHint</name>
242 <size>
243 <width>20</width>
244 <height>20</height>
245 </size>
246 </property>
247 </spacer>
248 <widget>
249 <class>QToolButton</class>
250 <property stdset="1">
251 <name>name</name>
252 <cstring>forwardweek</cstring>
253 </property>
254 <property stdset="1">
255 <name>text</name>
256 <string></string>
257 </property>
258 <property stdset="1">
259 <name>pixmap</name>
260 <pixmap></pixmap>
261 </property>
262 <property stdset="1">
263 <name>autoRepeat</name>
264 <bool>true</bool>
265 </property>
266 <property stdset="1">
267 <name>autoRaise</name>
268 <bool>true</bool>
269 </property>
270 </widget>
271 <widget>
272 <class>QToolButton</class>
273 <property stdset="1">
274 <name>name</name>
275 <cstring>forwardmonth</cstring>
276 </property>
277 <property stdset="1">
278 <name>text</name>
279 <string></string>
280 </property>
281 <property stdset="1">
282 <name>pixmap</name>
283 <pixmap></pixmap>
284 </property>
285 <property stdset="1">
286 <name>autoRepeat</name>
287 <bool>true</bool>
288 </property>
289 <property stdset="1">
290 <name>autoRaise</name>
291 <bool>true</bool>
141 </property> 292 </property>
142 </widget> 293 </widget>
143 </hbox> 294 </hbox>
144</widget> 295</widget>
145<connections> 296<connections>
146 <connection> 297 <connection>
147 <sender>spinYear</sender> 298 <sender>backmonth</sender>
148 <signal>valueChanged(int)</signal> 299 <signal>clicked()</signal>
300 <receiver>DateBookWeekHeaderBase</receiver>
301 <slot>prevMonth()</slot>
302 </connection>
303 <connection>
304 <sender>backweek</sender>
305 <signal>clicked()</signal>
306 <receiver>DateBookWeekHeaderBase</receiver>
307 <slot>prevWeek()</slot>
308 </connection>
309 <connection>
310 <sender>forwardweek</sender>
311 <signal>clicked()</signal>
312 <receiver>DateBookWeekHeaderBase</receiver>
313 <slot>nextWeek()</slot>
314 </connection>
315 <connection>
316 <sender>forwardmonth</sender>
317 <signal>clicked()</signal>
149 <receiver>DateBookWeekHeaderBase</receiver> 318 <receiver>DateBookWeekHeaderBase</receiver>
150 <slot>yearChanged( int )</slot> 319 <slot>nextMonth()</slot>
151 </connection> 320 </connection>
152 <connection> 321 <connection>
153 <sender>spinWeek</sender> 322 <sender>labelDate</sender>
154 <signal>valueChanged(int)</signal> 323 <signal>clicked()</signal>
155 <receiver>DateBookWeekHeaderBase</receiver> 324 <receiver>DateBookWeekHeaderBase</receiver>
156 <slot>weekChanged( int )</slot> 325 <slot>pickDate()</slot>
157 </connection> 326 </connection>
158 <slot access="public">yearChanged( int )</slot> 327 <slot access="public">yearChanged( int )</slot>
159 <slot access="public">nextWeek()</slot> 328 <slot access="public">nextWeek()</slot>
160 <slot access="public">prevWeek()</slot> 329 <slot access="public">prevWeek()</slot>
161 <slot access="public">weekChanged( int )</slot> 330 <slot access="public">weekChanged( int )</slot>
331 <slot access="public">nextMonth()</slot>
332 <slot access="public">prevMonth()</slot>
333 <slot access="public">pickDate()</slot>
162</connections> 334</connections>
163</UI> 335</UI>
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index e7c7208..5f555d5 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -5,104 +5,158 @@
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
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#include "datebookweekheaderimpl.h" 20#include "datebookweekheaderimpl.h"
21#include "datebookweekheader.h"
22#include "datebookweek.h"
21#include <qlabel.h> 23#include <qlabel.h>
22#include <qspinbox.h> 24#include <qspinbox.h>
23#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qpe/resource.h>
27#include <qpe/datebookmonth.h>
28
29#include <qtoolbutton.h>
24 30
25/* 31/*
26 * Constructs a DateBookWeekHeader which is a child of 'parent', with the 32 * Constructs a DateBookWeekHeader which is a child of 'parent', with the
27 * name 'name' and widget flags set to 'f' 33 * name 'name' and widget flags set to 'f'
28 */ 34 */
29DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, 35DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent,
30 const char* name, WFlags fl ) 36 const char* name, WFlags fl )
31 : DateBookWeekHeaderBase( parent, name, fl ), 37 : DateBookWeekHeaderBase( parent, name, fl ),
32 bStartOnMonday( startOnMonday ) 38 bStartOnMonday( startOnMonday )
33{ 39{
34 setBackgroundMode( PaletteButton ); 40 setBackgroundMode( PaletteButton );
35 labelDate->setBackgroundMode( PaletteButton ); 41 labelDate->setBackgroundMode( PaletteButton );
42
43 backmonth->setPixmap( Resource::loadPixmap("fastback") );
44 backweek->setPixmap( Resource::loadPixmap("back") );
45 forwardweek->setPixmap( Resource::loadPixmap("forward") );
46 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
47 spinYear->hide();
48 spinWeek->hide();
36} 49}
37 50
38/* 51/*
39 * Destroys the object and frees any allocated resources 52 * Destroys the object and frees any allocated resources
40 */ 53 */
41DateBookWeekHeader::~DateBookWeekHeader() 54DateBookWeekHeader::~DateBookWeekHeader()
42{ 55{
43 // no need to delete child widgets, Qt does it all for us 56 // no need to delete child widgets, Qt does it all for us
44} 57}
45 58
59void DateBookWeekHeader::pickDate()
60{
61 static QPopupMenu *m1 = 0;
62 static DateBookMonth *picker = 0;
63 QDate currDate = dateFromWeek( week, year, bStartOnMonday );
64 if ( !m1 ) {
65 m1 = new QPopupMenu( this );
66 picker = new DateBookMonth( m1, 0, TRUE );
67 m1->insertItem( picker );
68 connect( picker, SIGNAL( dateClicked( int, int, int ) ),
69 this, SLOT( setDate( int, int, int ) ) );
70 // connect( m1, SIGNAL( aboutToHide() ),
71 // this, SLOT( gotHide() ) );
72 }
73 picker->setDate( currDate.year(), currDate.month(), currDate.day() );
74 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
75 picker->setFocus();
76}
46/* 77/*
47 * public slot 78 * public slot
48 */ 79 */
49void DateBookWeekHeader::yearChanged( int y ) 80void DateBookWeekHeader::yearChanged( int y )
50{ 81{
51 setDate( y, week ); 82 setDate( y, week );
52} 83}
84void DateBookWeekHeader::nextMonth()
85{
86 QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week
87 calcWeek( mydate.addDays(28), week, year, bStartOnMonday ); // Add 4 weeks.
88 setDate( year, week ); // update view
89}
90void DateBookWeekHeader::prevMonth()
91{
92 QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week
93 calcWeek( mydate.addDays(-28), week, year, bStartOnMonday ); // Subtract 4 weeks
94 setDate( year, week ); // update view
95}
53/* 96/*
54 * public slot 97 * public slot
55 */ 98 */
56void DateBookWeekHeader::nextWeek() 99void DateBookWeekHeader::nextWeek()
57{ 100{
58 if ( week < 52 ) 101 QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week
59 week++; 102 calcWeek( mydate.addDays(7), week, year, bStartOnMonday); // Add 1 week
103// if ( week < 52 )
104 //week++;
60 setDate( year, week ); 105 setDate( year, week );
61} 106}
62/* 107/*
63 * public slot 108 * public slot
64 */ 109 */
65void DateBookWeekHeader::prevWeek() 110void DateBookWeekHeader::prevWeek()
66{ 111{
67 if ( week > 1 ) 112 QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week
68 week--; 113 calcWeek( mydate.addDays(-7), week, year, bStartOnMonday); // Add 1 week
114// if ( week > 1 )
115 //week--;
69 setDate( year, week ); 116 setDate( year, week );
70} 117}
71/* 118/*
72 * public slot 119 * public slot
73 */ 120 */
74void DateBookWeekHeader::weekChanged( int w ) 121void DateBookWeekHeader::weekChanged( int w )
75{ 122{
76 setDate( year, w ); 123 setDate( year, w );
77} 124}
78 125
126void DateBookWeekHeader::setDate( int y, int m, int d )
127{
128 calcWeek( QDate(y,m,d), week, year, bStartOnMonday );
129 setDate( year, week );
130}
131
79void DateBookWeekHeader::setDate( int y, int w ) 132void DateBookWeekHeader::setDate( int y, int w )
80{ 133{
81 year = y; 134 year = y;
82 week = w; 135 week = w;
83 spinYear->setValue( y ); 136 spinYear->setValue( y );
84 spinWeek->setValue( w ); 137 spinWeek->setValue( w );
85 138
86 QDate d = dateFromWeek( week, year, bStartOnMonday ); 139 QDate d = dateFromWeek( week, year, bStartOnMonday );
87 140
88 QString s = QString::number( d.day() ) + ". " + d.monthName( d.month() ) 141 QString s = QString::number( d.day() ) + ". " + d.monthName( d.month() )
89 + "-"; 142 + "-";
90 d = d.addDays( 6 ); 143 d = d.addDays( 6 );
91 s += QString::number( d.day() ) + ". " + d.monthName( d.month() ); 144 s += QString::number( d.day() ) + ". " + d.monthName( d.month() );
92 labelDate->setText( s ); 145 s += " ("+tr("week")+":"+QString::number( w )+")";
146 labelDate->setText( s );
93 147
94 emit dateChanged( y, w ); 148 emit dateChanged( y, w );
95} 149}
96 150
97void DateBookWeekHeader::setStartOfWeek( bool onMonday ) 151void DateBookWeekHeader::setStartOfWeek( bool onMonday )
98{ 152{
99 bStartOnMonday = onMonday; 153 bStartOnMonday = onMonday;
100 setDate( year, week ); 154 setDate( year, week );
101} 155}
102 156
103// dateFromWeek 157// dateFromWeek
104// compute the date from the week in the year 158// compute the date from the week in the year
105 159
106QDate dateFromWeek( int week, int year, bool startOnMonday ) 160QDate dateFromWeek( int week, int year, bool startOnMonday )
107{ 161{
108 QDate d; 162 QDate d;
diff --git a/core/pim/datebook/datebookweekheaderimpl.h b/core/pim/datebook/datebookweekheaderimpl.h
index 2abef46..2e5a6ca 100644
--- a/core/pim/datebook/datebookweekheaderimpl.h
+++ b/core/pim/datebook/datebookweekheaderimpl.h
@@ -26,36 +26,40 @@
26class DateBookWeekHeader : public DateBookWeekHeaderBase 26class DateBookWeekHeader : public DateBookWeekHeaderBase
27{ 27{
28 Q_OBJECT 28 Q_OBJECT
29 29
30public: 30public:
31 DateBookWeekHeader( bool startOnMonday, QWidget* parent = 0, 31 DateBookWeekHeader( bool startOnMonday, QWidget* parent = 0,
32 const char* name = 0, WFlags fl = 0 ); 32 const char* name = 0, WFlags fl = 0 );
33 ~DateBookWeekHeader(); 33 ~DateBookWeekHeader();
34 34
35 void setDate( int y, int w ); 35 void setDate( int y, int w );
36 void setStartOfWeek( bool onMonday ); 36 void setStartOfWeek( bool onMonday );
37 37
38signals: 38signals:
39 void dateChanged( int y, int w ); 39 void dateChanged( int y, int w );
40 40
41public slots: 41public slots:
42 void yearChanged( int ); 42 void pickDate();
43 void nextWeek(); 43 void yearChanged( int );
44 void prevWeek(); 44 void nextMonth();
45 void weekChanged( int ); 45 void prevMonth();
46 void nextWeek();
47 void prevWeek();
48 void weekChanged( int );
49 void setDate( int y, int m, int d);
46 50
47protected slots: 51protected slots:
48 void keyPressEvent(QKeyEvent *e) 52 void keyPressEvent(QKeyEvent *e)
49 { 53 {
50 e->ignore(); 54 e->ignore();
51 } 55 }
52 56
53private: 57private:
54 int year, 58 int year,
55 week; 59 week;
56 bool bStartOnMonday; 60 bool bStartOnMonday;
57 61
58}; 62};
59 63
60QDate dateFromWeek( int week, int year, bool startOnMonday ); 64QDate dateFromWeek( int week, int year, bool startOnMonday );
61 65