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
@@ -55,5 +55,5 @@ void Calendar::init()
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;
@@ -113,5 +113,12 @@ Calendar::~Calendar()
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{
@@ -349,5 +356,6 @@ 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}
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index ab40970..4c6760f 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -303,5 +303,9 @@ public:
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();
@@ -327,6 +331,8 @@ public:
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:
@@ -340,4 +346,5 @@ private:
340 CalFilter *mFilter; 346 CalFilter *mFilter;
341 CalFilter *mDefaultFilter; 347 CalFilter *mDefaultFilter;
348
342 349
343 QString mTimeZoneId; 350 QString mTimeZoneId;
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index fe74052..c5500bf 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -151,4 +151,6 @@ bool CalendarLocal::addEvent( Event *event )
151 151
152 setModified( true ); 152 setModified( true );
153 event->setCalID( mDefaultCalendar );
154 event->setCalEnabled( true );
153 155
154 return true; 156 return true;
@@ -171,5 +173,5 @@ Event *CalendarLocal::event( const QString &uid )
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 }
@@ -199,5 +201,6 @@ bool CalendarLocal::addTodo( Todo *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}
@@ -217,5 +220,8 @@ void CalendarLocal::deleteTodo( Todo *todo )
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 )
@@ -223,5 +229,5 @@ Todo *CalendarLocal::todo( QString syncProf, QString id )
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
@@ -268,5 +274,5 @@ Event *CalendarLocal::event( QString syncProf, QString id )
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
@@ -277,5 +283,5 @@ Todo *CalendarLocal::todo( const QString &uid )
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
@@ -390,4 +396,5 @@ QPtrList<Todo> CalendarLocal::todos( const QDate &date )
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 );
@@ -422,4 +429,5 @@ QDateTime CalendarLocal::nextAlarm( int daysTo )
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 ) {
@@ -435,4 +443,5 @@ QDateTime CalendarLocal::nextAlarm( int daysTo )
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 ) {
@@ -465,4 +474,5 @@ Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
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 );
@@ -471,5 +481,6 @@ Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
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
@@ -544,4 +555,5 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
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() ) {
@@ -596,4 +608,5 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
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();
@@ -671,5 +684,8 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
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
@@ -686,5 +702,6 @@ bool CalendarLocal::addJournal(Journal *journal)
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}
@@ -705,5 +722,5 @@ Journal *CalendarLocal::journal( const QDate &date )
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
@@ -714,5 +731,5 @@ 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
@@ -722,5 +739,44 @@ Journal *CalendarLocal::journal( const QString &uid )
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
@@ -181,4 +181,7 @@ class CalendarLocal : public Calendar
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:
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index 20078a7..3510c7d 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -79,4 +79,6 @@ void CalFilter::apply(QPtrList<Todo> *eventlist)
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 );
@@ -89,4 +91,7 @@ bool CalFilter::filterCalendarItem(Incidence *in)
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;
@@ -99,4 +104,6 @@ bool CalFilter::filterEvent(Event *event)
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;
@@ -105,4 +112,6 @@ bool CalFilter::filterJournal(Journal *j)
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;
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h
index 29db441..e349770 100644
--- a/libkcal/calfilter.h
+++ b/libkcal/calfilter.h
@@ -27,4 +27,5 @@
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 {
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 9b99855..7cd81fa 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -174,5 +174,7 @@ void Event::setDuration(int seconds)
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 );
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index b5fe2e6..2ddbb01 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -45,4 +45,7 @@ IncidenceBase::IncidenceBase() :
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
@@ -50,4 +53,5 @@ 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;
@@ -56,4 +60,7 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) :
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() ) {
@@ -133,4 +140,30 @@ QDateTime IncidenceBase::getEvenTime( QDateTime 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)
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 05209e0..dc6024a 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -142,4 +142,10 @@ class IncidenceBase : public CustomProperties
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:
@@ -152,4 +158,7 @@ class IncidenceBase : public CustomProperties
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;
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index c97a61e..42274ff 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -518,5 +518,5 @@ void Todo::setPercentComplete(int v)
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 ();