author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /library/datebookmonth.cpp | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
-rw-r--r-- | library/datebookmonth.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/library/datebookmonth.cpp b/library/datebookmonth.cpp index 76e022f..421559e 100644 --- a/library/datebookmonth.cpp +++ b/library/datebookmonth.cpp | |||
@@ -24,99 +24,99 @@ | |||
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 | 32 | ||
33 | DateBookMonthHeader::DateBookMonthHeader( QWidget *parent, const char *name ) | 33 | DateBookMonthHeader::DateBookMonthHeader( QWidget *parent, const char *name ) |
34 | : QHBox( parent, name ) | 34 | : QHBox( parent, name ) |
35 | { | 35 | { |
36 | setBackgroundMode( PaletteButton ); | 36 | setBackgroundMode( PaletteButton ); |
37 | 37 | ||
38 | begin = new QToolButton( this ); | 38 | begin = new QToolButton( this ); |
39 | begin->setFocusPolicy(NoFocus); | 39 | begin->setFocusPolicy(NoFocus); |
40 | begin->setPixmap( Resource::loadPixmap( "start" ) ); | 40 | begin->setPixmap( Resource::loadPixmap( "start" ) ); |
41 | begin->setAutoRaise( TRUE ); | 41 | begin->setAutoRaise( TRUE ); |
42 | begin->setFixedSize( begin->sizeHint() ); | 42 | begin->setFixedSize( begin->sizeHint() ); |
43 | QWhatsThis::add( begin, tr("Show January in the selected year") ); | 43 | QWhatsThis::add( begin, tr("Show January in the selected year") ); |
44 | 44 | ||
45 | back = new QToolButton( this ); | 45 | back = new QToolButton( this ); |
46 | back->setFocusPolicy(NoFocus); | 46 | back->setFocusPolicy(NoFocus); |
47 | back->setPixmap( Resource::loadPixmap( "back" ) ); | 47 | back->setPixmap( Resource::loadPixmap( "back" ) ); |
48 | back->setAutoRaise( TRUE ); | 48 | back->setAutoRaise( TRUE ); |
49 | back->setFixedSize( back->sizeHint() ); | 49 | back->setFixedSize( back->sizeHint() ); |
50 | QWhatsThis::add( back, tr("Show the previous month") ); | 50 | QWhatsThis::add( back, tr("Show the previous month") ); |
51 | 51 | ||
52 | month = new QComboBox( FALSE, this ); | 52 | month = new QComboBox( FALSE, this ); |
53 | for ( int i = 0; i < 12; ++i ) | 53 | for ( int i = 0; i < 12; ++i ) |
54 | month->insertItem( Calendar::nameOfMonth( i + 1 ) ); | 54 | month->insertItem( Calendar::nameOfMonth( i + 1 ) ); |
55 | 55 | ||
56 | year = new QSpinBox( 1752, 8000, 1, this ); | 56 | year = new QSpinBox( 1752, 8000, 1, this ); |
57 | 57 | ||
58 | next = new QToolButton( this ); | 58 | next = new QToolButton( this ); |
59 | next->setFocusPolicy(NoFocus); | 59 | next->setFocusPolicy(NoFocus); |
60 | next->setPixmap( Resource::loadPixmap( "forward" ) ); | 60 | next->setPixmap( Resource::loadPixmap( "forward" ) ); |
61 | next->setAutoRaise( TRUE ); | 61 | next->setAutoRaise( TRUE ); |
62 | next->setFixedSize( next->sizeHint() ); | 62 | next->setFixedSize( next->sizeHint() ); |
63 | QWhatsThis::add( next, tr("Show the next month") ); | 63 | QWhatsThis::add( next, tr("Show the next month") ); |
64 | 64 | ||
65 | end = new QToolButton( this ); | 65 | end = new QToolButton( this ); |
66 | end->setFocusPolicy(NoFocus); | 66 | end->setFocusPolicy(NoFocus); |
67 | end->setPixmap( Resource::loadPixmap( "finish" ) ); | 67 | end->setPixmap( Resource::loadPixmap( "finish" ) ); |
68 | end->setAutoRaise( TRUE ); | 68 | end->setAutoRaise( TRUE ); |
69 | end->setFixedSize( end->sizeHint() ); | 69 | end->setFixedSize( end->sizeHint() ); |
70 | QWhatsThis::add( end, tr("Show December in the selected year") ); | 70 | QWhatsThis::add( end, tr("Show December in the selected year") ); |
71 | 71 | ||
72 | connect( month, SIGNAL( activated( int ) ), | 72 | connect( month, SIGNAL( activated(int) ), |
73 | this, SLOT( updateDate() ) ); | 73 | this, SLOT( updateDate() ) ); |
74 | connect( year, SIGNAL( valueChanged( int ) ), | 74 | connect( year, SIGNAL( valueChanged(int) ), |
75 | this, SLOT( updateDate() ) ); | 75 | this, SLOT( updateDate() ) ); |
76 | connect( begin, SIGNAL( clicked() ), | 76 | connect( begin, SIGNAL( clicked() ), |
77 | this, SLOT( firstMonth() ) ); | 77 | this, SLOT( firstMonth() ) ); |
78 | connect( end, SIGNAL( clicked() ), | 78 | connect( end, SIGNAL( clicked() ), |
79 | this, SLOT( lastMonth() ) ); | 79 | this, SLOT( lastMonth() ) ); |
80 | connect( back, SIGNAL( clicked() ), | 80 | connect( back, SIGNAL( clicked() ), |
81 | this, SLOT( monthBack() ) ); | 81 | this, SLOT( monthBack() ) ); |
82 | connect( next, SIGNAL( clicked() ), | 82 | connect( next, SIGNAL( clicked() ), |
83 | this, SLOT( monthForward() ) ); | 83 | this, SLOT( monthForward() ) ); |
84 | back->setAutoRepeat( TRUE ); | 84 | back->setAutoRepeat( TRUE ); |
85 | next->setAutoRepeat( TRUE ); | 85 | next->setAutoRepeat( TRUE ); |
86 | } | 86 | } |
87 | 87 | ||
88 | 88 | ||
89 | DateBookMonthHeader::~DateBookMonthHeader() | 89 | DateBookMonthHeader::~DateBookMonthHeader() |
90 | { | 90 | { |
91 | 91 | ||
92 | } | 92 | } |
93 | 93 | ||
94 | void DateBookMonthHeader::updateDate() | 94 | void DateBookMonthHeader::updateDate() |
95 | { | 95 | { |
96 | emit dateChanged( year->value(), month->currentItem() + 1 ); | 96 | emit dateChanged( year->value(), month->currentItem() + 1 ); |
97 | } | 97 | } |
98 | 98 | ||
99 | void DateBookMonthHeader::firstMonth() | 99 | void DateBookMonthHeader::firstMonth() |
100 | { | 100 | { |
101 | emit dateChanged( year->value(), 1 ); | 101 | emit dateChanged( year->value(), 1 ); |
102 | month->setCurrentItem( 0 ); | 102 | month->setCurrentItem( 0 ); |
103 | } | 103 | } |
104 | 104 | ||
105 | void DateBookMonthHeader::lastMonth() | 105 | void DateBookMonthHeader::lastMonth() |
106 | { | 106 | { |
107 | emit dateChanged( year->value(), 12 ); | 107 | emit dateChanged( year->value(), 12 ); |
108 | month->setCurrentItem( 11 ); | 108 | month->setCurrentItem( 11 ); |
109 | } | 109 | } |
110 | 110 | ||
111 | void DateBookMonthHeader::monthBack() | 111 | void DateBookMonthHeader::monthBack() |
112 | { | 112 | { |
113 | if ( month->currentItem() > 0 ) { | 113 | if ( month->currentItem() > 0 ) { |
114 | emit dateChanged( year->value(), month->currentItem() ); | 114 | emit dateChanged( year->value(), month->currentItem() ); |
115 | month->setCurrentItem( month->currentItem() - 1 ); | 115 | month->setCurrentItem( month->currentItem() - 1 ); |
116 | } else { | 116 | } else { |
117 | emit dateChanged( year->value() - 1, 12 ); | 117 | emit dateChanged( year->value() - 1, 12 ); |
118 | // we have a signal set to a changed value in year so we only need to change | 118 | // we have a signal set to a changed value in year so we only need to change |
119 | // year to get the result... | 119 | // year to get the result... |
120 | month->setCurrentItem( 11 ); | 120 | month->setCurrentItem( 11 ); |
121 | year->setValue( year->value() - 1 ); | 121 | year->setValue( year->value() - 1 ); |
122 | } | 122 | } |
@@ -142,100 +142,100 @@ void DateBookMonthHeader::setDate( int y, int m ) | |||
142 | } | 142 | } |
143 | 143 | ||
144 | //--------------------------------------------------------------------------- | 144 | //--------------------------------------------------------------------------- |
145 | 145 | ||
146 | class DateBookMonthTablePrivate | 146 | class DateBookMonthTablePrivate |
147 | { | 147 | { |
148 | public: | 148 | public: |
149 | DateBookMonthTablePrivate() {}; | 149 | DateBookMonthTablePrivate() {}; |
150 | ~DateBookMonthTablePrivate() { mMonthEvents.clear(); }; | 150 | ~DateBookMonthTablePrivate() { mMonthEvents.clear(); }; |
151 | 151 | ||
152 | QValueList<EffectiveEvent> mMonthEvents; | 152 | QValueList<EffectiveEvent> mMonthEvents; |
153 | bool onMonday; | 153 | bool onMonday; |
154 | }; | 154 | }; |
155 | 155 | ||
156 | DateBookMonthTable::DateBookMonthTable( QWidget *parent, const char *name, | 156 | DateBookMonthTable::DateBookMonthTable( QWidget *parent, const char *name, |
157 | DateBookDB *newDb ) | 157 | DateBookDB *newDb ) |
158 | : QTable( 6, 7, parent, name ), | 158 | : QTable( 6, 7, parent, name ), |
159 | db( newDb ) | 159 | db( newDb ) |
160 | { | 160 | { |
161 | d = new DateBookMonthTablePrivate(); | 161 | d = new DateBookMonthTablePrivate(); |
162 | selYear = -1; | 162 | selYear = -1; |
163 | selMonth = -1; | 163 | selMonth = -1; |
164 | selDay = -1; | 164 | selDay = -1; |
165 | 165 | ||
166 | /* init these as well make valgrind happy and be consistent with Qtopia1.6 -zecke */ | 166 | /* init these as well make valgrind happy and be consistent with Qtopia1.6 -zecke */ |
167 | year = -1; | 167 | year = -1; |
168 | month = -1; | 168 | month = -1; |
169 | day = -1; | 169 | day = -1; |
170 | 170 | ||
171 | Config cfg( "qpe" ); | 171 | Config cfg( "qpe" ); |
172 | cfg.setGroup( "Time" ); | 172 | cfg.setGroup( "Time" ); |
173 | d->onMonday = cfg.readBoolEntry( "MONDAY" ); | 173 | d->onMonday = cfg.readBoolEntry( "MONDAY" ); |
174 | 174 | ||
175 | horizontalHeader()->setResizeEnabled( FALSE ); | 175 | horizontalHeader()->setResizeEnabled( FALSE ); |
176 | // we have to do this here... or suffer the consequences later... | 176 | // we have to do this here... or suffer the consequences later... |
177 | for ( int i = 0; i < 7; i++ ){ | 177 | for ( int i = 0; i < 7; i++ ){ |
178 | horizontalHeader()->resizeSection( i, 30 ); | 178 | horizontalHeader()->resizeSection( i, 30 ); |
179 | setColumnStretchable( i, TRUE ); | 179 | setColumnStretchable( i, TRUE ); |
180 | } | 180 | } |
181 | setupLabels(); | 181 | setupLabels(); |
182 | 182 | ||
183 | verticalHeader()->hide(); | 183 | verticalHeader()->hide(); |
184 | setLeftMargin( 0 ); | 184 | setLeftMargin( 0 ); |
185 | for ( int i = 0; i < 6; ++i ) | 185 | for ( int i = 0; i < 6; ++i ) |
186 | setRowStretchable( i, TRUE ); | 186 | setRowStretchable( i, TRUE ); |
187 | 187 | ||
188 | setSelectionMode( NoSelection ); | 188 | setSelectionMode( NoSelection ); |
189 | 189 | ||
190 | connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), | 190 | connect( this, SIGNAL( clicked(int,int,int,const QPoint&) ), |
191 | this, SLOT( dayClicked( int, int ) ) ); | 191 | this, SLOT( dayClicked(int,int) ) ); |
192 | connect( this, SIGNAL( currentChanged( int, int ) ), | 192 | connect( this, SIGNAL( currentChanged(int,int) ), |
193 | this, SLOT( dragDay( int, int ) ) ); | 193 | this, SLOT( dragDay(int,int) ) ); |
194 | setVScrollBarMode( AlwaysOff ); | 194 | setVScrollBarMode( AlwaysOff ); |
195 | setHScrollBarMode( AlwaysOff ); | 195 | setHScrollBarMode( AlwaysOff ); |
196 | } | 196 | } |
197 | 197 | ||
198 | DateBookMonthTable::~DateBookMonthTable() | 198 | DateBookMonthTable::~DateBookMonthTable() |
199 | { | 199 | { |
200 | monthsEvents.clear(); | 200 | monthsEvents.clear(); |
201 | delete d; | 201 | delete d; |
202 | } | 202 | } |
203 | 203 | ||
204 | void DateBookMonthTable::setDate(int y, int m, int d) | 204 | void DateBookMonthTable::setDate(int y, int m, int d) |
205 | { | 205 | { |
206 | if (month == m && year == y) { | 206 | if (month == m && year == y) { |
207 | if ( selYear == -1 ) | 207 | if ( selYear == -1 ) |
208 | year = selYear; | 208 | year = selYear; |
209 | if ( selMonth == -1 ) | 209 | if ( selMonth == -1 ) |
210 | month = selMonth; | 210 | month = selMonth; |
211 | int r1, c1, r2, c2; | 211 | int r1, c1, r2, c2; |
212 | findDay(selDay, r1, c1); | 212 | findDay(selDay, r1, c1); |
213 | selDay = day = d; | 213 | selDay = day = d; |
214 | findDay(selDay, r2, c2); | 214 | findDay(selDay, r2, c2); |
215 | setCurrentCell( r2, c2 ); | 215 | setCurrentCell( r2, c2 ); |
216 | //updateCell(r1,c1); | 216 | //updateCell(r1,c1); |
217 | //updateCell(r2,c2); | 217 | //updateCell(r2,c2); |
218 | } else { | 218 | } else { |
219 | selYear = year = y; | 219 | selYear = year = y; |
220 | selMonth = month = m; | 220 | selMonth = month = m; |
221 | selDay = day = d; | 221 | selDay = day = d; |
222 | setupTable(); | 222 | setupTable(); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
226 | void DateBookMonthTable::redraw() | 226 | void DateBookMonthTable::redraw() |
227 | { | 227 | { |
228 | setupLabels(); | 228 | setupLabels(); |
229 | setupTable(); | 229 | setupTable(); |
230 | } | 230 | } |
231 | 231 | ||
232 | void DateBookMonthTable::setWeekStart( bool onMonday ) | 232 | void DateBookMonthTable::setWeekStart( bool onMonday ) |
233 | { | 233 | { |
234 | d->onMonday = onMonday; | 234 | d->onMonday = onMonday; |
235 | setupLabels(); | 235 | setupLabels(); |
236 | setupTable(); | 236 | setupTable(); |
237 | } | 237 | } |
238 | 238 | ||
239 | void DateBookMonthTable::setupTable() | 239 | void DateBookMonthTable::setupTable() |
240 | { | 240 | { |
241 | QValueList<Calendar::Day> days = Calendar::daysOfMonth( year, month, d->onMonday ); | 241 | QValueList<Calendar::Day> days = Calendar::daysOfMonth( year, month, d->onMonday ); |
@@ -349,100 +349,100 @@ void DateBookMonthTable::getEvents() | |||
349 | && e.date() == (*it).date() ) { | 349 | && e.date() == (*it).date() ) { |
350 | dayEvent.append( *it ); | 350 | dayEvent.append( *it ); |
351 | ++it; | 351 | ++it; |
352 | } | 352 | } |
353 | int row, col; | 353 | int row, col; |
354 | findDay( e.date().day(), row, col ); | 354 | findDay( e.date().day(), row, col ); |
355 | DayItemMonth* w = static_cast<DayItemMonth*>( item( row, col ) ); | 355 | DayItemMonth* w = static_cast<DayItemMonth*>( item( row, col ) ); |
356 | w->setEvents( dayEvent ); | 356 | w->setEvents( dayEvent ); |
357 | updateCell( row, col ); | 357 | updateCell( row, col ); |
358 | dayEvent.clear(); | 358 | dayEvent.clear(); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | 361 | ||
362 | 362 | ||
363 | void DateBookMonthTable::setupLabels() | 363 | void DateBookMonthTable::setupLabels() |
364 | { | 364 | { |
365 | for ( int i = 0; i < 7; ++i ) { | 365 | for ( int i = 0; i < 7; ++i ) { |
366 | // horizontalHeader()->resizeSection( i, 30 ); | 366 | // horizontalHeader()->resizeSection( i, 30 ); |
367 | // setColumnStretchable( i, TRUE ); | 367 | // setColumnStretchable( i, TRUE ); |
368 | if ( d->onMonday ) | 368 | if ( d->onMonday ) |
369 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i + 1 ) ); | 369 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i + 1 ) ); |
370 | else { | 370 | else { |
371 | if ( i == 0 ) | 371 | if ( i == 0 ) |
372 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( 7 ) ); | 372 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( 7 ) ); |
373 | else | 373 | else |
374 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i ) ); | 374 | horizontalHeader()->setLabel( i, Calendar::nameOfDay( i ) ); |
375 | } | 375 | } |
376 | } | 376 | } |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | //--------------------------------------------------------------------------- | 380 | //--------------------------------------------------------------------------- |
381 | 381 | ||
382 | DateBookMonth::DateBookMonth( QWidget *parent, const char *name, bool ac, | 382 | DateBookMonth::DateBookMonth( QWidget *parent, const char *name, bool ac, |
383 | DateBookDB *data ) | 383 | DateBookDB *data ) |
384 | : QVBox( parent, name ), | 384 | : QVBox( parent, name ), |
385 | autoClose( ac ) | 385 | autoClose( ac ) |
386 | { | 386 | { |
387 | setFocusPolicy(StrongFocus); | 387 | setFocusPolicy(StrongFocus); |
388 | year = QDate::currentDate().year(); | 388 | year = QDate::currentDate().year(); |
389 | month = QDate::currentDate().month(); | 389 | month = QDate::currentDate().month(); |
390 | day = QDate::currentDate().day(); | 390 | day = QDate::currentDate().day(); |
391 | header = new DateBookMonthHeader( this, "DateBookMonthHeader" ); | 391 | header = new DateBookMonthHeader( this, "DateBookMonthHeader" ); |
392 | table = new DateBookMonthTable( this, "DateBookMonthTable", data ); | 392 | table = new DateBookMonthTable( this, "DateBookMonthTable", data ); |
393 | header->setDate( year, month ); | 393 | header->setDate( year, month ); |
394 | table->setDate( year, month, QDate::currentDate().day() ); | 394 | table->setDate( year, month, QDate::currentDate().day() ); |
395 | header->setFocusPolicy(NoFocus); | 395 | header->setFocusPolicy(NoFocus); |
396 | table->setFocusPolicy(NoFocus); | 396 | table->setFocusPolicy(NoFocus); |
397 | connect( header, SIGNAL( dateChanged( int, int ) ), | 397 | connect( header, SIGNAL( dateChanged(int,int) ), |
398 | this, SLOT( setDate( int, int ) ) ); | 398 | this, SLOT( setDate(int,int) ) ); |
399 | connect( table, SIGNAL( dateClicked( int, int, int ) ), | 399 | connect( table, SIGNAL( dateClicked(int,int,int) ), |
400 | this, SLOT( finalDate(int, int, int) ) ); | 400 | this, SLOT( finalDate(int,int,int) ) ); |
401 | connect( qApp, SIGNAL(weekChanged(bool)), this, | 401 | connect( qApp, SIGNAL(weekChanged(bool)), this, |
402 | SLOT(slotWeekChange(bool)) ); | 402 | SLOT(slotWeekChange(bool)) ); |
403 | table->setFocus(); | 403 | table->setFocus(); |
404 | } | 404 | } |
405 | 405 | ||
406 | DateBookMonth::~DateBookMonth() | 406 | DateBookMonth::~DateBookMonth() |
407 | { | 407 | { |
408 | 408 | ||
409 | } | 409 | } |
410 | 410 | ||
411 | void DateBookMonth::setDate( int y, int m ) | 411 | void DateBookMonth::setDate( int y, int m ) |
412 | { | 412 | { |
413 | /* only change the date if this is a different date, | 413 | /* only change the date if this is a different date, |
414 | * other wise we may mistakenly overide the day */ | 414 | * other wise we may mistakenly overide the day */ |
415 | if ( (y != year) || (m != month) ) { | 415 | if ( (y != year) || (m != month) ) { |
416 | year = y; | 416 | year = y; |
417 | month = m; | 417 | month = m; |
418 | QDate nd( y, m, 1 ); | 418 | QDate nd( y, m, 1 ); |
419 | if ( nd.daysInMonth() < day ) | 419 | if ( nd.daysInMonth() < day ) |
420 | day = nd.daysInMonth(); | 420 | day = nd.daysInMonth(); |
421 | table->setDate( year, month, day ); | 421 | table->setDate( year, month, day ); |
422 | } | 422 | } |
423 | } | 423 | } |
424 | 424 | ||
425 | void DateBookMonth::setDate( int y, int m, int d ) | 425 | void DateBookMonth::setDate( int y, int m, int d ) |
426 | { | 426 | { |
427 | header->setDate( y, m); | 427 | header->setDate( y, m); |
428 | table->setDate( y, m, d); | 428 | table->setDate( y, m, d); |
429 | year = y; | 429 | year = y; |
430 | month = m; | 430 | month = m; |
431 | day = d; | 431 | day = d; |
432 | } | 432 | } |
433 | 433 | ||
434 | /* called when we wish to close or pass back the date */ | 434 | /* called when we wish to close or pass back the date */ |
435 | void DateBookMonth::finalDate(int y, int m, int d) | 435 | void DateBookMonth::finalDate(int y, int m, int d) |
436 | { | 436 | { |
437 | setDate( y, m, d ); | 437 | setDate( y, m, d ); |
438 | 438 | ||
439 | emit dateClicked(y, m, d); | 439 | emit dateClicked(y, m, d); |
440 | // emit dateClicked(QDate(y, m, d).toString()); | 440 | // emit dateClicked(QDate(y, m, d).toString()); |
441 | 441 | ||
442 | if ( autoClose && parentWidget() ) | 442 | if ( autoClose && parentWidget() ) |
443 | parentWidget()->close(); | 443 | parentWidget()->close(); |
444 | } | 444 | } |
445 | 445 | ||
446 | void DateBookMonth::setDate( QDate d) | 446 | void DateBookMonth::setDate( QDate d) |
447 | { | 447 | { |
448 | setDate(d.year(), d.month(), d.day()); | 448 | setDate(d.year(), d.month(), d.day()); |
@@ -651,100 +651,100 @@ void DayItemMonth::paint( QPainter *p, const QColorGroup &cg, | |||
651 | p->setFont( f ); | 651 | p->setFont( f ); |
652 | QFontMetrics fm( f ); | 652 | QFontMetrics fm( f ); |
653 | p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) ); | 653 | p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) ); |
654 | 654 | ||
655 | p->restore(); | 655 | p->restore(); |
656 | } | 656 | } |
657 | 657 | ||
658 | 658 | ||
659 | 659 | ||
660 | void DayItemMonth::setType( Calendar::Day::Type t ) | 660 | void DayItemMonth::setType( Calendar::Day::Type t ) |
661 | { | 661 | { |
662 | switch ( t ) { | 662 | switch ( t ) { |
663 | case Calendar::Day::PrevMonth: | 663 | case Calendar::Day::PrevMonth: |
664 | case Calendar::Day::NextMonth: | 664 | case Calendar::Day::NextMonth: |
665 | back = QBrush( QColor( 224, 224, 224 ) ); | 665 | back = QBrush( QColor( 224, 224, 224 ) ); |
666 | forg = black; | 666 | forg = black; |
667 | break; | 667 | break; |
668 | case Calendar::Day::ThisMonth: | 668 | case Calendar::Day::ThisMonth: |
669 | back = QBrush( white ); | 669 | back = QBrush( white ); |
670 | forg = black; | 670 | forg = black; |
671 | break; | 671 | break; |
672 | } | 672 | } |
673 | typ = t; | 673 | typ = t; |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | 677 | ||
678 | DateButton::DateButton( bool longDate, QWidget *parent, const char * name ) | 678 | DateButton::DateButton( bool longDate, QWidget *parent, const char * name ) |
679 | :QPushButton( parent, name ) | 679 | :QPushButton( parent, name ) |
680 | { | 680 | { |
681 | longFormat = longDate; | 681 | longFormat = longDate; |
682 | df = DateFormat('/', DateFormat::MonthDayYear, DateFormat::MonthDayYear); | 682 | df = DateFormat('/', DateFormat::MonthDayYear, DateFormat::MonthDayYear); |
683 | setDate( QDate::currentDate() ); | 683 | setDate( QDate::currentDate() ); |
684 | 684 | ||
685 | connect(this,SIGNAL(pressed()),this,SLOT(pickDate())); | 685 | connect(this,SIGNAL(pressed()),this,SLOT(pickDate())); |
686 | 686 | ||
687 | 687 | ||
688 | } | 688 | } |
689 | 689 | ||
690 | 690 | ||
691 | void DateButton::pickDate() | 691 | void DateButton::pickDate() |
692 | { | 692 | { |
693 | static QPopupMenu *m1 = 0; | 693 | static QPopupMenu *m1 = 0; |
694 | static DateBookMonth *picker = 0; | 694 | static DateBookMonth *picker = 0; |
695 | if ( !m1 ) { | 695 | if ( !m1 ) { |
696 | m1 = new QPopupMenu( this ); | 696 | m1 = new QPopupMenu( this ); |
697 | picker = new DateBookMonth( m1, 0, TRUE ); | 697 | picker = new DateBookMonth( m1, 0, TRUE ); |
698 | m1->insertItem( picker ); | 698 | m1->insertItem( picker ); |
699 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), | 699 | connect( picker, SIGNAL( dateClicked(int,int,int) ), |
700 | this, SLOT( setDate( int, int, int ) ) ); | 700 | this, SLOT( setDate(int,int,int) ) ); |
701 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), | 701 | connect( picker, SIGNAL( dateClicked(int,int,int) ), |
702 | this, SIGNAL( dateSelected( int, int, int ) ) ); | 702 | this, SIGNAL( dateSelected(int,int,int) ) ); |
703 | connect( m1, SIGNAL( aboutToHide() ), | 703 | connect( m1, SIGNAL( aboutToHide() ), |
704 | this, SLOT( gotHide() ) ); | 704 | this, SLOT( gotHide() ) ); |
705 | } | 705 | } |
706 | picker->slotWeekChange( weekStartsMonday ); | 706 | picker->slotWeekChange( weekStartsMonday ); |
707 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); | 707 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); |
708 | m1->popup(mapToGlobal(QPoint(0,height()))); | 708 | m1->popup(mapToGlobal(QPoint(0,height()))); |
709 | picker->setFocus(); | 709 | picker->setFocus(); |
710 | } | 710 | } |
711 | 711 | ||
712 | 712 | ||
713 | void DateButton::gotHide() | 713 | void DateButton::gotHide() |
714 | { | 714 | { |
715 | // we have to redo the button... | 715 | // we have to redo the button... |
716 | setDown( false ); | 716 | setDown( false ); |
717 | } | 717 | } |
718 | 718 | ||
719 | 719 | ||
720 | // void dateSelected( int year, int month, int day ); | 720 | // void dateSelected( int year, int month, int day ); |
721 | 721 | ||
722 | void DateButton::setWeekStartsMonday( int b ) | 722 | void DateButton::setWeekStartsMonday( int b ) |
723 | { | 723 | { |
724 | weekStartsMonday = b; | 724 | weekStartsMonday = b; |
725 | } | 725 | } |
726 | 726 | ||
727 | void DateButton::setDate( int y, int m, int d ) | 727 | void DateButton::setDate( int y, int m, int d ) |
728 | { | 728 | { |
729 | setDate( QDate( y,m,d) ); | 729 | setDate( QDate( y,m,d) ); |
730 | } | 730 | } |
731 | 731 | ||
732 | void DateButton::setDate( QDate d ) | 732 | void DateButton::setDate( QDate d ) |
733 | { | 733 | { |
734 | currDate = d; | 734 | currDate = d; |
735 | setText( longFormat ? TimeString::longDateString( d, df ) : | 735 | setText( longFormat ? TimeString::longDateString( d, df ) : |
736 | TimeString::shortDate( d, df ) ); | 736 | TimeString::shortDate( d, df ) ); |
737 | 737 | ||
738 | } | 738 | } |
739 | 739 | ||
740 | void DateButton::setDateFormat( DateFormat f ) | 740 | void DateButton::setDateFormat( DateFormat f ) |
741 | { | 741 | { |
742 | df = f; | 742 | df = f; |
743 | setDate( currDate ); | 743 | setDate( currDate ); |
744 | } | 744 | } |
745 | 745 | ||
746 | bool DateButton::customWhatsThis() const | 746 | bool DateButton::customWhatsThis() const |
747 | { | 747 | { |
748 | return TRUE; | 748 | return TRUE; |
749 | } | 749 | } |
750 | 750 | ||