summaryrefslogtreecommitdiffabout
path: root/microkde
authorzautrix <zautrix>2005-02-08 18:29:59 (UTC)
committer zautrix <zautrix>2005-02-08 18:29:59 (UTC)
commit2124ce7f8c6edbd0e3ec32b1d1e6a625ef9450d6 (patch) (unidiff)
tree733f50ad5513065fe407fa341948172aae893b52 /microkde
parent126b79abd88bb13ab41c4d987ee759eb9ba7d483 (diff)
downloadkdepimpi-2124ce7f8c6edbd0e3ec32b1d1e6a625ef9450d6.zip
kdepimpi-2124ce7f8c6edbd0e3ec32b1d1e6a625ef9450d6.tar.gz
kdepimpi-2124ce7f8c6edbd0e3ec32b1d1e6a625ef9450d6.tar.bz2
font fix
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdatetbl.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index a9924ba..1024796 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -204,512 +204,514 @@ KDateTable::paintCell(QPainter *painter, int row, int col)
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 if ( e->state() != Qt::ControlButton ) { 243 if ( e->state() != Qt::ControlButton ) {
244 if ( e->key() == Qt::Key_Up ) { 244 if ( e->key() == Qt::Key_Up ) {
245 pos -= 7; 245 pos -= 7;
246 irgnore = false; 246 irgnore = false;
247 } 247 }
248 if ( e->key() == Qt::Key_Down ) { 248 if ( e->key() == Qt::Key_Down ) {
249 pos += 7; 249 pos += 7;
250 irgnore = false; 250 irgnore = false;
251 } 251 }
252 if ( e->key() == Qt::Key_Left ) { 252 if ( e->key() == Qt::Key_Left ) {
253 pos--; 253 pos--;
254 irgnore = false; 254 irgnore = false;
255 } 255 }
256 if ( e->key() == Qt::Key_Right ) { 256 if ( e->key() == Qt::Key_Right ) {
257 pos++; 257 pos++;
258 irgnore = false; 258 irgnore = false;
259 } 259 }
260 } 260 }
261 if ( irgnore ) 261 if ( irgnore )
262 e->ignore(); 262 e->ignore();
263 263
264 if(pos+dayoff<=firstday) 264 if(pos+dayoff<=firstday)
265 { // this day is in the previous month 265 { // this day is in the previous month
266 KNotifyClient::beep(); 266 KNotifyClient::beep();
267 return; 267 return;
268 } 268 }
269 if(firstday+numdays<pos+dayoff) 269 if(firstday+numdays<pos+dayoff)
270 { // this date is in the next month 270 { // this date is in the next month
271 KNotifyClient::beep(i18n( "Month not long enough" )); 271 KNotifyClient::beep(i18n( "Month not long enough" ));
272 return; 272 return;
273 } 273 }
274 274
275 if ( pos == temp ) 275 if ( pos == temp )
276 return; 276 return;
277 277
278 setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); 278 setDate(QDate(date.year(), date.month(), pos-firstday+dayoff));
279 updateCell(temp/7+1, temp%7); // Update the previously selected cell 279 updateCell(temp/7+1, temp%7); // Update the previously selected cell
280 updateCell(pos/7+1, pos%7); // Update the selected cell 280 updateCell(pos/7+1, pos%7); // Update the selected cell
281 assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); 281 assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
282 282
283 283
284} 284}
285 285
286void 286void
287KDateTable::viewportResizeEvent(QResizeEvent * e) 287KDateTable::viewportResizeEvent(QResizeEvent * e)
288{ 288{
289 QGridView::viewportResizeEvent(e); 289 QGridView::viewportResizeEvent(e);
290 290
291 setCellWidth(viewport()->width()/7); 291 setCellWidth(viewport()->width()/7);
292 setCellHeight(viewport()->height()/7); 292 setCellHeight(viewport()->height()/7);
293} 293}
294 294
295void 295void
296KDateTable::setFontSize(int size) 296KDateTable::setFontSize(int size)
297{ 297{
298 int count; 298 int count;
299 QRect rect; 299 QRect rect;
300 // ----- store rectangles: 300 // ----- store rectangles:
301 fontsize=size; 301 fontsize=size;
302 QFont _font = font(); 302 QFont _font = font();
303 _font.setPointSize(fontsize); 303 _font.setPointSize(fontsize);
304 setFont( _font ); 304 setFont( _font );
305 _font.setBold( true ); 305 _font.setBold( true );
306 QFontMetrics metrics(_font); 306 QFontMetrics metrics(_font);
307 307
308 // ----- find largest day name: 308 // ----- find largest day name:
309 maxCell.setWidth(0); 309 maxCell.setWidth(0);
310 maxCell.setHeight(0); 310 maxCell.setHeight(0);
311 for(count=0; count<7; ++count) 311 for(count=0; count<7; ++count)
312 { 312 {
313 rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); 313 rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true));
314 maxCell.setWidth(QMAX(maxCell.width(), rect.width())); 314 maxCell.setWidth(QMAX(maxCell.width(), rect.width()));
315 maxCell.setHeight(QMAX(maxCell.height(), rect.height())); 315 maxCell.setHeight(QMAX(maxCell.height(), rect.height()));
316 } 316 }
317 // ----- compare with a real wide number and add some space: 317 // ----- compare with a real wide number and add some space:
318 rect=metrics.boundingRect(QString::fromLatin1("88")); 318 rect=metrics.boundingRect(QString::fromLatin1("88"));
319 maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); 319 maxCell.setWidth(QMAX(maxCell.width()+2, rect.width()));
320#ifdef DESKTOP_VERSION 320#ifdef DESKTOP_VERSION
321 maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); 321 maxCell.setHeight(QMAX(maxCell.height()+8, rect.height()));
322#else 322#else
323 maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); 323 maxCell.setHeight(QMAX(maxCell.height()+4, rect.height()));
324#endif 324#endif
325 if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { 325 if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) {
326 maxCell.setHeight(maxCell.width() * 1000 / 1900 ); 326 maxCell.setHeight(maxCell.width() * 1000 / 1900 );
327 qDebug("setmax "); 327 qDebug("setmax ");
328 } 328 }
329} 329}
330 330
331void 331void
332KDateTable::contentsMousePressEvent(QMouseEvent *e) 332KDateTable::contentsMousePressEvent(QMouseEvent *e)
333{ 333{
334 if(e->type()!=QEvent::MouseButtonPress) 334 if(e->type()!=QEvent::MouseButtonPress)
335 { // the KDatePicker only reacts on mouse press events: 335 { // the KDatePicker only reacts on mouse press events:
336 return; 336 return;
337 } 337 }
338 if(!isEnabled()) 338 if(!isEnabled())
339 { 339 {
340 KNotifyClient::beep(); 340 KNotifyClient::beep();
341 return; 341 return;
342 } 342 }
343 343
344 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; 344 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
345 // ----- 345 // -----
346 int row, col, pos, temp; 346 int row, col, pos, temp;
347 QPoint mouseCoord; 347 QPoint mouseCoord;
348 // ----- 348 // -----
349 mouseCoord = e->pos(); 349 mouseCoord = e->pos();
350 row=rowAt(mouseCoord.y()); 350 row=rowAt(mouseCoord.y());
351 col=columnAt(mouseCoord.x()); 351 col=columnAt(mouseCoord.x());
352 if(row<0 || col<0) 352 if(row<0 || col<0)
353 { // the user clicked on the frame of the table 353 { // the user clicked on the frame of the table
354 return; 354 return;
355 } 355 }
356 pos=7*(row-1)+col+1; 356 pos=7*(row-1)+col+1;
357#if 0 357#if 0
358 if(pos+dayoff<=firstday) 358 if(pos+dayoff<=firstday)
359 { // this day is in the previous month 359 { // this day is in the previous month
360 KNotifyClient::beep(); 360 KNotifyClient::beep();
361 return; 361 return;
362 } 362 }
363 if(firstday+numdays<pos+dayoff) 363 if(firstday+numdays<pos+dayoff)
364 { // this date is in the next month 364 { // this date is in the next month
365 KNotifyClient::beep(); 365 KNotifyClient::beep();
366 return; 366 return;
367 } 367 }
368#endif 368#endif
369 temp=firstday+date.day()-dayoff-1; 369 temp=firstday+date.day()-dayoff-1;
370 QDate da = QDate(date.year(), date.month(),1); 370 QDate da = QDate(date.year(), date.month(),1);
371 setDate(da.addDays( pos-firstday+dayoff-1)); 371 setDate(da.addDays( pos-firstday+dayoff-1));
372 updateCell(temp/7+1, temp%7); // Update the previously selected cell 372 updateCell(temp/7+1, temp%7); // Update the previously selected cell
373 updateCell(row, col); // Update the selected cell 373 updateCell(row, col); // Update the selected cell
374 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); 374 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
375 emit(tableClicked()); 375 emit(tableClicked());
376} 376}
377 377
378bool 378bool
379KDateTable::setDate(const QDate& date_) 379KDateTable::setDate(const QDate& date_)
380{ 380{
381 bool changed=false; 381 bool changed=false;
382 QDate temp; 382 QDate temp;
383 mMarkCurrent = false; 383 mMarkCurrent = false;
384 // ----- 384 // -----
385 if(!date_.isValid()) 385 if(!date_.isValid())
386 { 386 {
387 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; 387 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl;
388 return false; 388 return false;
389 } 389 }
390 if(date!=date_) 390 if(date!=date_)
391 { 391 {
392 date=date_; 392 date=date_;
393 changed=true; 393 changed=true;
394 } 394 }
395 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); 395 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() );
396 temp.setYMD(date.year(), date.month(), 1); 396 temp.setYMD(date.year(), date.month(), 1);
397 firstday=temp.dayOfWeek(); 397 firstday=temp.dayOfWeek();
398 if(firstday==1) firstday=8; 398 if(firstday==1) firstday=8;
399 numdays=date.daysInMonth(); 399 numdays=date.daysInMonth();
400 if(date.month()==1) 400 if(date.month()==1)
401 { // set to december of previous year 401 { // set to december of previous year
402 temp.setYMD(date.year()-1, 12, 1); 402 temp.setYMD(date.year()-1, 12, 1);
403 } else { // set to previous month 403 } else { // set to previous month
404 temp.setYMD(date.year(), date.month()-1, 1); 404 temp.setYMD(date.year(), date.month()-1, 1);
405 } 405 }
406 numDaysPrevMonth=temp.daysInMonth(); 406 numDaysPrevMonth=temp.daysInMonth();
407 if(changed) 407 if(changed)
408 { 408 {
409 repaintContents(false); 409 repaintContents(false);
410 } 410 }
411 emit(dateChanged(date)); 411 emit(dateChanged(date));
412 return true; 412 return true;
413} 413}
414 414
415const QDate& 415const QDate&
416KDateTable::getDate() const 416KDateTable::getDate() const
417{ 417{
418 return date; 418 return date;
419} 419}
420 420
421void KDateTable::focusInEvent( QFocusEvent *e ) 421void KDateTable::focusInEvent( QFocusEvent *e )
422{ 422{
423 repaintContents(false); 423 repaintContents(false);
424 QGridView::focusInEvent( e ); 424 QGridView::focusInEvent( e );
425} 425}
426 426
427void KDateTable::focusOutEvent( QFocusEvent *e ) 427void KDateTable::focusOutEvent( QFocusEvent *e )
428{ 428{
429 repaintContents(false); 429 repaintContents(false);
430 QGridView::focusOutEvent( e ); 430 QGridView::focusOutEvent( e );
431} 431}
432 432
433QSize 433QSize
434KDateTable::sizeHint() const 434KDateTable::sizeHint() const
435{ 435{
436 if(maxCell.height()>0 && maxCell.width()>0) 436 if(maxCell.height()>0 && maxCell.width()>0)
437 { 437 {
438 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), 438 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(),
439 (maxCell.height()+4)*numRows()+2*frameWidth()); 439 (maxCell.height()+4)*numRows()+2*frameWidth());
440 } else { 440 } else {
441 return QSize(-1, -1); 441 return QSize(-1, -1);
442 } 442 }
443} 443}
444 444
445KDateInternalMonthPicker::KDateInternalMonthPicker 445KDateInternalMonthPicker::KDateInternalMonthPicker
446(QWidget* parent, const char* name) 446(QWidget* parent, const char* name)
447 : QGridView(parent, name), 447 : QGridView(parent, name),
448 result(0) // invalid 448 result(0) // invalid
449{ 449{
450 QRect rect; 450 QRect rect;
451 QFont font; 451 QFont font;
452 // ----- 452 // -----
453 activeCol = -1; 453 activeCol = -1;
454 activeRow = -1; 454 activeRow = -1;
455 font=KGlobalSettings::generalFont(); 455 font=KGlobalSettings::generalFont();
456 int fontsize = 10; 456 int fontsize = 10;
457 int add = 2; 457 int add = 2;
458 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 458 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
459 add += 8; 459 add += 8;
460 if ( QApplication::desktop()->width() > 640 )
461 add += 4;
460 font.setPointSize(fontsize+add); 462 font.setPointSize(fontsize+add);
461 setFont(font); 463 setFont(font);
462 setHScrollBarMode(AlwaysOff); 464 setHScrollBarMode(AlwaysOff);
463 setVScrollBarMode(AlwaysOff); 465 setVScrollBarMode(AlwaysOff);
464 setFrameStyle(QFrame::NoFrame); 466 setFrameStyle(QFrame::NoFrame);
465 setNumRows(4); 467 setNumRows(4);
466 setNumCols(3); 468 setNumCols(3);
467 // enable to find drawing failures: 469 // enable to find drawing failures:
468 // setTableFlags(Tbl_clipCellPainting); 470 // setTableFlags(Tbl_clipCellPainting);
469#if 0 471#if 0
470 viewport()->setEraseColor(lightGray); // for consistency with the datepicker 472 viewport()->setEraseColor(lightGray); // for consistency with the datepicker
471#endif 473#endif
472 // ----- find the preferred size 474 // ----- find the preferred size
473 // (this is slow, possibly, but unfortunatly it is needed here): 475 // (this is slow, possibly, but unfortunatly it is needed here):
474 QFontMetrics metrics(font); 476 QFontMetrics metrics(font);
475 for(int i=1; i <= 12; ++i) 477 for(int i=1; i <= 12; ++i)
476 { 478 {
477 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); 479 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false));
478 if(max.width()<rect.width()) max.setWidth(rect.width()); 480 if(max.width()<rect.width()) max.setWidth(rect.width());
479 if(max.height()<rect.height()) max.setHeight(rect.height()); 481 if(max.height()<rect.height()) max.setHeight(rect.height());
480 } 482 }
481 483
482} 484}
483 485
484QSize 486QSize
485KDateInternalMonthPicker::sizeHint() const 487KDateInternalMonthPicker::sizeHint() const
486{ 488{
487 return QSize((max.width()+6)*numCols()+2*frameWidth(), 489 return QSize((max.width()+6)*numCols()+2*frameWidth(),
488 (max.height()+6)*numRows()+2*frameWidth()); 490 (max.height()+6)*numRows()+2*frameWidth());
489} 491}
490 492
491int 493int
492KDateInternalMonthPicker::getResult() const 494KDateInternalMonthPicker::getResult() const
493{ 495{
494 return result; 496 return result;
495} 497}
496 498
497void 499void
498KDateInternalMonthPicker::setupPainter(QPainter *p) 500KDateInternalMonthPicker::setupPainter(QPainter *p)
499{ 501{
500 p->setPen(black); 502 p->setPen(black);
501} 503}
502 504
503void 505void
504KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) 506KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*)
505{ 507{
506 setCellWidth(width()/3); 508 setCellWidth(width()/3);
507 setCellHeight(height()/4); 509 setCellHeight(height()/4);
508} 510}
509 511
510void 512void
511KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) 513KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col)
512{ 514{
513 int index; 515 int index;
514 QString text; 516 QString text;
515 // ----- find the number of the cell: 517 // ----- find the number of the cell:
516 index=3*row+col+1; 518 index=3*row+col+1;
517 text=KGlobal::locale()->monthName(index, false); 519 text=KGlobal::locale()->monthName(index, false);
518 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); 520 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text);
519 if ( activeCol == col && activeRow == row ) 521 if ( activeCol == col && activeRow == row )
520 painter->drawRect( 0, 0, cellWidth(), cellHeight() ); 522 painter->drawRect( 0, 0, cellWidth(), cellHeight() );
521} 523}
522 524
523void 525void
524KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) 526KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e)
525{ 527{
526 if(!isEnabled() || e->button() != LeftButton) 528 if(!isEnabled() || e->button() != LeftButton)
527 { 529 {
528 KNotifyClient::beep(); 530 KNotifyClient::beep();
529 return; 531 return;
530 } 532 }
531 // ----- 533 // -----
532 int row, col; 534 int row, col;
533 QPoint mouseCoord; 535 QPoint mouseCoord;
534 // ----- 536 // -----
535 mouseCoord = e->pos(); 537 mouseCoord = e->pos();
536 row=rowAt(mouseCoord.y()); 538 row=rowAt(mouseCoord.y());
537 col=columnAt(mouseCoord.x()); 539 col=columnAt(mouseCoord.x());
538 540
539 if(row<0 || col<0) 541 if(row<0 || col<0)
540 { // the user clicked on the frame of the table 542 { // the user clicked on the frame of the table
541 activeCol = -1; 543 activeCol = -1;
542 activeRow = -1; 544 activeRow = -1;
543 } else { 545 } else {
544 activeCol = col; 546 activeCol = col;
545 activeRow = row; 547 activeRow = row;
546 updateCell( row, col /*, false */ ); 548 updateCell( row, col /*, false */ );
547 } 549 }
548} 550}
549 551
550void 552void
551KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) 553KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e)
552{ 554{
553 if (e->state() & LeftButton) 555 if (e->state() & LeftButton)
554 { 556 {
555 int row, col; 557 int row, col;
556 QPoint mouseCoord; 558 QPoint mouseCoord;
557 // ----- 559 // -----
558 mouseCoord = e->pos(); 560 mouseCoord = e->pos();
559 row=rowAt(mouseCoord.y()); 561 row=rowAt(mouseCoord.y());
560 col=columnAt(mouseCoord.x()); 562 col=columnAt(mouseCoord.x());
561 int tmpRow = -1, tmpCol = -1; 563 int tmpRow = -1, tmpCol = -1;
562 if(row<0 || col<0) 564 if(row<0 || col<0)
563 { // the user clicked on the frame of the table 565 { // the user clicked on the frame of the table
564 if ( activeCol > -1 ) 566 if ( activeCol > -1 )
565 { 567 {
566 tmpRow = activeRow; 568 tmpRow = activeRow;
567 tmpCol = activeCol; 569 tmpCol = activeCol;
568 } 570 }
569 activeCol = -1; 571 activeCol = -1;
570 activeRow = -1; 572 activeRow = -1;
571 } else { 573 } else {
572 bool differentCell = (activeRow != row || activeCol != col); 574 bool differentCell = (activeRow != row || activeCol != col);
573 if ( activeCol > -1 && differentCell) 575 if ( activeCol > -1 && differentCell)
574 { 576 {
575 tmpRow = activeRow; 577 tmpRow = activeRow;
576 tmpCol = activeCol; 578 tmpCol = activeCol;
577 } 579 }
578 if ( differentCell) 580 if ( differentCell)
579 { 581 {
580 activeRow = row; 582 activeRow = row;
581 activeCol = col; 583 activeCol = col;
582 updateCell( row, col /*, false */ ); // mark the new active cell 584 updateCell( row, col /*, false */ ); // mark the new active cell
583 } 585 }
584 } 586 }
585 if ( tmpRow > -1 ) // repaint the former active cell 587 if ( tmpRow > -1 ) // repaint the former active cell
586 updateCell( tmpRow, tmpCol /*, true */ ); 588 updateCell( tmpRow, tmpCol /*, true */ );
587 } 589 }
588} 590}
589 591
590void 592void
591KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) 593KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e)
592{ 594{
593 if(!isEnabled()) 595 if(!isEnabled())
594 { 596 {
595 return; 597 return;
596 } 598 }
597 // ----- 599 // -----
598 int row, col, pos; 600 int row, col, pos;
599 QPoint mouseCoord; 601 QPoint mouseCoord;
600 // ----- 602 // -----
601 mouseCoord = e->pos(); 603 mouseCoord = e->pos();
602 row=rowAt(mouseCoord.y()); 604 row=rowAt(mouseCoord.y());
603 col=columnAt(mouseCoord.x()); 605 col=columnAt(mouseCoord.x());
604 if(row<0 || col<0) 606 if(row<0 || col<0)
605 { // the user clicked on the frame of the table 607 { // the user clicked on the frame of the table
606 emit(closeMe(0)); 608 emit(closeMe(0));
607 } 609 }
608 pos=3*row+col+1; 610 pos=3*row+col+1;
609 result=pos; 611 result=pos;
610 emit(closeMe(1)); 612 emit(closeMe(1));
611} 613}
612 614
613 615
614 616
615KDateInternalYearSelector::KDateInternalYearSelector 617KDateInternalYearSelector::KDateInternalYearSelector
616(int fontsize, QWidget* parent, const char* name) 618(int fontsize, QWidget* parent, const char* name)
617 : QLineEdit(parent, name), 619 : QLineEdit(parent, name),
618 val(new QIntValidator(this)), 620 val(new QIntValidator(this)),
619 result(0) 621 result(0)
620{ 622{
621 QFont font; 623 QFont font;
622 // ----- 624 // -----
623 font=KGlobalSettings::generalFont(); 625 font=KGlobalSettings::generalFont();
624 font.setPointSize(fontsize); 626 font.setPointSize(fontsize);
625 setFont(font); 627 setFont(font);
626#if 0 628#if 0
627 setFrameStyle(QFrame::NoFrame); 629 setFrameStyle(QFrame::NoFrame);
628#endif 630#endif
629 // we have to respect the limits of QDate here, I fear: 631 // we have to respect the limits of QDate here, I fear:
630 val->setRange(0, 8000); 632 val->setRange(0, 8000);
631 setValidator(val); 633 setValidator(val);
632 connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot())); 634 connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot()));
633} 635}
634 636
635void 637void
636KDateInternalYearSelector::yearEnteredSlot() 638KDateInternalYearSelector::yearEnteredSlot()
637{ 639{
638 bool ok; 640 bool ok;
639 int year; 641 int year;
640 QDate date; 642 QDate date;
641 // ----- check if this is a valid year: 643 // ----- check if this is a valid year:
642 year=text().toInt(&ok); 644 year=text().toInt(&ok);
643 if(!ok) 645 if(!ok)
644 { 646 {
645 KNotifyClient::beep(); 647 KNotifyClient::beep();
646 return; 648 return;
647 } 649 }
648 date.setYMD(year, 1, 1); 650 date.setYMD(year, 1, 1);
649 if(!date.isValid()) 651 if(!date.isValid())
650 { 652 {
651 KNotifyClient::beep(); 653 KNotifyClient::beep();
652 return; 654 return;
653 } 655 }
654 result=year; 656 result=year;
655 emit(closeMe(1)); 657 emit(closeMe(1));
656} 658}
657 659
658int 660int
659KDateInternalYearSelector::getYear() 661KDateInternalYearSelector::getYear()
660{ 662{
661 return result; 663 return result;
662} 664}
663 665
664void 666void
665KDateInternalYearSelector::setYear(int year) 667KDateInternalYearSelector::setYear(int year)
666{ 668{
667 QString temp; 669 QString temp;
668 // ----- 670 // -----
669 temp.setNum(year); 671 temp.setNum(year);
670 setText(temp); 672 setText(temp);
671} 673}
672 674
673KPopupFrame::KPopupFrame(QWidget* parent, const char* name) 675KPopupFrame::KPopupFrame(QWidget* parent, const char* name)
674 : QFrame(parent, name, WType_Popup), 676 : QFrame(parent, name, WType_Popup),
675 result(0), // rejected 677 result(0), // rejected
676 main(0) 678 main(0)
677{ 679{
678 setFrameStyle(QFrame::Box|QFrame::Raised); 680 setFrameStyle(QFrame::Box|QFrame::Raised);
679 setMidLineWidth(2); 681 setMidLineWidth(2);
680} 682}
681 683
682void 684void
683KPopupFrame::keyPressEvent(QKeyEvent* e) 685KPopupFrame::keyPressEvent(QKeyEvent* e)
684{ 686{
685 if(e->key()==Key_Escape) 687 if(e->key()==Key_Escape)
686 { 688 {
687 result=0; // rejected 689 result=0; // rejected
688 qApp->exit_loop(); 690 qApp->exit_loop();
689 } 691 }
690} 692}
691 693
692void 694void
693KPopupFrame::close(int r) 695KPopupFrame::close(int r)
694{ 696{
695 result=r; 697 result=r;
696 qApp->exit_loop(); 698 qApp->exit_loop();
697} 699}
698 700
699void 701void
700KPopupFrame::setMainWidget(QWidget* m) 702KPopupFrame::setMainWidget(QWidget* m)
701{ 703{
702 main=m; 704 main=m;
703 if(main!=0) 705 if(main!=0)
704 { 706 {
705 resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); 707 resize(main->width()+2*frameWidth(), main->height()+2*frameWidth());
706 } 708 }
707} 709}
708 710
709void 711void
710KPopupFrame::resizeEvent(QResizeEvent*) 712KPopupFrame::resizeEvent(QResizeEvent*)
711{ 713{
712 if(main!=0) 714 if(main!=0)
713 { 715 {
714 main->setGeometry(frameWidth(), frameWidth(), 716 main->setGeometry(frameWidth(), frameWidth(),
715 width()-2*frameWidth(), height()-2*frameWidth()); 717 width()-2*frameWidth(), height()-2*frameWidth());