-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 | |||
@@ -45,25 +45,25 @@ 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")); |
@@ -103,25 +103,32 @@ void Calendar::init() | |||
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; |
@@ -339,25 +346,26 @@ 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 | ||
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index ab40970..4c6760f 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -293,61 +293,68 @@ public: | |||
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; |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index fe74052..c5500bf 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -141,45 +141,47 @@ bool CalendarLocal::addEventNoDup( Event *event ) | |||
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! "); |
@@ -189,49 +191,53 @@ bool CalendarLocal::addTodoNoDup( Todo *todo ) | |||
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() ) { |
@@ -258,34 +264,34 @@ QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | |||
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 | } |
@@ -380,24 +386,25 @@ void CalendarLocal::deRegisterAlarm() | |||
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 ); |
@@ -412,37 +419,39 @@ void CalendarLocal::reInitAlarmSettings() | |||
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 ) { |
@@ -455,31 +464,33 @@ 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() |
@@ -534,24 +545,25 @@ void CalendarLocal::update( IncidenceBase *incidence ) | |||
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 ) ) |
@@ -586,24 +598,25 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | |||
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 | } |
@@ -661,66 +674,109 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | |||
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 | |||
@@ -171,24 +171,27 @@ class CalendarLocal : public Calendar | |||
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. */ |
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp index 20078a7..3510c7d 100644 --- a/libkcal/calfilter.cpp +++ b/libkcal/calfilter.cpp | |||
@@ -69,50 +69,59 @@ void CalFilter::apply(QPtrList<Todo> *eventlist) | |||
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 | } |
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h index 29db441..e349770 100644 --- a/libkcal/calfilter.h +++ b/libkcal/calfilter.h | |||
@@ -17,24 +17,25 @@ | |||
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); |
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index 9b99855..7cd81fa 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -164,25 +164,27 @@ void Event::setTransparency(Event::Transparency transparency) | |||
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 ){ |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index b5fe2e6..2ddbb01 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -35,35 +35,42 @@ IncidenceBase::IncidenceBase() : | |||
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. |
@@ -123,24 +130,50 @@ bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | |||
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 | ||
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index 05209e0..dc6024a 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h | |||
@@ -132,34 +132,43 @@ class IncidenceBase : public CustomProperties | |||
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 |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index c97a61e..42274ff 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -508,25 +508,25 @@ 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; |