summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp14
-rw-r--r--libkcal/calendar.h9
-rw-r--r--libkcal/calendarlocal.cpp80
-rw-r--r--libkcal/calendarlocal.h3
-rw-r--r--libkcal/calfilter.cpp9
-rw-r--r--libkcal/calfilter.h1
-rw-r--r--libkcal/event.cpp4
-rw-r--r--libkcal/incidencebase.cpp33
-rw-r--r--libkcal/incidencebase.h9
-rw-r--r--libkcal/todo.cpp2
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
@@ -49,17 +49,17 @@ Calendar::Calendar( const QString &timeZoneId )
49} 49}
50 50
51void Calendar::init() 51void 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));
@@ -107,17 +107,24 @@ void Calendar::init()
107} 107}
108 108
109Calendar::~Calendar() 109Calendar::~Calendar()
110{ 110{
111 delete mDefaultFilter; 111 delete mDefaultFilter;
112 if ( mUndoIncidence ) 112 if ( mUndoIncidence )
113 delete mUndoIncidence; 113 delete mUndoIncidence;
114} 114}
115 115void Calendar::setDefaultCalendar( int d )
116{
117 mDefaultCalendar = d;
118}
119int Calendar::defaultCalendar()
120{
121 return mDefaultCalendar;
122}
116const QString &Calendar::getOwner() const 123const QString &Calendar::getOwner() const
117{ 124{
118 return mOwner; 125 return mOwner;
119} 126}
120 127
121bool Calendar::undoDeleteIncidence() 128bool Calendar::undoDeleteIncidence()
122{ 129{
123 if (!mUndoIncidence) 130 if (!mUndoIncidence)
@@ -343,17 +350,18 @@ void Calendar::addIncidenceBranch(Incidence *i)
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
348bool Calendar::addIncidence(Incidence *i) 355bool 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}
354void Calendar::deleteIncidence(Incidence *in) 362void 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);
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index ab40970..4c6760f 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -297,17 +297,21 @@ public:
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 &noti ); 314 void addAlarm(const QDateTime &qdt, const QString &noti );
311 void removeAlarm(const QDateTime &qdt, const QString &noti ); 315 void removeAlarm(const QDateTime &qdt, const QString &noti );
312 316
313 protected: 317 protected:
@@ -321,29 +325,32 @@ public:
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
332private: 338private:
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
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index fe74052..c5500bf 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -145,16 +145,18 @@ bool CalendarLocal::addEventNoDup( Event *event )
145 145
146bool CalendarLocal::addEvent( Event *event ) 146bool 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
157void CalendarLocal::deleteEvent( Event *event ) 159void CalendarLocal::deleteEvent( Event *event )
158{ 160{
159 if ( mUndoIncidence ) delete mUndoIncidence; 161 if ( mUndoIncidence ) delete mUndoIncidence;
160 mUndoIncidence = event->clone(); 162 mUndoIncidence = event->clone();
@@ -165,17 +167,17 @@ void CalendarLocal::deleteEvent( Event *event )
165 167
166 168
167Event *CalendarLocal::event( const QString &uid ) 169Event *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}
180bool CalendarLocal::addTodoNoDup( Todo *todo ) 182bool CalendarLocal::addTodoNoDup( Todo *todo )
181{ 183{
@@ -193,17 +195,18 @@ bool CalendarLocal::addTodo( Todo *todo )
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
205void CalendarLocal::deleteTodo( Todo *todo ) 208void 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 );
@@ -211,23 +214,26 @@ void CalendarLocal::deleteTodo( Todo *todo )
211 214
212 if ( mTodoList.removeRef( todo ) ) { 215 if ( mTodoList.removeRef( todo ) ) {
213 setModified( true ); 216 setModified( true );
214 } 217 }
215} 218}
216 219
217QPtrList<Todo> CalendarLocal::rawTodos() 220QPtrList<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}
221Todo *CalendarLocal::todo( QString syncProf, QString id ) 227Todo *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}
230void CalendarLocal::removeSyncInfo( QString syncProfile) 236void CalendarLocal::removeSyncInfo( QString syncProfile)
231{ 237{
232 QPtrList<Incidence> all = rawIncidences() ; 238 QPtrList<Incidence> all = rawIncidences() ;
233 Incidence *inc; 239 Incidence *inc;
@@ -262,26 +268,26 @@ QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
262 268
263 return el; 269 return el;
264 270
265} 271}
266Event *CalendarLocal::event( QString syncProf, QString id ) 272Event *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}
275Todo *CalendarLocal::todo( const QString &uid ) 281Todo *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}
284QString CalendarLocal::nextSummary() const 290QString CalendarLocal::nextSummary() const
285{ 291{
286 return mNextSummary; 292 return mNextSummary;
287} 293}
@@ -384,16 +390,17 @@ void CalendarLocal::deRegisterAlarm()
384} 390}
385 391
386QPtrList<Todo> CalendarLocal::todos( const QDate &date ) 392QPtrList<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}
@@ -416,29 +423,31 @@ QDateTime CalendarLocal::nextAlarm( int 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;
@@ -459,23 +468,25 @@ Alarm::List CalendarLocal::alarmsTo( const QDateTime &to )
459Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) 468Alarm::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
479void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, 490void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence,
480 const QDateTime &from, const QDateTime &to ) 491 const QDateTime &from, const QDateTime &to )
481{ 492{
@@ -538,16 +549,17 @@ void CalendarLocal::insertEvent( Event *event )
538 549
539 550
540QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) 551QPtrList<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;
@@ -590,16 +602,17 @@ 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
@@ -665,32 +678,36 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
665 678
666QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) 679QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
667{ 680{
668 return rawEventsForDate( qdt.date() ); 681 return rawEventsForDate( qdt.date() );
669} 682}
670 683
671QPtrList<Event> CalendarLocal::rawEvents() 684QPtrList<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
676bool CalendarLocal::addJournal(Journal *journal) 692bool 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
692void CalendarLocal::deleteJournal( Journal *journal ) 709void 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));
@@ -699,28 +716,67 @@ void CalendarLocal::deleteJournal( Journal *journal )
699 } 716 }
700} 717}
701 718
702Journal *CalendarLocal::journal( const QDate &date ) 719Journal *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
713Journal *CalendarLocal::journal( const QString &uid ) 730Journal *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
722QPtrList<Journal> CalendarLocal::journals() 739QPtrList<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
747void 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}
759void 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}
771void 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
@@ -175,16 +175,19 @@ class CalendarLocal : public Calendar
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;
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index 20078a7..3510c7d 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -73,42 +73,51 @@ void CalFilter::apply(QPtrList<Todo> *eventlist)
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}
79bool CalFilter::filterCalendarItem(Incidence *in) 79bool 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}
89bool CalFilter::filterEvent(Event *event) 91bool 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}
99bool CalFilter::filterJournal(Journal *j) 104bool 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}
105bool CalFilter::filterTodo(Todo *todo) 112bool 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}
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h
index 29db441..e349770 100644
--- a/libkcal/calfilter.h
+++ b/libkcal/calfilter.h
@@ -21,16 +21,17 @@
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
30namespace KCal { 31namespace KCal {
31 32
32/** 33/**
33 Filter for calendar objects. 34 Filter for calendar objects.
34*/ 35*/
35class CalFilter { 36class CalFilter {
36 public: 37 public:
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 9b99855..7cd81fa 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -168,17 +168,19 @@ Event::Transparency Event::transparency() const
168 168
169void Event::setDuration(int seconds) 169void Event::setDuration(int seconds)
170{ 170{
171 setHasEndDate(false); 171 setHasEndDate(false);
172 Incidence::setDuration(seconds); 172 Incidence::setDuration(seconds);
173} 173}
174QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const 174QDateTime 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;
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index b5fe2e6..2ddbb01 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -39,27 +39,34 @@ IncidenceBase::IncidenceBase() :
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
49IncidenceBase::IncidenceBase(const IncidenceBase &i) : 52IncidenceBase::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;
@@ -127,16 +134,42 @@ bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
127 134
128QDateTime IncidenceBase::getEvenTime( QDateTime dt ) 135QDateTime 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
142void IncidenceBase::setCalID( int id )
143{
144 mCalID = id;
145}
146int IncidenceBase::calID() const
147{
148 return mCalID;
149}
150void IncidenceBase::setCalEnabled( bool b )
151{
152 mCalEnabled = b;
153}
154bool IncidenceBase::calEnabled() const
155{
156 return mCalEnabled;
157}
158
159void IncidenceBase::setAlarmEnabled( bool b )
160{
161 mAlarmEnabled = b;
162}
163bool IncidenceBase::alarmEnabled() const
164{
165 return mAlarmEnabled;
166}
167
135 168
136void IncidenceBase::setUid(const QString &uid) 169void IncidenceBase::setUid(const QString &uid)
137{ 170{
138 mUid = uid; 171 mUid = uid;
139 updated(); 172 updated();
140} 173}
141 174
142QString IncidenceBase::uid() const 175QString IncidenceBase::uid() const
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 05209e0..dc6024a 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -136,26 +136,35 @@ class IncidenceBase : public CustomProperties
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;
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index c97a61e..42274ff 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -512,17 +512,17 @@ void Todo::setPercentComplete(int v)
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}
518QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const 518QDateTime 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;