summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2004-10-17 18:08:43 (UTC)
committer zautrix <zautrix>2004-10-17 18:08:43 (UTC)
commit6f6d1d58938539215bb4fcb5b97cf9fb089a11ef (patch) (unidiff)
tree9937fe24c3fa3f29421b39a58b393e893a11636a /libkcal
parentd92f58ffa1937af8a4240b9d235da15f5f352769 (diff)
downloadkdepimpi-6f6d1d58938539215bb4fcb5b97cf9fb089a11ef.zip
kdepimpi-6f6d1d58938539215bb4fcb5b97cf9fb089a11ef.tar.gz
kdepimpi-6f6d1d58938539215bb4fcb5b97cf9fb089a11ef.tar.bz2
more KDE sync fixes
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp8
-rw-r--r--libkcal/calendar.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index eeb5f48..52daaaa 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -156,206 +156,206 @@ QString Calendar::getTimeZoneStr() const
156 return ""; 156 return "";
157 QString tmpStr; 157 QString tmpStr;
158 int hours = abs(mTimeZone / 60); 158 int hours = abs(mTimeZone / 60);
159 int minutes = abs(mTimeZone % 60); 159 int minutes = abs(mTimeZone % 60);
160 bool neg = mTimeZone < 0; 160 bool neg = mTimeZone < 0;
161 161
162 tmpStr.sprintf("%c%.2d%.2d", 162 tmpStr.sprintf("%c%.2d%.2d",
163 (neg ? '-' : '+'), 163 (neg ? '-' : '+'),
164 hours, minutes); 164 hours, minutes);
165 return tmpStr; 165 return tmpStr;
166} 166}
167 167
168void Calendar::setTimeZone(int tz) 168void Calendar::setTimeZone(int tz)
169{ 169{
170 mTimeZone = tz; 170 mTimeZone = tz;
171 mLocalTime = false; 171 mLocalTime = false;
172 172
173 setModified( true ); 173 setModified( true );
174} 174}
175 175
176int Calendar::getTimeZone() const 176int Calendar::getTimeZone() const
177{ 177{
178 return mTimeZone; 178 return mTimeZone;
179} 179}
180 180
181void Calendar::setTimeZoneId(const QString &id) 181void Calendar::setTimeZoneId(const QString &id)
182{ 182{
183 mTimeZoneId = id; 183 mTimeZoneId = id;
184 mLocalTime = false; 184 mLocalTime = false;
185 mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); 185 mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId);
186 if ( mTimeZone > 1000) 186 if ( mTimeZone > 1000)
187 setLocalTime(); 187 setLocalTime();
188 //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); 188 //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone);
189 setModified( true ); 189 setModified( true );
190} 190}
191 191
192QString Calendar::timeZoneId() const 192QString Calendar::timeZoneId() const
193{ 193{
194 return mTimeZoneId; 194 return mTimeZoneId;
195} 195}
196 196
197void Calendar::setLocalTime() 197void Calendar::setLocalTime()
198{ 198{
199 //qDebug("Calendar::setLocalTime() "); 199 //qDebug("Calendar::setLocalTime() ");
200 mLocalTime = true; 200 mLocalTime = true;
201 mTimeZone = 0; 201 mTimeZone = 0;
202 mTimeZoneId = ""; 202 mTimeZoneId = "";
203 203
204 setModified( true ); 204 setModified( true );
205} 205}
206 206
207bool Calendar::isLocalTime() const 207bool Calendar::isLocalTime() const
208{ 208{
209 return mLocalTime; 209 return mLocalTime;
210} 210}
211 211
212const QString &Calendar::getEmail() 212const QString &Calendar::getEmail()
213{ 213{
214 return mOwnerEmail; 214 return mOwnerEmail;
215} 215}
216 216
217void Calendar::setEmail(const QString &e) 217void Calendar::setEmail(const QString &e)
218{ 218{
219 mOwnerEmail = e; 219 mOwnerEmail = e;
220 220
221 setModified( true ); 221 setModified( true );
222} 222}
223 223
224void Calendar::setFilter(CalFilter *filter) 224void Calendar::setFilter(CalFilter *filter)
225{ 225{
226 mFilter = filter; 226 mFilter = filter;
227} 227}
228 228
229CalFilter *Calendar::filter() 229CalFilter *Calendar::filter()
230{ 230{
231 return mFilter; 231 return mFilter;
232} 232}
233 233
234QPtrList<Incidence> Calendar::incidences() 234QPtrList<Incidence> Calendar::incidences()
235{ 235{
236 QPtrList<Incidence> incidences; 236 QPtrList<Incidence> incidences;
237 237
238 Incidence *i; 238 Incidence *i;
239 239
240 QPtrList<Event> e = events(); 240 QPtrList<Event> e = events();
241 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 241 for( i = e.first(); i; i = e.next() ) incidences.append( i );
242 242
243 QPtrList<Todo> t = todos(); 243 QPtrList<Todo> t = todos();
244 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 244 for( i = t.first(); i; i = t.next() ) incidences.append( i );
245 245
246 QPtrList<Journal> j = journals(); 246 QPtrList<Journal> j = journals();
247 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 247 for( i = j.first(); i; i = j.next() ) incidences.append( i );
248 248
249 return incidences; 249 return incidences;
250} 250}
251 251
252void Calendar::resetPilotStat() 252void Calendar::resetPilotStat(int id )
253{ 253{
254 QPtrList<Incidence> incidences; 254 QPtrList<Incidence> incidences;
255 255
256 Incidence *i; 256 Incidence *i;
257 257
258 QPtrList<Event> e = rawEvents(); 258 QPtrList<Event> e = rawEvents();
259 for( i = e.first(); i; i = e.next() ) i->setPilotId( 0 ); 259 for( i = e.first(); i; i = e.next() ) i->setPilotId( id );
260 260
261 QPtrList<Todo> t = rawTodos(); 261 QPtrList<Todo> t = rawTodos();
262 for( i = t.first(); i; i = t.next() ) i->setPilotId( 0 ); 262 for( i = t.first(); i; i = t.next() ) i->setPilotId( id );
263 263
264 QPtrList<Journal> j = journals(); 264 QPtrList<Journal> j = journals();
265 for( i = j.first(); i; i = j.next() ) i->setPilotId( 0 ); 265 for( i = j.first(); i; i = j.next() ) i->setPilotId( id );
266} 266}
267void Calendar::resetTempSyncStat() 267void Calendar::resetTempSyncStat()
268{ 268{
269 QPtrList<Incidence> incidences; 269 QPtrList<Incidence> incidences;
270 270
271 Incidence *i; 271 Incidence *i;
272 272
273 QPtrList<Event> e = rawEvents(); 273 QPtrList<Event> e = rawEvents();
274 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 274 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
275 275
276 QPtrList<Todo> t = rawTodos(); 276 QPtrList<Todo> t = rawTodos();
277 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 277 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
278 278
279 QPtrList<Journal> j = journals(); 279 QPtrList<Journal> j = journals();
280 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 280 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
281} 281}
282QPtrList<Incidence> Calendar::rawIncidences() 282QPtrList<Incidence> Calendar::rawIncidences()
283{ 283{
284 QPtrList<Incidence> incidences; 284 QPtrList<Incidence> incidences;
285 285
286 Incidence *i; 286 Incidence *i;
287 287
288 QPtrList<Event> e = rawEvents(); 288 QPtrList<Event> e = rawEvents();
289 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 289 for( i = e.first(); i; i = e.next() ) incidences.append( i );
290 290
291 QPtrList<Todo> t = rawTodos(); 291 QPtrList<Todo> t = rawTodos();
292 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 292 for( i = t.first(); i; i = t.next() ) incidences.append( i );
293 293
294 QPtrList<Journal> j = journals(); 294 QPtrList<Journal> j = journals();
295 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 295 for( i = j.first(); i; i = j.next() ) incidences.append( i );
296 296
297 return incidences; 297 return incidences;
298} 298}
299 299
300QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) 300QPtrList<Event> Calendar::events( const QDate &date, bool sorted )
301{ 301{
302 QPtrList<Event> el = rawEventsForDate(date,sorted); 302 QPtrList<Event> el = rawEventsForDate(date,sorted);
303 mFilter->apply(&el); 303 mFilter->apply(&el);
304 return el; 304 return el;
305} 305}
306 306
307QPtrList<Event> Calendar::events( const QDateTime &qdt ) 307QPtrList<Event> Calendar::events( const QDateTime &qdt )
308{ 308{
309 QPtrList<Event> el = rawEventsForDate(qdt); 309 QPtrList<Event> el = rawEventsForDate(qdt);
310 mFilter->apply(&el); 310 mFilter->apply(&el);
311 return el; 311 return el;
312} 312}
313 313
314QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, 314QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
315 bool inclusive) 315 bool inclusive)
316{ 316{
317 QPtrList<Event> el = rawEvents(start,end,inclusive); 317 QPtrList<Event> el = rawEvents(start,end,inclusive);
318 mFilter->apply(&el); 318 mFilter->apply(&el);
319 return el; 319 return el;
320} 320}
321 321
322QPtrList<Event> Calendar::events() 322QPtrList<Event> Calendar::events()
323{ 323{
324 QPtrList<Event> el = rawEvents(); 324 QPtrList<Event> el = rawEvents();
325 mFilter->apply(&el); 325 mFilter->apply(&el);
326 return el; 326 return el;
327} 327}
328 328
329 329
330bool Calendar::addIncidence(Incidence *i) 330bool Calendar::addIncidence(Incidence *i)
331{ 331{
332 Incidence::AddVisitor<Calendar> v(this); 332 Incidence::AddVisitor<Calendar> v(this);
333 333
334 return i->accept(v); 334 return i->accept(v);
335} 335}
336void Calendar::deleteIncidence(Incidence *in) 336void Calendar::deleteIncidence(Incidence *in)
337{ 337{
338 if ( in->type() == "Event" ) 338 if ( in->type() == "Event" )
339 deleteEvent( (Event*) in ); 339 deleteEvent( (Event*) in );
340 else if ( in->type() =="Todo" ) 340 else if ( in->type() =="Todo" )
341 deleteTodo( (Todo*) in); 341 deleteTodo( (Todo*) in);
342 else if ( in->type() =="Journal" ) 342 else if ( in->type() =="Journal" )
343 deleteJournal( (Journal*) in ); 343 deleteJournal( (Journal*) in );
344} 344}
345 345
346Incidence* Calendar::incidence( const QString& uid ) 346Incidence* Calendar::incidence( const QString& uid )
347{ 347{
348 Incidence* i; 348 Incidence* i;
349 349
350 if( (i = todo( uid )) != 0 ) 350 if( (i = todo( uid )) != 0 )
351 return i; 351 return i;
352 if( (i = event( uid )) != 0 ) 352 if( (i = event( uid )) != 0 )
353 return i; 353 return i;
354 if( (i = journal( uid )) != 0 ) 354 if( (i = journal( uid )) != 0 )
355 return i; 355 return i;
356 356
357 return 0; 357 return 0;
358} 358}
359 359
360QPtrList<Todo> Calendar::todos() 360QPtrList<Todo> Calendar::todos()
361{ 361{
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index d5294eb..b801186 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -1,166 +1,166 @@
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(); 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 bool isSaving() { return false; } 81 virtual bool isSaving() { return false; }
82 82
83 /** 83 /**
84 Return the owner of the calendar's full name. 84 Return the owner of the calendar's full name.
85 */ 85 */
86 const QString &getOwner() const; 86 const QString &getOwner() const;
87 /** 87 /**
88 Set the owner of the calendar. Should be owner's full name. 88 Set the owner of the calendar. Should be owner's full name.
89 */ 89 */
90 void setOwner( const QString &os ); 90 void setOwner( const QString &os );
91 /** 91 /**
92 Return the email address of the calendar owner. 92 Return the email address of the calendar owner.
93 */ 93 */
94 const QString &getEmail(); 94 const QString &getEmail();
95 /** 95 /**
96 Set the email address of the calendar owner. 96 Set the email address of the calendar owner.
97 */ 97 */
98 void setEmail( const QString & ); 98 void setEmail( const QString & );
99 99
100 /** 100 /**
101 Set time zone from a timezone string (e.g. -2:00) 101 Set time zone from a timezone string (e.g. -2:00)
102 */ 102 */
103 void setTimeZone( const QString &tz ); 103 void setTimeZone( const QString &tz );
104 /** 104 /**
105 Set time zone from a minutes value (e.g. -60) 105 Set time zone from a minutes value (e.g. -60)
106 */ 106 */
107 void setTimeZone( int tz ); 107 void setTimeZone( int tz );
108 /** 108 /**
109 Return time zone as offest in minutes. 109 Return time zone as offest in minutes.
110 */ 110 */
111 int getTimeZone() const; 111 int getTimeZone() const;
112 /** 112 /**
113 Compute an ISO 8601 format string from the time zone. 113 Compute an ISO 8601 format string from the time zone.
114 */ 114 */
115 QString getTimeZoneStr() const; 115 QString getTimeZoneStr() const;
116 /** 116 /**
117 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal 117 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal
118 values). 118 values).
119 */ 119 */
120 void setTimeZoneId( const QString & ); 120 void setTimeZoneId( const QString & );
121 /** 121 /**
122 Return time zone id. 122 Return time zone id.
123 */ 123 */
124 QString timeZoneId() const; 124 QString timeZoneId() const;
125 /** 125 /**
126 Use local time, not UTC or a time zone. 126 Use local time, not UTC or a time zone.
127 */ 127 */
128 void setLocalTime(); 128 void setLocalTime();
129 /** 129 /**
130 Return whether local time is being used. 130 Return whether local time is being used.
131 */ 131 */
132 bool isLocalTime() const; 132 bool isLocalTime() const;
133 133
134 /** 134 /**
135 Add an incidence to calendar. 135 Add an incidence to calendar.
136 136
137 @return true on success, false on error. 137 @return true on success, false on error.
138 */ 138 */
139 virtual bool addIncidence( Incidence * ); 139 virtual bool addIncidence( Incidence * );
140 /** 140 /**
141 Return filtered list of all incidences of this calendar. 141 Return filtered list of all incidences of this calendar.
142 */ 142 */
143 virtual QPtrList<Incidence> incidences(); 143 virtual QPtrList<Incidence> incidences();
144 144
145 /** 145 /**
146 Return unfiltered list of all incidences of this calendar. 146 Return unfiltered list of all incidences of this calendar.
147 */ 147 */
148 virtual QPtrList<Incidence> rawIncidences(); 148 virtual QPtrList<Incidence> rawIncidences();
149 149
150 /** 150 /**
151 Adds a Event to this calendar object. 151 Adds a Event to this calendar object.
152 @param anEvent a pointer to the event to add 152 @param anEvent a pointer to the event to add
153 153
154 @return true on success, false on error. 154 @return true on success, false on error.
155 */ 155 */
156 virtual bool addEventNoDup( Event *event ) = 0; 156 virtual bool addEventNoDup( Event *event ) = 0;
157 virtual bool addAnniversaryNoDup( Event *event ) = 0; 157 virtual bool addAnniversaryNoDup( Event *event ) = 0;
158 virtual bool addEvent( Event *anEvent ) = 0; 158 virtual bool addEvent( Event *anEvent ) = 0;
159 /** 159 /**
160 Delete event from calendar. 160 Delete event from calendar.
161 */ 161 */
162 virtual void deleteEvent( Event * ) = 0; 162 virtual void deleteEvent( Event * ) = 0;
163 /** 163 /**
164 Retrieves an event on the basis of the unique string ID. 164 Retrieves an event on the basis of the unique string ID.
165 */ 165 */
166 virtual Event *event( const QString &UniqueStr ) = 0; 166 virtual Event *event( const QString &UniqueStr ) = 0;