author | zautrix <zautrix> | 2005-03-18 15:12:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-18 15:12:58 (UTC) |
commit | f9f521c487143641b2cf077d04fe1c475001bce2 (patch) (unidiff) | |
tree | 4ffac6d14ceb3e5d77f7634f2b2a49fd91a9e77a /korganizer | |
parent | 66bc0202d4e2306f7029362fe09d0c7ab0e7cc36 (diff) | |
download | kdepimpi-f9f521c487143641b2cf077d04fe1c475001bce2.zip kdepimpi-f9f521c487143641b2cf077d04fe1c475001bce2.tar.gz kdepimpi-f9f521c487143641b2cf077d04fe1c475001bce2.tar.bz2 |
rec fix
-rw-r--r-- | korganizer/komonthview.cpp | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index cb69832..004ff50 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1215,141 +1215,132 @@ void KOMonthView::showDates(const QDate &start, const QDate &) | |||
1215 | date = date.addDays( 7 ); | 1215 | date = date.addDays( 7 ); |
1216 | } | 1216 | } |
1217 | updateView(); | 1217 | updateView(); |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | void KOMonthView::showEvents(QPtrList<Event>) | 1220 | void KOMonthView::showEvents(QPtrList<Event>) |
1221 | { | 1221 | { |
1222 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1222 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | void KOMonthView::changeEventDisplay(Event *, int) | 1225 | void KOMonthView::changeEventDisplay(Event *, int) |
1226 | { | 1226 | { |
1227 | // this should be re-written to be much more efficient, but this | 1227 | // this should be re-written to be much more efficient, but this |
1228 | // quick-and-dirty-hack gets the job done for right now. | 1228 | // quick-and-dirty-hack gets the job done for right now. |
1229 | updateView(); | 1229 | updateView(); |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | void KOMonthView::updateView() | 1232 | void KOMonthView::updateView() |
1233 | { | 1233 | { |
1234 | 1234 | ||
1235 | if ( !updatePossible ) | 1235 | if ( !updatePossible ) |
1236 | return; | 1236 | return; |
1237 | //QTime ti; | 1237 | //QTime ti; |
1238 | //ti.start(); | 1238 | //ti.start(); |
1239 | clearSelection(); | 1239 | clearSelection(); |
1240 | QPtrVector<MonthViewCell> *cells; | 1240 | QPtrVector<MonthViewCell> *cells; |
1241 | if ( mShowWeekView ) { | 1241 | if ( mShowWeekView ) { |
1242 | cells = &mCellsW; | 1242 | cells = &mCellsW; |
1243 | } else { | 1243 | } else { |
1244 | cells = &mCells; | 1244 | cells = &mCells; |
1245 | } | 1245 | } |
1246 | #if 1 | 1246 | #if 1 |
1247 | int i; | 1247 | int i; |
1248 | int timeSpan = (*cells).size()-1; | 1248 | int timeSpan = (*cells).size()-1; |
1249 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1249 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1250 | timeSpan = 6; | 1250 | timeSpan = 6; |
1251 | for( i = 0; i < timeSpan + 1; ++i ) { | 1251 | for( i = 0; i < timeSpan + 1; ++i ) { |
1252 | (*cells)[i]->startUpdateCell(); | 1252 | (*cells)[i]->startUpdateCell(); |
1253 | } | 1253 | } |
1254 | 1254 | ||
1255 | QPtrList<Event> events = calendar()->events(); | 1255 | QPtrList<Event> events = calendar()->events(); |
1256 | Event *event; | 1256 | Event *event; |
1257 | QDateTime dt; | 1257 | QDateTime dt; |
1258 | bool ok; | 1258 | bool ok; |
1259 | QDate endDate = mStartDate.addDays( timeSpan ); | 1259 | QDate endDate = mStartDate.addDays( timeSpan ); |
1260 | for( event = events.first(); event; event = events.next() ) { // for event | 1260 | for( event = events.first(); event; event = events.next() ) { // for event |
1261 | if ( event->doesRecur() ) { | 1261 | if ( event->doesRecur() ) { |
1262 | bool last; | 1262 | bool last; |
1263 | qDebug("********************************************** "); | ||
1264 | qDebug("Event summary: %s ", event->summary().latin1()); | ||
1265 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1263 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1266 | QDateTime incidenceEnd; | 1264 | QDateTime incidenceEnd; |
1267 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1265 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1268 | qDebug("eventlen %d ", eventlen); | ||
1269 | bool invalid = false; | 1266 | bool invalid = false; |
1270 | while( true ) { | 1267 | while( true ) { |
1271 | if ( incidenceStart.isValid() ) { | 1268 | if ( incidenceStart.isValid() ) { |
1272 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1269 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1273 | int st = incidenceStart.date().daysTo( endDate ); | 1270 | int st = incidenceStart.date().daysTo( endDate ); |
1274 | if ( st >= 0 ) { // start before timeend | 1271 | if ( st >= 0 ) { // start before timeend |
1275 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1272 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1276 | if ( end >= 0 ) { // end after timestart --- got one! | 1273 | if ( end >= 0 ) { // end after timestart --- got one! |
1277 | //normalize | 1274 | //normalize |
1278 | st = timeSpan - st; | 1275 | st = timeSpan - st; |
1279 | if ( st < 0 ) st = 0; | 1276 | if ( st < 0 ) st = 0; |
1280 | if ( end > timeSpan ) end = timeSpan; | 1277 | if ( end > timeSpan ) end = timeSpan; |
1281 | int iii; | 1278 | int iii; |
1282 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1279 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1283 | for ( iii = st;iii<= end;++iii) | 1280 | for ( iii = st;iii<= end;++iii) |
1284 | (*cells)[iii]->insertEvent( event ); | 1281 | (*cells)[iii]->insertEvent( event ); |
1285 | } | 1282 | } |
1286 | } | 1283 | } |
1287 | } else { | 1284 | } else { |
1288 | if ( invalid ) | 1285 | if ( invalid ) |
1289 | break; | 1286 | break; |
1290 | invalid = true; | 1287 | invalid = true; |
1291 | qDebug("invalid %s", event->summary().latin1()); | 1288 | //qDebug("invalid %s", event->summary().latin1()); |
1292 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1289 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1293 | } | 1290 | } |
1294 | if ( last ) | 1291 | if ( last ) |
1295 | break; | 1292 | break; |
1296 | bool ok; | 1293 | bool ok; |
1297 | qDebug("TRY next occurence %s ", incidenceStart.toString().latin1()); | ||
1298 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1294 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1299 | if ( ! ok ) { | 1295 | if ( ! ok ) |
1300 | qDebug("NOT OK "); | ||
1301 | break; | 1296 | break; |
1302 | } | 1297 | if ( incidenceStart.date() > endDate ) |
1303 | if ( incidenceStart.date() > endDate ) { | ||
1304 | qDebug("incidenceStart.date() > endDate "); | ||
1305 | break; | 1298 | break; |
1306 | } | ||
1307 | qDebug("next occurence %s ", incidenceStart.toString().latin1()); | ||
1308 | } | 1299 | } |
1309 | } else { // no recur | 1300 | } else { // no recur |
1310 | int st = event->dtStart().date().daysTo( endDate ); | 1301 | int st = event->dtStart().date().daysTo( endDate ); |
1311 | if ( st >= 0 ) { // start before timeend | 1302 | if ( st >= 0 ) { // start before timeend |
1312 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1303 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1313 | if ( end >= 0 ) { // end after timestart --- got one! | 1304 | if ( end >= 0 ) { // end after timestart --- got one! |
1314 | //normalize | 1305 | //normalize |
1315 | st = timeSpan - st; | 1306 | st = timeSpan - st; |
1316 | if ( st < 0 ) st = 0; | 1307 | if ( st < 0 ) st = 0; |
1317 | if ( end > timeSpan ) end = timeSpan; | 1308 | if ( end > timeSpan ) end = timeSpan; |
1318 | int iii; | 1309 | int iii; |
1319 | for ( iii = st;iii<= end;++iii) | 1310 | for ( iii = st;iii<= end;++iii) |
1320 | (*cells)[iii]->insertEvent( event ); | 1311 | (*cells)[iii]->insertEvent( event ); |
1321 | } | 1312 | } |
1322 | } | 1313 | } |
1323 | } | 1314 | } |
1324 | } | 1315 | } |
1325 | // insert due todos | 1316 | // insert due todos |
1326 | QPtrList<Todo> todos = calendar()->todos( ); | 1317 | QPtrList<Todo> todos = calendar()->todos( ); |
1327 | Todo *todo; | 1318 | Todo *todo; |
1328 | for(todo = todos.first(); todo; todo = todos.next()) { | 1319 | for(todo = todos.first(); todo; todo = todos.next()) { |
1329 | //insertTodo( todo ); | 1320 | //insertTodo( todo ); |
1330 | if ( todo->hasDueDate() ) { | 1321 | if ( todo->hasDueDate() ) { |
1331 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1322 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1332 | if ( day >= 0 && day < timeSpan + 1) { | 1323 | if ( day >= 0 && day < timeSpan + 1) { |
1333 | (*cells)[day]->insertTodo( todo ); | 1324 | (*cells)[day]->insertTodo( todo ); |
1334 | } | 1325 | } |
1335 | } | 1326 | } |
1336 | } | 1327 | } |
1337 | 1328 | ||
1338 | for( i = 0; i < timeSpan+1; ++i ) { | 1329 | for( i = 0; i < timeSpan+1; ++i ) { |
1339 | (*cells)[i]->finishUpdateCell(); | 1330 | (*cells)[i]->finishUpdateCell(); |
1340 | } | 1331 | } |
1341 | processSelectionChange(); | 1332 | processSelectionChange(); |
1342 | (*cells)[0]->setFocus(); | 1333 | (*cells)[0]->setFocus(); |
1343 | 1334 | ||
1344 | 1335 | ||
1345 | #else | 1336 | #else |
1346 | // old code | 1337 | // old code |
1347 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1338 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1348 | int i; | 1339 | int i; |
1349 | for( i = 0; i < (*cells).count(); ++i ) { | 1340 | for( i = 0; i < (*cells).count(); ++i ) { |
1350 | (*cells)[i]->updateCell(); | 1341 | (*cells)[i]->updateCell(); |
1351 | } | 1342 | } |
1352 | 1343 | ||
1353 | //qDebug("KOMonthView::updateView() "); | 1344 | //qDebug("KOMonthView::updateView() "); |
1354 | processSelectionChange(); | 1345 | processSelectionChange(); |
1355 | // qDebug("---------------------------------------------------------------------+ "); | 1346 | // qDebug("---------------------------------------------------------------------+ "); |