-rw-r--r-- | libkcal/calendar.cpp | 14 | ||||
-rw-r--r-- | libkcal/calendar.h | 9 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 80 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 3 | ||||
-rw-r--r-- | libkcal/calfilter.cpp | 9 | ||||
-rw-r--r-- | libkcal/calfilter.h | 1 | ||||
-rw-r--r-- | libkcal/event.cpp | 4 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 33 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 9 | ||||
-rw-r--r-- | libkcal/todo.cpp | 2 |
10 files changed, 146 insertions, 18 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 7e8e2c5..f4350d9 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -25,123 +25,130 @@ | |||
25 | #include <kdebug.h> | 25 | #include <kdebug.h> |
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | #include "exceptions.h" | 29 | #include "exceptions.h" |
30 | #include "calfilter.h" | 30 | #include "calfilter.h" |
31 | 31 | ||
32 | #include "calendar.h" | 32 | #include "calendar.h" |
33 | #include "syncdefines.h" | 33 | #include "syncdefines.h" |
34 | 34 | ||
35 | using namespace KCal; | 35 | using namespace KCal; |
36 | 36 | ||
37 | Calendar::Calendar() | 37 | Calendar::Calendar() |
38 | { | 38 | { |
39 | 39 | ||
40 | init(); | 40 | init(); |
41 | setTimeZoneId( " 00:00 Europe/London(UTC)" ); | 41 | setTimeZoneId( " 00:00 Europe/London(UTC)" ); |
42 | } | 42 | } |
43 | 43 | ||
44 | Calendar::Calendar( const QString &timeZoneId ) | 44 | Calendar::Calendar( const QString &timeZoneId ) |
45 | { | 45 | { |
46 | 46 | ||
47 | init(); | 47 | init(); |
48 | setTimeZoneId(timeZoneId); | 48 | setTimeZoneId(timeZoneId); |
49 | } | 49 | } |
50 | 50 | ||
51 | void Calendar::init() | 51 | void Calendar::init() |
52 | { | 52 | { |
53 | mObserver = 0; | 53 | mObserver = 0; |
54 | mNewObserver = false; | 54 | mNewObserver = false; |
55 | mUndoIncidence = 0; | 55 | mUndoIncidence = 0; |
56 | mModified = false; | 56 | mModified = false; |
57 | 57 | mDefaultCalendar = 1; | |
58 | // Setup default filter, which does nothing | 58 | // Setup default filter, which does nothing |
59 | mDefaultFilter = new CalFilter; | 59 | mDefaultFilter = new CalFilter; |
60 | mFilter = mDefaultFilter; | 60 | mFilter = mDefaultFilter; |
61 | mFilter->setEnabled(false); | 61 | mFilter->setEnabled(false); |
62 | 62 | ||
63 | // initialize random numbers. This is a hack, and not | 63 | // initialize random numbers. This is a hack, and not |
64 | // even that good of one at that. | 64 | // even that good of one at that. |
65 | // srandom(time(0)); | 65 | // srandom(time(0)); |
66 | 66 | ||
67 | // user information... | 67 | // user information... |
68 | setOwner(i18n("Unknown Name")); | 68 | setOwner(i18n("Unknown Name")); |
69 | setEmail(i18n("unknown@nowhere")); | 69 | setEmail(i18n("unknown@nowhere")); |
70 | 70 | ||
71 | #if 0 | 71 | #if 0 |
72 | tmpStr = KOPrefs::instance()->mTimeZone; | 72 | tmpStr = KOPrefs::instance()->mTimeZone; |
73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; | 73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; |
74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; | 74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; |
75 | extern long int timezone; | 75 | extern long int timezone; |
76 | struct tm *now; | 76 | struct tm *now; |
77 | time_t curtime; | 77 | time_t curtime; |
78 | curtime = time(0); | 78 | curtime = time(0); |
79 | now = localtime(&curtime); | 79 | now = localtime(&curtime); |
80 | int hourOff = - ((timezone / 60) / 60); | 80 | int hourOff = - ((timezone / 60) / 60); |
81 | if (now->tm_isdst) | 81 | if (now->tm_isdst) |
82 | hourOff += 1; | 82 | hourOff += 1; |
83 | QString tzStr; | 83 | QString tzStr; |
84 | tzStr.sprintf("%.2d%.2d", | 84 | tzStr.sprintf("%.2d%.2d", |
85 | hourOff, | 85 | hourOff, |
86 | abs((timezone / 60) % 60)); | 86 | abs((timezone / 60) % 60)); |
87 | 87 | ||
88 | // if no time zone was in the config file, write what we just discovered. | 88 | // if no time zone was in the config file, write what we just discovered. |
89 | if (tmpStr.isEmpty()) { | 89 | if (tmpStr.isEmpty()) { |
90 | // KOPrefs::instance()->mTimeZone = tzStr; | 90 | // KOPrefs::instance()->mTimeZone = tzStr; |
91 | } else { | 91 | } else { |
92 | tzStr = tmpStr; | 92 | tzStr = tmpStr; |
93 | } | 93 | } |
94 | 94 | ||
95 | // if daylight savings has changed since last load time, we need | 95 | // if daylight savings has changed since last load time, we need |
96 | // to rewrite these settings to the config file. | 96 | // to rewrite these settings to the config file. |
97 | if ((now->tm_isdst && !dstSetting) || | 97 | if ((now->tm_isdst && !dstSetting) || |
98 | (!now->tm_isdst && dstSetting)) { | 98 | (!now->tm_isdst && dstSetting)) { |
99 | KOPrefs::instance()->mTimeZone = tzStr; | 99 | KOPrefs::instance()->mTimeZone = tzStr; |
100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; | 100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; |
101 | } | 101 | } |
102 | 102 | ||
103 | setTimeZone(tzStr); | 103 | setTimeZone(tzStr); |
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | // KOPrefs::instance()->writeConfig(); | 106 | // KOPrefs::instance()->writeConfig(); |
107 | } | 107 | } |
108 | 108 | ||
109 | Calendar::~Calendar() | 109 | Calendar::~Calendar() |
110 | { | 110 | { |
111 | delete mDefaultFilter; | 111 | delete mDefaultFilter; |
112 | if ( mUndoIncidence ) | 112 | if ( mUndoIncidence ) |
113 | delete mUndoIncidence; | 113 | delete mUndoIncidence; |
114 | } | 114 | } |
115 | 115 | void Calendar::setDefaultCalendar( int d ) | |
116 | { | ||
117 | mDefaultCalendar = d; | ||
118 | } | ||
119 | int Calendar::defaultCalendar() | ||
120 | { | ||
121 | return mDefaultCalendar; | ||
122 | } | ||
116 | const QString &Calendar::getOwner() const | 123 | const QString &Calendar::getOwner() const |
117 | { | 124 | { |
118 | return mOwner; | 125 | return mOwner; |
119 | } | 126 | } |
120 | 127 | ||
121 | bool Calendar::undoDeleteIncidence() | 128 | bool Calendar::undoDeleteIncidence() |
122 | { | 129 | { |
123 | if (!mUndoIncidence) | 130 | if (!mUndoIncidence) |
124 | return false; | 131 | return false; |
125 | addIncidence(mUndoIncidence); | 132 | addIncidence(mUndoIncidence); |
126 | mUndoIncidence = 0; | 133 | mUndoIncidence = 0; |
127 | return true; | 134 | return true; |
128 | } | 135 | } |
129 | void Calendar::setOwner(const QString &os) | 136 | void Calendar::setOwner(const QString &os) |
130 | { | 137 | { |
131 | int i; | 138 | int i; |
132 | mOwner = os; | 139 | mOwner = os; |
133 | i = mOwner.find(','); | 140 | i = mOwner.find(','); |
134 | if (i != -1) | 141 | if (i != -1) |
135 | mOwner = mOwner.left(i); | 142 | mOwner = mOwner.left(i); |
136 | 143 | ||
137 | setModified( true ); | 144 | setModified( true ); |
138 | } | 145 | } |
139 | 146 | ||
140 | void Calendar::setTimeZone(const QString & tz) | 147 | void Calendar::setTimeZone(const QString & tz) |
141 | { | 148 | { |
142 | bool neg = FALSE; | 149 | bool neg = FALSE; |
143 | int hours, minutes; | 150 | int hours, minutes; |
144 | QString tmpStr(tz); | 151 | QString tmpStr(tz); |
145 | 152 | ||
146 | if (tmpStr.left(1) == "-") | 153 | if (tmpStr.left(1) == "-") |
147 | neg = TRUE; | 154 | neg = TRUE; |
@@ -319,65 +326,66 @@ QPtrList<Event> Calendar::events( const QDateTime &qdt ) | |||
319 | QPtrList<Event> el = rawEventsForDate(qdt); | 326 | QPtrList<Event> el = rawEventsForDate(qdt); |
320 | mFilter->apply(&el); | 327 | mFilter->apply(&el); |
321 | return el; | 328 | return el; |
322 | } | 329 | } |
323 | 330 | ||
324 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, | 331 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, |
325 | bool inclusive) | 332 | bool inclusive) |
326 | { | 333 | { |
327 | QPtrList<Event> el = rawEvents(start,end,inclusive); | 334 | QPtrList<Event> el = rawEvents(start,end,inclusive); |
328 | mFilter->apply(&el); | 335 | mFilter->apply(&el); |
329 | return el; | 336 | return el; |
330 | } | 337 | } |
331 | 338 | ||
332 | QPtrList<Event> Calendar::events() | 339 | QPtrList<Event> Calendar::events() |
333 | { | 340 | { |
334 | QPtrList<Event> el = rawEvents(); | 341 | QPtrList<Event> el = rawEvents(); |
335 | mFilter->apply(&el); | 342 | mFilter->apply(&el); |
336 | return el; | 343 | return el; |
337 | } | 344 | } |
338 | void Calendar::addIncidenceBranch(Incidence *i) | 345 | void Calendar::addIncidenceBranch(Incidence *i) |
339 | { | 346 | { |
340 | addIncidence( i ); | 347 | addIncidence( i ); |
341 | Incidence * inc; | 348 | Incidence * inc; |
342 | QPtrList<Incidence> Relations = i->relations(); | 349 | QPtrList<Incidence> Relations = i->relations(); |
343 | for (inc=Relations.first();inc;inc=Relations.next()) { | 350 | for (inc=Relations.first();inc;inc=Relations.next()) { |
344 | addIncidenceBranch( inc ); | 351 | addIncidenceBranch( inc ); |
345 | } | 352 | } |
346 | } | 353 | } |
347 | 354 | ||
348 | bool Calendar::addIncidence(Incidence *i) | 355 | bool Calendar::addIncidence(Incidence *i) |
349 | { | 356 | { |
350 | Incidence::AddVisitor<Calendar> v(this); | 357 | Incidence::AddVisitor<Calendar> v(this); |
351 | 358 | i->setCalID( mDefaultCalendar ); | |
359 | i->setCalEnabled( true ); | ||
352 | return i->accept(v); | 360 | return i->accept(v); |
353 | } | 361 | } |
354 | void Calendar::deleteIncidence(Incidence *in) | 362 | void Calendar::deleteIncidence(Incidence *in) |
355 | { | 363 | { |
356 | if ( in->typeID() == eventID ) | 364 | if ( in->typeID() == eventID ) |
357 | deleteEvent( (Event*) in ); | 365 | deleteEvent( (Event*) in ); |
358 | else if ( in->typeID() == todoID ) | 366 | else if ( in->typeID() == todoID ) |
359 | deleteTodo( (Todo*) in); | 367 | deleteTodo( (Todo*) in); |
360 | else if ( in->typeID() == journalID ) | 368 | else if ( in->typeID() == journalID ) |
361 | deleteJournal( (Journal*) in ); | 369 | deleteJournal( (Journal*) in ); |
362 | } | 370 | } |
363 | 371 | ||
364 | Incidence* Calendar::incidence( const QString& uid ) | 372 | Incidence* Calendar::incidence( const QString& uid ) |
365 | { | 373 | { |
366 | Incidence* i; | 374 | Incidence* i; |
367 | 375 | ||
368 | if( (i = todo( uid )) != 0 ) | 376 | if( (i = todo( uid )) != 0 ) |
369 | return i; | 377 | return i; |
370 | if( (i = event( uid )) != 0 ) | 378 | if( (i = event( uid )) != 0 ) |
371 | return i; | 379 | return i; |
372 | if( (i = journal( uid )) != 0 ) | 380 | if( (i = journal( uid )) != 0 ) |
373 | return i; | 381 | return i; |
374 | 382 | ||
375 | return 0; | 383 | return 0; |
376 | } | 384 | } |
377 | 385 | ||
378 | QPtrList<Todo> Calendar::todos() | 386 | QPtrList<Todo> Calendar::todos() |
379 | { | 387 | { |
380 | QPtrList<Todo> tl = rawTodos(); | 388 | QPtrList<Todo> tl = rawTodos(); |
381 | mFilter->apply( &tl ); | 389 | mFilter->apply( &tl ); |
382 | return tl; | 390 | return tl; |
383 | } | 391 | } |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index ab40970..4c6760f 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -273,87 +273,94 @@ public: | |||
273 | */ | 273 | */ |
274 | CalFilter *filter(); | 274 | CalFilter *filter(); |
275 | virtual QDateTime nextAlarm( int daysTo ) = 0; | 275 | virtual QDateTime nextAlarm( int daysTo ) = 0; |
276 | virtual QString nextSummary( ) const = 0; | 276 | virtual QString nextSummary( ) const = 0; |
277 | virtual void reInitAlarmSettings() = 0; | 277 | virtual void reInitAlarmSettings() = 0; |
278 | virtual QDateTime nextAlarmEventDateTime() const = 0; | 278 | virtual QDateTime nextAlarmEventDateTime() const = 0; |
279 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; | 279 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; |
280 | /** | 280 | /** |
281 | Return all alarms, which ocur in the given time interval. | 281 | Return all alarms, which ocur in the given time interval. |
282 | */ | 282 | */ |
283 | virtual Alarm::List alarms( const QDateTime &from, | 283 | virtual Alarm::List alarms( const QDateTime &from, |
284 | const QDateTime &to ) = 0; | 284 | const QDateTime &to ) = 0; |
285 | 285 | ||
286 | class Observer { | 286 | class Observer { |
287 | public: | 287 | public: |
288 | virtual void calendarModified( bool, Calendar * ) = 0; | 288 | virtual void calendarModified( bool, Calendar * ) = 0; |
289 | }; | 289 | }; |
290 | 290 | ||
291 | void registerObserver( Observer * ); | 291 | void registerObserver( Observer * ); |
292 | 292 | ||
293 | void setModified( bool ); | 293 | void setModified( bool ); |
294 | 294 | ||
295 | /** | 295 | /** |
296 | Set product id returned by loadedProductId(). This function is only | 296 | Set product id returned by loadedProductId(). This function is only |
297 | useful for the calendar loading code. | 297 | useful for the calendar loading code. |
298 | */ | 298 | */ |
299 | void setLoadedProductId( const QString & ); | 299 | void setLoadedProductId( const QString & ); |
300 | /** | 300 | /** |
301 | Return product id taken from file that has been loaded. Returns | 301 | Return product id taken from file that has been loaded. Returns |
302 | QString::null, if no calendar has been loaded. | 302 | QString::null, if no calendar has been loaded. |
303 | */ | 303 | */ |
304 | QString loadedProductId(); | 304 | QString loadedProductId(); |
305 | 305 | void setDefaultCalendar( int ); | |
306 | int defaultCalendar(); | ||
307 | virtual void setCalendarEnabled( int id, bool enable ) = 0; | ||
308 | virtual void setAlarmEnabled( int id, bool enable ) = 0; | ||
309 | virtual void setDefaultCalendarEnabledOnly() = 0; | ||
306 | signals: | 310 | signals: |
307 | void calendarChanged(); | 311 | void calendarChanged(); |
308 | void calendarSaved(); | 312 | void calendarSaved(); |
309 | void calendarLoaded(); | 313 | void calendarLoaded(); |
310 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 314 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
311 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 315 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
312 | 316 | ||
313 | protected: | 317 | protected: |
314 | /** | 318 | /** |
315 | Get unfiltered events, which occur on the given date. | 319 | Get unfiltered events, which occur on the given date. |
316 | */ | 320 | */ |
317 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; | 321 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; |
318 | /** | 322 | /** |
319 | Get unfiltered events, which occur on the given date. | 323 | Get unfiltered events, which occur on the given date. |
320 | */ | 324 | */ |
321 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, | 325 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, |
322 | bool sorted = false ) = 0; | 326 | bool sorted = false ) = 0; |
323 | /** | 327 | /** |
324 | Get events in a range of dates. If inclusive is set to true, only events | 328 | Get events in a range of dates. If inclusive is set to true, only events |
325 | are returned, which are completely included in the range. | 329 | are returned, which are completely included in the range. |
326 | */ | 330 | */ |
327 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 331 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
328 | bool inclusive = false ) = 0; | 332 | bool inclusive = false ) = 0; |
333 | |||
329 | Incidence *mNextAlarmIncidence; | 334 | Incidence *mNextAlarmIncidence; |
330 | Incidence *mUndoIncidence; | 335 | Incidence *mUndoIncidence; |
336 | int mDefaultCalendar; | ||
331 | 337 | ||
332 | private: | 338 | private: |
333 | void init(); | 339 | void init(); |
334 | 340 | ||
335 | QString mOwner; // who the calendar belongs to | 341 | QString mOwner; // who the calendar belongs to |
336 | QString mOwnerEmail; // email address of the owner | 342 | QString mOwnerEmail; // email address of the owner |
337 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) | 343 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) |
338 | bool mLocalTime; // use local time, not UTC or a time zone | 344 | bool mLocalTime; // use local time, not UTC or a time zone |
339 | 345 | ||
340 | CalFilter *mFilter; | 346 | CalFilter *mFilter; |
341 | CalFilter *mDefaultFilter; | 347 | CalFilter *mDefaultFilter; |
348 | |||
342 | 349 | ||
343 | QString mTimeZoneId; | 350 | QString mTimeZoneId; |
344 | 351 | ||
345 | Observer *mObserver; | 352 | Observer *mObserver; |
346 | bool mNewObserver; | 353 | bool mNewObserver; |
347 | 354 | ||
348 | bool mModified; | 355 | bool mModified; |
349 | 356 | ||
350 | QString mLoadedProductId; | 357 | QString mLoadedProductId; |
351 | 358 | ||
352 | // This list is used to put together related todos | 359 | // This list is used to put together related todos |
353 | QDict<Incidence> mOrphans; | 360 | QDict<Incidence> mOrphans; |
354 | QDict<Incidence> mOrphanUids; | 361 | QDict<Incidence> mOrphanUids; |
355 | }; | 362 | }; |
356 | 363 | ||
357 | } | 364 | } |
358 | 365 | ||
359 | #endif | 366 | #endif |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index fe74052..c5500bf 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -121,191 +121,197 @@ bool CalendarLocal::addAnniversaryNoDup( Event *event ) | |||
121 | continue; | 121 | continue; |
122 | // now we have an event with fitting category | 122 | // now we have an event with fitting category |
123 | if ( eve->dtStart().date() != event->dtStart().date() ) | 123 | if ( eve->dtStart().date() != event->dtStart().date() ) |
124 | continue; | 124 | continue; |
125 | // now we have an event with fitting category+date | 125 | // now we have an event with fitting category+date |
126 | if ( eve->summary() != event->summary() ) | 126 | if ( eve->summary() != event->summary() ) |
127 | continue; | 127 | continue; |
128 | // now we have an event with fitting category+date+summary | 128 | // now we have an event with fitting category+date+summary |
129 | return false; | 129 | return false; |
130 | } | 130 | } |
131 | return addEvent( event ); | 131 | return addEvent( event ); |
132 | 132 | ||
133 | } | 133 | } |
134 | bool CalendarLocal::addEventNoDup( Event *event ) | 134 | bool CalendarLocal::addEventNoDup( Event *event ) |
135 | { | 135 | { |
136 | Event * eve; | 136 | Event * eve; |
137 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 137 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
138 | if ( *eve == *event ) { | 138 | if ( *eve == *event ) { |
139 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); | 139 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); |
140 | return false; | 140 | return false; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | return addEvent( event ); | 143 | return addEvent( event ); |
144 | } | 144 | } |
145 | 145 | ||
146 | bool CalendarLocal::addEvent( Event *event ) | 146 | bool CalendarLocal::addEvent( Event *event ) |
147 | { | 147 | { |
148 | insertEvent( event ); | 148 | insertEvent( event ); |
149 | 149 | ||
150 | event->registerObserver( this ); | 150 | event->registerObserver( this ); |
151 | 151 | ||
152 | setModified( true ); | 152 | setModified( true ); |
153 | event->setCalID( mDefaultCalendar ); | ||
154 | event->setCalEnabled( true ); | ||
153 | 155 | ||
154 | return true; | 156 | return true; |
155 | } | 157 | } |
156 | 158 | ||
157 | void CalendarLocal::deleteEvent( Event *event ) | 159 | void CalendarLocal::deleteEvent( Event *event ) |
158 | { | 160 | { |
159 | if ( mUndoIncidence ) delete mUndoIncidence; | 161 | if ( mUndoIncidence ) delete mUndoIncidence; |
160 | mUndoIncidence = event->clone(); | 162 | mUndoIncidence = event->clone(); |
161 | if ( mEventList.removeRef( event ) ) { | 163 | if ( mEventList.removeRef( event ) ) { |
162 | setModified( true ); | 164 | setModified( true ); |
163 | } | 165 | } |
164 | } | 166 | } |
165 | 167 | ||
166 | 168 | ||
167 | Event *CalendarLocal::event( const QString &uid ) | 169 | Event *CalendarLocal::event( const QString &uid ) |
168 | { | 170 | { |
169 | 171 | ||
170 | Event *event; | 172 | Event *event; |
171 | 173 | ||
172 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 174 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
173 | if ( event->uid() == uid ) { | 175 | if ( event->uid() == uid && event->calEnabled() ) { |
174 | return event; | 176 | return event; |
175 | } | 177 | } |
176 | } | 178 | } |
177 | 179 | ||
178 | return 0; | 180 | return 0; |
179 | } | 181 | } |
180 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 182 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
181 | { | 183 | { |
182 | Todo * eve; | 184 | Todo * eve; |
183 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 185 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
184 | if ( *eve == *todo ) { | 186 | if ( *eve == *todo ) { |
185 | //qDebug("duplicate todo found! not inserted! "); | 187 | //qDebug("duplicate todo found! not inserted! "); |
186 | return false; | 188 | return false; |
187 | } | 189 | } |
188 | } | 190 | } |
189 | return addTodo( todo ); | 191 | return addTodo( todo ); |
190 | } | 192 | } |
191 | bool CalendarLocal::addTodo( Todo *todo ) | 193 | bool CalendarLocal::addTodo( Todo *todo ) |
192 | { | 194 | { |
193 | mTodoList.append( todo ); | 195 | mTodoList.append( todo ); |
194 | 196 | ||
195 | todo->registerObserver( this ); | 197 | todo->registerObserver( this ); |
196 | 198 | ||
197 | // Set up subtask relations | 199 | // Set up subtask relations |
198 | setupRelations( todo ); | 200 | setupRelations( todo ); |
199 | 201 | ||
200 | setModified( true ); | 202 | setModified( true ); |
201 | 203 | todo->setCalID( mDefaultCalendar ); | |
204 | todo->setCalEnabled( true ); | ||
202 | return true; | 205 | return true; |
203 | } | 206 | } |
204 | 207 | ||
205 | void CalendarLocal::deleteTodo( Todo *todo ) | 208 | void CalendarLocal::deleteTodo( Todo *todo ) |
206 | { | 209 | { |
207 | // Handle orphaned children | 210 | // Handle orphaned children |
208 | if ( mUndoIncidence ) delete mUndoIncidence; | 211 | if ( mUndoIncidence ) delete mUndoIncidence; |
209 | removeRelations( todo ); | 212 | removeRelations( todo ); |
210 | mUndoIncidence = todo->clone(); | 213 | mUndoIncidence = todo->clone(); |
211 | 214 | ||
212 | if ( mTodoList.removeRef( todo ) ) { | 215 | if ( mTodoList.removeRef( todo ) ) { |
213 | setModified( true ); | 216 | setModified( true ); |
214 | } | 217 | } |
215 | } | 218 | } |
216 | 219 | ||
217 | QPtrList<Todo> CalendarLocal::rawTodos() | 220 | QPtrList<Todo> CalendarLocal::rawTodos() |
218 | { | 221 | { |
219 | return mTodoList; | 222 | QPtrList<Todo> el; |
223 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | ||
224 | if ( it->calEnabled() ) el.append( it ); | ||
225 | return el; | ||
220 | } | 226 | } |
221 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 227 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
222 | { | 228 | { |
223 | Todo *todo; | 229 | Todo *todo; |
224 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 230 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
225 | if ( todo->getID( syncProf ) == id ) return todo; | 231 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
226 | } | 232 | } |
227 | 233 | ||
228 | return 0; | 234 | return 0; |
229 | } | 235 | } |
230 | void CalendarLocal::removeSyncInfo( QString syncProfile) | 236 | void CalendarLocal::removeSyncInfo( QString syncProfile) |
231 | { | 237 | { |
232 | QPtrList<Incidence> all = rawIncidences() ; | 238 | QPtrList<Incidence> all = rawIncidences() ; |
233 | Incidence *inc; | 239 | Incidence *inc; |
234 | for ( inc = all.first(); inc; inc = all.next() ) { | 240 | for ( inc = all.first(); inc; inc = all.next() ) { |
235 | inc->removeID( syncProfile ); | 241 | inc->removeID( syncProfile ); |
236 | } | 242 | } |
237 | if ( syncProfile.isEmpty() ) { | 243 | if ( syncProfile.isEmpty() ) { |
238 | QPtrList<Event> el; | 244 | QPtrList<Event> el; |
239 | Event *todo; | 245 | Event *todo; |
240 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 246 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
241 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 247 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
242 | el.append( todo ); | 248 | el.append( todo ); |
243 | } | 249 | } |
244 | for ( todo = el.first(); todo; todo = el.next() ) { | 250 | for ( todo = el.first(); todo; todo = el.next() ) { |
245 | deleteIncidence ( todo ); | 251 | deleteIncidence ( todo ); |
246 | } | 252 | } |
247 | } else { | 253 | } else { |
248 | Event *lse = event( "last-syncEvent-"+ syncProfile); | 254 | Event *lse = event( "last-syncEvent-"+ syncProfile); |
249 | if ( lse ) | 255 | if ( lse ) |
250 | deleteIncidence ( lse ); | 256 | deleteIncidence ( lse ); |
251 | } | 257 | } |
252 | } | 258 | } |
253 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 259 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
254 | { | 260 | { |
255 | QPtrList<Event> el; | 261 | QPtrList<Event> el; |
256 | Event *todo; | 262 | Event *todo; |
257 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 263 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
258 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 264 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
259 | if ( todo->summary().left(3) == "E: " ) | 265 | if ( todo->summary().left(3) == "E: " ) |
260 | el.append( todo ); | 266 | el.append( todo ); |
261 | } | 267 | } |
262 | 268 | ||
263 | return el; | 269 | return el; |
264 | 270 | ||
265 | } | 271 | } |
266 | Event *CalendarLocal::event( QString syncProf, QString id ) | 272 | Event *CalendarLocal::event( QString syncProf, QString id ) |
267 | { | 273 | { |
268 | Event *todo; | 274 | Event *todo; |
269 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 275 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
270 | if ( todo->getID( syncProf ) == id ) return todo; | 276 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
271 | } | 277 | } |
272 | 278 | ||
273 | return 0; | 279 | return 0; |
274 | } | 280 | } |
275 | Todo *CalendarLocal::todo( const QString &uid ) | 281 | Todo *CalendarLocal::todo( const QString &uid ) |
276 | { | 282 | { |
277 | Todo *todo; | 283 | Todo *todo; |
278 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 284 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
279 | if ( todo->uid() == uid ) return todo; | 285 | if ( todo->calEnabled() && todo->uid() == uid ) return todo; |
280 | } | 286 | } |
281 | 287 | ||
282 | return 0; | 288 | return 0; |
283 | } | 289 | } |
284 | QString CalendarLocal::nextSummary() const | 290 | QString CalendarLocal::nextSummary() const |
285 | { | 291 | { |
286 | return mNextSummary; | 292 | return mNextSummary; |
287 | } | 293 | } |
288 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 294 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
289 | { | 295 | { |
290 | return mNextAlarmEventDateTime; | 296 | return mNextAlarmEventDateTime; |
291 | } | 297 | } |
292 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 298 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
293 | { | 299 | { |
294 | //mNextAlarmIncidence | 300 | //mNextAlarmIncidence |
295 | //mNextAlarmDateTime | 301 | //mNextAlarmDateTime |
296 | //return mNextSummary; | 302 | //return mNextSummary; |
297 | //return mNextAlarmEventDateTime; | 303 | //return mNextAlarmEventDateTime; |
298 | bool newNextAlarm = false; | 304 | bool newNextAlarm = false; |
299 | bool computeNextAlarm = false; | 305 | bool computeNextAlarm = false; |
300 | bool ok; | 306 | bool ok; |
301 | int offset; | 307 | int offset; |
302 | QDateTime nextA; | 308 | QDateTime nextA; |
303 | // QString nextSum; | 309 | // QString nextSum; |
304 | //QDateTime nextEvent; | 310 | //QDateTime nextEvent; |
305 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { | 311 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { |
306 | computeNextAlarm = true; | 312 | computeNextAlarm = true; |
307 | } else { | 313 | } else { |
308 | if ( ! deleted ) { | 314 | if ( ! deleted ) { |
309 | nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 315 | nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
310 | if ( ok ) { | 316 | if ( ok ) { |
311 | if ( nextA < mNextAlarmDateTime ) { | 317 | if ( nextA < mNextAlarmDateTime ) { |
@@ -360,146 +366,151 @@ QString CalendarLocal:: getAlarmNotification() | |||
360 | ret += "\n" + mNextSummary.mid(25, 25 ); | 366 | ret += "\n" + mNextSummary.mid(25, 25 ); |
361 | ret+= "\n"+mNextAlarmEventDateTimeString; | 367 | ret+= "\n"+mNextAlarmEventDateTimeString; |
362 | return ret; | 368 | return ret; |
363 | } | 369 | } |
364 | void CalendarLocal::registerAlarm() | 370 | void CalendarLocal::registerAlarm() |
365 | { | 371 | { |
366 | mLastAlarmNotificationString = getAlarmNotification(); | 372 | mLastAlarmNotificationString = getAlarmNotification(); |
367 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); | 373 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); |
368 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 374 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
369 | // #ifndef DESKTOP_VERSION | 375 | // #ifndef DESKTOP_VERSION |
370 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); | 376 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); |
371 | // #endif | 377 | // #endif |
372 | } | 378 | } |
373 | void CalendarLocal::deRegisterAlarm() | 379 | void CalendarLocal::deRegisterAlarm() |
374 | { | 380 | { |
375 | if ( mLastAlarmNotificationString.isNull() ) | 381 | if ( mLastAlarmNotificationString.isNull() ) |
376 | return; | 382 | return; |
377 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); | 383 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); |
378 | 384 | ||
379 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 385 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
380 | mNextAlarmEventDateTime = QDateTime(); | 386 | mNextAlarmEventDateTime = QDateTime(); |
381 | // #ifndef DESKTOP_VERSION | 387 | // #ifndef DESKTOP_VERSION |
382 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); | 388 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); |
383 | // #endif | 389 | // #endif |
384 | } | 390 | } |
385 | 391 | ||
386 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) | 392 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) |
387 | { | 393 | { |
388 | QPtrList<Todo> todos; | 394 | QPtrList<Todo> todos; |
389 | 395 | ||
390 | Todo *todo; | 396 | Todo *todo; |
391 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 397 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
398 | if ( !todo->calEnabled() ) continue; | ||
392 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { | 399 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { |
393 | todos.append( todo ); | 400 | todos.append( todo ); |
394 | } | 401 | } |
395 | } | 402 | } |
396 | 403 | ||
397 | filter()->apply( &todos ); | 404 | filter()->apply( &todos ); |
398 | return todos; | 405 | return todos; |
399 | } | 406 | } |
400 | void CalendarLocal::reInitAlarmSettings() | 407 | void CalendarLocal::reInitAlarmSettings() |
401 | { | 408 | { |
402 | if ( !mNextAlarmIncidence ) { | 409 | if ( !mNextAlarmIncidence ) { |
403 | nextAlarm( 1000 ); | 410 | nextAlarm( 1000 ); |
404 | } | 411 | } |
405 | deRegisterAlarm(); | 412 | deRegisterAlarm(); |
406 | mNextAlarmIncidence = 0; | 413 | mNextAlarmIncidence = 0; |
407 | checkAlarmForIncidence( 0, false ); | 414 | checkAlarmForIncidence( 0, false ); |
408 | 415 | ||
409 | } | 416 | } |
410 | 417 | ||
411 | 418 | ||
412 | 419 | ||
413 | QDateTime CalendarLocal::nextAlarm( int daysTo ) | 420 | QDateTime CalendarLocal::nextAlarm( int daysTo ) |
414 | { | 421 | { |
415 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); | 422 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); |
416 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); | 423 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); |
417 | QDateTime next; | 424 | QDateTime next; |
418 | Event *e; | 425 | Event *e; |
419 | bool ok; | 426 | bool ok; |
420 | bool found = false; | 427 | bool found = false; |
421 | int offset; | 428 | int offset; |
422 | mNextAlarmIncidence = 0; | 429 | mNextAlarmIncidence = 0; |
423 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 430 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
431 | if ( !e->calEnabled() ) continue; | ||
424 | next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 432 | next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
425 | if ( ok ) { | 433 | if ( ok ) { |
426 | if ( next < nextA ) { | 434 | if ( next < nextA ) { |
427 | nextA = next; | 435 | nextA = next; |
428 | found = true; | 436 | found = true; |
429 | mNextSummary = e->summary(); | 437 | mNextSummary = e->summary(); |
430 | mNextAlarmEventDateTime = next.addSecs(offset ) ; | 438 | mNextAlarmEventDateTime = next.addSecs(offset ) ; |
431 | mNextAlarmIncidence = (Incidence *) e; | 439 | mNextAlarmIncidence = (Incidence *) e; |
432 | } | 440 | } |
433 | } | 441 | } |
434 | } | 442 | } |
435 | Todo *t; | 443 | Todo *t; |
436 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 444 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
445 | if ( !t->calEnabled() ) continue; | ||
437 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 446 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
438 | if ( ok ) { | 447 | if ( ok ) { |
439 | if ( next < nextA ) { | 448 | if ( next < nextA ) { |
440 | nextA = next; | 449 | nextA = next; |
441 | found = true; | 450 | found = true; |
442 | mNextSummary = t->summary(); | 451 | mNextSummary = t->summary(); |
443 | mNextAlarmEventDateTime = next.addSecs(offset ); | 452 | mNextAlarmEventDateTime = next.addSecs(offset ); |
444 | mNextAlarmIncidence = (Incidence *) t; | 453 | mNextAlarmIncidence = (Incidence *) t; |
445 | } | 454 | } |
446 | } | 455 | } |
447 | } | 456 | } |
448 | if ( mNextAlarmIncidence ) { | 457 | if ( mNextAlarmIncidence ) { |
449 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 458 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
450 | mNextAlarmDateTime = nextA; | 459 | mNextAlarmDateTime = nextA; |
451 | } | 460 | } |
452 | return nextA; | 461 | return nextA; |
453 | } | 462 | } |
454 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) | 463 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) |
455 | { | 464 | { |
456 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); | 465 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); |
457 | } | 466 | } |
458 | 467 | ||
459 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) | 468 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) |
460 | { | 469 | { |
461 | 470 | ||
462 | Alarm::List alarms; | 471 | Alarm::List alarms; |
463 | 472 | ||
464 | Event *e; | 473 | Event *e; |
465 | 474 | ||
466 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 475 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
476 | if ( !e->calEnabled() ) continue; | ||
467 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); | 477 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); |
468 | else appendAlarms( alarms, e, from, to ); | 478 | else appendAlarms( alarms, e, from, to ); |
469 | } | 479 | } |
470 | 480 | ||
471 | Todo *t; | 481 | Todo *t; |
472 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 482 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
473 | appendAlarms( alarms, t, from, to ); | 483 | if ( !t->calEnabled() ) continue; |
484 | appendAlarms( alarms, t, from, to ); | ||
474 | } | 485 | } |
475 | 486 | ||
476 | return alarms; | 487 | return alarms; |
477 | } | 488 | } |
478 | 489 | ||
479 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, | 490 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, |
480 | const QDateTime &from, const QDateTime &to ) | 491 | const QDateTime &from, const QDateTime &to ) |
481 | { | 492 | { |
482 | QPtrList<Alarm> alarmList = incidence->alarms(); | 493 | QPtrList<Alarm> alarmList = incidence->alarms(); |
483 | Alarm *alarm; | 494 | Alarm *alarm; |
484 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 495 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
485 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() | 496 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() |
486 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; | 497 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; |
487 | if ( alarm->enabled() ) { | 498 | if ( alarm->enabled() ) { |
488 | if ( alarm->time() >= from && alarm->time() <= to ) { | 499 | if ( alarm->time() >= from && alarm->time() <= to ) { |
489 | alarms.append( alarm ); | 500 | alarms.append( alarm ); |
490 | } | 501 | } |
491 | } | 502 | } |
492 | } | 503 | } |
493 | } | 504 | } |
494 | 505 | ||
495 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, | 506 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, |
496 | Incidence *incidence, | 507 | Incidence *incidence, |
497 | const QDateTime &from, | 508 | const QDateTime &from, |
498 | const QDateTime &to ) | 509 | const QDateTime &to ) |
499 | { | 510 | { |
500 | 511 | ||
501 | QPtrList<Alarm> alarmList = incidence->alarms(); | 512 | QPtrList<Alarm> alarmList = incidence->alarms(); |
502 | Alarm *alarm; | 513 | Alarm *alarm; |
503 | QDateTime qdt; | 514 | QDateTime qdt; |
504 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 515 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
505 | if (incidence->recursOn(from.date())) { | 516 | if (incidence->recursOn(from.date())) { |
@@ -514,116 +525,118 @@ void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, | |||
514 | } | 525 | } |
515 | } | 526 | } |
516 | } | 527 | } |
517 | } | 528 | } |
518 | 529 | ||
519 | 530 | ||
520 | /****************************** PROTECTED METHODS ****************************/ | 531 | /****************************** PROTECTED METHODS ****************************/ |
521 | 532 | ||
522 | // after changes are made to an event, this should be called. | 533 | // after changes are made to an event, this should be called. |
523 | void CalendarLocal::update( IncidenceBase *incidence ) | 534 | void CalendarLocal::update( IncidenceBase *incidence ) |
524 | { | 535 | { |
525 | incidence->setSyncStatus( Event::SYNCMOD ); | 536 | incidence->setSyncStatus( Event::SYNCMOD ); |
526 | incidence->setLastModified( QDateTime::currentDateTime() ); | 537 | incidence->setLastModified( QDateTime::currentDateTime() ); |
527 | // we should probably update the revision number here, | 538 | // we should probably update the revision number here, |
528 | // or internally in the Event itself when certain things change. | 539 | // or internally in the Event itself when certain things change. |
529 | // need to verify with ical documentation. | 540 | // need to verify with ical documentation. |
530 | 541 | ||
531 | setModified( true ); | 542 | setModified( true ); |
532 | } | 543 | } |
533 | 544 | ||
534 | void CalendarLocal::insertEvent( Event *event ) | 545 | void CalendarLocal::insertEvent( Event *event ) |
535 | { | 546 | { |
536 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); | 547 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); |
537 | } | 548 | } |
538 | 549 | ||
539 | 550 | ||
540 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | 551 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) |
541 | { | 552 | { |
542 | QPtrList<Event> eventList; | 553 | QPtrList<Event> eventList; |
543 | 554 | ||
544 | Event *event; | 555 | Event *event; |
545 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 556 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
557 | if ( !event->calEnabled() ) continue; | ||
546 | if ( event->doesRecur() ) { | 558 | if ( event->doesRecur() ) { |
547 | if ( event->isMultiDay() ) { | 559 | if ( event->isMultiDay() ) { |
548 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); | 560 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); |
549 | int i; | 561 | int i; |
550 | for ( i = 0; i <= extraDays; i++ ) { | 562 | for ( i = 0; i <= extraDays; i++ ) { |
551 | if ( event->recursOn( qd.addDays( -i ) ) ) { | 563 | if ( event->recursOn( qd.addDays( -i ) ) ) { |
552 | eventList.append( event ); | 564 | eventList.append( event ); |
553 | break; | 565 | break; |
554 | } | 566 | } |
555 | } | 567 | } |
556 | } else { | 568 | } else { |
557 | if ( event->recursOn( qd ) ) | 569 | if ( event->recursOn( qd ) ) |
558 | eventList.append( event ); | 570 | eventList.append( event ); |
559 | } | 571 | } |
560 | } else { | 572 | } else { |
561 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { | 573 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { |
562 | eventList.append( event ); | 574 | eventList.append( event ); |
563 | } | 575 | } |
564 | } | 576 | } |
565 | } | 577 | } |
566 | 578 | ||
567 | if ( !sorted ) { | 579 | if ( !sorted ) { |
568 | return eventList; | 580 | return eventList; |
569 | } | 581 | } |
570 | 582 | ||
571 | // kdDebug(5800) << "Sorting events for date\n" << endl; | 583 | // kdDebug(5800) << "Sorting events for date\n" << endl; |
572 | // now, we have to sort it based on dtStart.time() | 584 | // now, we have to sort it based on dtStart.time() |
573 | QPtrList<Event> eventListSorted; | 585 | QPtrList<Event> eventListSorted; |
574 | Event *sortEvent; | 586 | Event *sortEvent; |
575 | for ( event = eventList.first(); event; event = eventList.next() ) { | 587 | for ( event = eventList.first(); event; event = eventList.next() ) { |
576 | sortEvent = eventListSorted.first(); | 588 | sortEvent = eventListSorted.first(); |
577 | int i = 0; | 589 | int i = 0; |
578 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) | 590 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) |
579 | { | 591 | { |
580 | i++; | 592 | i++; |
581 | sortEvent = eventListSorted.next(); | 593 | sortEvent = eventListSorted.next(); |
582 | } | 594 | } |
583 | eventListSorted.insert( i, event ); | 595 | eventListSorted.insert( i, event ); |
584 | } | 596 | } |
585 | return eventListSorted; | 597 | return eventListSorted; |
586 | } | 598 | } |
587 | 599 | ||
588 | 600 | ||
589 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 601 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
590 | bool inclusive ) | 602 | bool inclusive ) |
591 | { | 603 | { |
592 | Event *event = 0; | 604 | Event *event = 0; |
593 | 605 | ||
594 | QPtrList<Event> eventList; | 606 | QPtrList<Event> eventList; |
595 | 607 | ||
596 | // Get non-recurring events | 608 | // Get non-recurring events |
597 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 609 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
610 | if ( !event->calEnabled() ) continue; | ||
598 | if ( event->doesRecur() ) { | 611 | if ( event->doesRecur() ) { |
599 | QDate rStart = event->dtStart().date(); | 612 | QDate rStart = event->dtStart().date(); |
600 | bool found = false; | 613 | bool found = false; |
601 | if ( inclusive ) { | 614 | if ( inclusive ) { |
602 | if ( rStart >= start && rStart <= end ) { | 615 | if ( rStart >= start && rStart <= end ) { |
603 | // Start date of event is in range. Now check for end date. | 616 | // Start date of event is in range. Now check for end date. |
604 | // if duration is negative, event recurs forever, so do not include it. | 617 | // if duration is negative, event recurs forever, so do not include it. |
605 | if ( event->recurrence()->duration() == 0 ) { // End date set | 618 | if ( event->recurrence()->duration() == 0 ) { // End date set |
606 | QDate rEnd = event->recurrence()->endDate(); | 619 | QDate rEnd = event->recurrence()->endDate(); |
607 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 620 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
608 | found = true; | 621 | found = true; |
609 | } | 622 | } |
610 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 623 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
611 | // TODO: Calculate end date from duration. Should be done in Event | 624 | // TODO: Calculate end date from duration. Should be done in Event |
612 | // For now exclude all events with a duration. | 625 | // For now exclude all events with a duration. |
613 | } | 626 | } |
614 | } | 627 | } |
615 | } else { | 628 | } else { |
616 | bool founOne; | 629 | bool founOne; |
617 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 630 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
618 | if ( founOne ) { | 631 | if ( founOne ) { |
619 | if ( next <= end ) { | 632 | if ( next <= end ) { |
620 | found = true; | 633 | found = true; |
621 | } | 634 | } |
622 | } | 635 | } |
623 | 636 | ||
624 | /* | 637 | /* |
625 | // crap !!! | 638 | // crap !!! |
626 | if ( rStart <= end ) { // Start date not after range | 639 | if ( rStart <= end ) { // Start date not after range |
627 | if ( rStart >= start ) { // Start date within range | 640 | if ( rStart >= start ) { // Start date within range |
628 | found = true; | 641 | found = true; |
629 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 642 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
@@ -641,86 +654,129 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | |||
641 | } | 654 | } |
642 | */ | 655 | */ |
643 | 656 | ||
644 | } | 657 | } |
645 | 658 | ||
646 | if ( found ) eventList.append( event ); | 659 | if ( found ) eventList.append( event ); |
647 | } else { | 660 | } else { |
648 | QDate s = event->dtStart().date(); | 661 | QDate s = event->dtStart().date(); |
649 | QDate e = event->dtEnd().date(); | 662 | QDate e = event->dtEnd().date(); |
650 | 663 | ||
651 | if ( inclusive ) { | 664 | if ( inclusive ) { |
652 | if ( s >= start && e <= end ) { | 665 | if ( s >= start && e <= end ) { |
653 | eventList.append( event ); | 666 | eventList.append( event ); |
654 | } | 667 | } |
655 | } else { | 668 | } else { |
656 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { | 669 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { |
657 | eventList.append( event ); | 670 | eventList.append( event ); |
658 | } | 671 | } |
659 | } | 672 | } |
660 | } | 673 | } |
661 | } | 674 | } |
662 | 675 | ||
663 | return eventList; | 676 | return eventList; |
664 | } | 677 | } |
665 | 678 | ||
666 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 679 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
667 | { | 680 | { |
668 | return rawEventsForDate( qdt.date() ); | 681 | return rawEventsForDate( qdt.date() ); |
669 | } | 682 | } |
670 | 683 | ||
671 | QPtrList<Event> CalendarLocal::rawEvents() | 684 | QPtrList<Event> CalendarLocal::rawEvents() |
672 | { | 685 | { |
673 | return mEventList; | 686 | QPtrList<Event> el; |
687 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | ||
688 | if ( it->calEnabled() ) el.append( it ); | ||
689 | return el; | ||
674 | } | 690 | } |
675 | 691 | ||
676 | bool CalendarLocal::addJournal(Journal *journal) | 692 | bool CalendarLocal::addJournal(Journal *journal) |
677 | { | 693 | { |
678 | if ( journal->dtStart().isValid()) | 694 | if ( journal->dtStart().isValid()) |
679 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; | 695 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; |
680 | else | 696 | else |
681 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; | 697 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; |
682 | 698 | ||
683 | mJournalList.append(journal); | 699 | mJournalList.append(journal); |
684 | 700 | ||
685 | journal->registerObserver( this ); | 701 | journal->registerObserver( this ); |
686 | 702 | ||
687 | setModified( true ); | 703 | setModified( true ); |
688 | 704 | journal->setCalID( mDefaultCalendar ); | |
705 | journal->setCalEnabled( true ); | ||
689 | return true; | 706 | return true; |
690 | } | 707 | } |
691 | 708 | ||
692 | void CalendarLocal::deleteJournal( Journal *journal ) | 709 | void CalendarLocal::deleteJournal( Journal *journal ) |
693 | { | 710 | { |
694 | if ( mUndoIncidence ) delete mUndoIncidence; | 711 | if ( mUndoIncidence ) delete mUndoIncidence; |
695 | mUndoIncidence = journal->clone(); | 712 | mUndoIncidence = journal->clone(); |
696 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); | 713 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); |
697 | if ( mJournalList.removeRef(journal) ) { | 714 | if ( mJournalList.removeRef(journal) ) { |
698 | setModified( true ); | 715 | setModified( true ); |
699 | } | 716 | } |
700 | } | 717 | } |
701 | 718 | ||
702 | Journal *CalendarLocal::journal( const QDate &date ) | 719 | Journal *CalendarLocal::journal( const QDate &date ) |
703 | { | 720 | { |
704 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 721 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
705 | 722 | ||
706 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 723 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
707 | if ( it->dtStart().date() == date ) | 724 | if ( it->calEnabled() && it->dtStart().date() == date ) |
708 | return it; | 725 | return it; |
709 | 726 | ||
710 | return 0; | 727 | return 0; |
711 | } | 728 | } |
712 | 729 | ||
713 | Journal *CalendarLocal::journal( const QString &uid ) | 730 | Journal *CalendarLocal::journal( const QString &uid ) |
714 | { | 731 | { |
715 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 732 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
716 | if ( it->uid() == uid ) | 733 | if ( it->calEnabled() && it->uid() == uid ) |
717 | return it; | 734 | return it; |
718 | 735 | ||
719 | return 0; | 736 | return 0; |
720 | } | 737 | } |
721 | 738 | ||
722 | QPtrList<Journal> CalendarLocal::journals() | 739 | QPtrList<Journal> CalendarLocal::journals() |
723 | { | 740 | { |
724 | return mJournalList; | 741 | QPtrList<Journal> el; |
742 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | ||
743 | if ( it->calEnabled() ) el.append( it ); | ||
744 | return el; | ||
725 | } | 745 | } |
726 | 746 | ||
747 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) | ||
748 | { | ||
749 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | ||
750 | if ( it->calID() == id ) it->setCalEnabled( enable ); | ||
751 | |||
752 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | ||
753 | if ( it->calID() == id ) it->setCalEnabled( enable ); | ||
754 | |||
755 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | ||
756 | if ( it->calID() == id ) it->setCalEnabled( enable ); | ||
757 | |||
758 | } | ||
759 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) | ||
760 | { | ||
761 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | ||
762 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | ||
763 | |||
764 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | ||
765 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | ||
766 | |||
767 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | ||
768 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | ||
769 | |||
770 | } | ||
771 | void CalendarLocal::setDefaultCalendarEnabledOnly() | ||
772 | { | ||
773 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | ||
774 | it->setCalEnabled( it->calID() == mDefaultCalendar ); | ||
775 | |||
776 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | ||
777 | it->setCalEnabled( it->calID() == mDefaultCalendar); | ||
778 | |||
779 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | ||
780 | it->setCalEnabled( it->calID() == mDefaultCalendar); | ||
781 | |||
782 | } | ||
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 98ec710..b25fcbe 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -151,64 +151,67 @@ class CalendarLocal : public Calendar | |||
151 | QDateTime nextAlarmEventDateTime() const; | 151 | QDateTime nextAlarmEventDateTime() const; |
152 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; | 152 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; |
153 | void registerAlarm(); | 153 | void registerAlarm(); |
154 | void deRegisterAlarm(); | 154 | void deRegisterAlarm(); |
155 | QString getAlarmNotification(); | 155 | QString getAlarmNotification(); |
156 | QString nextSummary() const ; | 156 | QString nextSummary() const ; |
157 | /** | 157 | /** |
158 | This method should be called whenever a Event is modified directly | 158 | This method should be called whenever a Event is modified directly |
159 | via it's pointer. It makes sure that the calendar is internally | 159 | via it's pointer. It makes sure that the calendar is internally |
160 | consistent. | 160 | consistent. |
161 | */ | 161 | */ |
162 | void update( IncidenceBase *incidence ); | 162 | void update( IncidenceBase *incidence ); |
163 | 163 | ||
164 | /** | 164 | /** |
165 | Builds and then returns a list of all events that match for the | 165 | Builds and then returns a list of all events that match for the |
166 | date specified. useful for dayView, etc. etc. | 166 | date specified. useful for dayView, etc. etc. |
167 | */ | 167 | */ |
168 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); | 168 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); |
169 | /** | 169 | /** |
170 | Get unfiltered events for date \a qdt. | 170 | Get unfiltered events for date \a qdt. |
171 | */ | 171 | */ |
172 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); | 172 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); |
173 | /** | 173 | /** |
174 | Get unfiltered events in a range of dates. If inclusive is set to true, | 174 | Get unfiltered events in a range of dates. If inclusive is set to true, |
175 | only events are returned, which are completely included in the range. | 175 | only events are returned, which are completely included in the range. |
176 | */ | 176 | */ |
177 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 177 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
178 | bool inclusive = false ); | 178 | bool inclusive = false ); |
179 | Todo *todo( QString, QString ); | 179 | Todo *todo( QString, QString ); |
180 | Event *event( QString, QString ); | 180 | Event *event( QString, QString ); |
181 | 181 | ||
182 | 182 | ||
183 | void setCalendarEnabled( int id, bool enable ); | ||
184 | void setAlarmEnabled( int id, bool enable ); | ||
185 | void setDefaultCalendarEnabledOnly(); | ||
183 | 186 | ||
184 | protected: | 187 | protected: |
185 | 188 | ||
186 | // Event* mNextAlarmEvent; | 189 | // Event* mNextAlarmEvent; |
187 | QString mNextSummary; | 190 | QString mNextSummary; |
188 | QString mNextAlarmEventDateTimeString; | 191 | QString mNextAlarmEventDateTimeString; |
189 | QString mLastAlarmNotificationString; | 192 | QString mLastAlarmNotificationString; |
190 | QDateTime mNextAlarmEventDateTime; | 193 | QDateTime mNextAlarmEventDateTime; |
191 | QDateTime mNextAlarmDateTime; | 194 | QDateTime mNextAlarmDateTime; |
192 | void reInitAlarmSettings(); | 195 | void reInitAlarmSettings(); |
193 | 196 | ||
194 | /** Notification function of IncidenceBase::Observer. */ | 197 | /** Notification function of IncidenceBase::Observer. */ |
195 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } | 198 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } |
196 | 199 | ||
197 | /** inserts an event into its "proper place" in the calendar. */ | 200 | /** inserts an event into its "proper place" in the calendar. */ |
198 | void insertEvent( Event *event ); | 201 | void insertEvent( Event *event ); |
199 | 202 | ||
200 | /** Append alarms of incidence in interval to list of alarms. */ | 203 | /** Append alarms of incidence in interval to list of alarms. */ |
201 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, | 204 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, |
202 | const QDateTime &from, const QDateTime &to ); | 205 | const QDateTime &from, const QDateTime &to ); |
203 | 206 | ||
204 | /** Append alarms of recurring events in interval to list of alarms. */ | 207 | /** Append alarms of recurring events in interval to list of alarms. */ |
205 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, | 208 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, |
206 | const QDateTime &from, const QDateTime &to ); | 209 | const QDateTime &from, const QDateTime &to ); |
207 | 210 | ||
208 | private: | 211 | private: |
209 | void init(); | 212 | void init(); |
210 | 213 | ||
211 | QPtrList<Event> mEventList; | 214 | QPtrList<Event> mEventList; |
212 | QPtrList<Todo> mTodoList; | 215 | QPtrList<Todo> mTodoList; |
213 | QPtrList<Journal> mJournalList; | 216 | QPtrList<Journal> mJournalList; |
214 | }; | 217 | }; |
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp index 20078a7..3510c7d 100644 --- a/libkcal/calfilter.cpp +++ b/libkcal/calfilter.cpp | |||
@@ -49,90 +49,99 @@ void CalFilter::apply(QPtrList<Event> *eventlist) | |||
49 | 49 | ||
50 | Event *event = eventlist->first(); | 50 | Event *event = eventlist->first(); |
51 | while(event) { | 51 | while(event) { |
52 | if (!filterEvent(event)) { | 52 | if (!filterEvent(event)) { |
53 | eventlist->remove(); | 53 | eventlist->remove(); |
54 | event = eventlist->current(); | 54 | event = eventlist->current(); |
55 | } else { | 55 | } else { |
56 | event = eventlist->next(); | 56 | event = eventlist->next(); |
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->calEnabled() ) | ||
82 | return false; | ||
81 | if ( in->typeID() == eventID ) | 83 | if ( in->typeID() == eventID ) |
82 | return filterEvent( (Event*) in ); | 84 | return filterEvent( (Event*) in ); |
83 | else if ( in->typeID() == todoID ) | 85 | else if ( in->typeID() == todoID ) |
84 | return filterTodo( (Todo*) in); | 86 | return filterTodo( (Todo*) in); |
85 | else if ( in->typeID () == journalID ) | 87 | else if ( in->typeID () == journalID ) |
86 | return filterJournal( (Journal*) in ); | 88 | return filterJournal( (Journal*) in ); |
87 | return false; | 89 | return false; |
88 | } | 90 | } |
89 | bool CalFilter::filterEvent(Event *event) | 91 | bool CalFilter::filterEvent(Event *event) |
90 | { | 92 | { |
93 | |||
94 | if ( !event->calEnabled() ) | ||
95 | return false; | ||
91 | if (mCriteria & HideEvents) | 96 | if (mCriteria & HideEvents) |
92 | return false; | 97 | return false; |
93 | if (mCriteria & HideRecurring) { | 98 | if (mCriteria & HideRecurring) { |
94 | if (event->recurrence()->doesRecur()) return false; | 99 | if (event->recurrence()->doesRecur()) return false; |
95 | } | 100 | } |
96 | 101 | ||
97 | return filterIncidence(event); | 102 | return filterIncidence(event); |
98 | } | 103 | } |
99 | bool CalFilter::filterJournal(Journal *j) | 104 | bool CalFilter::filterJournal(Journal *j) |
100 | { | 105 | { |
106 | if ( !j->calEnabled() ) | ||
107 | return false; | ||
101 | if (mCriteria & HideJournals) | 108 | if (mCriteria & HideJournals) |
102 | return false; | 109 | return false; |
103 | return true; | 110 | return true; |
104 | } | 111 | } |
105 | bool CalFilter::filterTodo(Todo *todo) | 112 | bool CalFilter::filterTodo(Todo *todo) |
106 | { | 113 | { |
114 | if ( !todo->calEnabled() ) | ||
115 | return false; | ||
107 | if (mCriteria & HideTodos) | 116 | if (mCriteria & HideTodos) |
108 | return false; | 117 | return false; |
109 | if (mCriteria & HideCompleted) { | 118 | if (mCriteria & HideCompleted) { |
110 | if (todo->isCompleted()) return false; | 119 | if (todo->isCompleted()) return false; |
111 | } | 120 | } |
112 | 121 | ||
113 | return filterIncidence(todo); | 122 | return filterIncidence(todo); |
114 | } | 123 | } |
115 | bool CalFilter::showCategories() | 124 | bool CalFilter::showCategories() |
116 | { | 125 | { |
117 | return mCriteria & ShowCategories; | 126 | return mCriteria & ShowCategories; |
118 | } | 127 | } |
119 | int CalFilter::getSecrecy() | 128 | int CalFilter::getSecrecy() |
120 | { | 129 | { |
121 | if ( (mCriteria & ShowPublic )) | 130 | if ( (mCriteria & ShowPublic )) |
122 | return Incidence::SecrecyPublic; | 131 | return Incidence::SecrecyPublic; |
123 | if ( (mCriteria & ShowPrivate )) | 132 | if ( (mCriteria & ShowPrivate )) |
124 | return Incidence::SecrecyPrivate; | 133 | return Incidence::SecrecyPrivate; |
125 | if ( (mCriteria & ShowConfidential )) | 134 | if ( (mCriteria & ShowConfidential )) |
126 | return Incidence::SecrecyConfidential; | 135 | return Incidence::SecrecyConfidential; |
127 | return Incidence::SecrecyPublic; | 136 | return Incidence::SecrecyPublic; |
128 | } | 137 | } |
129 | bool CalFilter::filterIncidence(Incidence *incidence) | 138 | bool CalFilter::filterIncidence(Incidence *incidence) |
130 | { | 139 | { |
131 | if ( mCriteria > 7 ) { | 140 | if ( mCriteria > 7 ) { |
132 | switch (incidence->secrecy()) { | 141 | switch (incidence->secrecy()) { |
133 | case Incidence::SecrecyPublic: | 142 | case Incidence::SecrecyPublic: |
134 | if (! (mCriteria & ShowPublic )) | 143 | if (! (mCriteria & ShowPublic )) |
135 | return false; | 144 | return false; |
136 | break; | 145 | break; |
137 | case Incidence::SecrecyPrivate: | 146 | case Incidence::SecrecyPrivate: |
138 | if (! (mCriteria & ShowPrivate )) | 147 | if (! (mCriteria & ShowPrivate )) |
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h index 29db441..e349770 100644 --- a/libkcal/calfilter.h +++ b/libkcal/calfilter.h | |||
@@ -1,60 +1,61 @@ | |||
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 _CALFILTER_H | 21 | #ifndef _CALFILTER_H |
22 | #define _CALFILTER_H | 22 | #define _CALFILTER_H |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | 26 | ||
27 | #include "event.h" | 27 | #include "event.h" |
28 | #include "todo.h" | 28 | #include "todo.h" |
29 | #include "journal.h" | ||
29 | 30 | ||
30 | namespace KCal { | 31 | namespace KCal { |
31 | 32 | ||
32 | /** | 33 | /** |
33 | Filter for calendar objects. | 34 | Filter for calendar objects. |
34 | */ | 35 | */ |
35 | class CalFilter { | 36 | class CalFilter { |
36 | public: | 37 | public: |
37 | /** Construct filter. */ | 38 | /** Construct filter. */ |
38 | CalFilter(); | 39 | CalFilter(); |
39 | /** Construct filter with name */ | 40 | /** Construct filter with name */ |
40 | CalFilter(const QString &name); | 41 | CalFilter(const QString &name); |
41 | /** Destruct filter. */ | 42 | /** Destruct filter. */ |
42 | ~CalFilter(); | 43 | ~CalFilter(); |
43 | 44 | ||
44 | /** | 45 | /** |
45 | Set name of filter. | 46 | Set name of filter. |
46 | */ | 47 | */ |
47 | void setName(const QString &name) { mName = name; } | 48 | void setName(const QString &name) { mName = name; } |
48 | /** | 49 | /** |
49 | Return name of filter. | 50 | Return name of filter. |
50 | */ | 51 | */ |
51 | QString name() const { return mName; } | 52 | QString name() const { return mName; } |
52 | 53 | ||
53 | /** | 54 | /** |
54 | Apply filter to eventlist, all events not matching filter criterias are | 55 | Apply filter to eventlist, all events not matching filter criterias are |
55 | removed from the list. | 56 | removed from the list. |
56 | */ | 57 | */ |
57 | void apply(QPtrList<Event> *eventlist); | 58 | void apply(QPtrList<Event> *eventlist); |
58 | 59 | ||
59 | /** | 60 | /** |
60 | Apply filter to todolist, all todos not matching filter criterias are | 61 | Apply filter to todolist, all todos not matching filter criterias are |
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index 9b99855..7cd81fa 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -144,65 +144,67 @@ void Event::setHasEndDate(bool b) | |||
144 | } | 144 | } |
145 | 145 | ||
146 | bool Event::hasEndDate() const | 146 | bool Event::hasEndDate() const |
147 | { | 147 | { |
148 | return mHasEndDate; | 148 | return mHasEndDate; |
149 | } | 149 | } |
150 | 150 | ||
151 | bool Event::isMultiDay() const | 151 | bool Event::isMultiDay() const |
152 | { | 152 | { |
153 | bool multi = !(dtStart().date() == dtEnd().date()); | 153 | bool multi = !(dtStart().date() == dtEnd().date()); |
154 | return multi; | 154 | return multi; |
155 | } | 155 | } |
156 | 156 | ||
157 | void Event::setTransparency(Event::Transparency transparency) | 157 | void Event::setTransparency(Event::Transparency transparency) |
158 | { | 158 | { |
159 | if (mReadOnly) return; | 159 | if (mReadOnly) return; |
160 | mTransparency = transparency; | 160 | mTransparency = transparency; |
161 | updated(); | 161 | updated(); |
162 | } | 162 | } |
163 | 163 | ||
164 | Event::Transparency Event::transparency() const | 164 | Event::Transparency Event::transparency() const |
165 | { | 165 | { |
166 | return mTransparency; | 166 | return mTransparency; |
167 | } | 167 | } |
168 | 168 | ||
169 | void Event::setDuration(int seconds) | 169 | void Event::setDuration(int seconds) |
170 | { | 170 | { |
171 | setHasEndDate(false); | 171 | setHasEndDate(false); |
172 | Incidence::setDuration(seconds); | 172 | Incidence::setDuration(seconds); |
173 | } | 173 | } |
174 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 174 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
175 | { | 175 | { |
176 | 176 | *ok = false; | |
177 | if ( !alarmEnabled() ) | ||
178 | return QDateTime (); | ||
177 | bool yes; | 179 | bool yes; |
178 | QDateTime incidenceStart = getNextOccurence( start_dt, &yes ); | 180 | QDateTime incidenceStart = getNextOccurence( start_dt, &yes ); |
179 | if ( ! yes || cancelled() ) { | 181 | if ( ! yes || cancelled() ) { |
180 | *ok = false; | 182 | *ok = false; |
181 | return QDateTime (); | 183 | return QDateTime (); |
182 | } | 184 | } |
183 | 185 | ||
184 | bool enabled = false; | 186 | bool enabled = false; |
185 | Alarm* alarm; | 187 | Alarm* alarm; |
186 | int off = 0; | 188 | int off = 0; |
187 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 189 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
188 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 190 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
189 | // *ok = false; | 191 | // *ok = false; |
190 | // return incidenceStart; | 192 | // return incidenceStart; |
191 | // } | 193 | // } |
192 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 194 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
193 | if (alarm->enabled()) { | 195 | if (alarm->enabled()) { |
194 | if ( alarm->hasTime () ) { | 196 | if ( alarm->hasTime () ) { |
195 | if ( alarm->time() < alarmStart ) { | 197 | if ( alarm->time() < alarmStart ) { |
196 | alarmStart = alarm->time(); | 198 | alarmStart = alarm->time(); |
197 | enabled = true; | 199 | enabled = true; |
198 | off = alarmStart.secsTo( incidenceStart ); | 200 | off = alarmStart.secsTo( incidenceStart ); |
199 | } | 201 | } |
200 | 202 | ||
201 | } else { | 203 | } else { |
202 | int secs = alarm->startOffset().asSeconds(); | 204 | int secs = alarm->startOffset().asSeconds(); |
203 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 205 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
204 | alarmStart = incidenceStart.addSecs( secs ); | 206 | alarmStart = incidenceStart.addSecs( secs ); |
205 | enabled = true; | 207 | enabled = true; |
206 | off = -secs; | 208 | off = -secs; |
207 | } | 209 | } |
208 | } | 210 | } |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index b5fe2e6..2ddbb01 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -15,75 +15,82 @@ | |||
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 | #include <kidmanager.h> | 24 | #include <kidmanager.h> |
25 | 25 | ||
26 | #include "calformat.h" | 26 | #include "calformat.h" |
27 | #include "syncdefines.h" | 27 | #include "syncdefines.h" |
28 | 28 | ||
29 | #include "incidencebase.h" | 29 | #include "incidencebase.h" |
30 | 30 | ||
31 | using namespace KCal; | 31 | using namespace KCal; |
32 | 32 | ||
33 | IncidenceBase::IncidenceBase() : | 33 | IncidenceBase::IncidenceBase() : |
34 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), | 34 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), |
35 | mPilotId(0), mSyncStatus(SYNCMOD) | 35 | mPilotId(0), mSyncStatus(SYNCMOD) |
36 | { | 36 | { |
37 | setUid(CalFormat::createUniqueId()); | 37 | setUid(CalFormat::createUniqueId()); |
38 | mOrganizer = ""; | 38 | mOrganizer = ""; |
39 | mFloats = false; | 39 | mFloats = false; |
40 | mDuration = 0; | 40 | mDuration = 0; |
41 | mHasDuration = false; | 41 | mHasDuration = false; |
42 | mPilotId = 0; | 42 | mPilotId = 0; |
43 | mExternalId = ":"; | 43 | mExternalId = ":"; |
44 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 44 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
45 | mSyncStatus = 0; | 45 | mSyncStatus = 0; |
46 | mAttendees.setAutoDelete( true ); | 46 | mAttendees.setAutoDelete( true ); |
47 | mCalEnabled = true; | ||
48 | mAlarmEnabled = true; | ||
49 | mCalID = 0; | ||
47 | } | 50 | } |
48 | 51 | ||
49 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : | 52 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : |
50 | CustomProperties( i ) | 53 | CustomProperties( i ) |
51 | { | 54 | { |
55 | |||
52 | mReadOnly = i.mReadOnly; | 56 | mReadOnly = i.mReadOnly; |
53 | mDtStart = i.mDtStart; | 57 | mDtStart = i.mDtStart; |
54 | mDuration = i.mDuration; | 58 | mDuration = i.mDuration; |
55 | mHasDuration = i.mHasDuration; | 59 | mHasDuration = i.mHasDuration; |
56 | mOrganizer = i.mOrganizer; | 60 | mOrganizer = i.mOrganizer; |
57 | mUid = i.mUid; | 61 | mUid = i.mUid; |
62 | mCalEnabled = i.mCalEnabled; | ||
63 | mAlarmEnabled = i.mAlarmEnabled; | ||
64 | mCalID = i.mCalID; | ||
58 | QPtrList<Attendee> attendees = i.attendees(); | 65 | QPtrList<Attendee> attendees = i.attendees(); |
59 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { | 66 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { |
60 | mAttendees.append( new Attendee( *a ) ); | 67 | mAttendees.append( new Attendee( *a ) ); |
61 | } | 68 | } |
62 | mFloats = i.mFloats; | 69 | mFloats = i.mFloats; |
63 | mLastModified = i.mLastModified; | 70 | mLastModified = i.mLastModified; |
64 | mPilotId = i.mPilotId; | 71 | mPilotId = i.mPilotId; |
65 | mTempSyncStat = i.mTempSyncStat; | 72 | mTempSyncStat = i.mTempSyncStat; |
66 | mSyncStatus = i.mSyncStatus; | 73 | mSyncStatus = i.mSyncStatus; |
67 | mExternalId = i.mExternalId; | 74 | mExternalId = i.mExternalId; |
68 | // The copied object is a new one, so it isn't observed by the observer | 75 | // The copied object is a new one, so it isn't observed by the observer |
69 | // of the original object. | 76 | // of the original object. |
70 | mObservers.clear(); | 77 | mObservers.clear(); |
71 | 78 | ||
72 | mAttendees.setAutoDelete( true ); | 79 | mAttendees.setAutoDelete( true ); |
73 | } | 80 | } |
74 | 81 | ||
75 | IncidenceBase::~IncidenceBase() | 82 | IncidenceBase::~IncidenceBase() |
76 | { | 83 | { |
77 | } | 84 | } |
78 | 85 | ||
79 | 86 | ||
80 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | 87 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) |
81 | { | 88 | { |
82 | // do not compare mSyncStatus and mExternalId | 89 | // do not compare mSyncStatus and mExternalId |
83 | if( i1.attendees().count() != i2.attendees().count() ) { | 90 | if( i1.attendees().count() != i2.attendees().count() ) { |
84 | return false; // no need to check further | 91 | return false; // no need to check further |
85 | } | 92 | } |
86 | if ( i1.attendees().count() > 0 ) { | 93 | if ( i1.attendees().count() > 0 ) { |
87 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; | 94 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; |
88 | while ( a1 ) { | 95 | while ( a1 ) { |
89 | if ( !( (*a1) == (*a2)) ) | 96 | if ( !( (*a1) == (*a2)) ) |
@@ -103,64 +110,90 @@ bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | |||
103 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); | 110 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); |
104 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); | 111 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); |
105 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); | 112 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); |
106 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); | 113 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); |
107 | 114 | ||
108 | #endif | 115 | #endif |
109 | if ( i1.hasDuration() == i2.hasDuration() ) { | 116 | if ( i1.hasDuration() == i2.hasDuration() ) { |
110 | if ( i1.hasDuration() ) { | 117 | if ( i1.hasDuration() ) { |
111 | if ( i1.duration() != i2.duration() ) | 118 | if ( i1.duration() != i2.duration() ) |
112 | return false; | 119 | return false; |
113 | } | 120 | } |
114 | } else { | 121 | } else { |
115 | return false; | 122 | return false; |
116 | } | 123 | } |
117 | 124 | ||
118 | return ( i1.organizer() == i2.organizer() && | 125 | return ( i1.organizer() == i2.organizer() && |
119 | // i1.uid() == i2.uid() && | 126 | // i1.uid() == i2.uid() && |
120 | // Don't compare lastModified, otherwise the operator is not | 127 | // Don't compare lastModified, otherwise the operator is not |
121 | // of much use. We are not comparing for identity, after all. | 128 | // of much use. We are not comparing for identity, after all. |
122 | i1.doesFloat() == i2.doesFloat() && | 129 | i1.doesFloat() == i2.doesFloat() && |
123 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); | 130 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); |
124 | // no need to compare mObserver | 131 | // no need to compare mObserver |
125 | } | 132 | } |
126 | 133 | ||
127 | 134 | ||
128 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) | 135 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) |
129 | { | 136 | { |
130 | QTime t = dt.time(); | 137 | QTime t = dt.time(); |
131 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 138 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
132 | return dt; | 139 | return dt; |
133 | } | 140 | } |
134 | 141 | ||
142 | void IncidenceBase::setCalID( int id ) | ||
143 | { | ||
144 | mCalID = id; | ||
145 | } | ||
146 | int IncidenceBase::calID() const | ||
147 | { | ||
148 | return mCalID; | ||
149 | } | ||
150 | void IncidenceBase::setCalEnabled( bool b ) | ||
151 | { | ||
152 | mCalEnabled = b; | ||
153 | } | ||
154 | bool IncidenceBase::calEnabled() const | ||
155 | { | ||
156 | return mCalEnabled; | ||
157 | } | ||
158 | |||
159 | void IncidenceBase::setAlarmEnabled( bool b ) | ||
160 | { | ||
161 | mAlarmEnabled = b; | ||
162 | } | ||
163 | bool IncidenceBase::alarmEnabled() const | ||
164 | { | ||
165 | return mAlarmEnabled; | ||
166 | } | ||
167 | |||
135 | 168 | ||
136 | void IncidenceBase::setUid(const QString &uid) | 169 | void IncidenceBase::setUid(const QString &uid) |
137 | { | 170 | { |
138 | mUid = uid; | 171 | mUid = uid; |
139 | updated(); | 172 | updated(); |
140 | } | 173 | } |
141 | 174 | ||
142 | QString IncidenceBase::uid() const | 175 | QString IncidenceBase::uid() const |
143 | { | 176 | { |
144 | return mUid; | 177 | return mUid; |
145 | } | 178 | } |
146 | 179 | ||
147 | void IncidenceBase::setLastModified(const QDateTime &lm) | 180 | void IncidenceBase::setLastModified(const QDateTime &lm) |
148 | { | 181 | { |
149 | // DON'T! updated() because we call this from | 182 | // DON'T! updated() because we call this from |
150 | // Calendar::updateEvent(). | 183 | // Calendar::updateEvent(). |
151 | mLastModified = getEvenTime(lm); | 184 | mLastModified = getEvenTime(lm); |
152 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); | 185 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); |
153 | } | 186 | } |
154 | 187 | ||
155 | QDateTime IncidenceBase::lastModified() const | 188 | QDateTime IncidenceBase::lastModified() const |
156 | { | 189 | { |
157 | return mLastModified; | 190 | return mLastModified; |
158 | } | 191 | } |
159 | 192 | ||
160 | void IncidenceBase::setOrganizer(const QString &o) | 193 | void IncidenceBase::setOrganizer(const QString &o) |
161 | { | 194 | { |
162 | // we don't check for readonly here, because it is | 195 | // we don't check for readonly here, because it is |
163 | // possible that by setting the organizer we are changing | 196 | // possible that by setting the organizer we are changing |
164 | // the event's readonly status... | 197 | // the event's readonly status... |
165 | mOrganizer = o; | 198 | mOrganizer = o; |
166 | if (mOrganizer.left(7).upper() == "MAILTO:") | 199 | if (mOrganizer.left(7).upper() == "MAILTO:") |
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index 05209e0..dc6024a 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h | |||
@@ -112,63 +112,72 @@ class IncidenceBase : public CustomProperties | |||
112 | /** Return number of attendees. */ | 112 | /** Return number of attendees. */ |
113 | int attendeeCount() const { return mAttendees.count(); }; | 113 | int attendeeCount() const { return mAttendees.count(); }; |
114 | /** Return the Attendee with this email */ | 114 | /** Return the Attendee with this email */ |
115 | Attendee* attendeeByMail(const QString &); | 115 | Attendee* attendeeByMail(const QString &); |
116 | /** Return first Attendee with one of this emails */ | 116 | /** Return first Attendee with one of this emails */ |
117 | Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); | 117 | Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); |
118 | 118 | ||
119 | /** pilot syncronization states */ | 119 | /** pilot syncronization states */ |
120 | enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; | 120 | enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; |
121 | /** Set synchronisation satus. */ | 121 | /** Set synchronisation satus. */ |
122 | void setSyncStatus(int stat); | 122 | void setSyncStatus(int stat); |
123 | /** Return synchronisation status. */ | 123 | /** Return synchronisation status. */ |
124 | int syncStatus() const; | 124 | int syncStatus() const; |
125 | 125 | ||
126 | /** Set Pilot Id. */ | 126 | /** Set Pilot Id. */ |
127 | void setPilotId(int id); | 127 | void setPilotId(int id); |
128 | /** Return Pilot Id. */ | 128 | /** Return Pilot Id. */ |
129 | int pilotId() const; | 129 | int pilotId() const; |
130 | 130 | ||
131 | void setTempSyncStat(int id); | 131 | void setTempSyncStat(int id); |
132 | int tempSyncStat() const; | 132 | int tempSyncStat() const; |
133 | void setIDStr( const QString & ); | 133 | void setIDStr( const QString & ); |
134 | QString IDStr() const; | 134 | QString IDStr() const; |
135 | void setID( const QString &, const QString & ); | 135 | void setID( const QString &, const QString & ); |
136 | QString getID( const QString & ); | 136 | QString getID( const QString & ); |
137 | void setCsum( const QString &, const QString & ); | 137 | void setCsum( const QString &, const QString & ); |
138 | QString getCsum( const QString & ); | 138 | QString getCsum( const QString & ); |
139 | void removeID(const QString &); | 139 | void removeID(const QString &); |
140 | 140 | ||
141 | void registerObserver( Observer * ); | 141 | void registerObserver( Observer * ); |
142 | void unRegisterObserver( Observer * ); | 142 | void unRegisterObserver( Observer * ); |
143 | void updated(); | 143 | void updated(); |
144 | void setCalID( int id ); | ||
145 | int calID() const; | ||
146 | void setCalEnabled( bool ); | ||
147 | bool calEnabled() const; | ||
148 | void setAlarmEnabled( bool ); | ||
149 | bool alarmEnabled() const; | ||
144 | 150 | ||
145 | protected: | 151 | protected: |
146 | QDateTime mDtStart; | 152 | QDateTime mDtStart; |
147 | bool mReadOnly; | 153 | bool mReadOnly; |
148 | QDateTime getEvenTime( QDateTime ); | 154 | QDateTime getEvenTime( QDateTime ); |
149 | 155 | ||
150 | private: | 156 | private: |
151 | // base components | 157 | // base components |
152 | QString mOrganizer; | 158 | QString mOrganizer; |
153 | QString mUid; | 159 | QString mUid; |
160 | int mCalID; | ||
161 | bool mCalEnabled; | ||
162 | bool mAlarmEnabled; | ||
154 | QDateTime mLastModified; | 163 | QDateTime mLastModified; |
155 | QPtrList<Attendee> mAttendees; | 164 | QPtrList<Attendee> mAttendees; |
156 | 165 | ||
157 | bool mFloats; | 166 | bool mFloats; |
158 | 167 | ||
159 | int mDuration; | 168 | int mDuration; |
160 | bool mHasDuration; | 169 | bool mHasDuration; |
161 | QString mExternalId; | 170 | QString mExternalId; |
162 | int mTempSyncStat; | 171 | int mTempSyncStat; |
163 | 172 | ||
164 | // PILOT SYNCHRONIZATION STUFF | 173 | // PILOT SYNCHRONIZATION STUFF |
165 | int mPilotId; // unique id for pilot sync | 174 | int mPilotId; // unique id for pilot sync |
166 | int mSyncStatus; // status (for sync) | 175 | int mSyncStatus; // status (for sync) |
167 | 176 | ||
168 | QPtrList<Observer> mObservers; | 177 | QPtrList<Observer> mObservers; |
169 | }; | 178 | }; |
170 | 179 | ||
171 | bool operator==( const IncidenceBase&, const IncidenceBase& ); | 180 | bool operator==( const IncidenceBase&, const IncidenceBase& ); |
172 | } | 181 | } |
173 | 182 | ||
174 | #endif | 183 | #endif |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index c97a61e..42274ff 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -488,65 +488,65 @@ bool Todo::setRecurDates() | |||
488 | if ( !mHasRecurrenceID ) | 488 | if ( !mHasRecurrenceID ) |
489 | return true; | 489 | return true; |
490 | int secs = mDtStart.secsTo( dtDue() ); | 490 | int secs = mDtStart.secsTo( dtDue() ); |
491 | bool ok; | 491 | bool ok; |
492 | qDebug("T:setRecurDates() "); | 492 | qDebug("T:setRecurDates() "); |
493 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 493 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
494 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); | 494 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); |
495 | if ( ok ) { | 495 | if ( ok ) { |
496 | mRecurrenceID = next; | 496 | mRecurrenceID = next; |
497 | mDtStart = next; | 497 | mDtStart = next; |
498 | setDtDue( next.addSecs( secs ) ); | 498 | setDtDue( next.addSecs( secs ) ); |
499 | if ( QDateTime::currentDateTime() > next) | 499 | if ( QDateTime::currentDateTime() > next) |
500 | return false; | 500 | return false; |
501 | } else { | 501 | } else { |
502 | setHasRecurrenceID( false ); | 502 | setHasRecurrenceID( false ); |
503 | recurrence()->unsetRecurs(); | 503 | recurrence()->unsetRecurs(); |
504 | } | 504 | } |
505 | return true; | 505 | return true; |
506 | } | 506 | } |
507 | void Todo::setPercentComplete(int v) | 507 | void Todo::setPercentComplete(int v) |
508 | { | 508 | { |
509 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { | 509 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { |
510 | if ( !setRecurDates() ) | 510 | if ( !setRecurDates() ) |
511 | v = 0; | 511 | v = 0; |
512 | } | 512 | } |
513 | mPercentComplete = v; | 513 | mPercentComplete = v; |
514 | if ( v != 100 ) | 514 | if ( v != 100 ) |
515 | mHasCompletedDate = false; | 515 | mHasCompletedDate = false; |
516 | updated(); | 516 | updated(); |
517 | } | 517 | } |
518 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 518 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
519 | { | 519 | { |
520 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { | 520 | if ( isCompleted() || ! hasDueDate() || cancelled() || !alarmEnabled() ) { |
521 | *ok = false; | 521 | *ok = false; |
522 | return QDateTime (); | 522 | return QDateTime (); |
523 | } | 523 | } |
524 | QDateTime incidenceStart; | 524 | QDateTime incidenceStart; |
525 | incidenceStart = dtDue(); | 525 | incidenceStart = dtDue(); |
526 | bool enabled = false; | 526 | bool enabled = false; |
527 | Alarm* alarm; | 527 | Alarm* alarm; |
528 | int off = 0; | 528 | int off = 0; |
529 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 529 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
530 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 530 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
531 | // *ok = false; | 531 | // *ok = false; |
532 | // return incidenceStart; | 532 | // return incidenceStart; |
533 | // } | 533 | // } |
534 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 534 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
535 | if (alarm->enabled()) { | 535 | if (alarm->enabled()) { |
536 | if ( alarm->hasTime () ) { | 536 | if ( alarm->hasTime () ) { |
537 | if ( alarm->time() < alarmStart ) { | 537 | if ( alarm->time() < alarmStart ) { |
538 | alarmStart = alarm->time(); | 538 | alarmStart = alarm->time(); |
539 | enabled = true; | 539 | enabled = true; |
540 | off = alarmStart.secsTo( incidenceStart ); | 540 | off = alarmStart.secsTo( incidenceStart ); |
541 | } | 541 | } |
542 | 542 | ||
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 | } |