-rw-r--r-- | korganizer/komonthview.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 610aae6..85e9166 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -484,519 +484,527 @@ int MonthViewItem::width(const QListBox *lb) const | |||
484 | if( mRecur ) { | 484 | if( mRecur ) { |
485 | x += size+1; | 485 | x += size+1; |
486 | } | 486 | } |
487 | if( mAlarm ) { | 487 | if( mAlarm ) { |
488 | x += size+1; | 488 | x += size+1; |
489 | } | 489 | } |
490 | if( mReply ) { | 490 | if( mReply ) { |
491 | x += size+1; | 491 | x += size+1; |
492 | } | 492 | } |
493 | } | 493 | } |
494 | if( mMultiday ) { | 494 | if( mMultiday ) { |
495 | x += size+1+2+size/2; | 495 | x += size+1+2+size/2; |
496 | } | 496 | } |
497 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 497 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
498 | } | 498 | } |
499 | if ( ! lb ) | 499 | if ( ! lb ) |
500 | return 10; | 500 | return 10; |
501 | return lb->width(); | 501 | return lb->width(); |
502 | } | 502 | } |
503 | 503 | ||
504 | 504 | ||
505 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 505 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
506 | : KNoScrollListBox( par ), | 506 | : KNoScrollListBox( par ), |
507 | mMonthView( parent ) | 507 | mMonthView( parent ) |
508 | { | 508 | { |
509 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 509 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
510 | currentPalette = 0; | 510 | currentPalette = 0; |
511 | // mLabel = new QLabel( this );QPushButton | 511 | // mLabel = new QLabel( this );QPushButton |
512 | mLabel = new QPushButton( this ); | 512 | mLabel = new QPushButton( this ); |
513 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 513 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
514 | //mLabel->setLineWidth( 1 ); | 514 | //mLabel->setLineWidth( 1 ); |
515 | //mLabel->setAlignment( AlignCenter ); | 515 | //mLabel->setAlignment( AlignCenter ); |
516 | mLabel->setFlat( true ); | 516 | mLabel->setFlat( true ); |
517 | mLabel->setFocusPolicy(NoFocus); | 517 | mLabel->setFocusPolicy(NoFocus); |
518 | //mItemList = new KNoScrollListBox( this ); | 518 | //mItemList = new KNoScrollListBox( this ); |
519 | setMinimumSize( 10, 10 ); | 519 | setMinimumSize( 10, 10 ); |
520 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 520 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
521 | setLineWidth( 1 ); | 521 | setLineWidth( 1 ); |
522 | //topLayout->addWidget( mItemList ); | 522 | //topLayout->addWidget( mItemList ); |
523 | mLabel->raise(); | 523 | mLabel->raise(); |
524 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 524 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
525 | mStandardPalette = palette(); | 525 | mStandardPalette = palette(); |
526 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 526 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
527 | 527 | ||
528 | enableScrollBars( false ); | 528 | enableScrollBars( false ); |
529 | updateConfig(); | 529 | updateConfig(); |
530 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 530 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
531 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 531 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
532 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 532 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
533 | SLOT( defaultAction( QListBoxItem * ) ) ); | 533 | SLOT( defaultAction( QListBoxItem * ) ) ); |
534 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 534 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
535 | const QPoint &) ), | 535 | const QPoint &) ), |
536 | SLOT( contextMenu( QListBoxItem * ) ) ); | 536 | SLOT( contextMenu( QListBoxItem * ) ) ); |
537 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 537 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
538 | SLOT( selection( QListBoxItem * ) ) ); | 538 | SLOT( selection( QListBoxItem * ) ) ); |
539 | 539 | ||
540 | /* | 540 | /* |
541 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 541 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
542 | SLOT( selection( QListBoxItem * ) ) ); | 542 | SLOT( selection( QListBoxItem * ) ) ); |
543 | */ | 543 | */ |
544 | } | 544 | } |
545 | #ifdef DESKTOP_VERSION | 545 | #ifdef DESKTOP_VERSION |
546 | QToolTipGroup *MonthViewCell::toolTipGroup() | 546 | QToolTipGroup *MonthViewCell::toolTipGroup() |
547 | { | 547 | { |
548 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 548 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
549 | return mToolTipGroup; | 549 | return mToolTipGroup; |
550 | } | 550 | } |
551 | #endif | 551 | #endif |
552 | 552 | ||
553 | void MonthViewCell::setDate( const QDate &date ) | 553 | void MonthViewCell::setDate( const QDate &date ) |
554 | { | 554 | { |
555 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 555 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
556 | mDate = date; | 556 | mDate = date; |
557 | 557 | ||
558 | 558 | ||
559 | 559 | ||
560 | //resizeEvent( 0 ); | 560 | //resizeEvent( 0 ); |
561 | } | 561 | } |
562 | 562 | ||
563 | QDate MonthViewCell::date() const | 563 | QDate MonthViewCell::date() const |
564 | { | 564 | { |
565 | return mDate; | 565 | return mDate; |
566 | } | 566 | } |
567 | 567 | ||
568 | void MonthViewCell::setPrimary( bool primary ) | 568 | void MonthViewCell::setPrimary( bool primary ) |
569 | { | 569 | { |
570 | mPrimary = primary; | 570 | mPrimary = primary; |
571 | //setMyPalette(); | 571 | //setMyPalette(); |
572 | } | 572 | } |
573 | void MonthViewCell::setMyPalette() | 573 | void MonthViewCell::setMyPalette() |
574 | { | 574 | { |
575 | 575 | ||
576 | if ( mHoliday) { | 576 | if ( mHoliday) { |
577 | if ( currentPalette == 1 ) return; | 577 | if ( currentPalette == 1 ) return; |
578 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 578 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
579 | setPalette( mHolidayPalette ); | 579 | setPalette( mHolidayPalette ); |
580 | //mLabel->setPalette( mHolidayPalette ); | 580 | //mLabel->setPalette( mHolidayPalette ); |
581 | currentPalette = 1; | 581 | currentPalette = 1; |
582 | 582 | ||
583 | } else { | 583 | } else { |
584 | if ( mPrimary ) { | 584 | if ( mPrimary ) { |
585 | if ( currentPalette == 2 ) return; | 585 | if ( currentPalette == 2 ) return; |
586 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 586 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
587 | //mLabel->setPalette( mPrimaryPalette ); | 587 | //mLabel->setPalette( mPrimaryPalette ); |
588 | setPalette( mPrimaryPalette ); | 588 | setPalette( mPrimaryPalette ); |
589 | currentPalette = 2; | 589 | currentPalette = 2; |
590 | 590 | ||
591 | } else { | 591 | } else { |
592 | if ( currentPalette == 3 ) return; | 592 | if ( currentPalette == 3 ) return; |
593 | setPalette( mNonPrimaryPalette ); | 593 | setPalette( mNonPrimaryPalette ); |
594 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 594 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
595 | //mLabel->setPalette( mNonPrimaryPalette );; | 595 | //mLabel->setPalette( mNonPrimaryPalette );; |
596 | currentPalette = 3; | 596 | currentPalette = 3; |
597 | } | 597 | } |
598 | } | 598 | } |
599 | //QPalette pal = palette(); | 599 | //QPalette pal = palette(); |
600 | 600 | ||
601 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 601 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
602 | } | 602 | } |
603 | QPalette MonthViewCell::getPalette () | 603 | QPalette MonthViewCell::getPalette () |
604 | { | 604 | { |
605 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 605 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
606 | return mStandardPalette; | 606 | return mStandardPalette; |
607 | if ( mHoliday) { | 607 | if ( mHoliday) { |
608 | return mHolidayPalette ; | 608 | return mHolidayPalette ; |
609 | } else { | 609 | } else { |
610 | if ( mPrimary ) { | 610 | if ( mPrimary ) { |
611 | return mPrimaryPalette ; | 611 | return mPrimaryPalette ; |
612 | } | 612 | } |
613 | } | 613 | } |
614 | return mNonPrimaryPalette; | 614 | return mNonPrimaryPalette; |
615 | } | 615 | } |
616 | bool MonthViewCell::isPrimary() const | 616 | bool MonthViewCell::isPrimary() const |
617 | { | 617 | { |
618 | return mPrimary; | 618 | return mPrimary; |
619 | } | 619 | } |
620 | 620 | ||
621 | void MonthViewCell::setHoliday( bool holiday ) | 621 | void MonthViewCell::setHoliday( bool holiday ) |
622 | { | 622 | { |
623 | mHoliday = holiday; | 623 | mHoliday = holiday; |
624 | //setMyPalette(); | 624 | //setMyPalette(); |
625 | } | 625 | } |
626 | 626 | ||
627 | void MonthViewCell::setHoliday( const QString &holiday ) | 627 | void MonthViewCell::setHoliday( const QString &holiday ) |
628 | { | 628 | { |
629 | mHolidayString = holiday; | 629 | mHolidayString = holiday; |
630 | 630 | ||
631 | if ( !holiday.isEmpty() ) { | 631 | if ( !holiday.isEmpty() ) { |
632 | setHoliday( true ); | 632 | setHoliday( true ); |
633 | } | 633 | } |
634 | } | 634 | } |
635 | 635 | ||
636 | void MonthViewCell::startUpdateCell() | 636 | void MonthViewCell::startUpdateCell() |
637 | { | 637 | { |
638 | blockSignals( true ); | 638 | blockSignals( true ); |
639 | mdayCount = 0; | 639 | mdayCount = 0; |
640 | setFocusPolicy(NoFocus); | 640 | setFocusPolicy(NoFocus); |
641 | if ( !mMonthView->isUpdatePossible() ) | 641 | if ( !mMonthView->isUpdatePossible() ) |
642 | return; | 642 | return; |
643 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 643 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
644 | while ( mitem ) { | 644 | while ( mitem ) { |
645 | mitem->setBlockRepaint( true ); | 645 | mitem->setBlockRepaint( true ); |
646 | mitem = (MonthViewItem *)mitem->next(); | 646 | mitem = (MonthViewItem *)mitem->next(); |
647 | } | 647 | } |
648 | if ( mAvailItemList.count() > 20 ) { | 648 | if ( mAvailItemList.count() > 20 ) { |
649 | mAvailItemList.setAutoDelete( true ); | 649 | mAvailItemList.setAutoDelete( true ); |
650 | mAvailItemList.clear(); | 650 | mAvailItemList.clear(); |
651 | mAvailItemList.setAutoDelete( false ); | 651 | mAvailItemList.setAutoDelete( false ); |
652 | clear(); | 652 | clear(); |
653 | } | 653 | } |
654 | 654 | ||
655 | setPrimary( mDate.month()%2 ); | 655 | setPrimary( mDate.month()%2 ); |
656 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 656 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
657 | if ( mDate == QDate::currentDate() ) { | 657 | if ( mDate == QDate::currentDate() ) { |
658 | setLineWidth( 3 ); | 658 | setLineWidth( 3 ); |
659 | } else { | 659 | } else { |
660 | setLineWidth( 1 ); | 660 | setLineWidth( 1 ); |
661 | } | 661 | } |
662 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 662 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
663 | //clear(); | 663 | //clear(); |
664 | while ( CurrentAvailItem ) { | 664 | while ( CurrentAvailItem ) { |
665 | MonthViewItem *item = CurrentAvailItem; | 665 | MonthViewItem *item = CurrentAvailItem; |
666 | //item->setHighlightedFalse(); | 666 | //item->setHighlightedFalse(); |
667 | item->recycle( 0, ""); | 667 | item->recycle( 0, ""); |
668 | CurrentAvailItem = (MonthViewItem *)item->next(); | 668 | CurrentAvailItem = (MonthViewItem *)item->next(); |
669 | mAvailItemList.append( item ); | 669 | mAvailItemList.append( item ); |
670 | takeItem ( item ); | 670 | takeItem ( item ); |
671 | } | 671 | } |
672 | 672 | ||
673 | #ifdef DESKTOP_VERSION | 673 | #ifdef DESKTOP_VERSION |
674 | QToolTip::remove(this); | 674 | QToolTip::remove(this); |
675 | #endif | 675 | #endif |
676 | mToolTip.clear(); | 676 | mToolTip.clear(); |
677 | //qApp->processEvents(); | 677 | //qApp->processEvents(); |
678 | #if 0 | 678 | #if 0 |
679 | if ( !mHolidayString.isEmpty() ) { | 679 | if ( !mHolidayString.isEmpty() ) { |
680 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 680 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
681 | item->setPalette( mHolidayPalette ); | 681 | item->setPalette( mHolidayPalette ); |
682 | insertItem( item ); | 682 | insertItem( item ); |
683 | mToolTip.append ( mHolidayString ); | 683 | mToolTip.append ( mHolidayString ); |
684 | } | 684 | } |
685 | #endif | 685 | #endif |
686 | } | 686 | } |
687 | 687 | ||
688 | int MonthViewCell::insertEvent(Event *event) | 688 | int MonthViewCell::insertEvent(Event *event) |
689 | { | 689 | { |
690 | bool useToolTips = true; | 690 | bool useToolTips = true; |
691 | #ifndef DESKTOP_VERSION | 691 | #ifndef DESKTOP_VERSION |
692 | useToolTips = false; | 692 | useToolTips = false; |
693 | #endif | 693 | #endif |
694 | QString mToolTipText; | 694 | QString mToolTipText; |
695 | setFocusPolicy(WheelFocus); | 695 | setFocusPolicy(WheelFocus); |
696 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 696 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
697 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 697 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
698 | return mdayCount; | 698 | return mdayCount; |
699 | else | 699 | else |
700 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 700 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
701 | return mdayCount; | 701 | return mdayCount; |
702 | } | 702 | } |
703 | 703 | ||
704 | if ( event->isHoliday()) { | 704 | if ( event->isHoliday()) { |
705 | setHoliday( true ); | 705 | setHoliday( true ); |
706 | if ( mDate.dayOfWeek() == 7 ) | 706 | if ( mDate.dayOfWeek() == 7 ) |
707 | setLineWidth( 3 ); | 707 | setLineWidth( 3 ); |
708 | } | 708 | } |
709 | QString text; | 709 | QString text; |
710 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 710 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
711 | if (event->isMultiDay()) { | 711 | if (event->isMultiDay()) { |
712 | QString prefix = "<->";multiday = 2; | 712 | QString prefix = "<->";multiday = 2; |
713 | QString time; | 713 | QString time; |
714 | if ( event->doesRecur() ) { | 714 | if ( event->doesRecur() ) { |
715 | if ( event->recursOn( mDate) ) { | 715 | if ( event->recursOn( mDate) ) { |
716 | prefix ="->" ;multiday = 1; | 716 | prefix ="->" ;multiday = 1; |
717 | } | 717 | } |
718 | else { | 718 | else { |
719 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 719 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
720 | if ( event->recursOn( mDate.addDays( -days)) ) { | 720 | if ( event->recursOn( mDate.addDays( -days)) ) { |
721 | prefix ="<-" ;multiday = 3; | 721 | prefix ="<-" ;multiday = 3; |
722 | } | 722 | } |
723 | } | 723 | } |
724 | 724 | ||
725 | } else { | 725 | } else { |
726 | if (mDate == event->dtStart().date()) { | 726 | if (mDate == event->dtStart().date()) { |
727 | prefix ="->" ;multiday = 1; | 727 | prefix ="->" ;multiday = 1; |
728 | } else if (mDate == event->dtEnd().date()) { | 728 | } else if (mDate == event->dtEnd().date()) { |
729 | prefix ="<-" ;multiday = 3; | 729 | prefix ="<-" ;multiday = 3; |
730 | } | 730 | } |
731 | } | 731 | } |
732 | if ( !event->doesFloat() ) { | 732 | if ( !event->doesFloat() ) { |
733 | if ( mDate == event->dtStart().date () ) | 733 | if ( mDate == event->dtStart().date () ) |
734 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 734 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
735 | else if ( mDate == event->dtEnd().date () ) | 735 | else if ( mDate == event->dtEnd().date () ) |
736 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 736 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
737 | 737 | ||
738 | } | 738 | } |
739 | text = time + event->summary(); | 739 | text = time + event->summary(); |
740 | |||
741 | int dur = 0; | ||
742 | if ( event->doesFloat() ) { | ||
743 | dur = event->dtStart().daysTo(event->dtEnd())+1; | ||
744 | |||
745 | } | ||
740 | if ( useToolTips ) { | 746 | if ( useToolTips ) { |
741 | mToolTipText += prefix + text; | 747 | mToolTipText += prefix + text; |
742 | if ( event->doesFloat() ) { | 748 | if ( dur ) { |
743 | mToolTipText += i18n(" (Duration: %1 days)" ).arg ( event->dtStart().daysTo(event->dtEnd())+1); | 749 | mToolTipText += i18n(" (Duration: %1 days)" ).arg ( dur ); |
744 | |||
745 | } | 750 | } |
746 | } | 751 | } |
752 | if ( dur ) { | ||
753 | text += " ("+ QString::number( dur ) + i18n(" days" ) + ")"; | ||
754 | } | ||
747 | } else { | 755 | } else { |
748 | if (event->doesFloat()) { | 756 | if (event->doesFloat()) { |
749 | text = event->summary(); | 757 | text = event->summary(); |
750 | if ( useToolTips ) | 758 | if ( useToolTips ) |
751 | mToolTipText += text; | 759 | mToolTipText += text; |
752 | } | 760 | } |
753 | else { | 761 | else { |
754 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 762 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
755 | text += " " + event->summary(); | 763 | text += " " + event->summary(); |
756 | if ( useToolTips ) | 764 | if ( useToolTips ) |
757 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 765 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
758 | } | 766 | } |
759 | } | 767 | } |
760 | if ( useToolTips && ! event->location().isEmpty() ) { | 768 | if ( useToolTips && ! event->location().isEmpty() ) { |
761 | mToolTipText += " (" + event->location() +")"; | 769 | mToolTipText += " (" + event->location() +")"; |
762 | } | 770 | } |
763 | MonthViewItem *item ; | 771 | MonthViewItem *item ; |
764 | 772 | ||
765 | if ( mAvailItemList.count() ) { | 773 | if ( mAvailItemList.count() ) { |
766 | item = mAvailItemList.first(); | 774 | item = mAvailItemList.first(); |
767 | mAvailItemList.remove( item ); | 775 | mAvailItemList.remove( item ); |
768 | item->recycle( event, text ); | 776 | item->recycle( event, text ); |
769 | } else { | 777 | } else { |
770 | item = new MonthViewItem( event, text ); | 778 | item = new MonthViewItem( event, text ); |
771 | } | 779 | } |
772 | 780 | ||
773 | QPalette pal; | 781 | QPalette pal; |
774 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 782 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
775 | QStringList categories = event->categories(); | 783 | QStringList categories = event->categories(); |
776 | QString cat = categories.first(); | 784 | QString cat = categories.first(); |
777 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 785 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
778 | pal = getPalette(); | 786 | pal = getPalette(); |
779 | if (cat.isEmpty()) { | 787 | if (cat.isEmpty()) { |
780 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 788 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
781 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); | 789 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); |
782 | } else { | 790 | } else { |
783 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 791 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
784 | } | 792 | } |
785 | 793 | ||
786 | } else { | 794 | } else { |
787 | if (cat.isEmpty()) { | 795 | if (cat.isEmpty()) { |
788 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 796 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
789 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); | 797 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); |
790 | } else { | 798 | } else { |
791 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 799 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
792 | } | 800 | } |
793 | } | 801 | } |
794 | 802 | ||
795 | } else { | 803 | } else { |
796 | pal = mStandardPalette ; | 804 | pal = mStandardPalette ; |
797 | } | 805 | } |
798 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 806 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
799 | item->setPalette( pal ); | 807 | item->setPalette( pal ); |
800 | item->setRecur( event->doesRecur() ); | 808 | item->setRecur( event->doesRecur() ); |
801 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); | 809 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); |
802 | item->setMoreInfo( event->description().length() > 0 ); | 810 | item->setMoreInfo( event->description().length() > 0 ); |
803 | #ifdef DESKTOP_VERSION | 811 | #ifdef DESKTOP_VERSION |
804 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 812 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
805 | KOPrefs::instance()->email()); | 813 | KOPrefs::instance()->email()); |
806 | if ( me != 0 ) { | 814 | if ( me != 0 ) { |
807 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 815 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
808 | item->setReply(true && multiday < 2); | 816 | item->setReply(true && multiday < 2); |
809 | else | 817 | else |
810 | item->setReply(false); | 818 | item->setReply(false); |
811 | } else | 819 | } else |
812 | item->setReply(false); | 820 | item->setReply(false); |
813 | #endif | 821 | #endif |
814 | 822 | ||
815 | item->setMultiDay( multiday ); | 823 | item->setMultiDay( multiday ); |
816 | if ( multiday ) { | 824 | if ( multiday ) { |
817 | insertItem( item ,mdayCount); | 825 | insertItem( item ,mdayCount); |
818 | ++mdayCount; | 826 | ++mdayCount; |
819 | } else { | 827 | } else { |
820 | uint i = mdayCount; | 828 | uint i = mdayCount; |
821 | uint pos = mdayCount; | 829 | uint pos = mdayCount; |
822 | uint itcount = count(); | 830 | uint itcount = count(); |
823 | if ( itcount > 1000 ) { | 831 | if ( itcount > 1000 ) { |
824 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); | 832 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); |
825 | itcount = 0; | 833 | itcount = 0; |
826 | } | 834 | } |
827 | for ( i = pos; i < itcount;++i ) { | 835 | for ( i = pos; i < itcount;++i ) { |
828 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); | 836 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); |
829 | QListBoxItem* it = this->item ( i ); | 837 | QListBoxItem* it = this->item ( i ); |
830 | if ( it && text < it->text() ) { | 838 | if ( it && text < it->text() ) { |
831 | pos = i; | 839 | pos = i; |
832 | break; | 840 | break; |
833 | } | 841 | } |
834 | ++pos; | 842 | ++pos; |
835 | } | 843 | } |
836 | insertItem( item ,pos); | 844 | insertItem( item ,pos); |
837 | } | 845 | } |
838 | if ( useToolTips ) { | 846 | if ( useToolTips ) { |
839 | mToolTip.append( mToolTipText ); | 847 | mToolTip.append( mToolTipText ); |
840 | } | 848 | } |
841 | return mdayCount; | 849 | return mdayCount; |
842 | } | 850 | } |
843 | void MonthViewCell::insertTodo(Todo *todo) | 851 | void MonthViewCell::insertTodo(Todo *todo) |
844 | { | 852 | { |
845 | setFocusPolicy(WheelFocus); | 853 | setFocusPolicy(WheelFocus); |
846 | QString text; | 854 | QString text; |
847 | if (todo->hasDueDate()) { | 855 | if (todo->hasDueDate()) { |
848 | if (!todo->doesFloat()) { | 856 | if (!todo->doesFloat()) { |
849 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 857 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
850 | text += " "; | 858 | text += " "; |
851 | } | 859 | } |
852 | } | 860 | } |
853 | text += todo->summary(); | 861 | text += todo->summary(); |
854 | MonthViewItem *item ; | 862 | MonthViewItem *item ; |
855 | if ( mAvailItemList.count() ) { | 863 | if ( mAvailItemList.count() ) { |
856 | item = mAvailItemList.first(); | 864 | item = mAvailItemList.first(); |
857 | mAvailItemList.remove( item ); | 865 | mAvailItemList.remove( item ); |
858 | item->recycle( todo, text ); | 866 | item->recycle( todo, text ); |
859 | } else { | 867 | } else { |
860 | item = new MonthViewItem( todo, text ); | 868 | item = new MonthViewItem( todo, text ); |
861 | } | 869 | } |
862 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 870 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
863 | //item->setPalette( mStandardPalette ); | 871 | //item->setPalette( mStandardPalette ); |
864 | QPalette pal; | 872 | QPalette pal; |
865 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 873 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
866 | QStringList categories = todo->categories(); | 874 | QStringList categories = todo->categories(); |
867 | QString cat = categories.first(); | 875 | QString cat = categories.first(); |
868 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 876 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
869 | pal = getPalette(); | 877 | pal = getPalette(); |
870 | if (cat.isEmpty()) { | 878 | if (cat.isEmpty()) { |
871 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 879 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
872 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); | 880 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); |
873 | } else { | 881 | } else { |
874 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 882 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
875 | } | 883 | } |
876 | 884 | ||
877 | } else { | 885 | } else { |
878 | if (cat.isEmpty()) { | 886 | if (cat.isEmpty()) { |
879 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 887 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
880 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); | 888 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); |
881 | } else { | 889 | } else { |
882 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 890 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
883 | } | 891 | } |
884 | } | 892 | } |
885 | 893 | ||
886 | } else { | 894 | } else { |
887 | pal = mStandardPalette ; | 895 | pal = mStandardPalette ; |
888 | } | 896 | } |
889 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 897 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
890 | item->setPalette( pal ); | 898 | item->setPalette( pal ); |
891 | item->setRecur( todo->doesRecur() ); | 899 | item->setRecur( todo->doesRecur() ); |
892 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); | 900 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); |
893 | item->setMoreInfo( todo->description().length() > 0 ); | 901 | item->setMoreInfo( todo->description().length() > 0 ); |
894 | insertItem( item , count()); | 902 | insertItem( item , count()); |
895 | #ifdef DESKTOP_VERSION | 903 | #ifdef DESKTOP_VERSION |
896 | mToolTip.append( text ); | 904 | mToolTip.append( text ); |
897 | #endif | 905 | #endif |
898 | } | 906 | } |
899 | void MonthViewCell::repaintfinishUpdateCell() | 907 | void MonthViewCell::repaintfinishUpdateCell() |
900 | { | 908 | { |
901 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 909 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
902 | while ( mitem ) { | 910 | while ( mitem ) { |
903 | mitem->setBlockRepaint( false ); | 911 | mitem->setBlockRepaint( false ); |
904 | updateItem ( mitem ); | 912 | updateItem ( mitem ); |
905 | mitem = (MonthViewItem *)mitem->next(); | 913 | mitem = (MonthViewItem *)mitem->next(); |
906 | } | 914 | } |
907 | blockSignals( false ); | 915 | blockSignals( false ); |
908 | } | 916 | } |
909 | void MonthViewCell::finishUpdateCell() | 917 | void MonthViewCell::finishUpdateCell() |
910 | { | 918 | { |
911 | 919 | ||
912 | 920 | ||
913 | 921 | ||
914 | #ifdef DESKTOP_VERSION | 922 | #ifdef DESKTOP_VERSION |
915 | if (mToolTip.count() > 0 ) { | 923 | if (mToolTip.count() > 0 ) { |
916 | mToolTip.sort(); | 924 | mToolTip.sort(); |
917 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 925 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
918 | } | 926 | } |
919 | #endif | 927 | #endif |
920 | //sort(); | 928 | //sort(); |
921 | //setMyPalette(); | 929 | //setMyPalette(); |
922 | setMyPalette(); | 930 | setMyPalette(); |
923 | 931 | ||
924 | resizeEvent( 0 ); | 932 | resizeEvent( 0 ); |
925 | 933 | ||
926 | } | 934 | } |
927 | void MonthViewCell::updateCell() | 935 | void MonthViewCell::updateCell() |
928 | { | 936 | { |
929 | if ( !mMonthView->isUpdatePossible() ) | 937 | if ( !mMonthView->isUpdatePossible() ) |
930 | return; | 938 | return; |
931 | startUpdateCell(); | 939 | startUpdateCell(); |
932 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 940 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
933 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 941 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
934 | Event *event; | 942 | Event *event; |
935 | for( event = events.first(); event; event = events.next() ) { // for event | 943 | for( event = events.first(); event; event = events.next() ) { // for event |
936 | insertEvent(event); | 944 | insertEvent(event); |
937 | } | 945 | } |
938 | // insert due todos | 946 | // insert due todos |
939 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 947 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
940 | Todo *todo; | 948 | Todo *todo; |
941 | for(todo = todos.first(); todo; todo = todos.next()) { | 949 | for(todo = todos.first(); todo; todo = todos.next()) { |
942 | insertTodo( todo ); | 950 | insertTodo( todo ); |
943 | } | 951 | } |
944 | finishUpdateCell(); | 952 | finishUpdateCell(); |
945 | // if ( isVisible()) | 953 | // if ( isVisible()) |
946 | //qApp->processEvents(); | 954 | //qApp->processEvents(); |
947 | } | 955 | } |
948 | 956 | ||
949 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 957 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
950 | { | 958 | { |
951 | 959 | ||
952 | if ( bigFont ) { | 960 | if ( bigFont ) { |
953 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 961 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
954 | int ps = fo.pointSize() + 2; | 962 | int ps = fo.pointSize() + 2; |
955 | if ( ps < 18 ) | 963 | if ( ps < 18 ) |
956 | ps += 2; | 964 | ps += 2; |
957 | fo.setPointSize( ps ); | 965 | fo.setPointSize( ps ); |
958 | setFont( fo ); | 966 | setFont( fo ); |
959 | } else | 967 | } else |
960 | setFont( KOPrefs::instance()->mMonthViewFont ); | 968 | setFont( KOPrefs::instance()->mMonthViewFont ); |
961 | 969 | ||
962 | QFontMetrics fm( font() ); | 970 | QFontMetrics fm( font() ); |
963 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 971 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
964 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 972 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
965 | mHolidayPalette = mStandardPalette; | 973 | mHolidayPalette = mStandardPalette; |
966 | mPrimaryPalette = mStandardPalette; | 974 | mPrimaryPalette = mStandardPalette; |
967 | mNonPrimaryPalette = mStandardPalette; | 975 | mNonPrimaryPalette = mStandardPalette; |
968 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 976 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
969 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 977 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
970 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 978 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
971 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 979 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
972 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 980 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
973 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 981 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
974 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 982 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
975 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 983 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
976 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 984 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
977 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 985 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
978 | } | 986 | } |
979 | //updateCell(); | 987 | //updateCell(); |
980 | } | 988 | } |
981 | 989 | ||
982 | void MonthViewCell::enableScrollBars( bool enabled ) | 990 | void MonthViewCell::enableScrollBars( bool enabled ) |
983 | { | 991 | { |
984 | 992 | ||
985 | return; | 993 | return; |
986 | if ( enabled ) { | 994 | if ( enabled ) { |
987 | QListBoxItem *fi = firstItem (); | 995 | QListBoxItem *fi = firstItem (); |
988 | if (fi ) { | 996 | if (fi ) { |
989 | int ihei = fi->height( this ); | 997 | int ihei = fi->height( this ); |
990 | int hei = numRows () * ihei; | 998 | int hei = numRows () * ihei; |
991 | if ( hei < height() - horizontalScrollBar()->height () ) { | 999 | if ( hei < height() - horizontalScrollBar()->height () ) { |
992 | setVScrollBarMode(QScrollView::AlwaysOff); | 1000 | setVScrollBarMode(QScrollView::AlwaysOff); |
993 | } | 1001 | } |
994 | else | 1002 | else |
995 | setVScrollBarMode(QScrollView::Auto); | 1003 | setVScrollBarMode(QScrollView::Auto); |
996 | if ( ihei *3 > height() ) { | 1004 | if ( ihei *3 > height() ) { |
997 | setHScrollBarMode(QScrollView::AlwaysOff); | 1005 | setHScrollBarMode(QScrollView::AlwaysOff); |
998 | } | 1006 | } |
999 | else { | 1007 | else { |
1000 | setHScrollBarMode(QScrollView::Auto); | 1008 | setHScrollBarMode(QScrollView::Auto); |
1001 | } | 1009 | } |
1002 | } else { | 1010 | } else { |