-rw-r--r-- | korganizer/koagendaview.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 131a345..a01323a 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -985,423 +985,438 @@ void KOAgendaView::updateConfig() | |||
985 | 985 | ||
986 | // ToolTips displaying summary of events | 986 | // ToolTips displaying summary of events |
987 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 987 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
988 | ->mEnableToolTips); | 988 | ->mEnableToolTips); |
989 | 989 | ||
990 | //setHolidayMasks(); | 990 | //setHolidayMasks(); |
991 | 991 | ||
992 | //createDayLabels(); called by via updateView(); | 992 | //createDayLabels(); called by via updateView(); |
993 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 993 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
994 | updateView(); | 994 | updateView(); |
995 | mAgenda->restorePosition(); | 995 | mAgenda->restorePosition(); |
996 | } | 996 | } |
997 | 997 | ||
998 | 998 | ||
999 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 999 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
1000 | { | 1000 | { |
1001 | 1001 | ||
1002 | 1002 | ||
1003 | int xxx = item->cellX(); | 1003 | int xxx = item->cellX(); |
1004 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); | 1004 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); |
1005 | if ( mMinY.at(xxx) > item->cellYTop() ) | 1005 | if ( mMinY.at(xxx) > item->cellYTop() ) |
1006 | mMinY.at(xxx) = item->cellYTop(); | 1006 | mMinY.at(xxx) = item->cellYTop(); |
1007 | if ( mMaxY.at(xxx) < item->cellYBottom() ) | 1007 | if ( mMaxY.at(xxx) < item->cellYBottom() ) |
1008 | mMaxY.at(xxx) = item->cellYBottom(); | 1008 | mMaxY.at(xxx) = item->cellYBottom(); |
1009 | 1009 | ||
1010 | QDateTime startDt,endDt; | 1010 | QDateTime startDt,endDt; |
1011 | QDate startDate; | 1011 | QDate startDate; |
1012 | int lenInSecs; | 1012 | int lenInSecs; |
1013 | // if ( type == KOAgenda::RESIZETOP ) | 1013 | // if ( type == KOAgenda::RESIZETOP ) |
1014 | // qDebug("RESIZETOP "); | 1014 | // qDebug("RESIZETOP "); |
1015 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 1015 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
1016 | // qDebug("RESIZEBOTTOM "); | 1016 | // qDebug("RESIZEBOTTOM "); |
1017 | // if ( type == KOAgenda::MOVE ) | 1017 | // if ( type == KOAgenda::MOVE ) |
1018 | // qDebug("MOVE "); | 1018 | // qDebug("MOVE "); |
1019 | if ( item->incidence()->typeID() == eventID ) { | 1019 | if ( item->incidence()->typeID() == eventID ) { |
1020 | startDt =item->incidence()->dtStart(); | 1020 | startDt =item->incidence()->dtStart(); |
1021 | endDt = item->incidence()->dtEnd(); | 1021 | endDt = item->incidence()->dtEnd(); |
1022 | lenInSecs = startDt.secsTo( endDt ); | 1022 | lenInSecs = startDt.secsTo( endDt ); |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 1025 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
1026 | 1026 | ||
1027 | if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { | 1027 | if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { |
1028 | startDate = mSelectedDates[item->mLastMoveXPos]; | 1028 | startDate = mSelectedDates[item->mLastMoveXPos]; |
1029 | } else { | 1029 | } else { |
1030 | if (item->cellX() < 0) { | 1030 | if (item->cellX() < 0) { |
1031 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 1031 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
1032 | } else { | 1032 | } else { |
1033 | startDate = mSelectedDates[item->cellX()]; | 1033 | startDate = mSelectedDates[item->cellX()]; |
1034 | } | 1034 | } |
1035 | } | 1035 | } |
1036 | startDt.setDate(startDate); | 1036 | startDt.setDate(startDate); |
1037 | 1037 | ||
1038 | if (item->incidence()->doesFloat()) { | 1038 | if (item->incidence()->doesFloat()) { |
1039 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 1039 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
1040 | } else { | 1040 | } else { |
1041 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 1041 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
1042 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 1042 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
1043 | if ( item->incidence()->typeID() == eventID ) { | 1043 | if ( item->incidence()->typeID() == eventID ) { |
1044 | if ( type == KOAgenda::MOVE ) { | 1044 | if ( type == KOAgenda::MOVE ) { |
1045 | endDt = startDt.addSecs(lenInSecs); | 1045 | endDt = startDt.addSecs(lenInSecs); |
1046 | 1046 | ||
1047 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 1047 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
1048 | if (item->lastMultiItem()) { | 1048 | if (item->lastMultiItem()) { |
1049 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1049 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1050 | endDt.setDate(startDate. | 1050 | endDt.setDate(startDate. |
1051 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1051 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1052 | } else { | 1052 | } else { |
1053 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1053 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1054 | endDt.setDate(startDate); | 1054 | endDt.setDate(startDate); |
1055 | } | 1055 | } |
1056 | } | 1056 | } |
1057 | } else { | 1057 | } else { |
1058 | // todo | 1058 | // todo |
1059 | if (item->lastMultiItem()) { | 1059 | if (item->lastMultiItem()) { |
1060 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1060 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1061 | endDt.setDate(startDate. | 1061 | endDt.setDate(startDate. |
1062 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1062 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1063 | } else { | 1063 | } else { |
1064 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 1064 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1065 | if ( item->cellYBottom() > 0 ) | 1065 | if ( item->cellYBottom() > 0 ) |
1066 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1066 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1067 | else | 1067 | else |
1068 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1068 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1069 | endDt.setDate(startDate); | 1069 | endDt.setDate(startDate); |
1070 | } | 1070 | } |
1071 | } | 1071 | } |
1072 | } | 1072 | } |
1073 | if ( item->incidence()->typeID() == eventID ) { | 1073 | if ( item->incidence()->typeID() == eventID ) { |
1074 | item->incidence()->setDtStart(startDt); | 1074 | item->incidence()->setDtStart(startDt); |
1075 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1075 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1076 | } else if ( item->incidence()->typeID() == todoID ) { | 1076 | } else if ( item->incidence()->typeID() == todoID ) { |
1077 | Todo* to = static_cast<Todo*>(item->incidence()); | 1077 | Todo* to = static_cast<Todo*>(item->incidence()); |
1078 | 1078 | ||
1079 | to->setDtDue(endDt); | 1079 | to->setDtDue(endDt); |
1080 | if ( to->hasStartDate() ) { | 1080 | if ( to->hasStartDate() ) { |
1081 | if (to->dtStart() >= to->dtDue() ) | 1081 | if (to->dtStart() >= to->dtDue() ) |
1082 | to->setDtStart(to->dtDue().addDays( -2 )); | 1082 | to->setDtStart(to->dtDue().addDays( -2 )); |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | } | 1085 | } |
1086 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1086 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1087 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1087 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1088 | item->setItemDate(startDt.date()); | 1088 | item->setItemDate(startDt.date()); |
1089 | //item->updateItem(); | 1089 | //item->updateItem(); |
1090 | if ( item->incidence()->typeID() == todoID ) { | 1090 | if ( item->incidence()->typeID() == todoID ) { |
1091 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1091 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1092 | 1092 | ||
1093 | } | 1093 | } |
1094 | else | 1094 | else |
1095 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1095 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1096 | item->updateItem(); | 1096 | item->updateItem(); |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1099 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1100 | { | 1100 | { |
1101 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1101 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1102 | 1102 | ||
1103 | mSelectedDates.clear(); | 1103 | mSelectedDates.clear(); |
1104 | // qDebug("KOAgendaView::showDates "); | 1104 | // qDebug("KOAgendaView::showDates "); |
1105 | QDate d = start; | 1105 | QDate d = start; |
1106 | while (d <= end) { | 1106 | while (d <= end) { |
1107 | mSelectedDates.append(d); | 1107 | mSelectedDates.append(d); |
1108 | d = d.addDays( 1 ); | 1108 | d = d.addDays( 1 ); |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | // and update the view | 1111 | // and update the view |
1112 | fillAgenda(); | 1112 | fillAgenda(); |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | 1115 | ||
1116 | void KOAgendaView::showEvents(QPtrList<Event>) | 1116 | void KOAgendaView::showEvents(QPtrList<Event>) |
1117 | { | 1117 | { |
1118 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1118 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | void KOAgendaView::changeEventDisplay(Event *, int) | 1121 | void KOAgendaView::changeEventDisplay(Event *, int) |
1122 | { | 1122 | { |
1123 | // qDebug("KOAgendaView::changeEventDisplay "); | 1123 | // qDebug("KOAgendaView::changeEventDisplay "); |
1124 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1124 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1125 | // this should be re-written to be MUCH smarter. Right now we | 1125 | // this should be re-written to be MUCH smarter. Right now we |
1126 | // are just playing dumb. | 1126 | // are just playing dumb. |
1127 | fillAgenda(); | 1127 | fillAgenda(); |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | void KOAgendaView::fillAgenda(const QDate &) | 1130 | void KOAgendaView::fillAgenda(const QDate &) |
1131 | { | 1131 | { |
1132 | // qDebug("KOAgendaView::fillAgenda "); | 1132 | // qDebug("KOAgendaView::fillAgenda "); |
1133 | fillAgenda(); | 1133 | fillAgenda(); |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | void KOAgendaView::fillAgenda() | 1136 | void KOAgendaView::fillAgenda() |
1137 | { | 1137 | { |
1138 | if ( globalFlagBlockStartup ) | 1138 | if ( globalFlagBlockStartup ) |
1139 | return; | 1139 | return; |
1140 | if ( globalFlagBlockAgenda == 1 ) | 1140 | if ( globalFlagBlockAgenda == 1 ) |
1141 | return; | 1141 | return; |
1142 | static bool onlyOne = false; | 1142 | static bool onlyOne = false; |
1143 | if ( onlyOne ) | 1143 | if ( onlyOne ) |
1144 | return; | 1144 | return; |
1145 | onlyOne = true; | 1145 | onlyOne = true; |
1146 | //if ( globalFlagBlockAgenda == 2 ) | 1146 | //if ( globalFlagBlockAgenda == 2 ) |
1147 | //globalFlagBlockAgenda = 0; | 1147 | //globalFlagBlockAgenda = 0; |
1148 | // globalFlagBlockPainting = false; | 1148 | // globalFlagBlockPainting = false; |
1149 | if ( globalFlagBlockAgenda == 0 ) | 1149 | if ( globalFlagBlockAgenda == 0 ) |
1150 | globalFlagBlockAgenda = 1; | 1150 | globalFlagBlockAgenda = 1; |
1151 | // clearView(); | 1151 | // clearView(); |
1152 | //qDebug("fillAgenda()++++ "); | 1152 | //qDebug("fillAgenda()++++ "); |
1153 | globalFlagBlockAgendaItemPaint = 1; | 1153 | globalFlagBlockAgendaItemPaint = 1; |
1154 | 1154 | ||
1155 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1155 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1156 | mAgenda->changeColumns(mSelectedDates.count()); | 1156 | mAgenda->changeColumns(mSelectedDates.count()); |
1157 | qApp->processEvents(); | 1157 | qApp->processEvents(); |
1158 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1158 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1159 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1159 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1160 | setHolidayMasks(); | 1160 | setHolidayMasks(); |
1161 | 1161 | ||
1162 | mMinY.resize(mSelectedDates.count()); | 1162 | mMinY.resize(mSelectedDates.count()); |
1163 | mMaxY.resize(mSelectedDates.count()); | 1163 | mMaxY.resize(mSelectedDates.count()); |
1164 | 1164 | ||
1165 | QPtrList<Event> dayEvents; | 1165 | QPtrList<Event> dayEvents; |
1166 | 1166 | ||
1167 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1167 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1168 | // Therefore, gtodoset all of them. | 1168 | // Therefore, gtodoset all of them. |
1169 | QPtrList<Todo> todos = calendar()->todos(); | 1169 | QPtrList<Todo> todos = calendar()->todos(); |
1170 | 1170 | ||
1171 | mAgenda->setDateList(mSelectedDates); | 1171 | mAgenda->setDateList(mSelectedDates); |
1172 | 1172 | ||
1173 | QDate today = QDate::currentDate(); | 1173 | QDate today = QDate::currentDate(); |
1174 | 1174 | ||
1175 | DateList::ConstIterator dit; | 1175 | DateList::ConstIterator dit; |
1176 | int curCol = 0; | 1176 | int curCol = 0; |
1177 | int maxCol = mSelectedDates.count()-1; | ||
1177 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1178 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1178 | QDate currentDate = *dit; | 1179 | QDate currentDate = *dit; |
1179 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1180 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1180 | // << endl; | 1181 | // << endl; |
1181 | 1182 | ||
1182 | dayEvents = calendar()->events(currentDate,false); | 1183 | dayEvents = calendar()->events(currentDate,false); |
1183 | 1184 | ||
1184 | // Default values, which can never be reached | 1185 | // Default values, which can never be reached |
1185 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1186 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1186 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1187 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1187 | 1188 | ||
1188 | unsigned int numEvent; | 1189 | unsigned int numEvent; |
1190 | //qDebug("+++++NUMEVENT %d", dayEvents.count()); | ||
1189 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1191 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1190 | Event *event = dayEvents.at(numEvent); | 1192 | Event *event = dayEvents.at(numEvent); |
1191 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1193 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1192 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1194 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1193 | continue; | 1195 | continue; |
1194 | // kdDebug() << " Event: " << event->summary() << endl; | 1196 | // kdDebug() << " Event: " << event->summary() << endl; |
1195 | 1197 | ||
1196 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1198 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1197 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1199 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1198 | 1200 | ||
1199 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1201 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1200 | 1202 | ||
1201 | if (event->doesFloat()) { | 1203 | if (event->doesFloat()) { |
1202 | if (event->recurrence()->doesRecur()) { | 1204 | if (event->recurrence()->doesRecur()) { |
1203 | if (event->isMultiDay() ) { | 1205 | if (event->isMultiDay() ) { |
1204 | endX = endX - beginX;// endX is now number of days | 1206 | endX = endX - beginX;// endX is now number of days |
1205 | if ( event->recursOn( currentDate ) ) { | 1207 | if ( event->recursOn( currentDate ) ) { |
1206 | endX += curCol; | 1208 | endX += curCol; |
1207 | beginX = curCol; | 1209 | beginX = curCol; |
1208 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1210 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1209 | } else { | 1211 | } else { |
1210 | //qDebug("days %d %s",endX , currentDate.toString().latin1()); | 1212 | //qDebug("days endX %d curCol %d max Col %d %s",endX ,curCol, maxCol, currentDate.toString().latin1()); |
1211 | QDate dateit = currentDate.addDays( -endX ); | 1213 | if ( curCol == maxCol && maxCol+1 < endX ) { |
1212 | if ( event->recursOn( dateit ) ) { | 1214 | int i; |
1213 | //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); | 1215 | for ( i = 1; i< endX; ++i ) { |
1214 | if ( curCol-endX < 0 ) { | 1216 | if ( event->recursOn( currentDate.addDays( -i ) ) ) |
1217 | break; | ||
1218 | } | ||
1219 | if ( i > maxCol ) { | ||
1215 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); | 1220 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); |
1221 | //qDebug("BINGO "); | ||
1222 | } | ||
1223 | |||
1224 | } else { | ||
1225 | QDate dateit = currentDate.addDays( -endX ); | ||
1226 | if ( event->recursOn( dateit ) ) { | ||
1227 | //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); | ||
1228 | if ( curCol-endX < 0 ) { | ||
1229 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); | ||
1230 | } | ||
1216 | } | 1231 | } |
1217 | } | 1232 | } |
1218 | } | 1233 | } |
1219 | } else { | 1234 | } else { |
1220 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1235 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1221 | } | 1236 | } |
1222 | 1237 | ||
1223 | } else { | 1238 | } else { |
1224 | if (beginX <= 0 && curCol == 0) { | 1239 | if (beginX <= 0 && curCol == 0) { |
1225 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1240 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1226 | } else if (beginX == curCol) { | 1241 | } else if (beginX == curCol) { |
1227 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1242 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1228 | } | 1243 | } |
1229 | } | 1244 | } |
1230 | } else if (event->isMultiDay()) { | 1245 | } else if (event->isMultiDay()) { |
1231 | if ( event->doesRecur () ) { | 1246 | if ( event->doesRecur () ) { |
1232 | QDate dateit = currentDate; | 1247 | QDate dateit = currentDate; |
1233 | int count = 0; | 1248 | int count = 0; |
1234 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1249 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1235 | while (! event->recursOn( dateit ) && count <= max ) { | 1250 | while (! event->recursOn( dateit ) && count <= max ) { |
1236 | ++count; | 1251 | ++count; |
1237 | dateit = dateit.addDays( -1 ); | 1252 | dateit = dateit.addDays( -1 ); |
1238 | } | 1253 | } |
1239 | bool ok; | 1254 | bool ok; |
1240 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1255 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1241 | if ( ok ) | 1256 | if ( ok ) |
1242 | { | 1257 | { |
1243 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1258 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1244 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1259 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1245 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1260 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1246 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1261 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1247 | 1262 | ||
1248 | } | 1263 | } |
1249 | } | 1264 | } |
1250 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1265 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1251 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1266 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1252 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1267 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1253 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1268 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1254 | //qDebug("insert!!! "); | 1269 | //qDebug("insert!!! "); |
1255 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1270 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1256 | } | 1271 | } |
1257 | if (beginX == curCol) { | 1272 | if (beginX == curCol) { |
1258 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1273 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1259 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1274 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1260 | } else if (endX == curCol) { | 1275 | } else if (endX == curCol) { |
1261 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1276 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1262 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1277 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1263 | } else { | 1278 | } else { |
1264 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1279 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1265 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1280 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1266 | } | 1281 | } |
1267 | } else { | 1282 | } else { |
1268 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1283 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1269 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1284 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1270 | if (endY < startY) endY = startY; | 1285 | if (endY < startY) endY = startY; |
1271 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1286 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1272 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1287 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1273 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1288 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1274 | } | 1289 | } |
1275 | } | 1290 | } |
1276 | // ---------- [display Todos -------------- | 1291 | // ---------- [display Todos -------------- |
1277 | unsigned int numTodo; | 1292 | unsigned int numTodo; |
1278 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1293 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1279 | Todo *todo = todos.at(numTodo); | 1294 | Todo *todo = todos.at(numTodo); |
1280 | 1295 | ||
1281 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1296 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1282 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; | 1297 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; |
1283 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1298 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1284 | // Already completed items can be displayed on their original due date | 1299 | // Already completed items can be displayed on their original due date |
1285 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1300 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1286 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1301 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1287 | bool fillIn = false; | 1302 | bool fillIn = false; |
1288 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1303 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1289 | fillIn = true; | 1304 | fillIn = true; |
1290 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1305 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1291 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1306 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1292 | if ( fillIn ) { | 1307 | if ( fillIn ) { |
1293 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1308 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1294 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1309 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1295 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1310 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1296 | } | 1311 | } |
1297 | else { | 1312 | else { |
1298 | QDateTime dt; | 1313 | QDateTime dt; |
1299 | if ( todo->hasCompletedDate() ) | 1314 | if ( todo->hasCompletedDate() ) |
1300 | dt = todo->completed(); | 1315 | dt = todo->completed(); |
1301 | else | 1316 | else |
1302 | dt = todo->dtDue();; | 1317 | dt = todo->dtDue();; |
1303 | 1318 | ||
1304 | 1319 | ||
1305 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1320 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1306 | int hi = (18/KOPrefs::instance()->mHourSize); | 1321 | int hi = (18/KOPrefs::instance()->mHourSize); |
1307 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1322 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1308 | int startY = endY -hi; | 1323 | int startY = endY -hi; |
1309 | 1324 | ||
1310 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1325 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1311 | 1326 | ||
1312 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1327 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1313 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1328 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1314 | } | 1329 | } |
1315 | } | 1330 | } |
1316 | } | 1331 | } |
1317 | // ---------- display Todos] -------------- | 1332 | // ---------- display Todos] -------------- |
1318 | 1333 | ||
1319 | ++curCol; | 1334 | ++curCol; |
1320 | } | 1335 | } |
1321 | mAgenda->hideUnused(); | 1336 | mAgenda->hideUnused(); |
1322 | mAllDayAgenda->hideUnused(); | 1337 | mAllDayAgenda->hideUnused(); |
1323 | mAgenda->checkScrollBoundaries(); | 1338 | mAgenda->checkScrollBoundaries(); |
1324 | deleteSelectedDateTime(); | 1339 | deleteSelectedDateTime(); |
1325 | createDayLabels(); | 1340 | createDayLabels(); |
1326 | emit incidenceSelected( 0 ); | 1341 | emit incidenceSelected( 0 ); |
1327 | 1342 | ||
1328 | if ( globalFlagBlockAgenda == 2 ) { | 1343 | if ( globalFlagBlockAgenda == 2 ) { |
1329 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1344 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1330 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1345 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1331 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1346 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1332 | setStartHour( QTime::currentTime ().hour() ); | 1347 | setStartHour( QTime::currentTime ().hour() ); |
1333 | } | 1348 | } |
1334 | qApp->processEvents(); | 1349 | qApp->processEvents(); |
1335 | globalFlagBlockAgenda = 0; | 1350 | globalFlagBlockAgenda = 0; |
1336 | mAllDayAgenda->drawContentsToPainter(); | 1351 | mAllDayAgenda->drawContentsToPainter(); |
1337 | mAgenda->drawContentsToPainter(); | 1352 | mAgenda->drawContentsToPainter(); |
1338 | repaintAgenda(); | 1353 | repaintAgenda(); |
1339 | startIdleTimeout(); | 1354 | startIdleTimeout(); |
1340 | onlyOne = false; | 1355 | onlyOne = false; |
1341 | } | 1356 | } |
1342 | void KOAgendaView::repaintAgenda() | 1357 | void KOAgendaView::repaintAgenda() |
1343 | { | 1358 | { |
1344 | mAgenda->viewport()->repaint( false ); | 1359 | mAgenda->viewport()->repaint( false ); |
1345 | mAllDayAgenda->viewport()->repaint( false ); | 1360 | mAllDayAgenda->viewport()->repaint( false ); |
1346 | mAgenda->finishUpdate(); | 1361 | mAgenda->finishUpdate(); |
1347 | mAllDayAgenda->finishUpdate(); | 1362 | mAllDayAgenda->finishUpdate(); |
1348 | } | 1363 | } |
1349 | 1364 | ||
1350 | 1365 | ||
1351 | void KOAgendaView::clearView() | 1366 | void KOAgendaView::clearView() |
1352 | { | 1367 | { |
1353 | mAllDayAgenda->clear(); | 1368 | mAllDayAgenda->clear(); |
1354 | mAgenda->clear(); | 1369 | mAgenda->clear(); |
1355 | } | 1370 | } |
1356 | void KOAgendaView::clearList() | 1371 | void KOAgendaView::clearList() |
1357 | { | 1372 | { |
1358 | clearView(); | 1373 | clearView(); |
1359 | mAllDayAgenda->hideUnused(); | 1374 | mAllDayAgenda->hideUnused(); |
1360 | mAgenda->hideUnused(); | 1375 | mAgenda->hideUnused(); |
1361 | } | 1376 | } |
1362 | 1377 | ||
1363 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1378 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1364 | const QDate &td) | 1379 | const QDate &td) |
1365 | { | 1380 | { |
1366 | #ifndef KORG_NOPRINTER | 1381 | #ifndef KORG_NOPRINTER |
1367 | if (fd == td) | 1382 | if (fd == td) |
1368 | calPrinter->preview(CalPrinter::Day, fd, td); | 1383 | calPrinter->preview(CalPrinter::Day, fd, td); |
1369 | else | 1384 | else |
1370 | calPrinter->preview(CalPrinter::Week, fd, td); | 1385 | calPrinter->preview(CalPrinter::Week, fd, td); |
1371 | #endif | 1386 | #endif |
1372 | } | 1387 | } |
1373 | 1388 | ||
1374 | // void KOAgendaView::updateMovedTodo() | 1389 | // void KOAgendaView::updateMovedTodo() |
1375 | // { | 1390 | // { |
1376 | // // updateConfig(); | 1391 | // // updateConfig(); |
1377 | // // emit updateTodoViews(); | 1392 | // // emit updateTodoViews(); |
1378 | // } | 1393 | // } |
1379 | 1394 | ||
1380 | void KOAgendaView::slotShowDateView( int mode , int d ) | 1395 | void KOAgendaView::slotShowDateView( int mode , int d ) |
1381 | { | 1396 | { |
1382 | if ( d >= mSelectedDates.count() ) { | 1397 | if ( d >= mSelectedDates.count() ) { |
1383 | qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); | 1398 | qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); |
1384 | 1399 | ||
1385 | } else { | 1400 | } else { |
1386 | QDate day = mSelectedDates[d]; | 1401 | QDate day = mSelectedDates[d]; |
1387 | emit showDateView(mode , day ); | 1402 | emit showDateView(mode , day ); |
1388 | } | 1403 | } |
1389 | 1404 | ||
1390 | } | 1405 | } |
1391 | void KOAgendaView::newEvent(int gx, int gy) | 1406 | void KOAgendaView::newEvent(int gx, int gy) |
1392 | { | 1407 | { |
1393 | if (!mSelectedDates.count()) return; | 1408 | if (!mSelectedDates.count()) return; |
1394 | 1409 | ||
1395 | QDate day = mSelectedDates[gx]; | 1410 | QDate day = mSelectedDates[gx]; |
1396 | 1411 | ||
1397 | QTime time = mAgenda->gyToTime(gy); | 1412 | QTime time = mAgenda->gyToTime(gy); |
1398 | QDateTime dt(day,time); | 1413 | QDateTime dt(day,time); |
1399 | // if ( dt < QDateTime::currentDateTime () ) | 1414 | // if ( dt < QDateTime::currentDateTime () ) |
1400 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1415 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1401 | emit newEventSignal(dt); | 1416 | emit newEventSignal(dt); |
1402 | } | 1417 | } |
1403 | 1418 | ||
1404 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1419 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1405 | { | 1420 | { |
1406 | if (!mSelectedDates.count()) return; | 1421 | if (!mSelectedDates.count()) return; |
1407 | 1422 | ||