summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2003-03-25 23:44:32 (UTC)
committer umopapisdn <umopapisdn>2003-03-25 23:44:32 (UTC)
commitc98faafefdf2e9b9e16dcf2b1d57525f38282296 (patch) (unidiff)
tree75a6bc72f13ee81b86c368517aba3496b2c7e800
parentaca404f0c049c5b1bace7e842e7e64b987f04616 (diff)
downloadopie-c98faafefdf2e9b9e16dcf2b1d57525f38282296.zip
opie-c98faafefdf2e9b9e16dcf2b1d57525f38282296.tar.gz
opie-c98faafefdf2e9b9e16dcf2b1d57525f38282296.tar.bz2
Revamped the userinterface of the header for weekview to look more like the other views.
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
@@ -30,8 +30,8 @@
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>
@@ -47,9 +47,79 @@
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>
@@ -109,8 +179,29 @@
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>
@@ -132,32 +223,113 @@
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
@@ -18,9 +18,15 @@
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
@@ -33,6 +39,13 @@ DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent,
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/*
@@ -43,6 +56,24 @@ DateBookWeekHeader::~DateBookWeekHeader()
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 */
@@ -50,13 +81,27 @@ void 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/*
@@ -64,8 +109,10 @@ void DateBookWeekHeader::nextWeek()
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/*
@@ -76,6 +123,12 @@ void DateBookWeekHeader::weekChanged( int w )
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;
@@ -89,7 +142,8 @@ void DateBookWeekHeader::setDate( int y, int w )
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}
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
@@ -39,10 +39,14 @@ signals:
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)