-rw-r--r-- | korganizer/koagendaview.cpp | 1 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index d43712f..aa36553 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -631,384 +631,385 @@ void KOAgendaView::createDayLabels() | |||
631 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 631 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
632 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 632 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
633 | return; | 633 | return; |
634 | 634 | ||
635 | } | 635 | } |
636 | int newHight; | 636 | int newHight; |
637 | 637 | ||
638 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 638 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
639 | // It would remove some flickering and gain speed (since this is called by | 639 | // It would remove some flickering and gain speed (since this is called by |
640 | // each updateView() call) | 640 | // each updateView() call) |
641 | 641 | ||
642 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 642 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
643 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 643 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
644 | if ( maxWid < 0 ) | 644 | if ( maxWid < 0 ) |
645 | maxWid = 20; | 645 | maxWid = 20; |
646 | 646 | ||
647 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 647 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
648 | QFontMetrics fm ( dlf ); | 648 | QFontMetrics fm ( dlf ); |
649 | int selCount = mSelectedDates.count(); | 649 | int selCount = mSelectedDates.count(); |
650 | QString dayTest = "Mon 20"; | 650 | QString dayTest = "Mon 20"; |
651 | int wid = fm.width( dayTest ); | 651 | int wid = fm.width( dayTest ); |
652 | maxWid -= ( selCount * 3 ); | 652 | maxWid -= ( selCount * 3 ); |
653 | if ( maxWid < 0 ) | 653 | if ( maxWid < 0 ) |
654 | maxWid = 20; | 654 | maxWid = 20; |
655 | int needWid = wid * selCount; | 655 | int needWid = wid * selCount; |
656 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 656 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
657 | //if ( needWid > maxWid ) | 657 | //if ( needWid > maxWid ) |
658 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 658 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
659 | while ( needWid > maxWid ) { | 659 | while ( needWid > maxWid ) { |
660 | dayTest = dayTest.left( dayTest.length() - 1 ); | 660 | dayTest = dayTest.left( dayTest.length() - 1 ); |
661 | wid = fm.width( dayTest ); | 661 | wid = fm.width( dayTest ); |
662 | needWid = wid * selCount; | 662 | needWid = wid * selCount; |
663 | } | 663 | } |
664 | int maxLen = dayTest.length(); | 664 | int maxLen = dayTest.length(); |
665 | int fontPoint = dlf.pointSize(); | 665 | int fontPoint = dlf.pointSize(); |
666 | if ( maxLen < 2 ) { | 666 | if ( maxLen < 2 ) { |
667 | int fontPoint = dlf.pointSize(); | 667 | int fontPoint = dlf.pointSize(); |
668 | while ( fontPoint > 4 ) { | 668 | while ( fontPoint > 4 ) { |
669 | --fontPoint; | 669 | --fontPoint; |
670 | dlf.setPointSize( fontPoint ); | 670 | dlf.setPointSize( fontPoint ); |
671 | QFontMetrics f( dlf ); | 671 | QFontMetrics f( dlf ); |
672 | wid = f.width( "20" ); | 672 | wid = f.width( "20" ); |
673 | needWid = wid * selCount; | 673 | needWid = wid * selCount; |
674 | if ( needWid < maxWid ) | 674 | if ( needWid < maxWid ) |
675 | break; | 675 | break; |
676 | } | 676 | } |
677 | maxLen = 2; | 677 | maxLen = 2; |
678 | } | 678 | } |
679 | //qDebug("Max len %d ", dayTest.length() ); | 679 | //qDebug("Max len %d ", dayTest.length() ); |
680 | 680 | ||
681 | QFontMetrics tempF( dlf ); | 681 | QFontMetrics tempF( dlf ); |
682 | newHight = tempF.height(); | 682 | newHight = tempF.height(); |
683 | mDayLabels->setFont( dlf ); | 683 | mDayLabels->setFont( dlf ); |
684 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 684 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
685 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 685 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
686 | //mLayoutDayLabels->addSpacing( 2 ); | 686 | //mLayoutDayLabels->addSpacing( 2 ); |
687 | // QFont lFont = dlf; | 687 | // QFont lFont = dlf; |
688 | bool appendLabels = false; | 688 | bool appendLabels = false; |
689 | QPushButton *dayLabel; | 689 | QPushButton *dayLabel; |
690 | dayLabel = mDayLabelsList.first(); | 690 | dayLabel = mDayLabelsList.first(); |
691 | if ( !dayLabel ) { | 691 | if ( !dayLabel ) { |
692 | appendLabels = true; | 692 | appendLabels = true; |
693 | dayLabel = new QPushButton(mDayLabels); | 693 | dayLabel = new QPushButton(mDayLabels); |
694 | dayLabel->setFlat( true ); | 694 | dayLabel->setFlat( true ); |
695 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); | 695 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); |
696 | dayLabel->setFocusPolicy(NoFocus); | 696 | dayLabel->setFocusPolicy(NoFocus); |
697 | mDayLabelsList.append( dayLabel ); | 697 | mDayLabelsList.append( dayLabel ); |
698 | mLayoutDayLabels->addWidget(dayLabel); | 698 | mLayoutDayLabels->addWidget(dayLabel); |
699 | } | 699 | } |
700 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 700 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
701 | dayLabel->setFont( dlf ); | 701 | dayLabel->setFont( dlf ); |
702 | dayLabel->setCaption("0"); | 702 | dayLabel->setCaption("0"); |
703 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 703 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
704 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 704 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
705 | dayLabel->show(); | 705 | dayLabel->show(); |
706 | DateList::ConstIterator dit; | 706 | DateList::ConstIterator dit; |
707 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 707 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
708 | int counter = 0; | 708 | int counter = 0; |
709 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 709 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
710 | ++counter; | 710 | ++counter; |
711 | QDate date = *dit; | 711 | QDate date = *dit; |
712 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 712 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
713 | if ( ! appendLabels ) { | 713 | if ( ! appendLabels ) { |
714 | dayLabel = mDayLabelsList.next(); | 714 | dayLabel = mDayLabelsList.next(); |
715 | if ( !dayLabel ) | 715 | if ( !dayLabel ) |
716 | appendLabels = true; | 716 | appendLabels = true; |
717 | } | 717 | } |
718 | if ( appendLabels ) { | 718 | if ( appendLabels ) { |
719 | dayLabel = new QPushButton(mDayLabels); | 719 | dayLabel = new QPushButton(mDayLabels); |
720 | dayLabel->setFlat( true ); | 720 | dayLabel->setFlat( true ); |
721 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); | 721 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); |
722 | dayLabel->setFocusPolicy(NoFocus); | 722 | dayLabel->setFocusPolicy(NoFocus); |
723 | mDayLabelsList.append( dayLabel ); | 723 | mDayLabelsList.append( dayLabel ); |
724 | mLayoutDayLabels->addWidget(dayLabel); | 724 | mLayoutDayLabels->addWidget(dayLabel); |
725 | } | 725 | } |
726 | dayLabel->setMinimumWidth( 1 ); | 726 | dayLabel->setMinimumWidth( 1 ); |
727 | dayLabel->setMaximumWidth( 2048 ); | 727 | dayLabel->setMaximumWidth( 2048 ); |
728 | dayLabel->setFont( dlf ); | 728 | dayLabel->setFont( dlf ); |
729 | dayLabel->show(); | 729 | dayLabel->show(); |
730 | dayLabel->setCaption(QString::number( counter )); | 730 | dayLabel->setCaption(QString::number( counter )); |
731 | QString str; | 731 | QString str; |
732 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 732 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
733 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 733 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
734 | switch ( maxLen ) { | 734 | switch ( maxLen ) { |
735 | case 2: | 735 | case 2: |
736 | str = QString::number( date.day() ); | 736 | str = QString::number( date.day() ); |
737 | break; | 737 | break; |
738 | 738 | ||
739 | case 3: | 739 | case 3: |
740 | str = dayName.left( 1 ) +QString::number( date.day()); | 740 | str = dayName.left( 1 ) +QString::number( date.day()); |
741 | 741 | ||
742 | break; | 742 | break; |
743 | case 4: | 743 | case 4: |
744 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 744 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
745 | 745 | ||
746 | break; | 746 | break; |
747 | case 5: | 747 | case 5: |
748 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 748 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
749 | 749 | ||
750 | break; | 750 | break; |
751 | case 6: | 751 | case 6: |
752 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 752 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
753 | break; | 753 | break; |
754 | 754 | ||
755 | default: | 755 | default: |
756 | break; | 756 | break; |
757 | } | 757 | } |
758 | if ( oneday ) { | 758 | if ( oneday ) { |
759 | QString addString; | 759 | QString addString; |
760 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 760 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
761 | addString = i18n("Today"); | 761 | addString = i18n("Today"); |
762 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 762 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
763 | addString = i18n("Tomorrow"); | 763 | addString = i18n("Tomorrow"); |
764 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 764 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
765 | addString = i18n("Yesterday"); | 765 | addString = i18n("Yesterday"); |
766 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 766 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
767 | addString = i18n("Day before yesterday"); | 767 | addString = i18n("Day before yesterday"); |
768 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 768 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
769 | addString = i18n("Day after tomorrow"); | 769 | addString = i18n("Day after tomorrow"); |
770 | if ( !addString.isEmpty() ) { | 770 | if ( !addString.isEmpty() ) { |
771 | str = addString+", " + str; | 771 | str = addString+", " + str; |
772 | } | 772 | } |
773 | } | 773 | } |
774 | dayLabel->setText(str); | 774 | dayLabel->setText(str); |
775 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 775 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
776 | if (date == QDate::currentDate()) { | 776 | if (date == QDate::currentDate()) { |
777 | QFont bFont = dlf; | 777 | QFont bFont = dlf; |
778 | bFont.setBold( true ); | 778 | bFont.setBold( true ); |
779 | dayLabel->setFont(bFont); | 779 | dayLabel->setFont(bFont); |
780 | } | 780 | } |
781 | //dayLayout->addWidget(dayLabel); | 781 | //dayLayout->addWidget(dayLabel); |
782 | 782 | ||
783 | #ifndef KORG_NOPLUGINS | 783 | #ifndef KORG_NOPLUGINS |
784 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 784 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
785 | CalendarDecoration *it; | 785 | CalendarDecoration *it; |
786 | for(it = cds.first(); it; it = cds.next()) { | 786 | for(it = cds.first(); it; it = cds.next()) { |
787 | QString text = it->shortText( date ); | 787 | QString text = it->shortText( date ); |
788 | if ( !text.isEmpty() ) { | 788 | if ( !text.isEmpty() ) { |
789 | QLabel *label = new QLabel(text,mDayLabels); | 789 | QLabel *label = new QLabel(text,mDayLabels); |
790 | label->setAlignment(AlignCenter); | 790 | label->setAlignment(AlignCenter); |
791 | dayLayout->addWidget(label); | 791 | dayLayout->addWidget(label); |
792 | } | 792 | } |
793 | } | 793 | } |
794 | 794 | ||
795 | for(it = cds.first(); it; it = cds.next()) { | 795 | for(it = cds.first(); it; it = cds.next()) { |
796 | QWidget *wid = it->smallWidget(mDayLabels,date); | 796 | QWidget *wid = it->smallWidget(mDayLabels,date); |
797 | if ( wid ) { | 797 | if ( wid ) { |
798 | // wid->setHeight(20); | 798 | // wid->setHeight(20); |
799 | dayLayout->addWidget(wid); | 799 | dayLayout->addWidget(wid); |
800 | } | 800 | } |
801 | } | 801 | } |
802 | #endif | 802 | #endif |
803 | } | 803 | } |
804 | if ( ! appendLabels ) { | 804 | if ( ! appendLabels ) { |
805 | dayLabel = mDayLabelsList.next(); | 805 | dayLabel = mDayLabelsList.next(); |
806 | if ( !dayLabel ) | 806 | if ( !dayLabel ) |
807 | appendLabels = true; | 807 | appendLabels = true; |
808 | } | 808 | } |
809 | if ( appendLabels ) { | 809 | if ( appendLabels ) { |
810 | dayLabel = new QPushButton(mDayLabels); | 810 | dayLabel = new QPushButton(mDayLabels); |
811 | dayLabel->setFlat( true ); | 811 | dayLabel->setFlat( true ); |
812 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); | 812 | connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); |
813 | dayLabel->setFocusPolicy(NoFocus); | 813 | dayLabel->setFocusPolicy(NoFocus); |
814 | mDayLabelsList.append( dayLabel ); | 814 | mDayLabelsList.append( dayLabel ); |
815 | mLayoutDayLabels->addWidget(dayLabel); | 815 | mLayoutDayLabels->addWidget(dayLabel); |
816 | } | 816 | } |
817 | //dayLabel->hide();//test only | 817 | //dayLabel->hide();//test only |
818 | 818 | ||
819 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 819 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
820 | if ( offset < 0 ) offset = 0; | 820 | if ( offset < 0 ) offset = 0; |
821 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 821 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
822 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 822 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
823 | dayLabel->setFont( dlf ); | ||
823 | dayLabel->show(); | 824 | dayLabel->show(); |
824 | dayLabel->setCaption("last"); | 825 | dayLabel->setCaption("last"); |
825 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 826 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
826 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 827 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
827 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 828 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
828 | if ( !appendLabels ) { | 829 | if ( !appendLabels ) { |
829 | dayLabel = mDayLabelsList.next(); | 830 | dayLabel = mDayLabelsList.next(); |
830 | while ( dayLabel ) { | 831 | while ( dayLabel ) { |
831 | //qDebug("!dayLabel %d",dayLabel ); | 832 | //qDebug("!dayLabel %d",dayLabel ); |
832 | dayLabel->hide(); | 833 | dayLabel->hide(); |
833 | dayLabel = mDayLabelsList.next(); | 834 | dayLabel = mDayLabelsList.next(); |
834 | } | 835 | } |
835 | } | 836 | } |
836 | //mDayLabelsFrame->show(); | 837 | //mDayLabelsFrame->show(); |
837 | //mDayLabels->show(); | 838 | //mDayLabels->show(); |
838 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 839 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
839 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 840 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
840 | mDayLabelsFrame->setFixedHeight( newHight ); | 841 | mDayLabelsFrame->setFixedHeight( newHight ); |
841 | } | 842 | } |
842 | 843 | ||
843 | int KOAgendaView::maxDatesHint() | 844 | int KOAgendaView::maxDatesHint() |
844 | { | 845 | { |
845 | // Not sure about the max number of events, so return 0 for now. | 846 | // Not sure about the max number of events, so return 0 for now. |
846 | return 0; | 847 | return 0; |
847 | } | 848 | } |
848 | 849 | ||
849 | int KOAgendaView::currentDateCount() | 850 | int KOAgendaView::currentDateCount() |
850 | { | 851 | { |
851 | return mSelectedDates.count(); | 852 | return mSelectedDates.count(); |
852 | } | 853 | } |
853 | 854 | ||
854 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 855 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
855 | { | 856 | { |
856 | QPtrList<Incidence> selected; | 857 | QPtrList<Incidence> selected; |
857 | Incidence *incidence; | 858 | Incidence *incidence; |
858 | 859 | ||
859 | incidence = mAgenda->selectedIncidence(); | 860 | incidence = mAgenda->selectedIncidence(); |
860 | if (incidence) selected.append(incidence); | 861 | if (incidence) selected.append(incidence); |
861 | 862 | ||
862 | incidence = mAllDayAgenda->selectedIncidence(); | 863 | incidence = mAllDayAgenda->selectedIncidence(); |
863 | if (incidence) selected.append(incidence); | 864 | if (incidence) selected.append(incidence); |
864 | 865 | ||
865 | return selected; | 866 | return selected; |
866 | } | 867 | } |
867 | 868 | ||
868 | DateList KOAgendaView::selectedDates() | 869 | DateList KOAgendaView::selectedDates() |
869 | { | 870 | { |
870 | DateList selected; | 871 | DateList selected; |
871 | QDate qd; | 872 | QDate qd; |
872 | 873 | ||
873 | qd = mAgenda->selectedIncidenceDate(); | 874 | qd = mAgenda->selectedIncidenceDate(); |
874 | if (qd.isValid()) selected.append(qd); | 875 | if (qd.isValid()) selected.append(qd); |
875 | 876 | ||
876 | qd = mAllDayAgenda->selectedIncidenceDate(); | 877 | qd = mAllDayAgenda->selectedIncidenceDate(); |
877 | if (qd.isValid()) selected.append(qd); | 878 | if (qd.isValid()) selected.append(qd); |
878 | 879 | ||
879 | return selected; | 880 | return selected; |
880 | } | 881 | } |
881 | 882 | ||
882 | 883 | ||
883 | void KOAgendaView::updateView() | 884 | void KOAgendaView::updateView() |
884 | { | 885 | { |
885 | if ( mBlockUpdating ) | 886 | if ( mBlockUpdating ) |
886 | return; | 887 | return; |
887 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 888 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
888 | fillAgenda(); | 889 | fillAgenda(); |
889 | 890 | ||
890 | } | 891 | } |
891 | 892 | ||
892 | 893 | ||
893 | /* | 894 | /* |
894 | Update configuration settings for the agenda view. This method is not | 895 | Update configuration settings for the agenda view. This method is not |
895 | complete. | 896 | complete. |
896 | */ | 897 | */ |
897 | void KOAgendaView::updateConfig() | 898 | void KOAgendaView::updateConfig() |
898 | { | 899 | { |
899 | if ( mBlockUpdating ) | 900 | if ( mBlockUpdating ) |
900 | return; | 901 | return; |
901 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; | 902 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; |
902 | 903 | ||
903 | // update config for children | 904 | // update config for children |
904 | mTimeLabels->updateConfig(); | 905 | mTimeLabels->updateConfig(); |
905 | mAgenda->storePosition(); | 906 | mAgenda->storePosition(); |
906 | mAgenda->updateConfig(); | 907 | mAgenda->updateConfig(); |
907 | mAllDayAgenda->updateConfig(); | 908 | mAllDayAgenda->updateConfig(); |
908 | // widget synchronization | 909 | // widget synchronization |
909 | //TODO: find a better way, maybe signal/slot | 910 | //TODO: find a better way, maybe signal/slot |
910 | mTimeLabels->positionChanged(); | 911 | mTimeLabels->positionChanged(); |
911 | 912 | ||
912 | // for some reason, this needs to be called explicitly | 913 | // for some reason, this needs to be called explicitly |
913 | mTimeLabels->repaint(); | 914 | mTimeLabels->repaint(); |
914 | 915 | ||
915 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 916 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
916 | 917 | ||
917 | // ToolTips displaying summary of events | 918 | // ToolTips displaying summary of events |
918 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 919 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
919 | ->mEnableToolTips); | 920 | ->mEnableToolTips); |
920 | 921 | ||
921 | //setHolidayMasks(); | 922 | //setHolidayMasks(); |
922 | 923 | ||
923 | //createDayLabels(); called by via updateView(); | 924 | //createDayLabels(); called by via updateView(); |
924 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 925 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
925 | updateView(); | 926 | updateView(); |
926 | mAgenda->restorePosition(); | 927 | mAgenda->restorePosition(); |
927 | } | 928 | } |
928 | 929 | ||
929 | 930 | ||
930 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 931 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
931 | { | 932 | { |
932 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 933 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
933 | //qDebug("KOAgendaView::updateEventDates "); | 934 | //qDebug("KOAgendaView::updateEventDates "); |
934 | QDateTime startDt,endDt; | 935 | QDateTime startDt,endDt; |
935 | QDate startDate; | 936 | QDate startDate; |
936 | int lenInSecs; | 937 | int lenInSecs; |
937 | // if ( type == KOAgenda::RESIZETOP ) | 938 | // if ( type == KOAgenda::RESIZETOP ) |
938 | // qDebug("RESIZETOP "); | 939 | // qDebug("RESIZETOP "); |
939 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 940 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
940 | // qDebug("RESIZEBOTTOM "); | 941 | // qDebug("RESIZEBOTTOM "); |
941 | // if ( type == KOAgenda::MOVE ) | 942 | // if ( type == KOAgenda::MOVE ) |
942 | // qDebug("MOVE "); | 943 | // qDebug("MOVE "); |
943 | if ( item->incidence()->type() == "Event" ) { | 944 | if ( item->incidence()->type() == "Event" ) { |
944 | startDt =item->incidence()->dtStart(); | 945 | startDt =item->incidence()->dtStart(); |
945 | endDt = item->incidence()->dtEnd(); | 946 | endDt = item->incidence()->dtEnd(); |
946 | lenInSecs = startDt.secsTo( endDt ); | 947 | lenInSecs = startDt.secsTo( endDt ); |
947 | } | 948 | } |
948 | 949 | ||
949 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 950 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
950 | 951 | ||
951 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 952 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
952 | startDate = mSelectedDates[item->mLastMoveXPos]; | 953 | startDate = mSelectedDates[item->mLastMoveXPos]; |
953 | } else { | 954 | } else { |
954 | if (item->cellX() < 0) { | 955 | if (item->cellX() < 0) { |
955 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 956 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
956 | } else { | 957 | } else { |
957 | startDate = mSelectedDates[item->cellX()]; | 958 | startDate = mSelectedDates[item->cellX()]; |
958 | } | 959 | } |
959 | } | 960 | } |
960 | startDt.setDate(startDate); | 961 | startDt.setDate(startDate); |
961 | 962 | ||
962 | if (item->incidence()->doesFloat()) { | 963 | if (item->incidence()->doesFloat()) { |
963 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 964 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
964 | } else { | 965 | } else { |
965 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 966 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
966 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 967 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
967 | if ( item->incidence()->type() == "Event" ) { | 968 | if ( item->incidence()->type() == "Event" ) { |
968 | if ( type == KOAgenda::MOVE ) { | 969 | if ( type == KOAgenda::MOVE ) { |
969 | endDt = startDt.addSecs(lenInSecs); | 970 | endDt = startDt.addSecs(lenInSecs); |
970 | 971 | ||
971 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 972 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
972 | if (item->lastMultiItem()) { | 973 | if (item->lastMultiItem()) { |
973 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 974 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
974 | endDt.setDate(startDate. | 975 | endDt.setDate(startDate. |
975 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 976 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
976 | } else { | 977 | } else { |
977 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 978 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
978 | endDt.setDate(startDate); | 979 | endDt.setDate(startDate); |
979 | } | 980 | } |
980 | } | 981 | } |
981 | } else { | 982 | } else { |
982 | // todo | 983 | // todo |
983 | qDebug("tooooodoooooo "); | 984 | qDebug("tooooodoooooo "); |
984 | if (item->lastMultiItem()) { | 985 | if (item->lastMultiItem()) { |
985 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 986 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
986 | endDt.setDate(startDate. | 987 | endDt.setDate(startDate. |
987 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 988 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
988 | } else { | 989 | } else { |
989 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 990 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
990 | if ( item->cellYBottom() > 0 ) | 991 | if ( item->cellYBottom() > 0 ) |
991 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 992 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
992 | else | 993 | else |
993 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 994 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
994 | endDt.setDate(startDate); | 995 | endDt.setDate(startDate); |
995 | } | 996 | } |
996 | } | 997 | } |
997 | } | 998 | } |
998 | 999 | ||
999 | qDebug("to888"); | 1000 | qDebug("to888"); |
1000 | if ( item->incidence()->type() == "Event" ) { | 1001 | if ( item->incidence()->type() == "Event" ) { |
1001 | item->incidence()->setDtStart(startDt); | 1002 | item->incidence()->setDtStart(startDt); |
1002 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1003 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1003 | } else if ( item->incidence()->type() == "Todo" ) { | 1004 | } else if ( item->incidence()->type() == "Todo" ) { |
1004 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); | 1005 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); |
1005 | } | 1006 | } |
1006 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1007 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1007 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1008 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1008 | item->setItemDate(startDt.date()); | 1009 | item->setItemDate(startDt.date()); |
1009 | //item->updateItem(); | 1010 | //item->updateItem(); |
1010 | if ( item->incidence()->type() == "Todo" ) { | 1011 | if ( item->incidence()->type() == "Todo" ) { |
1011 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1012 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1012 | 1013 | ||
1013 | } | 1014 | } |
1014 | else | 1015 | else |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 549ef2a..dd83d48 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -301,328 +301,329 @@ const QDate& KODayMatrix::getDate(int offset) | |||
301 | qDebug("Wrong offset2 "); | 301 | qDebug("Wrong offset2 "); |
302 | return days[0]; | 302 | return days[0]; |
303 | } | 303 | } |
304 | return days[offset]; | 304 | return days[offset]; |
305 | } | 305 | } |
306 | 306 | ||
307 | QString KODayMatrix::getHolidayLabel(int offset) | 307 | QString KODayMatrix::getHolidayLabel(int offset) |
308 | { | 308 | { |
309 | if (offset < 0 || offset > NUMDAYS-1) { | 309 | if (offset < 0 || offset > NUMDAYS-1) { |
310 | qDebug("Wrong offset1 "); | 310 | qDebug("Wrong offset1 "); |
311 | return 0; | 311 | return 0; |
312 | } | 312 | } |
313 | return mHolidays[offset]; | 313 | return mHolidays[offset]; |
314 | } | 314 | } |
315 | 315 | ||
316 | int KODayMatrix::getDayIndexFrom(int x, int y) | 316 | int KODayMatrix::getDayIndexFrom(int x, int y) |
317 | { | 317 | { |
318 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 318 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
319 | 6 - x/daysize.width() : x/daysize.width()); | 319 | 6 - x/daysize.width() : x/daysize.width()); |
320 | } | 320 | } |
321 | 321 | ||
322 | // ---------------------------------------------------------------------------- | 322 | // ---------------------------------------------------------------------------- |
323 | // M O U S E E V E N T H A N D L I N G | 323 | // M O U S E E V E N T H A N D L I N G |
324 | // ---------------------------------------------------------------------------- | 324 | // ---------------------------------------------------------------------------- |
325 | 325 | ||
326 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 326 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
327 | { | 327 | { |
328 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 328 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
329 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 329 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
330 | mSelInit = mSelStart; | 330 | mSelInit = mSelStart; |
331 | } | 331 | } |
332 | 332 | ||
333 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 333 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
334 | { | 334 | { |
335 | 335 | ||
336 | int tmp = getDayIndexFrom(e->x(), e->y()); | 336 | int tmp = getDayIndexFrom(e->x(), e->y()); |
337 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 337 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
338 | 338 | ||
339 | if (mSelInit > tmp) { | 339 | if (mSelInit > tmp) { |
340 | mSelEnd = mSelInit; | 340 | mSelEnd = mSelInit; |
341 | if (tmp != mSelStart) { | 341 | if (tmp != mSelStart) { |
342 | mSelStart = tmp; | 342 | mSelStart = tmp; |
343 | repaint(); | 343 | repaint(); |
344 | } | 344 | } |
345 | } else { | 345 | } else { |
346 | mSelStart = mSelInit; | 346 | mSelStart = mSelInit; |
347 | 347 | ||
348 | //repaint only if selection has changed | 348 | //repaint only if selection has changed |
349 | if (tmp != mSelEnd) { | 349 | if (tmp != mSelEnd) { |
350 | mSelEnd = tmp; | 350 | mSelEnd = tmp; |
351 | repaint(); | 351 | repaint(); |
352 | } | 352 | } |
353 | } | 353 | } |
354 | 354 | ||
355 | DateList daylist; | 355 | DateList daylist; |
356 | if ( mSelStart < 0 ) | 356 | if ( mSelStart < 0 ) |
357 | mSelStart = 0; | 357 | mSelStart = 0; |
358 | for (int i = mSelStart; i <= mSelEnd; i++) { | 358 | for (int i = mSelStart; i <= mSelEnd; i++) { |
359 | daylist.append(days[i]); | 359 | daylist.append(days[i]); |
360 | } | 360 | } |
361 | emit selected((const DateList)daylist); | 361 | emit selected((const DateList)daylist); |
362 | 362 | ||
363 | } | 363 | } |
364 | 364 | ||
365 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 365 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
366 | { | 366 | { |
367 | int tmp = getDayIndexFrom(e->x(), e->y()); | 367 | int tmp = getDayIndexFrom(e->x(), e->y()); |
368 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 368 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
369 | 369 | ||
370 | if (mSelInit > tmp) { | 370 | if (mSelInit > tmp) { |
371 | mSelEnd = mSelInit; | 371 | mSelEnd = mSelInit; |
372 | if (tmp != mSelStart) { | 372 | if (tmp != mSelStart) { |
373 | mSelStart = tmp; | 373 | mSelStart = tmp; |
374 | repaint(); | 374 | repaint(); |
375 | } | 375 | } |
376 | } else { | 376 | } else { |
377 | mSelStart = mSelInit; | 377 | mSelStart = mSelInit; |
378 | 378 | ||
379 | //repaint only if selection has changed | 379 | //repaint only if selection has changed |
380 | if (tmp != mSelEnd) { | 380 | if (tmp != mSelEnd) { |
381 | mSelEnd = tmp; | 381 | mSelEnd = tmp; |
382 | repaint(); | 382 | repaint(); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | // ---------------------------------------------------------------------------- | 387 | // ---------------------------------------------------------------------------- |
388 | // D R A G ' N D R O P H A N D L I N G | 388 | // D R A G ' N D R O P H A N D L I N G |
389 | // ---------------------------------------------------------------------------- | 389 | // ---------------------------------------------------------------------------- |
390 | 390 | ||
391 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 391 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
392 | { | 392 | { |
393 | #ifndef KORG_NODND | 393 | #ifndef KORG_NODND |
394 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 394 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
395 | e->ignore(); | 395 | e->ignore(); |
396 | return; | 396 | return; |
397 | } | 397 | } |
398 | 398 | ||
399 | // some visual feedback | 399 | // some visual feedback |
400 | // oldPalette = palette(); | 400 | // oldPalette = palette(); |
401 | // setPalette(my_HilitePalette); | 401 | // setPalette(my_HilitePalette); |
402 | // update(); | 402 | // update(); |
403 | #endif | 403 | #endif |
404 | } | 404 | } |
405 | 405 | ||
406 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 406 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
407 | { | 407 | { |
408 | #ifndef KORG_NODND | 408 | #ifndef KORG_NODND |
409 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 409 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
410 | e->ignore(); | 410 | e->ignore(); |
411 | return; | 411 | return; |
412 | } | 412 | } |
413 | 413 | ||
414 | e->accept(); | 414 | e->accept(); |
415 | #endif | 415 | #endif |
416 | } | 416 | } |
417 | 417 | ||
418 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 418 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
419 | { | 419 | { |
420 | #ifndef KORG_NODND | 420 | #ifndef KORG_NODND |
421 | // setPalette(oldPalette); | 421 | // setPalette(oldPalette); |
422 | // update(); | 422 | // update(); |
423 | #endif | 423 | #endif |
424 | } | 424 | } |
425 | 425 | ||
426 | void KODayMatrix::dropEvent(QDropEvent *e) | 426 | void KODayMatrix::dropEvent(QDropEvent *e) |
427 | { | 427 | { |
428 | #ifndef KORG_NODND | 428 | #ifndef KORG_NODND |
429 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 429 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
430 | 430 | ||
431 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 431 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
432 | e->ignore(); | 432 | e->ignore(); |
433 | return; | 433 | return; |
434 | } | 434 | } |
435 | 435 | ||
436 | DndFactory factory( mCalendar ); | 436 | DndFactory factory( mCalendar ); |
437 | Event *event = factory.createDrop(e); | 437 | Event *event = factory.createDrop(e); |
438 | 438 | ||
439 | if (event) { | 439 | if (event) { |
440 | e->acceptAction(); | 440 | e->acceptAction(); |
441 | 441 | ||
442 | Event *existingEvent = mCalendar->event(event->uid()); | 442 | Event *existingEvent = mCalendar->event(event->uid()); |
443 | 443 | ||
444 | if(existingEvent) { | 444 | if(existingEvent) { |
445 | // uniquify event | 445 | // uniquify event |
446 | event->recreate(); | 446 | event->recreate(); |
447 | /* | 447 | /* |
448 | KMessageBox::sorry(this, | 448 | KMessageBox::sorry(this, |
449 | i18n("Event already exists in this calendar."), | 449 | i18n("Event already exists in this calendar."), |
450 | i18n("Drop Event")); | 450 | i18n("Drop Event")); |
451 | delete event; | 451 | delete event; |
452 | return; | 452 | return; |
453 | */ | 453 | */ |
454 | } | 454 | } |
455 | // kdDebug() << "Drop new Event" << endl; | 455 | // kdDebug() << "Drop new Event" << endl; |
456 | // Adjust date | 456 | // Adjust date |
457 | QDateTime start = event->dtStart(); | 457 | QDateTime start = event->dtStart(); |
458 | QDateTime end = event->dtEnd(); | 458 | QDateTime end = event->dtEnd(); |
459 | int duration = start.daysTo(end); | 459 | int duration = start.daysTo(end); |
460 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 460 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
461 | 461 | ||
462 | start.setDate(days[idx]); | 462 | start.setDate(days[idx]); |
463 | end.setDate(days[idx].addDays(duration)); | 463 | end.setDate(days[idx].addDays(duration)); |
464 | 464 | ||
465 | event->setDtStart(start); | 465 | event->setDtStart(start); |
466 | event->setDtEnd(end); | 466 | event->setDtEnd(end); |
467 | mCalendar->addEvent(event); | 467 | mCalendar->addEvent(event); |
468 | 468 | ||
469 | emit eventDropped(event); | 469 | emit eventDropped(event); |
470 | } else { | 470 | } else { |
471 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 471 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
472 | e->ignore(); | 472 | e->ignore(); |
473 | } | 473 | } |
474 | #endif | 474 | #endif |
475 | } | 475 | } |
476 | 476 | ||
477 | // ---------------------------------------------------------------------------- | 477 | // ---------------------------------------------------------------------------- |
478 | // P A I N T E V E N T H A N D L I N G | 478 | // P A I N T E V E N T H A N D L I N G |
479 | // ---------------------------------------------------------------------------- | 479 | // ---------------------------------------------------------------------------- |
480 | 480 | ||
481 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 481 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
482 | { | 482 | { |
483 | if ( width() <= 0 || height() <= 0 ) | 483 | if ( width() <= 0 || height() <= 0 ) |
484 | return; | 484 | return; |
485 | if ( mPendingUpdateBeforeRepaint ) { | 485 | if ( mPendingUpdateBeforeRepaint ) { |
486 | updateViewTimed(); | 486 | updateViewTimed(); |
487 | mPendingUpdateBeforeRepaint = false; | 487 | mPendingUpdateBeforeRepaint = false; |
488 | } | 488 | } |
489 | if ( myPix.width() != width() || myPix.height()!=height() ) { | 489 | if ( myPix.width() != width() || myPix.height()!=height() ) { |
490 | myPix.resize(size() ); | 490 | myPix.resize(size() ); |
491 | } | 491 | } |
492 | QPainter p(&myPix); | 492 | QPainter p(&myPix); |
493 | p.setFont(font()); | ||
493 | 494 | ||
494 | QRect sz = frameRect(); | 495 | QRect sz = frameRect(); |
495 | int dheight = daysize.height(); | 496 | int dheight = daysize.height(); |
496 | int dwidth = daysize.width(); | 497 | int dwidth = daysize.width(); |
497 | int row,col; | 498 | int row,col; |
498 | int selw, selh; | 499 | int selw, selh; |
499 | bool isRTL = KOGlobals::self()->reverseLayout(); | 500 | bool isRTL = KOGlobals::self()->reverseLayout(); |
500 | 501 | ||
501 | // draw background and topleft frame | 502 | // draw background and topleft frame |
502 | p.fillRect(pevent->rect(), mDefaultBackColor); | 503 | p.fillRect(pevent->rect(), mDefaultBackColor); |
503 | p.setPen(mDefaultTextColor); | 504 | p.setPen(mDefaultTextColor); |
504 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 505 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
505 | 506 | ||
506 | // draw selected days with highlighted background color | 507 | // draw selected days with highlighted background color |
507 | if (mSelStart != NOSELECTION) { | 508 | if (mSelStart != NOSELECTION) { |
508 | 509 | ||
509 | row = mSelStart/7; | 510 | row = mSelStart/7; |
510 | col = mSelStart -row*7; | 511 | col = mSelStart -row*7; |
511 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 512 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
512 | 513 | ||
513 | if (row == mSelEnd/7) { | 514 | if (row == mSelEnd/7) { |
514 | // Single row selection | 515 | // Single row selection |
515 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, | 516 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, |
516 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); | 517 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); |
517 | } else { | 518 | } else { |
518 | // draw first row to the right | 519 | // draw first row to the right |
519 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, | 520 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, |
520 | dheight, selcol); | 521 | dheight, selcol); |
521 | // draw full block till last line | 522 | // draw full block till last line |
522 | selh = mSelEnd/7-row; | 523 | selh = mSelEnd/7-row; |
523 | if (selh > 1) { | 524 | if (selh > 1) { |
524 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); | 525 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); |
525 | } | 526 | } |
526 | // draw last block from left to mSelEnd | 527 | // draw last block from left to mSelEnd |
527 | selw = mSelEnd-7*(mSelEnd/7)+1; | 528 | selw = mSelEnd-7*(mSelEnd/7)+1; |
528 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, | 529 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, |
529 | selw*dwidth, dheight, selcol); | 530 | selw*dwidth, dheight, selcol); |
530 | } | 531 | } |
531 | } | 532 | } |
532 | 533 | ||
533 | // iterate over all days in the matrix and draw the day label in appropriate colors | 534 | // iterate over all days in the matrix and draw the day label in appropriate colors |
534 | QColor actcol = mDefaultTextColorShaded; | 535 | QColor actcol = mDefaultTextColorShaded; |
535 | p.setPen(actcol); | 536 | p.setPen(actcol); |
536 | QPen tmppen; | 537 | QPen tmppen; |
537 | for(int i = 0; i < NUMDAYS; i++) { | 538 | for(int i = 0; i < NUMDAYS; i++) { |
538 | row = i/7; | 539 | row = i/7; |
539 | col = isRTL ? 6-(i-row*7) : i-row*7; | 540 | col = isRTL ? 6-(i-row*7) : i-row*7; |
540 | 541 | ||
541 | // if it is the first day of a month switch color from normal to shaded and vice versa | 542 | // if it is the first day of a month switch color from normal to shaded and vice versa |
542 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 543 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
543 | if (actcol == mDefaultTextColorShaded) { | 544 | if (actcol == mDefaultTextColorShaded) { |
544 | actcol = mDefaultTextColor; | 545 | actcol = mDefaultTextColor; |
545 | } else { | 546 | } else { |
546 | actcol = mDefaultTextColorShaded; | 547 | actcol = mDefaultTextColorShaded; |
547 | } | 548 | } |
548 | p.setPen(actcol); | 549 | p.setPen(actcol); |
549 | } | 550 | } |
550 | 551 | ||
551 | //Reset pen color after selected days block | 552 | //Reset pen color after selected days block |
552 | if (i == mSelEnd+1) { | 553 | if (i == mSelEnd+1) { |
553 | p.setPen(actcol); | 554 | p.setPen(actcol); |
554 | } | 555 | } |
555 | 556 | ||
556 | // if today then draw rectangle around day | 557 | // if today then draw rectangle around day |
557 | if (today == i) { | 558 | if (today == i) { |
558 | tmppen = p.pen(); | 559 | tmppen = p.pen(); |
559 | QPen mTodayPen(p.pen()); | 560 | QPen mTodayPen(p.pen()); |
560 | 561 | ||
561 | mTodayPen.setWidth(mTodayMarginWidth); | 562 | mTodayPen.setWidth(mTodayMarginWidth); |
562 | //draw red rectangle for holidays | 563 | //draw red rectangle for holidays |
563 | if (!mHolidays[i].isNull()) { | 564 | if (!mHolidays[i].isNull()) { |
564 | if (actcol == mDefaultTextColor) { | 565 | if (actcol == mDefaultTextColor) { |
565 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 566 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
566 | } else { | 567 | } else { |
567 | mTodayPen.setColor(mHolidayColorShaded); | 568 | mTodayPen.setColor(mHolidayColorShaded); |
568 | } | 569 | } |
569 | } | 570 | } |
570 | //draw gray rectangle for today if in selection | 571 | //draw gray rectangle for today if in selection |
571 | if (i >= mSelStart && i <= mSelEnd) { | 572 | if (i >= mSelStart && i <= mSelEnd) { |
572 | QColor grey("grey"); | 573 | QColor grey("grey"); |
573 | mTodayPen.setColor(grey); | 574 | mTodayPen.setColor(grey); |
574 | } | 575 | } |
575 | p.setPen(mTodayPen); | 576 | p.setPen(mTodayPen); |
576 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); | 577 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); |
577 | p.setPen(tmppen); | 578 | p.setPen(tmppen); |
578 | } | 579 | } |
579 | 580 | ||
580 | // if any events are on that day then draw it using a bold font | 581 | // if any events are on that day then draw it using a bold font |
581 | if (events[i] > 0) { | 582 | if (events[i] > 0) { |
582 | QFont myFont = font(); | 583 | QFont myFont = font(); |
583 | myFont.setBold(true); | 584 | myFont.setBold(true); |
584 | p.setFont(myFont); | 585 | p.setFont(myFont); |
585 | } | 586 | } |
586 | 587 | ||
587 | // if it is a holiday then use the default holiday color | 588 | // if it is a holiday then use the default holiday color |
588 | if (!mHolidays[i].isNull()) { | 589 | if (!mHolidays[i].isNull()) { |
589 | if (actcol == mDefaultTextColor) { | 590 | if (actcol == mDefaultTextColor) { |
590 | p.setPen(KOPrefs::instance()->mHolidayColor); | 591 | p.setPen(KOPrefs::instance()->mHolidayColor); |
591 | } else { | 592 | } else { |
592 | p.setPen(mHolidayColorShaded); | 593 | p.setPen(mHolidayColorShaded); |
593 | } | 594 | } |
594 | } | 595 | } |
595 | 596 | ||
596 | // draw selected days with special color | 597 | // draw selected days with special color |
597 | // DO NOT specially highlight holidays in selection ! | 598 | // DO NOT specially highlight holidays in selection ! |
598 | if (i >= mSelStart && i <= mSelEnd) { | 599 | if (i >= mSelStart && i <= mSelEnd) { |
599 | p.setPen(mSelectedDaysColor); | 600 | p.setPen(mSelectedDaysColor); |
600 | } | 601 | } |
601 | 602 | ||
602 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, | 603 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, |
603 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 604 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
604 | 605 | ||
605 | // reset color to actual color | 606 | // reset color to actual color |
606 | if (!mHolidays[i].isNull()) { | 607 | if (!mHolidays[i].isNull()) { |
607 | p.setPen(actcol); | 608 | p.setPen(actcol); |
608 | } | 609 | } |
609 | // reset bold font to plain font | 610 | // reset bold font to plain font |
610 | if (events[i] > 0) { | 611 | if (events[i] > 0) { |
611 | QFont myFont = font(); | 612 | QFont myFont = font(); |
612 | myFont.setBold(false); | 613 | myFont.setBold(false); |
613 | p.setFont(myFont); | 614 | p.setFont(myFont); |
614 | } | 615 | } |
615 | } | 616 | } |
616 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 617 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); |
617 | } | 618 | } |
618 | 619 | ||
619 | // ---------------------------------------------------------------------------- | 620 | // ---------------------------------------------------------------------------- |
620 | // R E SI Z E E V E N T H A N D L I N G | 621 | // R E SI Z E E V E N T H A N D L I N G |
621 | // ---------------------------------------------------------------------------- | 622 | // ---------------------------------------------------------------------------- |
622 | 623 | ||
623 | void KODayMatrix::resizeEvent(QResizeEvent *) | 624 | void KODayMatrix::resizeEvent(QResizeEvent *) |
624 | { | 625 | { |
625 | QRect sz = frameRect(); | 626 | QRect sz = frameRect(); |
626 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 627 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
627 | daysize.setWidth(sz.width() / 7); | 628 | daysize.setWidth(sz.width() / 7); |
628 | } | 629 | } |