summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp25
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
@@ -1081,231 +1081,246 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
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
1099void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1099void 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
1116void KOAgendaView::showEvents(QPtrList<Event>) 1116void 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
1121void KOAgendaView::changeEventDisplay(Event *, int) 1121void 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
1130void KOAgendaView::fillAgenda(const QDate &) 1130void KOAgendaView::fillAgenda(const QDate &)
1131{ 1131{
1132 // qDebug("KOAgendaView::fillAgenda "); 1132 // qDebug("KOAgendaView::fillAgenda ");
1133 fillAgenda(); 1133 fillAgenda();
1134} 1134}
1135 1135
1136void KOAgendaView::fillAgenda() 1136void 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