author | zautrix <zautrix> | 2005-07-28 10:38:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-28 10:38:58 (UTC) |
commit | fee4c893fe8fd01af1b55c1ccd40213fc18a36b4 (patch) (unidiff) | |
tree | 83a3018d54d60e880d441a6f91ef8fe54254aaff /libkcal | |
parent | 27ffa2e08ebb38e71f613af3a214750442418e2c (diff) | |
download | kdepimpi-fee4c893fe8fd01af1b55c1ccd40213fc18a36b4.zip kdepimpi-fee4c893fe8fd01af1b55c1ccd40213fc18a36b4.tar.gz kdepimpi-fee4c893fe8fd01af1b55c1ccd40213fc18a36b4.tar.bz2 |
fixxxx
-rw-r--r-- | libkcal/alarm.cpp | 2 | ||||
-rw-r--r-- | libkcal/event.cpp | 8 | ||||
-rw-r--r-- | libkcal/event.h | 1 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 29 | ||||
-rw-r--r-- | libkcal/incidence.h | 3 | ||||
-rw-r--r-- | libkcal/todo.cpp | 10 | ||||
-rw-r--r-- | libkcal/todo.h | 1 |
7 files changed, 52 insertions, 2 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp index 79e0464..3157214 100644 --- a/libkcal/alarm.cpp +++ b/libkcal/alarm.cpp | |||
@@ -257,193 +257,193 @@ void Alarm::setMailSubject(const QString &mailAlarmSubject) | |||
257 | if (mType == Email) { | 257 | if (mType == Email) { |
258 | mMailSubject = mailAlarmSubject; | 258 | mMailSubject = mailAlarmSubject; |
259 | mParent->updated(); | 259 | mParent->updated(); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | 262 | ||
263 | QString Alarm::mailSubject() const | 263 | QString Alarm::mailSubject() const |
264 | { | 264 | { |
265 | return (mType == Email) ? mMailSubject : QString::null; | 265 | return (mType == Email) ? mMailSubject : QString::null; |
266 | } | 266 | } |
267 | 267 | ||
268 | void Alarm::setMailAttachment(const QString &mailAttachFile) | 268 | void Alarm::setMailAttachment(const QString &mailAttachFile) |
269 | { | 269 | { |
270 | if (mType == Email) { | 270 | if (mType == Email) { |
271 | mMailAttachFiles.clear(); | 271 | mMailAttachFiles.clear(); |
272 | mMailAttachFiles += mailAttachFile; | 272 | mMailAttachFiles += mailAttachFile; |
273 | mParent->updated(); | 273 | mParent->updated(); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | 276 | ||
277 | void Alarm::setMailAttachments(const QStringList &mailAttachFiles) | 277 | void Alarm::setMailAttachments(const QStringList &mailAttachFiles) |
278 | { | 278 | { |
279 | if (mType == Email) { | 279 | if (mType == Email) { |
280 | mMailAttachFiles = mailAttachFiles; | 280 | mMailAttachFiles = mailAttachFiles; |
281 | mParent->updated(); | 281 | mParent->updated(); |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | void Alarm::addMailAttachment(const QString &mailAttachFile) | 285 | void Alarm::addMailAttachment(const QString &mailAttachFile) |
286 | { | 286 | { |
287 | if (mType == Email) { | 287 | if (mType == Email) { |
288 | mMailAttachFiles += mailAttachFile; | 288 | mMailAttachFiles += mailAttachFile; |
289 | mParent->updated(); | 289 | mParent->updated(); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | QStringList Alarm::mailAttachments() const | 293 | QStringList Alarm::mailAttachments() const |
294 | { | 294 | { |
295 | return (mType == Email) ? mMailAttachFiles : QStringList(); | 295 | return (mType == Email) ? mMailAttachFiles : QStringList(); |
296 | } | 296 | } |
297 | 297 | ||
298 | void Alarm::setMailText(const QString &text) | 298 | void Alarm::setMailText(const QString &text) |
299 | { | 299 | { |
300 | if (mType == Email) { | 300 | if (mType == Email) { |
301 | mDescription = text; | 301 | mDescription = text; |
302 | mParent->updated(); | 302 | mParent->updated(); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | QString Alarm::mailText() const | 306 | QString Alarm::mailText() const |
307 | { | 307 | { |
308 | return (mType == Email) ? mDescription : QString::null; | 308 | return (mType == Email) ? mDescription : QString::null; |
309 | } | 309 | } |
310 | 310 | ||
311 | void Alarm::setDisplayAlarm(const QString &text) | 311 | void Alarm::setDisplayAlarm(const QString &text) |
312 | { | 312 | { |
313 | mType = Display; | 313 | mType = Display; |
314 | mDescription = text; | 314 | mDescription = text; |
315 | mParent->updated(); | 315 | mParent->updated(); |
316 | } | 316 | } |
317 | 317 | ||
318 | void Alarm::setText(const QString &text) | 318 | void Alarm::setText(const QString &text) |
319 | { | 319 | { |
320 | if (mType == Display) { | 320 | if (mType == Display) { |
321 | mDescription = text; | 321 | mDescription = text; |
322 | mParent->updated(); | 322 | mParent->updated(); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
326 | QString Alarm::text() const | 326 | QString Alarm::text() const |
327 | { | 327 | { |
328 | return (mType == Display) ? mDescription : QString::null; | 328 | return (mType == Display) ? mDescription : QString::null; |
329 | } | 329 | } |
330 | 330 | ||
331 | void Alarm::setTime(const QDateTime &alarmTime) | 331 | void Alarm::setTime(const QDateTime &alarmTime) |
332 | { | 332 | { |
333 | mAlarmTime = alarmTime; | 333 | mAlarmTime = alarmTime; |
334 | mHasTime = true; | 334 | mHasTime = true; |
335 | 335 | ||
336 | mParent->updated(); | 336 | mParent->updated(); |
337 | } | 337 | } |
338 | int Alarm::offset() | 338 | int Alarm::offset() |
339 | { | 339 | { |
340 | if ( hasTime() ) { | 340 | if ( hasTime() ) { |
341 | if (mParent->typeID() == todoID ) { | 341 | if (mParent->typeID() == todoID ) { |
342 | Todo *t = static_cast<Todo*>(mParent); | 342 | Todo *t = static_cast<Todo*>(mParent); |
343 | return t->dtDue().secsTo( mAlarmTime ) ; | 343 | return t->dtDue().secsTo( mAlarmTime ) ; |
344 | } else | 344 | } else |
345 | return mParent->dtStart().secsTo( mAlarmTime ) ; | 345 | return mParent->dtStart().secsTo( mAlarmTime ) ; |
346 | } | 346 | } |
347 | else | 347 | else |
348 | { | 348 | { |
349 | return mOffset.asSeconds(); | 349 | return mOffset.asSeconds(); |
350 | } | 350 | } |
351 | 351 | ||
352 | } | 352 | } |
353 | QString Alarm::offsetText() | 353 | QString Alarm::offsetText() |
354 | { | 354 | { |
355 | int min = -offset()/60; | 355 | int min = -offset()/60; |
356 | int hours = min /60; | 356 | int hours = min /60; |
357 | min = min % 60; | 357 | min = min % 60; |
358 | int days = hours /24; | 358 | int days = hours /24; |
359 | hours = hours % 24; | 359 | hours = hours % 24; |
360 | QString message; | 360 | QString message; |
361 | //qDebug("%d %d %d ", days, hours, min ); | 361 | //qDebug("%d %d %d ", days, hours, min ); |
362 | if ( days > 0 ) | 362 | if ( days > 0 ) |
363 | message += i18n("%1d").arg( days ); | 363 | message += i18n("%1d").arg( days ); |
364 | if ( hours > 0 ) { | 364 | if ( hours > 0 ) { |
365 | if ( !message.isEmpty() ) message += "/"; | 365 | if ( !message.isEmpty() ) message += "/"; |
366 | message += i18n("%1h").arg( hours ); | 366 | message += i18n("%1h").arg( hours ); |
367 | } | 367 | } |
368 | if ( min > 0 ) { | 368 | if ( min > 0 ) { |
369 | if ( !message.isEmpty() ) message += "/"; | 369 | if ( !message.isEmpty() ) message += "/"; |
370 | message += i18n("%1min").arg( min ); | 370 | message += i18n("%1min").arg( min ); |
371 | } | 371 | } |
372 | if ( message.isEmpty() ) | 372 | if ( message.isEmpty() ) |
373 | message = i18n("%1min").arg( 0 ); | 373 | message = i18n("%1min").arg( 0 ); |
374 | if ( !mParent->alarmEnabled() ) | 374 | if ( !mParent->alarmEnabled() ) |
375 | return "!"+message + i18n("(disabled)"); | 375 | return "!"+message + i18n("(disabled)"); |
376 | return message; | 376 | return message; |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | QDateTime Alarm::time() const | 380 | QDateTime Alarm::time() const |
381 | { | 381 | { |
382 | if ( hasTime() ) | 382 | if ( hasTime() ) |
383 | return mAlarmTime; | 383 | return mAlarmTime; |
384 | else | 384 | else |
385 | { | 385 | { |
386 | if (mParent->typeID() == todoID ) { | 386 | if (mParent->typeID() == todoID ) { |
387 | Todo *t = static_cast<Todo*>(mParent); | 387 | Todo *t = static_cast<Todo*>(mParent); |
388 | return mOffset.end( t->dtDue() ); | 388 | return mOffset.end( t->dtDue() ); |
389 | } else if (mEndOffset) { | 389 | } else if (mEndOffset) { |
390 | return mOffset.end( mParent->dtEnd() ); | 390 | return mOffset.end( mParent->dtEnd() ); |
391 | } else { | 391 | } else { |
392 | return mOffset.end( mParent->dtStart() ); | 392 | return mOffset.end( mParent->dtStart() ); |
393 | } | 393 | } |
394 | } | 394 | } |
395 | } | 395 | } |
396 | 396 | ||
397 | bool Alarm::hasTime() const | 397 | bool Alarm::hasTime() const |
398 | { | 398 | { |
399 | return mHasTime; | 399 | return mHasTime; |
400 | } | 400 | } |
401 | 401 | ||
402 | void Alarm::setSnoozeTime(int alarmSnoozeTime) | 402 | void Alarm::setSnoozeTime(int alarmSnoozeTime) |
403 | { | 403 | { |
404 | mAlarmSnoozeTime = alarmSnoozeTime; | 404 | mAlarmSnoozeTime = alarmSnoozeTime; |
405 | mParent->updated(); | 405 | mParent->updated(); |
406 | } | 406 | } |
407 | 407 | ||
408 | int Alarm::snoozeTime() const | 408 | int Alarm::snoozeTime() const |
409 | { | 409 | { |
410 | return mAlarmSnoozeTime; | 410 | return mAlarmSnoozeTime; |
411 | } | 411 | } |
412 | 412 | ||
413 | void Alarm::setRepeatCount(int alarmRepeatCount) | 413 | void Alarm::setRepeatCount(int alarmRepeatCount) |
414 | { | 414 | { |
415 | kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; | 415 | kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; |
416 | 416 | ||
417 | mAlarmRepeatCount = alarmRepeatCount; | 417 | mAlarmRepeatCount = alarmRepeatCount; |
418 | mParent->updated(); | 418 | mParent->updated(); |
419 | } | 419 | } |
420 | 420 | ||
421 | int Alarm::repeatCount() const | 421 | int Alarm::repeatCount() const |
422 | { | 422 | { |
423 | kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; | 423 | kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; |
424 | return mAlarmRepeatCount; | 424 | return mAlarmRepeatCount; |
425 | } | 425 | } |
426 | 426 | ||
427 | void Alarm::toggleAlarm() | 427 | void Alarm::toggleAlarm() |
428 | { | 428 | { |
429 | mAlarmEnabled = !mAlarmEnabled; | 429 | mAlarmEnabled = !mAlarmEnabled; |
430 | mParent->updated(); | 430 | mParent->updated(); |
431 | } | 431 | } |
432 | 432 | ||
433 | void Alarm::setEnabled(bool enable) | 433 | void Alarm::setEnabled(bool enable) |
434 | { | 434 | { |
435 | mAlarmEnabled = enable; | 435 | mAlarmEnabled = enable; |
436 | mParent->updated(); | 436 | mParent->updated(); |
437 | } | 437 | } |
438 | 438 | ||
439 | bool Alarm::enabled() const | 439 | bool Alarm::enabled() const |
440 | { | 440 | { |
441 | return mAlarmEnabled; | 441 | return mAlarmEnabled; |
442 | } | 442 | } |
443 | 443 | ||
444 | void Alarm::setStartOffset( const Duration &offset ) | 444 | void Alarm::setStartOffset( const Duration &offset ) |
445 | { | 445 | { |
446 | mOffset = offset; | 446 | mOffset = offset; |
447 | mEndOffset = false; | 447 | mEndOffset = false; |
448 | mHasTime = false; | 448 | mHasTime = false; |
449 | mParent->updated(); | 449 | mParent->updated(); |
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index 0766fd9..fdf5657 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -321,96 +321,104 @@ bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime* | |||
321 | incidenceStart = incidenceStart.addSecs( -300 ); | 321 | incidenceStart = incidenceStart.addSecs( -300 ); |
322 | else | 322 | else |
323 | testincidenceStart = testincidenceStart.addSecs( -300 ); | 323 | testincidenceStart = testincidenceStart.addSecs( -300 ); |
324 | int count = 0; | 324 | int count = 0; |
325 | ok = true; | 325 | ok = true; |
326 | int countbreak = 2000; | 326 | int countbreak = 2000; |
327 | QDateTime stopSearch; | 327 | QDateTime stopSearch; |
328 | bool testStop = false; | 328 | bool testStop = false; |
329 | if ( startDT ) { | 329 | if ( startDT ) { |
330 | stopSearch = startDT->addDays( 365*3 ); | 330 | stopSearch = startDT->addDays( 365*3 ); |
331 | testStop = true; | 331 | testStop = true; |
332 | } | 332 | } |
333 | while ( ok ) { | 333 | while ( ok ) { |
334 | ++count; | 334 | ++count; |
335 | if ( count > countbreak ) break; | 335 | if ( count > countbreak ) break; |
336 | if ( computeThis ) { | 336 | if ( computeThis ) { |
337 | if ( testStop ) | 337 | if ( testStop ) |
338 | if ( testincidenceStart > stopSearch ) | 338 | if ( testincidenceStart > stopSearch ) |
339 | break; | 339 | break; |
340 | incidenceStart = getNextOccurence( incidenceStart.addSecs( 60 ), &ok ); | 340 | incidenceStart = getNextOccurence( incidenceStart.addSecs( 60 ), &ok ); |
341 | } | 341 | } |
342 | else { | 342 | else { |
343 | if ( testStop ) | 343 | if ( testStop ) |
344 | if ( incidenceStart > stopSearch ) | 344 | if ( incidenceStart > stopSearch ) |
345 | break; | 345 | break; |
346 | testincidenceStart = testEvent->getNextOccurence( testincidenceStart.addSecs( 60 ), &ok ); | 346 | testincidenceStart = testEvent->getNextOccurence( testincidenceStart.addSecs( 60 ), &ok ); |
347 | } | 347 | } |
348 | if ( ok ) { | 348 | if ( ok ) { |
349 | if ( incidenceStart < testincidenceStart.addSecs( testduration ) && testincidenceStart < incidenceStart.addSecs( duration ) ) { | 349 | if ( incidenceStart < testincidenceStart.addSecs( testduration ) && testincidenceStart < incidenceStart.addSecs( duration ) ) { |
350 | if ( incidenceStart < testincidenceStart ) | 350 | if ( incidenceStart < testincidenceStart ) |
351 | *overlapDT = testincidenceStart; | 351 | *overlapDT = testincidenceStart; |
352 | else | 352 | else |
353 | *overlapDT = incidenceStart; | 353 | *overlapDT = incidenceStart; |
354 | if ( startDT ) { | 354 | if ( startDT ) { |
355 | if ( *overlapDT >= *startDT ) | 355 | if ( *overlapDT >= *startDT ) |
356 | return true; | 356 | return true; |
357 | } else | 357 | } else |
358 | return true; | 358 | return true; |
359 | } | 359 | } |
360 | computeThis = ( incidenceStart < testincidenceStart ); | 360 | computeThis = ( incidenceStart < testincidenceStart ); |
361 | } | 361 | } |
362 | 362 | ||
363 | } | 363 | } |
364 | //qDebug("%d rec counter stopped at %d - %s %s", ok ,count, summary().latin1(),testEvent->summary().latin1() ); | 364 | //qDebug("%d rec counter stopped at %d - %s %s", ok ,count, summary().latin1(),testEvent->summary().latin1() ); |
365 | return false; | 365 | return false; |
366 | } | 366 | } |
367 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 367 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
368 | { | 368 | { |
369 | *ok = false; | 369 | *ok = false; |
370 | if ( !alarmEnabled() ) | 370 | if ( !alarmEnabled() ) |
371 | return QDateTime (); | 371 | return QDateTime (); |
372 | bool yes; | 372 | bool yes; |
373 | QDateTime incidenceStart = getNextOccurence( start_dt, &yes ); | 373 | QDateTime incidenceStart = getNextOccurence( start_dt, &yes ); |
374 | if ( ! yes || cancelled() ) { | 374 | if ( ! yes || cancelled() ) { |
375 | *ok = false; | 375 | *ok = false; |
376 | return QDateTime (); | 376 | return QDateTime (); |
377 | } | 377 | } |
378 | 378 | ||
379 | bool enabled = false; | 379 | bool enabled = false; |
380 | Alarm* alarm; | 380 | Alarm* alarm; |
381 | int off = 0; | 381 | int off = 0; |
382 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 382 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
383 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 383 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
384 | // *ok = false; | 384 | // *ok = false; |
385 | // return incidenceStart; | 385 | // return incidenceStart; |
386 | // } | 386 | // } |
387 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 387 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
388 | if (alarm->enabled()) { | 388 | if (alarm->enabled()) { |
389 | if ( alarm->hasTime () ) { | 389 | if ( alarm->hasTime () ) { |
390 | if ( alarm->time() < alarmStart ) { | 390 | if ( alarm->time() < alarmStart ) { |
391 | alarmStart = alarm->time(); | 391 | alarmStart = alarm->time(); |
392 | enabled = true; | 392 | enabled = true; |
393 | off = alarmStart.secsTo( incidenceStart ); | 393 | off = alarmStart.secsTo( incidenceStart ); |
394 | } | 394 | } |
395 | 395 | ||
396 | } else { | 396 | } else { |
397 | int secs = alarm->startOffset().asSeconds(); | 397 | int secs = alarm->startOffset().asSeconds(); |
398 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 398 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
399 | alarmStart = incidenceStart.addSecs( secs ); | 399 | alarmStart = incidenceStart.addSecs( secs ); |
400 | enabled = true; | 400 | enabled = true; |
401 | off = -secs; | 401 | off = -secs; |
402 | } | 402 | } |
403 | } | 403 | } |
404 | } | 404 | } |
405 | } | 405 | } |
406 | if ( enabled ) { | 406 | if ( enabled ) { |
407 | if ( alarmStart > start_dt ) { | 407 | if ( alarmStart > start_dt ) { |
408 | *ok = true; | 408 | *ok = true; |
409 | * offset = off; | 409 | * offset = off; |
410 | return alarmStart; | 410 | return alarmStart; |
411 | } | 411 | } |
412 | } | 412 | } |
413 | *ok = false; | 413 | *ok = false; |
414 | return QDateTime (); | 414 | return QDateTime (); |
415 | 415 | ||
416 | } | 416 | } |
417 | |||
418 | QString Event::durationText() | ||
419 | { | ||
420 | int sec = mDtStart.secsTo( mDtEnd ); | ||
421 | if ( doesFloat() ) | ||
422 | sec += 86400; | ||
423 | return durationText4Time( sec ); | ||
424 | } | ||
diff --git a/libkcal/event.h b/libkcal/event.h index 2da9770..6a58618 100644 --- a/libkcal/event.h +++ b/libkcal/event.h | |||
@@ -1,94 +1,95 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef EVENT_H | 21 | #ifndef EVENT_H |
22 | #define EVENT_H | 22 | #define EVENT_H |
23 | // | 23 | // |
24 | // Event component, representing a VEVENT object | 24 | // Event component, representing a VEVENT object |
25 | // | 25 | // |
26 | 26 | ||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | namespace KCal { | 28 | namespace KCal { |
29 | 29 | ||
30 | /** | 30 | /** |
31 | This class provides an Event in the sense of RFC2445. | 31 | This class provides an Event in the sense of RFC2445. |
32 | */ | 32 | */ |
33 | class Event : public Incidence | 33 | class Event : public Incidence |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | enum Transparency { Opaque, Transparent }; | 36 | enum Transparency { Opaque, Transparent }; |
37 | typedef ListBase<Event> List; | 37 | typedef ListBase<Event> List; |
38 | Event(); | 38 | Event(); |
39 | Event(const Event &); | 39 | Event(const Event &); |
40 | ~Event(); | 40 | ~Event(); |
41 | bool matchTime(QDateTime*startDT, QDateTime* endDT); | 41 | bool matchTime(QDateTime*startDT, QDateTime* endDT); |
42 | 42 | ||
43 | QCString type() const { return "Event"; } | 43 | QCString type() const { return "Event"; } |
44 | IncTypeID typeID() const { return eventID; } | 44 | IncTypeID typeID() const { return eventID; } |
45 | 45 | ||
46 | Incidence *clone(); | 46 | Incidence *clone(); |
47 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; | 47 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; |
48 | 48 | ||
49 | /** for setting an event's ending date/time with a QDateTime. */ | 49 | /** for setting an event's ending date/time with a QDateTime. */ |
50 | void setDtEnd(const QDateTime &dtEnd); | 50 | void setDtEnd(const QDateTime &dtEnd); |
51 | /** Return the event's ending date/time as a QDateTime. */ | 51 | /** Return the event's ending date/time as a QDateTime. */ |
52 | virtual QDateTime dtEnd() const; | 52 | virtual QDateTime dtEnd() const; |
53 | /** returns an event's end time as a string formatted according to the | 53 | /** returns an event's end time as a string formatted according to the |
54 | users locale settings */ | 54 | users locale settings */ |
55 | QString dtEndTimeStr() const; | 55 | QString dtEndTimeStr() const; |
56 | /** returns an event's end date as a string formatted according to the | 56 | /** returns an event's end date as a string formatted according to the |
57 | users locale settings */ | 57 | users locale settings */ |
58 | QString dtEndDateStr(bool shortfmt=true) const; | 58 | QString dtEndDateStr(bool shortfmt=true) const; |
59 | /** returns an event's end date and time as a string formatted according | 59 | /** returns an event's end date and time as a string formatted according |
60 | to the users locale settings */ | 60 | to the users locale settings */ |
61 | QString dtEndStr(bool shortfmt=true) const; | 61 | QString dtEndStr(bool shortfmt=true) const; |
62 | void setHasEndDate(bool); | 62 | void setHasEndDate(bool); |
63 | /** Return whether the event has an end date/time. */ | 63 | /** Return whether the event has an end date/time. */ |
64 | bool hasEndDate() const; | 64 | bool hasEndDate() const; |
65 | 65 | ||
66 | /** Return true if the event spans multiple days, otherwise return false. */ | 66 | /** Return true if the event spans multiple days, otherwise return false. */ |
67 | bool isMultiDay() const; | 67 | bool isMultiDay() const; |
68 | 68 | ||
69 | /** set the event's time transparency level. */ | 69 | /** set the event's time transparency level. */ |
70 | void setTransparency(Transparency transparency); | 70 | void setTransparency(Transparency transparency); |
71 | /** get the event's time transparency level. */ | 71 | /** get the event's time transparency level. */ |
72 | Transparency transparency() const; | 72 | Transparency transparency() const; |
73 | 73 | ||
74 | void setDuration(int seconds); | 74 | void setDuration(int seconds); |
75 | 75 | ||
76 | bool contains ( Event*); | 76 | bool contains ( Event*); |
77 | 77 | ||
78 | bool isOverlapping ( Event*, QDateTime*, QDateTime* ); | 78 | bool isOverlapping ( Event*, QDateTime*, QDateTime* ); |
79 | QString durationText(); | ||
79 | 80 | ||
80 | private: | 81 | private: |
81 | bool accept(Visitor &v) { return v.visit(this); } | 82 | bool accept(Visitor &v) { return v.visit(this); } |
82 | 83 | ||
83 | QDateTime mDtEnd; | 84 | QDateTime mDtEnd; |
84 | bool mHasEndDate; | 85 | bool mHasEndDate; |
85 | Transparency mTransparency; | 86 | Transparency mTransparency; |
86 | }; | 87 | }; |
87 | 88 | ||
88 | bool operator==( const Event&, const Event& ); | 89 | bool operator==( const Event&, const Event& ); |
89 | 90 | ||
90 | 91 | ||
91 | } | 92 | } |
92 | 93 | ||
93 | 94 | ||
94 | #endif | 95 | #endif |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 4643a3a..201f593 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -7,193 +7,222 @@ | |||
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | #include "todo.h" | 28 | #include "todo.h" |
29 | 29 | ||
30 | using namespace KCal; | 30 | using namespace KCal; |
31 | 31 | ||
32 | Incidence::Incidence() : | 32 | Incidence::Incidence() : |
33 | IncidenceBase(), | 33 | IncidenceBase(), |
34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) | 34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) |
35 | { | 35 | { |
36 | mRecurrence = 0;//new Recurrence(this); | 36 | mRecurrence = 0;//new Recurrence(this); |
37 | mCancelled = false; | 37 | mCancelled = false; |
38 | recreate(); | 38 | recreate(); |
39 | mHasStartDate = true; | 39 | mHasStartDate = true; |
40 | mAlarms.setAutoDelete(true); | 40 | mAlarms.setAutoDelete(true); |
41 | mAttachments.setAutoDelete(true); | 41 | mAttachments.setAutoDelete(true); |
42 | mHasRecurrenceID = false; | 42 | mHasRecurrenceID = false; |
43 | mHoliday = false; | 43 | mHoliday = false; |
44 | mBirthday = false; | 44 | mBirthday = false; |
45 | mAnniversary = false; | 45 | mAnniversary = false; |
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | 49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) |
50 | { | 50 | { |
51 | // TODO: reenable attributes currently commented out. | 51 | // TODO: reenable attributes currently commented out. |
52 | mRevision = i.mRevision; | 52 | mRevision = i.mRevision; |
53 | mCreated = i.mCreated; | 53 | mCreated = i.mCreated; |
54 | mDescription = i.mDescription; | 54 | mDescription = i.mDescription; |
55 | mSummary = i.mSummary; | 55 | mSummary = i.mSummary; |
56 | mCategories = i.mCategories; | 56 | mCategories = i.mCategories; |
57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; | 57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; |
58 | mRelatedTo = 0; | 58 | mRelatedTo = 0; |
59 | mRelatedToUid = i.mRelatedToUid; | 59 | mRelatedToUid = i.mRelatedToUid; |
60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; | 60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; |
61 | mExDates = i.mExDates; | 61 | mExDates = i.mExDates; |
62 | mAttachments = i.mAttachments; | 62 | mAttachments = i.mAttachments; |
63 | mResources = i.mResources; | 63 | mResources = i.mResources; |
64 | mSecrecy = i.mSecrecy; | 64 | mSecrecy = i.mSecrecy; |
65 | mPriority = i.mPriority; | 65 | mPriority = i.mPriority; |
66 | mLocation = i.mLocation; | 66 | mLocation = i.mLocation; |
67 | mCancelled = i.mCancelled; | 67 | mCancelled = i.mCancelled; |
68 | mHasStartDate = i.mHasStartDate; | 68 | mHasStartDate = i.mHasStartDate; |
69 | QPtrListIterator<Alarm> it( i.mAlarms ); | 69 | QPtrListIterator<Alarm> it( i.mAlarms ); |
70 | const Alarm *a; | 70 | const Alarm *a; |
71 | while( (a = it.current()) ) { | 71 | while( (a = it.current()) ) { |
72 | Alarm *b = new Alarm( *a ); | 72 | Alarm *b = new Alarm( *a ); |
73 | b->setParent( this ); | 73 | b->setParent( this ); |
74 | mAlarms.append( b ); | 74 | mAlarms.append( b ); |
75 | 75 | ||
76 | ++it; | 76 | ++it; |
77 | } | 77 | } |
78 | mAlarms.setAutoDelete(true); | 78 | mAlarms.setAutoDelete(true); |
79 | mHasRecurrenceID = i.mHasRecurrenceID; | 79 | mHasRecurrenceID = i.mHasRecurrenceID; |
80 | mRecurrenceID = i.mRecurrenceID; | 80 | mRecurrenceID = i.mRecurrenceID; |
81 | if ( i.mRecurrence ) | 81 | if ( i.mRecurrence ) |
82 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 82 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); |
83 | else | 83 | else |
84 | mRecurrence = 0; | 84 | mRecurrence = 0; |
85 | mHoliday = i.mHoliday ; | 85 | mHoliday = i.mHoliday ; |
86 | mBirthday = i.mBirthday; | 86 | mBirthday = i.mBirthday; |
87 | mAnniversary = i.mAnniversary; | 87 | mAnniversary = i.mAnniversary; |
88 | } | 88 | } |
89 | 89 | ||
90 | Incidence::~Incidence() | 90 | Incidence::~Incidence() |
91 | { | 91 | { |
92 | 92 | ||
93 | Incidence *ev; | 93 | Incidence *ev; |
94 | QPtrList<Incidence> Relations = relations(); | 94 | QPtrList<Incidence> Relations = relations(); |
95 | for (ev=Relations.first();ev;ev=Relations.next()) { | 95 | for (ev=Relations.first();ev;ev=Relations.next()) { |
96 | if (ev->relatedTo() == this) ev->setRelatedTo(0); | 96 | if (ev->relatedTo() == this) ev->setRelatedTo(0); |
97 | } | 97 | } |
98 | if (relatedTo()) relatedTo()->removeRelation(this); | 98 | if (relatedTo()) relatedTo()->removeRelation(this); |
99 | if ( mRecurrence ) | 99 | if ( mRecurrence ) |
100 | delete mRecurrence; | 100 | delete mRecurrence; |
101 | 101 | ||
102 | } | 102 | } |
103 | QString Incidence::durationText() | ||
104 | { | ||
105 | return "---"; | ||
106 | } | ||
107 | QString Incidence::durationText4Time( int offset ) | ||
108 | { | ||
109 | int min = offset/60; | ||
110 | int hours = min /60; | ||
111 | min = min % 60; | ||
112 | int days = hours /24; | ||
113 | hours = hours % 24; | ||
114 | |||
115 | if ( doesFloat() || ( min == 0 && hours == 0 ) ) { | ||
116 | if ( days == 1 ) | ||
117 | return "1" + i18n(" day"); | ||
118 | else | ||
119 | return QString::number( days )+ i18n(" days"); | ||
103 | 120 | ||
121 | } | ||
122 | QString message = QString::number ( hours ) +":"; | ||
123 | if ( min < 10 ) message += "0"; | ||
124 | message += QString::number ( min ); | ||
125 | if ( days > 0 ) { | ||
126 | if ( days == 1 ) | ||
127 | message = "1" + i18n(" day") + " "+message; | ||
128 | else | ||
129 | message = QString::number( days )+ i18n(" days") + " "+message; | ||
130 | } | ||
131 | return message; | ||
132 | } | ||
104 | bool Incidence::isHoliday() const | 133 | bool Incidence::isHoliday() const |
105 | { | 134 | { |
106 | return mHoliday; | 135 | return mHoliday; |
107 | } | 136 | } |
108 | bool Incidence::isBirthday() const | 137 | bool Incidence::isBirthday() const |
109 | { | 138 | { |
110 | 139 | ||
111 | return mBirthday ; | 140 | return mBirthday ; |
112 | } | 141 | } |
113 | bool Incidence::isAnniversary() const | 142 | bool Incidence::isAnniversary() const |
114 | { | 143 | { |
115 | return mAnniversary ; | 144 | return mAnniversary ; |
116 | 145 | ||
117 | } | 146 | } |
118 | 147 | ||
119 | bool Incidence::hasRecurrenceID() const | 148 | bool Incidence::hasRecurrenceID() const |
120 | { | 149 | { |
121 | return mHasRecurrenceID; | 150 | return mHasRecurrenceID; |
122 | } | 151 | } |
123 | 152 | ||
124 | void Incidence::setHasRecurrenceID( bool b ) | 153 | void Incidence::setHasRecurrenceID( bool b ) |
125 | { | 154 | { |
126 | mHasRecurrenceID = b; | 155 | mHasRecurrenceID = b; |
127 | } | 156 | } |
128 | 157 | ||
129 | void Incidence::setRecurrenceID(QDateTime d) | 158 | void Incidence::setRecurrenceID(QDateTime d) |
130 | { | 159 | { |
131 | mRecurrenceID = d; | 160 | mRecurrenceID = d; |
132 | mHasRecurrenceID = true; | 161 | mHasRecurrenceID = true; |
133 | updated(); | 162 | updated(); |
134 | } | 163 | } |
135 | QDateTime Incidence::recurrenceID () const | 164 | QDateTime Incidence::recurrenceID () const |
136 | { | 165 | { |
137 | return mRecurrenceID; | 166 | return mRecurrenceID; |
138 | } | 167 | } |
139 | 168 | ||
140 | bool Incidence::cancelled() const | 169 | bool Incidence::cancelled() const |
141 | { | 170 | { |
142 | return mCancelled; | 171 | return mCancelled; |
143 | } | 172 | } |
144 | void Incidence::setCancelled( bool b ) | 173 | void Incidence::setCancelled( bool b ) |
145 | { | 174 | { |
146 | mCancelled = b; | 175 | mCancelled = b; |
147 | updated(); | 176 | updated(); |
148 | } | 177 | } |
149 | bool Incidence::hasStartDate() const | 178 | bool Incidence::hasStartDate() const |
150 | { | 179 | { |
151 | return mHasStartDate; | 180 | return mHasStartDate; |
152 | } | 181 | } |
153 | 182 | ||
154 | void Incidence::setHasStartDate(bool f) | 183 | void Incidence::setHasStartDate(bool f) |
155 | { | 184 | { |
156 | if (mReadOnly) return; | 185 | if (mReadOnly) return; |
157 | mHasStartDate = f; | 186 | mHasStartDate = f; |
158 | updated(); | 187 | updated(); |
159 | } | 188 | } |
160 | 189 | ||
161 | // A string comparison that considers that null and empty are the same | 190 | // A string comparison that considers that null and empty are the same |
162 | static bool stringCompare( const QString& s1, const QString& s2 ) | 191 | static bool stringCompare( const QString& s1, const QString& s2 ) |
163 | { | 192 | { |
164 | if ( s1.isEmpty() && s2.isEmpty() ) | 193 | if ( s1.isEmpty() && s2.isEmpty() ) |
165 | return true; | 194 | return true; |
166 | return s1 == s2; | 195 | return s1 == s2; |
167 | } | 196 | } |
168 | 197 | ||
169 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | 198 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) |
170 | { | 199 | { |
171 | 200 | ||
172 | if( i1.alarms().count() != i2.alarms().count() ) { | 201 | if( i1.alarms().count() != i2.alarms().count() ) { |
173 | return false; // no need to check further | 202 | return false; // no need to check further |
174 | } | 203 | } |
175 | if ( i1.alarms().count() > 0 ) { | 204 | if ( i1.alarms().count() > 0 ) { |
176 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 205 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
177 | { | 206 | { |
178 | qDebug("alarm not equal "); | 207 | qDebug("alarm not equal "); |
179 | return false; | 208 | return false; |
180 | } | 209 | } |
181 | } | 210 | } |
182 | #if 0 | 211 | #if 0 |
183 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 212 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
184 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 213 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
185 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 214 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
186 | if( *a1.current() == *a2.current() ) { | 215 | if( *a1.current() == *a2.current() ) { |
187 | continue; | 216 | continue; |
188 | } | 217 | } |
189 | else { | 218 | else { |
190 | return false; | 219 | return false; |
191 | } | 220 | } |
192 | } | 221 | } |
193 | #endif | 222 | #endif |
194 | 223 | ||
195 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { | 224 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { |
196 | if ( i1.hasRecurrenceID() ) { | 225 | if ( i1.hasRecurrenceID() ) { |
197 | if ( i1.recurrenceID() != i2.recurrenceID() ) | 226 | if ( i1.recurrenceID() != i2.recurrenceID() ) |
198 | return false; | 227 | return false; |
199 | } | 228 | } |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index 8519f01..88df217 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -188,135 +188,136 @@ class Incidence : public IncidenceBase | |||
188 | void setExDates(const char *dates); | 188 | void setExDates(const char *dates); |
189 | /** Add a date to the list of exceptions of the recurrence rule. */ | 189 | /** Add a date to the list of exceptions of the recurrence rule. */ |
190 | void addExDate(const QDate &date); | 190 | void addExDate(const QDate &date); |
191 | 191 | ||
192 | /** returns true if there is an exception for this date in the recurrence | 192 | /** returns true if there is an exception for this date in the recurrence |
193 | rule set, or false otherwise. */ | 193 | rule set, or false otherwise. */ |
194 | bool isException(const QDate &qd) const; | 194 | bool isException(const QDate &qd) const; |
195 | 195 | ||
196 | /** add attachment to this event */ | 196 | /** add attachment to this event */ |
197 | void addAttachment(Attachment *attachment); | 197 | void addAttachment(Attachment *attachment); |
198 | /** remove and delete a specific attachment */ | 198 | /** remove and delete a specific attachment */ |
199 | void deleteAttachment(Attachment *attachment); | 199 | void deleteAttachment(Attachment *attachment); |
200 | /** remove and delete all attachments with this mime type */ | 200 | /** remove and delete all attachments with this mime type */ |
201 | void deleteAttachments(const QString& mime); | 201 | void deleteAttachments(const QString& mime); |
202 | /** return list of all associated attachments */ | 202 | /** return list of all associated attachments */ |
203 | QPtrList<Attachment> attachments() const; | 203 | QPtrList<Attachment> attachments() const; |
204 | /** find a list of attachments with this mime type */ | 204 | /** find a list of attachments with this mime type */ |
205 | QPtrList<Attachment> attachments(const QString& mime) const; | 205 | QPtrList<Attachment> attachments(const QString& mime) const; |
206 | 206 | ||
207 | /** sets the event's status the value specified. See the enumeration | 207 | /** sets the event's status the value specified. See the enumeration |
208 | * above for possible values. */ | 208 | * above for possible values. */ |
209 | void setSecrecy(int); | 209 | void setSecrecy(int); |
210 | /** return the event's secrecy. */ | 210 | /** return the event's secrecy. */ |
211 | int secrecy() const; | 211 | int secrecy() const; |
212 | /** return the event's secrecy in string format. */ | 212 | /** return the event's secrecy in string format. */ |
213 | QString secrecyStr() const; | 213 | QString secrecyStr() const; |
214 | /** return list of all availbale secrecy classes */ | 214 | /** return list of all availbale secrecy classes */ |
215 | static QStringList secrecyList(); | 215 | static QStringList secrecyList(); |
216 | /** return human-readable name of secrecy class */ | 216 | /** return human-readable name of secrecy class */ |
217 | static QString secrecyName(int); | 217 | static QString secrecyName(int); |
218 | 218 | ||
219 | /** returns TRUE if the date specified is one on which the event will | 219 | /** returns TRUE if the date specified is one on which the event will |
220 | * recur. */ | 220 | * recur. */ |
221 | bool recursOn(const QDate &qd) const; | 221 | bool recursOn(const QDate &qd) const; |
222 | 222 | ||
223 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): | 223 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): |
224 | 224 | ||
225 | /** set resources used, such as Office, Car, etc. */ | 225 | /** set resources used, such as Office, Car, etc. */ |
226 | void setResources(const QStringList &resources); | 226 | void setResources(const QStringList &resources); |
227 | /** return list of current resources */ | 227 | /** return list of current resources */ |
228 | QStringList resources() const; | 228 | QStringList resources() const; |
229 | 229 | ||
230 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ | 230 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ |
231 | void setPriority(int priority); | 231 | void setPriority(int priority); |
232 | /** get the event's priority */ | 232 | /** get the event's priority */ |
233 | int priority() const; | 233 | int priority() const; |
234 | 234 | ||
235 | /** All alarms that are associated with this incidence */ | 235 | /** All alarms that are associated with this incidence */ |
236 | QPtrList<Alarm> alarms() const; | 236 | QPtrList<Alarm> alarms() const; |
237 | /** Create a new alarm which is associated with this incidence */ | 237 | /** Create a new alarm which is associated with this incidence */ |
238 | Alarm* newAlarm(); | 238 | Alarm* newAlarm(); |
239 | /** Add an alarm which is associated with this incidence */ | 239 | /** Add an alarm which is associated with this incidence */ |
240 | void addAlarm(Alarm*); | 240 | void addAlarm(Alarm*); |
241 | /** Remove an alarm that is associated with this incidence */ | 241 | /** Remove an alarm that is associated with this incidence */ |
242 | void removeAlarm(Alarm*); | 242 | void removeAlarm(Alarm*); |
243 | /** Remove all alarms that are associated with this incidence */ | 243 | /** Remove all alarms that are associated with this incidence */ |
244 | void clearAlarms(); | 244 | void clearAlarms(); |
245 | /** return whether any alarm associated with this incidence is enabled */ | 245 | /** return whether any alarm associated with this incidence is enabled */ |
246 | bool isAlarmEnabled() const; | 246 | bool isAlarmEnabled() const; |
247 | 247 | ||
248 | /** | 248 | /** |
249 | Return the recurrence rule associated with this incidence. If there is | 249 | Return the recurrence rule associated with this incidence. If there is |
250 | none, returns an appropriate (non-0) object. | 250 | none, returns an appropriate (non-0) object. |
251 | */ | 251 | */ |
252 | Recurrence *recurrence(); | 252 | Recurrence *recurrence(); |
253 | void setRecurrence(Recurrence * r); | 253 | void setRecurrence(Recurrence * r); |
254 | /** | 254 | /** |
255 | Forward to Recurrence::doesRecur(). | 255 | Forward to Recurrence::doesRecur(). |
256 | */ | 256 | */ |
257 | ushort doesRecur() const; | 257 | ushort doesRecur() const; |
258 | 258 | ||
259 | /** set the event's/todo's location. Do _not_ use it with journal */ | 259 | /** set the event's/todo's location. Do _not_ use it with journal */ |
260 | void setLocation(const QString &location); | 260 | void setLocation(const QString &location); |
261 | /** return the event's/todo's location. Do _not_ use it with journal */ | 261 | /** return the event's/todo's location. Do _not_ use it with journal */ |
262 | QString location() const; | 262 | QString location() const; |
263 | /** returns TRUE or FALSE depending on whether the todo has a start date */ | 263 | /** returns TRUE or FALSE depending on whether the todo has a start date */ |
264 | bool hasStartDate() const; | 264 | bool hasStartDate() const; |
265 | /** sets the event's hasStartDate value. */ | 265 | /** sets the event's hasStartDate value. */ |
266 | void setHasStartDate(bool f); | 266 | void setHasStartDate(bool f); |
267 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; | 267 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; |
268 | bool cancelled() const; | 268 | bool cancelled() const; |
269 | void setCancelled( bool b ); | 269 | void setCancelled( bool b ); |
270 | 270 | ||
271 | bool hasRecurrenceID() const; | 271 | bool hasRecurrenceID() const; |
272 | void setHasRecurrenceID( bool b ); | 272 | void setHasRecurrenceID( bool b ); |
273 | 273 | ||
274 | void setRecurrenceID(QDateTime); | 274 | void setRecurrenceID(QDateTime); |
275 | QDateTime recurrenceID () const; | 275 | QDateTime recurrenceID () const; |
276 | QDateTime dtStart() const; | 276 | QDateTime dtStart() const; |
277 | bool isHoliday() const; | 277 | bool isHoliday() const; |
278 | bool isBirthday() const; | 278 | bool isBirthday() const; |
279 | bool isAnniversary() const; | 279 | bool isAnniversary() const; |
280 | QDateTime lastModifiedSub(); | 280 | QDateTime lastModifiedSub(); |
281 | QString recurrenceText() const; | 281 | QString recurrenceText() const; |
282 | void setLastModifiedSubInvalid(); | 282 | void setLastModifiedSubInvalid(); |
283 | 283 | ||
284 | 284 | virtual QString durationText(); | |
285 | QString durationText4Time( int secs ); | ||
285 | Recurrence *mRecurrence; | 286 | Recurrence *mRecurrence; |
286 | protected: | 287 | protected: |
287 | QPtrList<Alarm> mAlarms; | 288 | QPtrList<Alarm> mAlarms; |
288 | QPtrList<Incidence> mRelations; | 289 | QPtrList<Incidence> mRelations; |
289 | QDateTime mRecurrenceID; | 290 | QDateTime mRecurrenceID; |
290 | bool mHasRecurrenceID; | 291 | bool mHasRecurrenceID; |
291 | private: | 292 | private: |
292 | void checkCategories(); | 293 | void checkCategories(); |
293 | bool mHoliday, mBirthday, mAnniversary; | 294 | bool mHoliday, mBirthday, mAnniversary; |
294 | int mRevision; | 295 | int mRevision; |
295 | bool mCancelled; | 296 | bool mCancelled; |
296 | 297 | ||
297 | // base components of jounal, event and todo | 298 | // base components of jounal, event and todo |
298 | QDateTime mCreated; | 299 | QDateTime mCreated; |
299 | QDateTime mLastModifiedSub; | 300 | QDateTime mLastModifiedSub; |
300 | QString mDescription; | 301 | QString mDescription; |
301 | QString mSummary; | 302 | QString mSummary; |
302 | QStringList mCategories; | 303 | QStringList mCategories; |
303 | Incidence *mRelatedTo; | 304 | Incidence *mRelatedTo; |
304 | QString mRelatedToUid; | 305 | QString mRelatedToUid; |
305 | DateList mExDates; | 306 | DateList mExDates; |
306 | QPtrList<Attachment> mAttachments; | 307 | QPtrList<Attachment> mAttachments; |
307 | QStringList mResources; | 308 | QStringList mResources; |
308 | bool mHasStartDate; // if todo has associated start date | 309 | bool mHasStartDate; // if todo has associated start date |
309 | 310 | ||
310 | int mSecrecy; | 311 | int mSecrecy; |
311 | int mPriority; // 1 = highest, 2 = less, etc. | 312 | int mPriority; // 1 = highest, 2 = less, etc. |
312 | 313 | ||
313 | //QPtrList<Alarm> mAlarms; | 314 | //QPtrList<Alarm> mAlarms; |
314 | 315 | ||
315 | QString mLocation; | 316 | QString mLocation; |
316 | }; | 317 | }; |
317 | 318 | ||
318 | bool operator==( const Incidence&, const Incidence& ); | 319 | bool operator==( const Incidence&, const Incidence& ); |
319 | 320 | ||
320 | } | 321 | } |
321 | 322 | ||
322 | #endif | 323 | #endif |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 7bf756a..e4508a0 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -521,96 +521,106 @@ bool Todo::setRecurDates() | |||
521 | return false; | 521 | return false; |
522 | } else { | 522 | } else { |
523 | setHasRecurrenceID( false ); | 523 | setHasRecurrenceID( false ); |
524 | recurrence()->unsetRecurs(); | 524 | recurrence()->unsetRecurs(); |
525 | } | 525 | } |
526 | return true; | 526 | return true; |
527 | } | 527 | } |
528 | void Todo::setPercentComplete(int v) | 528 | void Todo::setPercentComplete(int v) |
529 | { | 529 | { |
530 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { | 530 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { |
531 | if ( !setRecurDates() ) | 531 | if ( !setRecurDates() ) |
532 | v = 0; | 532 | v = 0; |
533 | } | 533 | } |
534 | mPercentComplete = v; | 534 | mPercentComplete = v; |
535 | if ( v != 100 ) | 535 | if ( v != 100 ) |
536 | mHasCompletedDate = false; | 536 | mHasCompletedDate = false; |
537 | updated(); | 537 | updated(); |
538 | } | 538 | } |
539 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 539 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
540 | { | 540 | { |
541 | *ok = false; | 541 | *ok = false; |
542 | if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) { | 542 | if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) { |
543 | return QDateTime (); | 543 | return QDateTime (); |
544 | } | 544 | } |
545 | // if the recurring todo is set to complete and requested time < start time of todo | 545 | // if the recurring todo is set to complete and requested time < start time of todo |
546 | // we want to get the alarm. | 546 | // we want to get the alarm. |
547 | bool iscompleted = isCompleted(); | 547 | bool iscompleted = isCompleted(); |
548 | if ( iscompleted && doesRecur() ) { | 548 | if ( iscompleted && doesRecur() ) { |
549 | Todo * to = (Todo*) this; | 549 | Todo * to = (Todo*) this; |
550 | to->checkSetCompletedFalse(); | 550 | to->checkSetCompletedFalse(); |
551 | iscompleted = isCompleted(); | 551 | iscompleted = isCompleted(); |
552 | if ( hasStartDate() && start_dt < dtStart() ){ | 552 | if ( hasStartDate() && start_dt < dtStart() ){ |
553 | iscompleted = false; | 553 | iscompleted = false; |
554 | } | 554 | } |
555 | } | 555 | } |
556 | if ( iscompleted ) { | 556 | if ( iscompleted ) { |
557 | return QDateTime (); | 557 | return QDateTime (); |
558 | } | 558 | } |
559 | QDateTime incidenceStart; | 559 | QDateTime incidenceStart; |
560 | incidenceStart = dtDue(); | 560 | incidenceStart = dtDue(); |
561 | bool enabled = false; | 561 | bool enabled = false; |
562 | Alarm* alarm; | 562 | Alarm* alarm; |
563 | int off = 0; | 563 | int off = 0; |
564 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 564 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
565 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 565 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
566 | // *ok = false; | 566 | // *ok = false; |
567 | // return incidenceStart; | 567 | // return incidenceStart; |
568 | // } | 568 | // } |
569 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 569 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
570 | if (alarm->enabled()) { | 570 | if (alarm->enabled()) { |
571 | if ( alarm->hasTime () ) { | 571 | if ( alarm->hasTime () ) { |
572 | if ( alarm->time() < alarmStart ) { | 572 | if ( alarm->time() < alarmStart ) { |
573 | alarmStart = alarm->time(); | 573 | alarmStart = alarm->time(); |
574 | enabled = true; | 574 | enabled = true; |
575 | off = alarmStart.secsTo( incidenceStart ); | 575 | off = alarmStart.secsTo( incidenceStart ); |
576 | } | 576 | } |
577 | 577 | ||
578 | } else { | 578 | } else { |
579 | int secs = alarm->startOffset().asSeconds(); | 579 | int secs = alarm->startOffset().asSeconds(); |
580 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 580 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
581 | alarmStart = incidenceStart.addSecs( secs ); | 581 | alarmStart = incidenceStart.addSecs( secs ); |
582 | enabled = true; | 582 | enabled = true; |
583 | off = -secs; | 583 | off = -secs; |
584 | } | 584 | } |
585 | } | 585 | } |
586 | } | 586 | } |
587 | } | 587 | } |
588 | if ( enabled ) { | 588 | if ( enabled ) { |
589 | if ( alarmStart > start_dt ) { | 589 | if ( alarmStart > start_dt ) { |
590 | *ok = true; | 590 | *ok = true; |
591 | * offset = off; | 591 | * offset = off; |
592 | return alarmStart; | 592 | return alarmStart; |
593 | } | 593 | } |
594 | } | 594 | } |
595 | *ok = false; | 595 | *ok = false; |
596 | return QDateTime (); | 596 | return QDateTime (); |
597 | 597 | ||
598 | } | 598 | } |
599 | 599 | ||
600 | void Todo::checkSetCompletedFalse() | 600 | void Todo::checkSetCompletedFalse() |
601 | { | 601 | { |
602 | if ( !mHasRecurrenceID ) { | 602 | if ( !mHasRecurrenceID ) { |
603 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); | 603 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); |
604 | return; | 604 | return; |
605 | } | 605 | } |
606 | // qDebug("Todo::checkSetCompletedFalse()"); | 606 | // qDebug("Todo::checkSetCompletedFalse()"); |
607 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 607 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
608 | if ( mPercentComplete == 100 ) { | 608 | if ( mPercentComplete == 100 ) { |
609 | QDateTime dt = QDateTime::currentDateTime(); | 609 | QDateTime dt = QDateTime::currentDateTime(); |
610 | if ( dt > mDtStart && dt > mRecurrenceID ) { | 610 | if ( dt > mDtStart && dt > mRecurrenceID ) { |
611 | qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 611 | qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
612 | setCompleted( false ); | 612 | setCompleted( false ); |
613 | qDebug("Todo::checkSetCompletedFalse "); | 613 | qDebug("Todo::checkSetCompletedFalse "); |
614 | } | 614 | } |
615 | } | 615 | } |
616 | } | 616 | } |
617 | QString Todo::durationText() | ||
618 | { | ||
619 | if ( mHasDueDate && hasStartDate() ) { | ||
620 | int sec = dtStart().secsTo( dtDue() ); | ||
621 | if ( doesFloat() ) | ||
622 | sec += 86400; | ||
623 | return durationText4Time( sec ); | ||
624 | } | ||
625 | return "---"; | ||
626 | } | ||
diff --git a/libkcal/todo.h b/libkcal/todo.h index 425dfad..7feb32e 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -37,119 +37,120 @@ namespace KCal { | |||
37 | Q_OBJECT | 37 | Q_OBJECT |
38 | public: | 38 | public: |
39 | Todo(); | 39 | Todo(); |
40 | Todo(const Todo &); | 40 | Todo(const Todo &); |
41 | ~Todo(); | 41 | ~Todo(); |
42 | typedef ListBase<Todo> List; | 42 | typedef ListBase<Todo> List; |
43 | QCString type() const { return "Todo"; } | 43 | QCString type() const { return "Todo"; } |
44 | IncTypeID typeID() const { return todoID; } | 44 | IncTypeID typeID() const { return todoID; } |
45 | 45 | ||
46 | /** Return an exact copy of this todo. */ | 46 | /** Return an exact copy of this todo. */ |
47 | Incidence *clone(); | 47 | Incidence *clone(); |
48 | QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const; | 48 | QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const; |
49 | 49 | ||
50 | /** for setting the todo's due date/time with a QDateTime. */ | 50 | /** for setting the todo's due date/time with a QDateTime. */ |
51 | void setDtDue(const QDateTime &dtDue); | 51 | void setDtDue(const QDateTime &dtDue); |
52 | /** returns an event's Due date/time as a QDateTime. */ | 52 | /** returns an event's Due date/time as a QDateTime. */ |
53 | QDateTime dtDue() const; | 53 | QDateTime dtDue() const; |
54 | /** returns an event's due time as a string formatted according to the | 54 | /** returns an event's due time as a string formatted according to the |
55 | users locale settings */ | 55 | users locale settings */ |
56 | QString dtDueTimeStr() const; | 56 | QString dtDueTimeStr() const; |
57 | /** returns an event's due date as a string formatted according to the | 57 | /** returns an event's due date as a string formatted according to the |
58 | users locale settings */ | 58 | users locale settings */ |
59 | QString dtDueDateStr(bool shortfmt=true) const; | 59 | QString dtDueDateStr(bool shortfmt=true) const; |
60 | /** returns an event's due date and time as a string formatted according | 60 | /** returns an event's due date and time as a string formatted according |
61 | to the users locale settings */ | 61 | to the users locale settings */ |
62 | QString dtDueStr(bool shortfmt=true) const; | 62 | QString dtDueStr(bool shortfmt=true) const; |
63 | 63 | ||
64 | /** returns TRUE or FALSE depending on whether the todo has a due date */ | 64 | /** returns TRUE or FALSE depending on whether the todo has a due date */ |
65 | bool hasDueDate() const; | 65 | bool hasDueDate() const; |
66 | /** sets the event's hasDueDate value. */ | 66 | /** sets the event's hasDueDate value. */ |
67 | void setHasDueDate(bool f); | 67 | void setHasDueDate(bool f); |
68 | 68 | ||
69 | /* | 69 | /* |
70 | Looks for a subtodo (including itself ) which is not complete and is | 70 | Looks for a subtodo (including itself ) which is not complete and is |
71 | - overdue, or | 71 | - overdue, or |
72 | - due today. | 72 | - due today. |
73 | It returns 0 for nothing found, | 73 | It returns 0 for nothing found, |
74 | 1 for found a todo which is due today and no overdue found | 74 | 1 for found a todo which is due today and no overdue found |
75 | 2 for found a overdue todo | 75 | 2 for found a overdue todo |
76 | */ | 76 | */ |
77 | int hasDueSubTodo( bool checkSubtodos = true ); | 77 | int hasDueSubTodo( bool checkSubtodos = true ); |
78 | /* same as above, but a specific date can be specified*/ | 78 | /* same as above, but a specific date can be specified*/ |
79 | int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ); | 79 | int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ); |
80 | 80 | ||
81 | 81 | ||
82 | /** sets the event's status to the string specified. The string | 82 | /** sets the event's status to the string specified. The string |
83 | * must be a recognized value for the status field, i.e. a string | 83 | * must be a recognized value for the status field, i.e. a string |
84 | * equivalent of the possible status enumerations previously described. */ | 84 | * equivalent of the possible status enumerations previously described. */ |
85 | // void setStatus(const QString &statStr); | 85 | // void setStatus(const QString &statStr); |
86 | /** sets the event's status to the value specified. See the enumeration | 86 | /** sets the event's status to the value specified. See the enumeration |
87 | * above for possible values. */ | 87 | * above for possible values. */ |
88 | // void setStatus(int); | 88 | // void setStatus(int); |
89 | /** return the event's status. */ | 89 | /** return the event's status. */ |
90 | // int status() const; | 90 | // int status() const; |
91 | /** return the event's status in string format. */ | 91 | /** return the event's status in string format. */ |
92 | // QString statusStr() const; | 92 | // QString statusStr() const; |
93 | 93 | ||
94 | /** return, if this todo is completed */ | 94 | /** return, if this todo is completed */ |
95 | bool isCompleted() const; | 95 | bool isCompleted() const; |
96 | /** set completed state of this todo */ | 96 | /** set completed state of this todo */ |
97 | void setCompleted(bool); | 97 | void setCompleted(bool); |
98 | 98 | ||
99 | /** | 99 | /** |
100 | Return how many percent of the task are completed. Returns a value | 100 | Return how many percent of the task are completed. Returns a value |
101 | between 0 and 100. | 101 | between 0 and 100. |
102 | */ | 102 | */ |
103 | int percentComplete() const; | 103 | int percentComplete() const; |
104 | /** | 104 | /** |
105 | Set how many percent of the task are completed. Valid values are in the | 105 | Set how many percent of the task are completed. Valid values are in the |
106 | range from 0 to 100. | 106 | range from 0 to 100. |
107 | */ | 107 | */ |
108 | void setPercentComplete(int); | 108 | void setPercentComplete(int); |
109 | 109 | ||
110 | /** return date and time when todo was completed */ | 110 | /** return date and time when todo was completed */ |
111 | QDateTime completed() const; | 111 | QDateTime completed() const; |
112 | QString completedStr(bool shortF = true) const; | 112 | QString completedStr(bool shortF = true) const; |
113 | /** set date and time of completion */ | 113 | /** set date and time of completion */ |
114 | void setCompleted(const QDateTime &completed); | 114 | void setCompleted(const QDateTime &completed); |
115 | 115 | ||
116 | /** Return true, if todo has a date associated with completion */ | 116 | /** Return true, if todo has a date associated with completion */ |
117 | bool hasCompletedDate() const; | 117 | bool hasCompletedDate() const; |
118 | bool contains ( Todo*); | 118 | bool contains ( Todo*); |
119 | void checkSetCompletedFalse(); | 119 | void checkSetCompletedFalse(); |
120 | bool setRecurDates(); | 120 | bool setRecurDates(); |
121 | bool isRunning() {return mRunning;} | 121 | bool isRunning() {return mRunning;} |
122 | bool hasRunningSub(); | 122 | bool hasRunningSub(); |
123 | void setRunning( bool ); | 123 | void setRunning( bool ); |
124 | void setRunningFalse( QString ); | 124 | void setRunningFalse( QString ); |
125 | void stopRunning(); | 125 | void stopRunning(); |
126 | int runTime(); | 126 | int runTime(); |
127 | QDateTime runStart () const { return mRunStart;} | 127 | QDateTime runStart () const { return mRunStart;} |
128 | void saveRunningInfo( QString comment, QDateTime start, QDateTime end ); | 128 | void saveRunningInfo( QString comment, QDateTime start, QDateTime end ); |
129 | public slots: | 129 | public slots: |
130 | void saveRunningInfoToFile( QString st ); | 130 | void saveRunningInfoToFile( QString st ); |
131 | void saveRunningInfoToFile( ); | 131 | void saveRunningInfoToFile( ); |
132 | void saveParents(); | 132 | void saveParents(); |
133 | QString durationText(); | ||
133 | private: | 134 | private: |
134 | bool mRunning; | 135 | bool mRunning; |
135 | QTimer * mRunSaveTimer; | 136 | QTimer * mRunSaveTimer; |
136 | QDateTime mRunStart; | 137 | QDateTime mRunStart; |
137 | QDateTime mRunEnd; | 138 | QDateTime mRunEnd; |
138 | bool accept(Visitor &v) { return v.visit(this); } | 139 | bool accept(Visitor &v) { return v.visit(this); } |
139 | 140 | ||
140 | QDateTime mDtDue; // due date of todo | 141 | QDateTime mDtDue; // due date of todo |
141 | 142 | ||
142 | bool mHasDueDate; // if todo has associated due date | 143 | bool mHasDueDate; // if todo has associated due date |
143 | 144 | ||
144 | // int mStatus; // confirmed/delegated/tentative/etc | 145 | // int mStatus; // confirmed/delegated/tentative/etc |
145 | 146 | ||
146 | QDateTime mCompleted; | 147 | QDateTime mCompleted; |
147 | bool mHasCompletedDate; | 148 | bool mHasCompletedDate; |
148 | 149 | ||
149 | int mPercentComplete; | 150 | int mPercentComplete; |
150 | }; | 151 | }; |
151 | 152 | ||
152 | bool operator==( const Todo&, const Todo& ); | 153 | bool operator==( const Todo&, const Todo& ); |
153 | } | 154 | } |
154 | 155 | ||
155 | #endif | 156 | #endif |