author | alwin <alwin> | 2005-03-20 18:29:19 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-20 18:29:19 (UTC) |
commit | ee29d99e2af9837b61ece67ebb54f2cbdfc50732 (patch) (unidiff) | |
tree | 34642ff35645ec9cd4fa182ca9d35d7c2739210b /library | |
parent | d330608d5c2713f8bde051b91382d0e0e54317ba (diff) | |
download | opie-ee29d99e2af9837b61ece67ebb54f2cbdfc50732.zip opie-ee29d99e2af9837b61ece67ebb54f2cbdfc50732.tar.gz opie-ee29d99e2af9837b61ece67ebb54f2cbdfc50732.tar.bz2 |
made monthview colors a little bit darker so them will visible on bright
displays
-rw-r--r-- | library/datebookmonth.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/library/datebookmonth.cpp b/library/datebookmonth.cpp index 013ab66..2616b7b 100644 --- a/library/datebookmonth.cpp +++ b/library/datebookmonth.cpp | |||
@@ -1,287 +1,290 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
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 "config.h" | 20 | #include "config.h" |
21 | #include "datebookmonth.h" | 21 | #include "datebookmonth.h" |
22 | #include "datebookdb.h" | 22 | #include "datebookdb.h" |
23 | #include "resource.h" | 23 | #include "resource.h" |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | 25 | ||
26 | #include <qtoolbutton.h> | 26 | #include <qtoolbutton.h> |
27 | #include <qspinbox.h> | 27 | #include <qspinbox.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qvaluestack.h> | 29 | #include <qvaluestack.h> |
30 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
31 | 31 | ||
32 | static const QColor s_colorNormalLight = QColor(255, 150, 150); | ||
33 | static const QColor s_colorRepeatLight = QColor(150, 150, 255); | ||
34 | static const QColor s_colorHolidayLight= QColor(150, 255, 150); | ||
32 | 35 | ||
33 | DateBookMonthHeader::DateBookMonthHeader( QWidget *parent, const char *name ) | 36 | DateBookMonthHeader::DateBookMonthHeader( QWidget *parent, const char *name ) |
34 | : QHBox( parent, name ) | 37 | : QHBox( parent, name ) |
35 | { | 38 | { |
36 | setBackgroundMode( PaletteButton ); | 39 | setBackgroundMode( PaletteButton ); |
37 | 40 | ||
38 | begin = new QToolButton( this ); | 41 | begin = new QToolButton( this ); |
39 | begin->setFocusPolicy(NoFocus); | 42 | begin->setFocusPolicy(NoFocus); |
40 | begin->setPixmap( Resource::loadPixmap( "start" ) ); | 43 | begin->setPixmap( Resource::loadPixmap( "start" ) ); |
41 | begin->setAutoRaise( TRUE ); | 44 | begin->setAutoRaise( TRUE ); |
42 | begin->setFixedSize( begin->sizeHint() ); | 45 | begin->setFixedSize( begin->sizeHint() ); |
43 | QWhatsThis::add( begin, tr("Show January in the selected year") ); | 46 | QWhatsThis::add( begin, tr("Show January in the selected year") ); |
44 | 47 | ||
45 | back = new QToolButton( this ); | 48 | back = new QToolButton( this ); |
46 | back->setFocusPolicy(NoFocus); | 49 | back->setFocusPolicy(NoFocus); |
47 | back->setPixmap( Resource::loadPixmap( "back" ) ); | 50 | back->setPixmap( Resource::loadPixmap( "back" ) ); |
48 | back->setAutoRaise( TRUE ); | 51 | back->setAutoRaise( TRUE ); |
49 | back->setFixedSize( back->sizeHint() ); | 52 | back->setFixedSize( back->sizeHint() ); |
50 | QWhatsThis::add( back, tr("Show the previous month") ); | 53 | QWhatsThis::add( back, tr("Show the previous month") ); |
51 | 54 | ||
52 | month = new QComboBox( FALSE, this ); | 55 | month = new QComboBox( FALSE, this ); |
53 | for ( int i = 0; i < 12; ++i ) | 56 | for ( int i = 0; i < 12; ++i ) |
54 | month->insertItem( Calendar::nameOfMonth( i + 1 ) ); | 57 | month->insertItem( Calendar::nameOfMonth( i + 1 ) ); |
55 | 58 | ||
56 | year = new QSpinBox( 1752, 8000, 1, this ); | 59 | year = new QSpinBox( 1752, 8000, 1, this ); |
57 | 60 | ||
58 | next = new QToolButton( this ); | 61 | next = new QToolButton( this ); |
59 | next->setFocusPolicy(NoFocus); | 62 | next->setFocusPolicy(NoFocus); |
60 | next->setPixmap( Resource::loadPixmap( "forward" ) ); | 63 | next->setPixmap( Resource::loadPixmap( "forward" ) ); |
61 | next->setAutoRaise( TRUE ); | 64 | next->setAutoRaise( TRUE ); |
62 | next->setFixedSize( next->sizeHint() ); | 65 | next->setFixedSize( next->sizeHint() ); |
63 | QWhatsThis::add( next, tr("Show the next month") ); | 66 | QWhatsThis::add( next, tr("Show the next month") ); |
64 | 67 | ||
65 | end = new QToolButton( this ); | 68 | end = new QToolButton( this ); |
66 | end->setFocusPolicy(NoFocus); | 69 | end->setFocusPolicy(NoFocus); |
67 | end->setPixmap( Resource::loadPixmap( "finish" ) ); | 70 | end->setPixmap( Resource::loadPixmap( "finish" ) ); |
68 | end->setAutoRaise( TRUE ); | 71 | end->setAutoRaise( TRUE ); |
69 | end->setFixedSize( end->sizeHint() ); | 72 | end->setFixedSize( end->sizeHint() ); |
70 | QWhatsThis::add( end, tr("Show December in the selected year") ); | 73 | QWhatsThis::add( end, tr("Show December in the selected year") ); |
71 | 74 | ||
72 | connect( month, SIGNAL( activated(int) ), | 75 | connect( month, SIGNAL( activated(int) ), |
73 | this, SLOT( updateDate() ) ); | 76 | this, SLOT( updateDate() ) ); |
74 | connect( year, SIGNAL( valueChanged(int) ), | 77 | connect( year, SIGNAL( valueChanged(int) ), |
75 | this, SLOT( updateDate() ) ); | 78 | this, SLOT( updateDate() ) ); |
76 | connect( begin, SIGNAL( clicked() ), | 79 | connect( begin, SIGNAL( clicked() ), |
77 | this, SLOT( firstMonth() ) ); | 80 | this, SLOT( firstMonth() ) ); |
78 | connect( end, SIGNAL( clicked() ), | 81 | connect( end, SIGNAL( clicked() ), |
79 | this, SLOT( lastMonth() ) ); | 82 | this, SLOT( lastMonth() ) ); |
80 | connect( back, SIGNAL( clicked() ), | 83 | connect( back, SIGNAL( clicked() ), |
81 | this, SLOT( monthBack() ) ); | 84 | this, SLOT( monthBack() ) ); |
82 | connect( next, SIGNAL( clicked() ), | 85 | connect( next, SIGNAL( clicked() ), |
83 | this, SLOT( monthForward() ) ); | 86 | this, SLOT( monthForward() ) ); |
84 | back->setAutoRepeat( TRUE ); | 87 | back->setAutoRepeat( TRUE ); |
85 | next->setAutoRepeat( TRUE ); | 88 | next->setAutoRepeat( TRUE ); |
86 | } | 89 | } |
87 | 90 | ||
88 | 91 | ||
89 | DateBookMonthHeader::~DateBookMonthHeader() | 92 | DateBookMonthHeader::~DateBookMonthHeader() |
90 | { | 93 | { |
91 | 94 | ||
92 | } | 95 | } |
93 | 96 | ||
94 | void DateBookMonthHeader::updateDate() | 97 | void DateBookMonthHeader::updateDate() |
95 | { | 98 | { |
96 | emit dateChanged( year->value(), month->currentItem() + 1 ); | 99 | emit dateChanged( year->value(), month->currentItem() + 1 ); |
97 | } | 100 | } |
98 | 101 | ||
99 | void DateBookMonthHeader::firstMonth() | 102 | void DateBookMonthHeader::firstMonth() |
100 | { | 103 | { |
101 | emit dateChanged( year->value(), 1 ); | 104 | emit dateChanged( year->value(), 1 ); |
102 | month->setCurrentItem( 0 ); | 105 | month->setCurrentItem( 0 ); |
103 | } | 106 | } |
104 | 107 | ||
105 | void DateBookMonthHeader::lastMonth() | 108 | void DateBookMonthHeader::lastMonth() |
106 | { | 109 | { |
107 | emit dateChanged( year->value(), 12 ); | 110 | emit dateChanged( year->value(), 12 ); |
108 | month->setCurrentItem( 11 ); | 111 | month->setCurrentItem( 11 ); |
109 | } | 112 | } |
110 | 113 | ||
111 | void DateBookMonthHeader::monthBack() | 114 | void DateBookMonthHeader::monthBack() |
112 | { | 115 | { |
113 | if ( month->currentItem() > 0 ) { | 116 | if ( month->currentItem() > 0 ) { |
114 | emit dateChanged( year->value(), month->currentItem() ); | 117 | emit dateChanged( year->value(), month->currentItem() ); |
115 | month->setCurrentItem( month->currentItem() - 1 ); | 118 | month->setCurrentItem( month->currentItem() - 1 ); |
116 | } else { | 119 | } else { |
117 | emit dateChanged( year->value() - 1, 12 ); | 120 | emit dateChanged( year->value() - 1, 12 ); |
118 | // we have a signal set to a changed value in year so we only need to change | 121 | // we have a signal set to a changed value in year so we only need to change |
119 | // year to get the result... | 122 | // year to get the result... |
120 | month->setCurrentItem( 11 ); | 123 | month->setCurrentItem( 11 ); |
121 | year->setValue( year->value() - 1 ); | 124 | year->setValue( year->value() - 1 ); |
122 | } | 125 | } |
123 | } | 126 | } |
124 | 127 | ||
125 | void DateBookMonthHeader::monthForward() | 128 | void DateBookMonthHeader::monthForward() |
126 | { | 129 | { |
127 | if ( month->currentItem() < 11 ) { | 130 | if ( month->currentItem() < 11 ) { |
128 | emit dateChanged( year->value(), month->currentItem() + 2 ); | 131 | emit dateChanged( year->value(), month->currentItem() + 2 ); |
129 | month->setCurrentItem( month->currentItem() + 1 ); | 132 | month->setCurrentItem( month->currentItem() + 1 ); |
130 | } else { | 133 | } else { |
131 | // we have a signal set to a changed value in year so we only need to change | 134 | // we have a signal set to a changed value in year so we only need to change |
132 | // year to get the result... | 135 | // year to get the result... |
133 | month->setCurrentItem( 0 ); | 136 | month->setCurrentItem( 0 ); |
134 | year->setValue( year->value() + 1 ); | 137 | year->setValue( year->value() + 1 ); |
135 | } | 138 | } |
136 | } | 139 | } |
137 | 140 | ||
138 | void DateBookMonthHeader::setDate( int y, int m ) | 141 | void DateBookMonthHeader::setDate( int y, int m ) |
139 | { | 142 | { |
140 | year->setValue( y ); | 143 | year->setValue( y ); |
141 | month->setCurrentItem( m - 1 ); | 144 | month->setCurrentItem( m - 1 ); |
142 | } | 145 | } |
143 | 146 | ||
144 | //--------------------------------------------------------------------------- | 147 | //--------------------------------------------------------------------------- |
145 | 148 | ||
146 | class DateBookMonthTablePrivate | 149 | class DateBookMonthTablePrivate |
147 | { | 150 | { |
148 | public: | 151 | public: |
149 | DateBookMonthTablePrivate() {}; | 152 | DateBookMonthTablePrivate() {}; |
150 | ~DateBookMonthTablePrivate() { mMonthEvents.clear(); }; | 153 | ~DateBookMonthTablePrivate() { mMonthEvents.clear(); }; |
151 | 154 | ||
152 | QValueList<EffectiveEvent> mMonthEvents; | 155 | QValueList<EffectiveEvent> mMonthEvents; |
153 | bool onMonday; | 156 | bool onMonday; |
154 | }; | 157 | }; |
155 | 158 | ||
156 | DateBookMonthTable::DateBookMonthTable( QWidget *parent, const char *name, | 159 | DateBookMonthTable::DateBookMonthTable( QWidget *parent, const char *name, |
157 | DateBookDB *newDb ) | 160 | DateBookDB *newDb ) |
158 | : QTable( 6, 7, parent, name ), | 161 | : QTable( 6, 7, parent, name ), |
159 | db( newDb ) | 162 | db( newDb ) |
160 | { | 163 | { |
161 | d = new DateBookMonthTablePrivate(); | 164 | d = new DateBookMonthTablePrivate(); |
162 | selYear = -1; | 165 | selYear = -1; |
163 | selMonth = -1; | 166 | selMonth = -1; |
164 | selDay = -1; | 167 | selDay = -1; |
165 | 168 | ||
166 | /* init these as well make valgrind happy and be consistent with Qtopia1.6 -zecke */ | 169 | /* init these as well make valgrind happy and be consistent with Qtopia1.6 -zecke */ |
167 | year = -1; | 170 | year = -1; |
168 | month = -1; | 171 | month = -1; |
169 | day = -1; | 172 | day = -1; |
170 | 173 | ||
171 | Config cfg( "qpe" ); | 174 | Config cfg( "qpe" ); |
172 | cfg.setGroup( "Time" ); | 175 | cfg.setGroup( "Time" ); |
173 | d->onMonday = cfg.readBoolEntry( "MONDAY" ); | 176 | d->onMonday = cfg.readBoolEntry( "MONDAY" ); |
174 | 177 | ||
175 | horizontalHeader()->setResizeEnabled( FALSE ); | 178 | horizontalHeader()->setResizeEnabled( FALSE ); |
176 | // we have to do this here... or suffer the consequences later... | 179 | // we have to do this here... or suffer the consequences later... |
177 | for ( int i = 0; i < 7; i++ ){ | 180 | for ( int i = 0; i < 7; i++ ){ |
178 | horizontalHeader()->resizeSection( i, 30 ); | 181 | horizontalHeader()->resizeSection( i, 30 ); |
179 | setColumnStretchable( i, TRUE ); | 182 | setColumnStretchable( i, TRUE ); |
180 | } | 183 | } |
181 | setupLabels(); | 184 | setupLabels(); |
182 | 185 | ||
183 | verticalHeader()->hide(); | 186 | verticalHeader()->hide(); |
184 | setLeftMargin( 0 ); | 187 | setLeftMargin( 0 ); |
185 | for ( int i = 0; i < 6; ++i ) | 188 | for ( int i = 0; i < 6; ++i ) |
186 | setRowStretchable( i, TRUE ); | 189 | setRowStretchable( i, TRUE ); |
187 | 190 | ||
188 | setSelectionMode( NoSelection ); | 191 | setSelectionMode( NoSelection ); |
189 | 192 | ||
190 | connect( this, SIGNAL( clicked(int,int,int,const QPoint&) ), | 193 | connect( this, SIGNAL( clicked(int,int,int,const QPoint&) ), |
191 | this, SLOT( dayClicked(int,int) ) ); | 194 | this, SLOT( dayClicked(int,int) ) ); |
192 | connect( this, SIGNAL( currentChanged(int,int) ), | 195 | connect( this, SIGNAL( currentChanged(int,int) ), |
193 | this, SLOT( dragDay(int,int) ) ); | 196 | this, SLOT( dragDay(int,int) ) ); |
194 | setVScrollBarMode( AlwaysOff ); | 197 | setVScrollBarMode( AlwaysOff ); |
195 | setHScrollBarMode( AlwaysOff ); | 198 | setHScrollBarMode( AlwaysOff ); |
196 | } | 199 | } |
197 | 200 | ||
198 | DateBookMonthTable::~DateBookMonthTable() | 201 | DateBookMonthTable::~DateBookMonthTable() |
199 | { | 202 | { |
200 | monthsEvents.clear(); | 203 | monthsEvents.clear(); |
201 | delete d; | 204 | delete d; |
202 | } | 205 | } |
203 | 206 | ||
204 | void DateBookMonthTable::setDate(int y, int m, int d) | 207 | void DateBookMonthTable::setDate(int y, int m, int d) |
205 | { | 208 | { |
206 | if (month == m && year == y) { | 209 | if (month == m && year == y) { |
207 | if ( selYear == -1 ) | 210 | if ( selYear == -1 ) |
208 | year = selYear; | 211 | year = selYear; |
209 | if ( selMonth == -1 ) | 212 | if ( selMonth == -1 ) |
210 | month = selMonth; | 213 | month = selMonth; |
211 | int r1, c1, r2, c2; | 214 | int r1, c1, r2, c2; |
212 | findDay(selDay, r1, c1); | 215 | findDay(selDay, r1, c1); |
213 | selDay = day = d; | 216 | selDay = day = d; |
214 | findDay(selDay, r2, c2); | 217 | findDay(selDay, r2, c2); |
215 | setCurrentCell( r2, c2 ); | 218 | setCurrentCell( r2, c2 ); |
216 | //updateCell(r1,c1); | 219 | //updateCell(r1,c1); |
217 | //updateCell(r2,c2); | 220 | //updateCell(r2,c2); |
218 | } else { | 221 | } else { |
219 | selYear = year = y; | 222 | selYear = year = y; |
220 | selMonth = month = m; | 223 | selMonth = month = m; |
221 | selDay = day = d; | 224 | selDay = day = d; |
222 | setupTable(); | 225 | setupTable(); |
223 | } | 226 | } |
224 | } | 227 | } |
225 | 228 | ||
226 | void DateBookMonthTable::redraw() | 229 | void DateBookMonthTable::redraw() |
227 | { | 230 | { |
228 | setupLabels(); | 231 | setupLabels(); |
229 | setupTable(); | 232 | setupTable(); |
230 | } | 233 | } |
231 | 234 | ||
232 | void DateBookMonthTable::setWeekStart( bool onMonday ) | 235 | void DateBookMonthTable::setWeekStart( bool onMonday ) |
233 | { | 236 | { |
234 | d->onMonday = onMonday; | 237 | d->onMonday = onMonday; |
235 | setupLabels(); | 238 | setupLabels(); |
236 | setupTable(); | 239 | setupTable(); |
237 | } | 240 | } |
238 | 241 | ||
239 | void DateBookMonthTable::setupTable() | 242 | void DateBookMonthTable::setupTable() |
240 | { | 243 | { |
241 | QValueList<Calendar::Day> days = Calendar::daysOfMonth( year, month, d->onMonday ); | 244 | QValueList<Calendar::Day> days = Calendar::daysOfMonth( year, month, d->onMonday ); |
242 | QValueList<Calendar::Day>::Iterator it = days.begin(); | 245 | QValueList<Calendar::Day>::Iterator it = days.begin(); |
243 | int row = 0, col = 0; | 246 | int row = 0, col = 0; |
244 | int crow = 0; | 247 | int crow = 0; |
245 | int ccol = 0; | 248 | int ccol = 0; |
246 | for ( ; it != days.end(); ++it ) { | 249 | for ( ; it != days.end(); ++it ) { |
247 | DayItemMonth *i = (DayItemMonth *)item( row, col ); | 250 | DayItemMonth *i = (DayItemMonth *)item( row, col ); |
248 | if ( !i ) { | 251 | if ( !i ) { |
249 | i = new DayItemMonth( this, QTableItem::Never, "" ); | 252 | i = new DayItemMonth( this, QTableItem::Never, "" ); |
250 | setItem( row, col, i ); | 253 | setItem( row, col, i ); |
251 | } | 254 | } |
252 | Calendar::Day calDay = *it; | 255 | Calendar::Day calDay = *it; |
253 | i->clearEffEvents(); | 256 | i->clearEffEvents(); |
254 | i->setDay( calDay.date ); | 257 | i->setDay( calDay.date ); |
255 | i->setType( calDay.type ); | 258 | i->setType( calDay.type ); |
256 | if ( i->day() == day && calDay.type == Calendar::Day::ThisMonth ) { | 259 | if ( i->day() == day && calDay.type == Calendar::Day::ThisMonth ) { |
257 | crow = row; | 260 | crow = row; |
258 | ccol = col; | 261 | ccol = col; |
259 | } | 262 | } |
260 | 263 | ||
261 | updateCell( row, col ); | 264 | updateCell( row, col ); |
262 | 265 | ||
263 | if ( col == 6 ) { | 266 | if ( col == 6 ) { |
264 | ++row; | 267 | ++row; |
265 | col = 0; | 268 | col = 0; |
266 | } else { | 269 | } else { |
267 | ++col; | 270 | ++col; |
268 | } | 271 | } |
269 | } | 272 | } |
270 | setCurrentCell( crow, ccol ); | 273 | setCurrentCell( crow, ccol ); |
271 | getEvents(); | 274 | getEvents(); |
272 | } | 275 | } |
273 | 276 | ||
274 | void DateBookMonthTable::findDay( int day, int &row, int &col ) | 277 | void DateBookMonthTable::findDay( int day, int &row, int &col ) |
275 | { | 278 | { |
276 | QDate dtBegin( year, month, 1 ); | 279 | QDate dtBegin( year, month, 1 ); |
277 | int skips = dtBegin.dayOfWeek(); | 280 | int skips = dtBegin.dayOfWeek(); |
278 | int effective_day = day + skips - 1; // row/columns begin at 0 | 281 | int effective_day = day + skips - 1; // row/columns begin at 0 |
279 | // make an extra adjustment if we start on Mondays. | 282 | // make an extra adjustment if we start on Mondays. |
280 | if ( d->onMonday ) | 283 | if ( d->onMonday ) |
281 | effective_day--; | 284 | effective_day--; |
282 | row = effective_day / 7; | 285 | row = effective_day / 7; |
283 | col = effective_day % 7; | 286 | col = effective_day % 7; |
284 | } | 287 | } |
285 | 288 | ||
286 | void DateBookMonthTable::dayClicked( int row, int col ) | 289 | void DateBookMonthTable::dayClicked( int row, int col ) |
287 | { | 290 | { |
@@ -357,417 +360,417 @@ void DateBookMonthTable::getEvents() | |||
357 | updateCell( row, col ); | 360 | updateCell( row, col ); |
358 | dayEvent.clear(); | 361 | dayEvent.clear(); |
359 | } | 362 | } |
360 | } | 363 | } |
361 | 364 | ||
362 | 365 | ||
363 | void DateBookMonthTable::setupLabels() | 366 | void DateBookMonthTable::setupLabels() |
364 | { | 367 | { |
365 | for ( int i = 0; i < 7; ++i ) { | 368 | for ( int i = 0; i < 7; ++i ) { |
366 | // horizontalHeader()->resizeSection( i, 30 ); | 369 | // horizontalHeader()->resizeSection( i, 30 ); |
367 | // setColumnStretchable( i, TRUE ); | 370 | // setColumnStretchable( i, TRUE ); |
368 | if ( d->onMonday ) | 371 | if ( d->onMonday ) |
369 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i + 1 ) ); | 372 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i + 1 ) ); |
370 | else { | 373 | else { |
371 | if ( i == 0 ) | 374 | if ( i == 0 ) |
372 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( 7 ) ); | 375 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( 7 ) ); |
373 | else | 376 | else |
374 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i ) ); | 377 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i ) ); |
375 | } | 378 | } |
376 | } | 379 | } |
377 | } | 380 | } |
378 | 381 | ||
379 | 382 | ||
380 | //--------------------------------------------------------------------------- | 383 | //--------------------------------------------------------------------------- |
381 | 384 | ||
382 | DateBookMonth::DateBookMonth( QWidget *parent, const char *name, bool ac, | 385 | DateBookMonth::DateBookMonth( QWidget *parent, const char *name, bool ac, |
383 | DateBookDB *data ) | 386 | DateBookDB *data ) |
384 | : QVBox( parent, name ), | 387 | : QVBox( parent, name ), |
385 | autoClose( ac ) | 388 | autoClose( ac ) |
386 | { | 389 | { |
387 | setFocusPolicy(StrongFocus); | 390 | setFocusPolicy(StrongFocus); |
388 | year = QDate::currentDate().year(); | 391 | year = QDate::currentDate().year(); |
389 | month = QDate::currentDate().month(); | 392 | month = QDate::currentDate().month(); |
390 | day = QDate::currentDate().day(); | 393 | day = QDate::currentDate().day(); |
391 | header = new DateBookMonthHeader( this, "DateBookMonthHeader" ); | 394 | header = new DateBookMonthHeader( this, "DateBookMonthHeader" ); |
392 | table = new DateBookMonthTable( this, "DateBookMonthTable", data ); | 395 | table = new DateBookMonthTable( this, "DateBookMonthTable", data ); |
393 | header->setDate( year, month ); | 396 | header->setDate( year, month ); |
394 | table->setDate( year, month, QDate::currentDate().day() ); | 397 | table->setDate( year, month, QDate::currentDate().day() ); |
395 | header->setFocusPolicy(NoFocus); | 398 | header->setFocusPolicy(NoFocus); |
396 | table->setFocusPolicy(NoFocus); | 399 | table->setFocusPolicy(NoFocus); |
397 | connect( header, SIGNAL( dateChanged(int,int) ), | 400 | connect( header, SIGNAL( dateChanged(int,int) ), |
398 | this, SLOT( setDate(int,int) ) ); | 401 | this, SLOT( setDate(int,int) ) ); |
399 | connect( table, SIGNAL( dateClicked(int,int,int) ), | 402 | connect( table, SIGNAL( dateClicked(int,int,int) ), |
400 | this, SLOT( finalDate(int,int,int) ) ); | 403 | this, SLOT( finalDate(int,int,int) ) ); |
401 | connect( qApp, SIGNAL(weekChanged(bool)), this, | 404 | connect( qApp, SIGNAL(weekChanged(bool)), this, |
402 | SLOT(slotWeekChange(bool)) ); | 405 | SLOT(slotWeekChange(bool)) ); |
403 | table->setFocus(); | 406 | table->setFocus(); |
404 | } | 407 | } |
405 | 408 | ||
406 | DateBookMonth::~DateBookMonth() | 409 | DateBookMonth::~DateBookMonth() |
407 | { | 410 | { |
408 | 411 | ||
409 | } | 412 | } |
410 | 413 | ||
411 | void DateBookMonth::setDate( int y, int m ) | 414 | void DateBookMonth::setDate( int y, int m ) |
412 | { | 415 | { |
413 | /* only change the date if this is a different date, | 416 | /* only change the date if this is a different date, |
414 | * other wise we may mistakenly overide the day */ | 417 | * other wise we may mistakenly overide the day */ |
415 | if ( (y != year) || (m != month) ) { | 418 | if ( (y != year) || (m != month) ) { |
416 | year = y; | 419 | year = y; |
417 | month = m; | 420 | month = m; |
418 | QDate nd( y, m, 1 ); | 421 | QDate nd( y, m, 1 ); |
419 | if ( nd.daysInMonth() < day ) | 422 | if ( nd.daysInMonth() < day ) |
420 | day = nd.daysInMonth(); | 423 | day = nd.daysInMonth(); |
421 | table->setDate( year, month, day ); | 424 | table->setDate( year, month, day ); |
422 | } | 425 | } |
423 | } | 426 | } |
424 | 427 | ||
425 | void DateBookMonth::setDate( int y, int m, int d ) | 428 | void DateBookMonth::setDate( int y, int m, int d ) |
426 | { | 429 | { |
427 | header->setDate( y, m); | 430 | header->setDate( y, m); |
428 | table->setDate( y, m, d); | 431 | table->setDate( y, m, d); |
429 | year = y; | 432 | year = y; |
430 | month = m; | 433 | month = m; |
431 | day = d; | 434 | day = d; |
432 | } | 435 | } |
433 | 436 | ||
434 | /* called when we wish to close or pass back the date */ | 437 | /* called when we wish to close or pass back the date */ |
435 | void DateBookMonth::finalDate(int y, int m, int d) | 438 | void DateBookMonth::finalDate(int y, int m, int d) |
436 | { | 439 | { |
437 | setDate( y, m, d ); | 440 | setDate( y, m, d ); |
438 | 441 | ||
439 | emit dateClicked(y, m, d); | 442 | emit dateClicked(y, m, d); |
440 | // emit dateClicked(QDate(y, m, d).toString()); | 443 | // emit dateClicked(QDate(y, m, d).toString()); |
441 | 444 | ||
442 | if ( autoClose && parentWidget() ) | 445 | if ( autoClose && parentWidget() ) |
443 | parentWidget()->close(); | 446 | parentWidget()->close(); |
444 | } | 447 | } |
445 | 448 | ||
446 | void DateBookMonth::setDate( QDate d) | 449 | void DateBookMonth::setDate( QDate d) |
447 | { | 450 | { |
448 | setDate(d.year(), d.month(), d.day()); | 451 | setDate(d.year(), d.month(), d.day()); |
449 | } | 452 | } |
450 | 453 | ||
451 | void DateBookMonth::redraw() | 454 | void DateBookMonth::redraw() |
452 | { | 455 | { |
453 | table->setDate( year, month, day ); | 456 | table->setDate( year, month, day ); |
454 | table->redraw(); | 457 | table->redraw(); |
455 | } | 458 | } |
456 | 459 | ||
457 | QDate DateBookMonth::selectedDate() const | 460 | QDate DateBookMonth::selectedDate() const |
458 | { | 461 | { |
459 | if ( !table ) | 462 | if ( !table ) |
460 | return QDate::currentDate(); | 463 | return QDate::currentDate(); |
461 | int y, m, d; | 464 | int y, m, d; |
462 | table->getDate( y, m, d ); | 465 | table->getDate( y, m, d ); |
463 | return QDate( y, m, d ); | 466 | return QDate( y, m, d ); |
464 | } | 467 | } |
465 | 468 | ||
466 | void DateBookMonth::slotWeekChange( bool startOnMonday ) | 469 | void DateBookMonth::slotWeekChange( bool startOnMonday ) |
467 | { | 470 | { |
468 | table->setWeekStart( startOnMonday ); | 471 | table->setWeekStart( startOnMonday ); |
469 | } | 472 | } |
470 | 473 | ||
471 | void DateBookMonth::keyPressEvent( QKeyEvent *e ) | 474 | void DateBookMonth::keyPressEvent( QKeyEvent *e ) |
472 | { | 475 | { |
473 | switch(e->key()) { | 476 | switch(e->key()) { |
474 | case Key_Up: | 477 | case Key_Up: |
475 | setDate(QDate(year, month, day).addDays(-7)); | 478 | setDate(QDate(year, month, day).addDays(-7)); |
476 | break; | 479 | break; |
477 | case Key_Down: | 480 | case Key_Down: |
478 | setDate(QDate(year, month, day).addDays(7)); | 481 | setDate(QDate(year, month, day).addDays(7)); |
479 | break; | 482 | break; |
480 | case Key_Left: | 483 | case Key_Left: |
481 | setDate(QDate(year, month, day).addDays(-1)); | 484 | setDate(QDate(year, month, day).addDays(-1)); |
482 | break; | 485 | break; |
483 | case Key_Right: | 486 | case Key_Right: |
484 | setDate(QDate(year, month, day).addDays(1)); | 487 | setDate(QDate(year, month, day).addDays(1)); |
485 | break; | 488 | break; |
486 | case Key_Space: | 489 | case Key_Space: |
487 | qWarning("space"); | 490 | qWarning("space"); |
488 | emit dateClicked(year, month, day); | 491 | emit dateClicked(year, month, day); |
489 | if ( autoClose && parentWidget() ) | 492 | if ( autoClose && parentWidget() ) |
490 | parentWidget()->close(); | 493 | parentWidget()->close(); |
491 | break; | 494 | break; |
492 | default: | 495 | default: |
493 | qWarning("ignore"); | 496 | qWarning("ignore"); |
494 | e->ignore(); | 497 | e->ignore(); |
495 | break; | 498 | break; |
496 | } | 499 | } |
497 | } | 500 | } |
498 | 501 | ||
499 | //--------------------------------------------------------------------------- | 502 | //--------------------------------------------------------------------------- |
500 | class DayItemMonthPrivate | 503 | class DayItemMonthPrivate |
501 | { | 504 | { |
502 | public: | 505 | public: |
503 | DayItemMonthPrivate() {}; | 506 | DayItemMonthPrivate() {}; |
504 | ~DayItemMonthPrivate() { mDayEvents.clear(); }; | 507 | ~DayItemMonthPrivate() { mDayEvents.clear(); }; |
505 | QValueList<EffectiveEvent> mDayEvents; | 508 | QValueList<EffectiveEvent> mDayEvents; |
506 | }; | 509 | }; |
507 | 510 | ||
508 | DayItemMonth::DayItemMonth( QTable *table, EditType et, const QString &t ) | 511 | DayItemMonth::DayItemMonth( QTable *table, EditType et, const QString &t ) |
509 | : QTableItem( table, et, t ) | 512 | : QTableItem( table, et, t ) |
510 | { | 513 | { |
511 | d = new DayItemMonthPrivate(); | 514 | d = new DayItemMonthPrivate(); |
512 | } | 515 | } |
513 | 516 | ||
514 | DayItemMonth::~DayItemMonth() | 517 | DayItemMonth::~DayItemMonth() |
515 | { | 518 | { |
516 | daysEvents.clear(); | 519 | daysEvents.clear(); |
517 | delete d; | 520 | delete d; |
518 | } | 521 | } |
519 | 522 | ||
520 | void DayItemMonth::setEvents( const QValueList<EffectiveEvent> &effEv ) | 523 | void DayItemMonth::setEvents( const QValueList<EffectiveEvent> &effEv ) |
521 | { | 524 | { |
522 | d->mDayEvents = effEv; | 525 | d->mDayEvents = effEv; |
523 | } | 526 | } |
524 | 527 | ||
525 | void DayItemMonth::clearEffEvents() | 528 | void DayItemMonth::clearEffEvents() |
526 | { | 529 | { |
527 | d->mDayEvents.clear(); | 530 | d->mDayEvents.clear(); |
528 | } | 531 | } |
529 | 532 | ||
530 | void DayItemMonth::paint( QPainter *p, const QColorGroup &cg, | 533 | void DayItemMonth::paint( QPainter *p, const QColorGroup &cg, |
531 | const QRect &cr, bool selected ) | 534 | const QRect &cr, bool selected ) |
532 | { | 535 | { |
533 | p->save(); | 536 | p->save(); |
534 | 537 | ||
535 | QColorGroup g( cg ); | 538 | QColorGroup g( cg ); |
536 | g.setBrush( QColorGroup::Base, back ); | 539 | g.setBrush( QColorGroup::Base, back ); |
537 | g.setColor( QColorGroup::Text, forg ); | 540 | g.setColor( QColorGroup::Text, forg ); |
538 | if ( selected ) | 541 | if ( selected ) |
539 | p->setPen( g.highlightedText() ); | 542 | p->setPen( g.highlightedText() ); |
540 | else | 543 | else |
541 | p->setPen( g.text() ); | 544 | p->setPen( g.text() ); |
542 | 545 | ||
543 | QValueStack<int> normalLine; | 546 | QValueStack<int> normalLine; |
544 | QValueStack<int> repeatLine; | 547 | QValueStack<int> repeatLine; |
545 | QValueStack<int> travelLine; | 548 | QValueStack<int> travelLine; |
546 | 549 | ||
547 | bool normalAllDay = FALSE; | 550 | bool normalAllDay = FALSE; |
548 | bool repeatAllDay = FALSE; | 551 | bool repeatAllDay = FALSE; |
549 | bool travelAllDay = FALSE; | 552 | bool travelAllDay = FALSE; |
550 | bool holidayAllDay = FALSE; | 553 | bool holidayAllDay = FALSE; |
551 | 554 | ||
552 | QValueListIterator<EffectiveEvent> itDays = d->mDayEvents.begin(); | 555 | QValueListIterator<EffectiveEvent> itDays = d->mDayEvents.begin(); |
553 | 556 | ||
554 | for ( ; itDays != d->mDayEvents.end(); ++itDays ) { | 557 | for ( ; itDays != d->mDayEvents.end(); ++itDays ) { |
555 | int w = cr.width(); | 558 | int w = cr.width(); |
556 | Event ev = (*itDays).event(); | 559 | Event ev = (*itDays).event(); |
557 | 560 | ||
558 | int f = (*itDays).start().hour(); // assume Effective event | 561 | int f = (*itDays).start().hour(); // assume Effective event |
559 | int t = (*itDays).end().hour(); // is truncated. | 562 | int t = (*itDays).end().hour(); // is truncated. |
560 | 563 | ||
561 | if (ev.isAllDay()) { | 564 | if (ev.isAllDay()) { |
562 | if (!ev.hasRepeat()) { | 565 | if (!ev.hasRepeat()) { |
563 | normalAllDay = TRUE; | 566 | normalAllDay = TRUE; |
564 | if (!ev.isValidUid()) { | 567 | if (!ev.isValidUid()) { |
565 | holidayAllDay = TRUE; | 568 | holidayAllDay = TRUE; |
566 | } | 569 | } |
567 | } else { | 570 | } else { |
568 | repeatAllDay = TRUE; | 571 | repeatAllDay = TRUE; |
569 | } | 572 | } |
570 | } else { | 573 | } else { |
571 | int sLine, eLine; | 574 | int sLine, eLine; |
572 | if (f == 0) | 575 | if (f == 0) |
573 | sLine = 0; | 576 | sLine = 0; |
574 | else if (f < 8 ) | 577 | else if (f < 8 ) |
575 | sLine = 1; | 578 | sLine = 1; |
576 | else if (f >= 17) | 579 | else if (f >= 17) |
577 | sLine = w - 4; | 580 | sLine = w - 4; |
578 | else { | 581 | else { |
579 | sLine = (f - 8) * (w - 8); | 582 | sLine = (f - 8) * (w - 8); |
580 | if (sLine) | 583 | if (sLine) |
581 | sLine /= 8; | 584 | sLine /= 8; |
582 | sLine += 4; | 585 | sLine += 4; |
583 | } | 586 | } |
584 | if (t == 23) | 587 | if (t == 23) |
585 | eLine = w; | 588 | eLine = w; |
586 | else if (t < 8) | 589 | else if (t < 8) |
587 | eLine = 4; | 590 | eLine = 4; |
588 | else if (t >= 17) | 591 | else if (t >= 17) |
589 | eLine = w - 1; | 592 | eLine = w - 1; |
590 | else { | 593 | else { |
591 | eLine = (t - 8) * (w - 8); | 594 | eLine = (t - 8) * (w - 8); |
592 | if (eLine) | 595 | if (eLine) |
593 | eLine /= 8; | 596 | eLine /= 8; |
594 | eLine += 4; | 597 | eLine += 4; |
595 | } | 598 | } |
596 | if (!ev.hasRepeat()) { | 599 | if (!ev.hasRepeat()) { |
597 | normalLine.push(sLine); | 600 | normalLine.push(sLine); |
598 | normalLine.push(eLine); | 601 | normalLine.push(eLine); |
599 | } else { | 602 | } else { |
600 | repeatLine.push(sLine); | 603 | repeatLine.push(sLine); |
601 | repeatLine.push(eLine); | 604 | repeatLine.push(eLine); |
602 | } | 605 | } |
603 | } | 606 | } |
604 | } | 607 | } |
605 | 608 | ||
606 | // draw the background | 609 | // draw the background |
607 | if (normalAllDay || repeatAllDay || travelAllDay || holidayAllDay) { | 610 | if (normalAllDay || repeatAllDay || travelAllDay || holidayAllDay) { |
608 | p->save(); | 611 | p->save(); |
609 | 612 | ||
610 | if (normalAllDay) | 613 | if (normalAllDay) |
611 | if (repeatAllDay) { | 614 | if (repeatAllDay) { |
612 | p->fillRect( 0, 0, cr.width(), cr.height() / 2, | 615 | p->fillRect( 0, 0, cr.width(), cr.height() / 2, |
613 | colorNormalLight ); | 616 | s_colorNormalLight ); |
614 | p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2, | 617 | p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2, |
615 | colorRepeatLight ); | 618 | colorRepeatLight ); |
616 | } else { | 619 | } else { |
617 | if (!holidayAllDay) { | 620 | if (!holidayAllDay) { |
618 | p->fillRect( 0, 0, cr.width(), cr.height(), | 621 | p->fillRect( 0, 0, cr.width(), cr.height(), |
619 | colorNormalLight ); | 622 | s_colorNormalLight ); |
620 | } else { | 623 | } else { |
621 | p->fillRect( 0, 0, cr.width(), cr.height(), | 624 | p->fillRect( 0, 0, cr.width(), cr.height(), |
622 | QColor(0,220,0) ); | 625 | s_colorHolidayLight ); |
623 | } | 626 | } |
624 | } else if (repeatAllDay) { | 627 | } else if (repeatAllDay) { |
625 | p->fillRect( 0, 0, cr.width(), cr.height(), | 628 | p->fillRect( 0, 0, cr.width(), cr.height(), |
626 | colorRepeatLight ); | 629 | s_colorRepeatLight ); |
627 | } | 630 | } |
628 | } else { | 631 | } else { |
629 | p->fillRect( 0, 0, cr.width(), | 632 | p->fillRect( 0, 0, cr.width(), |
630 | cr.height(), selected | 633 | cr.height(), selected |
631 | ? g.brush( QColorGroup::Highlight ) | 634 | ? g.brush( QColorGroup::Highlight ) |
632 | : g.brush( QColorGroup::Base ) ); | 635 | : g.brush( QColorGroup::Base ) ); |
633 | } | 636 | } |
634 | 637 | ||
635 | // The lines | 638 | // The lines |
636 | // now for the lines. | 639 | // now for the lines. |
637 | int h = 5; | 640 | int h = 5; |
638 | int y = cr.height() / 2 - h; | 641 | int y = cr.height() / 2 - h; |
639 | 642 | ||
640 | while(normalLine.count() >= 2) { | 643 | while(normalLine.count() >= 2) { |
641 | int x2 = normalLine.pop(); | 644 | int x2 = normalLine.pop(); |
642 | int x1 = normalLine.pop(); | 645 | int x1 = normalLine.pop(); |
643 | if (x2 < x1 + 2) | 646 | if (x2 < x1 + 2) |
644 | x2 = x1 + 2; | 647 | x2 = x1 + 2; |
645 | p->fillRect(x1, y, x2 - x1, h, colorNormal); | 648 | p->fillRect(x1, y, x2 - x1, h, colorNormal); |
646 | } | 649 | } |
647 | 650 | ||
648 | y += h; | 651 | y += h; |
649 | 652 | ||
650 | while(repeatLine.count() >= 2) { | 653 | while(repeatLine.count() >= 2) { |
651 | int x2 = repeatLine.pop(); | 654 | int x2 = repeatLine.pop(); |
652 | int x1 = repeatLine.pop(); | 655 | int x1 = repeatLine.pop(); |
653 | if (x2 < x1 + 2) | 656 | if (x2 < x1 + 2) |
654 | x2 = x1 + 2; | 657 | x2 = x1 + 2; |
655 | p->fillRect(x1, y, x2 - x1, h, colorRepeat); | 658 | p->fillRect(x1, y, x2 - x1, h, colorRepeat); |
656 | } | 659 | } |
657 | 660 | ||
658 | 661 | ||
659 | // Finally, draw the number. | 662 | // Finally, draw the number. |
660 | QFont f = p->font(); | 663 | QFont f = p->font(); |
661 | f.setPointSize( ( f.pointSize() / 3 ) * 2 ); | 664 | f.setPointSize( ( f.pointSize() / 3 ) * 2 ); |
662 | p->setFont( f ); | 665 | p->setFont( f ); |
663 | QFontMetrics fm( f ); | 666 | QFontMetrics fm( f ); |
664 | p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) ); | 667 | p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) ); |
665 | 668 | ||
666 | p->restore(); | 669 | p->restore(); |
667 | } | 670 | } |
668 | 671 | ||
669 | 672 | ||
670 | 673 | ||
671 | void DayItemMonth::setType( Calendar::Day::Type t ) | 674 | void DayItemMonth::setType( Calendar::Day::Type t ) |
672 | { | 675 | { |
673 | switch ( t ) { | 676 | switch ( t ) { |
674 | case Calendar::Day::PrevMonth: | 677 | case Calendar::Day::PrevMonth: |
675 | case Calendar::Day::NextMonth: | 678 | case Calendar::Day::NextMonth: |
676 | back = QBrush( QColor( 224, 224, 224 ) ); | 679 | back = QBrush( QColor( 224, 224, 224 ) ); |
677 | forg = black; | 680 | forg = black; |
678 | break; | 681 | break; |
679 | case Calendar::Day::ThisMonth: | 682 | case Calendar::Day::ThisMonth: |
680 | back = QBrush( white ); | 683 | back = QBrush( white ); |
681 | forg = black; | 684 | forg = black; |
682 | break; | 685 | break; |
683 | } | 686 | } |
684 | typ = t; | 687 | typ = t; |
685 | } | 688 | } |
686 | 689 | ||
687 | 690 | ||
688 | 691 | ||
689 | DateButton::DateButton( bool longDate, QWidget *parent, const char * name ) | 692 | DateButton::DateButton( bool longDate, QWidget *parent, const char * name ) |
690 | :QPushButton( parent, name ) | 693 | :QPushButton( parent, name ) |
691 | { | 694 | { |
692 | longFormat = longDate; | 695 | longFormat = longDate; |
693 | df = DateFormat('/', DateFormat::MonthDayYear, DateFormat::MonthDayYear); | 696 | df = DateFormat('/', DateFormat::MonthDayYear, DateFormat::MonthDayYear); |
694 | setDate( QDate::currentDate() ); | 697 | setDate( QDate::currentDate() ); |
695 | 698 | ||
696 | connect(this,SIGNAL(pressed()),this,SLOT(pickDate())); | 699 | connect(this,SIGNAL(pressed()),this,SLOT(pickDate())); |
697 | 700 | ||
698 | 701 | ||
699 | } | 702 | } |
700 | 703 | ||
701 | 704 | ||
702 | void DateButton::pickDate() | 705 | void DateButton::pickDate() |
703 | { | 706 | { |
704 | static QPopupMenu *m1 = 0; | 707 | static QPopupMenu *m1 = 0; |
705 | static DateBookMonth *picker = 0; | 708 | static DateBookMonth *picker = 0; |
706 | if ( !m1 ) { | 709 | if ( !m1 ) { |
707 | m1 = new QPopupMenu( this ); | 710 | m1 = new QPopupMenu( this ); |
708 | picker = new DateBookMonth( m1, 0, TRUE ); | 711 | picker = new DateBookMonth( m1, 0, TRUE ); |
709 | m1->insertItem( picker ); | 712 | m1->insertItem( picker ); |
710 | connect( picker, SIGNAL( dateClicked(int,int,int) ), | 713 | connect( picker, SIGNAL( dateClicked(int,int,int) ), |
711 | this, SLOT( setDate(int,int,int) ) ); | 714 | this, SLOT( setDate(int,int,int) ) ); |
712 | connect( picker, SIGNAL( dateClicked(int,int,int) ), | 715 | connect( picker, SIGNAL( dateClicked(int,int,int) ), |
713 | this, SIGNAL( dateSelected(int,int,int) ) ); | 716 | this, SIGNAL( dateSelected(int,int,int) ) ); |
714 | connect( m1, SIGNAL( aboutToHide() ), | 717 | connect( m1, SIGNAL( aboutToHide() ), |
715 | this, SLOT( gotHide() ) ); | 718 | this, SLOT( gotHide() ) ); |
716 | } | 719 | } |
717 | picker->slotWeekChange( weekStartsMonday ); | 720 | picker->slotWeekChange( weekStartsMonday ); |
718 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); | 721 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); |
719 | m1->popup(mapToGlobal(QPoint(0,height()))); | 722 | m1->popup(mapToGlobal(QPoint(0,height()))); |
720 | picker->setFocus(); | 723 | picker->setFocus(); |
721 | } | 724 | } |
722 | 725 | ||
723 | 726 | ||
724 | void DateButton::gotHide() | 727 | void DateButton::gotHide() |
725 | { | 728 | { |
726 | // we have to redo the button... | 729 | // we have to redo the button... |
727 | setDown( false ); | 730 | setDown( false ); |
728 | } | 731 | } |
729 | 732 | ||
730 | 733 | ||
731 | // void dateSelected( int year, int month, int day ); | 734 | // void dateSelected( int year, int month, int day ); |
732 | 735 | ||
733 | void DateButton::setWeekStartsMonday( int b ) | 736 | void DateButton::setWeekStartsMonday( int b ) |
734 | { | 737 | { |
735 | weekStartsMonday = b; | 738 | weekStartsMonday = b; |
736 | } | 739 | } |
737 | 740 | ||
738 | void DateButton::setDate( int y, int m, int d ) | 741 | void DateButton::setDate( int y, int m, int d ) |
739 | { | 742 | { |
740 | setDate( QDate( y,m,d) ); | 743 | setDate( QDate( y,m,d) ); |
741 | } | 744 | } |
742 | 745 | ||
743 | void DateButton::setDate( QDate d ) | 746 | void DateButton::setDate( QDate d ) |
744 | { | 747 | { |
745 | currDate = d; | 748 | currDate = d; |
746 | setText( longFormat ? TimeString::longDateString( d, df ) : | 749 | setText( longFormat ? TimeString::longDateString( d, df ) : |
747 | TimeString::shortDate( d, df ) ); | 750 | TimeString::shortDate( d, df ) ); |
748 | 751 | ||
749 | } | 752 | } |
750 | 753 | ||
751 | void DateButton::setDateFormat( DateFormat f ) | 754 | void DateButton::setDateFormat( DateFormat f ) |
752 | { | 755 | { |
753 | df = f; | 756 | df = f; |
754 | setDate( currDate ); | 757 | setDate( currDate ); |
755 | } | 758 | } |
756 | 759 | ||
757 | bool DateButton::customWhatsThis() const | 760 | bool DateButton::customWhatsThis() const |
758 | { | 761 | { |
759 | return TRUE; | 762 | return TRUE; |
760 | } | 763 | } |
761 | 764 | ||
762 | 765 | ||
763 | // this class is only here for Sharp ROM compatibility | 766 | // this class is only here for Sharp ROM compatibility |
764 | // I have reverse engineered this class and it seems to | 767 | // I have reverse engineered this class and it seems to |
765 | // work (only qtmail seems to use it) - sandman | 768 | // work (only qtmail seems to use it) - sandman |
766 | // DO NOT USE IT IN NEW CODE !! | 769 | // DO NOT USE IT IN NEW CODE !! |
767 | 770 | ||
768 | DateBookMonthPopup::DateBookMonthPopup ( QWidget *w ) | 771 | DateBookMonthPopup::DateBookMonthPopup ( QWidget *w ) |
769 | : QPopupMenu ( w ) | 772 | : QPopupMenu ( w ) |
770 | { | 773 | { |
771 | m_dbm = new DateBookMonth( this, 0, TRUE ); | 774 | m_dbm = new DateBookMonth( this, 0, TRUE ); |
772 | insertItem( m_dbm ); | 775 | insertItem( m_dbm ); |
773 | } | 776 | } |