summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2004-08-02 00:09:04 (UTC)
committer zautrix <zautrix>2004-08-02 00:09:04 (UTC)
commit3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0 (patch) (unidiff)
treefdff56329649c084b6f5af8d8e96c0157686575e /libkcal
parent3b4aa1cd78395c0f94b99decd901842944765746 (diff)
downloadkdepimpi-3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0.zip
kdepimpi-3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0.tar.gz
kdepimpi-3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0.tar.bz2
More sync hacking
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.h2
-rw-r--r--libkcal/calendarlocal.cpp14
-rw-r--r--libkcal/calendarlocal.h2
3 files changed, 15 insertions, 3 deletions
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 7d23619..df5bbcf 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -54,49 +54,49 @@ class CalFilter;
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 void deleteIncidence(Incidence *in); 68 void deleteIncidence(Incidence *in);
69 /** 69 /**
70 Clears out the current calendar, freeing all used memory etc. 70 Clears out the current calendar, freeing all used memory etc.
71 */ 71 */
72 virtual void close() = 0; 72 virtual void close() = 0;
73 73
74 /** 74 /**
75 Sync changes in memory to persistant storage. 75 Sync changes in memory to persistant storage.
76 */ 76 */
77 virtual void save() = 0; 77 virtual void save() = 0;
78 78 virtual QPtrList<Event> getExternLastSyncEvents() = 0;
79 virtual bool isSaving() { return false; } 79 virtual bool isSaving() { return false; }
80 80
81 /** 81 /**
82 Return the owner of the calendar's full name. 82 Return the owner of the calendar's full name.
83 */ 83 */
84 const QString &getOwner() const; 84 const QString &getOwner() const;
85 /** 85 /**
86 Set the owner of the calendar. Should be owner's full name. 86 Set the owner of the calendar. Should be owner's full name.
87 */ 87 */
88 void setOwner( const QString &os ); 88 void setOwner( const QString &os );
89 /** 89 /**
90 Return the email address of the calendar owner. 90 Return the email address of the calendar owner.
91 */ 91 */
92 const QString &getEmail(); 92 const QString &getEmail();
93 /** 93 /**
94 Set the email address of the calendar owner. 94 Set the email address of the calendar owner.
95 */ 95 */
96 void setEmail( const QString & ); 96 void setEmail( const QString & );
97 97
98 /** 98 /**
99 Set time zone from a timezone string (e.g. -2:00) 99 Set time zone from a timezone string (e.g. -2:00)
100 */ 100 */
101 void setTimeZone( const QString &tz ); 101 void setTimeZone( const QString &tz );
102 /** 102 /**
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 3c572f0..09ce9f0 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -201,48 +201,61 @@ bool CalendarLocal::addTodo( Todo *todo )
201void CalendarLocal::deleteTodo( Todo *todo ) 201void 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
211QPtrList<Todo> CalendarLocal::rawTodos() 211QPtrList<Todo> CalendarLocal::rawTodos()
212{ 212{
213 return mTodoList; 213 return mTodoList;
214} 214}
215Todo *CalendarLocal::todo( int id ) 215Todo *CalendarLocal::todo( int 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->zaurusId() == id ) return todo; 219 if ( todo->zaurusId() == id ) return todo;
220 } 220 }
221 221
222 return 0; 222 return 0;
223} 223}
224 224
225QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
226{
227 QPtrList<Event> el;
228 Event *todo;
229 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
230 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
231 if ( todo->summary().left(3) == "E: " )
232 el.append( todo );
233 }
234
235 return el;
236
237}
225Event *CalendarLocal::event( int id ) 238Event *CalendarLocal::event( int id )
226{ 239{
227 Event *todo; 240 Event *todo;
228 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 241 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
229 if ( todo->zaurusId() == id ) return todo; 242 if ( todo->zaurusId() == id ) return todo;
230 } 243 }
231 244
232 return 0; 245 return 0;
233} 246}
234Todo *CalendarLocal::todo( const QString &uid ) 247Todo *CalendarLocal::todo( const QString &uid )
235{ 248{
236 Todo *todo; 249 Todo *todo;
237 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 250 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
238 if ( todo->uid() == uid ) return todo; 251 if ( todo->uid() == uid ) return todo;
239 } 252 }
240 253
241 return 0; 254 return 0;
242} 255}
243QString CalendarLocal::nextSummary() const 256QString CalendarLocal::nextSummary() const
244{ 257{
245 return mNextSummary; 258 return mNextSummary;
246} 259}
247QDateTime CalendarLocal::nextAlarmEventDateTime() const 260QDateTime CalendarLocal::nextAlarmEventDateTime() const
248{ 261{
@@ -299,49 +312,48 @@ void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted
299 } 312 }
300 newNextAlarm = true; 313 newNextAlarm = true;
301 } 314 }
302 if ( newNextAlarm ) 315 if ( newNextAlarm )
303 registerAlarm(); 316 registerAlarm();
304} 317}
305QString CalendarLocal:: getAlarmNotification() 318QString CalendarLocal:: getAlarmNotification()
306{ 319{
307 QString ret; 320 QString ret;
308 // this should not happen 321 // this should not happen
309 if (! mNextAlarmIncidence ) 322 if (! mNextAlarmIncidence )
310 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; 323 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString;
311 Alarm* alarm = mNextAlarmIncidence->alarms().first(); 324 Alarm* alarm = mNextAlarmIncidence->alarms().first();
312 if ( alarm->type() == Alarm::Procedure ) { 325 if ( alarm->type() == Alarm::Procedure ) {
313 ret = "proc_alarm" + alarm->programFile()+"+++"; 326 ret = "proc_alarm" + alarm->programFile()+"+++";
314 } else { 327 } else {
315 ret = "audio_alarm" +alarm->audioFile() +"+++"; 328 ret = "audio_alarm" +alarm->audioFile() +"+++";
316 } 329 }
317 ret += "cal_alarm"+ mNextSummary.left( 25 ); 330 ret += "cal_alarm"+ mNextSummary.left( 25 );
318 if ( mNextSummary.length() > 25 ) 331 if ( mNextSummary.length() > 25 )
319 ret += "\n" + mNextSummary.mid(25, 25 ); 332 ret += "\n" + mNextSummary.mid(25, 25 );
320 ret+= "\n"+mNextAlarmEventDateTimeString; 333 ret+= "\n"+mNextAlarmEventDateTimeString;
321 return ret; 334 return ret;
322} 335}
323
324void CalendarLocal::registerAlarm() 336void CalendarLocal::registerAlarm()
325{ 337{
326 mLastAlarmNotificationString = getAlarmNotification(); 338 mLastAlarmNotificationString = getAlarmNotification();
327 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); 339 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() );
328 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 340 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
329// #ifndef DESKTOP_VERSION 341// #ifndef DESKTOP_VERSION
330// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); 342// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() );
331// #endif 343// #endif
332} 344}
333void CalendarLocal::deRegisterAlarm() 345void CalendarLocal::deRegisterAlarm()
334{ 346{
335 if ( mLastAlarmNotificationString.isNull() ) 347 if ( mLastAlarmNotificationString.isNull() )
336 return; 348 return;
337 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); 349 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() );
338 350
339 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 351 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
340// #ifndef DESKTOP_VERSION 352// #ifndef DESKTOP_VERSION
341// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); 353// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() );
342// #endif 354// #endif
343} 355}
344 356
345QPtrList<Todo> CalendarLocal::todos( const QDate &date ) 357QPtrList<Todo> CalendarLocal::todos( const QDate &date )
346{ 358{
347 QPtrList<Todo> todos; 359 QPtrList<Todo> todos;
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index a2e50e3..3257198 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -64,49 +64,49 @@ class CalendarLocal : public Calendar
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 bool addAnniversaryNoDup( Event *event ); 72 bool addAnniversaryNoDup( Event *event );
73 bool addEventNoDup( Event *event ); 73 bool addEventNoDup( Event *event );
74 bool addEvent( Event *event ); 74 bool addEvent( Event *event );
75 /** 75 /**
76 Deletes an event from this calendar. 76 Deletes an event from this calendar.
77 */ 77 */
78 void deleteEvent( Event *event ); 78 void deleteEvent( Event *event );
79 79
80 /** 80 /**
81 Retrieves an event on the basis of the unique string ID. 81 Retrieves an event on the basis of the unique string ID.
82 */ 82 */
83 Event *event( const QString &uid ); 83 Event *event( const QString &uid );
84 /** 84 /**
85 Return unfiltered list of all events in calendar. 85 Return unfiltered list of all events in calendar.
86 */ 86 */
87 QPtrList<Event> rawEvents(); 87 QPtrList<Event> rawEvents();
88 88 QPtrList<Event> getExternLastSyncEvents();
89 /** 89 /**
90 Add a todo to the todolist. 90 Add a todo to the todolist.
91 */ 91 */
92 bool addTodo( Todo *todo ); 92 bool addTodo( Todo *todo );
93 bool addTodoNoDup( Todo *todo ); 93 bool addTodoNoDup( Todo *todo );
94 /** 94 /**
95 Remove a todo from the todolist. 95 Remove a todo from the todolist.
96 */ 96 */
97 void deleteTodo( Todo * ); 97 void deleteTodo( Todo * );
98 /** 98 /**
99 Searches todolist for an event with this unique string identifier, 99 Searches todolist for an event with this unique string identifier,
100 returns a pointer or null. 100 returns a pointer or null.
101 */ 101 */
102 Todo *todo( const QString &uid ); 102 Todo *todo( const QString &uid );
103 /** 103 /**
104 Return list of all todos. 104 Return list of all todos.
105 */ 105 */
106 QPtrList<Todo> rawTodos(); 106 QPtrList<Todo> rawTodos();
107 /** 107 /**
108 Returns list of todos due on the specified date. 108 Returns list of todos due on the specified date.
109 */ 109 */
110 QPtrList<Todo> todos( const QDate &date ); 110 QPtrList<Todo> todos( const QDate &date );
111 /** 111 /**
112 Return list of all todos. 112 Return list of all todos.