summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-06-10 20:13:31 (UTC)
committer zautrix <zautrix>2005-06-10 20:13:31 (UTC)
commitcdc55afb3d2c3ebd970843b7dce02acb1e6a189b (patch) (unidiff)
tree45f3bfa69a72de4e8b53bbcb2414478ec65cd183 /libkcal
parent31fed261955dcb25d06052a8154ac4cc630b0f7d (diff)
downloadkdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.zip
kdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.tar.gz
kdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.tar.bz2
many preparations for multiple calendars
Diffstat (limited to 'libkcal') (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
@@ -56,3 +56,3 @@ void Calendar::init()
56 mModified = false; 56 mModified = false;
57 57 mDefaultCalendar = 1;
58 // Setup default filter, which does nothing 58 // Setup default filter, which does nothing
@@ -114,3 +114,10 @@ Calendar::~Calendar()
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
@@ -350,3 +357,4 @@ bool Calendar::addIncidence(Incidence *i)
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);
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index ab40970..4c6760f 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -304,3 +304,7 @@ public:
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:
@@ -328,4 +332,6 @@ public:
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
@@ -341,2 +347,3 @@ private:
341 CalFilter *mDefaultFilter; 347 CalFilter *mDefaultFilter;
348
342 349
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index fe74052..c5500bf 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -152,2 +152,4 @@ bool CalendarLocal::addEvent( Event *event )
152 setModified( true ); 152 setModified( true );
153 event->setCalID( mDefaultCalendar );
154 event->setCalEnabled( true );
153 155
@@ -172,3 +174,3 @@ Event *CalendarLocal::event( const QString &uid )
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;
@@ -200,3 +202,4 @@ bool CalendarLocal::addTodo( Todo *todo )
200 setModified( true ); 202 setModified( true );
201 203 todo->setCalID( mDefaultCalendar );
204 todo->setCalEnabled( true );
202 return true; 205 return true;
@@ -218,3 +221,6 @@ 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}
@@ -224,3 +230,3 @@ Todo *CalendarLocal::todo( QString syncProf, QString id )
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 }
@@ -269,3 +275,3 @@ Event *CalendarLocal::event( QString syncProf, QString id )
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 }
@@ -278,3 +284,3 @@ Todo *CalendarLocal::todo( const QString &uid )
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 }
@@ -391,2 +397,3 @@ QPtrList<Todo> CalendarLocal::todos( const QDate &date )
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 ) {
@@ -423,2 +430,3 @@ QDateTime CalendarLocal::nextAlarm( int daysTo )
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() ) ;
@@ -436,2 +444,3 @@ QDateTime CalendarLocal::nextAlarm( int daysTo )
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() ) ;
@@ -466,2 +475,3 @@ Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
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 );
@@ -472,3 +482,4 @@ Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
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 }
@@ -545,2 +556,3 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
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() ) {
@@ -597,2 +609,3 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
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() ) {
@@ -672,3 +685,6 @@ 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}
@@ -687,3 +703,4 @@ bool CalendarLocal::addJournal(Journal *journal)
687 setModified( true ); 703 setModified( true );
688 704 journal->setCalID( mDefaultCalendar );
705 journal->setCalEnabled( true );
689 return true; 706 return true;
@@ -706,3 +723,3 @@ Journal *CalendarLocal::journal( const QDate &date )
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;
@@ -715,3 +732,3 @@ Journal *CalendarLocal::journal( const QString &uid )
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;
@@ -723,4 +740,43 @@ 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
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
@@ -182,2 +182,5 @@ class CalendarLocal : public Calendar
182 182
183 void setCalendarEnabled( int id, bool enable );
184 void setAlarmEnabled( int id, bool enable );
185 void setDefaultCalendarEnabledOnly();
183 186
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index 20078a7..3510c7d 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -80,2 +80,4 @@ bool CalFilter::filterCalendarItem(Incidence *in)
80{ 80{
81 if ( !in->calEnabled() )
82 return false;
81 if ( in->typeID() == eventID ) 83 if ( in->typeID() == eventID )
@@ -90,2 +92,5 @@ bool CalFilter::filterEvent(Event *event)
90{ 92{
93
94 if ( !event->calEnabled() )
95 return false;
91 if (mCriteria & HideEvents) 96 if (mCriteria & HideEvents)
@@ -100,2 +105,4 @@ bool CalFilter::filterJournal(Journal *j)
100{ 105{
106 if ( !j->calEnabled() )
107 return false;
101 if (mCriteria & HideJournals) 108 if (mCriteria & HideJournals)
@@ -106,2 +113,4 @@ bool CalFilter::filterTodo(Todo *todo)
106{ 113{
114 if ( !todo->calEnabled() )
115 return false;
107 if (mCriteria & HideTodos) 116 if (mCriteria & HideTodos)
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h
index 29db441..e349770 100644
--- a/libkcal/calfilter.h
+++ b/libkcal/calfilter.h
@@ -28,2 +28,3 @@
28#include "todo.h" 28#include "todo.h"
29#include "journal.h"
29 30
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 9b99855..7cd81fa 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -175,3 +175,5 @@ QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_
175{ 175{
176 176 *ok = false;
177 if ( !alarmEnabled() )
178 return QDateTime ();
177 bool yes; 179 bool yes;
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index b5fe2e6..2ddbb01 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -46,2 +46,5 @@ IncidenceBase::IncidenceBase() :
46 mAttendees.setAutoDelete( true ); 46 mAttendees.setAutoDelete( true );
47 mCalEnabled = true;
48 mAlarmEnabled = true;
49 mCalID = 0;
47} 50}
@@ -51,2 +54,3 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) :
51{ 54{
55
52 mReadOnly = i.mReadOnly; 56 mReadOnly = i.mReadOnly;
@@ -57,2 +61,5 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) :
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();
@@ -134,2 +141,28 @@ QDateTime IncidenceBase::getEvenTime( QDateTime dt )
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
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 05209e0..dc6024a 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -143,2 +143,8 @@ class IncidenceBase : public CustomProperties
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
@@ -153,2 +159,5 @@ class IncidenceBase : public CustomProperties
153 QString mUid; 159 QString mUid;
160 int mCalID;
161 bool mCalEnabled;
162 bool mAlarmEnabled;
154 QDateTime mLastModified; 163 QDateTime mLastModified;
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index c97a61e..42274ff 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -519,3 +519,3 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_d
519{ 519{
520 if ( isCompleted() || ! hasDueDate() || cancelled() ) { 520 if ( isCompleted() || ! hasDueDate() || cancelled() || !alarmEnabled() ) {
521 *ok = false; 521 *ok = false;