author | zautrix <zautrix> | 2004-10-26 22:19:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-26 22:19:18 (UTC) |
commit | 6385f303bef3cbcd19d097a7b05c30e144d5dd6e (patch) (unidiff) | |
tree | 770795d94ea6ec1dc8bcaa67cc174a9c0add564a /libkcal | |
parent | 13e996beddabc5e88f4f2fe49b2ce6cb8408eb30 (diff) | |
download | kdepimpi-6385f303bef3cbcd19d097a7b05c30e144d5dd6e.zip kdepimpi-6385f303bef3cbcd19d097a7b05c30e144d5dd6e.tar.gz kdepimpi-6385f303bef3cbcd19d097a7b05c30e144d5dd6e.tar.bz2 |
implemented remove sync info for kopi and kapi
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 23 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 5 |
4 files changed, 28 insertions, 2 deletions
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index b801186..b7d6a1f 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -49,64 +49,65 @@ namespace KCal { | |||
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 | void deleteIncidence(Incidence *in); | 68 | void deleteIncidence(Incidence *in); |
69 | void resetTempSyncStat(); | 69 | void resetTempSyncStat(); |
70 | void resetPilotStat(int id); | 70 | void resetPilotStat(int id); |
71 | /** | 71 | /** |
72 | Clears out the current calendar, freeing all used memory etc. | 72 | Clears out the current calendar, freeing all used memory etc. |
73 | */ | 73 | */ |
74 | virtual void close() = 0; | 74 | virtual void close() = 0; |
75 | 75 | ||
76 | /** | 76 | /** |
77 | Sync changes in memory to persistant storage. | 77 | Sync changes in memory to persistant storage. |
78 | */ | 78 | */ |
79 | virtual void save() = 0; | 79 | virtual void save() = 0; |
80 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 80 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
81 | virtual void removeSyncInfo( QString syncProfile) = 0; | ||
81 | virtual bool isSaving() { return false; } | 82 | virtual bool isSaving() { return false; } |
82 | 83 | ||
83 | /** | 84 | /** |
84 | Return the owner of the calendar's full name. | 85 | Return the owner of the calendar's full name. |
85 | */ | 86 | */ |
86 | const QString &getOwner() const; | 87 | const QString &getOwner() const; |
87 | /** | 88 | /** |
88 | Set the owner of the calendar. Should be owner's full name. | 89 | Set the owner of the calendar. Should be owner's full name. |
89 | */ | 90 | */ |
90 | void setOwner( const QString &os ); | 91 | void setOwner( const QString &os ); |
91 | /** | 92 | /** |
92 | Return the email address of the calendar owner. | 93 | Return the email address of the calendar owner. |
93 | */ | 94 | */ |
94 | const QString &getEmail(); | 95 | const QString &getEmail(); |
95 | /** | 96 | /** |
96 | Set the email address of the calendar owner. | 97 | Set the email address of the calendar owner. |
97 | */ | 98 | */ |
98 | void setEmail( const QString & ); | 99 | void setEmail( const QString & ); |
99 | 100 | ||
100 | /** | 101 | /** |
101 | Set time zone from a timezone string (e.g. -2:00) | 102 | Set time zone from a timezone string (e.g. -2:00) |
102 | */ | 103 | */ |
103 | void setTimeZone( const QString &tz ); | 104 | void setTimeZone( const QString &tz ); |
104 | /** | 105 | /** |
105 | Set time zone from a minutes value (e.g. -60) | 106 | Set time zone from a minutes value (e.g. -60) |
106 | */ | 107 | */ |
107 | void setTimeZone( int tz ); | 108 | void setTimeZone( int tz ); |
108 | /** | 109 | /** |
109 | Return time zone as offest in minutes. | 110 | Return time zone as offest in minutes. |
110 | */ | 111 | */ |
111 | int getTimeZone() const; | 112 | int getTimeZone() const; |
112 | /** | 113 | /** |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 21b4aaf..3f46d53 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -192,65 +192,86 @@ bool CalendarLocal::addTodo( Todo *todo ) | |||
192 | 192 | ||
193 | // Set up subtask relations | 193 | // Set up subtask relations |
194 | setupRelations( todo ); | 194 | setupRelations( todo ); |
195 | 195 | ||
196 | setModified( true ); | 196 | setModified( true ); |
197 | 197 | ||
198 | return true; | 198 | return true; |
199 | } | 199 | } |
200 | 200 | ||
201 | void CalendarLocal::deleteTodo( Todo *todo ) | 201 | void CalendarLocal::deleteTodo( Todo *todo ) |
202 | { | 202 | { |
203 | // Handle orphaned children | 203 | // Handle orphaned children |
204 | removeRelations( todo ); | 204 | removeRelations( todo ); |
205 | 205 | ||
206 | if ( mTodoList.removeRef( todo ) ) { | 206 | if ( mTodoList.removeRef( todo ) ) { |
207 | setModified( true ); | 207 | setModified( true ); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | QPtrList<Todo> CalendarLocal::rawTodos() | 211 | QPtrList<Todo> CalendarLocal::rawTodos() |
212 | { | 212 | { |
213 | return mTodoList; | 213 | return mTodoList; |
214 | } | 214 | } |
215 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 215 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
216 | { | 216 | { |
217 | Todo *todo; | 217 | Todo *todo; |
218 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 218 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
219 | if ( todo->getID( syncProf ) == id ) return todo; | 219 | if ( todo->getID( syncProf ) == id ) return todo; |
220 | } | 220 | } |
221 | 221 | ||
222 | return 0; | 222 | return 0; |
223 | } | 223 | } |
224 | 224 | void CalendarLocal::removeSyncInfo( QString syncProfile) | |
225 | { | ||
226 | QPtrList<Incidence> all = rawIncidences() ; | ||
227 | Incidence *inc; | ||
228 | for ( inc = all.first(); inc; inc = all.next() ) { | ||
229 | inc->removeID( syncProfile ); | ||
230 | } | ||
231 | if ( syncProfile.isEmpty() ) { | ||
232 | QPtrList<Event> el; | ||
233 | Event *todo; | ||
234 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | ||
235 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | ||
236 | el.append( todo ); | ||
237 | } | ||
238 | for ( todo = el.first(); todo; todo = el.next() ) { | ||
239 | deleteIncidence ( todo ); | ||
240 | } | ||
241 | } else { | ||
242 | Event *lse = event( "last-syncEvent-"+ syncProfile); | ||
243 | deleteIncidence ( lse ); | ||
244 | } | ||
245 | } | ||
225 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 246 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
226 | { | 247 | { |
227 | QPtrList<Event> el; | 248 | QPtrList<Event> el; |
228 | Event *todo; | 249 | Event *todo; |
229 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 250 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
230 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 251 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
231 | if ( todo->summary().left(3) == "E: " ) | 252 | if ( todo->summary().left(3) == "E: " ) |
232 | el.append( todo ); | 253 | el.append( todo ); |
233 | } | 254 | } |
234 | 255 | ||
235 | return el; | 256 | return el; |
236 | 257 | ||
237 | } | 258 | } |
238 | Event *CalendarLocal::event( QString syncProf, QString id ) | 259 | Event *CalendarLocal::event( QString syncProf, QString id ) |
239 | { | 260 | { |
240 | Event *todo; | 261 | Event *todo; |
241 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 262 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
242 | if ( todo->getID( syncProf ) == id ) return todo; | 263 | if ( todo->getID( syncProf ) == id ) return todo; |
243 | } | 264 | } |
244 | 265 | ||
245 | return 0; | 266 | return 0; |
246 | } | 267 | } |
247 | Todo *CalendarLocal::todo( const QString &uid ) | 268 | Todo *CalendarLocal::todo( const QString &uid ) |
248 | { | 269 | { |
249 | Todo *todo; | 270 | Todo *todo; |
250 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 271 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
251 | if ( todo->uid() == uid ) return todo; | 272 | if ( todo->uid() == uid ) return todo; |
252 | } | 273 | } |
253 | 274 | ||
254 | return 0; | 275 | return 0; |
255 | } | 276 | } |
256 | QString CalendarLocal::nextSummary() const | 277 | QString CalendarLocal::nextSummary() const |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 5b6c64c..98ec710 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -40,64 +40,65 @@ class CalendarLocal : public Calendar | |||
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 | ||
47 | /** | 47 | /** |
48 | Loads a calendar on disk in vCalendar or iCalendar format into the current | 48 | Loads a calendar on disk in vCalendar or iCalendar format into the current |
49 | calendar. Any information already present is lost. | 49 | calendar. Any information already present is lost. |
50 | @return true, if successfull, false on error. | 50 | @return true, if successfull, false on error. |
51 | @param fileName the name of the calendar on disk. | 51 | @param fileName the name of the calendar on disk. |
52 | */ | 52 | */ |
53 | bool load( const QString &fileName ); | 53 | bool load( const QString &fileName ); |
54 | /** | 54 | /** |
55 | Writes out the calendar to disk in the specified \a format. | 55 | Writes out the calendar to disk in the specified \a format. |
56 | CalendarLocal takes ownership of the CalFormat object. | 56 | CalendarLocal takes ownership of the CalFormat object. |
57 | @return true, if successfull, false on error. | 57 | @return true, if successfull, false on error. |
58 | @param fileName the name of the file | 58 | @param fileName the name of the file |
59 | */ | 59 | */ |
60 | bool save( const QString &fileName, CalFormat *format = 0 ); | 60 | bool save( const QString &fileName, CalFormat *format = 0 ); |
61 | 61 | ||
62 | /** | 62 | /** |
63 | Clears out the current calendar, freeing all used memory etc. etc. | 63 | Clears out the current calendar, freeing all used memory etc. etc. |
64 | */ | 64 | */ |
65 | void close(); | 65 | void close(); |
66 | 66 | ||
67 | void save() {} | 67 | void save() {} |
68 | 68 | ||
69 | /** | 69 | /** |
70 | Add Event to calendar. | 70 | Add Event to calendar. |
71 | */ | 71 | */ |
72 | void removeSyncInfo( QString syncProfile); | ||
72 | bool addAnniversaryNoDup( Event *event ); | 73 | bool addAnniversaryNoDup( Event *event ); |
73 | bool addEventNoDup( Event *event ); | 74 | bool addEventNoDup( Event *event ); |
74 | bool addEvent( Event *event ); | 75 | bool addEvent( Event *event ); |
75 | /** | 76 | /** |
76 | Deletes an event from this calendar. | 77 | Deletes an event from this calendar. |
77 | */ | 78 | */ |
78 | void deleteEvent( Event *event ); | 79 | void deleteEvent( Event *event ); |
79 | 80 | ||
80 | /** | 81 | /** |
81 | Retrieves an event on the basis of the unique string ID. | 82 | Retrieves an event on the basis of the unique string ID. |
82 | */ | 83 | */ |
83 | Event *event( const QString &uid ); | 84 | Event *event( const QString &uid ); |
84 | /** | 85 | /** |
85 | Return unfiltered list of all events in calendar. | 86 | Return unfiltered list of all events in calendar. |
86 | */ | 87 | */ |
87 | QPtrList<Event> rawEvents(); | 88 | QPtrList<Event> rawEvents(); |
88 | QPtrList<Event> getExternLastSyncEvents(); | 89 | QPtrList<Event> getExternLastSyncEvents(); |
89 | /** | 90 | /** |
90 | Add a todo to the todolist. | 91 | Add a todo to the todolist. |
91 | */ | 92 | */ |
92 | bool addTodo( Todo *todo ); | 93 | bool addTodo( Todo *todo ); |
93 | bool addTodoNoDup( Todo *todo ); | 94 | bool addTodoNoDup( Todo *todo ); |
94 | /** | 95 | /** |
95 | Remove a todo from the todolist. | 96 | Remove a todo from the todolist. |
96 | */ | 97 | */ |
97 | void deleteTodo( Todo * ); | 98 | void deleteTodo( Todo * ); |
98 | /** | 99 | /** |
99 | Searches todolist for an event with this unique string identifier, | 100 | Searches todolist for an event with this unique string identifier, |
100 | returns a pointer or null. | 101 | returns a pointer or null. |
101 | */ | 102 | */ |
102 | Todo *todo( const QString &uid ); | 103 | Todo *todo( const QString &uid ); |
103 | /** | 104 | /** |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index b36dc1a..9aa517c 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -324,65 +324,68 @@ void IncidenceBase::setSyncStatus(int stat) | |||
324 | if (mReadOnly) return; | 324 | if (mReadOnly) return; |
325 | mSyncStatus = stat; | 325 | mSyncStatus = stat; |
326 | } | 326 | } |
327 | 327 | ||
328 | int IncidenceBase::syncStatus() const | 328 | int IncidenceBase::syncStatus() const |
329 | { | 329 | { |
330 | return mSyncStatus; | 330 | return mSyncStatus; |
331 | } | 331 | } |
332 | 332 | ||
333 | void IncidenceBase::setPilotId( int id ) | 333 | void IncidenceBase::setPilotId( int id ) |
334 | { | 334 | { |
335 | if (mReadOnly) return; | 335 | if (mReadOnly) return; |
336 | mPilotId = id; | 336 | mPilotId = id; |
337 | } | 337 | } |
338 | 338 | ||
339 | int IncidenceBase::pilotId() const | 339 | int IncidenceBase::pilotId() const |
340 | { | 340 | { |
341 | return mPilotId; | 341 | return mPilotId; |
342 | } | 342 | } |
343 | 343 | ||
344 | int IncidenceBase::tempSyncStat() const | 344 | int IncidenceBase::tempSyncStat() const |
345 | { | 345 | { |
346 | return mTempSyncStat; | 346 | return mTempSyncStat; |
347 | } | 347 | } |
348 | void IncidenceBase::setTempSyncStat( int id ) | 348 | void IncidenceBase::setTempSyncStat( int id ) |
349 | { | 349 | { |
350 | if (mReadOnly) return; | 350 | if (mReadOnly) return; |
351 | mTempSyncStat = id; | 351 | mTempSyncStat = id; |
352 | } | 352 | } |
353 | 353 | ||
354 | void IncidenceBase::removeID(const QString &prof) | 354 | void IncidenceBase::removeID(const QString &prof) |
355 | { | 355 | { |
356 | mExternalId = KIdManager::removeId ( mExternalId, prof); | 356 | if ( prof.isEmpty() ) |
357 | mExternalId = ":"; | ||
358 | else | ||
359 | mExternalId = KIdManager::removeId ( mExternalId, prof); | ||
357 | 360 | ||
358 | } | 361 | } |
359 | void IncidenceBase::setID( const QString & prof , const QString & id ) | 362 | void IncidenceBase::setID( const QString & prof , const QString & id ) |
360 | { | 363 | { |
361 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); | 364 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); |
362 | } | 365 | } |
363 | QString IncidenceBase::getID( const QString & prof) | 366 | QString IncidenceBase::getID( const QString & prof) |
364 | { | 367 | { |
365 | return KIdManager::getId ( mExternalId, prof ); | 368 | return KIdManager::getId ( mExternalId, prof ); |
366 | } | 369 | } |
367 | 370 | ||
368 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: | 371 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: |
369 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 | 372 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 |
370 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) | 373 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) |
371 | { | 374 | { |
372 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); | 375 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); |
373 | } | 376 | } |
374 | QString IncidenceBase::getCsum( const QString & prof) | 377 | QString IncidenceBase::getCsum( const QString & prof) |
375 | { | 378 | { |
376 | return KIdManager::getCsum ( mExternalId, prof ); | 379 | return KIdManager::getCsum ( mExternalId, prof ); |
377 | } | 380 | } |
378 | 381 | ||
379 | void IncidenceBase::setIDStr( const QString & s ) | 382 | void IncidenceBase::setIDStr( const QString & s ) |
380 | { | 383 | { |
381 | if (mReadOnly) return; | 384 | if (mReadOnly) return; |
382 | mExternalId = s; | 385 | mExternalId = s; |
383 | } | 386 | } |
384 | 387 | ||
385 | QString IncidenceBase::IDStr() const | 388 | QString IncidenceBase::IDStr() const |
386 | { | 389 | { |
387 | return mExternalId ; | 390 | return mExternalId ; |
388 | } | 391 | } |