summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.h2
-rw-r--r--libkcal/calendarlocal.cpp26
-rw-r--r--libkcal/calendarlocal.h1
3 files changed, 28 insertions, 1 deletions
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 3f6895d..4b8b3ff 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -274,96 +274,98 @@ public:
274 /** 274 /**
275 Set calendar filter, which filters events for the events() functions. 275 Set calendar filter, which filters events for the events() functions.
276 The Filter object is owned by the caller. 276 The Filter object is owned by the caller.
277 */ 277 */
278 void setFilter( CalFilter * ); 278 void setFilter( CalFilter * );
279 /** 279 /**
280 Return calendar filter. 280 Return calendar filter.
281 */ 281 */
282 CalFilter *filter(); 282 CalFilter *filter();
283 virtual QDateTime nextAlarm( int daysTo ) = 0; 283 virtual QDateTime nextAlarm( int daysTo ) = 0;
284 virtual QString nextSummary( ) const = 0; 284 virtual QString nextSummary( ) const = 0;
285 virtual void reInitAlarmSettings() = 0; 285 virtual void reInitAlarmSettings() = 0;
286 virtual QDateTime nextAlarmEventDateTime() const = 0; 286 virtual QDateTime nextAlarmEventDateTime() const = 0;
287 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; 287 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0;
288 /** 288 /**
289 Return all alarms, which ocur in the given time interval. 289 Return all alarms, which ocur in the given time interval.
290 */ 290 */
291 virtual Alarm::List alarms( const QDateTime &from, 291 virtual Alarm::List alarms( const QDateTime &from,
292 const QDateTime &to ) = 0; 292 const QDateTime &to ) = 0;
293 293
294 class Observer { 294 class Observer {
295 public: 295 public:
296 virtual void calendarModified( bool, Calendar * ) = 0; 296 virtual void calendarModified( bool, Calendar * ) = 0;
297 }; 297 };
298 298
299 void registerObserver( Observer * ); 299 void registerObserver( Observer * );
300 300
301 void setModified( bool ); 301 void setModified( bool );
302 302
303 /** 303 /**
304 Set product id returned by loadedProductId(). This function is only 304 Set product id returned by loadedProductId(). This function is only
305 useful for the calendar loading code. 305 useful for the calendar loading code.
306 */ 306 */
307 void setLoadedProductId( const QString & ); 307 void setLoadedProductId( const QString & );
308 /** 308 /**
309 Return product id taken from file that has been loaded. Returns 309 Return product id taken from file that has been loaded. Returns
310 QString::null, if no calendar has been loaded. 310 QString::null, if no calendar has been loaded.
311 */ 311 */
312 QString loadedProductId(); 312 QString loadedProductId();
313 int defaultCalendar(); 313 int defaultCalendar();
314 void setDontDeleteIncidencesOnClose (); 314 void setDontDeleteIncidencesOnClose ();
315 public slots: 315 public slots:
316 void setDefaultCalendar( int ); 316 void setDefaultCalendar( int );
317 virtual void setCalendarEnabled( int id, bool enable ) = 0; 317 virtual void setCalendarEnabled( int id, bool enable ) = 0;
318 virtual void setAlarmEnabled( int id, bool enable ) = 0; 318 virtual void setAlarmEnabled( int id, bool enable ) = 0;
319 virtual void setReadOnly( int id, bool enable ) = 0; 319 virtual void setReadOnly( int id, bool enable ) = 0;
320 virtual void setDefaultCalendarEnabledOnly() = 0; 320 virtual void setDefaultCalendarEnabledOnly() = 0;
321 virtual void setCalendarRemove( int id ) = 0; 321 virtual void setCalendarRemove( int id ) = 0;
322 virtual void getIncidenceCount( int calId, int& events, int & todos, int & journals) = 0;
323
322 signals: 324 signals:
323 void calendarChanged(); 325 void calendarChanged();
324 void calendarSaved(); 326 void calendarSaved();
325 void calendarLoaded(); 327 void calendarLoaded();
326 void addAlarm(const QDateTime &qdt, const QString &noti ); 328 void addAlarm(const QDateTime &qdt, const QString &noti );
327 void removeAlarm(const QDateTime &qdt, const QString &noti ); 329 void removeAlarm(const QDateTime &qdt, const QString &noti );
328 330
329 protected: 331 protected:
330 /** 332 /**
331 Get unfiltered events, which occur on the given date. 333 Get unfiltered events, which occur on the given date.
332 */ 334 */
333 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; 335 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0;
334 /** 336 /**
335 Get unfiltered events, which occur on the given date. 337 Get unfiltered events, which occur on the given date.
336 */ 338 */
337 virtual QPtrList<Event> rawEventsForDate( const QDate &date, 339 virtual QPtrList<Event> rawEventsForDate( const QDate &date,
338 bool sorted = false ) = 0; 340 bool sorted = false ) = 0;
339 /** 341 /**
340 Get events in a range of dates. If inclusive is set to true, only events 342 Get events in a range of dates. If inclusive is set to true, only events
341 are returned, which are completely included in the range. 343 are returned, which are completely included in the range.
342 */ 344 */
343 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 345 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
344 bool inclusive = false ) = 0; 346 bool inclusive = false ) = 0;
345 347
346 Incidence *mNextAlarmIncidence; 348 Incidence *mNextAlarmIncidence;
347 Incidence *mUndoIncidence; 349 Incidence *mUndoIncidence;
348 int mDefaultCalendar; 350 int mDefaultCalendar;
349 bool mDeleteIncidencesOnClose; 351 bool mDeleteIncidencesOnClose;
350 352
351private: 353private:
352 void init(); 354 void init();
353 355
354 QString mOwner; // who the calendar belongs to 356 QString mOwner; // who the calendar belongs to
355 QString mOwnerEmail; // email address of the owner 357 QString mOwnerEmail; // email address of the owner
356 int mTimeZone; // timezone OFFSET from GMT (MINUTES) 358 int mTimeZone; // timezone OFFSET from GMT (MINUTES)
357 bool mLocalTime; // use local time, not UTC or a time zone 359 bool mLocalTime; // use local time, not UTC or a time zone
358 360
359 361
360 CalFilter *mFilter; 362 CalFilter *mFilter;
361 CalFilter *mDefaultFilter; 363 CalFilter *mDefaultFilter;
362 364
363 365
364 QString mTimeZoneId; 366 QString mTimeZoneId;
365 367
366 Observer *mObserver; 368 Observer *mObserver;
367 bool mNewObserver; 369 bool mNewObserver;
368 370
369 bool mModified; 371 bool mModified;
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 1a1c6be..0ddfeca 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -407,111 +407,135 @@ Todo *CalendarLocal::todo( QString syncProf, QString id )
407} 407}
408void CalendarLocal::removeSyncInfo( QString syncProfile) 408void CalendarLocal::removeSyncInfo( QString syncProfile)
409{ 409{
410 QPtrList<Incidence> all = rawIncidences() ; 410 QPtrList<Incidence> all = rawIncidences() ;
411 Incidence *inc; 411 Incidence *inc;
412 for ( inc = all.first(); inc; inc = all.next() ) { 412 for ( inc = all.first(); inc; inc = all.next() ) {
413 inc->removeID( syncProfile ); 413 inc->removeID( syncProfile );
414 } 414 }
415 if ( syncProfile.isEmpty() ) { 415 if ( syncProfile.isEmpty() ) {
416 QPtrList<Event> el; 416 QPtrList<Event> el;
417 Event *todo; 417 Event *todo;
418 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 418 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
419 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 419 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
420 el.append( todo ); 420 el.append( todo );
421 } 421 }
422 for ( todo = el.first(); todo; todo = el.next() ) { 422 for ( todo = el.first(); todo; todo = el.next() ) {
423 deleteIncidence ( todo ); 423 deleteIncidence ( todo );
424 } 424 }
425 } else { 425 } else {
426 Event *lse = event( "last-syncEvent-"+ syncProfile); 426 Event *lse = event( "last-syncEvent-"+ syncProfile);
427 if ( lse ) 427 if ( lse )
428 deleteIncidence ( lse ); 428 deleteIncidence ( lse );
429 } 429 }
430} 430}
431QPtrList<Event> CalendarLocal::getExternLastSyncEvents() 431QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
432{ 432{
433 QPtrList<Event> el; 433 QPtrList<Event> el;
434 Event *todo; 434 Event *todo;
435 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 435 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
436 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 436 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
437 if ( todo->summary().left(3) == "E: " ) 437 if ( todo->summary().left(3) == "E: " )
438 el.append( todo ); 438 el.append( todo );
439 } 439 }
440 440
441 return el; 441 return el;
442 442
443} 443}
444Event *CalendarLocal::event( QString syncProf, QString id ) 444Event *CalendarLocal::event( QString syncProf, QString id )
445{ 445{
446 Event *todo; 446 Event *todo;
447 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 447 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
448 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; 448 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
449 } 449 }
450 450
451 return 0; 451 return 0;
452} 452}
453Todo *CalendarLocal::todo( const QString &uid ) 453Todo *CalendarLocal::todo( const QString &uid )
454{ 454{
455 Todo *todo;; 455 Todo *todo;
456 Todo *retVal = 0; 456 Todo *retVal = 0;
457 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 457 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
458 if ( todo->calEnabled() && todo->uid() == uid ) { 458 if ( todo->calEnabled() && todo->uid() == uid ) {
459 if ( retVal ) { 459 if ( retVal ) {
460 if ( retVal->calID() > todo->calID() ) { 460 if ( retVal->calID() > todo->calID() ) {
461 retVal = todo; 461 retVal = todo;
462 } 462 }
463 } else { 463 } else {
464 retVal = todo; 464 retVal = todo;
465 } 465 }
466 } 466 }
467 } 467 }
468 return retVal; 468 return retVal;
469} 469}
470void CalendarLocal::getIncidenceCount( int calId, int& events, int & todos, int & journals)
471{
472 events = 0;
473 todos = 0;
474 journals = 0;
475 {
476 Todo *todo;
477 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
478 if ( todo->calID() == calId )
479 ++todos;
480 }
481 }
482 {
483 Event *todo;
484 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
485 if ( todo->calID() == calId )
486 ++events;
487
488 }
489 }
490 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
491 if ( it->calID() == calId ) ++journals;
492
493}
470QString CalendarLocal::nextSummary() const 494QString CalendarLocal::nextSummary() const
471{ 495{
472 return mNextSummary; 496 return mNextSummary;
473} 497}
474QDateTime CalendarLocal::nextAlarmEventDateTime() const 498QDateTime CalendarLocal::nextAlarmEventDateTime() const
475{ 499{
476 return mNextAlarmEventDateTime; 500 return mNextAlarmEventDateTime;
477} 501}
478void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) 502void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted)
479{ 503{
480 //mNextAlarmIncidence 504 //mNextAlarmIncidence
481 //mNextAlarmDateTime 505 //mNextAlarmDateTime
482 //return mNextSummary; 506 //return mNextSummary;
483 //return mNextAlarmEventDateTime; 507 //return mNextAlarmEventDateTime;
484 bool newNextAlarm = false; 508 bool newNextAlarm = false;
485 bool computeNextAlarm = false; 509 bool computeNextAlarm = false;
486 bool ok; 510 bool ok;
487 int offset; 511 int offset;
488 QDateTime nextA; 512 QDateTime nextA;
489 // QString nextSum; 513 // QString nextSum;
490 //QDateTime nextEvent; 514 //QDateTime nextEvent;
491 if ( mNextAlarmIncidence == 0 || incidence == 0 ) { 515 if ( mNextAlarmIncidence == 0 || incidence == 0 ) {
492 computeNextAlarm = true; 516 computeNextAlarm = true;
493 } else { 517 } else {
494 if ( ! deleted ) { 518 if ( ! deleted ) {
495 nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 519 nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
496 if ( ok ) { 520 if ( ok ) {
497 if ( nextA < mNextAlarmDateTime ) { 521 if ( nextA < mNextAlarmDateTime ) {
498 deRegisterAlarm(); 522 deRegisterAlarm();
499 mNextAlarmDateTime = nextA; 523 mNextAlarmDateTime = nextA;
500 mNextSummary = incidence->summary(); 524 mNextSummary = incidence->summary();
501 mNextAlarmEventDateTime = nextA.addSecs(offset ) ; 525 mNextAlarmEventDateTime = nextA.addSecs(offset ) ;
502 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 526 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
503 newNextAlarm = true; 527 newNextAlarm = true;
504 mNextAlarmIncidence = incidence; 528 mNextAlarmIncidence = incidence;
505 } else { 529 } else {
506 if ( incidence == mNextAlarmIncidence ) { 530 if ( incidence == mNextAlarmIncidence ) {
507 computeNextAlarm = true; 531 computeNextAlarm = true;
508 } 532 }
509 } 533 }
510 } else { 534 } else {
511 if ( mNextAlarmIncidence == incidence ) { 535 if ( mNextAlarmIncidence == incidence ) {
512 computeNextAlarm = true; 536 computeNextAlarm = true;
513 } 537 }
514 } 538 }
515 } else { // deleted 539 } else { // deleted
516 if ( incidence == mNextAlarmIncidence ) { 540 if ( incidence == mNextAlarmIncidence ) {
517 computeNextAlarm = true; 541 computeNextAlarm = true;
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index a7a85c8..ca0bd98 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -140,91 +140,92 @@ class CalendarLocal : public Calendar
140 */ 140 */
141 Journal *journal( const QString &uid ); 141 Journal *journal( const QString &uid );
142 /** 142 /**
143 Return list of all Journals stored in calendar. 143 Return list of all Journals stored in calendar.
144 */ 144 */
145 QPtrList<Journal> journals(); 145 QPtrList<Journal> journals();
146 146
147 /** 147 /**
148 Return all alarms, which ocur in the given time interval. 148 Return all alarms, which ocur in the given time interval.
149 */ 149 */
150 Alarm::List alarms( const QDateTime &from, const QDateTime &to ); 150 Alarm::List alarms( const QDateTime &from, const QDateTime &to );
151 151
152 /** 152 /**
153 Return all alarms, which ocur before given date. 153 Return all alarms, which ocur before given date.
154 */ 154 */
155 Alarm::List alarmsTo( const QDateTime &to ); 155 Alarm::List alarmsTo( const QDateTime &to );
156 156
157 QDateTime nextAlarm( int daysTo ) ; 157 QDateTime nextAlarm( int daysTo ) ;
158 QDateTime nextAlarmEventDateTime() const; 158 QDateTime nextAlarmEventDateTime() const;
159 void checkAlarmForIncidence( Incidence *, bool deleted ) ; 159 void checkAlarmForIncidence( Incidence *, bool deleted ) ;
160 void registerAlarm(); 160 void registerAlarm();
161 void deRegisterAlarm(); 161 void deRegisterAlarm();
162 QString getAlarmNotification(); 162 QString getAlarmNotification();
163 QString nextSummary() const ; 163 QString nextSummary() const ;
164 /** 164 /**
165 This method should be called whenever a Event is modified directly 165 This method should be called whenever a Event is modified directly
166 via it's pointer. It makes sure that the calendar is internally 166 via it's pointer. It makes sure that the calendar is internally
167 consistent. 167 consistent.
168 */ 168 */
169 void update( IncidenceBase *incidence ); 169 void update( IncidenceBase *incidence );
170 170
171 /** 171 /**
172 Builds and then returns a list of all events that match for the 172 Builds and then returns a list of all events that match for the
173 date specified. useful for dayView, etc. etc. 173 date specified. useful for dayView, etc. etc.
174 */ 174 */
175 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); 175 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false );
176 /** 176 /**
177 Get unfiltered events for date \a qdt. 177 Get unfiltered events for date \a qdt.
178 */ 178 */
179 QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); 179 QPtrList<Event> rawEventsForDate( const QDateTime &qdt );
180 /** 180 /**
181 Get unfiltered events in a range of dates. If inclusive is set to true, 181 Get unfiltered events in a range of dates. If inclusive is set to true,
182 only events are returned, which are completely included in the range. 182 only events are returned, which are completely included in the range.
183 */ 183 */
184 QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 184 QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
185 bool inclusive = false ); 185 bool inclusive = false );
186 Todo *todo( QString, QString ); 186 Todo *todo( QString, QString );
187 Event *event( QString, QString ); 187 Event *event( QString, QString );
188 void getIncidenceCount( int calId, int& events, int & todos, int & journals);
188 189
189public slots: 190public slots:
190 void setCalendarEnabled( int id, bool enable ); 191 void setCalendarEnabled( int id, bool enable );
191 void setAlarmEnabled( int id, bool enable ); 192 void setAlarmEnabled( int id, bool enable );
192 void setReadOnly( int id, bool enable ); 193 void setReadOnly( int id, bool enable );
193 void setDefaultCalendarEnabledOnly(); 194 void setDefaultCalendarEnabledOnly();
194 void setCalendarRemove( int id ); 195 void setCalendarRemove( int id );
195 196
196 protected: 197 protected:
197 198
198 // Event* mNextAlarmEvent; 199 // Event* mNextAlarmEvent;
199 QString mNextSummary; 200 QString mNextSummary;
200 QString mNextAlarmEventDateTimeString; 201 QString mNextAlarmEventDateTimeString;
201 QString mLastAlarmNotificationString; 202 QString mLastAlarmNotificationString;
202 QDateTime mNextAlarmEventDateTime; 203 QDateTime mNextAlarmEventDateTime;
203 QDateTime mNextAlarmDateTime; 204 QDateTime mNextAlarmDateTime;
204 void reInitAlarmSettings(); 205 void reInitAlarmSettings();
205 206
206 /** Notification function of IncidenceBase::Observer. */ 207 /** Notification function of IncidenceBase::Observer. */
207 void incidenceUpdated( IncidenceBase *i ) { update( i ); } 208 void incidenceUpdated( IncidenceBase *i ) { update( i ); }
208 209
209 /** inserts an event into its "proper place" in the calendar. */ 210 /** inserts an event into its "proper place" in the calendar. */
210 void insertEvent( Event *event ); 211 void insertEvent( Event *event );
211 212
212 /** Append alarms of incidence in interval to list of alarms. */ 213 /** Append alarms of incidence in interval to list of alarms. */
213 void appendAlarms( Alarm::List &alarms, Incidence *incidence, 214 void appendAlarms( Alarm::List &alarms, Incidence *incidence,
214 const QDateTime &from, const QDateTime &to ); 215 const QDateTime &from, const QDateTime &to );
215 216
216 /** Append alarms of recurring events in interval to list of alarms. */ 217 /** Append alarms of recurring events in interval to list of alarms. */
217 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, 218 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence,
218 const QDateTime &from, const QDateTime &to ); 219 const QDateTime &from, const QDateTime &to );
219 220
220 private: 221 private:
221 void init(); 222 void init();
222 223
223 QPtrList<Event> mEventList; 224 QPtrList<Event> mEventList;
224 QPtrList<Todo> mTodoList; 225 QPtrList<Todo> mTodoList;
225 QPtrList<Journal> mJournalList; 226 QPtrList<Journal> mJournalList;
226}; 227};
227 228
228} 229}
229 230
230#endif 231#endif