author | zautrix <zautrix> | 2005-02-13 19:07:45 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-13 19:07:45 (UTC) |
commit | 7bd83e913399b8be68a7d37e8f02118ec9eab90e (patch) (unidiff) | |
tree | 284d1592687ea4d3e0c220fafd289a702718dee4 /korganizer/koagendaview.cpp | |
parent | 293271fe9e6a9061da329183f8f488d79580f7da (diff) | |
download | kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.zip kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.gz kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.bz2 |
todo fixi
-rw-r--r-- | korganizer/koagendaview.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 13d8398..4ff6899 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -906,374 +906,387 @@ void KOAgendaView::updateConfig() | |||
906 | mAgenda->storePosition(); | 906 | mAgenda->storePosition(); |
907 | mAgenda->updateConfig(); | 907 | mAgenda->updateConfig(); |
908 | mAllDayAgenda->updateConfig(); | 908 | mAllDayAgenda->updateConfig(); |
909 | // widget synchronization | 909 | // widget synchronization |
910 | //TODO: find a better way, maybe signal/slot | 910 | //TODO: find a better way, maybe signal/slot |
911 | mTimeLabels->positionChanged(); | 911 | mTimeLabels->positionChanged(); |
912 | 912 | ||
913 | // for some reason, this needs to be called explicitly | 913 | // for some reason, this needs to be called explicitly |
914 | mTimeLabels->repaint(); | 914 | mTimeLabels->repaint(); |
915 | 915 | ||
916 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 916 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
917 | 917 | ||
918 | // ToolTips displaying summary of events | 918 | // ToolTips displaying summary of events |
919 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 919 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
920 | ->mEnableToolTips); | 920 | ->mEnableToolTips); |
921 | 921 | ||
922 | //setHolidayMasks(); | 922 | //setHolidayMasks(); |
923 | 923 | ||
924 | //createDayLabels(); called by via updateView(); | 924 | //createDayLabels(); called by via updateView(); |
925 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 925 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
926 | updateView(); | 926 | updateView(); |
927 | mAgenda->restorePosition(); | 927 | mAgenda->restorePosition(); |
928 | } | 928 | } |
929 | 929 | ||
930 | 930 | ||
931 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 931 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
932 | { | 932 | { |
933 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 933 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
934 | //qDebug("KOAgendaView::updateEventDates "); | 934 | //qDebug("KOAgendaView::updateEventDates "); |
935 | QDateTime startDt,endDt; | 935 | QDateTime startDt,endDt; |
936 | QDate startDate; | 936 | QDate startDate; |
937 | int lenInSecs; | 937 | int lenInSecs; |
938 | // if ( type == KOAgenda::RESIZETOP ) | 938 | // if ( type == KOAgenda::RESIZETOP ) |
939 | // qDebug("RESIZETOP "); | 939 | // qDebug("RESIZETOP "); |
940 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 940 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
941 | // qDebug("RESIZEBOTTOM "); | 941 | // qDebug("RESIZEBOTTOM "); |
942 | // if ( type == KOAgenda::MOVE ) | 942 | // if ( type == KOAgenda::MOVE ) |
943 | // qDebug("MOVE "); | 943 | // qDebug("MOVE "); |
944 | if ( item->incidence()->type() == "Event" ) { | 944 | if ( item->incidence()->type() == "Event" ) { |
945 | startDt =item->incidence()->dtStart(); | 945 | startDt =item->incidence()->dtStart(); |
946 | endDt = item->incidence()->dtEnd(); | 946 | endDt = item->incidence()->dtEnd(); |
947 | lenInSecs = startDt.secsTo( endDt ); | 947 | lenInSecs = startDt.secsTo( endDt ); |
948 | } | 948 | } |
949 | 949 | ||
950 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 950 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
951 | 951 | ||
952 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 952 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
953 | startDate = mSelectedDates[item->mLastMoveXPos]; | 953 | startDate = mSelectedDates[item->mLastMoveXPos]; |
954 | } else { | 954 | } else { |
955 | if (item->cellX() < 0) { | 955 | if (item->cellX() < 0) { |
956 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 956 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
957 | } else { | 957 | } else { |
958 | startDate = mSelectedDates[item->cellX()]; | 958 | startDate = mSelectedDates[item->cellX()]; |
959 | } | 959 | } |
960 | } | 960 | } |
961 | startDt.setDate(startDate); | 961 | startDt.setDate(startDate); |
962 | 962 | ||
963 | if (item->incidence()->doesFloat()) { | 963 | if (item->incidence()->doesFloat()) { |
964 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 964 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
965 | } else { | 965 | } else { |
966 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 966 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
967 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 967 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
968 | if ( item->incidence()->type() == "Event" ) { | 968 | if ( item->incidence()->type() == "Event" ) { |
969 | if ( type == KOAgenda::MOVE ) { | 969 | if ( type == KOAgenda::MOVE ) { |
970 | endDt = startDt.addSecs(lenInSecs); | 970 | endDt = startDt.addSecs(lenInSecs); |
971 | 971 | ||
972 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 972 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
973 | if (item->lastMultiItem()) { | 973 | if (item->lastMultiItem()) { |
974 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 974 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
975 | endDt.setDate(startDate. | 975 | endDt.setDate(startDate. |
976 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 976 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
977 | } else { | 977 | } else { |
978 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 978 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
979 | endDt.setDate(startDate); | 979 | endDt.setDate(startDate); |
980 | } | 980 | } |
981 | } | 981 | } |
982 | } else { | 982 | } else { |
983 | // todo | 983 | // todo |
984 | if (item->lastMultiItem()) { | 984 | if (item->lastMultiItem()) { |
985 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 985 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
986 | endDt.setDate(startDate. | 986 | endDt.setDate(startDate. |
987 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 987 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
988 | } else { | 988 | } else { |
989 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 989 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
990 | if ( item->cellYBottom() > 0 ) | 990 | if ( item->cellYBottom() > 0 ) |
991 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 991 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
992 | else | 992 | else |
993 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 993 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
994 | endDt.setDate(startDate); | 994 | endDt.setDate(startDate); |
995 | } | 995 | } |
996 | } | 996 | } |
997 | } | 997 | } |
998 | if ( item->incidence()->type() == "Event" ) { | 998 | if ( item->incidence()->type() == "Event" ) { |
999 | item->incidence()->setDtStart(startDt); | 999 | item->incidence()->setDtStart(startDt); |
1000 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1000 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1001 | } else if ( item->incidence()->type() == "Todo" ) { | 1001 | } else if ( item->incidence()->type() == "Todo" ) { |
1002 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); | 1002 | Todo* to = static_cast<Todo*>(item->incidence()); |
1003 | |||
1004 | int len = 0; | ||
1005 | if ( to->hasStartDate() && to->hasDueDate() ) | ||
1006 | len = to->dtStart().secsTo( to->dtDue()); | ||
1007 | to->setDtDue(endDt); | ||
1008 | if ( to->hasStartDate() ) { | ||
1009 | if ( len>0 ) | ||
1010 | to->setDtStart(to->dtDue().addSecs( -len )); | ||
1011 | else | ||
1012 | if (to->dtStart() > to->dtDue() ) | ||
1013 | to->setDtStart(to->dtDue().addDays( -3 )); | ||
1014 | } | ||
1015 | |||
1003 | } | 1016 | } |
1004 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1017 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1005 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1018 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1006 | item->setItemDate(startDt.date()); | 1019 | item->setItemDate(startDt.date()); |
1007 | //item->updateItem(); | 1020 | //item->updateItem(); |
1008 | if ( item->incidence()->type() == "Todo" ) { | 1021 | if ( item->incidence()->type() == "Todo" ) { |
1009 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1022 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1010 | 1023 | ||
1011 | } | 1024 | } |
1012 | else | 1025 | else |
1013 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1026 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1014 | item->updateItem(); | 1027 | item->updateItem(); |
1015 | } | 1028 | } |
1016 | 1029 | ||
1017 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1030 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1018 | { | 1031 | { |
1019 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1032 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1020 | 1033 | ||
1021 | mSelectedDates.clear(); | 1034 | mSelectedDates.clear(); |
1022 | // qDebug("KOAgendaView::showDates "); | 1035 | // qDebug("KOAgendaView::showDates "); |
1023 | QDate d = start; | 1036 | QDate d = start; |
1024 | while (d <= end) { | 1037 | while (d <= end) { |
1025 | mSelectedDates.append(d); | 1038 | mSelectedDates.append(d); |
1026 | d = d.addDays( 1 ); | 1039 | d = d.addDays( 1 ); |
1027 | } | 1040 | } |
1028 | 1041 | ||
1029 | // and update the view | 1042 | // and update the view |
1030 | fillAgenda(); | 1043 | fillAgenda(); |
1031 | } | 1044 | } |
1032 | 1045 | ||
1033 | 1046 | ||
1034 | void KOAgendaView::showEvents(QPtrList<Event>) | 1047 | void KOAgendaView::showEvents(QPtrList<Event>) |
1035 | { | 1048 | { |
1036 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1049 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1037 | } | 1050 | } |
1038 | 1051 | ||
1039 | void KOAgendaView::changeEventDisplay(Event *, int) | 1052 | void KOAgendaView::changeEventDisplay(Event *, int) |
1040 | { | 1053 | { |
1041 | // qDebug("KOAgendaView::changeEventDisplay "); | 1054 | // qDebug("KOAgendaView::changeEventDisplay "); |
1042 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1055 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1043 | // this should be re-written to be MUCH smarter. Right now we | 1056 | // this should be re-written to be MUCH smarter. Right now we |
1044 | // are just playing dumb. | 1057 | // are just playing dumb. |
1045 | fillAgenda(); | 1058 | fillAgenda(); |
1046 | } | 1059 | } |
1047 | 1060 | ||
1048 | void KOAgendaView::fillAgenda(const QDate &) | 1061 | void KOAgendaView::fillAgenda(const QDate &) |
1049 | { | 1062 | { |
1050 | // qDebug("KOAgendaView::fillAgenda "); | 1063 | // qDebug("KOAgendaView::fillAgenda "); |
1051 | fillAgenda(); | 1064 | fillAgenda(); |
1052 | } | 1065 | } |
1053 | 1066 | ||
1054 | void KOAgendaView::fillAgenda() | 1067 | void KOAgendaView::fillAgenda() |
1055 | { | 1068 | { |
1056 | if ( globalFlagBlockStartup ) | 1069 | if ( globalFlagBlockStartup ) |
1057 | return; | 1070 | return; |
1058 | if ( globalFlagBlockAgenda == 1 ) | 1071 | if ( globalFlagBlockAgenda == 1 ) |
1059 | return; | 1072 | return; |
1060 | //if ( globalFlagBlockAgenda == 2 ) | 1073 | //if ( globalFlagBlockAgenda == 2 ) |
1061 | //globalFlagBlockAgenda = 0; | 1074 | //globalFlagBlockAgenda = 0; |
1062 | // globalFlagBlockPainting = false; | 1075 | // globalFlagBlockPainting = false; |
1063 | if ( globalFlagBlockAgenda == 0 ) | 1076 | if ( globalFlagBlockAgenda == 0 ) |
1064 | globalFlagBlockAgenda = 1; | 1077 | globalFlagBlockAgenda = 1; |
1065 | // clearView(); | 1078 | // clearView(); |
1066 | //qDebug("fillAgenda()++++ "); | 1079 | //qDebug("fillAgenda()++++ "); |
1067 | globalFlagBlockAgendaItemPaint = 1; | 1080 | globalFlagBlockAgendaItemPaint = 1; |
1068 | 1081 | ||
1069 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1082 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1070 | mAgenda->changeColumns(mSelectedDates.count()); | 1083 | mAgenda->changeColumns(mSelectedDates.count()); |
1071 | qApp->processEvents(); | 1084 | qApp->processEvents(); |
1072 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1085 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1073 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1086 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1074 | setHolidayMasks(); | 1087 | setHolidayMasks(); |
1075 | 1088 | ||
1076 | //mAgenda->hideUnused(); | 1089 | //mAgenda->hideUnused(); |
1077 | //mAllDayAgenda->hideUnused(); | 1090 | //mAllDayAgenda->hideUnused(); |
1078 | 1091 | ||
1079 | // mAgenda->blockNextRepaint( false ); | 1092 | // mAgenda->blockNextRepaint( false ); |
1080 | // mAgenda->viewport()->repaint(); | 1093 | // mAgenda->viewport()->repaint(); |
1081 | // mAgenda->blockNextRepaint( true ); | 1094 | // mAgenda->blockNextRepaint( true ); |
1082 | mMinY.resize(mSelectedDates.count()); | 1095 | mMinY.resize(mSelectedDates.count()); |
1083 | mMaxY.resize(mSelectedDates.count()); | 1096 | mMaxY.resize(mSelectedDates.count()); |
1084 | 1097 | ||
1085 | QPtrList<Event> dayEvents; | 1098 | QPtrList<Event> dayEvents; |
1086 | 1099 | ||
1087 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1100 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1088 | // Therefore, gtodoset all of them. | 1101 | // Therefore, gtodoset all of them. |
1089 | QPtrList<Todo> todos = calendar()->todos(); | 1102 | QPtrList<Todo> todos = calendar()->todos(); |
1090 | 1103 | ||
1091 | mAgenda->setDateList(mSelectedDates); | 1104 | mAgenda->setDateList(mSelectedDates); |
1092 | 1105 | ||
1093 | QDate today = QDate::currentDate(); | 1106 | QDate today = QDate::currentDate(); |
1094 | 1107 | ||
1095 | DateList::ConstIterator dit; | 1108 | DateList::ConstIterator dit; |
1096 | int curCol = 0; | 1109 | int curCol = 0; |
1097 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1110 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1098 | QDate currentDate = *dit; | 1111 | QDate currentDate = *dit; |
1099 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1112 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1100 | // << endl; | 1113 | // << endl; |
1101 | 1114 | ||
1102 | dayEvents = calendar()->events(currentDate,true); | 1115 | dayEvents = calendar()->events(currentDate,true); |
1103 | 1116 | ||
1104 | // Default values, which can never be reached | 1117 | // Default values, which can never be reached |
1105 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1118 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1106 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1119 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1107 | 1120 | ||
1108 | unsigned int numEvent; | 1121 | unsigned int numEvent; |
1109 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1122 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1110 | Event *event = dayEvents.at(numEvent); | 1123 | Event *event = dayEvents.at(numEvent); |
1111 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1124 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1112 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1125 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1113 | continue; | 1126 | continue; |
1114 | // kdDebug() << " Event: " << event->summary() << endl; | 1127 | // kdDebug() << " Event: " << event->summary() << endl; |
1115 | 1128 | ||
1116 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1129 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1117 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1130 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1118 | 1131 | ||
1119 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1132 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1120 | 1133 | ||
1121 | if (event->doesFloat()) { | 1134 | if (event->doesFloat()) { |
1122 | if (event->recurrence()->doesRecur()) { | 1135 | if (event->recurrence()->doesRecur()) { |
1123 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1136 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1124 | } else { | 1137 | } else { |
1125 | if (beginX <= 0 && curCol == 0) { | 1138 | if (beginX <= 0 && curCol == 0) { |
1126 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1139 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1127 | } else if (beginX == curCol) { | 1140 | } else if (beginX == curCol) { |
1128 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1141 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1129 | } | 1142 | } |
1130 | } | 1143 | } |
1131 | } else if (event->isMultiDay()) { | 1144 | } else if (event->isMultiDay()) { |
1132 | if ( event->doesRecur () ) { | 1145 | if ( event->doesRecur () ) { |
1133 | QDate dateit = currentDate; | 1146 | QDate dateit = currentDate; |
1134 | int count = 0; | 1147 | int count = 0; |
1135 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1148 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1136 | while (! event->recursOn( dateit ) && count <= max ) { | 1149 | while (! event->recursOn( dateit ) && count <= max ) { |
1137 | ++count; | 1150 | ++count; |
1138 | dateit = dateit.addDays( -1 ); | 1151 | dateit = dateit.addDays( -1 ); |
1139 | } | 1152 | } |
1140 | bool ok; | 1153 | bool ok; |
1141 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1154 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1142 | if ( ok ) | 1155 | if ( ok ) |
1143 | { | 1156 | { |
1144 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1157 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1145 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1158 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1146 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1159 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1147 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1160 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1148 | 1161 | ||
1149 | } | 1162 | } |
1150 | } | 1163 | } |
1151 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1164 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1152 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1165 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1153 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1166 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1154 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1167 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1155 | //qDebug("insert!!! "); | 1168 | //qDebug("insert!!! "); |
1156 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1169 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1157 | } | 1170 | } |
1158 | if (beginX == curCol) { | 1171 | if (beginX == curCol) { |
1159 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1172 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1160 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1173 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1161 | } else if (endX == curCol) { | 1174 | } else if (endX == curCol) { |
1162 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1175 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1163 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1176 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1164 | } else { | 1177 | } else { |
1165 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1178 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1166 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1179 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1167 | } | 1180 | } |
1168 | } else { | 1181 | } else { |
1169 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1182 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1170 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1183 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1171 | if (endY < startY) endY = startY; | 1184 | if (endY < startY) endY = startY; |
1172 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1185 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1173 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1186 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1174 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1187 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1175 | } | 1188 | } |
1176 | } | 1189 | } |
1177 | // ---------- [display Todos -------------- | 1190 | // ---------- [display Todos -------------- |
1178 | unsigned int numTodo; | 1191 | unsigned int numTodo; |
1179 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1192 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1180 | Todo *todo = todos.at(numTodo); | 1193 | Todo *todo = todos.at(numTodo); |
1181 | 1194 | ||
1182 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1195 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1183 | 1196 | ||
1184 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1197 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1185 | // Already completed items can be displayed on their original due date | 1198 | // Already completed items can be displayed on their original due date |
1186 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1199 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1187 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1200 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1188 | bool fillIn = false; | 1201 | bool fillIn = false; |
1189 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1202 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1190 | fillIn = true; | 1203 | fillIn = true; |
1191 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1204 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1192 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1205 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1193 | if ( fillIn ) { | 1206 | if ( fillIn ) { |
1194 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1207 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1195 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1208 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1196 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1209 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1197 | } | 1210 | } |
1198 | else { | 1211 | else { |
1199 | QDateTime dt; | 1212 | QDateTime dt; |
1200 | if ( todo->hasCompletedDate() ) | 1213 | if ( todo->hasCompletedDate() ) |
1201 | dt = todo->completed(); | 1214 | dt = todo->completed(); |
1202 | else | 1215 | else |
1203 | dt = todo->dtDue();; | 1216 | dt = todo->dtDue();; |
1204 | 1217 | ||
1205 | 1218 | ||
1206 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1219 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1207 | int hi = (18/KOPrefs::instance()->mHourSize); | 1220 | int hi = (18/KOPrefs::instance()->mHourSize); |
1208 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1221 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1209 | int startY = endY -hi; | 1222 | int startY = endY -hi; |
1210 | 1223 | ||
1211 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1224 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1212 | 1225 | ||
1213 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1226 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1214 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1227 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1215 | } | 1228 | } |
1216 | } | 1229 | } |
1217 | } | 1230 | } |
1218 | // ---------- display Todos] -------------- | 1231 | // ---------- display Todos] -------------- |
1219 | 1232 | ||
1220 | ++curCol; | 1233 | ++curCol; |
1221 | } | 1234 | } |
1222 | mAgenda->hideUnused(); | 1235 | mAgenda->hideUnused(); |
1223 | mAllDayAgenda->hideUnused(); | 1236 | mAllDayAgenda->hideUnused(); |
1224 | mAgenda->checkScrollBoundaries(); | 1237 | mAgenda->checkScrollBoundaries(); |
1225 | 1238 | ||
1226 | deleteSelectedDateTime(); | 1239 | deleteSelectedDateTime(); |
1227 | 1240 | ||
1228 | createDayLabels(); | 1241 | createDayLabels(); |
1229 | emit incidenceSelected( 0 ); | 1242 | emit incidenceSelected( 0 ); |
1230 | 1243 | ||
1231 | if ( globalFlagBlockAgenda == 2 ) { | 1244 | if ( globalFlagBlockAgenda == 2 ) { |
1232 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1245 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1233 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1246 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1234 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1247 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1235 | setStartHour( QTime::currentTime ().hour() ); | 1248 | setStartHour( QTime::currentTime ().hour() ); |
1236 | // qApp->processEvents(); | 1249 | // qApp->processEvents(); |
1237 | } | 1250 | } |
1238 | qApp->processEvents(); | 1251 | qApp->processEvents(); |
1239 | //qDebug("qApp->processEvents(); END "); | 1252 | //qDebug("qApp->processEvents(); END "); |
1240 | globalFlagBlockAgenda = 0; | 1253 | globalFlagBlockAgenda = 0; |
1241 | 1254 | ||
1242 | // mAgenda->hideUnused(); | 1255 | // mAgenda->hideUnused(); |
1243 | //mAllDayAgenda->hideUnused(); | 1256 | //mAllDayAgenda->hideUnused(); |
1244 | mAllDayAgenda->drawContentsToPainter(); | 1257 | mAllDayAgenda->drawContentsToPainter(); |
1245 | mAgenda->drawContentsToPainter(); | 1258 | mAgenda->drawContentsToPainter(); |
1246 | repaintAgenda(); | 1259 | repaintAgenda(); |
1247 | // mAgenda->finishUpdate(); | 1260 | // mAgenda->finishUpdate(); |
1248 | //mAllDayAgenda->finishUpdate(); | 1261 | //mAllDayAgenda->finishUpdate(); |
1249 | 1262 | ||
1250 | // repaintAgenda(); | 1263 | // repaintAgenda(); |
1251 | //qApp->processEvents(); | 1264 | //qApp->processEvents(); |
1252 | // globalFlagBlockAgenda = 0; | 1265 | // globalFlagBlockAgenda = 0; |
1253 | } | 1266 | } |
1254 | void KOAgendaView::repaintAgenda() | 1267 | void KOAgendaView::repaintAgenda() |
1255 | { | 1268 | { |
1256 | // mAllDayAgenda->drawContentsToPainter(); | 1269 | // mAllDayAgenda->drawContentsToPainter(); |
1257 | // mAllDayAgenda->viewport()->repaint( false ); | 1270 | // mAllDayAgenda->viewport()->repaint( false ); |
1258 | // mAgenda->drawContentsToPainter(); | 1271 | // mAgenda->drawContentsToPainter(); |
1259 | // mAgenda->viewport()->repaint( false ); | 1272 | // mAgenda->viewport()->repaint( false ); |
1260 | // qApp->processEvents(); | 1273 | // qApp->processEvents(); |
1261 | 1274 | ||
1262 | //qDebug("KOAgendaView::repaintAgenda() "); | 1275 | //qDebug("KOAgendaView::repaintAgenda() "); |
1263 | //qApp->processEvents(); | 1276 | //qApp->processEvents(); |
1264 | mAgenda->viewport()->repaint( false ); | 1277 | mAgenda->viewport()->repaint( false ); |
1265 | mAllDayAgenda->viewport()->repaint( false ); | 1278 | mAllDayAgenda->viewport()->repaint( false ); |
1266 | mAgenda->finishUpdate(); | 1279 | mAgenda->finishUpdate(); |
1267 | mAllDayAgenda->finishUpdate(); | 1280 | mAllDayAgenda->finishUpdate(); |
1268 | } | 1281 | } |
1269 | 1282 | ||
1270 | 1283 | ||
1271 | void KOAgendaView::clearView() | 1284 | void KOAgendaView::clearView() |
1272 | { | 1285 | { |
1273 | // kdDebug() << "ClearView" << endl; | 1286 | // kdDebug() << "ClearView" << endl; |
1274 | mAllDayAgenda->clear(); | 1287 | mAllDayAgenda->clear(); |
1275 | mAgenda->clear(); | 1288 | mAgenda->clear(); |
1276 | } | 1289 | } |
1277 | 1290 | ||
1278 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1291 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1279 | const QDate &td) | 1292 | const QDate &td) |