author | zautrix <zautrix> | 2005-02-01 23:46:24 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-01 23:46:24 (UTC) |
commit | 9ecfd0660e36b6b8dd7401f0edb16dd3d6f03289 (patch) (unidiff) | |
tree | d80eb20b97ab401b4e9e34f25b65030fb2c0b035 /korganizer | |
parent | afa94abe147d23e09a14a81e47d04d4a3d5670c3 (diff) | |
download | kdepimpi-9ecfd0660e36b6b8dd7401f0edb16dd3d6f03289.zip kdepimpi-9ecfd0660e36b6b8dd7401f0edb16dd3d6f03289.tar.gz kdepimpi-9ecfd0660e36b6b8dd7401f0edb16dd3d6f03289.tar.bz2 |
text
-rw-r--r-- | korganizer/komonthview.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 9888566..6294b98 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -629,133 +629,129 @@ void MonthViewCell::updateConfig() | |||
629 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 629 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
630 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 630 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
631 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 631 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
632 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 632 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
633 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 633 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
634 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 634 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
635 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 635 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
636 | } | 636 | } |
637 | //updateCell(); | 637 | //updateCell(); |
638 | } | 638 | } |
639 | 639 | ||
640 | void MonthViewCell::enableScrollBars( bool enabled ) | 640 | void MonthViewCell::enableScrollBars( bool enabled ) |
641 | { | 641 | { |
642 | if ( enabled ) { | 642 | if ( enabled ) { |
643 | mItemList->setVScrollBarMode(QScrollView::Auto); | 643 | mItemList->setVScrollBarMode(QScrollView::Auto); |
644 | mItemList->setHScrollBarMode(QScrollView::Auto); | 644 | mItemList->setHScrollBarMode(QScrollView::Auto); |
645 | } else { | 645 | } else { |
646 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 646 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
647 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 647 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
648 | } | 648 | } |
649 | } | 649 | } |
650 | 650 | ||
651 | Incidence *MonthViewCell::selectedIncidence() | 651 | Incidence *MonthViewCell::selectedIncidence() |
652 | { | 652 | { |
653 | int index = mItemList->currentItem(); | 653 | int index = mItemList->currentItem(); |
654 | if ( index < 0 ) return 0; | 654 | if ( index < 0 ) return 0; |
655 | 655 | ||
656 | MonthViewItem *item = | 656 | MonthViewItem *item = |
657 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 657 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
658 | 658 | ||
659 | if ( !item ) return 0; | 659 | if ( !item ) return 0; |
660 | 660 | ||
661 | return item->incidence(); | 661 | return item->incidence(); |
662 | } | 662 | } |
663 | 663 | ||
664 | QDate MonthViewCell::selectedIncidenceDate() | 664 | QDate MonthViewCell::selectedIncidenceDate() |
665 | { | 665 | { |
666 | QDate qd; | 666 | QDate qd; |
667 | int index = mItemList->currentItem(); | 667 | int index = mItemList->currentItem(); |
668 | if ( index < 0 ) return qd; | 668 | if ( index < 0 ) return qd; |
669 | 669 | ||
670 | MonthViewItem *item = | 670 | MonthViewItem *item = |
671 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 671 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
672 | 672 | ||
673 | if ( !item ) return qd; | 673 | if ( !item ) return qd; |
674 | 674 | ||
675 | return item->incidenceDate(); | 675 | return item->incidenceDate(); |
676 | } | 676 | } |
677 | 677 | ||
678 | void MonthViewCell::deselect() | 678 | void MonthViewCell::deselect() |
679 | { | 679 | { |
680 | mItemList->clearSelection(); | 680 | mItemList->clearSelection(); |
681 | enableScrollBars( false ); | 681 | enableScrollBars( false ); |
682 | // updateCell(); | 682 | // updateCell(); |
683 | } | 683 | } |
684 | void MonthViewCell::select() | 684 | void MonthViewCell::select() |
685 | { | 685 | { |
686 | ;// updateCell(); | 686 | ;// updateCell(); |
687 | } | 687 | } |
688 | 688 | ||
689 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 689 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
690 | { | 690 | { |
691 | if ( !mMonthView->isUpdatePossible() ) | 691 | if ( !mMonthView->isUpdatePossible() ) |
692 | return; | 692 | return; |
693 | #ifndef DESKTOP_VERSION | 693 | |
694 | if ( !isVisible() ){ | ||
695 | return; | ||
696 | } | ||
697 | #endif | ||
698 | int size = height() - mLabel->height() - 2; | 694 | int size = height() - mLabel->height() - 2; |
699 | if ( size > 0 ) | 695 | if ( size > 0 ) |
700 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 696 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
701 | size = width() - mLabel->width() -2; | 697 | size = width() - mLabel->width() -2; |
702 | if ( size > 0 ) | 698 | if ( size > 0 ) |
703 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 699 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
704 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 700 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
705 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 701 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
706 | } | 702 | } |
707 | 703 | ||
708 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 704 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
709 | { | 705 | { |
710 | if ( !item ) return; | 706 | if ( !item ) return; |
711 | 707 | ||
712 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 708 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
713 | Incidence *incidence = eventItem->incidence(); | 709 | Incidence *incidence = eventItem->incidence(); |
714 | if ( incidence ) mMonthView->defaultAction( incidence ); | 710 | if ( incidence ) mMonthView->defaultAction( incidence ); |
715 | } | 711 | } |
716 | void MonthViewCell::showDay() | 712 | void MonthViewCell::showDay() |
717 | { | 713 | { |
718 | emit showDaySignal( date() ); | 714 | emit showDaySignal( date() ); |
719 | } | 715 | } |
720 | void MonthViewCell::newEvent() | 716 | void MonthViewCell::newEvent() |
721 | { | 717 | { |
722 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 718 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
723 | emit newEventSignal( dt ); | 719 | emit newEventSignal( dt ); |
724 | } | 720 | } |
725 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 721 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
726 | { | 722 | { |
727 | static QListBoxItem * lastClicked = 0; | 723 | static QListBoxItem * lastClicked = 0; |
728 | if ( item == 0 ) { | 724 | if ( item == 0 ) { |
729 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 725 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
730 | emit newEventSignal( dt ); | 726 | emit newEventSignal( dt ); |
731 | return; | 727 | return; |
732 | } | 728 | } |
733 | /* | 729 | /* |
734 | if ( lastClicked ) | 730 | if ( lastClicked ) |
735 | if ( ! item ) { | 731 | if ( ! item ) { |
736 | if ( lastClicked->listBox() != item->listBox() ) | 732 | if ( lastClicked->listBox() != item->listBox() ) |
737 | lastClicked->listBox()->clearSelection(); | 733 | lastClicked->listBox()->clearSelection(); |
738 | } | 734 | } |
739 | */ | 735 | */ |
740 | 736 | ||
741 | mMonthView->setSelectedCell( this ); | 737 | mMonthView->setSelectedCell( this ); |
742 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 738 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
743 | select(); | 739 | select(); |
744 | } | 740 | } |
745 | 741 | ||
746 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 742 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
747 | { | 743 | { |
748 | if ( !item ) return; | 744 | if ( !item ) return; |
749 | 745 | ||
750 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 746 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
751 | Incidence *incidence = eventItem->incidence(); | 747 | Incidence *incidence = eventItem->incidence(); |
752 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 748 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
753 | } | 749 | } |
754 | 750 | ||
755 | void MonthViewCell::selection( QListBoxItem *item ) | 751 | void MonthViewCell::selection( QListBoxItem *item ) |
756 | { | 752 | { |
757 | if ( !item ) return; | 753 | if ( !item ) return; |
758 | 754 | ||
759 | mMonthView->setSelectedCell( this ); | 755 | mMonthView->setSelectedCell( this ); |
760 | } | 756 | } |
761 | 757 | ||
@@ -780,128 +776,130 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
780 | // mDayLayout = new QGridLayout( this ); | 776 | // mDayLayout = new QGridLayout( this ); |
781 | // create the day of the week labels (Sun, Mon, etc) and add them to | 777 | // create the day of the week labels (Sun, Mon, etc) and add them to |
782 | // the layout. | 778 | // the layout. |
783 | mDayLabels.resize( mDaysPerWeek ); | 779 | mDayLabels.resize( mDaysPerWeek ); |
784 | QFont bfont = font(); | 780 | QFont bfont = font(); |
785 | if ( QApplication::desktop()->width() < 650 ) { | 781 | if ( QApplication::desktop()->width() < 650 ) { |
786 | bfont.setPointSize( bfont.pointSize() - 2 ); | 782 | bfont.setPointSize( bfont.pointSize() - 2 ); |
787 | } | 783 | } |
788 | bfont.setBold( true ); | 784 | bfont.setBold( true ); |
789 | int i; | 785 | int i; |
790 | 786 | ||
791 | for( i = 0; i < mDaysPerWeek; i++ ) { | 787 | for( i = 0; i < mDaysPerWeek; i++ ) { |
792 | QLabel *label = new QLabel( this ); | 788 | QLabel *label = new QLabel( this ); |
793 | label->setFont(bfont); | 789 | label->setFont(bfont); |
794 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 790 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
795 | label->setLineWidth(1); | 791 | label->setLineWidth(1); |
796 | label->setAlignment(AlignCenter); | 792 | label->setAlignment(AlignCenter); |
797 | mDayLabels.insert( i, label ); | 793 | mDayLabels.insert( i, label ); |
798 | } | 794 | } |
799 | 795 | ||
800 | bfont.setBold( false ); | 796 | bfont.setBold( false ); |
801 | mWeekLabels.resize( mNumWeeks+1 ); | 797 | mWeekLabels.resize( mNumWeeks+1 ); |
802 | for( i = 0; i < mNumWeeks+1; i++ ) { | 798 | for( i = 0; i < mNumWeeks+1; i++ ) { |
803 | KOWeekButton *label = new KOWeekButton( this ); | 799 | KOWeekButton *label = new KOWeekButton( this ); |
804 | label->setFont(bfont); | 800 | label->setFont(bfont); |
805 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); | 801 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); |
806 | label->setFlat(true); | 802 | label->setFlat(true); |
807 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); | 803 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); |
808 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 804 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
809 | //label->setLineWidth(1); | 805 | //label->setLineWidth(1); |
810 | //label->setAlignment(AlignCenter); | 806 | //label->setAlignment(AlignCenter); |
811 | mWeekLabels.insert( i, label ); | 807 | mWeekLabels.insert( i, label ); |
812 | } | 808 | } |
813 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 809 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
814 | int row, col; | 810 | int row, col; |
815 | mCells.resize( mNumCells ); | 811 | mCells.resize( mNumCells ); |
816 | for( row = 0; row < mNumWeeks; ++row ) { | 812 | for( row = 0; row < mNumWeeks; ++row ) { |
817 | for( col = 0; col < mDaysPerWeek; ++col ) { | 813 | for( col = 0; col < mDaysPerWeek; ++col ) { |
818 | MonthViewCell *cell = new MonthViewCell( this ); | 814 | MonthViewCell *cell = new MonthViewCell( this ); |
819 | mCells.insert( row * mDaysPerWeek + col, cell ); | 815 | mCells.insert( row * mDaysPerWeek + col, cell ); |
820 | 816 | ||
821 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 817 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
822 | SLOT( defaultAction( Incidence * ) ) ); | 818 | SLOT( defaultAction( Incidence * ) ) ); |
823 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 819 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
824 | SIGNAL( newEventSignal( QDateTime ) ) ); | 820 | SIGNAL( newEventSignal( QDateTime ) ) ); |
825 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 821 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
826 | SIGNAL( showDaySignal( QDate ) ) ); | 822 | SIGNAL( showDaySignal( QDate ) ) ); |
827 | } | 823 | } |
828 | } | 824 | } |
829 | 825 | ||
830 | connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), | 826 | connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), |
831 | SLOT( switchView() ) ); | 827 | SLOT( switchView() ) ); |
832 | mContextMenu = eventPopup(); | 828 | mContextMenu = eventPopup(); |
833 | // updateConfig(); //useless here | 829 | // updateConfig(); //useless here |
834 | 830 | ||
835 | emit incidenceSelected( 0 ); | 831 | emit incidenceSelected( 0 ); |
836 | } | 832 | } |
837 | 833 | ||
838 | KOMonthView::~KOMonthView() | 834 | KOMonthView::~KOMonthView() |
839 | { | 835 | { |
840 | delete mContextMenu; | 836 | delete mContextMenu; |
841 | } | 837 | } |
842 | void KOMonthView::switchView() | 838 | void KOMonthView::switchView() |
843 | { | 839 | { |
840 | if ( selectedCell( ) ) | ||
841 | selectedCell()->deselect(); | ||
844 | mShowWeekView = !mShowWeekView; | 842 | mShowWeekView = !mShowWeekView; |
845 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 843 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
846 | emit showNavigator( !mShowWeekView ); | 844 | emit showNavigator( !mShowWeekView ); |
847 | computeLayout(); | 845 | computeLayout(); |
848 | updateConfig(); | 846 | updateConfig(); |
849 | } | 847 | } |
850 | 848 | ||
851 | int KOMonthView::maxDatesHint() | 849 | int KOMonthView::maxDatesHint() |
852 | { | 850 | { |
853 | return mNumCells; | 851 | return mNumCells; |
854 | } | 852 | } |
855 | 853 | ||
856 | int KOMonthView::currentDateCount() | 854 | int KOMonthView::currentDateCount() |
857 | { | 855 | { |
858 | return mNumCells; | 856 | return mNumCells; |
859 | } | 857 | } |
860 | 858 | ||
861 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 859 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
862 | { | 860 | { |
863 | QPtrList<Incidence> selected; | 861 | QPtrList<Incidence> selected; |
864 | 862 | ||
865 | if ( mSelectedCell ) { | 863 | if ( mSelectedCell ) { |
866 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 864 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
867 | if ( incidence ) selected.append( incidence ); | 865 | if ( incidence ) selected.append( incidence ); |
868 | } | 866 | } |
869 | 867 | ||
870 | return selected; | 868 | return selected; |
871 | } | 869 | } |
872 | 870 | ||
873 | DateList KOMonthView::selectedDates() | 871 | DateList KOMonthView::selectedDates() |
874 | { | 872 | { |
875 | DateList selected; | 873 | DateList selected; |
876 | 874 | ||
877 | if ( mSelectedCell ) { | 875 | if ( mSelectedCell ) { |
878 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 876 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
879 | if ( qd.isValid() ) selected.append( qd ); | 877 | if ( qd.isValid() ) selected.append( qd ); |
880 | } | 878 | } |
881 | 879 | ||
882 | return selected; | 880 | return selected; |
883 | } | 881 | } |
884 | 882 | ||
885 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 883 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
886 | const QDate &td) | 884 | const QDate &td) |
887 | { | 885 | { |
888 | #ifndef KORG_NOPRINTER | 886 | #ifndef KORG_NOPRINTER |
889 | calPrinter->preview(CalPrinter::Month, fd, td); | 887 | calPrinter->preview(CalPrinter::Month, fd, td); |
890 | #endif | 888 | #endif |
891 | } | 889 | } |
892 | 890 | ||
893 | void KOMonthView::updateConfig() | 891 | void KOMonthView::updateConfig() |
894 | { | 892 | { |
895 | 893 | ||
896 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 894 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
897 | 895 | ||
898 | if ( mShowWeekView ) | 896 | if ( mShowWeekView ) |
899 | mWeekStartsMonday = true; | 897 | mWeekStartsMonday = true; |
900 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 898 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
901 | mWidthLongDayLabel = 0; | 899 | mWidthLongDayLabel = 0; |
902 | 900 | ||
903 | for (int i = 0; i < 7; i++) { | 901 | for (int i = 0; i < 7; i++) { |
904 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 902 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
905 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 903 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
906 | } | 904 | } |
907 | bool temp = mShowSatSunComp ; | 905 | bool temp = mShowSatSunComp ; |
@@ -1098,133 +1096,134 @@ void KOMonthView::updateView() | |||
1098 | mCells[i]->updateCell(); | 1096 | mCells[i]->updateCell(); |
1099 | } | 1097 | } |
1100 | 1098 | ||
1101 | //qDebug("KOMonthView::updateView() "); | 1099 | //qDebug("KOMonthView::updateView() "); |
1102 | processSelectionChange(); | 1100 | processSelectionChange(); |
1103 | // qDebug("---------------------------------------------------------------------+ "); | 1101 | // qDebug("---------------------------------------------------------------------+ "); |
1104 | mCells[0]->setFocus(); | 1102 | mCells[0]->setFocus(); |
1105 | #endif | 1103 | #endif |
1106 | 1104 | ||
1107 | //qDebug("update time %d ", ti.elapsed()); | 1105 | //qDebug("update time %d ", ti.elapsed()); |
1108 | } | 1106 | } |
1109 | 1107 | ||
1110 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1108 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1111 | { | 1109 | { |
1112 | computeLayout(); | 1110 | computeLayout(); |
1113 | mCells[0]->setFocus(); | 1111 | mCells[0]->setFocus(); |
1114 | } | 1112 | } |
1115 | void KOMonthView::computeLayoutWeek() | 1113 | void KOMonthView::computeLayoutWeek() |
1116 | { | 1114 | { |
1117 | 1115 | ||
1118 | int daysToShow; | 1116 | int daysToShow; |
1119 | bool combinedSatSun = false; | 1117 | bool combinedSatSun = false; |
1120 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1118 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1121 | daysToShow = 6; | 1119 | daysToShow = 6; |
1122 | combinedSatSun = true; | 1120 | combinedSatSun = true; |
1123 | } | 1121 | } |
1124 | int tWid = topLevelWidget()->size().width(); | 1122 | int tWid = topLevelWidget()->size().width(); |
1125 | int tHei = topLevelWidget()->size().height(); | 1123 | int tHei = topLevelWidget()->size().height(); |
1126 | 1124 | ||
1127 | int wid = size().width();//e | 1125 | int wid = size().width();//e |
1128 | int hei = size().height()-1; | 1126 | int hei = size().height()-1; |
1129 | 1127 | ||
1130 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1128 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1131 | return; | 1129 | return; |
1132 | 1130 | ||
1133 | if ( wid < hei ) | 1131 | if ( wid < hei ) |
1134 | daysToShow = 2; | 1132 | daysToShow = 2; |
1135 | else | 1133 | else |
1136 | daysToShow = 3; | 1134 | daysToShow = 3; |
1137 | mShowSatSunComp = true; | 1135 | mShowSatSunComp = true; |
1138 | combinedSatSun = true; | 1136 | combinedSatSun = true; |
1139 | 1137 | ||
1140 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1138 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1141 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1139 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1142 | int weeklabelwid = fm.width( "888" ); | 1140 | int weeklabelwid = fm.width( "888" ); |
1143 | wid -= weeklabelwid; | 1141 | wid -= weeklabelwid; |
1144 | 1142 | ||
1145 | int colWid = wid / daysToShow; | 1143 | int colWid = wid / daysToShow; |
1146 | int lastCol = wid - ( colWid*6 ); | 1144 | int lastCol = wid - ( colWid*6 ); |
1147 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1145 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1148 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1146 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1149 | int colModulo = wid % daysToShow; | 1147 | int colModulo = wid % daysToShow; |
1150 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1148 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1151 | //qDebug("rowmod %d ", rowModulo); | 1149 | //qDebug("rowmod %d ", rowModulo); |
1152 | int i; | 1150 | int i; |
1153 | int x,y,w,h; | 1151 | int x,y,w,h; |
1154 | x= 0; | 1152 | x= 0; |
1155 | y= 0; | 1153 | y= 0; |
1156 | w = colWid; | 1154 | w = colWid; |
1157 | h = dayLabelHei ; | 1155 | h = dayLabelHei ; |
1158 | for ( i = 0; i < 7; i++) { | 1156 | for ( i = 0; i < 7; i++) { |
1159 | if ( i && !( i % daysToShow) && i < 6) { | 1157 | if ( i && !( i % daysToShow) && i < 6) { |
1160 | y += hei/(5-daysToShow); | 1158 | y += hei/(5-daysToShow); |
1161 | x = 0; | 1159 | x = 0; |
1160 | w = colWid; | ||
1162 | } | 1161 | } |
1163 | if ( i == daysToShow-colModulo ) | 1162 | if ( i == daysToShow-colModulo ) |
1164 | ++w; | 1163 | ++w; |
1165 | if ( i >= 5 ) { | 1164 | if ( i >= 5 ) { |
1166 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1165 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+1,h); |
1167 | x -= w/2 ; | 1166 | x -= w/2 ; |
1168 | } | 1167 | } |
1169 | else | 1168 | else |
1170 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1169 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1171 | x += w; | 1170 | x += w; |
1172 | } | 1171 | } |
1173 | x= 0; | 1172 | x= 0; |
1174 | y= dayLabelHei; | 1173 | y= dayLabelHei; |
1175 | w = colWid; | 1174 | w = colWid; |
1176 | h = cellHei; | 1175 | h = cellHei; |
1177 | for ( i = 0; i < mCells.count(); ++i) { | 1176 | for ( i = 0; i < mCells.count(); ++i) { |
1178 | if ( i > 6 ) { | 1177 | if ( i > 6 ) { |
1179 | mCells[i]->hide(); | 1178 | mCells[i]->hide(); |
1180 | continue; | 1179 | continue; |
1181 | } | 1180 | } |
1182 | 1181 | ||
1183 | w = colWid; | 1182 | w = colWid; |
1184 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1183 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1185 | ++w; | 1184 | ++w; |
1186 | } | 1185 | } |
1187 | if ( i == (daysToShow-1-rowModulo)*7) | 1186 | if ( i == (daysToShow-1-rowModulo)*7) |
1188 | ++h; | 1187 | ++h; |
1189 | 1188 | ||
1190 | if ( i >= 5 ) { | 1189 | if ( i >= 5 ) { |
1191 | if ( i ==5 ) { | 1190 | if ( i ==5 ) { |
1192 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1191 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1193 | x -= w ;y += h/2; | 1192 | x -= w ;y += h/2; |
1194 | } else { | 1193 | } else { |
1195 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1194 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1196 | y -= h/2; | 1195 | y -= h/2; |
1197 | } | 1196 | } |
1198 | } else | 1197 | } else |
1199 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1198 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1200 | 1199 | ||
1201 | 1200 | ||
1202 | x += w; | 1201 | x += w; |
1203 | if ( x + w/2 > wid ) { | 1202 | if ( x + w/2 > wid ) { |
1204 | x = 0; | 1203 | x = 0; |
1205 | y += h+dayLabelHei ; | 1204 | y += h+dayLabelHei ; |
1206 | } | 1205 | } |
1207 | } | 1206 | } |
1208 | y= dayLabelHei; | 1207 | y= dayLabelHei; |
1209 | h = cellHei ; | 1208 | h = cellHei ; |
1210 | mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1209 | mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1211 | for ( i = 1; i < 6; i++) { | 1210 | for ( i = 1; i < 6; i++) { |
1212 | mWeekLabels[i]->hide(); | 1211 | mWeekLabels[i]->hide(); |
1213 | } | 1212 | } |
1214 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1213 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1215 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1214 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1216 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1215 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1217 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1216 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1218 | updateDayLabels(); | 1217 | updateDayLabels(); |
1219 | bool forceUpdate = !updatePossible; | 1218 | bool forceUpdate = !updatePossible; |
1220 | updatePossible = true; | 1219 | updatePossible = true; |
1221 | mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1220 | mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1222 | if ( forceUpdate ) | 1221 | if ( forceUpdate ) |
1223 | updateView(); | 1222 | updateView(); |
1224 | } | 1223 | } |
1225 | void KOMonthView::computeLayout() | 1224 | void KOMonthView::computeLayout() |
1226 | { | 1225 | { |
1227 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 1226 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
1228 | // note this only changes the text if the requested size crosses the | 1227 | // note this only changes the text if the requested size crosses the |
1229 | // threshold between big enough to support the full name and not big | 1228 | // threshold between big enough to support the full name and not big |
1230 | // enough. | 1229 | // enough. |