-rw-r--r-- | korganizer/komonthview.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 4cefb26..770a42b 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -880,192 +880,193 @@ void KOMonthView::updateConfig() | |||
880 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 880 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
881 | #endif | 881 | #endif |
882 | } | 882 | } |
883 | 883 | ||
884 | void KOMonthView::updateDayLabels() | 884 | void KOMonthView::updateDayLabels() |
885 | { | 885 | { |
886 | 886 | ||
887 | for (int i = 0; i < 7; i++) { | 887 | for (int i = 0; i < 7; i++) { |
888 | if (mWeekStartsMonday) { | 888 | if (mWeekStartsMonday) { |
889 | bool show = mShortDayLabels; | 889 | bool show = mShortDayLabels; |
890 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) | 890 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) |
891 | show = true; | 891 | show = true; |
892 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 892 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
893 | } else { | 893 | } else { |
894 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 894 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
895 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 895 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
896 | 896 | ||
897 | } | 897 | } |
898 | } | 898 | } |
899 | } | 899 | } |
900 | 900 | ||
901 | void KOMonthView::showDates(const QDate &start, const QDate &) | 901 | void KOMonthView::showDates(const QDate &start, const QDate &) |
902 | { | 902 | { |
903 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 903 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
904 | 904 | ||
905 | 905 | ||
906 | mStartDate = start; | 906 | mStartDate = start; |
907 | 907 | ||
908 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 908 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
909 | 909 | ||
910 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 910 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
911 | mStartDate = mStartDate.addDays( -1 ); | 911 | mStartDate = mStartDate.addDays( -1 ); |
912 | } | 912 | } |
913 | 913 | ||
914 | bool primary = false; | 914 | bool primary = false; |
915 | uint i; | 915 | uint i; |
916 | for( i = 0; i < mCells.size(); ++i ) { | 916 | for( i = 0; i < mCells.size(); ++i ) { |
917 | QDate date = mStartDate.addDays( i ); | 917 | QDate date = mStartDate.addDays( i ); |
918 | mCells[i]->setDate( date ); | 918 | mCells[i]->setDate( date ); |
919 | 919 | ||
920 | #ifndef KORG_NOPLUGINS | 920 | #ifndef KORG_NOPLUGINS |
921 | // add holiday, if present | 921 | // add holiday, if present |
922 | QString hstring(KOCore::self()->holiday(date)); | 922 | QString hstring(KOCore::self()->holiday(date)); |
923 | mCells[i]->setHoliday( hstring ); | 923 | mCells[i]->setHoliday( hstring ); |
924 | #endif | 924 | #endif |
925 | 925 | ||
926 | } | 926 | } |
927 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 927 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
928 | for( i = 0; i < 6; ++i ) { | 928 | for( i = 0; i < 6; ++i ) { |
929 | int wno; | 929 | int wno; |
930 | // remember, according to ISO 8601, the first week of the year is the | 930 | // remember, according to ISO 8601, the first week of the year is the |
931 | // first week that contains a thursday. Thus we must subtract off 4, | 931 | // first week that contains a thursday. Thus we must subtract off 4, |
932 | // not just 1. | 932 | // not just 1. |
933 | int dayOfYear = date.dayOfYear(); | 933 | int dayOfYear = date.dayOfYear(); |
934 | if (dayOfYear % 7 != 0) | 934 | if (dayOfYear % 7 != 0) |
935 | wno = dayOfYear / 7 + 1; | 935 | wno = dayOfYear / 7 + 1; |
936 | else | 936 | else |
937 | wno =dayOfYear / 7; | 937 | wno =dayOfYear / 7; |
938 | mWeekLabels[i]->setWeekNum( wno ); | 938 | mWeekLabels[i]->setWeekNum( wno ); |
939 | date = date.addDays( 7 ); | 939 | date = date.addDays( 7 ); |
940 | } | 940 | } |
941 | updateView(); | 941 | updateView(); |
942 | } | 942 | } |
943 | 943 | ||
944 | void KOMonthView::showEvents(QPtrList<Event>) | 944 | void KOMonthView::showEvents(QPtrList<Event>) |
945 | { | 945 | { |
946 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 946 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
947 | } | 947 | } |
948 | 948 | ||
949 | void KOMonthView::changeEventDisplay(Event *, int) | 949 | void KOMonthView::changeEventDisplay(Event *, int) |
950 | { | 950 | { |
951 | // this should be re-written to be much more efficient, but this | 951 | // this should be re-written to be much more efficient, but this |
952 | // quick-and-dirty-hack gets the job done for right now. | 952 | // quick-and-dirty-hack gets the job done for right now. |
953 | updateView(); | 953 | updateView(); |
954 | } | 954 | } |
955 | 955 | ||
956 | void KOMonthView::updateView() | 956 | void KOMonthView::updateView() |
957 | { | 957 | { |
958 | 958 | ||
959 | if ( !updatePossible ) | 959 | if ( !updatePossible ) |
960 | return; | 960 | return; |
961 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 961 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
962 | int i; | 962 | int i; |
963 | for( i = 0; i < mCells.count(); ++i ) { | 963 | for( i = 0; i < mCells.count(); ++i ) { |
964 | mCells[i]->updateCell(); | 964 | mCells[i]->updateCell(); |
965 | } | 965 | } |
966 | 966 | ||
967 | //qDebug("KOMonthView::updateView() "); | 967 | //qDebug("KOMonthView::updateView() "); |
968 | processSelectionChange(); | 968 | processSelectionChange(); |
969 | // qDebug("---------------------------------------------------------------------+ "); | 969 | // qDebug("---------------------------------------------------------------------+ "); |
970 | mCells[0]->setFocus(); | 970 | mCells[0]->setFocus(); |
971 | } | 971 | } |
972 | 972 | ||
973 | void KOMonthView::resizeEvent(QResizeEvent * e) | 973 | void KOMonthView::resizeEvent(QResizeEvent * e) |
974 | { | 974 | { |
975 | computeLayout(); | 975 | computeLayout(); |
976 | mCells[0]->setFocus(); | ||
976 | } | 977 | } |
977 | void KOMonthView::computeLayout() | 978 | void KOMonthView::computeLayout() |
978 | { | 979 | { |
979 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 980 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
980 | // note this only changes the text if the requested size crosses the | 981 | // note this only changes the text if the requested size crosses the |
981 | // threshold between big enough to support the full name and not big | 982 | // threshold between big enough to support the full name and not big |
982 | // enough. | 983 | // enough. |
983 | 984 | ||
984 | int daysToShow = 7; | 985 | int daysToShow = 7; |
985 | bool combinedSatSun = false; | 986 | bool combinedSatSun = false; |
986 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 987 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
987 | daysToShow = 6; | 988 | daysToShow = 6; |
988 | combinedSatSun = true; | 989 | combinedSatSun = true; |
989 | } | 990 | } |
990 | int tWid = topLevelWidget()->size().width(); | 991 | int tWid = topLevelWidget()->size().width(); |
991 | int tHei = topLevelWidget()->size().height(); | 992 | int tHei = topLevelWidget()->size().height(); |
992 | 993 | ||
993 | int wid = size().width();//e | 994 | int wid = size().width();//e |
994 | int hei = size().height()-1; | 995 | int hei = size().height()-1; |
995 | 996 | ||
996 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 997 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
997 | return; | 998 | return; |
998 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 999 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
999 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1000 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1000 | int weeklabelwid = fm.width( "888" ); | 1001 | int weeklabelwid = fm.width( "888" ); |
1001 | wid -= weeklabelwid; | 1002 | wid -= weeklabelwid; |
1002 | 1003 | ||
1003 | int colWid = wid / daysToShow; | 1004 | int colWid = wid / daysToShow; |
1004 | int lastCol = wid - ( colWid*6 ); | 1005 | int lastCol = wid - ( colWid*6 ); |
1005 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1006 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1006 | int cellHei = (hei - dayLabelHei) /6; | 1007 | int cellHei = (hei - dayLabelHei) /6; |
1007 | int colModulo = wid % daysToShow; | 1008 | int colModulo = wid % daysToShow; |
1008 | int rowModulo = (hei- dayLabelHei) % 6; | 1009 | int rowModulo = (hei- dayLabelHei) % 6; |
1009 | //qDebug("rowmod %d ", rowModulo); | 1010 | //qDebug("rowmod %d ", rowModulo); |
1010 | int i; | 1011 | int i; |
1011 | int x,y,w,h; | 1012 | int x,y,w,h; |
1012 | x= 0; | 1013 | x= 0; |
1013 | y= 0; | 1014 | y= 0; |
1014 | w = colWid; | 1015 | w = colWid; |
1015 | h = dayLabelHei ; | 1016 | h = dayLabelHei ; |
1016 | for ( i = 0; i < 7; i++) { | 1017 | for ( i = 0; i < 7; i++) { |
1017 | if ( i == daysToShow-colModulo ) | 1018 | if ( i == daysToShow-colModulo ) |
1018 | ++w; | 1019 | ++w; |
1019 | if ( combinedSatSun ) { | 1020 | if ( combinedSatSun ) { |
1020 | if ( i >= daysToShow-1 ) { | 1021 | if ( i >= daysToShow-1 ) { |
1021 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1022 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1022 | x -= w/2 ; | 1023 | x -= w/2 ; |
1023 | } | 1024 | } |
1024 | else | 1025 | else |
1025 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1026 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1026 | } else | 1027 | } else |
1027 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1028 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1028 | x += w; | 1029 | x += w; |
1029 | } | 1030 | } |
1030 | x= 0; | 1031 | x= 0; |
1031 | y= dayLabelHei; | 1032 | y= dayLabelHei; |
1032 | w = colWid; | 1033 | w = colWid; |
1033 | h = cellHei ; | 1034 | h = cellHei ; |
1034 | for ( i = 0; i < mCells.count(); ++i) { | 1035 | for ( i = 0; i < mCells.count(); ++i) { |
1035 | 1036 | ||
1036 | w = colWid; | 1037 | w = colWid; |
1037 | if ( ((i) % 7) >= 7-colModulo ) { | 1038 | if ( ((i) % 7) >= 7-colModulo ) { |
1038 | ++w; | 1039 | ++w; |
1039 | } | 1040 | } |
1040 | if ( i == (6-rowModulo)*7) | 1041 | if ( i == (6-rowModulo)*7) |
1041 | ++h; | 1042 | ++h; |
1042 | if ( combinedSatSun ) { | 1043 | if ( combinedSatSun ) { |
1043 | if ( (i)%7 >= daysToShow-1 ) { | 1044 | if ( (i)%7 >= daysToShow-1 ) { |
1044 | if ( (i)%7 == daysToShow-1 ) { | 1045 | if ( (i)%7 == daysToShow-1 ) { |
1045 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1046 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1046 | x -= w ;y += h/2; | 1047 | x -= w ;y += h/2; |
1047 | } else { | 1048 | } else { |
1048 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1049 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1049 | y -= h/2; | 1050 | y -= h/2; |
1050 | } | 1051 | } |
1051 | } else | 1052 | } else |
1052 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1053 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1053 | 1054 | ||
1054 | } | 1055 | } |
1055 | else | 1056 | else |
1056 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1057 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1057 | x += w; | 1058 | x += w; |
1058 | if ( x + w/2 > wid ) { | 1059 | if ( x + w/2 > wid ) { |
1059 | x = 0; | 1060 | x = 0; |
1060 | y += h; | 1061 | y += h; |
1061 | } | 1062 | } |
1062 | } | 1063 | } |
1063 | y= dayLabelHei; | 1064 | y= dayLabelHei; |
1064 | h = cellHei ; | 1065 | h = cellHei ; |
1065 | for ( i = 0; i < 6; i++) { | 1066 | for ( i = 0; i < 6; i++) { |
1066 | if ( i == (6-rowModulo)) | 1067 | if ( i == (6-rowModulo)) |
1067 | ++h; | 1068 | ++h; |
1068 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1069 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1069 | y += h; | 1070 | y += h; |
1070 | } | 1071 | } |
1071 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1072 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |