author | zautrix <zautrix> | 2005-04-05 23:31:44 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-05 23:31:44 (UTC) |
commit | cf4848d972efe96640f2d5f5d52704306d0cbe4c (patch) (unidiff) | |
tree | 123a2075927def5f7f59a20949d6b59174ae79b6 /korganizer/kodaymatrix.cpp | |
parent | 6add774cf9841377f32613c7aa23161a823aa1da (diff) | |
download | kdepimpi-cf4848d972efe96640f2d5f5d52704306d0cbe4c.zip kdepimpi-cf4848d972efe96640f2d5f5d52704306d0cbe4c.tar.gz kdepimpi-cf4848d972efe96640f2d5f5d52704306d0cbe4c.tar.bz2 |
fixes
-rw-r--r-- | korganizer/kodaymatrix.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 322131f..ecca374 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -247,196 +247,196 @@ KODayMatrix::~KODayMatrix() | |||
247 | // delete mKODaymatrixWhatsThis; | 247 | // delete mKODaymatrixWhatsThis; |
248 | delete [] days; | 248 | delete [] days; |
249 | delete [] daylbls; | 249 | delete [] daylbls; |
250 | //delete [] events; | 250 | //delete [] events; |
251 | delete mToolTip; | 251 | delete mToolTip; |
252 | } | 252 | } |
253 | 253 | ||
254 | /* | 254 | /* |
255 | void KODayMatrix::setStartDate(QDate start) | 255 | void KODayMatrix::setStartDate(QDate start) |
256 | { | 256 | { |
257 | updateView(start); | 257 | updateView(start); |
258 | } | 258 | } |
259 | */ | 259 | */ |
260 | 260 | ||
261 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 261 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
262 | { | 262 | { |
263 | 263 | ||
264 | if (mSelStart == NOSELECTION) { | 264 | if (mSelStart == NOSELECTION) { |
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | //cope with selection being out of matrix limits at top (< 0) | 268 | //cope with selection being out of matrix limits at top (< 0) |
269 | int i0 = mSelStart; | 269 | int i0 = mSelStart; |
270 | if (i0 < 0) { | 270 | if (i0 < 0) { |
271 | for (int i = i0; i < 0; i++) { | 271 | for (int i = i0; i < 0; i++) { |
272 | selDays.append(days[0].addDays(i)); | 272 | selDays.append(days[0].addDays(i)); |
273 | } | 273 | } |
274 | i0 = 0; | 274 | i0 = 0; |
275 | } | 275 | } |
276 | 276 | ||
277 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 277 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
278 | if (mSelEnd > NUMDAYS-1) { | 278 | if (mSelEnd > NUMDAYS-1) { |
279 | for (int i = i0; i <= NUMDAYS-1; i++) { | 279 | for (int i = i0; i <= NUMDAYS-1; i++) { |
280 | selDays.append(days[i]); | 280 | selDays.append(days[i]); |
281 | } | 281 | } |
282 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 282 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
283 | selDays.append(days[0].addDays(i)); | 283 | selDays.append(days[0].addDays(i)); |
284 | } | 284 | } |
285 | 285 | ||
286 | // apply normal routine to selection being entirely within matrix limits | 286 | // apply normal routine to selection being entirely within matrix limits |
287 | } else { | 287 | } else { |
288 | for (int i = i0; i <= mSelEnd; i++) { | 288 | for (int i = i0; i <= mSelEnd; i++) { |
289 | selDays.append(days[i]); | 289 | selDays.append(days[i]); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | } | 292 | } |
293 | 293 | ||
294 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 294 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
295 | { | 295 | { |
296 | mRedrawNeeded = true; | 296 | mRedrawNeeded = true; |
297 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); | 297 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); |
298 | mSelStart = startdate.daysTo(start); | 298 | mSelStart = startdate.daysTo(start); |
299 | if ( mSelStart < 0 ) | 299 | if ( mSelStart < 0 ) |
300 | mSelStart = 0; | 300 | mSelStart = 0; |
301 | mSelEnd = startdate.daysTo(end); | 301 | mSelEnd = startdate.daysTo(end); |
302 | if ( mSelEnd > NUMDAYS-1 ) | 302 | if ( mSelEnd > NUMDAYS-1 ) |
303 | mSelEnd = NUMDAYS-1; | 303 | mSelEnd = NUMDAYS-1; |
304 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { | 304 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { |
305 | clearSelection(); | 305 | clearSelection(); |
306 | if ( noSel ) | 306 | if ( noSel ) |
307 | return false; | 307 | return false; |
308 | } | 308 | } |
309 | 309 | ||
310 | return true; | 310 | return true; |
311 | } | 311 | } |
312 | void KODayMatrix::clearSelection() | 312 | void KODayMatrix::clearSelection() |
313 | { | 313 | { |
314 | mSelEnd = mSelStart = NOSELECTION; | 314 | mSelEnd = mSelStart = NOSELECTION; |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | void KODayMatrix::recalculateToday() | 318 | void KODayMatrix::recalculateToday() |
319 | { | 319 | { |
320 | today = -1; | 320 | today = -1; |
321 | for (int i=0; i<NUMDAYS; i++) { | 321 | for (int i=0; i<NUMDAYS; i++) { |
322 | //events[i] = 0; | 322 | //events[i] = 0; |
323 | days[i] = startdate.addDays(i); | 323 | days[i] = startdate.addDays(i); |
324 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 324 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
325 | 325 | ||
326 | // if today is in the currently displayed month, hilight today | 326 | // if today is in the currently displayed month, hilight today |
327 | if (days[i].year() == QDate::currentDate().year() && | 327 | if (days[i].year() == QDate::currentDate().year() && |
328 | days[i].month() == QDate::currentDate().month() && | 328 | days[i].month() == QDate::currentDate().month() && |
329 | days[i].day() == QDate::currentDate().day()) { | 329 | days[i].day() == QDate::currentDate().day()) { |
330 | today = i; | 330 | today = i; |
331 | } | 331 | } |
332 | } | 332 | } |
333 | // qDebug(QString("Today is visible at %1.").arg(today)); | 333 | // qDebug(QString("Today is visible at %1.").arg(today)); |
334 | } | 334 | } |
335 | 335 | ||
336 | void KODayMatrix::updateView() | 336 | void KODayMatrix::updateView() |
337 | { | 337 | { |
338 | updateView(startdate); | 338 | updateView(startdate); |
339 | } | 339 | } |
340 | void KODayMatrix::repaintViewTimed() | 340 | void KODayMatrix::repaintViewTimed() |
341 | { | 341 | { |
342 | mRedrawNeeded = true; | 342 | mRedrawNeeded = true; |
343 | bDays.fill( false); | 343 | // bDays.fill( false); |
344 | pDays.fill( false); | 344 | //pDays.fill( false); |
345 | hDays.fill( false); | 345 | //hDays.fill( false); |
346 | eDays.fill( false); | 346 | //eDays.fill( false); |
347 | mRepaintTimer->stop(); | 347 | mRepaintTimer->stop(); |
348 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday | 348 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday |
349 | int i; | 349 | int i; |
350 | for(i = 0; i < NUMDAYS; i++) { | 350 | for(i = 0; i < NUMDAYS; i++) { |
351 | if ( ( (i+startDay) % 7 == 0 ) ) { | 351 | if ( ( (i+startDay) % 7 == 0 ) ) { |
352 | pDays.setBit(i); | 352 | pDays.setBit(i); |
353 | } | 353 | } |
354 | } | 354 | } |
355 | repaint(false); | 355 | repaint(false); |
356 | } | 356 | } |
357 | void KODayMatrix::computeEvent(Event *event, int i ) | 357 | void KODayMatrix::computeEvent(Event *event, int i ) |
358 | { | 358 | { |
359 | QString holiStr = mHolidays[i]; | 359 | QString holiStr = mHolidays[i]; |
360 | if ( event->isHoliday()) { | 360 | if ( event->isHoliday()) { |
361 | pDays.setBit(i); | 361 | pDays.setBit(i); |
362 | hDays.setBit(i); | 362 | hDays.setBit(i); |
363 | if ( !holiStr.isEmpty() ) | 363 | if ( !holiStr.isEmpty() ) |
364 | holiStr += "\n"; | 364 | holiStr += "\n"; |
365 | holiStr += event->summary(); | 365 | holiStr += event->summary(); |
366 | if ( !event->location().isEmpty() ) | 366 | if ( !event->location().isEmpty() ) |
367 | holiStr += " (" + event->location() + ")"; | 367 | holiStr += " (" + event->location() + ")"; |
368 | mHolidays[i] =holiStr ; | 368 | mHolidays[i] =holiStr ; |
369 | } | 369 | } |
370 | if ( event->isBirthday()) { | 370 | if ( event->isBirthday()) { |
371 | pDays.setBit(i); | 371 | pDays.setBit(i); |
372 | if ( !holiStr.isEmpty() ) | 372 | if ( !holiStr.isEmpty() ) |
373 | holiStr += "\n"; | 373 | holiStr += "\n"; |
374 | holiStr += i18n("Birthday") + ": "+event->summary(); | 374 | holiStr += i18n("Birthday") + ": "+event->summary(); |
375 | if ( !event->location().isEmpty() ) | 375 | if ( !event->location().isEmpty() ) |
376 | holiStr += " (" + event->location() + ")"; | 376 | holiStr += " (" + event->location() + ")"; |
377 | bDays.setBit(i); | 377 | bDays.setBit(i); |
378 | mHolidays[i] =holiStr ; | 378 | mHolidays[i] =holiStr ; |
379 | } | 379 | } |
380 | eDays.setBit(i); | 380 | eDays.setBit(i); |
381 | } | 381 | } |
382 | void KODayMatrix::updateViewTimed() | 382 | void KODayMatrix::updateViewTimed() |
383 | { | 383 | { |
384 | mUpdateTimer->stop(); | 384 | mUpdateTimer->stop(); |
385 | if ( !mCalendar ) { | 385 | if ( !mCalendar ) { |
386 | qDebug("NOT CAL "); | 386 | qDebug("NOT CAL "); |
387 | return; | 387 | return; |
388 | } | 388 | } |
389 | #if 1 | 389 | #if 1 |
390 | 390 | ||
391 | int i; | 391 | int i; |
392 | int timeSpan = NUMDAYS-1; | 392 | int timeSpan = NUMDAYS-1; |
393 | QPtrList<Event> events = mCalendar->events(); | 393 | QPtrList<Event> events = mCalendar->events(); |
394 | Event *event; | 394 | Event *event; |
395 | QDateTime dt; | 395 | QDateTime dt; |
396 | bool ok; | 396 | bool ok; |
397 | bDays.fill( false); | 397 | bDays.fill( false); |
398 | pDays.fill( false); | 398 | pDays.fill( false); |
399 | hDays.fill( false); | 399 | hDays.fill( false); |
400 | eDays.fill( false); | 400 | eDays.fill( false); |
401 | mHolidays.clear(); | 401 | mHolidays.clear(); |
402 | QDate mStartDate = days[0]; | 402 | QDate mStartDate = days[0]; |
403 | QDate endDate = mStartDate.addDays( timeSpan ); | 403 | QDate endDate = mStartDate.addDays( timeSpan ); |
404 | for( event = events.first(); event; event = events.next() ) { // for event | 404 | for( event = events.first(); event; event = events.next() ) { // for event |
405 | ushort recurType = event->recurrence()->doesRecur(); | 405 | ushort recurType = event->recurrence()->doesRecur(); |
406 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 406 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
407 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 407 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
408 | continue; | 408 | continue; |
409 | } | 409 | } |
410 | if ( event->doesRecur() ) { | 410 | if ( event->doesRecur() ) { |
411 | bool last; | 411 | bool last; |
412 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 412 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
413 | QDateTime incidenceEnd; | 413 | QDateTime incidenceEnd; |
414 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 414 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
415 | bool invalid = false; | 415 | bool invalid = false; |
416 | while( true ) { | 416 | while( true ) { |
417 | if ( incidenceStart.isValid() ) { | 417 | if ( incidenceStart.isValid() ) { |
418 | incidenceEnd = incidenceStart.addDays( eventlen ); | 418 | incidenceEnd = incidenceStart.addDays( eventlen ); |
419 | int st = incidenceStart.date().daysTo( endDate ); | 419 | int st = incidenceStart.date().daysTo( endDate ); |
420 | if ( st >= 0 ) { // start before timeend | 420 | if ( st >= 0 ) { // start before timeend |
421 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 421 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
422 | if ( end >= 0 ) { // end after timestart --- got one! | 422 | if ( end >= 0 ) { // end after timestart --- got one! |
423 | //normalize | 423 | //normalize |
424 | st = timeSpan - st; | 424 | st = timeSpan - st; |
425 | if ( st < 0 ) st = 0; | 425 | if ( st < 0 ) st = 0; |
426 | if ( end > timeSpan ) end = timeSpan; | 426 | if ( end > timeSpan ) end = timeSpan; |
427 | int iii; | 427 | int iii; |
428 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 428 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
429 | for ( iii = st;iii<= end;++iii) { | 429 | for ( iii = st;iii<= end;++iii) { |
430 | computeEvent( event, iii ); | 430 | computeEvent( event, iii ); |
431 | } | 431 | } |
432 | } | 432 | } |
433 | } | 433 | } |
434 | } else { | 434 | } else { |
435 | if ( invalid ) | 435 | if ( invalid ) |
436 | break; | 436 | break; |
437 | invalid = true; | 437 | invalid = true; |
438 | //qDebug("invalid %s", event->summary().latin1()); | 438 | //qDebug("invalid %s", event->summary().latin1()); |
439 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 439 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
440 | } | 440 | } |
441 | if ( last ) | 441 | if ( last ) |
442 | break; | 442 | break; |