author | zautrix <zautrix> | 2005-06-08 10:34:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-08 10:34:22 (UTC) |
commit | 793d117812b4da36c9c11d90cccba347cbc6e208 (patch) (unidiff) | |
tree | 5bc77e2b7a32a541c2a3b3c3d6d50f873216deef /libkcal | |
parent | 39d84e2fc3099bd5d7596e8be5dc6783826cec01 (diff) | |
download | kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.zip kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.gz kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.bz2 |
changed incidence type to a faster access method
-rw-r--r-- | libkcal/calendar.cpp | 6 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 6 | ||||
-rw-r--r-- | libkcal/calfilter.cpp | 6 | ||||
-rw-r--r-- | libkcal/event.h | 1 | ||||
-rw-r--r-- | libkcal/freebusy.h | 1 | ||||
-rw-r--r-- | libkcal/icalformat.cpp | 4 | ||||
-rw-r--r-- | libkcal/icalformatimpl.cpp | 6 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 6 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 2 | ||||
-rw-r--r-- | libkcal/journal.h | 1 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 4 | ||||
-rw-r--r-- | libkcal/todo.cpp | 5 | ||||
-rw-r--r-- | libkcal/todo.h | 1 |
13 files changed, 26 insertions, 23 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index ed39ddb..7e8e2c5 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -332,53 +332,53 @@ QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, | |||
332 | QPtrList<Event> Calendar::events() | 332 | QPtrList<Event> Calendar::events() |
333 | { | 333 | { |
334 | QPtrList<Event> el = rawEvents(); | 334 | QPtrList<Event> el = rawEvents(); |
335 | mFilter->apply(&el); | 335 | mFilter->apply(&el); |
336 | return el; | 336 | return el; |
337 | } | 337 | } |
338 | void Calendar::addIncidenceBranch(Incidence *i) | 338 | void Calendar::addIncidenceBranch(Incidence *i) |
339 | { | 339 | { |
340 | addIncidence( i ); | 340 | addIncidence( i ); |
341 | Incidence * inc; | 341 | Incidence * inc; |
342 | QPtrList<Incidence> Relations = i->relations(); | 342 | QPtrList<Incidence> Relations = i->relations(); |
343 | for (inc=Relations.first();inc;inc=Relations.next()) { | 343 | for (inc=Relations.first();inc;inc=Relations.next()) { |
344 | addIncidenceBranch( inc ); | 344 | addIncidenceBranch( inc ); |
345 | } | 345 | } |
346 | } | 346 | } |
347 | 347 | ||
348 | bool Calendar::addIncidence(Incidence *i) | 348 | bool Calendar::addIncidence(Incidence *i) |
349 | { | 349 | { |
350 | Incidence::AddVisitor<Calendar> v(this); | 350 | Incidence::AddVisitor<Calendar> v(this); |
351 | 351 | ||
352 | return i->accept(v); | 352 | return i->accept(v); |
353 | } | 353 | } |
354 | void Calendar::deleteIncidence(Incidence *in) | 354 | void Calendar::deleteIncidence(Incidence *in) |
355 | { | 355 | { |
356 | if ( in->type() == "Event" ) | 356 | if ( in->typeID() == eventID ) |
357 | deleteEvent( (Event*) in ); | 357 | deleteEvent( (Event*) in ); |
358 | else if ( in->type() =="Todo" ) | 358 | else if ( in->typeID() == todoID ) |
359 | deleteTodo( (Todo*) in); | 359 | deleteTodo( (Todo*) in); |
360 | else if ( in->type() =="Journal" ) | 360 | else if ( in->typeID() == journalID ) |
361 | deleteJournal( (Journal*) in ); | 361 | deleteJournal( (Journal*) in ); |
362 | } | 362 | } |
363 | 363 | ||
364 | Incidence* Calendar::incidence( const QString& uid ) | 364 | Incidence* Calendar::incidence( const QString& uid ) |
365 | { | 365 | { |
366 | Incidence* i; | 366 | Incidence* i; |
367 | 367 | ||
368 | if( (i = todo( uid )) != 0 ) | 368 | if( (i = todo( uid )) != 0 ) |
369 | return i; | 369 | return i; |
370 | if( (i = event( uid )) != 0 ) | 370 | if( (i = event( uid )) != 0 ) |
371 | return i; | 371 | return i; |
372 | if( (i = journal( uid )) != 0 ) | 372 | if( (i = journal( uid )) != 0 ) |
373 | return i; | 373 | return i; |
374 | 374 | ||
375 | return 0; | 375 | return 0; |
376 | } | 376 | } |
377 | 377 | ||
378 | QPtrList<Todo> Calendar::todos() | 378 | QPtrList<Todo> Calendar::todos() |
379 | { | 379 | { |
380 | QPtrList<Todo> tl = rawTodos(); | 380 | QPtrList<Todo> tl = rawTodos(); |
381 | mFilter->apply( &tl ); | 381 | mFilter->apply( &tl ); |
382 | return tl; | 382 | return tl; |
383 | } | 383 | } |
384 | 384 | ||
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index bc76c0b..fe74052 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -437,80 +437,76 @@ QDateTime CalendarLocal::nextAlarm( int daysTo ) | |||
437 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 437 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
438 | if ( ok ) { | 438 | if ( ok ) { |
439 | if ( next < nextA ) { | 439 | if ( next < nextA ) { |
440 | nextA = next; | 440 | nextA = next; |
441 | found = true; | 441 | found = true; |
442 | mNextSummary = t->summary(); | 442 | mNextSummary = t->summary(); |
443 | mNextAlarmEventDateTime = next.addSecs(offset ); | 443 | mNextAlarmEventDateTime = next.addSecs(offset ); |
444 | mNextAlarmIncidence = (Incidence *) t; | 444 | mNextAlarmIncidence = (Incidence *) t; |
445 | } | 445 | } |
446 | } | 446 | } |
447 | } | 447 | } |
448 | if ( mNextAlarmIncidence ) { | 448 | if ( mNextAlarmIncidence ) { |
449 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 449 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
450 | mNextAlarmDateTime = nextA; | 450 | mNextAlarmDateTime = nextA; |
451 | } | 451 | } |
452 | return nextA; | 452 | return nextA; |
453 | } | 453 | } |
454 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) | 454 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) |
455 | { | 455 | { |
456 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); | 456 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); |
457 | } | 457 | } |
458 | 458 | ||
459 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) | 459 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) |
460 | { | 460 | { |
461 | kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " | 461 | |
462 | << to.toString() << ")\n"; | ||
463 | |||
464 | Alarm::List alarms; | 462 | Alarm::List alarms; |
465 | 463 | ||
466 | Event *e; | 464 | Event *e; |
467 | 465 | ||
468 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 466 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
469 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); | 467 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); |
470 | else appendAlarms( alarms, e, from, to ); | 468 | else appendAlarms( alarms, e, from, to ); |
471 | } | 469 | } |
472 | 470 | ||
473 | Todo *t; | 471 | Todo *t; |
474 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 472 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
475 | appendAlarms( alarms, t, from, to ); | 473 | appendAlarms( alarms, t, from, to ); |
476 | } | 474 | } |
477 | 475 | ||
478 | return alarms; | 476 | return alarms; |
479 | } | 477 | } |
480 | 478 | ||
481 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, | 479 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, |
482 | const QDateTime &from, const QDateTime &to ) | 480 | const QDateTime &from, const QDateTime &to ) |
483 | { | 481 | { |
484 | QPtrList<Alarm> alarmList = incidence->alarms(); | 482 | QPtrList<Alarm> alarmList = incidence->alarms(); |
485 | Alarm *alarm; | 483 | Alarm *alarm; |
486 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 484 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
487 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() | 485 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() |
488 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; | 486 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; |
489 | if ( alarm->enabled() ) { | 487 | if ( alarm->enabled() ) { |
490 | if ( alarm->time() >= from && alarm->time() <= to ) { | 488 | if ( alarm->time() >= from && alarm->time() <= to ) { |
491 | kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary() | ||
492 | << "': " << alarm->time().toString() << endl; | ||
493 | alarms.append( alarm ); | 489 | alarms.append( alarm ); |
494 | } | 490 | } |
495 | } | 491 | } |
496 | } | 492 | } |
497 | } | 493 | } |
498 | 494 | ||
499 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, | 495 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, |
500 | Incidence *incidence, | 496 | Incidence *incidence, |
501 | const QDateTime &from, | 497 | const QDateTime &from, |
502 | const QDateTime &to ) | 498 | const QDateTime &to ) |
503 | { | 499 | { |
504 | 500 | ||
505 | QPtrList<Alarm> alarmList = incidence->alarms(); | 501 | QPtrList<Alarm> alarmList = incidence->alarms(); |
506 | Alarm *alarm; | 502 | Alarm *alarm; |
507 | QDateTime qdt; | 503 | QDateTime qdt; |
508 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 504 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
509 | if (incidence->recursOn(from.date())) { | 505 | if (incidence->recursOn(from.date())) { |
510 | qdt.setTime(alarm->time().time()); | 506 | qdt.setTime(alarm->time().time()); |
511 | qdt.setDate(from.date()); | 507 | qdt.setDate(from.date()); |
512 | } | 508 | } |
513 | else qdt = alarm->time(); | 509 | else qdt = alarm->time(); |
514 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); | 510 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); |
515 | if ( alarm->enabled() ) { | 511 | if ( alarm->enabled() ) { |
516 | if ( qdt >= from && qdt <= to ) { | 512 | if ( qdt >= from && qdt <= to ) { |
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp index c425dfc..20078a7 100644 --- a/libkcal/calfilter.cpp +++ b/libkcal/calfilter.cpp | |||
@@ -57,53 +57,53 @@ void CalFilter::apply(QPtrList<Event> *eventlist) | |||
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | // kdDebug(5800) << "CalFilter::apply() done" << endl; | 60 | // kdDebug(5800) << "CalFilter::apply() done" << endl; |
61 | } | 61 | } |
62 | 62 | ||
63 | // TODO: avoid duplicating apply() code | 63 | // TODO: avoid duplicating apply() code |
64 | void CalFilter::apply(QPtrList<Todo> *eventlist) | 64 | void CalFilter::apply(QPtrList<Todo> *eventlist) |
65 | { | 65 | { |
66 | if (!mEnabled) return; | 66 | if (!mEnabled) return; |
67 | Todo *event = eventlist->first(); | 67 | Todo *event = eventlist->first(); |
68 | while(event) { | 68 | while(event) { |
69 | if (!filterTodo(event)) { | 69 | if (!filterTodo(event)) { |
70 | eventlist->remove(); | 70 | eventlist->remove(); |
71 | event = eventlist->current(); | 71 | event = eventlist->current(); |
72 | } else { | 72 | } else { |
73 | event = eventlist->next(); | 73 | event = eventlist->next(); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | // kdDebug(5800) << "CalFilter::apply() done" << endl; | 77 | // kdDebug(5800) << "CalFilter::apply() done" << endl; |
78 | } | 78 | } |
79 | bool CalFilter::filterCalendarItem(Incidence *in) | 79 | bool CalFilter::filterCalendarItem(Incidence *in) |
80 | { | 80 | { |
81 | if ( in->type() == "Event" ) | 81 | if ( in->typeID() == eventID ) |
82 | return filterEvent( (Event*) in ); | 82 | return filterEvent( (Event*) in ); |
83 | else if ( in->type() =="Todo" ) | 83 | else if ( in->typeID() == todoID ) |
84 | return filterTodo( (Todo*) in); | 84 | return filterTodo( (Todo*) in); |
85 | else if ( in->type() =="Journal" ) | 85 | else if ( in->typeID () == journalID ) |
86 | return filterJournal( (Journal*) in ); | 86 | return filterJournal( (Journal*) in ); |
87 | return false; | 87 | return false; |
88 | } | 88 | } |
89 | bool CalFilter::filterEvent(Event *event) | 89 | bool CalFilter::filterEvent(Event *event) |
90 | { | 90 | { |
91 | if (mCriteria & HideEvents) | 91 | if (mCriteria & HideEvents) |
92 | return false; | 92 | return false; |
93 | if (mCriteria & HideRecurring) { | 93 | if (mCriteria & HideRecurring) { |
94 | if (event->recurrence()->doesRecur()) return false; | 94 | if (event->recurrence()->doesRecur()) return false; |
95 | } | 95 | } |
96 | 96 | ||
97 | return filterIncidence(event); | 97 | return filterIncidence(event); |
98 | } | 98 | } |
99 | bool CalFilter::filterJournal(Journal *j) | 99 | bool CalFilter::filterJournal(Journal *j) |
100 | { | 100 | { |
101 | if (mCriteria & HideJournals) | 101 | if (mCriteria & HideJournals) |
102 | return false; | 102 | return false; |
103 | return true; | 103 | return true; |
104 | } | 104 | } |
105 | bool CalFilter::filterTodo(Todo *todo) | 105 | bool CalFilter::filterTodo(Todo *todo) |
106 | { | 106 | { |
107 | if (mCriteria & HideTodos) | 107 | if (mCriteria & HideTodos) |
108 | return false; | 108 | return false; |
109 | if (mCriteria & HideCompleted) { | 109 | if (mCriteria & HideCompleted) { |
diff --git a/libkcal/event.h b/libkcal/event.h index 8729956..287d403 100644 --- a/libkcal/event.h +++ b/libkcal/event.h | |||
@@ -19,48 +19,49 @@ | |||
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 | 41 | ||
42 | QCString type() const { return "Event"; } | 42 | QCString type() const { return "Event"; } |
43 | IncTypeID typeID() const { return eventID; } | ||
43 | 44 | ||
44 | Incidence *clone(); | 45 | Incidence *clone(); |
45 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; | 46 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; |
46 | 47 | ||
47 | /** for setting an event's ending date/time with a QDateTime. */ | 48 | /** for setting an event's ending date/time with a QDateTime. */ |
48 | void setDtEnd(const QDateTime &dtEnd); | 49 | void setDtEnd(const QDateTime &dtEnd); |
49 | /** Return the event's ending date/time as a QDateTime. */ | 50 | /** Return the event's ending date/time as a QDateTime. */ |
50 | virtual QDateTime dtEnd() const; | 51 | virtual QDateTime dtEnd() const; |
51 | /** returns an event's end time as a string formatted according to the | 52 | /** returns an event's end time as a string formatted according to the |
52 | users locale settings */ | 53 | users locale settings */ |
53 | QString dtEndTimeStr() const; | 54 | QString dtEndTimeStr() const; |
54 | /** returns an event's end date as a string formatted according to the | 55 | /** returns an event's end date as a string formatted according to the |
55 | users locale settings */ | 56 | users locale settings */ |
56 | QString dtEndDateStr(bool shortfmt=true) const; | 57 | QString dtEndDateStr(bool shortfmt=true) const; |
57 | /** returns an event's end date and time as a string formatted according | 58 | /** returns an event's end date and time as a string formatted according |
58 | to the users locale settings */ | 59 | to the users locale settings */ |
59 | QString dtEndStr(bool shortfmt=true) const; | 60 | QString dtEndStr(bool shortfmt=true) const; |
60 | void setHasEndDate(bool); | 61 | void setHasEndDate(bool); |
61 | /** Return whether the event has an end date/time. */ | 62 | /** Return whether the event has an end date/time. */ |
62 | bool hasEndDate() const; | 63 | bool hasEndDate() const; |
63 | 64 | ||
64 | /** Return true if the event spans multiple days, otherwise return false. */ | 65 | /** Return true if the event spans multiple days, otherwise return false. */ |
65 | bool isMultiDay() const; | 66 | bool isMultiDay() const; |
66 | 67 | ||
diff --git a/libkcal/freebusy.h b/libkcal/freebusy.h index 054feda..d741c72 100644 --- a/libkcal/freebusy.h +++ b/libkcal/freebusy.h | |||
@@ -27,46 +27,47 @@ | |||
27 | #include <qvaluelist.h> | 27 | #include <qvaluelist.h> |
28 | #include <qptrlist.h> | 28 | #include <qptrlist.h> |
29 | 29 | ||
30 | #include "period.h" | 30 | #include "period.h" |
31 | #include "calendar.h" | 31 | #include "calendar.h" |
32 | 32 | ||
33 | #include "incidencebase.h" | 33 | #include "incidencebase.h" |
34 | 34 | ||
35 | namespace KCal { | 35 | namespace KCal { |
36 | 36 | ||
37 | /** | 37 | /** |
38 | This class provides information about free/busy time of a calendar user. | 38 | This class provides information about free/busy time of a calendar user. |
39 | */ | 39 | */ |
40 | class FreeBusy : public IncidenceBase | 40 | class FreeBusy : public IncidenceBase |
41 | { | 41 | { |
42 | public: | 42 | public: |
43 | FreeBusy(); | 43 | FreeBusy(); |
44 | FreeBusy(const QDateTime &start, const QDateTime &end); | 44 | FreeBusy(const QDateTime &start, const QDateTime &end); |
45 | FreeBusy(Calendar *calendar, const QDateTime &start, const QDateTime &end); | 45 | FreeBusy(Calendar *calendar, const QDateTime &start, const QDateTime &end); |
46 | FreeBusy(QValueList<Period> busyPeriods); | 46 | FreeBusy(QValueList<Period> busyPeriods); |
47 | 47 | ||
48 | ~FreeBusy(); | 48 | ~FreeBusy(); |
49 | 49 | ||
50 | QCString type() const { return "FreeBusy"; } | 50 | QCString type() const { return "FreeBusy"; } |
51 | IncTypeID typeID() const { return freebusyID; } | ||
51 | 52 | ||
52 | virtual QDateTime dtEnd() const; | 53 | virtual QDateTime dtEnd() const; |
53 | bool setDtEnd( const QDateTime &end ); | 54 | bool setDtEnd( const QDateTime &end ); |
54 | 55 | ||
55 | QValueList<Period> busyPeriods() const; | 56 | QValueList<Period> busyPeriods() const; |
56 | 57 | ||
57 | void addPeriod(const QDateTime &start, const QDateTime &end); | 58 | void addPeriod(const QDateTime &start, const QDateTime &end); |
58 | void sortList(); | 59 | void sortList(); |
59 | 60 | ||
60 | private: | 61 | private: |
61 | 62 | ||
62 | //This is used for creating a freebusy object for the current user | 63 | //This is used for creating a freebusy object for the current user |
63 | bool addLocalPeriod(const QDateTime &start, const QDateTime &end); | 64 | bool addLocalPeriod(const QDateTime &start, const QDateTime &end); |
64 | 65 | ||
65 | QDateTime mDtEnd; | 66 | QDateTime mDtEnd; |
66 | QValueList<Period> mBusyPeriods; | 67 | QValueList<Period> mBusyPeriods; |
67 | Calendar *mCalendar; | 68 | Calendar *mCalendar; |
68 | }; | 69 | }; |
69 | 70 | ||
70 | } | 71 | } |
71 | 72 | ||
72 | #endif | 73 | #endif |
diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp index 3a2aac6..d9fe40b 100644 --- a/libkcal/icalformat.cpp +++ b/libkcal/icalformat.cpp | |||
@@ -363,54 +363,54 @@ ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal, | |||
363 | method = Scheduler::Counter; | 363 | method = Scheduler::Counter; |
364 | break; | 364 | break; |
365 | case ICAL_METHOD_DECLINECOUNTER: | 365 | case ICAL_METHOD_DECLINECOUNTER: |
366 | method = Scheduler::Declinecounter; | 366 | method = Scheduler::Declinecounter; |
367 | break; | 367 | break; |
368 | default: | 368 | default: |
369 | method = Scheduler::NoMethod; | 369 | method = Scheduler::NoMethod; |
370 | kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl; | 370 | kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl; |
371 | break; | 371 | break; |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | if (!icalrestriction_check(message)) { | 375 | if (!icalrestriction_check(message)) { |
376 | setException(new ErrorFormat(ErrorFormat::Restriction, | 376 | setException(new ErrorFormat(ErrorFormat::Restriction, |
377 | Scheduler::translatedMethodName(method) + ": " + | 377 | Scheduler::translatedMethodName(method) + ": " + |
378 | mImpl->extractErrorProperty(c))); | 378 | mImpl->extractErrorProperty(c))); |
379 | return 0; | 379 | return 0; |
380 | } | 380 | } |
381 | 381 | ||
382 | icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal); | 382 | icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal); |
383 | 383 | ||
384 | Incidence *existingIncidence = cal->event(incidence->uid()); | 384 | Incidence *existingIncidence = cal->event(incidence->uid()); |
385 | if (existingIncidence) { | 385 | if (existingIncidence) { |
386 | // TODO: check, if cast is required, or if it can be done by virtual funcs. | 386 | // TODO: check, if cast is required, or if it can be done by virtual funcs. |
387 | if (existingIncidence->type() == "Todo") { | 387 | if (existingIncidence->typeID() == todoID ) { |
388 | Todo *todo = static_cast<Todo *>(existingIncidence); | 388 | Todo *todo = static_cast<Todo *>(existingIncidence); |
389 | icalcomponent_add_component(calendarComponent, | 389 | icalcomponent_add_component(calendarComponent, |
390 | mImpl->writeTodo(todo)); | 390 | mImpl->writeTodo(todo)); |
391 | } | 391 | } |
392 | if (existingIncidence->type() == "Event") { | 392 | if (existingIncidence->typeID() == eventID ) { |
393 | Event *event = static_cast<Event *>(existingIncidence); | 393 | Event *event = static_cast<Event *>(existingIncidence); |
394 | icalcomponent_add_component(calendarComponent, | 394 | icalcomponent_add_component(calendarComponent, |
395 | mImpl->writeEvent(event)); | 395 | mImpl->writeEvent(event)); |
396 | } | 396 | } |
397 | } else { | 397 | } else { |
398 | calendarComponent = 0; | 398 | calendarComponent = 0; |
399 | } | 399 | } |
400 | qDebug("icalclassify commented out "); | 400 | qDebug("icalclassify commented out "); |
401 | ScheduleMessage::Status status; | 401 | ScheduleMessage::Status status; |
402 | #if 0 | 402 | #if 0 |
403 | 403 | ||
404 | icalclass result = icalclassify(message,calendarComponent,(char *)""); | 404 | icalclass result = icalclassify(message,calendarComponent,(char *)""); |
405 | 405 | ||
406 | 406 | ||
407 | 407 | ||
408 | switch (result) { | 408 | switch (result) { |
409 | case ICAL_PUBLISH_NEW_CLASS: | 409 | case ICAL_PUBLISH_NEW_CLASS: |
410 | status = ScheduleMessage::PublishNew; | 410 | status = ScheduleMessage::PublishNew; |
411 | break; | 411 | break; |
412 | case ICAL_OBSOLETE_CLASS: | 412 | case ICAL_OBSOLETE_CLASS: |
413 | status = ScheduleMessage::Obsolete; | 413 | status = ScheduleMessage::Obsolete; |
414 | break; | 414 | break; |
415 | case ICAL_REQUEST_NEW_CLASS: | 415 | case ICAL_REQUEST_NEW_CLASS: |
416 | status = ScheduleMessage::RequestNew; | 416 | status = ScheduleMessage::RequestNew; |
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index 2405682..3e28714 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp | |||
@@ -2134,39 +2134,39 @@ icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence, | |||
2134 | break; | 2134 | break; |
2135 | case Scheduler::Cancel: | 2135 | case Scheduler::Cancel: |
2136 | icalmethod = ICAL_METHOD_CANCEL; | 2136 | icalmethod = ICAL_METHOD_CANCEL; |
2137 | break; | 2137 | break; |
2138 | case Scheduler::Add: | 2138 | case Scheduler::Add: |
2139 | icalmethod = ICAL_METHOD_ADD; | 2139 | icalmethod = ICAL_METHOD_ADD; |
2140 | break; | 2140 | break; |
2141 | case Scheduler::Reply: | 2141 | case Scheduler::Reply: |
2142 | icalmethod = ICAL_METHOD_REPLY; | 2142 | icalmethod = ICAL_METHOD_REPLY; |
2143 | break; | 2143 | break; |
2144 | case Scheduler::Counter: | 2144 | case Scheduler::Counter: |
2145 | icalmethod = ICAL_METHOD_COUNTER; | 2145 | icalmethod = ICAL_METHOD_COUNTER; |
2146 | break; | 2146 | break; |
2147 | case Scheduler::Declinecounter: | 2147 | case Scheduler::Declinecounter: |
2148 | icalmethod = ICAL_METHOD_DECLINECOUNTER; | 2148 | icalmethod = ICAL_METHOD_DECLINECOUNTER; |
2149 | break; | 2149 | break; |
2150 | default: | 2150 | default: |
2151 | 2151 | ||
2152 | return message; | 2152 | return message; |
2153 | } | 2153 | } |
2154 | 2154 | ||
2155 | icalcomponent_add_property(message,icalproperty_new_method(icalmethod)); | 2155 | icalcomponent_add_property(message,icalproperty_new_method(icalmethod)); |
2156 | 2156 | ||
2157 | // TODO: check, if dynamic cast is required | 2157 | // TODO: check, if dynamic cast is required |
2158 | if(incidence->type() == "Todo") { | 2158 | if(incidence->typeID() == todoID ) { |
2159 | Todo *todo = static_cast<Todo *>(incidence); | 2159 | Todo *todo = static_cast<Todo *>(incidence); |
2160 | icalcomponent_add_component(message,writeTodo(todo)); | 2160 | icalcomponent_add_component(message,writeTodo(todo)); |
2161 | } | 2161 | } |
2162 | if(incidence->type() == "Event") { | 2162 | if(incidence->typeID() == eventID ) { |
2163 | Event *event = static_cast<Event *>(incidence); | 2163 | Event *event = static_cast<Event *>(incidence); |
2164 | icalcomponent_add_component(message,writeEvent(event)); | 2164 | icalcomponent_add_component(message,writeEvent(event)); |
2165 | } | 2165 | } |
2166 | if(incidence->type() == "FreeBusy") { | 2166 | if(incidence->typeID() == freebusyID) { |
2167 | FreeBusy *freebusy = static_cast<FreeBusy *>(incidence); | 2167 | FreeBusy *freebusy = static_cast<FreeBusy *>(incidence); |
2168 | icalcomponent_add_component(message,writeFreeBusy(freebusy, method)); | 2168 | icalcomponent_add_component(message,writeFreeBusy(freebusy, method)); |
2169 | } | 2169 | } |
2170 | 2170 | ||
2171 | return message; | 2171 | return message; |
2172 | } | 2172 | } |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 762103f..f446197 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -215,49 +215,49 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | |||
215 | return | 215 | return |
216 | // i1.created() == i2.created() && | 216 | // i1.created() == i2.created() && |
217 | stringCompare( i1.description(), i2.description() ) && | 217 | stringCompare( i1.description(), i2.description() ) && |
218 | stringCompare( i1.summary(), i2.summary() ) && | 218 | stringCompare( i1.summary(), i2.summary() ) && |
219 | i1.categories() == i2.categories() && | 219 | i1.categories() == i2.categories() && |
220 | // no need to compare mRelatedTo | 220 | // no need to compare mRelatedTo |
221 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 221 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
222 | // i1.relations() == i2.relations() && | 222 | // i1.relations() == i2.relations() && |
223 | i1.exDates() == i2.exDates() && | 223 | i1.exDates() == i2.exDates() && |
224 | i1.attachments() == i2.attachments() && | 224 | i1.attachments() == i2.attachments() && |
225 | i1.resources() == i2.resources() && | 225 | i1.resources() == i2.resources() && |
226 | i1.secrecy() == i2.secrecy() && | 226 | i1.secrecy() == i2.secrecy() && |
227 | i1.priority() == i2.priority() && | 227 | i1.priority() == i2.priority() && |
228 | i1.cancelled() == i2.cancelled() && | 228 | i1.cancelled() == i2.cancelled() && |
229 | stringCompare( i1.location(), i2.location() ); | 229 | stringCompare( i1.location(), i2.location() ); |
230 | } | 230 | } |
231 | 231 | ||
232 | Incidence* Incidence::recreateCloneException( QDate d ) | 232 | Incidence* Incidence::recreateCloneException( QDate d ) |
233 | { | 233 | { |
234 | Incidence* newInc = clone(); | 234 | Incidence* newInc = clone(); |
235 | newInc->recreate(); | 235 | newInc->recreate(); |
236 | if ( doesRecur() ) { | 236 | if ( doesRecur() ) { |
237 | addExDate( d ); | 237 | addExDate( d ); |
238 | newInc->recurrence()->unsetRecurs(); | 238 | newInc->recurrence()->unsetRecurs(); |
239 | if ( type() == "Event") { | 239 | if ( typeID() == eventID ) { |
240 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); | 240 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); |
241 | QTime tim = dtStart().time(); | 241 | QTime tim = dtStart().time(); |
242 | newInc->setDtStart( QDateTime(d, tim) ); | 242 | newInc->setDtStart( QDateTime(d, tim) ); |
243 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 243 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
244 | } else { | 244 | } else { |
245 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); | 245 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); |
246 | QTime tim = ((Todo*)this)->dtDue().time(); | 246 | QTime tim = ((Todo*)this)->dtDue().time(); |
247 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); | 247 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); |
248 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); | 248 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); |
249 | ((Todo*)this)->setRecurDates(); | 249 | ((Todo*)this)->setRecurDates(); |
250 | } | 250 | } |
251 | newInc->setExDates( DateList () ); | 251 | newInc->setExDates( DateList () ); |
252 | } | 252 | } |
253 | return newInc; | 253 | return newInc; |
254 | } | 254 | } |
255 | 255 | ||
256 | void Incidence::recreate() | 256 | void Incidence::recreate() |
257 | { | 257 | { |
258 | setCreated(QDateTime::currentDateTime()); | 258 | setCreated(QDateTime::currentDateTime()); |
259 | 259 | ||
260 | setUid(CalFormat::createUniqueId()); | 260 | setUid(CalFormat::createUniqueId()); |
261 | 261 | ||
262 | setRevision(0); | 262 | setRevision(0); |
263 | setIDStr( ":" ); | 263 | setIDStr( ":" ); |
@@ -703,42 +703,42 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | |||
703 | while ( !last ) { | 703 | while ( !last ) { |
704 | ++count; | 704 | ++count; |
705 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); | 705 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); |
706 | if ( recursOn( incidenceStart.date() ) ) { | 706 | if ( recursOn( incidenceStart.date() ) ) { |
707 | last = true; // exit while llop | 707 | last = true; // exit while llop |
708 | } else { | 708 | } else { |
709 | if ( last ) { // no alarm on last recurrence | 709 | if ( last ) { // no alarm on last recurrence |
710 | return QDateTime (); | 710 | return QDateTime (); |
711 | } | 711 | } |
712 | int year = incidenceStart.date().year(); | 712 | int year = incidenceStart.date().year(); |
713 | // workaround for bug in recurrence | 713 | // workaround for bug in recurrence |
714 | if ( count == 100 || year < 1000 || year > 5000 ) { | 714 | if ( count == 100 || year < 1000 || year > 5000 ) { |
715 | return QDateTime (); | 715 | return QDateTime (); |
716 | } | 716 | } |
717 | incidenceStart = incidenceStart.addSecs( 1 ); | 717 | incidenceStart = incidenceStart.addSecs( 1 ); |
718 | } | 718 | } |
719 | } | 719 | } |
720 | } else { | 720 | } else { |
721 | return QDateTime (); | 721 | return QDateTime (); |
722 | } | 722 | } |
723 | } else { | 723 | } else { |
724 | if ( hasStartDate () ) { | 724 | if ( hasStartDate () ) { |
725 | incidenceStart = dtStart(); | 725 | incidenceStart = dtStart(); |
726 | } | 726 | } |
727 | if ( type() =="Todo" ) { | 727 | if ( typeID() == todoID ) { |
728 | if ( ((Todo*)this)->hasDueDate() ) | 728 | if ( ((Todo*)this)->hasDueDate() ) |
729 | incidenceStart = ((Todo*)this)->dtDue(); | 729 | incidenceStart = ((Todo*)this)->dtDue(); |
730 | } | 730 | } |
731 | } | 731 | } |
732 | if ( incidenceStart > dt ) | 732 | if ( incidenceStart > dt ) |
733 | *ok = true; | 733 | *ok = true; |
734 | return incidenceStart; | 734 | return incidenceStart; |
735 | } | 735 | } |
736 | QDateTime Incidence::dtStart() const | 736 | QDateTime Incidence::dtStart() const |
737 | { | 737 | { |
738 | if ( doesRecur() ) { | 738 | if ( doesRecur() ) { |
739 | if ( type() == "Todo" ) { | 739 | if ( typeID() == todoID ) { |
740 | ((Todo*)this)->checkSetCompletedFalse(); | 740 | ((Todo*)this)->checkSetCompletedFalse(); |
741 | } | 741 | } |
742 | } | 742 | } |
743 | return mDtStart; | 743 | return mDtStart; |
744 | } | 744 | } |
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index 8624786..05209e0 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h | |||
@@ -13,65 +13,67 @@ | |||
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 | #ifndef KCAL_INCIDENCEBASE_H | 20 | #ifndef KCAL_INCIDENCEBASE_H |
21 | #define KCAL_INCIDENCEBASE_H | 21 | #define KCAL_INCIDENCEBASE_H |
22 | // | 22 | // |
23 | // Incidence - base class of calendaring components | 23 | // Incidence - base class of calendaring components |
24 | // | 24 | // |
25 | 25 | ||
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | #include <qvaluelist.h> | 28 | #include <qvaluelist.h> |
29 | #include <qptrlist.h> | 29 | #include <qptrlist.h> |
30 | 30 | ||
31 | #include "customproperties.h" | 31 | #include "customproperties.h" |
32 | #include "attendee.h" | 32 | #include "attendee.h" |
33 | 33 | ||
34 | namespace KCal { | 34 | namespace KCal { |
35 | 35 | ||
36 | typedef QValueList<QDate> DateList; | 36 | typedef QValueList<QDate> DateList; |
37 | enum IncTypeID { eventID,todoID,journalID,freebusyID }; | ||
37 | 38 | ||
38 | /** | 39 | /** |
39 | This class provides the base class common to all calendar components. | 40 | This class provides the base class common to all calendar components. |
40 | */ | 41 | */ |
41 | class IncidenceBase : public CustomProperties | 42 | class IncidenceBase : public CustomProperties |
42 | { | 43 | { |
43 | public: | 44 | public: |
44 | class Observer { | 45 | class Observer { |
45 | public: | 46 | public: |
46 | virtual void incidenceUpdated( IncidenceBase * ) = 0; | 47 | virtual void incidenceUpdated( IncidenceBase * ) = 0; |
47 | }; | 48 | }; |
48 | 49 | ||
49 | IncidenceBase(); | 50 | IncidenceBase(); |
50 | IncidenceBase(const IncidenceBase &); | 51 | IncidenceBase(const IncidenceBase &); |
51 | virtual ~IncidenceBase(); | 52 | virtual ~IncidenceBase(); |
52 | 53 | ||
53 | virtual QCString type() const = 0; | 54 | virtual QCString type() const = 0; |
55 | virtual IncTypeID typeID() const = 0; | ||
54 | 56 | ||
55 | /** Set the unique id for the event */ | 57 | /** Set the unique id for the event */ |
56 | void setUid(const QString &); | 58 | void setUid(const QString &); |
57 | /** Return the unique id for the event */ | 59 | /** Return the unique id for the event */ |
58 | QString uid() const; | 60 | QString uid() const; |
59 | 61 | ||
60 | /** Sets the time the incidence was last modified. */ | 62 | /** Sets the time the incidence was last modified. */ |
61 | void setLastModified(const QDateTime &lm); | 63 | void setLastModified(const QDateTime &lm); |
62 | /** Return the time the incidence was last modified. */ | 64 | /** Return the time the incidence was last modified. */ |
63 | QDateTime lastModified() const; | 65 | QDateTime lastModified() const; |
64 | 66 | ||
65 | /** sets the organizer for the event */ | 67 | /** sets the organizer for the event */ |
66 | void setOrganizer(const QString &o); | 68 | void setOrganizer(const QString &o); |
67 | QString organizer() const; | 69 | QString organizer() const; |
68 | 70 | ||
69 | /** Set readonly status. */ | 71 | /** Set readonly status. */ |
70 | virtual void setReadOnly( bool ); | 72 | virtual void setReadOnly( bool ); |
71 | /** Return if the object is read-only. */ | 73 | /** Return if the object is read-only. */ |
72 | bool isReadOnly() const { return mReadOnly; } | 74 | bool isReadOnly() const { return mReadOnly; } |
73 | 75 | ||
74 | /** for setting the event's starting date/time with a QDateTime. */ | 76 | /** for setting the event's starting date/time with a QDateTime. */ |
75 | virtual void setDtStart(const QDateTime &dtStart); | 77 | virtual void setDtStart(const QDateTime &dtStart); |
76 | /** returns an event's starting date/time as a QDateTime. */ | 78 | /** returns an event's starting date/time as a QDateTime. */ |
77 | virtual QDateTime dtStart() const; | 79 | virtual QDateTime dtStart() const; |
diff --git a/libkcal/journal.h b/libkcal/journal.h index 2c1d7ea..1cd0a22 100644 --- a/libkcal/journal.h +++ b/libkcal/journal.h | |||
@@ -16,35 +16,36 @@ | |||
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 | #ifndef JOURNAL_H | 20 | #ifndef JOURNAL_H |
21 | #define JOURNAL_H | 21 | #define JOURNAL_H |
22 | // | 22 | // |
23 | // Journal component, representing a VJOURNAL object | 23 | // Journal component, representing a VJOURNAL object |
24 | // | 24 | // |
25 | 25 | ||
26 | #include "incidence.h" | 26 | #include "incidence.h" |
27 | 27 | ||
28 | namespace KCal { | 28 | namespace KCal { |
29 | 29 | ||
30 | /** | 30 | /** |
31 | This class provides a Journal in the sense of RFC2445. | 31 | This class provides a Journal in the sense of RFC2445. |
32 | */ | 32 | */ |
33 | class Journal : public Incidence | 33 | class Journal : public Incidence |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | Journal(); | 36 | Journal(); |
37 | ~Journal(); | 37 | ~Journal(); |
38 | 38 | ||
39 | QCString type() const { return "Journal"; } | 39 | QCString type() const { return "Journal"; } |
40 | IncTypeID typeID() const { return journalID; } | ||
40 | 41 | ||
41 | Incidence *clone(); | 42 | Incidence *clone(); |
42 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; | 43 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; |
43 | private: | 44 | private: |
44 | bool accept(Visitor &v) { return v.visit(this); } | 45 | bool accept(Visitor &v) { return v.visit(this); } |
45 | }; | 46 | }; |
46 | 47 | ||
47 | bool operator==( const Journal&, const Journal& ); | 48 | bool operator==( const Journal&, const Journal& ); |
48 | } | 49 | } |
49 | 50 | ||
50 | #endif | 51 | #endif |
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index 7d61b7f..d1ace4f 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -1,50 +1,50 @@ | |||
1 | #include "kincidenceformatter.h" | 1 | #include "kincidenceformatter.h" |
2 | #include <kstaticdeleter.h> | 2 | #include <kstaticdeleter.h> |
3 | #include <kglobal.h> | 3 | #include <kglobal.h> |
4 | #include <klocale.h> | 4 | #include <klocale.h> |
5 | #ifdef DEKTOP_VERSION | 5 | #ifdef DEKTOP_VERSION |
6 | #include <kabc/stdaddressbook.h> | 6 | #include <kabc/stdaddressbook.h> |
7 | #define size count | 7 | #define size count |
8 | #endif | 8 | #endif |
9 | 9 | ||
10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; | 10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; |
11 | static KStaticDeleter<KIncidenceFormatter> insd; | 11 | static KStaticDeleter<KIncidenceFormatter> insd; |
12 | 12 | ||
13 | QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) | 13 | QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) |
14 | { | 14 | { |
15 | // #ifndef QT_NO_INPUTDIALOG | 15 | // #ifndef QT_NO_INPUTDIALOG |
16 | // return QInputDialog::getItem( caption, label, items, current, editable ); | 16 | // return QInputDialog::getItem( caption, label, items, current, editable ); |
17 | // #else | 17 | // #else |
18 | // return QString::null; | 18 | // return QString::null; |
19 | // #endif | 19 | // #endif |
20 | mDetails = details; | 20 | mDetails = details; |
21 | mCreated = created ; | 21 | mCreated = created ; |
22 | mModified = modified; | 22 | mModified = modified; |
23 | mText = ""; | 23 | mText = ""; |
24 | if ( inc->type() == "Event" ) | 24 | if ( inc->typeID() == eventID ) |
25 | setEvent((Event *) inc ); | 25 | setEvent((Event *) inc ); |
26 | else if ( inc->type() == "Todo" ) | 26 | else if ( inc->typeID() == todoID ) |
27 | setTodo((Todo *) inc ); | 27 | setTodo((Todo *) inc ); |
28 | return mText; | 28 | return mText; |
29 | } | 29 | } |
30 | 30 | ||
31 | KIncidenceFormatter* KIncidenceFormatter::instance() | 31 | KIncidenceFormatter* KIncidenceFormatter::instance() |
32 | { | 32 | { |
33 | if (!mInstance) { | 33 | if (!mInstance) { |
34 | mInstance = insd.setObject(new KIncidenceFormatter()); | 34 | mInstance = insd.setObject(new KIncidenceFormatter()); |
35 | } | 35 | } |
36 | return mInstance; | 36 | return mInstance; |
37 | } | 37 | } |
38 | KIncidenceFormatter::~KIncidenceFormatter() | 38 | KIncidenceFormatter::~KIncidenceFormatter() |
39 | { | 39 | { |
40 | if (mInstance == this) | 40 | if (mInstance == this) |
41 | mInstance = insd.setObject(0); | 41 | mInstance = insd.setObject(0); |
42 | //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); | 42 | //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); |
43 | } | 43 | } |
44 | KIncidenceFormatter::KIncidenceFormatter() | 44 | KIncidenceFormatter::KIncidenceFormatter() |
45 | { | 45 | { |
46 | mColorMode = 0; | 46 | mColorMode = 0; |
47 | } | 47 | } |
48 | void KIncidenceFormatter::setEvent(Event *event) | 48 | void KIncidenceFormatter::setEvent(Event *event) |
49 | { | 49 | { |
50 | int mode = 0; | 50 | int mode = 0; |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 38ba2c7..c97a61e 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -109,49 +109,49 @@ void Todo::saveRunningInfoToFile( QString comment ) | |||
109 | to->setDtStart( mRunStart ); | 109 | to->setDtStart( mRunStart ); |
110 | to->setHasStartDate( true ); | 110 | to->setHasStartDate( true ); |
111 | to->setDtDue( QDateTime::currentDateTime() ); | 111 | to->setDtDue( QDateTime::currentDateTime() ); |
112 | to->setHasDueDate( true ); | 112 | to->setHasDueDate( true ); |
113 | to->setUid( file ); | 113 | to->setUid( file ); |
114 | if ( !comment.isEmpty() ) { | 114 | if ( !comment.isEmpty() ) { |
115 | QString des = to->description(); | 115 | QString des = to->description(); |
116 | if ( des.isEmpty () ) | 116 | if ( des.isEmpty () ) |
117 | to->setDescription( "TT-Note: " + comment ); | 117 | to->setDescription( "TT-Note: " + comment ); |
118 | else | 118 | else |
119 | to->setDescription( "TT-Note: " + comment +"\n" + des ); | 119 | to->setDescription( "TT-Note: " + comment +"\n" + des ); |
120 | } | 120 | } |
121 | cal.addIncidence( to ); | 121 | cal.addIncidence( to ); |
122 | ICalFormat format; | 122 | ICalFormat format; |
123 | file = dir +"/" +file +".ics"; | 123 | file = dir +"/" +file +".ics"; |
124 | format.save( &cal, file ); | 124 | format.save( &cal, file ); |
125 | saveParents(); | 125 | saveParents(); |
126 | 126 | ||
127 | } | 127 | } |
128 | void Todo::saveParents() | 128 | void Todo::saveParents() |
129 | { | 129 | { |
130 | if (!relatedTo() ) | 130 | if (!relatedTo() ) |
131 | return; | 131 | return; |
132 | Incidence * inc = relatedTo(); | 132 | Incidence * inc = relatedTo(); |
133 | if ( inc->type() != "Todo" ) | 133 | if ( inc->typeID() != todoID ) |
134 | return; | 134 | return; |
135 | Todo* to = (Todo*)inc; | 135 | Todo* to = (Todo*)inc; |
136 | bool saveTodo = false; | 136 | bool saveTodo = false; |
137 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; | 137 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; |
138 | QFileInfo fi ( file ); | 138 | QFileInfo fi ( file ); |
139 | if ( fi.exists() ) { | 139 | if ( fi.exists() ) { |
140 | if ( fi.lastModified () < to->lastModified ()) | 140 | if ( fi.lastModified () < to->lastModified ()) |
141 | saveTodo = true; | 141 | saveTodo = true; |
142 | } else { | 142 | } else { |
143 | saveTodo = true; | 143 | saveTodo = true; |
144 | } | 144 | } |
145 | if ( saveTodo ) { | 145 | if ( saveTodo ) { |
146 | CalendarLocal cal; | 146 | CalendarLocal cal; |
147 | cal.setLocalTime(); | 147 | cal.setLocalTime(); |
148 | Todo * par = (Todo *) to->clone(); | 148 | Todo * par = (Todo *) to->clone(); |
149 | cal.addIncidence( par ); | 149 | cal.addIncidence( par ); |
150 | ICalFormat format; | 150 | ICalFormat format; |
151 | format.save( &cal, file ); | 151 | format.save( &cal, file ); |
152 | } | 152 | } |
153 | to->saveParents(); | 153 | to->saveParents(); |
154 | } | 154 | } |
155 | 155 | ||
156 | int Todo::runTime() | 156 | int Todo::runTime() |
157 | { | 157 | { |
@@ -543,38 +543,39 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_d | |||
543 | } else { | 543 | } else { |
544 | int secs = alarm->startOffset().asSeconds(); | 544 | int secs = alarm->startOffset().asSeconds(); |
545 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 545 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
546 | alarmStart = incidenceStart.addSecs( secs ); | 546 | alarmStart = incidenceStart.addSecs( secs ); |
547 | enabled = true; | 547 | enabled = true; |
548 | off = -secs; | 548 | off = -secs; |
549 | } | 549 | } |
550 | } | 550 | } |
551 | } | 551 | } |
552 | } | 552 | } |
553 | if ( enabled ) { | 553 | if ( enabled ) { |
554 | if ( alarmStart > start_dt ) { | 554 | if ( alarmStart > start_dt ) { |
555 | *ok = true; | 555 | *ok = true; |
556 | * offset = off; | 556 | * offset = off; |
557 | return alarmStart; | 557 | return alarmStart; |
558 | } | 558 | } |
559 | } | 559 | } |
560 | *ok = false; | 560 | *ok = false; |
561 | return QDateTime (); | 561 | return QDateTime (); |
562 | 562 | ||
563 | } | 563 | } |
564 | 564 | ||
565 | void Todo::checkSetCompletedFalse() | 565 | void Todo::checkSetCompletedFalse() |
566 | { | 566 | { |
567 | if ( !hasRecurrenceID() ) { | 567 | if ( !mHasRecurrenceID ) { |
568 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); | 568 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); |
569 | return; | ||
569 | } | 570 | } |
570 | // qDebug("Todo::checkSetCompletedFalse()"); | 571 | // qDebug("Todo::checkSetCompletedFalse()"); |
571 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 572 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
572 | if ( mPercentComplete == 100 ) { | 573 | if ( mPercentComplete == 100 ) { |
573 | QDateTime dt = QDateTime::currentDateTime(); | 574 | QDateTime dt = QDateTime::currentDateTime(); |
574 | if ( dt > mDtStart && dt > mRecurrenceID ) { | 575 | if ( dt > mDtStart && dt > mRecurrenceID ) { |
575 | qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 576 | qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
576 | setCompleted( false ); | 577 | setCompleted( false ); |
577 | qDebug("Todo::checkSetCompletedFalse "); | 578 | qDebug("Todo::checkSetCompletedFalse "); |
578 | } | 579 | } |
579 | } | 580 | } |
580 | } | 581 | } |
diff --git a/libkcal/todo.h b/libkcal/todo.h index ab8fdf1..501c2ba 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -20,48 +20,49 @@ | |||
20 | #ifndef TODO_H | 20 | #ifndef TODO_H |
21 | #define TODO_H | 21 | #define TODO_H |
22 | // | 22 | // |
23 | // Todo component, representing a VTODO object | 23 | // Todo component, representing a VTODO object |
24 | // | 24 | // |
25 | 25 | ||
26 | #include "incidence.h" | 26 | #include "incidence.h" |
27 | 27 | ||
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | 29 | ||
30 | namespace KCal { | 30 | namespace KCal { |
31 | 31 | ||
32 | /** | 32 | /** |
33 | This class provides a Todo in the sense of RFC2445. | 33 | This class provides a Todo in the sense of RFC2445. |
34 | */ | 34 | */ |
35 | class Todo : public QObject,public Incidence | 35 | class Todo : public QObject,public Incidence |
36 | { | 36 | { |
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 | 45 | ||
45 | /** Return an exact copy of this todo. */ | 46 | /** Return an exact copy of this todo. */ |
46 | Incidence *clone(); | 47 | Incidence *clone(); |
47 | QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const; | 48 | QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const; |
48 | 49 | ||
49 | /** for setting the todo's due date/time with a QDateTime. */ | 50 | /** for setting the todo's due date/time with a QDateTime. */ |
50 | void setDtDue(const QDateTime &dtDue); | 51 | void setDtDue(const QDateTime &dtDue); |
51 | /** returns an event's Due date/time as a QDateTime. */ | 52 | /** returns an event's Due date/time as a QDateTime. */ |
52 | QDateTime dtDue() const; | 53 | QDateTime dtDue() const; |
53 | /** 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 |
54 | users locale settings */ | 55 | users locale settings */ |
55 | QString dtDueTimeStr() const; | 56 | QString dtDueTimeStr() const; |
56 | /** 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 |
57 | users locale settings */ | 58 | users locale settings */ |
58 | QString dtDueDateStr(bool shortfmt=true) const; | 59 | QString dtDueDateStr(bool shortfmt=true) const; |
59 | /** 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 |
60 | to the users locale settings */ | 61 | to the users locale settings */ |
61 | QString dtDueStr(bool shortfmt=true) const; | 62 | QString dtDueStr(bool shortfmt=true) const; |
62 | 63 | ||
63 | /** 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 */ |
64 | bool hasDueDate() const; | 65 | bool hasDueDate() const; |
65 | /** sets the event's hasDueDate value. */ | 66 | /** sets the event's hasDueDate value. */ |
66 | void setHasDueDate(bool f); | 67 | void setHasDueDate(bool f); |
67 | 68 | ||