-rw-r--r-- | korganizer/komonthview.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 12233ee..9085775 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -421,192 +421,197 @@ QToolTipGroup *MonthViewCell::toolTipGroup() | |||
421 | #endif | 421 | #endif |
422 | 422 | ||
423 | void MonthViewCell::setDate( const QDate &date ) | 423 | void MonthViewCell::setDate( const QDate &date ) |
424 | { | 424 | { |
425 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 425 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
426 | mDate = date; | 426 | mDate = date; |
427 | 427 | ||
428 | 428 | ||
429 | 429 | ||
430 | //resizeEvent( 0 ); | 430 | //resizeEvent( 0 ); |
431 | } | 431 | } |
432 | 432 | ||
433 | QDate MonthViewCell::date() const | 433 | QDate MonthViewCell::date() const |
434 | { | 434 | { |
435 | return mDate; | 435 | return mDate; |
436 | } | 436 | } |
437 | 437 | ||
438 | void MonthViewCell::setPrimary( bool primary ) | 438 | void MonthViewCell::setPrimary( bool primary ) |
439 | { | 439 | { |
440 | mPrimary = primary; | 440 | mPrimary = primary; |
441 | //setMyPalette(); | 441 | //setMyPalette(); |
442 | } | 442 | } |
443 | void MonthViewCell::setMyPalette() | 443 | void MonthViewCell::setMyPalette() |
444 | { | 444 | { |
445 | 445 | ||
446 | if ( mHoliday) { | 446 | if ( mHoliday) { |
447 | if ( currentPalette == 1 ) return; | 447 | if ( currentPalette == 1 ) return; |
448 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 448 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
449 | setPalette( mHolidayPalette ); | 449 | setPalette( mHolidayPalette ); |
450 | //mLabel->setPalette( mHolidayPalette ); | 450 | //mLabel->setPalette( mHolidayPalette ); |
451 | currentPalette = 1; | 451 | currentPalette = 1; |
452 | 452 | ||
453 | } else { | 453 | } else { |
454 | if ( mPrimary ) { | 454 | if ( mPrimary ) { |
455 | if ( currentPalette == 2 ) return; | 455 | if ( currentPalette == 2 ) return; |
456 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 456 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
457 | //mLabel->setPalette( mPrimaryPalette ); | 457 | //mLabel->setPalette( mPrimaryPalette ); |
458 | setPalette( mPrimaryPalette ); | 458 | setPalette( mPrimaryPalette ); |
459 | currentPalette = 2; | 459 | currentPalette = 2; |
460 | 460 | ||
461 | } else { | 461 | } else { |
462 | if ( currentPalette == 3 ) return; | 462 | if ( currentPalette == 3 ) return; |
463 | setPalette( mNonPrimaryPalette ); | 463 | setPalette( mNonPrimaryPalette ); |
464 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 464 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
465 | //mLabel->setPalette( mNonPrimaryPalette );; | 465 | //mLabel->setPalette( mNonPrimaryPalette );; |
466 | currentPalette = 3; | 466 | currentPalette = 3; |
467 | } | 467 | } |
468 | } | 468 | } |
469 | //QPalette pal = palette(); | 469 | //QPalette pal = palette(); |
470 | 470 | ||
471 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 471 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
472 | } | 472 | } |
473 | QPalette MonthViewCell::getPalette () | 473 | QPalette MonthViewCell::getPalette () |
474 | { | 474 | { |
475 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 475 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
476 | return mStandardPalette; | 476 | return mStandardPalette; |
477 | if ( mHoliday) { | 477 | if ( mHoliday) { |
478 | return mHolidayPalette ; | 478 | return mHolidayPalette ; |
479 | } else { | 479 | } else { |
480 | if ( mPrimary ) { | 480 | if ( mPrimary ) { |
481 | return mPrimaryPalette ; | 481 | return mPrimaryPalette ; |
482 | } | 482 | } |
483 | } | 483 | } |
484 | return mNonPrimaryPalette; | 484 | return mNonPrimaryPalette; |
485 | } | 485 | } |
486 | bool MonthViewCell::isPrimary() const | 486 | bool MonthViewCell::isPrimary() const |
487 | { | 487 | { |
488 | return mPrimary; | 488 | return mPrimary; |
489 | } | 489 | } |
490 | 490 | ||
491 | void MonthViewCell::setHoliday( bool holiday ) | 491 | void MonthViewCell::setHoliday( bool holiday ) |
492 | { | 492 | { |
493 | mHoliday = holiday; | 493 | mHoliday = holiday; |
494 | //setMyPalette(); | 494 | //setMyPalette(); |
495 | } | 495 | } |
496 | 496 | ||
497 | void MonthViewCell::setHoliday( const QString &holiday ) | 497 | void MonthViewCell::setHoliday( const QString &holiday ) |
498 | { | 498 | { |
499 | mHolidayString = holiday; | 499 | mHolidayString = holiday; |
500 | 500 | ||
501 | if ( !holiday.isEmpty() ) { | 501 | if ( !holiday.isEmpty() ) { |
502 | setHoliday( true ); | 502 | setHoliday( true ); |
503 | } | 503 | } |
504 | } | 504 | } |
505 | 505 | ||
506 | void MonthViewCell::startUpdateCell() | 506 | void MonthViewCell::startUpdateCell() |
507 | { | 507 | { |
508 | 508 | ||
509 | setFocusPolicy(NoFocus); | 509 | setFocusPolicy(NoFocus); |
510 | if ( !mMonthView->isUpdatePossible() ) | 510 | if ( !mMonthView->isUpdatePossible() ) |
511 | return; | 511 | return; |
512 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 512 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
513 | while ( mitem ) { | 513 | while ( mitem ) { |
514 | mitem->setBlockRepaint( true ); | 514 | mitem->setBlockRepaint( true ); |
515 | mitem = (MonthViewItem *)mitem->next(); | 515 | mitem = (MonthViewItem *)mitem->next(); |
516 | } | 516 | } |
517 | if ( mAvailItemList.count() > 20 ) { | ||
518 | mAvailItemList.setAutoDelete( true ); | ||
519 | mAvailItemList.clear(); | ||
520 | mAvailItemList.setAutoDelete( false ); | ||
521 | } | ||
517 | /* | 522 | /* |
518 | if ( !isVisible() ){ | 523 | if ( !isVisible() ){ |
519 | return; | 524 | return; |
520 | } | 525 | } |
521 | */ | 526 | */ |
522 | // qDebug("MonthViewCell::updateCell() "); | 527 | // qDebug("MonthViewCell::updateCell() "); |
523 | setPrimary( mDate.month()%2 ); | 528 | setPrimary( mDate.month()%2 ); |
524 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 529 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
525 | if ( mDate == QDate::currentDate() ) { | 530 | if ( mDate == QDate::currentDate() ) { |
526 | setLineWidth( 3 ); | 531 | setLineWidth( 3 ); |
527 | } else { | 532 | } else { |
528 | setLineWidth( 1 ); | 533 | setLineWidth( 1 ); |
529 | } | 534 | } |
530 | mCurrentAvailItem = (MonthViewItem*) firstItem (); | 535 | mCurrentAvailItem = (MonthViewItem*) firstItem (); |
531 | //clear(); | 536 | //clear(); |
532 | 537 | ||
533 | #ifdef DESKTOP_VERSION | 538 | #ifdef DESKTOP_VERSION |
534 | QToolTip::remove(this); | 539 | QToolTip::remove(this); |
535 | #endif | 540 | #endif |
536 | mToolTip.clear(); | 541 | mToolTip.clear(); |
537 | //qApp->processEvents(); | 542 | //qApp->processEvents(); |
538 | #if 0 | 543 | #if 0 |
539 | if ( !mHolidayString.isEmpty() ) { | 544 | if ( !mHolidayString.isEmpty() ) { |
540 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 545 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
541 | item->setPalette( mHolidayPalette ); | 546 | item->setPalette( mHolidayPalette ); |
542 | insertItem( item ); | 547 | insertItem( item ); |
543 | mToolTip.append ( mHolidayString ); | 548 | mToolTip.append ( mHolidayString ); |
544 | } | 549 | } |
545 | #endif | 550 | #endif |
546 | } | 551 | } |
547 | 552 | ||
548 | void MonthViewCell::insertEvent(Event *event) | 553 | void MonthViewCell::insertEvent(Event *event) |
549 | { | 554 | { |
550 | QString mToolTipText; | 555 | QString mToolTipText; |
551 | bool insertNewItem = false; | 556 | bool insertNewItem = false; |
552 | setFocusPolicy(WheelFocus); | 557 | setFocusPolicy(WheelFocus); |
553 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 558 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
554 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 559 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
555 | return; | 560 | return; |
556 | else | 561 | else |
557 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 562 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
558 | return; | 563 | return; |
559 | } | 564 | } |
560 | 565 | ||
561 | if ( event->isHoliday()) { | 566 | if ( event->isHoliday()) { |
562 | setHoliday( true ); | 567 | setHoliday( true ); |
563 | if ( mDate.dayOfWeek() == 7 ) | 568 | if ( mDate.dayOfWeek() == 7 ) |
564 | setLineWidth( 3 ); | 569 | setLineWidth( 3 ); |
565 | } | 570 | } |
566 | QString text; | 571 | QString text; |
567 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 572 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
568 | if (event->isMultiDay()) { | 573 | if (event->isMultiDay()) { |
569 | QString prefix = "<->";multiday = 2; | 574 | QString prefix = "<->";multiday = 2; |
570 | QString time; | 575 | QString time; |
571 | if ( event->doesRecur() ) { | 576 | if ( event->doesRecur() ) { |
572 | if ( event->recursOn( mDate) ) { | 577 | if ( event->recursOn( mDate) ) { |
573 | prefix ="->" ;multiday = 1; | 578 | prefix ="->" ;multiday = 1; |
574 | } | 579 | } |
575 | else { | 580 | else { |
576 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 581 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
577 | if ( event->recursOn( mDate.addDays( -days)) ) { | 582 | if ( event->recursOn( mDate.addDays( -days)) ) { |
578 | prefix ="<-" ;multiday = 3; | 583 | prefix ="<-" ;multiday = 3; |
579 | } | 584 | } |
580 | } | 585 | } |
581 | 586 | ||
582 | } else { | 587 | } else { |
583 | if (mDate == event->dtStart().date()) { | 588 | if (mDate == event->dtStart().date()) { |
584 | prefix ="->" ;multiday = 1; | 589 | prefix ="->" ;multiday = 1; |
585 | } else if (mDate == event->dtEnd().date()) { | 590 | } else if (mDate == event->dtEnd().date()) { |
586 | prefix ="<-" ;multiday = 3; | 591 | prefix ="<-" ;multiday = 3; |
587 | } | 592 | } |
588 | } | 593 | } |
589 | if ( !event->doesFloat() ) { | 594 | if ( !event->doesFloat() ) { |
590 | if ( mDate == event->dtStart().date () ) | 595 | if ( mDate == event->dtStart().date () ) |
591 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 596 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
592 | else if ( mDate == event->dtEnd().date () ) | 597 | else if ( mDate == event->dtEnd().date () ) |
593 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 598 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
594 | 599 | ||
595 | } | 600 | } |
596 | text = time + event->summary(); | 601 | text = time + event->summary(); |
597 | mToolTipText += prefix + text; | 602 | mToolTipText += prefix + text; |
598 | } else { | 603 | } else { |
599 | if (event->doesFloat()) { | 604 | if (event->doesFloat()) { |
600 | text = event->summary(); | 605 | text = event->summary(); |
601 | mToolTipText += text; | 606 | mToolTipText += text; |
602 | } | 607 | } |
603 | else { | 608 | else { |
604 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 609 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
605 | text += " " + event->summary(); | 610 | text += " " + event->summary(); |
606 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 611 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
607 | } | 612 | } |
608 | } | 613 | } |
609 | MonthViewItem *item ; | 614 | MonthViewItem *item ; |
610 | if ( mCurrentAvailItem ) { | 615 | if ( mCurrentAvailItem ) { |
611 | item = mCurrentAvailItem; | 616 | item = mCurrentAvailItem; |
612 | mCurrentAvailItem = (MonthViewItem*) item->next(); | 617 | mCurrentAvailItem = (MonthViewItem*) item->next(); |
@@ -724,200 +729,200 @@ void MonthViewCell::insertTodo(Todo *todo) | |||
724 | item->setMoreInfo( todo->description().length() > 0 ); | 729 | item->setMoreInfo( todo->description().length() > 0 ); |
725 | if ( insertNewItem) | 730 | if ( insertNewItem) |
726 | insertItem( item ); | 731 | insertItem( item ); |
727 | mToolTip.append( text ); | 732 | mToolTip.append( text ); |
728 | } | 733 | } |
729 | void MonthViewCell::repaintfinishUpdateCell() | 734 | void MonthViewCell::repaintfinishUpdateCell() |
730 | { | 735 | { |
731 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 736 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
732 | while ( mitem ) { | 737 | while ( mitem ) { |
733 | mitem->setBlockRepaint( false ); | 738 | mitem->setBlockRepaint( false ); |
734 | updateItem ( mitem ); | 739 | updateItem ( mitem ); |
735 | mitem = (MonthViewItem *)mitem->next(); | 740 | mitem = (MonthViewItem *)mitem->next(); |
736 | } | 741 | } |
737 | } | 742 | } |
738 | void MonthViewCell::finishUpdateCell() | 743 | void MonthViewCell::finishUpdateCell() |
739 | { | 744 | { |
740 | while ( mCurrentAvailItem ) { | 745 | while ( mCurrentAvailItem ) { |
741 | MonthViewItem *item = mCurrentAvailItem; | 746 | MonthViewItem *item = mCurrentAvailItem; |
742 | mCurrentAvailItem = (MonthViewItem *)item->next(); | 747 | mCurrentAvailItem = (MonthViewItem *)item->next(); |
743 | mAvailItemList.append( item ); | 748 | mAvailItemList.append( item ); |
744 | takeItem ( item ); | 749 | takeItem ( item ); |
745 | } | 750 | } |
746 | 751 | ||
747 | 752 | ||
748 | #ifdef DESKTOP_VERSION | 753 | #ifdef DESKTOP_VERSION |
749 | if (mToolTip.count() > 0 ) { | 754 | if (mToolTip.count() > 0 ) { |
750 | mToolTip.sort(); | 755 | mToolTip.sort(); |
751 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 756 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
752 | } | 757 | } |
753 | #endif | 758 | #endif |
754 | sort(); | 759 | sort(); |
755 | //setMyPalette(); | 760 | //setMyPalette(); |
756 | setMyPalette(); | 761 | setMyPalette(); |
757 | 762 | ||
758 | resizeEvent( 0 ); | 763 | resizeEvent( 0 ); |
759 | 764 | ||
760 | } | 765 | } |
761 | void MonthViewCell::updateCell() | 766 | void MonthViewCell::updateCell() |
762 | { | 767 | { |
763 | //qDebug("MonthViewCell::updateCell() "); | 768 | //qDebug("MonthViewCell::updateCell() "); |
764 | if ( !mMonthView->isUpdatePossible() ) | 769 | if ( !mMonthView->isUpdatePossible() ) |
765 | return; | 770 | return; |
766 | startUpdateCell(); | 771 | startUpdateCell(); |
767 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 772 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
768 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 773 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
769 | Event *event; | 774 | Event *event; |
770 | for( event = events.first(); event; event = events.next() ) { // for event | 775 | for( event = events.first(); event; event = events.next() ) { // for event |
771 | insertEvent(event); | 776 | insertEvent(event); |
772 | } | 777 | } |
773 | // insert due todos | 778 | // insert due todos |
774 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 779 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
775 | Todo *todo; | 780 | Todo *todo; |
776 | for(todo = todos.first(); todo; todo = todos.next()) { | 781 | for(todo = todos.first(); todo; todo = todos.next()) { |
777 | insertTodo( todo ); | 782 | insertTodo( todo ); |
778 | } | 783 | } |
779 | finishUpdateCell(); | 784 | finishUpdateCell(); |
780 | // if ( isVisible()) | 785 | // if ( isVisible()) |
781 | //qApp->processEvents(); | 786 | //qApp->processEvents(); |
782 | } | 787 | } |
783 | 788 | ||
784 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 789 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
785 | { | 790 | { |
786 | 791 | ||
787 | if ( bigFont ) { | 792 | if ( bigFont ) { |
788 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 793 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
789 | int ps = fo.pointSize() + 2; | 794 | int ps = fo.pointSize() + 2; |
790 | if ( ps < 18 ) | 795 | if ( ps < 18 ) |
791 | ps += 2; | 796 | ps += 2; |
792 | fo.setPointSize( ps ); | 797 | fo.setPointSize( ps ); |
793 | setFont( fo ); | 798 | setFont( fo ); |
794 | } else | 799 | } else |
795 | setFont( KOPrefs::instance()->mMonthViewFont ); | 800 | setFont( KOPrefs::instance()->mMonthViewFont ); |
796 | 801 | ||
797 | QFontMetrics fm( font() ); | 802 | QFontMetrics fm( font() ); |
798 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 803 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
799 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 804 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
800 | mHolidayPalette = mStandardPalette; | 805 | mHolidayPalette = mStandardPalette; |
801 | mPrimaryPalette = mStandardPalette; | 806 | mPrimaryPalette = mStandardPalette; |
802 | mNonPrimaryPalette = mStandardPalette; | 807 | mNonPrimaryPalette = mStandardPalette; |
803 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 808 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
804 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 809 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
805 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 810 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
806 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 811 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
807 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 812 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
808 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 813 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
809 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 814 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
810 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 815 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
811 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 816 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
812 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 817 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
813 | } | 818 | } |
814 | //updateCell(); | 819 | //updateCell(); |
815 | } | 820 | } |
816 | 821 | ||
817 | void MonthViewCell::enableScrollBars( bool enabled ) | 822 | void MonthViewCell::enableScrollBars( bool enabled ) |
818 | { | 823 | { |
819 | if ( enabled ) { | 824 | if ( enabled ) { |
820 | |||
821 | QListBoxItem *fi = firstItem (); | 825 | QListBoxItem *fi = firstItem (); |
822 | if (fi ) { | 826 | if (fi ) { |
823 | int ihei = fi->height( this ); | 827 | int ihei = fi->height( this ); |
824 | int hei = numRows () * ihei; | 828 | int hei = numRows () * ihei; |
825 | if ( hei < height() - horizontalScrollBar()->height () ) | 829 | if ( hei < height() - horizontalScrollBar()->height () ) { |
826 | setVScrollBarMode(QScrollView::AlwaysOff); | 830 | setVScrollBarMode(QScrollView::AlwaysOff); |
827 | else | 831 | } |
832 | else | ||
828 | setVScrollBarMode(QScrollView::Auto); | 833 | setVScrollBarMode(QScrollView::Auto); |
829 | if ( ihei *3 > height() ) | 834 | if ( ihei *3 > height() ) |
830 | setHScrollBarMode(QScrollView::AlwaysOff); | 835 | setHScrollBarMode(QScrollView::AlwaysOff); |
831 | else | 836 | else |
832 | setHScrollBarMode(QScrollView::Auto); | 837 | setHScrollBarMode(QScrollView::Auto); |
833 | } else { | 838 | } else { |
834 | setVScrollBarMode(QScrollView::Auto); | 839 | setVScrollBarMode(QScrollView::Auto); |
835 | setHScrollBarMode(QScrollView::Auto); | 840 | setHScrollBarMode(QScrollView::Auto); |
836 | } | 841 | } |
837 | } else { | 842 | } else { |
838 | setVScrollBarMode(QScrollView::AlwaysOff); | 843 | setVScrollBarMode(QScrollView::AlwaysOff); |
839 | setHScrollBarMode(QScrollView::AlwaysOff); | 844 | setHScrollBarMode(QScrollView::AlwaysOff); |
840 | } | 845 | } |
841 | } | 846 | } |
842 | 847 | ||
843 | Incidence *MonthViewCell::selectedIncidence() | 848 | Incidence *MonthViewCell::selectedIncidence() |
844 | { | 849 | { |
845 | int index = currentItem(); | 850 | int index = currentItem(); |
846 | if ( index < 0 ) return 0; | 851 | if ( index < 0 ) return 0; |
847 | 852 | ||
848 | MonthViewItem *mitem = | 853 | MonthViewItem *mitem = |
849 | static_cast<MonthViewItem *>( item( index ) ); | 854 | static_cast<MonthViewItem *>( item( index ) ); |
850 | 855 | ||
851 | if ( !mitem ) return 0; | 856 | if ( !mitem ) return 0; |
852 | 857 | ||
853 | return mitem->incidence(); | 858 | return mitem->incidence(); |
854 | } | 859 | } |
855 | 860 | ||
856 | QDate MonthViewCell::selectedIncidenceDate() | 861 | QDate MonthViewCell::selectedIncidenceDate() |
857 | { | 862 | { |
858 | QDate qd; | 863 | QDate qd; |
859 | int index = currentItem(); | 864 | int index = currentItem(); |
860 | if ( index < 0 ) return qd; | 865 | if ( index < 0 ) return qd; |
861 | 866 | ||
862 | MonthViewItem *mitem = | 867 | MonthViewItem *mitem = |
863 | static_cast<MonthViewItem *>( item( index ) ); | 868 | static_cast<MonthViewItem *>( item( index ) ); |
864 | 869 | ||
865 | if ( !mitem ) return qd; | 870 | if ( !mitem ) return qd; |
866 | 871 | ||
867 | return mitem->incidenceDate(); | 872 | return mitem->incidenceDate(); |
868 | } | 873 | } |
869 | 874 | ||
870 | void MonthViewCell::deselect() | 875 | void MonthViewCell::deselect() |
871 | { | 876 | { |
872 | clearSelection(); | 877 | clearSelection(); |
873 | enableScrollBars( false ); | 878 | enableScrollBars( false ); |
874 | // updateCell(); | 879 | // updateCell(); |
875 | } | 880 | } |
876 | void MonthViewCell::select() | 881 | void MonthViewCell::select() |
877 | { | 882 | { |
878 | ;// updateCell(); | 883 | ;// updateCell(); |
879 | } | 884 | } |
880 | 885 | ||
881 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 886 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
882 | { | 887 | { |
883 | if ( !mMonthView->isUpdatePossible() ) | 888 | if ( !mMonthView->isUpdatePossible() ) |
884 | return; | 889 | return; |
885 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 890 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
886 | deselect(); | 891 | deselect(); |
887 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 892 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
888 | 893 | ||
889 | QString text; | 894 | QString text; |
890 | mLabel->setText( text ); | 895 | mLabel->setText( text ); |
891 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 896 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
892 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 897 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
893 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 898 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
894 | mLabel->resize( mLabelBigSize ); | 899 | mLabel->resize( mLabelBigSize ); |
895 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 900 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
896 | } else { | 901 | } else { |
897 | mLabel->resize( mLabelSize ); | 902 | mLabel->resize( mLabelSize ); |
898 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 903 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
899 | } | 904 | } |
900 | mLabel->setText( text ); | 905 | mLabel->setText( text ); |
901 | 906 | ||
902 | int size = height() - mLabel->height() - lineWidth()-1; | 907 | int size = height() - mLabel->height() - lineWidth()-1; |
903 | //qDebug("LW %d ", lineWidth()); | 908 | //qDebug("LW %d ", lineWidth()); |
904 | if ( size > 0 ) | 909 | if ( size > 0 ) |
905 | verticalScrollBar()->setMaximumHeight( size ); | 910 | verticalScrollBar()->setMaximumHeight( size ); |
906 | size = width() - mLabel->width() -lineWidth()-1; | 911 | size = width() - mLabel->width() -lineWidth()-1; |
907 | if ( size > 0 ) | 912 | if ( size > 0 ) |
908 | horizontalScrollBar()->setMaximumWidth( size ); | 913 | horizontalScrollBar()->setMaximumWidth( size ); |
909 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 914 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
910 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 915 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
911 | // mItemList->resize ( width(), height () ); | 916 | // mItemList->resize ( width(), height () ); |
912 | if ( e ) | 917 | if ( e ) |
913 | KNoScrollListBox::resizeEvent ( e ); | 918 | KNoScrollListBox::resizeEvent ( e ); |
914 | } | 919 | } |
915 | 920 | ||
916 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 921 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
917 | { | 922 | { |
918 | if ( !item ) return; | 923 | if ( !item ) return; |
919 | 924 | ||
920 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 925 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
921 | Incidence *incidence = eventItem->incidence(); | 926 | Incidence *incidence = eventItem->incidence(); |
922 | if ( incidence ) mMonthView->defaultAction( incidence ); | 927 | if ( incidence ) mMonthView->defaultAction( incidence ); |
923 | } | 928 | } |