-rw-r--r-- | korganizer/komonthview.cpp | 90 |
1 files changed, 39 insertions, 51 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index ffb2e1e..70cbf96 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -862,97 +862,104 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
862 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 862 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
863 | 863 | ||
864 | for( i = 0; i < 1+1; i++ ) { | 864 | for( i = 0; i < 1+1; i++ ) { |
865 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 865 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
866 | label->setFocusPolicy(NoFocus); | 866 | label->setFocusPolicy(NoFocus); |
867 | label->setFont(bfont); | 867 | label->setFont(bfont); |
868 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 868 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
869 | label->setFlat(true); | 869 | label->setFlat(true); |
870 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 870 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
871 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 871 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
872 | //label->setLineWidth(1); | 872 | //label->setLineWidth(1); |
873 | //label->setAlignment(AlignCenter); | 873 | //label->setAlignment(AlignCenter); |
874 | mWeekLabelsW.insert( i, label ); | 874 | mWeekLabelsW.insert( i, label ); |
875 | } | 875 | } |
876 | mWeekLabelsW[1]->setText( i18n("W")); | 876 | mWeekLabelsW[1]->setText( i18n("W")); |
877 | 877 | ||
878 | 878 | ||
879 | int row, col; | 879 | int row, col; |
880 | mCells.resize( mNumCells ); | 880 | mCells.resize( mNumCells ); |
881 | for( row = 0; row < mNumWeeks; ++row ) { | 881 | for( row = 0; row < mNumWeeks; ++row ) { |
882 | for( col = 0; col < mDaysPerWeek; ++col ) { | 882 | for( col = 0; col < mDaysPerWeek; ++col ) { |
883 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 883 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
884 | mCells.insert( row * mDaysPerWeek + col, cell ); | 884 | mCells.insert( row * mDaysPerWeek + col, cell ); |
885 | 885 | ||
886 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 886 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
887 | SLOT( defaultAction( Incidence * ) ) ); | 887 | SLOT( defaultAction( Incidence * ) ) ); |
888 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 888 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
889 | SIGNAL( newEventSignal( QDateTime ) ) ); | 889 | SIGNAL( newEventSignal( QDateTime ) ) ); |
890 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 890 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
891 | SIGNAL( showDaySignal( QDate ) ) ); | 891 | SIGNAL( showDaySignal( QDate ) ) ); |
892 | } | 892 | } |
893 | } | 893 | } |
894 | mCellsW.resize( mDaysPerWeek ); | 894 | mCellsW.resize( mDaysPerWeek ); |
895 | for( col = 0; col < mDaysPerWeek; ++col ) { | 895 | for( col = 0; col < mDaysPerWeek; ++col ) { |
896 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 896 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
897 | mCellsW.insert( col, cell ); | 897 | mCellsW.insert( col, cell ); |
898 | 898 | ||
899 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 899 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
900 | SLOT( defaultAction( Incidence * ) ) ); | 900 | SLOT( defaultAction( Incidence * ) ) ); |
901 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 901 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
902 | SIGNAL( newEventSignal( QDateTime ) ) ); | 902 | SIGNAL( newEventSignal( QDateTime ) ) ); |
903 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 903 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
904 | SIGNAL( showDaySignal( QDate ) ) ); | 904 | SIGNAL( showDaySignal( QDate ) ) ); |
905 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 905 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
906 | } | 906 | } |
907 | 907 | ||
908 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 908 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
909 | mContextMenu = eventPopup(); | 909 | mContextMenu = eventPopup(); |
910 | updateConfig(); //useless here | 910 | //updateConfig(); //useless here ... |
911 | // ... but we need mWidthLongDayLabel computed | ||
912 | QFontMetrics fontmetric(mDayLabels[0]->font()); | ||
913 | mWidthLongDayLabel = 0; | ||
914 | for (int i = 0; i < 7; i++) { | ||
915 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | ||
916 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | ||
917 | } | ||
911 | 918 | ||
912 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 919 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
913 | 920 | ||
914 | if ( mShowWeekView ) | 921 | if ( mShowWeekView ) |
915 | mWidStack->raiseWidget( mWeekView ); | 922 | mWidStack->raiseWidget( mWeekView ); |
916 | else | 923 | else |
917 | mWidStack->raiseWidget( mMonthView ); | 924 | mWidStack->raiseWidget( mMonthView ); |
918 | 925 | ||
919 | emit incidenceSelected( 0 ); | 926 | emit incidenceSelected( 0 ); |
920 | } | 927 | } |
921 | 928 | ||
922 | KOMonthView::~KOMonthView() | 929 | KOMonthView::~KOMonthView() |
923 | { | 930 | { |
924 | delete mContextMenu; | 931 | delete mContextMenu; |
925 | } | 932 | } |
926 | 933 | ||
927 | void KOMonthView::selectInternalWeekNum ( int n ) | 934 | void KOMonthView::selectInternalWeekNum ( int n ) |
928 | { | 935 | { |
929 | switchView(); | 936 | switchView(); |
930 | emit selectWeekNum ( n ); | 937 | emit selectWeekNum ( n ); |
931 | } | 938 | } |
932 | 939 | ||
933 | int KOMonthView::currentWeek() | 940 | int KOMonthView::currentWeek() |
934 | { | 941 | { |
935 | if ( mShowWeekView ) | 942 | if ( mShowWeekView ) |
936 | return mWeekLabelsW[0]->getWeekNum(); | 943 | return mWeekLabelsW[0]->getWeekNum(); |
937 | return mWeekLabels[0]->getWeekNum(); | 944 | return mWeekLabels[0]->getWeekNum(); |
938 | } | 945 | } |
939 | void KOMonthView::switchView() | 946 | void KOMonthView::switchView() |
940 | { | 947 | { |
941 | 948 | ||
942 | if ( selectedCell( ) ) | 949 | if ( selectedCell( ) ) |
943 | selectedCell()->deselect(); | 950 | selectedCell()->deselect(); |
944 | mShowWeekView = !mShowWeekView; | 951 | mShowWeekView = !mShowWeekView; |
945 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 952 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
946 | //emit showNavigator( !mShowWeekView ); | 953 | //emit showNavigator( !mShowWeekView ); |
947 | if ( clPending ) { | 954 | if ( clPending ) { |
948 | computeLayout(); | 955 | computeLayout(); |
949 | updateConfig(); | 956 | updateConfig(); |
950 | } | 957 | } |
951 | if ( mShowWeekView ) | 958 | if ( mShowWeekView ) |
952 | mWidStack->raiseWidget( mWeekView ); | 959 | mWidStack->raiseWidget( mWeekView ); |
953 | else | 960 | else |
954 | mWidStack->raiseWidget( mMonthView ); | 961 | mWidStack->raiseWidget( mMonthView ); |
955 | clPending = false; | 962 | clPending = false; |
956 | } | 963 | } |
957 | 964 | ||
958 | int KOMonthView::maxDatesHint() | 965 | int KOMonthView::maxDatesHint() |
@@ -962,132 +969,125 @@ int KOMonthView::maxDatesHint() | |||
962 | 969 | ||
963 | int KOMonthView::currentDateCount() | 970 | int KOMonthView::currentDateCount() |
964 | { | 971 | { |
965 | return mNumCells; | 972 | return mNumCells; |
966 | } | 973 | } |
967 | 974 | ||
968 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 975 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
969 | { | 976 | { |
970 | QPtrList<Incidence> selected; | 977 | QPtrList<Incidence> selected; |
971 | 978 | ||
972 | if ( mSelectedCell ) { | 979 | if ( mSelectedCell ) { |
973 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 980 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
974 | if ( incidence ) selected.append( incidence ); | 981 | if ( incidence ) selected.append( incidence ); |
975 | } | 982 | } |
976 | 983 | ||
977 | return selected; | 984 | return selected; |
978 | } | 985 | } |
979 | 986 | ||
980 | DateList KOMonthView::selectedDates() | 987 | DateList KOMonthView::selectedDates() |
981 | { | 988 | { |
982 | DateList selected; | 989 | DateList selected; |
983 | 990 | ||
984 | if ( mSelectedCell ) { | 991 | if ( mSelectedCell ) { |
985 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 992 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
986 | if ( qd.isValid() ) selected.append( qd ); | 993 | if ( qd.isValid() ) selected.append( qd ); |
987 | } | 994 | } |
988 | 995 | ||
989 | return selected; | 996 | return selected; |
990 | } | 997 | } |
991 | 998 | ||
992 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 999 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
993 | const QDate &td) | 1000 | const QDate &td) |
994 | { | 1001 | { |
995 | #ifndef KORG_NOPRINTER | 1002 | #ifndef KORG_NOPRINTER |
996 | calPrinter->preview(CalPrinter::Month, fd, td); | 1003 | calPrinter->preview(CalPrinter::Month, fd, td); |
997 | #endif | 1004 | #endif |
998 | } | 1005 | } |
999 | 1006 | ||
1000 | void KOMonthView::updateConfig() | 1007 | void KOMonthView::updateConfig() |
1001 | { | 1008 | { |
1002 | 1009 | ||
1003 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1010 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1004 | 1011 | ||
1005 | if ( mShowWeekView ) { | 1012 | if ( mShowWeekView ) { |
1006 | mWeekStartsMonday = true; | 1013 | mWeekStartsMonday = true; |
1007 | } | 1014 | } |
1008 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1015 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1009 | mWidthLongDayLabel = 0; | 1016 | mWidthLongDayLabel = 0; |
1010 | qDebug("KOMonthView::updateConfig() "); | ||
1011 | for (int i = 0; i < 7; i++) { | 1017 | for (int i = 0; i < 7; i++) { |
1012 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1018 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1013 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1019 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1014 | } | 1020 | } |
1015 | if ( ! mShowWeekView ) { | 1021 | if ( ! mShowWeekView ) { |
1016 | computeLayout(); | 1022 | computeLayout(); |
1017 | } | 1023 | } |
1018 | updateDayLabels(); | 1024 | updateDayLabels(); |
1019 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1025 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1020 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1026 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1021 | //resizeEvent( 0 ); | 1027 | //resizeEvent( 0 ); |
1022 | for (uint i = 0; i < mCells.count(); ++i) { | 1028 | for (uint i = 0; i < mCells.count(); ++i) { |
1023 | mCells[i]->updateConfig(); | 1029 | mCells[i]->updateConfig(); |
1024 | } | 1030 | } |
1025 | 1031 | ||
1026 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1032 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1027 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1033 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1028 | } | 1034 | } |
1029 | #ifdef DESKTOP_VERSION | 1035 | #ifdef DESKTOP_VERSION |
1030 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1036 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1031 | #endif | 1037 | #endif |
1032 | updateView(); | 1038 | updateView(); |
1033 | } | 1039 | } |
1034 | 1040 | ||
1035 | void KOMonthView::updateDayLabels() | 1041 | void KOMonthView::updateDayLabels() |
1036 | { | 1042 | { |
1037 | 1043 | ||
1038 | QPtrVector<QLabel> *mDayLabelsT; | 1044 | QPtrVector<QLabel> *mDayLabelsT; |
1039 | #if 0 | 1045 | |
1040 | if (mShowWeekView ) | ||
1041 | mDayLabelsT = &mDayLabelsW; | ||
1042 | else | ||
1043 | mDayLabelsT = &mDayLabels; | ||
1044 | #endif | ||
1045 | qDebug("updateDayLabels W %d M %d ",mShortDayLabelsW ,mShortDayLabelsM); | ||
1046 | mDayLabelsT = &mDayLabelsW; | 1046 | mDayLabelsT = &mDayLabelsW; |
1047 | for (int i = 0; i < 7; i++) { | 1047 | for (int i = 0; i < 7; i++) { |
1048 | if (mWeekStartsMonday) { | 1048 | if (mWeekStartsMonday) { |
1049 | bool show = mShortDayLabelsW; | 1049 | bool show = mShortDayLabelsW; |
1050 | if ( i > 4 && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1050 | if ( i > 4 && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1051 | show = true; | 1051 | show = true; |
1052 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1052 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1053 | } else { | 1053 | } else { |
1054 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); | 1054 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); |
1055 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); | 1055 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); |
1056 | 1056 | ||
1057 | } | 1057 | } |
1058 | } | 1058 | } |
1059 | mDayLabelsT = &mDayLabels; | 1059 | mDayLabelsT = &mDayLabels; |
1060 | for (int i = 0; i < 7; i++) { | 1060 | for (int i = 0; i < 7; i++) { |
1061 | if (mWeekStartsMonday) { | 1061 | if (mWeekStartsMonday) { |
1062 | bool show = mShortDayLabelsM; | 1062 | bool show = mShortDayLabelsM; |
1063 | if ( i > 4 && KOPrefs::instance()->mMonthViewSatSunTog && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1063 | if ( i > 4 && KOPrefs::instance()->mMonthViewSatSunTog && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1064 | show = true; | 1064 | show = true; |
1065 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1065 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1066 | } else { | 1066 | } else { |
1067 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1067 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1068 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1068 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1069 | 1069 | ||
1070 | } | 1070 | } |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1075 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1076 | { | 1076 | { |
1077 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1077 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1078 | 1078 | ||
1079 | QPtrVector<MonthViewCell> *cells; | 1079 | QPtrVector<MonthViewCell> *cells; |
1080 | QPtrVector<QLabel> *dayLabels; | 1080 | QPtrVector<QLabel> *dayLabels; |
1081 | QPtrVector<KOWeekButton> *weekLabels; | 1081 | QPtrVector<KOWeekButton> *weekLabels; |
1082 | int weekNum = 6; | 1082 | int weekNum = 6; |
1083 | if ( mShowWeekView ) { | 1083 | if ( mShowWeekView ) { |
1084 | weekNum = 1; | 1084 | weekNum = 1; |
1085 | cells = &mCellsW; | 1085 | cells = &mCellsW; |
1086 | dayLabels = &mDayLabelsW; | 1086 | dayLabels = &mDayLabelsW; |
1087 | weekLabels = &mWeekLabelsW; | 1087 | weekLabels = &mWeekLabelsW; |
1088 | } else { | 1088 | } else { |
1089 | cells = &mCells; | 1089 | cells = &mCells; |
1090 | dayLabels = &mDayLabels; | 1090 | dayLabels = &mDayLabels; |
1091 | weekLabels = &mWeekLabels; | 1091 | weekLabels = &mWeekLabels; |
1092 | } | 1092 | } |
1093 | 1093 | ||
@@ -1218,359 +1218,347 @@ void KOMonthView::updateView() | |||
1218 | if ( st < 0 ) st = 0; | 1218 | if ( st < 0 ) st = 0; |
1219 | if ( end > timeSpan ) end = timeSpan; | 1219 | if ( end > timeSpan ) end = timeSpan; |
1220 | int iii; | 1220 | int iii; |
1221 | for ( iii = st;iii<= end;++iii) | 1221 | for ( iii = st;iii<= end;++iii) |
1222 | (*cells)[iii]->insertEvent( event ); | 1222 | (*cells)[iii]->insertEvent( event ); |
1223 | } | 1223 | } |
1224 | } | 1224 | } |
1225 | } | 1225 | } |
1226 | } | 1226 | } |
1227 | // insert due todos | 1227 | // insert due todos |
1228 | QPtrList<Todo> todos = calendar()->todos( ); | 1228 | QPtrList<Todo> todos = calendar()->todos( ); |
1229 | Todo *todo; | 1229 | Todo *todo; |
1230 | for(todo = todos.first(); todo; todo = todos.next()) { | 1230 | for(todo = todos.first(); todo; todo = todos.next()) { |
1231 | //insertTodo( todo ); | 1231 | //insertTodo( todo ); |
1232 | if ( todo->hasDueDate() ) { | 1232 | if ( todo->hasDueDate() ) { |
1233 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1233 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1234 | if ( day >= 0 && day < timeSpan + 1) { | 1234 | if ( day >= 0 && day < timeSpan + 1) { |
1235 | (*cells)[day]->insertTodo( todo ); | 1235 | (*cells)[day]->insertTodo( todo ); |
1236 | } | 1236 | } |
1237 | } | 1237 | } |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | for( i = 0; i < timeSpan+1; ++i ) { | 1240 | for( i = 0; i < timeSpan+1; ++i ) { |
1241 | (*cells)[i]->finishUpdateCell(); | 1241 | (*cells)[i]->finishUpdateCell(); |
1242 | } | 1242 | } |
1243 | processSelectionChange(); | 1243 | processSelectionChange(); |
1244 | (*cells)[0]->setFocus(); | 1244 | (*cells)[0]->setFocus(); |
1245 | 1245 | ||
1246 | 1246 | ||
1247 | #else | 1247 | #else |
1248 | // old code | 1248 | // old code |
1249 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1249 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1250 | int i; | 1250 | int i; |
1251 | for( i = 0; i < (*cells).count(); ++i ) { | 1251 | for( i = 0; i < (*cells).count(); ++i ) { |
1252 | (*cells)[i]->updateCell(); | 1252 | (*cells)[i]->updateCell(); |
1253 | } | 1253 | } |
1254 | 1254 | ||
1255 | //qDebug("KOMonthView::updateView() "); | 1255 | //qDebug("KOMonthView::updateView() "); |
1256 | processSelectionChange(); | 1256 | processSelectionChange(); |
1257 | // qDebug("---------------------------------------------------------------------+ "); | 1257 | // qDebug("---------------------------------------------------------------------+ "); |
1258 | (*cells)[0]->setFocus(); | 1258 | (*cells)[0]->setFocus(); |
1259 | #endif | 1259 | #endif |
1260 | 1260 | ||
1261 | //qDebug("update time %d ", ti.elapsed()); | 1261 | //qDebug("update time %d ", ti.elapsed()); |
1262 | } | 1262 | } |
1263 | 1263 | ||
1264 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1264 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1265 | { | 1265 | { |
1266 | qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1266 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1267 | if ( ignoreResizeEvent ) { | 1267 | if ( ignoreResizeEvent ) { |
1268 | int diff = e->size().height() - e->oldSize().height(); | 1268 | //qDebug("KOMonthView::resizeEvent ignored "); |
1269 | if ( diff < 0 ) | ||
1270 | diff = diff * (-1); | ||
1271 | if ( diff == ignoreResizeEventHeight ) { | ||
1272 | qDebug("KOMonthView::resizeEvent ignored "); | ||
1273 | --ignoreResizeEvent; | 1269 | --ignoreResizeEvent; |
1274 | return; | 1270 | return; |
1275 | } | 1271 | } |
1276 | ignoreResizeEvent = 0; | ||
1277 | } | ||
1278 | if ( e->size().width()+ e->size().height() < 240 ) | 1272 | if ( e->size().width()+ e->size().height() < 240 ) |
1279 | return; | 1273 | return; |
1280 | computeLayout(); | 1274 | computeLayout(); |
1281 | clPending = true; | 1275 | clPending = true; |
1282 | if ( mShowWeekView ) | 1276 | if ( mShowWeekView ) |
1283 | mCellsW[0]->setFocus(); | 1277 | mCellsW[0]->setFocus(); |
1284 | else | 1278 | else |
1285 | mCells[0]->setFocus(); | 1279 | mCells[0]->setFocus(); |
1286 | } | 1280 | } |
1287 | void KOMonthView::computeLayoutWeek() | 1281 | void KOMonthView::computeLayoutWeek() |
1288 | { | 1282 | { |
1289 | 1283 | static int widd = 0; | |
1284 | static int heigg = 0; | ||
1285 | if ( widd == width() && heigg == height () ) { | ||
1286 | return; | ||
1287 | } | ||
1288 | widd = width() ; | ||
1289 | heigg = height (); | ||
1290 | int daysToShow; | 1290 | int daysToShow; |
1291 | int tWid = topLevelWidget()->size().width(); | ||
1292 | int tHei = topLevelWidget()->size().height(); | ||
1293 | |||
1294 | int wid = size().width();//e | 1291 | int wid = size().width();//e |
1295 | int hei = size().height()-1; | 1292 | int hei = size().height()-1; |
1296 | |||
1297 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | ||
1298 | return; | ||
1299 | |||
1300 | if ( wid < hei ) | 1293 | if ( wid < hei ) |
1301 | daysToShow = 2; | 1294 | daysToShow = 2; |
1302 | else | 1295 | else |
1303 | daysToShow = 3; | 1296 | daysToShow = 3; |
1304 | bool combinedSatSun = true; | 1297 | bool combinedSatSun = true; |
1305 | 1298 | ||
1306 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | ||
1307 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1299 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1308 | int weeklabelwid = fm.width( "888" ); | 1300 | int weeklabelwid = fm.width( "888" ); |
1309 | wid -= weeklabelwid; | 1301 | wid -= weeklabelwid; |
1310 | 1302 | ||
1311 | int colWid = wid / daysToShow; | 1303 | int colWid = wid / daysToShow; |
1312 | int lastCol = wid - ( colWid*6 ); | 1304 | int lastCol = wid - ( colWid*6 ); |
1313 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1305 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1314 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1306 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1315 | int colModulo = wid % daysToShow; | 1307 | int colModulo = wid % daysToShow; |
1316 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1308 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1317 | //qDebug("rowmod %d ", rowModulo); | 1309 | //qDebug("rowmod %d ", rowModulo); |
1318 | int i; | 1310 | int i; |
1319 | int x,y,w,h; | 1311 | int x,y,w,h; |
1320 | x= 0; | 1312 | x= 0; |
1321 | y= 0; | 1313 | y= 0; |
1322 | w = colWid; | 1314 | w = colWid; |
1323 | h = dayLabelHei ; | 1315 | h = dayLabelHei ; |
1324 | for ( i = 0; i < 7; i++) { | 1316 | for ( i = 0; i < 7; i++) { |
1325 | if ( i && !( i % daysToShow) && i < 6) { | 1317 | if ( i && !( i % daysToShow) && i < 6) { |
1326 | y += hei/(5-daysToShow); | 1318 | y += hei/(5-daysToShow); |
1327 | x = 0; | 1319 | x = 0; |
1328 | w = colWid; | 1320 | w = colWid; |
1329 | } | 1321 | } |
1330 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1322 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1331 | ++w; | 1323 | ++w; |
1332 | } | 1324 | } |
1333 | if ( i >= 5 ) { | 1325 | if ( i >= 5 ) { |
1334 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); | 1326 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); |
1335 | x -= (w/2 ); | 1327 | x -= (w/2 ); |
1336 | } | 1328 | } |
1337 | else | 1329 | else |
1338 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); | 1330 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); |
1339 | x += w; | 1331 | x += w; |
1340 | } | 1332 | } |
1341 | x= 0; | 1333 | x= 0; |
1342 | y= dayLabelHei; | 1334 | y= dayLabelHei; |
1343 | w = colWid; | 1335 | w = colWid; |
1344 | h = cellHei; | 1336 | h = cellHei; |
1345 | for ( i = 0; i < mCellsW.count(); ++i) { | 1337 | for ( i = 0; i < mCellsW.count(); ++i) { |
1346 | if ( i > 6 ) { | 1338 | if ( i > 6 ) { |
1347 | mCellsW[i]->hide(); | 1339 | mCellsW[i]->hide(); |
1348 | continue; | 1340 | continue; |
1349 | } | 1341 | } |
1350 | 1342 | ||
1351 | w = colWid; | 1343 | w = colWid; |
1352 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1344 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1353 | ++w; | 1345 | ++w; |
1354 | } | 1346 | } |
1355 | if ( i == (daysToShow-1-rowModulo)*7) | 1347 | if ( i == (daysToShow-1-rowModulo)*7) |
1356 | ++h; | 1348 | ++h; |
1357 | 1349 | ||
1358 | if ( i >= 5 ) { | 1350 | if ( i >= 5 ) { |
1359 | if ( i ==5 ) { | 1351 | if ( i ==5 ) { |
1360 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1352 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1361 | x -= w ;y += h/2; | 1353 | x -= w ;y += h/2; |
1362 | } else { | 1354 | } else { |
1363 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1355 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1364 | ++w; | 1356 | ++w; |
1365 | } | 1357 | } |
1366 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1358 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1367 | y -= h/2; | 1359 | y -= h/2; |
1368 | } | 1360 | } |
1369 | } else | 1361 | } else |
1370 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1362 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1371 | 1363 | ||
1372 | 1364 | ||
1373 | x += w; | 1365 | x += w; |
1374 | if ( x + w/2 > wid ) { | 1366 | if ( x + w/2 > wid ) { |
1375 | x = 0; | 1367 | x = 0; |
1376 | y += h+dayLabelHei ; | 1368 | y += h+dayLabelHei ; |
1377 | } | 1369 | } |
1378 | } | 1370 | } |
1379 | y= dayLabelHei; | 1371 | y= dayLabelHei; |
1380 | h = cellHei ; | 1372 | h = cellHei ; |
1381 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1373 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1382 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1374 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1383 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1375 | |
1384 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | ||
1385 | mShortDayLabelsW = mDayLabelsW[0]->width() < mWidthLongDayLabel ; | 1376 | mShortDayLabelsW = mDayLabelsW[0]->width() < mWidthLongDayLabel ; |
1386 | updateDayLabels(); | 1377 | updateDayLabels(); |
1387 | bool forceUpdate = !updatePossible; | 1378 | bool forceUpdate = !updatePossible; |
1388 | updatePossible = true; | 1379 | updatePossible = true; |
1389 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1380 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1390 | if ( forceUpdate ) | 1381 | if ( forceUpdate ) |
1391 | updateView(); | 1382 | updateView(); |
1392 | } | 1383 | } |
1393 | void KOMonthView::computeLayout() | 1384 | void KOMonthView::computeLayout() |
1394 | { | 1385 | { |
1395 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 1386 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
1396 | // note this only changes the text if the requested size crosses the | 1387 | // note this only changes the text if the requested size crosses the |
1397 | // threshold between big enough to support the full name and not big | 1388 | // threshold between big enough to support the full name and not big |
1398 | // enough. | 1389 | // enough. |
1390 | |||
1391 | int tWid = topLevelWidget()->size().width(); | ||
1392 | int tHei = topLevelWidget()->size().height(); | ||
1393 | |||
1394 | int wid = size().width();//e | ||
1395 | int hei = size().height()-1; | ||
1396 | |||
1397 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | ||
1398 | return; | ||
1399 | |||
1400 | |||
1399 | if ( mShowWeekView ){ | 1401 | if ( mShowWeekView ){ |
1400 | computeLayoutWeek(); | 1402 | computeLayoutWeek(); |
1401 | return; | 1403 | return; |
1402 | } | 1404 | } |
1405 | static int widd = 0; | ||
1406 | static int heigg = 0; | ||
1407 | if ( widd == width() && heigg == height () ) { | ||
1408 | return; | ||
1409 | } | ||
1410 | widd = width() ; | ||
1411 | heigg = height (); | ||
1412 | |||
1403 | int daysToShow = 7; | 1413 | int daysToShow = 7; |
1404 | bool combinedSatSun = false; | 1414 | bool combinedSatSun = false; |
1405 | if (KOPrefs::instance()->mMonthViewSatSunTog ) { | 1415 | if (KOPrefs::instance()->mMonthViewSatSunTog ) { |
1406 | daysToShow = 6; | 1416 | daysToShow = 6; |
1407 | combinedSatSun = true; | 1417 | combinedSatSun = true; |
1408 | } | 1418 | } |
1409 | int tWid = topLevelWidget()->size().width(); | ||
1410 | int tHei = topLevelWidget()->size().height(); | ||
1411 | |||
1412 | int wid = size().width();//e | ||
1413 | int hei = size().height()-1; | ||
1414 | |||
1415 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | ||
1416 | return; | ||
1417 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | ||
1418 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1419 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1419 | int weeklabelwid = fm.width( "888" ); | 1420 | int weeklabelwid = fm.width( "888" ); |
1420 | wid -= weeklabelwid; | 1421 | wid -= weeklabelwid; |
1421 | 1422 | ||
1422 | int colWid = wid / daysToShow; | 1423 | int colWid = wid / daysToShow; |
1423 | int lastCol = wid - ( colWid*6 ); | 1424 | int lastCol = wid - ( colWid*6 ); |
1424 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1425 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1425 | int cellHei = (hei - dayLabelHei) /6; | 1426 | int cellHei = (hei - dayLabelHei) /6; |
1426 | int colModulo = wid % daysToShow; | 1427 | int colModulo = wid % daysToShow; |
1427 | int rowModulo = (hei- dayLabelHei) % 6; | 1428 | int rowModulo = (hei- dayLabelHei) % 6; |
1428 | //qDebug("rowmod %d ", rowModulo); | 1429 | //qDebug("rowmod %d ", rowModulo); |
1429 | int i; | 1430 | int i; |
1430 | int x,y,w,h; | 1431 | int x,y,w,h; |
1431 | x= 0; | 1432 | x= 0; |
1432 | y= 0; | 1433 | y= 0; |
1433 | w = colWid; | 1434 | w = colWid; |
1434 | h = dayLabelHei ; | 1435 | h = dayLabelHei ; |
1435 | for ( i = 0; i < 7; i++) { | 1436 | for ( i = 0; i < 7; i++) { |
1436 | if ( i == daysToShow-colModulo ) | 1437 | if ( i == daysToShow-colModulo ) |
1437 | ++w; | 1438 | ++w; |
1438 | if ( combinedSatSun ) { | 1439 | if ( combinedSatSun ) { |
1439 | if ( i >= daysToShow-1 ) { | 1440 | if ( i >= daysToShow-1 ) { |
1440 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1441 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1441 | x -= w/2 ; | 1442 | x -= w/2 ; |
1442 | } | 1443 | } |
1443 | else | 1444 | else |
1444 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1445 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1445 | } else | 1446 | } else |
1446 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1447 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1447 | x += w; | 1448 | x += w; |
1448 | } | 1449 | } |
1449 | x= 0; | 1450 | x= 0; |
1450 | y= dayLabelHei; | 1451 | y= dayLabelHei; |
1451 | w = colWid; | 1452 | w = colWid; |
1452 | h = cellHei ; | 1453 | h = cellHei ; |
1453 | for ( i = 0; i < mCells.count(); ++i) { | 1454 | for ( i = 0; i < mCells.count(); ++i) { |
1454 | w = colWid; | 1455 | w = colWid; |
1455 | if ( ((i) % 7) >= 7-colModulo ) { | 1456 | if ( ((i) % 7) >= 7-colModulo ) { |
1456 | ++w; | 1457 | ++w; |
1457 | } | 1458 | } |
1458 | if ( i == (6-rowModulo)*7) | 1459 | if ( i == (6-rowModulo)*7) |
1459 | ++h; | 1460 | ++h; |
1460 | if ( combinedSatSun ) { | 1461 | if ( combinedSatSun ) { |
1461 | if ( (i)%7 >= daysToShow-1 ) { | 1462 | if ( (i)%7 >= daysToShow-1 ) { |
1462 | if ( (i)%7 == daysToShow-1 ) { | 1463 | if ( (i)%7 == daysToShow-1 ) { |
1463 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1464 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1464 | x -= w ;y += h/2; | 1465 | x -= w ;y += h/2; |
1465 | } else { | 1466 | } else { |
1466 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1467 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1467 | y -= h/2; | 1468 | y -= h/2; |
1468 | } | 1469 | } |
1469 | } else | 1470 | } else |
1470 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1471 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1471 | 1472 | ||
1472 | } | 1473 | } |
1473 | else | 1474 | else |
1474 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1475 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1475 | x += w; | 1476 | x += w; |
1476 | if ( x + w/2 > wid ) { | 1477 | if ( x + w/2 > wid ) { |
1477 | x = 0; | 1478 | x = 0; |
1478 | y += h; | 1479 | y += h; |
1479 | } | 1480 | } |
1480 | } | 1481 | } |
1481 | y= dayLabelHei; | 1482 | y= dayLabelHei; |
1482 | h = cellHei ; | 1483 | h = cellHei ; |
1483 | for ( i = 0; i < 6; i++) { | 1484 | for ( i = 0; i < 6; i++) { |
1484 | if ( i == (6-rowModulo)) | 1485 | if ( i == (6-rowModulo)) |
1485 | ++h; | 1486 | ++h; |
1486 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1487 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1487 | y += h; | 1488 | y += h; |
1488 | } | 1489 | } |
1489 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1490 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1490 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | ||
1491 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | ||
1492 | mShortDayLabelsM = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1491 | mShortDayLabelsM = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1493 | qDebug("dlwid %d %d ",mDayLabels[0]->width() , mWidthLongDayLabel); | 1492 | qDebug("dlwid %d %d ",mDayLabels[0]->width() , mWidthLongDayLabel); |
1494 | updateDayLabels(); | 1493 | updateDayLabels(); |
1495 | bool forceUpdate = !updatePossible; | 1494 | bool forceUpdate = !updatePossible; |
1496 | updatePossible = true; | 1495 | updatePossible = true; |
1497 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | ||
1498 | if ( forceUpdate ) | 1496 | if ( forceUpdate ) |
1499 | updateView(); | 1497 | updateView(); |
1500 | } | 1498 | } |
1501 | 1499 | ||
1502 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1500 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1503 | { | 1501 | { |
1504 | mContextMenu->showIncidencePopup(incidence); | 1502 | mContextMenu->showIncidencePopup(incidence); |
1505 | /* | 1503 | |
1506 | if( incidence && incidence->type() == "Event" ) { | ||
1507 | Event *event = static_cast<Event *>(incidence); | ||
1508 | mContextMenu->showEventPopup(event); | ||
1509 | } else { | ||
1510 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | ||
1511 | } | ||
1512 | */ | ||
1513 | } | 1504 | } |
1514 | MonthViewCell * KOMonthView::selectedCell( ) | 1505 | MonthViewCell * KOMonthView::selectedCell( ) |
1515 | { | 1506 | { |
1516 | return mSelectedCell; | 1507 | return mSelectedCell; |
1517 | } | 1508 | } |
1518 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1509 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1519 | { | 1510 | { |
1520 | //qDebug("KOMonthView::setSelectedCell %x ", cell); | ||
1521 | if ( mSelectedCell && mSelectedCell != cell ) { | 1511 | if ( mSelectedCell && mSelectedCell != cell ) { |
1522 | MonthViewCell * mvc = mSelectedCell; | 1512 | MonthViewCell * mvc = mSelectedCell; |
1523 | mSelectedCell = cell; | 1513 | mSelectedCell = cell; |
1524 | mvc->deselect(); | 1514 | mvc->deselect(); |
1525 | } else | 1515 | } else |
1526 | mSelectedCell = cell; | 1516 | mSelectedCell = cell; |
1527 | // if ( mSelectedCell ) | ||
1528 | // mSelectedCell->select(); | ||
1529 | if ( !mSelectedCell ) | 1517 | if ( !mSelectedCell ) |
1530 | emit incidenceSelected( 0 ); | 1518 | emit incidenceSelected( 0 ); |
1531 | else | 1519 | else |
1532 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1520 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1533 | } | 1521 | } |
1534 | 1522 | ||
1535 | void KOMonthView::processSelectionChange() | 1523 | void KOMonthView::processSelectionChange() |
1536 | { | 1524 | { |
1537 | QPtrList<Incidence> incidences = selectedIncidences(); | 1525 | QPtrList<Incidence> incidences = selectedIncidences(); |
1538 | if (incidences.count() > 0) { | 1526 | if (incidences.count() > 0) { |
1539 | emit incidenceSelected( incidences.first() ); | 1527 | emit incidenceSelected( incidences.first() ); |
1540 | } else { | 1528 | } else { |
1541 | emit incidenceSelected( 0 ); | 1529 | emit incidenceSelected( 0 ); |
1542 | } | 1530 | } |
1543 | } | 1531 | } |
1544 | 1532 | ||
1545 | void KOMonthView::clearSelection() | 1533 | void KOMonthView::clearSelection() |
1546 | { | 1534 | { |
1547 | if ( mSelectedCell ) { | 1535 | if ( mSelectedCell ) { |
1548 | mSelectedCell->deselect(); | 1536 | mSelectedCell->deselect(); |
1549 | mSelectedCell = 0; | 1537 | mSelectedCell = 0; |
1550 | } | 1538 | } |
1551 | } | 1539 | } |
1552 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1540 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1553 | { | 1541 | { |
1554 | //qDebug("KOMonthView::keyPressEvent "); | 1542 | //qDebug("KOMonthView::keyPressEvent "); |
1555 | switch(e->key()) { | 1543 | switch(e->key()) { |
1556 | case Key_Up: | 1544 | case Key_Up: |
1557 | { | 1545 | { |
1558 | emit prevMonth(); | 1546 | emit prevMonth(); |
1559 | if ( mShowWeekView ) | 1547 | if ( mShowWeekView ) |
1560 | mCellsW[0]->setFocus(); | 1548 | mCellsW[0]->setFocus(); |
1561 | else | 1549 | else |
1562 | mCells[0]->setFocus(); | 1550 | mCells[0]->setFocus(); |
1563 | } | 1551 | } |
1564 | e->accept(); | 1552 | e->accept(); |
1565 | break; | 1553 | break; |
1566 | case Key_Down: | 1554 | case Key_Down: |
1567 | { | 1555 | { |
1568 | emit nextMonth(); | 1556 | emit nextMonth(); |
1569 | if ( mShowWeekView ) | 1557 | if ( mShowWeekView ) |
1570 | mCellsW[0]->setFocus(); | 1558 | mCellsW[0]->setFocus(); |
1571 | else | 1559 | else |
1572 | mCells[0]->setFocus(); | 1560 | mCells[0]->setFocus(); |
1573 | 1561 | ||
1574 | } | 1562 | } |
1575 | e->accept(); | 1563 | e->accept(); |
1576 | break; | 1564 | break; |