-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 10 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 2 |
4 files changed, 14 insertions, 0 deletions
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 2243e28..3b7b183 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -47,64 +47,65 @@ namespace KCal { | |||
47 | one calendar is associated with each CalendarView (@see calendarview.h). | 47 | one calendar is associated with each CalendarView (@see calendarview.h). |
48 | This is an abstract base class defining the interface to a calendar. It is | 48 | This is an abstract base class defining the interface to a calendar. It is |
49 | implemented by subclasses like @see CalendarLocal, which use different | 49 | implemented by subclasses like @see CalendarLocal, which use different |
50 | methods to store and access the data. | 50 | methods to store and access the data. |
51 | 51 | ||
52 | Ownership of events etc. is handled by the following policy: As soon as an | 52 | Ownership of events etc. is handled by the following policy: As soon as an |
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 | */ |
60 | class Calendar : public QObject, public CustomProperties, | 60 | class Calendar : public QObject, public CustomProperties, |
61 | public IncidenceBase::Observer | 61 | public IncidenceBase::Observer |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
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; | 77 | virtual void addCalendar( Calendar* ) = 0; |
78 | virtual bool addCalendarFile( QString name, int id ) = 0; | 78 | virtual bool addCalendarFile( QString name, int id ) = 0; |
79 | virtual void setSyncEventsReadOnly() = 0; | ||
79 | 80 | ||
80 | /** | 81 | /** |
81 | Sync changes in memory to persistant storage. | 82 | Sync changes in memory to persistant storage. |
82 | */ | 83 | */ |
83 | virtual void save() = 0; | 84 | virtual void save() = 0; |
84 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 85 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
85 | virtual void removeSyncInfo( QString syncProfile) = 0; | 86 | virtual void removeSyncInfo( QString syncProfile) = 0; |
86 | virtual bool isSaving() { return false; } | 87 | virtual bool isSaving() { return false; } |
87 | 88 | ||
88 | /** | 89 | /** |
89 | Return the owner of the calendar's full name. | 90 | Return the owner of the calendar's full name. |
90 | */ | 91 | */ |
91 | const QString &getOwner() const; | 92 | const QString &getOwner() const; |
92 | /** | 93 | /** |
93 | Set the owner of the calendar. Should be owner's full name. | 94 | Set the owner of the calendar. Should be owner's full name. |
94 | */ | 95 | */ |
95 | void setOwner( const QString &os ); | 96 | void setOwner( const QString &os ); |
96 | /** | 97 | /** |
97 | Return the email address of the calendar owner. | 98 | Return the email address of the calendar owner. |
98 | */ | 99 | */ |
99 | const QString &getEmail(); | 100 | const QString &getEmail(); |
100 | /** | 101 | /** |
101 | Set the email address of the calendar owner. | 102 | Set the email address of the calendar owner. |
102 | */ | 103 | */ |
103 | void setEmail( const QString & ); | 104 | void setEmail( const QString & ); |
104 | 105 | ||
105 | /** | 106 | /** |
106 | Set time zone from a timezone string (e.g. -2:00) | 107 | Set time zone from a timezone string (e.g. -2:00) |
107 | */ | 108 | */ |
108 | void setTimeZone( const QString &tz ); | 109 | void setTimeZone( const QString &tz ); |
109 | /** | 110 | /** |
110 | Set time zone from a minutes value (e.g. -60) | 111 | Set time zone from a minutes value (e.g. -60) |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 336c3e8..8c4dde1 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -49,64 +49,74 @@ CalendarLocal::CalendarLocal() | |||
49 | : Calendar() | 49 | : Calendar() |
50 | { | 50 | { |
51 | init(); | 51 | init(); |
52 | } | 52 | } |
53 | 53 | ||
54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) | 54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) |
55 | : Calendar(timeZoneId) | 55 | : Calendar(timeZoneId) |
56 | { | 56 | { |
57 | init(); | 57 | init(); |
58 | } | 58 | } |
59 | 59 | ||
60 | void CalendarLocal::init() | 60 | void CalendarLocal::init() |
61 | { | 61 | { |
62 | mNextAlarmIncidence = 0; | 62 | mNextAlarmIncidence = 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | CalendarLocal::~CalendarLocal() | 66 | CalendarLocal::~CalendarLocal() |
67 | { | 67 | { |
68 | if ( mDeleteIncidencesOnClose ) | 68 | if ( mDeleteIncidencesOnClose ) |
69 | close(); | 69 | close(); |
70 | } | 70 | } |
71 | bool CalendarLocal::addCalendarFile( QString name, int id ) | 71 | bool CalendarLocal::addCalendarFile( QString name, int id ) |
72 | { | 72 | { |
73 | CalendarLocal calendar( timeZoneId() ); | 73 | CalendarLocal calendar( timeZoneId() ); |
74 | calendar.setDefaultCalendar( id ); | 74 | calendar.setDefaultCalendar( id ); |
75 | if ( calendar.load( name ) ) { | 75 | if ( calendar.load( name ) ) { |
76 | addCalendar( &calendar ); | 76 | addCalendar( &calendar ); |
77 | return true; | 77 | return true; |
78 | } | 78 | } |
79 | return false; | 79 | return false; |
80 | } | 80 | } |
81 | void CalendarLocal::setSyncEventsReadOnly() | ||
82 | { | ||
83 | Event * ev; | ||
84 | ev = mEventList.first(); | ||
85 | while ( ev ) { | ||
86 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | ||
87 | ev->setReadOnly( true ); | ||
88 | ev = mEventList.next(); | ||
89 | } | ||
90 | } | ||
81 | void CalendarLocal::addCalendar( Calendar* cal ) | 91 | void CalendarLocal::addCalendar( Calendar* cal ) |
82 | { | 92 | { |
83 | cal->setDontDeleteIncidencesOnClose(); | 93 | cal->setDontDeleteIncidencesOnClose(); |
84 | { | 94 | { |
85 | QPtrList<Event> EventList = cal->rawEvents(); | 95 | QPtrList<Event> EventList = cal->rawEvents(); |
86 | Event * ev = EventList.first(); | 96 | Event * ev = EventList.first(); |
87 | while ( ev ) { | 97 | while ( ev ) { |
88 | ev->unRegisterObserver( cal ); | 98 | ev->unRegisterObserver( cal ); |
89 | ev->registerObserver( this ); | 99 | ev->registerObserver( this ); |
90 | mEventList.append( ev ); | 100 | mEventList.append( ev ); |
91 | ev = EventList.next(); | 101 | ev = EventList.next(); |
92 | } | 102 | } |
93 | } | 103 | } |
94 | { | 104 | { |
95 | 105 | ||
96 | QPtrList<Todo> TodoList = cal->rawTodos(); | 106 | QPtrList<Todo> TodoList = cal->rawTodos(); |
97 | Todo * ev = TodoList.first(); | 107 | Todo * ev = TodoList.first(); |
98 | while ( ev ) { | 108 | while ( ev ) { |
99 | QString rel = ev->relatedToUid(); | 109 | QString rel = ev->relatedToUid(); |
100 | if ( !rel.isEmpty() ){ | 110 | if ( !rel.isEmpty() ){ |
101 | ev->setRelatedTo ( 0 ); | 111 | ev->setRelatedTo ( 0 ); |
102 | ev->setRelatedToUid( rel ); | 112 | ev->setRelatedToUid( rel ); |
103 | } | 113 | } |
104 | ev = TodoList.next(); | 114 | ev = TodoList.next(); |
105 | } | 115 | } |
106 | //TodoList = cal->rawTodos(); | 116 | //TodoList = cal->rawTodos(); |
107 | ev = TodoList.first(); | 117 | ev = TodoList.first(); |
108 | while ( ev ) { | 118 | while ( ev ) { |
109 | ev->unRegisterObserver( cal ); | 119 | ev->unRegisterObserver( cal ); |
110 | ev->registerObserver( this ); | 120 | ev->registerObserver( this ); |
111 | mTodoList.append( ev ); | 121 | mTodoList.append( ev ); |
112 | setupRelations( ev ); | 122 | setupRelations( ev ); |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 5bbe55f..0286b48 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -16,64 +16,65 @@ | |||
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
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 | ||
27 | namespace KCal { | 27 | namespace KCal { |
28 | 28 | ||
29 | class CalFormat; | 29 | class 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 | */ |
34 | class CalendarLocal : public Calendar | 34 | class 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 | void addCalendar( Calendar* ); | 46 | void addCalendar( Calendar* ); |
47 | bool addCalendarFile( QString name, int id ); | 47 | bool addCalendarFile( QString name, int id ); |
48 | void setSyncEventsReadOnly(); | ||
48 | /** | 49 | /** |
49 | Loads a calendar on disk in vCalendar or iCalendar format into the current | 50 | Loads a calendar on disk in vCalendar or iCalendar format into the current |
50 | calendar. Any information already present is lost. | 51 | calendar. Any information already present is lost. |
51 | @return true, if successfull, false on error. | 52 | @return true, if successfull, false on error. |
52 | @param fileName the name of the calendar on disk. | 53 | @param fileName the name of the calendar on disk. |
53 | */ | 54 | */ |
54 | bool load( const QString &fileName ); | 55 | bool load( const QString &fileName ); |
55 | /** | 56 | /** |
56 | Writes out the calendar to disk in the specified \a format. | 57 | Writes out the calendar to disk in the specified \a format. |
57 | CalendarLocal takes ownership of the CalFormat object. | 58 | CalendarLocal takes ownership of the CalFormat object. |
58 | @return true, if successfull, false on error. | 59 | @return true, if successfull, false on error. |
59 | @param fileName the name of the file | 60 | @param fileName the name of the file |
60 | */ | 61 | */ |
61 | bool save( const QString &fileName, CalFormat *format = 0 ); | 62 | bool save( const QString &fileName, CalFormat *format = 0 ); |
62 | 63 | ||
63 | /** | 64 | /** |
64 | Clears out the current calendar, freeing all used memory etc. etc. | 65 | Clears out the current calendar, freeing all used memory etc. etc. |
65 | */ | 66 | */ |
66 | void close(); | 67 | void close(); |
67 | 68 | ||
68 | void save() {} | 69 | void save() {} |
69 | 70 | ||
70 | /** | 71 | /** |
71 | Add Event to calendar. | 72 | Add Event to calendar. |
72 | */ | 73 | */ |
73 | void removeSyncInfo( QString syncProfile); | 74 | void removeSyncInfo( QString syncProfile); |
74 | bool addAnniversaryNoDup( Event *event ); | 75 | bool addAnniversaryNoDup( Event *event ); |
75 | bool addEventNoDup( Event *event ); | 76 | bool addEventNoDup( Event *event ); |
76 | bool addEvent( Event *event ); | 77 | bool addEvent( Event *event ); |
77 | /** | 78 | /** |
78 | Deletes an event from this calendar. | 79 | Deletes an event from this calendar. |
79 | */ | 80 | */ |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 2ddbb01..96039df 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -112,64 +112,66 @@ bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | |||
112 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); | 112 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); |
113 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); | 113 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); |
114 | 114 | ||
115 | #endif | 115 | #endif |
116 | if ( i1.hasDuration() == i2.hasDuration() ) { | 116 | if ( i1.hasDuration() == i2.hasDuration() ) { |
117 | if ( i1.hasDuration() ) { | 117 | if ( i1.hasDuration() ) { |
118 | if ( i1.duration() != i2.duration() ) | 118 | if ( i1.duration() != i2.duration() ) |
119 | return false; | 119 | return false; |
120 | } | 120 | } |
121 | } else { | 121 | } else { |
122 | return false; | 122 | return false; |
123 | } | 123 | } |
124 | 124 | ||
125 | return ( i1.organizer() == i2.organizer() && | 125 | return ( i1.organizer() == i2.organizer() && |
126 | // i1.uid() == i2.uid() && | 126 | // i1.uid() == i2.uid() && |
127 | // Don't compare lastModified, otherwise the operator is not | 127 | // Don't compare lastModified, otherwise the operator is not |
128 | // of much use. We are not comparing for identity, after all. | 128 | // of much use. We are not comparing for identity, after all. |
129 | i1.doesFloat() == i2.doesFloat() && | 129 | i1.doesFloat() == i2.doesFloat() && |
130 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); | 130 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); |
131 | // no need to compare mObserver | 131 | // no need to compare mObserver |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) | 135 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) |
136 | { | 136 | { |
137 | QTime t = dt.time(); | 137 | QTime t = dt.time(); |
138 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 138 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
139 | return dt; | 139 | return dt; |
140 | } | 140 | } |
141 | 141 | ||
142 | void IncidenceBase::setCalID( int id ) | 142 | void IncidenceBase::setCalID( int id ) |
143 | { | 143 | { |
144 | if ( mCalID > 0 ) | ||
145 | updated(); | ||
144 | mCalID = id; | 146 | mCalID = id; |
145 | } | 147 | } |
146 | int IncidenceBase::calID() const | 148 | int IncidenceBase::calID() const |
147 | { | 149 | { |
148 | return mCalID; | 150 | return mCalID; |
149 | } | 151 | } |
150 | void IncidenceBase::setCalEnabled( bool b ) | 152 | void IncidenceBase::setCalEnabled( bool b ) |
151 | { | 153 | { |
152 | mCalEnabled = b; | 154 | mCalEnabled = b; |
153 | } | 155 | } |
154 | bool IncidenceBase::calEnabled() const | 156 | bool IncidenceBase::calEnabled() const |
155 | { | 157 | { |
156 | return mCalEnabled; | 158 | return mCalEnabled; |
157 | } | 159 | } |
158 | 160 | ||
159 | void IncidenceBase::setAlarmEnabled( bool b ) | 161 | void IncidenceBase::setAlarmEnabled( bool b ) |
160 | { | 162 | { |
161 | mAlarmEnabled = b; | 163 | mAlarmEnabled = b; |
162 | } | 164 | } |
163 | bool IncidenceBase::alarmEnabled() const | 165 | bool IncidenceBase::alarmEnabled() const |
164 | { | 166 | { |
165 | return mAlarmEnabled; | 167 | return mAlarmEnabled; |
166 | } | 168 | } |
167 | 169 | ||
168 | 170 | ||
169 | void IncidenceBase::setUid(const QString &uid) | 171 | void IncidenceBase::setUid(const QString &uid) |
170 | { | 172 | { |
171 | mUid = uid; | 173 | mUid = uid; |
172 | updated(); | 174 | updated(); |
173 | } | 175 | } |
174 | 176 | ||
175 | QString IncidenceBase::uid() const | 177 | QString IncidenceBase::uid() const |