-rw-r--r-- | microkde/kdatetbl.cpp | 2 |
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 | |||
@@ -396,128 +396,130 @@ KDateTable::setDate(const QDate& date_) | |||
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 | ||
415 | const QDate& | 415 | const QDate& |
416 | KDateTable::getDate() const | 416 | KDateTable::getDate() const |
417 | { | 417 | { |
418 | return date; | 418 | return date; |
419 | } | 419 | } |
420 | 420 | ||
421 | void KDateTable::focusInEvent( QFocusEvent *e ) | 421 | void KDateTable::focusInEvent( QFocusEvent *e ) |
422 | { | 422 | { |
423 | repaintContents(false); | 423 | repaintContents(false); |
424 | QGridView::focusInEvent( e ); | 424 | QGridView::focusInEvent( e ); |
425 | } | 425 | } |
426 | 426 | ||
427 | void KDateTable::focusOutEvent( QFocusEvent *e ) | 427 | void KDateTable::focusOutEvent( QFocusEvent *e ) |
428 | { | 428 | { |
429 | repaintContents(false); | 429 | repaintContents(false); |
430 | QGridView::focusOutEvent( e ); | 430 | QGridView::focusOutEvent( e ); |
431 | } | 431 | } |
432 | 432 | ||
433 | QSize | 433 | QSize |
434 | KDateTable::sizeHint() const | 434 | KDateTable::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 | ||
445 | KDateInternalMonthPicker::KDateInternalMonthPicker | 445 | KDateInternalMonthPicker::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 | ||
484 | QSize | 486 | QSize |
485 | KDateInternalMonthPicker::sizeHint() const | 487 | KDateInternalMonthPicker::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 | ||
491 | int | 493 | int |
492 | KDateInternalMonthPicker::getResult() const | 494 | KDateInternalMonthPicker::getResult() const |
493 | { | 495 | { |
494 | return result; | 496 | return result; |
495 | } | 497 | } |
496 | 498 | ||
497 | void | 499 | void |
498 | KDateInternalMonthPicker::setupPainter(QPainter *p) | 500 | KDateInternalMonthPicker::setupPainter(QPainter *p) |
499 | { | 501 | { |
500 | p->setPen(black); | 502 | p->setPen(black); |
501 | } | 503 | } |
502 | 504 | ||
503 | void | 505 | void |
504 | KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) | 506 | KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) |
505 | { | 507 | { |
506 | setCellWidth(width()/3); | 508 | setCellWidth(width()/3); |
507 | setCellHeight(height()/4); | 509 | setCellHeight(height()/4); |
508 | } | 510 | } |
509 | 511 | ||
510 | void | 512 | void |
511 | KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) | 513 | KDateInternalMonthPicker::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 | ||
523 | void | 525 | void |