summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-06-13 10:51:47 (UTC)
committer zautrix <zautrix>2005-06-13 10:51:47 (UTC)
commit4f3ff02932b39bf16b9692c3cb69c101a28b4616 (patch) (unidiff)
treebae36a7e654c788a0994bb353f3997b495e2459c /libkcal
parent2be8214908c52298ba79c8058d340edca5a8b417 (diff)
downloadkdepimpi-4f3ff02932b39bf16b9692c3cb69c101a28b4616.zip
kdepimpi-4f3ff02932b39bf16b9692c3cb69c101a28b4616.tar.gz
kdepimpi-4f3ff02932b39bf16b9692c3cb69c101a28b4616.tar.bz2
fixx
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp5
-rw-r--r--libkcal/calendar.h9
-rw-r--r--libkcal/calendarlocal.cpp56
-rw-r--r--libkcal/calendarlocal.h6
4 files changed, 71 insertions, 5 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index f4350d9..5092d1a 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -32,48 +32,49 @@
32#include "calendar.h" 32#include "calendar.h"
33#include "syncdefines.h" 33#include "syncdefines.h"
34 34
35using namespace KCal; 35using namespace KCal;
36 36
37Calendar::Calendar() 37Calendar::Calendar()
38{ 38{
39 39
40 init(); 40 init();
41 setTimeZoneId( " 00:00 Europe/London(UTC)" ); 41 setTimeZoneId( " 00:00 Europe/London(UTC)" );
42} 42}
43 43
44Calendar::Calendar( const QString &timeZoneId ) 44Calendar::Calendar( const QString &timeZoneId )
45{ 45{
46 46
47 init(); 47 init();
48 setTimeZoneId(timeZoneId); 48 setTimeZoneId(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 mDeleteIncidencesOnClose = true;
56 mModified = false; 57 mModified = false;
57 mDefaultCalendar = 1; 58 mDefaultCalendar = 1;
58 // Setup default filter, which does nothing 59 // Setup default filter, which does nothing
59 mDefaultFilter = new CalFilter; 60 mDefaultFilter = new CalFilter;
60 mFilter = mDefaultFilter; 61 mFilter = mDefaultFilter;
61 mFilter->setEnabled(false); 62 mFilter->setEnabled(false);
62 63
63 // initialize random numbers. This is a hack, and not 64 // initialize random numbers. This is a hack, and not
64 // even that good of one at that. 65 // even that good of one at that.
65// srandom(time(0)); 66// srandom(time(0));
66 67
67 // user information... 68 // user information...
68 setOwner(i18n("Unknown Name")); 69 setOwner(i18n("Unknown Name"));
69 setEmail(i18n("unknown@nowhere")); 70 setEmail(i18n("unknown@nowhere"));
70 71
71#if 0 72#if 0
72 tmpStr = KOPrefs::instance()->mTimeZone; 73 tmpStr = KOPrefs::instance()->mTimeZone;
73// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; 74// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl;
74 int dstSetting = KOPrefs::instance()->mDaylightSavings; 75 int dstSetting = KOPrefs::instance()->mDaylightSavings;
75 extern long int timezone; 76 extern long int timezone;
76 struct tm *now; 77 struct tm *now;
77 time_t curtime; 78 time_t curtime;
78 curtime = time(0); 79 curtime = time(0);
79 now = localtime(&curtime); 80 now = localtime(&curtime);
@@ -91,48 +92,52 @@ void Calendar::init()
91 } else { 92 } else {
92 tzStr = tmpStr; 93 tzStr = tmpStr;
93 } 94 }
94 95
95 // if daylight savings has changed since last load time, we need 96 // if daylight savings has changed since last load time, we need
96 // to rewrite these settings to the config file. 97 // to rewrite these settings to the config file.
97 if ((now->tm_isdst && !dstSetting) || 98 if ((now->tm_isdst && !dstSetting) ||
98 (!now->tm_isdst && dstSetting)) { 99 (!now->tm_isdst && dstSetting)) {
99 KOPrefs::instance()->mTimeZone = tzStr; 100 KOPrefs::instance()->mTimeZone = tzStr;
100 KOPrefs::instance()->mDaylightSavings = now->tm_isdst; 101 KOPrefs::instance()->mDaylightSavings = now->tm_isdst;
101 } 102 }
102 103
103 setTimeZone(tzStr); 104 setTimeZone(tzStr);
104#endif 105#endif
105 106
106// KOPrefs::instance()->writeConfig(); 107// KOPrefs::instance()->writeConfig();
107} 108}
108 109
109Calendar::~Calendar() 110Calendar::~Calendar()
110{ 111{
111 delete mDefaultFilter; 112 delete mDefaultFilter;
112 if ( mUndoIncidence ) 113 if ( mUndoIncidence )
113 delete mUndoIncidence; 114 delete mUndoIncidence;
114} 115}
116void Calendar::setDontDeleteIncidencesOnClose ()
117{
118 mDeleteIncidencesOnClose = false;
119}
115void Calendar::setDefaultCalendar( int d ) 120void Calendar::setDefaultCalendar( int d )
116{ 121{
117 mDefaultCalendar = d; 122 mDefaultCalendar = d;
118} 123}
119int Calendar::defaultCalendar() 124int Calendar::defaultCalendar()
120{ 125{
121 return mDefaultCalendar; 126 return mDefaultCalendar;
122} 127}
123const QString &Calendar::getOwner() const 128const QString &Calendar::getOwner() const
124{ 129{
125 return mOwner; 130 return mOwner;
126} 131}
127 132
128bool Calendar::undoDeleteIncidence() 133bool Calendar::undoDeleteIncidence()
129{ 134{
130 if (!mUndoIncidence) 135 if (!mUndoIncidence)
131 return false; 136 return false;
132 addIncidence(mUndoIncidence); 137 addIncidence(mUndoIncidence);
133 mUndoIncidence = 0; 138 mUndoIncidence = 0;
134 return true; 139 return true;
135} 140}
136void Calendar::setOwner(const QString &os) 141void Calendar::setOwner(const QString &os)
137{ 142{
138 int i; 143 int i;
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 4c6760f..73f82bb 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -53,48 +53,50 @@ namespace KCal {
53 event (or any other subclass of IncidenceBase) object is added to the 53 event (or any other subclass of IncidenceBase) object is added to the
54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes 54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes
55 care of deleting it. All Events returned by the query functions are returned 55 care of deleting it. All Events returned by the query functions are returned
56 as pointers, that means all changes to the returned events are immediately 56 as pointers, that means all changes to the returned events are immediately
57 visible in the Calendar. You shouldn't delete any Event object you get from 57 visible in the Calendar. You shouldn't delete any Event object you get from
58 Calendar. 58 Calendar.
59*/ 59*/
60class Calendar : public QObject, public CustomProperties, 60class Calendar : public QObject, public CustomProperties,
61 public IncidenceBase::Observer 61 public IncidenceBase::Observer
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 Calendar(); 65 Calendar();
66 Calendar(const QString &timeZoneId); 66 Calendar(const QString &timeZoneId);
67 virtual ~Calendar(); 67 virtual ~Calendar();
68 Incidence * undoIncidence() { return mUndoIncidence; }; 68 Incidence * undoIncidence() { return mUndoIncidence; };
69 bool undoDeleteIncidence(); 69 bool undoDeleteIncidence();
70 void deleteIncidence(Incidence *in); 70 void deleteIncidence(Incidence *in);
71 void resetTempSyncStat(); 71 void resetTempSyncStat();
72 void resetPilotStat(int id); 72 void resetPilotStat(int id);
73 /** 73 /**
74 Clears out the current calendar, freeing all used memory etc. 74 Clears out the current calendar, freeing all used memory etc.
75 */ 75 */
76 virtual void close() = 0; 76 virtual void close() = 0;
77 virtual void addCalendar( Calendar* ) = 0;
78 virtual bool addCalendarFile( QString name, int id ) = 0;
77 79
78 /** 80 /**
79 Sync changes in memory to persistant storage. 81 Sync changes in memory to persistant storage.
80 */ 82 */
81 virtual void save() = 0; 83 virtual void save() = 0;
82 virtual QPtrList<Event> getExternLastSyncEvents() = 0; 84 virtual QPtrList<Event> getExternLastSyncEvents() = 0;
83 virtual void removeSyncInfo( QString syncProfile) = 0; 85 virtual void removeSyncInfo( QString syncProfile) = 0;
84 virtual bool isSaving() { return false; } 86 virtual bool isSaving() { return false; }
85 87
86 /** 88 /**
87 Return the owner of the calendar's full name. 89 Return the owner of the calendar's full name.
88 */ 90 */
89 const QString &getOwner() const; 91 const QString &getOwner() const;
90 /** 92 /**
91 Set the owner of the calendar. Should be owner's full name. 93 Set the owner of the calendar. Should be owner's full name.
92 */ 94 */
93 void setOwner( const QString &os ); 95 void setOwner( const QString &os );
94 /** 96 /**
95 Return the email address of the calendar owner. 97 Return the email address of the calendar owner.
96 */ 98 */
97 const QString &getEmail(); 99 const QString &getEmail();
98 /** 100 /**
99 Set the email address of the calendar owner. 101 Set the email address of the calendar owner.
100 */ 102 */
@@ -281,86 +283,91 @@ public:
281 Return all alarms, which ocur in the given time interval. 283 Return all alarms, which ocur in the given time interval.
282 */ 284 */
283 virtual Alarm::List alarms( const QDateTime &from, 285 virtual Alarm::List alarms( const QDateTime &from,
284 const QDateTime &to ) = 0; 286 const QDateTime &to ) = 0;
285 287
286 class Observer { 288 class Observer {
287 public: 289 public:
288 virtual void calendarModified( bool, Calendar * ) = 0; 290 virtual void calendarModified( bool, Calendar * ) = 0;
289 }; 291 };
290 292
291 void registerObserver( Observer * ); 293 void registerObserver( Observer * );
292 294
293 void setModified( bool ); 295 void setModified( bool );
294 296
295 /** 297 /**
296 Set product id returned by loadedProductId(). This function is only 298 Set product id returned by loadedProductId(). This function is only
297 useful for the calendar loading code. 299 useful for the calendar loading code.
298 */ 300 */
299 void setLoadedProductId( const QString & ); 301 void setLoadedProductId( const QString & );
300 /** 302 /**
301 Return product id taken from file that has been loaded. Returns 303 Return product id taken from file that has been loaded. Returns
302 QString::null, if no calendar has been loaded. 304 QString::null, if no calendar has been loaded.
303 */ 305 */
304 QString loadedProductId(); 306 QString loadedProductId();
305 void setDefaultCalendar( int );
306 int defaultCalendar(); 307 int defaultCalendar();
308 void setDontDeleteIncidencesOnClose ();
309 public slots:
310 void setDefaultCalendar( int );
307 virtual void setCalendarEnabled( int id, bool enable ) = 0; 311 virtual void setCalendarEnabled( int id, bool enable ) = 0;
308 virtual void setAlarmEnabled( int id, bool enable ) = 0; 312 virtual void setAlarmEnabled( int id, bool enable ) = 0;
313 virtual void setReadOnly( int id, bool enable ) = 0;
309 virtual void setDefaultCalendarEnabledOnly() = 0; 314 virtual void setDefaultCalendarEnabledOnly() = 0;
310 signals: 315 signals:
311 void calendarChanged(); 316 void calendarChanged();
312 void calendarSaved(); 317 void calendarSaved();
313 void calendarLoaded(); 318 void calendarLoaded();
314 void addAlarm(const QDateTime &qdt, const QString &noti ); 319 void addAlarm(const QDateTime &qdt, const QString &noti );
315 void removeAlarm(const QDateTime &qdt, const QString &noti ); 320 void removeAlarm(const QDateTime &qdt, const QString &noti );
316 321
317 protected: 322 protected:
318 /** 323 /**
319 Get unfiltered events, which occur on the given date. 324 Get unfiltered events, which occur on the given date.
320 */ 325 */
321 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; 326 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0;
322 /** 327 /**
323 Get unfiltered events, which occur on the given date. 328 Get unfiltered events, which occur on the given date.
324 */ 329 */
325 virtual QPtrList<Event> rawEventsForDate( const QDate &date, 330 virtual QPtrList<Event> rawEventsForDate( const QDate &date,
326 bool sorted = false ) = 0; 331 bool sorted = false ) = 0;
327 /** 332 /**
328 Get events in a range of dates. If inclusive is set to true, only events 333 Get events in a range of dates. If inclusive is set to true, only events
329 are returned, which are completely included in the range. 334 are returned, which are completely included in the range.
330 */ 335 */
331 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 336 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
332 bool inclusive = false ) = 0; 337 bool inclusive = false ) = 0;
333 338
334 Incidence *mNextAlarmIncidence; 339 Incidence *mNextAlarmIncidence;
335 Incidence *mUndoIncidence; 340 Incidence *mUndoIncidence;
336 int mDefaultCalendar; 341 int mDefaultCalendar;
342 bool mDeleteIncidencesOnClose;
337 343
338private: 344private:
339 void init(); 345 void init();
340 346
341 QString mOwner; // who the calendar belongs to 347 QString mOwner; // who the calendar belongs to
342 QString mOwnerEmail; // email address of the owner 348 QString mOwnerEmail; // email address of the owner
343 int mTimeZone; // timezone OFFSET from GMT (MINUTES) 349 int mTimeZone; // timezone OFFSET from GMT (MINUTES)
344 bool mLocalTime; // use local time, not UTC or a time zone 350 bool mLocalTime; // use local time, not UTC or a time zone
345 351
352
346 CalFilter *mFilter; 353 CalFilter *mFilter;
347 CalFilter *mDefaultFilter; 354 CalFilter *mDefaultFilter;
348 355
349 356
350 QString mTimeZoneId; 357 QString mTimeZoneId;
351 358
352 Observer *mObserver; 359 Observer *mObserver;
353 bool mNewObserver; 360 bool mNewObserver;
354 361
355 bool mModified; 362 bool mModified;
356 363
357 QString mLoadedProductId; 364 QString mLoadedProductId;
358 365
359 // This list is used to put together related todos 366 // This list is used to put together related todos
360 QDict<Incidence> mOrphans; 367 QDict<Incidence> mOrphans;
361 QDict<Incidence> mOrphanUids; 368 QDict<Incidence> mOrphanUids;
362}; 369};
363 370
364} 371}
365 372
366#endif 373#endif
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index c5500bf..e48122a 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -44,51 +44,89 @@
44// #include <qtopia/alarmserver.h> 44// #include <qtopia/alarmserver.h>
45// #endif 45// #endif
46using namespace KCal; 46using namespace KCal;
47 47
48CalendarLocal::CalendarLocal() 48CalendarLocal::CalendarLocal()
49 : Calendar() 49 : Calendar()
50{ 50{
51 init(); 51 init();
52} 52}
53 53
54CalendarLocal::CalendarLocal(const QString &timeZoneId) 54CalendarLocal::CalendarLocal(const QString &timeZoneId)
55 : Calendar(timeZoneId) 55 : Calendar(timeZoneId)
56{ 56{
57 init(); 57 init();
58} 58}
59 59
60void CalendarLocal::init() 60void CalendarLocal::init()
61{ 61{
62 mNextAlarmIncidence = 0; 62 mNextAlarmIncidence = 0;
63} 63}
64 64
65 65
66CalendarLocal::~CalendarLocal() 66CalendarLocal::~CalendarLocal()
67{ 67{
68 close(); 68 if ( mDeleteIncidencesOnClose )
69 close();
70}
71bool CalendarLocal::addCalendarFile( QString name, int id )
72{
73 CalendarLocal calendar( timeZoneId() );
74 calendar.setDefaultCalendar( id );
75 if ( calendar.load( name ) ) {
76 addCalendar( &calendar );
77 return true;
78 }
79 return false;
80}
81void CalendarLocal::addCalendar( Calendar* cal )
82{
83 cal->setDontDeleteIncidencesOnClose();
84 {
85 QPtrList<Event> EventList = cal->rawEvents();
86 Event * ev = EventList.first();
87 while ( ev ) {
88 mEventList.append( ev );
89 ev = EventList.next();
90 }
91 }
92 {
93 QPtrList<Todo> TodoList = cal->rawTodos();
94 Todo * ev = TodoList.first();
95 while ( ev ) {
96 mTodoList.append( ev );
97 ev = TodoList.next();
98 }
99 }
100 {
101 QPtrList<Journal> JournalList = cal->journals();
102 Journal * ev = JournalList.first();
103 while ( ev ) {
104 mJournalList.append( ev );
105 ev = JournalList.next();
106 }
107 }
69} 108}
70
71bool CalendarLocal::load( const QString &fileName ) 109bool CalendarLocal::load( const QString &fileName )
72{ 110{
73 FileStorage storage( this, fileName ); 111 FileStorage storage( this, fileName );
74 return storage.load(); 112 return storage.load();
75} 113}
76 114
77bool CalendarLocal::save( const QString &fileName, CalFormat *format ) 115bool CalendarLocal::save( const QString &fileName, CalFormat *format )
78{ 116{
79 FileStorage storage( this, fileName, format ); 117 FileStorage storage( this, fileName, format );
80 return storage.save(); 118 return storage.save();
81} 119}
82 120
83void CalendarLocal::close() 121void CalendarLocal::close()
84{ 122{
85 123
86 Todo * i; 124 Todo * i;
87 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); 125 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false);
88 126
89 mEventList.setAutoDelete( true ); 127 mEventList.setAutoDelete( true );
90 mTodoList.setAutoDelete( true ); 128 mTodoList.setAutoDelete( true );
91 mJournalList.setAutoDelete( false ); 129 mJournalList.setAutoDelete( false );
92 130
93 mEventList.clear(); 131 mEventList.clear();
94 mTodoList.clear(); 132 mTodoList.clear();
@@ -735,48 +773,62 @@ Journal *CalendarLocal::journal( const QString &uid )
735 773
736 return 0; 774 return 0;
737} 775}
738 776
739QPtrList<Journal> CalendarLocal::journals() 777QPtrList<Journal> CalendarLocal::journals()
740{ 778{
741 QPtrList<Journal> el; 779 QPtrList<Journal> el;
742 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 780 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
743 if ( it->calEnabled() ) el.append( it ); 781 if ( it->calEnabled() ) el.append( it );
744 return el; 782 return el;
745} 783}
746 784
747void CalendarLocal::setCalendarEnabled( int id, bool enable ) 785void CalendarLocal::setCalendarEnabled( int id, bool enable )
748{ 786{
749 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 787 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
750 if ( it->calID() == id ) it->setCalEnabled( enable ); 788 if ( it->calID() == id ) it->setCalEnabled( enable );
751 789
752 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 790 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
753 if ( it->calID() == id ) it->setCalEnabled( enable ); 791 if ( it->calID() == id ) it->setCalEnabled( enable );
754 792
755 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 793 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
756 if ( it->calID() == id ) it->setCalEnabled( enable ); 794 if ( it->calID() == id ) it->setCalEnabled( enable );
757 795
758} 796}
797
798void CalendarLocal::setReadOnly( int id, bool enable )
799{
800 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
801 if ( it->calID() == id ) it->setReadOnly( enable );
802
803 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
804 if ( it->calID() == id ) it->setReadOnly( enable );
805
806 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
807 if ( it->calID() == id ) it->setReadOnly( enable );
808
809}
810
759void CalendarLocal::setAlarmEnabled( int id, bool enable ) 811void CalendarLocal::setAlarmEnabled( int id, bool enable )
760{ 812{
761 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 813 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
762 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 814 if ( it->calID() == id ) it->setAlarmEnabled( enable );
763 815
764 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 816 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
765 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 817 if ( it->calID() == id ) it->setAlarmEnabled( enable );
766 818
767 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 819 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
768 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 820 if ( it->calID() == id ) it->setAlarmEnabled( enable );
769 821
770} 822}
771void CalendarLocal::setDefaultCalendarEnabledOnly() 823void CalendarLocal::setDefaultCalendarEnabledOnly()
772{ 824{
773 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 825 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
774 it->setCalEnabled( it->calID() == mDefaultCalendar ); 826 it->setCalEnabled( it->calID() == mDefaultCalendar );
775 827
776 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 828 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
777 it->setCalEnabled( it->calID() == mDefaultCalendar); 829 it->setCalEnabled( it->calID() == mDefaultCalendar);
778 830
779 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 831 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
780 it->setCalEnabled( it->calID() == mDefaultCalendar); 832 it->setCalEnabled( it->calID() == mDefaultCalendar);
781 833
782} 834}
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index b25fcbe..65f6aa7 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -22,49 +22,50 @@
22#ifndef KCAL_CALENDARLOCAL_H 22#ifndef KCAL_CALENDARLOCAL_H
23#define KCAL_CALENDARLOCAL_H 23#define KCAL_CALENDARLOCAL_H
24 24
25#include "calendar.h" 25#include "calendar.h"
26 26
27namespace KCal { 27namespace KCal {
28 28
29class CalFormat; 29class CalFormat;
30 30
31/** 31/**
32 This class provides a calendar stored as a local file. 32 This class provides a calendar stored as a local file.
33*/ 33*/
34class CalendarLocal : public Calendar 34class CalendarLocal : public Calendar
35{ 35{
36 public: 36 public:
37 /** 37 /**
38 Constructs a new calendar, with variables initialized to sane values. 38 Constructs a new calendar, with variables initialized to sane values.
39 */ 39 */
40 CalendarLocal(); 40 CalendarLocal();
41 /** 41 /**
42 Constructs a new calendar, with variables initialized to sane values. 42 Constructs a new calendar, with variables initialized to sane values.
43 */ 43 */
44 CalendarLocal( const QString &timeZoneId ); 44 CalendarLocal( const QString &timeZoneId );
45 ~CalendarLocal(); 45 ~CalendarLocal();
46 46 void addCalendar( Calendar* );
47 bool addCalendarFile( QString name, int id );
47 /** 48 /**
48 Loads a calendar on disk in vCalendar or iCalendar format into the current 49 Loads a calendar on disk in vCalendar or iCalendar format into the current
49 calendar. Any information already present is lost. 50 calendar. Any information already present is lost.
50 @return true, if successfull, false on error. 51 @return true, if successfull, false on error.
51 @param fileName the name of the calendar on disk. 52 @param fileName the name of the calendar on disk.
52 */ 53 */
53 bool load( const QString &fileName ); 54 bool load( const QString &fileName );
54 /** 55 /**
55 Writes out the calendar to disk in the specified \a format. 56 Writes out the calendar to disk in the specified \a format.
56 CalendarLocal takes ownership of the CalFormat object. 57 CalendarLocal takes ownership of the CalFormat object.
57 @return true, if successfull, false on error. 58 @return true, if successfull, false on error.
58 @param fileName the name of the file 59 @param fileName the name of the file
59 */ 60 */
60 bool save( const QString &fileName, CalFormat *format = 0 ); 61 bool save( const QString &fileName, CalFormat *format = 0 );
61 62
62 /** 63 /**
63 Clears out the current calendar, freeing all used memory etc. etc. 64 Clears out the current calendar, freeing all used memory etc. etc.
64 */ 65 */
65 void close(); 66 void close();
66 67
67 void save() {} 68 void save() {}
68 69
69 /** 70 /**
70 Add Event to calendar. 71 Add Event to calendar.
@@ -158,51 +159,52 @@ class CalendarLocal : public Calendar
158 This method should be called whenever a Event is modified directly 159 This method should be called whenever a Event is modified directly
159 via it's pointer. It makes sure that the calendar is internally 160 via it's pointer. It makes sure that the calendar is internally
160 consistent. 161 consistent.
161 */ 162 */
162 void update( IncidenceBase *incidence ); 163 void update( IncidenceBase *incidence );
163 164
164 /** 165 /**
165 Builds and then returns a list of all events that match for the 166 Builds and then returns a list of all events that match for the
166 date specified. useful for dayView, etc. etc. 167 date specified. useful for dayView, etc. etc.
167 */ 168 */
168 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); 169 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false );
169 /** 170 /**
170 Get unfiltered events for date \a qdt. 171 Get unfiltered events for date \a qdt.
171 */ 172 */
172 QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); 173 QPtrList<Event> rawEventsForDate( const QDateTime &qdt );
173 /** 174 /**
174 Get unfiltered events in a range of dates. If inclusive is set to true, 175 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. 176 only events are returned, which are completely included in the range.
176 */ 177 */
177 QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 178 QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
178 bool inclusive = false ); 179 bool inclusive = false );
179 Todo *todo( QString, QString ); 180 Todo *todo( QString, QString );
180 Event *event( QString, QString ); 181 Event *event( QString, QString );
181 182
182 183public slots:
183 void setCalendarEnabled( int id, bool enable ); 184 void setCalendarEnabled( int id, bool enable );
184 void setAlarmEnabled( int id, bool enable ); 185 void setAlarmEnabled( int id, bool enable );
186 void setReadOnly( int id, bool enable );
185 void setDefaultCalendarEnabledOnly(); 187 void setDefaultCalendarEnabledOnly();
186 188
187 protected: 189 protected:
188 190
189 // Event* mNextAlarmEvent; 191 // Event* mNextAlarmEvent;
190 QString mNextSummary; 192 QString mNextSummary;
191 QString mNextAlarmEventDateTimeString; 193 QString mNextAlarmEventDateTimeString;
192 QString mLastAlarmNotificationString; 194 QString mLastAlarmNotificationString;
193 QDateTime mNextAlarmEventDateTime; 195 QDateTime mNextAlarmEventDateTime;
194 QDateTime mNextAlarmDateTime; 196 QDateTime mNextAlarmDateTime;
195 void reInitAlarmSettings(); 197 void reInitAlarmSettings();
196 198
197 /** Notification function of IncidenceBase::Observer. */ 199 /** Notification function of IncidenceBase::Observer. */
198 void incidenceUpdated( IncidenceBase *i ) { update( i ); } 200 void incidenceUpdated( IncidenceBase *i ) { update( i ); }
199 201
200 /** inserts an event into its "proper place" in the calendar. */ 202 /** inserts an event into its "proper place" in the calendar. */
201 void insertEvent( Event *event ); 203 void insertEvent( Event *event );
202 204
203 /** Append alarms of incidence in interval to list of alarms. */ 205 /** Append alarms of incidence in interval to list of alarms. */
204 void appendAlarms( Alarm::List &alarms, Incidence *incidence, 206 void appendAlarms( Alarm::List &alarms, Incidence *incidence,
205 const QDateTime &from, const QDateTime &to ); 207 const QDateTime &from, const QDateTime &to );
206 208
207 /** Append alarms of recurring events in interval to list of alarms. */ 209 /** Append alarms of recurring events in interval to list of alarms. */
208 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, 210 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence,