summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.h1
-rw-r--r--libkcal/calendarlocal.cpp23
-rw-r--r--libkcal/calendarlocal.h1
-rw-r--r--libkcal/incidencebase.cpp5
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
@@ -1,176 +1,177 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef CALENDAR_H 22#ifndef CALENDAR_H
23#define CALENDAR_H 23#define CALENDAR_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qptrlist.h> 28#include <qptrlist.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "event.h" 32#include "event.h"
33#include "todo.h" 33#include "todo.h"
34#include "journal.h" 34#include "journal.h"
35#include "calfilter.h" 35#include "calfilter.h"
36 36
37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ 37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */
38 38
39class KConfig; 39class KConfig;
40 40
41namespace KCal { 41namespace KCal {
42 42
43 43
44/** 44/**
45 This is the main "calendar" object class for KOrganizer. It holds 45 This is the main "calendar" object class for KOrganizer. It holds
46 information like all appointments/events, user information, etc. etc. 46 information like all appointments/events, user information, etc. etc.
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*/
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 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 /**
113 Compute an ISO 8601 format string from the time zone. 114 Compute an ISO 8601 format string from the time zone.
114 */ 115 */
115 QString getTimeZoneStr() const; 116 QString getTimeZoneStr() const;
116 /** 117 /**
117 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal 118 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal
118 values). 119 values).
119 */ 120 */
120 void setTimeZoneId( const QString & ); 121 void setTimeZoneId( const QString & );
121 /** 122 /**
122 Return time zone id. 123 Return time zone id.
123 */ 124 */
124 QString timeZoneId() const; 125 QString timeZoneId() const;
125 /** 126 /**
126 Use local time, not UTC or a time zone. 127 Use local time, not UTC or a time zone.
127 */ 128 */
128 void setLocalTime(); 129 void setLocalTime();
129 /** 130 /**
130 Return whether local time is being used. 131 Return whether local time is being used.
131 */ 132 */
132 bool isLocalTime() const; 133 bool isLocalTime() const;
133 134
134 /** 135 /**
135 Add an incidence to calendar. 136 Add an incidence to calendar.
136 137
137 @return true on success, false on error. 138 @return true on success, false on error.
138 */ 139 */
139 virtual bool addIncidence( Incidence * ); 140 virtual bool addIncidence( Incidence * );
140 /** 141 /**
141 Return filtered list of all incidences of this calendar. 142 Return filtered list of all incidences of this calendar.
142 */ 143 */
143 virtual QPtrList<Incidence> incidences(); 144 virtual QPtrList<Incidence> incidences();
144 145
145 /** 146 /**
146 Return unfiltered list of all incidences of this calendar. 147 Return unfiltered list of all incidences of this calendar.
147 */ 148 */
148 virtual QPtrList<Incidence> rawIncidences(); 149 virtual QPtrList<Incidence> rawIncidences();
149 150
150 /** 151 /**
151 Adds a Event to this calendar object. 152 Adds a Event to this calendar object.
152 @param anEvent a pointer to the event to add 153 @param anEvent a pointer to the event to add
153 154
154 @return true on success, false on error. 155 @return true on success, false on error.
155 */ 156 */
156 virtual bool addEventNoDup( Event *event ) = 0; 157 virtual bool addEventNoDup( Event *event ) = 0;
157 virtual bool addAnniversaryNoDup( Event *event ) = 0; 158 virtual bool addAnniversaryNoDup( Event *event ) = 0;
158 virtual bool addEvent( Event *anEvent ) = 0; 159 virtual bool addEvent( Event *anEvent ) = 0;
159 /** 160 /**
160 Delete event from calendar. 161 Delete event from calendar.
161 */ 162 */
162 virtual void deleteEvent( Event * ) = 0; 163 virtual void deleteEvent( Event * ) = 0;
163 /** 164 /**
164 Retrieves an event on the basis of the unique string ID. 165 Retrieves an event on the basis of the unique string ID.
165 */ 166 */
166 virtual Event *event( const QString &UniqueStr ) = 0; 167 virtual Event *event( const QString &UniqueStr ) = 0;
167 virtual Event *event( QString, QString ) = 0; 168 virtual Event *event( QString, QString ) = 0;
168 /** 169 /**
169 Builds and then returns a list of all events that match for the 170 Builds and then returns a list of all events that match for the
170 date specified. useful for dayView, etc. etc. 171 date specified. useful for dayView, etc. etc.
171 The calendar filter is applied. 172 The calendar filter is applied.
172 */ 173 */
173 QPtrList<Event> events( const QDate &date, bool sorted = false); 174 QPtrList<Event> events( const QDate &date, bool sorted = false);
174 /** 175 /**
175 Get events, which occur on the given date. 176 Get events, which occur on the given date.
176 The calendar filter is applied. 177 The calendar filter is applied.
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 21b4aaf..3f46d53 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -128,193 +128,214 @@ bool CalendarLocal::addAnniversaryNoDup( Event *event )
128 128
129} 129}
130bool CalendarLocal::addEventNoDup( Event *event ) 130bool CalendarLocal::addEventNoDup( Event *event )
131{ 131{
132 Event * eve; 132 Event * eve;
133 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 133 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
134 if ( *eve == *event ) { 134 if ( *eve == *event ) {
135 //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); 135 //qDebug("CalendarLocal::Duplicate event found! Not inserted! ");
136 return false; 136 return false;
137 } 137 }
138 } 138 }
139 return addEvent( event ); 139 return addEvent( event );
140} 140}
141 141
142bool CalendarLocal::addEvent( Event *event ) 142bool CalendarLocal::addEvent( Event *event )
143{ 143{
144 insertEvent( event ); 144 insertEvent( event );
145 145
146 event->registerObserver( this ); 146 event->registerObserver( this );
147 147
148 setModified( true ); 148 setModified( true );
149 149
150 return true; 150 return true;
151} 151}
152 152
153void CalendarLocal::deleteEvent( Event *event ) 153void CalendarLocal::deleteEvent( Event *event )
154{ 154{
155 155
156 156
157 if ( mEventList.removeRef( event ) ) { 157 if ( mEventList.removeRef( event ) ) {
158 setModified( true ); 158 setModified( true );
159 } 159 }
160} 160}
161 161
162 162
163Event *CalendarLocal::event( const QString &uid ) 163Event *CalendarLocal::event( const QString &uid )
164{ 164{
165 165
166 Event *event; 166 Event *event;
167 167
168 for ( event = mEventList.first(); event; event = mEventList.next() ) { 168 for ( event = mEventList.first(); event; event = mEventList.next() ) {
169 if ( event->uid() == uid ) { 169 if ( event->uid() == uid ) {
170 return event; 170 return event;
171 } 171 }
172 } 172 }
173 173
174 return 0; 174 return 0;
175} 175}
176bool CalendarLocal::addTodoNoDup( Todo *todo ) 176bool CalendarLocal::addTodoNoDup( Todo *todo )
177{ 177{
178 Todo * eve; 178 Todo * eve;
179 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { 179 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) {
180 if ( *eve == *todo ) { 180 if ( *eve == *todo ) {
181 //qDebug("duplicate todo found! not inserted! "); 181 //qDebug("duplicate todo found! not inserted! ");
182 return false; 182 return false;
183 } 183 }
184 } 184 }
185 return addTodo( todo ); 185 return addTodo( todo );
186} 186}
187bool CalendarLocal::addTodo( Todo *todo ) 187bool CalendarLocal::addTodo( Todo *todo )
188{ 188{
189 mTodoList.append( todo ); 189 mTodoList.append( todo );
190 190
191 todo->registerObserver( this ); 191 todo->registerObserver( this );
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
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( QString syncProf, QString id ) 215Todo *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 224void 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}
225QPtrList<Event> CalendarLocal::getExternLastSyncEvents() 246QPtrList<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}
238Event *CalendarLocal::event( QString syncProf, QString id ) 259Event *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}
247Todo *CalendarLocal::todo( const QString &uid ) 268Todo *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}
256QString CalendarLocal::nextSummary() const 277QString CalendarLocal::nextSummary() const
257{ 278{
258 return mNextSummary; 279 return mNextSummary;
259} 280}
260QDateTime CalendarLocal::nextAlarmEventDateTime() const 281QDateTime CalendarLocal::nextAlarmEventDateTime() const
261{ 282{
262 return mNextAlarmEventDateTime; 283 return mNextAlarmEventDateTime;
263} 284}
264void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) 285void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted)
265{ 286{
266 //mNextAlarmIncidence 287 //mNextAlarmIncidence
267 //mNextAlarmDateTime 288 //mNextAlarmDateTime
268 //return mNextSummary; 289 //return mNextSummary;
269 //return mNextAlarmEventDateTime; 290 //return mNextAlarmEventDateTime;
270 bool newNextAlarm = false; 291 bool newNextAlarm = false;
271 bool computeNextAlarm = false; 292 bool computeNextAlarm = false;
272 bool ok; 293 bool ok;
273 int offset; 294 int offset;
274 QDateTime nextA; 295 QDateTime nextA;
275 // QString nextSum; 296 // QString nextSum;
276 //QDateTime nextEvent; 297 //QDateTime nextEvent;
277 if ( mNextAlarmIncidence == 0 || incidence == 0 ) { 298 if ( mNextAlarmIncidence == 0 || incidence == 0 ) {
278 computeNextAlarm = true; 299 computeNextAlarm = true;
279 } else { 300 } else {
280 if ( ! deleted ) { 301 if ( ! deleted ) {
281 nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; 302 nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ;
282 if ( ok ) { 303 if ( ok ) {
283 if ( nextA < mNextAlarmDateTime ) { 304 if ( nextA < mNextAlarmDateTime ) {
284 deRegisterAlarm(); 305 deRegisterAlarm();
285 mNextAlarmDateTime = nextA; 306 mNextAlarmDateTime = nextA;
286 mNextSummary = incidence->summary(); 307 mNextSummary = incidence->summary();
287 mNextAlarmEventDateTime = nextA.addSecs(offset ) ; 308 mNextAlarmEventDateTime = nextA.addSecs(offset ) ;
288 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 309 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
289 newNextAlarm = true; 310 newNextAlarm = true;
290 mNextAlarmIncidence = incidence; 311 mNextAlarmIncidence = incidence;
291 } else { 312 } else {
292 if ( incidence == mNextAlarmIncidence ) { 313 if ( incidence == mNextAlarmIncidence ) {
293 computeNextAlarm = true; 314 computeNextAlarm = true;
294 } 315 }
295 } 316 }
296 } else { 317 } else {
297 if ( mNextAlarmIncidence == incidence ) { 318 if ( mNextAlarmIncidence == incidence ) {
298 computeNextAlarm = true; 319 computeNextAlarm = true;
299 } 320 }
300 } 321 }
301 } else { // deleted 322 } else { // deleted
302 if ( incidence == mNextAlarmIncidence ) { 323 if ( incidence == mNextAlarmIncidence ) {
303 computeNextAlarm = true; 324 computeNextAlarm = true;
304 } 325 }
305 } 326 }
306 } 327 }
307 if ( computeNextAlarm ) { 328 if ( computeNextAlarm ) {
308 deRegisterAlarm(); 329 deRegisterAlarm();
309 nextA = nextAlarm( 1000 ); 330 nextA = nextAlarm( 1000 );
310 if (! mNextAlarmIncidence ) { 331 if (! mNextAlarmIncidence ) {
311 return; 332 return;
312 } 333 }
313 newNextAlarm = true; 334 newNextAlarm = true;
314 } 335 }
315 if ( newNextAlarm ) 336 if ( newNextAlarm )
316 registerAlarm(); 337 registerAlarm();
317} 338}
318QString CalendarLocal:: getAlarmNotification() 339QString CalendarLocal:: getAlarmNotification()
319{ 340{
320 QString ret; 341 QString ret;
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index 5b6c64c..98ec710 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -1,167 +1,168 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> 5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
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
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
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 /**
104 Return list of all todos. 105 Return list of all todos.
105 */ 106 */
106 QPtrList<Todo> rawTodos(); 107 QPtrList<Todo> rawTodos();
107 /** 108 /**
108 Returns list of todos due on the specified date. 109 Returns list of todos due on the specified date.
109 */ 110 */
110 QPtrList<Todo> todos( const QDate &date ); 111 QPtrList<Todo> todos( const QDate &date );
111 /** 112 /**
112 Return list of all todos. 113 Return list of all todos.
113 114
114 Workaround because compiler does not recognize function of base class. 115 Workaround because compiler does not recognize function of base class.
115 */ 116 */
116 QPtrList<Todo> todos() { return Calendar::todos(); } 117 QPtrList<Todo> todos() { return Calendar::todos(); }
117 118
118 /** 119 /**
119 Add a Journal entry to calendar. 120 Add a Journal entry to calendar.
120 */ 121 */
121 bool addJournal( Journal * ); 122 bool addJournal( Journal * );
122 /** 123 /**
123 Remove a Journal from the calendar. 124 Remove a Journal from the calendar.
124 */ 125 */
125 void deleteJournal( Journal * ); 126 void deleteJournal( Journal * );
126 /** 127 /**
127 Return Journal for given date. 128 Return Journal for given date.
128 */ 129 */
129 Journal *journal( const QDate & ); 130 Journal *journal( const QDate & );
130 /** 131 /**
131 Return Journal with given UID. 132 Return Journal with given UID.
132 */ 133 */
133 Journal *journal( const QString &uid ); 134 Journal *journal( const QString &uid );
134 /** 135 /**
135 Return list of all Journals stored in calendar. 136 Return list of all Journals stored in calendar.
136 */ 137 */
137 QPtrList<Journal> journals(); 138 QPtrList<Journal> journals();
138 139
139 /** 140 /**
140 Return all alarms, which ocur in the given time interval. 141 Return all alarms, which ocur in the given time interval.
141 */ 142 */
142 Alarm::List alarms( const QDateTime &from, const QDateTime &to ); 143 Alarm::List alarms( const QDateTime &from, const QDateTime &to );
143 144
144 /** 145 /**
145 Return all alarms, which ocur before given date. 146 Return all alarms, which ocur before given date.
146 */ 147 */
147 Alarm::List alarmsTo( const QDateTime &to ); 148 Alarm::List alarmsTo( const QDateTime &to );
148 149
149 QDateTime nextAlarm( int daysTo ) ; 150 QDateTime nextAlarm( int daysTo ) ;
150 QDateTime nextAlarmEventDateTime() const; 151 QDateTime nextAlarmEventDateTime() const;
151 void checkAlarmForIncidence( Incidence *, bool deleted ) ; 152 void checkAlarmForIncidence( Incidence *, bool deleted ) ;
152 void registerAlarm(); 153 void registerAlarm();
153 void deRegisterAlarm(); 154 void deRegisterAlarm();
154 QString getAlarmNotification(); 155 QString getAlarmNotification();
155 QString nextSummary() const ; 156 QString nextSummary() const ;
156 /** 157 /**
157 This method should be called whenever a Event is modified directly 158 This method should be called whenever a Event is modified directly
158 via it's pointer. It makes sure that the calendar is internally 159 via it's pointer. It makes sure that the calendar is internally
159 consistent. 160 consistent.
160 */ 161 */
161 void update( IncidenceBase *incidence ); 162 void update( IncidenceBase *incidence );
162 163
163 /** 164 /**
164 Builds and then returns a list of all events that match for the 165 Builds and then returns a list of all events that match for the
165 date specified. useful for dayView, etc. etc. 166 date specified. useful for dayView, etc. etc.
166 */ 167 */
167 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); 168 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false );
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index b36dc1a..9aa517c 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -260,148 +260,151 @@ Attendee *IncidenceBase::getAttendee(const char *n) const
260 if (qli.current()->getName() == n) 260 if (qli.current()->getName() == n)
261 return qli.current(); 261 return qli.current();
262 ++qli; 262 ++qli;
263 } 263 }
264 return 0L; 264 return 0L;
265} 265}
266#endif 266#endif
267 267
268Attendee *IncidenceBase::attendeeByMail(const QString &email) 268Attendee *IncidenceBase::attendeeByMail(const QString &email)
269{ 269{
270 QPtrListIterator<Attendee> qli(mAttendees); 270 QPtrListIterator<Attendee> qli(mAttendees);
271 271
272 qli.toFirst(); 272 qli.toFirst();
273 while (qli) { 273 while (qli) {
274 if (qli.current()->email().lower() == email.lower()) 274 if (qli.current()->email().lower() == email.lower())
275 return qli.current(); 275 return qli.current();
276 ++qli; 276 ++qli;
277 } 277 }
278 return 0L; 278 return 0L;
279} 279}
280 280
281Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) 281Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email)
282{ 282{
283 QPtrListIterator<Attendee> qli(mAttendees); 283 QPtrListIterator<Attendee> qli(mAttendees);
284 284
285 QStringList mails = emails; 285 QStringList mails = emails;
286 if (!email.isEmpty()) { 286 if (!email.isEmpty()) {
287 mails.append(email); 287 mails.append(email);
288 } 288 }
289 qli.toFirst(); 289 qli.toFirst();
290 while (qli) { 290 while (qli) {
291 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { 291 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) {
292 if (qli.current()->email().lower() == (*it).lower()) 292 if (qli.current()->email().lower() == (*it).lower())
293 return qli.current(); 293 return qli.current();
294 } 294 }
295 295
296 ++qli; 296 ++qli;
297 } 297 }
298 return 0L; 298 return 0L;
299} 299}
300 300
301void IncidenceBase::setDuration(int seconds) 301void IncidenceBase::setDuration(int seconds)
302{ 302{
303 mDuration = seconds; 303 mDuration = seconds;
304 setHasDuration(true); 304 setHasDuration(true);
305} 305}
306 306
307int IncidenceBase::duration() const 307int IncidenceBase::duration() const
308{ 308{
309 return mDuration; 309 return mDuration;
310} 310}
311 311
312void IncidenceBase::setHasDuration(bool b) 312void IncidenceBase::setHasDuration(bool b)
313{ 313{
314 mHasDuration = b; 314 mHasDuration = b;
315} 315}
316 316
317bool IncidenceBase::hasDuration() const 317bool IncidenceBase::hasDuration() const
318{ 318{
319 return mHasDuration; 319 return mHasDuration;
320} 320}
321 321
322void IncidenceBase::setSyncStatus(int stat) 322void IncidenceBase::setSyncStatus(int stat)
323{ 323{
324 if (mReadOnly) return; 324 if (mReadOnly) return;
325 mSyncStatus = stat; 325 mSyncStatus = stat;
326} 326}
327 327
328int IncidenceBase::syncStatus() const 328int IncidenceBase::syncStatus() const
329{ 329{
330 return mSyncStatus; 330 return mSyncStatus;
331} 331}
332 332
333void IncidenceBase::setPilotId( int id ) 333void IncidenceBase::setPilotId( int id )
334{ 334{
335 if (mReadOnly) return; 335 if (mReadOnly) return;
336 mPilotId = id; 336 mPilotId = id;
337} 337}
338 338
339int IncidenceBase::pilotId() const 339int IncidenceBase::pilotId() const
340{ 340{
341 return mPilotId; 341 return mPilotId;
342} 342}
343 343
344int IncidenceBase::tempSyncStat() const 344int IncidenceBase::tempSyncStat() const
345{ 345{
346 return mTempSyncStat; 346 return mTempSyncStat;
347} 347}
348void IncidenceBase::setTempSyncStat( int id ) 348void IncidenceBase::setTempSyncStat( int id )
349{ 349{
350 if (mReadOnly) return; 350 if (mReadOnly) return;
351 mTempSyncStat = id; 351 mTempSyncStat = id;
352} 352}
353 353
354void IncidenceBase::removeID(const QString &prof) 354void 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}
359void IncidenceBase::setID( const QString & prof , const QString & id ) 362void 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}
363QString IncidenceBase::getID( const QString & prof) 366QString 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
370void IncidenceBase::setCsum( const QString & prof , const QString & id ) 373void 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}
374QString IncidenceBase::getCsum( const QString & prof) 377QString IncidenceBase::getCsum( const QString & prof)
375{ 378{
376 return KIdManager::getCsum ( mExternalId, prof ); 379 return KIdManager::getCsum ( mExternalId, prof );
377} 380}
378 381
379void IncidenceBase::setIDStr( const QString & s ) 382void 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
385QString IncidenceBase::IDStr() const 388QString IncidenceBase::IDStr() const
386{ 389{
387 return mExternalId ; 390 return mExternalId ;
388} 391}
389void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) 392void IncidenceBase::registerObserver( IncidenceBase::Observer *observer )
390{ 393{
391 if( !mObservers.contains(observer) ) mObservers.append( observer ); 394 if( !mObservers.contains(observer) ) mObservers.append( observer );
392} 395}
393 396
394void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) 397void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer )
395{ 398{
396 mObservers.remove( observer ); 399 mObservers.remove( observer );
397} 400}
398 401
399void IncidenceBase::updated() 402void IncidenceBase::updated()
400{ 403{
401 QPtrListIterator<Observer> it(mObservers); 404 QPtrListIterator<Observer> it(mObservers);
402 while( it.current() ) { 405 while( it.current() ) {
403 Observer *o = it.current(); 406 Observer *o = it.current();
404 ++it; 407 ++it;
405 o->incidenceUpdated( this ); 408 o->incidenceUpdated( this );
406 } 409 }
407} 410}