summaryrefslogtreecommitdiffabout
path: root/microkde/kdatetbl.cpp
authorzautrix <zautrix>2005-10-27 23:22:36 (UTC)
committer zautrix <zautrix>2005-10-27 23:22:36 (UTC)
commitcbda16d4966c7483d20d1b6b5a64c8af367ea732 (patch) (unidiff)
tree47099fd5b318c47eb1d8fff3d8a3eef6e34f6f23 /microkde/kdatetbl.cpp
parentd6d384e50cfd511866958e58cdd3adeb35ed1c4e (diff)
downloadkdepimpi-cbda16d4966c7483d20d1b6b5a64c8af367ea732.zip
kdepimpi-cbda16d4966c7483d20d1b6b5a64c8af367ea732.tar.gz
kdepimpi-cbda16d4966c7483d20d1b6b5a64c8af367ea732.tar.bz2
us fix
Diffstat (limited to 'microkde/kdatetbl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdatetbl.cpp32
1 files changed, 10 insertions, 22 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index 4271b55..353f78d 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -51,425 +51,413 @@ KDateValidator::KDateValidator(QWidget* parent, const char* name)
51 : QValidator(parent, name) 51 : QValidator(parent, name)
52{ 52{
53} 53}
54 54
55QValidator::State 55QValidator::State
56KDateValidator::validate(QString& text, int&) const 56KDateValidator::validate(QString& text, int&) const
57{ 57{
58 QDate temp; 58 QDate temp;
59 // ----- everything is tested in date(): 59 // ----- everything is tested in date():
60 return date(text, temp); 60 return date(text, temp);
61} 61}
62 62
63QValidator::State 63QValidator::State
64KDateValidator::date(const QString& text, QDate& d) const 64KDateValidator::date(const QString& text, QDate& d) const
65{ 65{
66 QDate tmp = KGlobal::locale()->readDate(text); 66 QDate tmp = KGlobal::locale()->readDate(text);
67 if (!tmp.isNull()) 67 if (!tmp.isNull())
68 { 68 {
69 d = tmp; 69 d = tmp;
70 return Acceptable; 70 return Acceptable;
71 } else 71 } else
72 return Valid; 72 return Valid;
73} 73}
74 74
75void 75void
76KDateValidator::fixup( QString& ) const 76KDateValidator::fixup( QString& ) const
77{ 77{
78 78
79} 79}
80 80
81KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) 81KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f)
82 : QGridView(parent, name, f) 82 : QGridView(parent, name, f)
83{ 83{
84 setFont( KGlobalSettings::generalFont() ); 84 setFont( KGlobalSettings::generalFont() );
85 if(!date_.isValid()) 85 if(!date_.isValid())
86 { 86 {
87 date_=QDate::currentDate(); 87 date_=QDate::currentDate();
88 } 88 }
89 setFocusPolicy( QWidget::StrongFocus ); 89 setFocusPolicy( QWidget::StrongFocus );
90 setNumRows(7); // 6 weeks max + headline 90 setNumRows(7); // 6 weeks max + headline
91 setNumCols(7); // 7 days a week 91 setNumCols(7); // 7 days a week
92 setHScrollBarMode(AlwaysOff); 92 setHScrollBarMode(AlwaysOff);
93 setVScrollBarMode(AlwaysOff); 93 setVScrollBarMode(AlwaysOff);
94 viewport()->setBackgroundColor(QColor(220,245,255)); 94 viewport()->setBackgroundColor(QColor(220,245,255));
95#if 0 95#if 0
96 viewport()->setEraseColor(lightGray); 96 viewport()->setEraseColor(lightGray);
97#endif 97#endif
98 mMarkCurrent = false; 98 mMarkCurrent = false;
99 setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth 99 setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth
100} 100}
101 101
102void 102void
103KDateTable::paintCell(QPainter *painter, int row, int col) 103KDateTable::paintCell(QPainter *painter, int row, int col)
104{ 104{
105 QRect rect; 105 QRect rect;
106 QString text; 106 QString text;
107 QPen pen; 107 QPen pen;
108 int w=cellWidth(); 108 int w=cellWidth();
109 int h=cellHeight(); 109 int h=cellHeight();
110 int pos; 110 int pos;
111 QBrush brushBlue(blue); 111 QBrush brushBlue(blue);
112 QBrush brushLightblue(QColor(220,245,255)); 112 QBrush brushLightblue(QColor(220,245,255));
113 QFont _font=font(); 113 QFont _font=font();
114 // ----- 114 // -----
115 if(row==0) 115 if(row==0)
116 { // we are drawing the headline 116 { // we are drawing the headline
117 _font.setBold(true); 117 _font.setBold(true);
118 painter->setFont(_font); 118 painter->setFont(_font);
119 bool normalday = true; 119 bool normalday = true;
120 QString daystr; 120 QString daystr;
121 if (KGlobal::locale()->weekStartsMonday()) 121 if (KGlobal::locale()->weekStartsMonday())
122 { 122 {
123 daystr = KGlobal::locale()->weekDayName(col+1, true); 123 daystr = KGlobal::locale()->weekDayName(col+1, true);
124 if (col == 5 || col == 6) 124 if (col == 5 || col == 6)
125 normalday = false; 125 normalday = false;
126 } else { 126 } else {
127 daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); 127 daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true);
128 if (col == 0 || col == 6) 128 if (col == 0 || col == 6)
129 normalday = false; 129 normalday = false;
130 } 130 }
131 if (!normalday) 131 if (!normalday)
132 { 132 {
133 painter->setPen(QColor(220,245,255)); 133 painter->setPen(QColor(220,245,255));
134 painter->setBrush(brushLightblue); 134 painter->setBrush(brushLightblue);
135 painter->drawRect(0, 0, w, h); 135 painter->drawRect(0, 0, w, h);
136 painter->setPen(blue); 136 painter->setPen(blue);
137 } else { 137 } else {
138 painter->setPen(blue); 138 painter->setPen(blue);
139 painter->setBrush(brushBlue); 139 painter->setBrush(brushBlue);
140 painter->drawRect(0, 0, w, h); 140 painter->drawRect(0, 0, w, h);
141 painter->setPen(white); 141 painter->setPen(white);
142 } 142 }
143 painter->drawText(0, 0, w, h-1, AlignCenter, 143 painter->drawText(0, 0, w, h-1, AlignCenter,
144 daystr, -1, &rect); 144 daystr, -1, &rect);
145 painter->setPen(black); 145 painter->setPen(black);
146 painter->moveTo(0, h-1); 146 painter->moveTo(0, h-1);
147 painter->lineTo(w-1, h-1); 147 painter->lineTo(w-1, h-1);
148 // ----- draw the weekday: 148 // ----- draw the weekday:
149 } else { 149 } else {
150 painter->setFont(_font); 150 painter->setFont(_font);
151 pos=7*(row-1)+col; 151 pos=7*(row-1)+col;
152 if (KGlobal::locale()->weekStartsMonday()) 152 if (KGlobal::locale()->weekStartsMonday())
153 pos++; 153 pos++;
154 if(pos<firstday || (firstday+numdays<=pos)) 154 if(pos<firstday || (firstday+numdays<=pos))
155 { // we are either 155 { // we are either
156 // ° painting a day of the previous month or 156 // ° painting a day of the previous month or
157 // ° painting a day of the following month 157 // ° painting a day of the following month
158 if(pos<firstday) 158 if(pos<firstday)
159 { // previous month 159 { // previous month
160 text.setNum(numDaysPrevMonth+pos-firstday+1); 160 text.setNum(numDaysPrevMonth+pos-firstday+1);
161 } else { // following month 161 } else { // following month
162 text.setNum(pos-firstday-numdays+1); 162 text.setNum(pos-firstday-numdays+1);
163 } 163 }
164 painter->setPen(gray); 164 painter->setPen(gray);
165 } else { // paint a day of the current month 165 } else { // paint a day of the current month
166 text.setNum(pos-firstday+1); 166 text.setNum(pos-firstday+1);
167 painter->setPen(black); 167 painter->setPen(black);
168 } 168 }
169 169
170 pen=painter->pen(); 170 pen=painter->pen();
171 if(firstday+date.day()-1==pos) 171 if(firstday+date.day()-1==pos)
172 { 172 {
173 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) 173 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos)
174 painter->setPen(green); 174 painter->setPen(green);
175 else 175 else
176 painter->setPen(red); 176 painter->setPen(red);
177 if(hasFocus()) 177 if(hasFocus())
178 { 178 {
179 painter->setBrush(darkRed); 179 painter->setBrush(darkRed);
180 pen=white; 180 pen=white;
181 } else { 181 } else {
182 painter->setBrush(darkGray); 182 painter->setBrush(darkGray);
183 pen=white; 183 pen=white;
184 } 184 }
185 } else { 185 } else {
186 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) 186 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos)
187 { 187 {
188 painter->setPen(green); 188 painter->setPen(green);
189 painter->setBrush(darkGreen); 189 painter->setBrush(darkGreen);
190 pen=white; 190 pen=white;
191 } else { 191 } else {
192 painter->setBrush(QColor(220,245,255)); 192 painter->setBrush(QColor(220,245,255));
193 painter->setPen(QColor(220,245,255)); 193 painter->setPen(QColor(220,245,255));
194 } 194 }
195 } 195 }
196 painter->drawRect(0, 0, w, h); 196 painter->drawRect(0, 0, w, h);
197 painter->setPen(pen); 197 painter->setPen(pen);
198 painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); 198 painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect);
199 } 199 }
200 /* 200 /*
201 if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); 201 if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width());
202 if(rect.height()>maxCell.height()) { 202 if(rect.height()>maxCell.height()) {
203 maxCell.setHeight(rect.height()); 203 maxCell.setHeight(rect.height());
204 } 204 }
205 */ 205 */
206} 206}
207 207
208void 208void
209KDateTable::keyPressEvent( QKeyEvent *e ) 209KDateTable::keyPressEvent( QKeyEvent *e )
210{ 210{
211 /* 211 /*
212 // not working properly 212 // not working properly
213 if ( e->key() == Qt::Key_Prior ) { 213 if ( e->key() == Qt::Key_Prior ) {
214 if ( date.month() == 1 ) { 214 if ( date.month() == 1 ) {
215 KNotifyClient::beep(); 215 KNotifyClient::beep();
216 return; 216 return;
217 } 217 }
218 int day = date.day(); 218 int day = date.day();
219 if ( day > 27 ) 219 if ( day > 27 )
220 while ( !QDate::isValid( date.year(), date.month()-1, day ) ) 220 while ( !QDate::isValid( date.year(), date.month()-1, day ) )
221 day--; 221 day--;
222 setDate(QDate(date.year(), date.month()-1, day)); 222 setDate(QDate(date.year(), date.month()-1, day));
223 return; 223 return;
224 } 224 }
225 if ( e->key() == Qt::Key_Next ) { 225 if ( e->key() == Qt::Key_Next ) {
226 if ( date.month() == 12 ) { 226 if ( date.month() == 12 ) {
227 KNotifyClient::beep(); 227 KNotifyClient::beep();
228 return; 228 return;
229 } 229 }
230 int day = date.day(); 230 int day = date.day();
231 if ( day > 27 ) 231 if ( day > 27 )
232 while ( !QDate::isValid( date.year(), date.month()+1, day ) ) 232 while ( !QDate::isValid( date.year(), date.month()+1, day ) )
233 day--; 233 day--;
234 setDate(QDate(date.year(), date.month()+1, day)); 234 setDate(QDate(date.year(), date.month()+1, day));
235 return; 235 return;
236 } 236 }
237 */ 237 */
238 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; 238 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
239 239
240 int temp=firstday+date.day()-dayoff; 240 int temp=firstday+date.day()-dayoff;
241 int pos = temp; 241 int pos = temp;
242 bool irgnore = true; 242 bool irgnore = true;
243 int add = 0;
243 if ( e->state() != Qt::ControlButton ) { 244 if ( e->state() != Qt::ControlButton ) {
244 if ( e->key() == Qt::Key_Up ) { 245 if ( e->key() == Qt::Key_Up ) {
245 pos -= 7; 246 add -= 7;
246 irgnore = false; 247 irgnore = false;
247 } 248 }
248 if ( e->key() == Qt::Key_Down ) { 249 if ( e->key() == Qt::Key_Down ) {
249 pos += 7; 250 add += 7;
250 irgnore = false; 251 irgnore = false;
251 } 252 }
252 if ( e->key() == Qt::Key_Left ) { 253 if ( e->key() == Qt::Key_Left ) {
253 pos--; 254 --add;
254 irgnore = false; 255 irgnore = false;
255 } 256 }
256 if ( e->key() == Qt::Key_Right ) { 257 if ( e->key() == Qt::Key_Right ) {
257 pos++; 258 ++add;
258 irgnore = false; 259 irgnore = false;
259 } 260 }
260 } 261 }
261 if ( irgnore ) 262 if ( irgnore ) {
262 e->ignore(); 263 e->ignore();
263
264 if(pos+dayoff<=firstday)
265 { // this day is in the previous month
266 KNotifyClient::beep();
267 return;
268 }
269 if(firstday+numdays<pos+dayoff)
270 { // this date is in the next month
271 KNotifyClient::beep(i18n( "Month not long enough" ));
272 return;
273 }
274
275 if ( pos == temp )
276 return; 264 return;
265 }
277 266
278 setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); 267 pos += add;
268 setDate(date.addDays( add ));
279 updateCell(temp/7+1, temp%7); // Update the previously selected cell 269 updateCell(temp/7+1, temp%7); // Update the previously selected cell
280 updateCell(pos/7+1, pos%7); // Update the selected cell 270 updateCell(pos/7+1, pos%7); // Update the selected cell
281 assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); 271
282
283
284} 272}
285 273
286void 274void
287KDateTable::viewportResizeEvent(QResizeEvent * e) 275KDateTable::viewportResizeEvent(QResizeEvent * e)
288{ 276{
289 QGridView::viewportResizeEvent(e); 277 QGridView::viewportResizeEvent(e);
290 278
291 setCellWidth(viewport()->width()/7); 279 setCellWidth(viewport()->width()/7);
292 setCellHeight(viewport()->height()/7); 280 setCellHeight(viewport()->height()/7);
293} 281}
294 282
295void 283void
296KDateTable::setFontSize(int size) 284KDateTable::setFontSize(int size)
297{ 285{
298 int count; 286 int count;
299 QRect rect; 287 QRect rect;
300 // ----- store rectangles: 288 // ----- store rectangles:
301 fontsize=size; 289 fontsize=size;
302 QFont _font = font(); 290 QFont _font = font();
303 _font.setPointSize(fontsize); 291 _font.setPointSize(fontsize);
304 setFont( _font ); 292 setFont( _font );
305 _font.setBold( true ); 293 _font.setBold( true );
306 QFontMetrics metrics(_font); 294 QFontMetrics metrics(_font);
307 295
308 // ----- find largest day name: 296 // ----- find largest day name:
309 maxCell.setWidth(0); 297 maxCell.setWidth(0);
310 maxCell.setHeight(0); 298 maxCell.setHeight(0);
311 for(count=0; count<7; ++count) 299 for(count=0; count<7; ++count)
312 { 300 {
313 rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); 301 rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true));
314 maxCell.setWidth(QMAX(maxCell.width(), rect.width())); 302 maxCell.setWidth(QMAX(maxCell.width(), rect.width()));
315 maxCell.setHeight(QMAX(maxCell.height(), rect.height())); 303 maxCell.setHeight(QMAX(maxCell.height(), rect.height()));
316 } 304 }
317 // ----- compare with a real wide number and add some space: 305 // ----- compare with a real wide number and add some space:
318 rect=metrics.boundingRect(QString::fromLatin1("88")); 306 rect=metrics.boundingRect(QString::fromLatin1("88"));
319 maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); 307 maxCell.setWidth(QMAX(maxCell.width()+2, rect.width()));
320#ifdef DESKTOP_VERSION 308#ifdef DESKTOP_VERSION
321 maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); 309 maxCell.setHeight(QMAX(maxCell.height()+8, rect.height()));
322#else 310#else
323 maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); 311 maxCell.setHeight(QMAX(maxCell.height()+4, rect.height()));
324#endif 312#endif
325 if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { 313 if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) {
326 maxCell.setHeight(maxCell.width() * 1000 / 1900 ); 314 maxCell.setHeight(maxCell.width() * 1000 / 1900 );
327 //qDebug("setmax "); 315 //qDebug("setmax ");
328 } 316 }
329} 317}
330 318
331void 319void
332KDateTable::contentsMousePressEvent(QMouseEvent *e) 320KDateTable::contentsMousePressEvent(QMouseEvent *e)
333{ 321{
334 if(e->type()!=QEvent::MouseButtonPress) 322 if(e->type()!=QEvent::MouseButtonPress)
335 { // the KDatePicker only reacts on mouse press events: 323 { // the KDatePicker only reacts on mouse press events:
336 return; 324 return;
337 } 325 }
338 if(!isEnabled()) 326 if(!isEnabled())
339 { 327 {
340 KNotifyClient::beep(); 328 KNotifyClient::beep();
341 return; 329 return;
342 } 330 }
343 331
344 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; 332 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
345 // ----- 333 // -----
346 int row, col, pos, temp; 334 int row, col, pos, temp;
347 QPoint mouseCoord; 335 QPoint mouseCoord;
348 // ----- 336 // -----
349 mouseCoord = e->pos(); 337 mouseCoord = e->pos();
350 row=rowAt(mouseCoord.y()); 338 row=rowAt(mouseCoord.y());
351 col=columnAt(mouseCoord.x()); 339 col=columnAt(mouseCoord.x());
352 if(row<0 || col<0) 340 if(row<0 || col<0)
353 { // the user clicked on the frame of the table 341 { // the user clicked on the frame of the table
354 return; 342 return;
355 } 343 }
356 pos=7*(row-1)+col+1; 344 pos=7*(row-1)+col+1;
357#if 0 345#if 0
358 if(pos+dayoff<=firstday) 346 if(pos+dayoff<=firstday)
359 { // this day is in the previous month 347 { // this day is in the previous month
360 KNotifyClient::beep(); 348 KNotifyClient::beep();
361 return; 349 return;
362 } 350 }
363 if(firstday+numdays<pos+dayoff) 351 if(firstday+numdays<pos+dayoff)
364 { // this date is in the next month 352 { // this date is in the next month
365 KNotifyClient::beep(); 353 KNotifyClient::beep();
366 return; 354 return;
367 } 355 }
368#endif 356#endif
369 temp=firstday+date.day()-dayoff-1; 357 temp=firstday+date.day()-dayoff-1;
370 QDate da = QDate(date.year(), date.month(),1); 358 QDate da = QDate(date.year(), date.month(),1);
371 setDate(da.addDays( pos-firstday+dayoff-1)); 359 setDate(da.addDays( pos-firstday+dayoff-1));
372 updateCell(temp/7+1, temp%7); // Update the previously selected cell 360 updateCell(temp/7+1, temp%7); // Update the previously selected cell
373 updateCell(row, col); // Update the selected cell 361 updateCell(row, col); // Update the selected cell
374 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); 362 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
375 emit(tableClicked()); 363 emit(tableClicked());
376} 364}
377 365
378bool 366bool
379KDateTable::setDate(const QDate& date_) 367KDateTable::setDate(const QDate& date_)
380{ 368{
381 bool changed=false; 369 bool changed=false;
382 QDate temp; 370 QDate temp;
383 mMarkCurrent = false; 371 mMarkCurrent = false;
384 // ----- 372 // -----
385 if(!date_.isValid()) 373 if(!date_.isValid())
386 { 374 {
387 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; 375 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl;
388 return false; 376 return false;
389 } 377 }
390 if(date!=date_) 378 if(date!=date_)
391 { 379 {
392 date=date_; 380 date=date_;
393 changed=true; 381 changed=true;
394 } 382 }
395 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); 383 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() );
396 temp.setYMD(date.year(), date.month(), 1); 384 temp.setYMD(date.year(), date.month(), 1);
397 firstday=temp.dayOfWeek(); 385 firstday=temp.dayOfWeek();
398 if(firstday==1) firstday=8; 386 if(firstday==1) firstday=8;
399 numdays=date.daysInMonth(); 387 numdays=date.daysInMonth();
400 if(date.month()==1) 388 if(date.month()==1)
401 { // set to december of previous year 389 { // set to december of previous year
402 temp.setYMD(date.year()-1, 12, 1); 390 temp.setYMD(date.year()-1, 12, 1);
403 } else { // set to previous month 391 } else { // set to previous month
404 temp.setYMD(date.year(), date.month()-1, 1); 392 temp.setYMD(date.year(), date.month()-1, 1);
405 } 393 }
406 numDaysPrevMonth=temp.daysInMonth(); 394 numDaysPrevMonth=temp.daysInMonth();
407 if(changed) 395 if(changed)
408 { 396 {
409 repaintContents(false); 397 repaintContents(false);
410 } 398 }
411 emit(dateChanged(date)); 399 emit(dateChanged(date));
412 return true; 400 return true;
413} 401}
414 402
415const QDate& 403const QDate&
416KDateTable::getDate() const 404KDateTable::getDate() const
417{ 405{
418 return date; 406 return date;
419} 407}
420 408
421void KDateTable::focusInEvent( QFocusEvent *e ) 409void KDateTable::focusInEvent( QFocusEvent *e )
422{ 410{
423 repaintContents(false); 411 repaintContents(false);
424 QGridView::focusInEvent( e ); 412 QGridView::focusInEvent( e );
425} 413}
426 414
427void KDateTable::focusOutEvent( QFocusEvent *e ) 415void KDateTable::focusOutEvent( QFocusEvent *e )
428{ 416{
429 repaintContents(false); 417 repaintContents(false);
430 QGridView::focusOutEvent( e ); 418 QGridView::focusOutEvent( e );
431} 419}
432 420
433QSize 421QSize
434KDateTable::sizeHint() const 422KDateTable::sizeHint() const
435{ 423{
436 if(maxCell.height()>0 && maxCell.width()>0) 424 if(maxCell.height()>0 && maxCell.width()>0)
437 { 425 {
438 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), 426 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(),
439 (maxCell.height()+4)*numRows()+2*frameWidth()); 427 (maxCell.height()+4)*numRows()+2*frameWidth());
440 } else { 428 } else {
441 return QSize(-1, -1); 429 return QSize(-1, -1);
442 } 430 }
443} 431}
444 432
445KDateInternalMonthPicker::KDateInternalMonthPicker 433KDateInternalMonthPicker::KDateInternalMonthPicker
446(QWidget* parent, const char* name) 434(QWidget* parent, const char* name)
447 : QGridView(parent, name), 435 : QGridView(parent, name),
448 result(0) // invalid 436 result(0) // invalid
449{ 437{
450 QRect rect; 438 QRect rect;
451 QFont font; 439 QFont font;
452 // ----- 440 // -----
453 activeCol = -1; 441 activeCol = -1;
454 activeRow = -1; 442 activeRow = -1;
455 font=KGlobalSettings::generalFont(); 443 font=KGlobalSettings::generalFont();
456 int fontsize = 10; 444 int fontsize = 10;
457 int add = 2; 445 int add = 2;
458 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 446 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
459 add += 8; 447 add += 8;
460 if ( QApplication::desktop()->width() > 640 ) 448 if ( QApplication::desktop()->width() > 640 )
461 add += 6; 449 add += 6;
462 font.setPointSize(fontsize+add); 450 font.setPointSize(fontsize+add);
463 setFont(font); 451 setFont(font);
464 setHScrollBarMode(AlwaysOff); 452 setHScrollBarMode(AlwaysOff);
465 setVScrollBarMode(AlwaysOff); 453 setVScrollBarMode(AlwaysOff);
466 setFrameStyle(QFrame::NoFrame); 454 setFrameStyle(QFrame::NoFrame);
467 setNumRows(4); 455 setNumRows(4);
468 setNumCols(3); 456 setNumCols(3);
469 // enable to find drawing failures: 457 // enable to find drawing failures:
470 // setTableFlags(Tbl_clipCellPainting); 458 // setTableFlags(Tbl_clipCellPainting);
471#if 0 459#if 0
472 viewport()->setEraseColor(lightGray); // for consistency with the datepicker 460 viewport()->setEraseColor(lightGray); // for consistency with the datepicker
473#endif 461#endif
474 // ----- find the preferred size 462 // ----- find the preferred size
475 // (this is slow, possibly, but unfortunatly it is needed here): 463 // (this is slow, possibly, but unfortunatly it is needed here):