summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-08-19 12:08:05 (UTC)
committer zautrix <zautrix>2005-08-19 12:08:05 (UTC)
commit9014049779be6cfec02d73e19596439f0f4f9bed (patch) (unidiff)
tree3983282e83183cc15dd615ba4ac5a800da21efe0 /libkcal
parent81891a49afc2f7cd89db4e2770c3b7831644428d (diff)
downloadkdepimpi-9014049779be6cfec02d73e19596439f0f4f9bed.zip
kdepimpi-9014049779be6cfec02d73e19596439f0f4f9bed.tar.gz
kdepimpi-9014049779be6cfec02d73e19596439f0f4f9bed.tar.bz2
list sort fix
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp13
-rw-r--r--libkcal/incidence.h2
-rw-r--r--libkcal/incidencebase.cpp13
-rw-r--r--libkcal/incidencebase.h2
4 files changed, 29 insertions, 1 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 39c14f5..fe9f854 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -1,741 +1,754 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27#include "incidence.h" 27#include "incidence.h"
28#include "todo.h" 28#include "todo.h"
29 29
30using namespace KCal; 30using namespace KCal;
31 31
32Incidence::Incidence() : 32Incidence::Incidence() :
33 IncidenceBase(), 33 IncidenceBase(),
34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) 34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3)
35{ 35{
36 mRecurrence = 0;//new Recurrence(this); 36 mRecurrence = 0;//new Recurrence(this);
37 mCancelled = false; 37 mCancelled = false;
38 recreate(); 38 recreate();
39 mHasStartDate = true; 39 mHasStartDate = true;
40 mAlarms.setAutoDelete(true); 40 mAlarms.setAutoDelete(true);
41 mAttachments.setAutoDelete(true); 41 mAttachments.setAutoDelete(true);
42 mHasRecurrenceID = false; 42 mHasRecurrenceID = false;
43 mHoliday = false; 43 mHoliday = false;
44 mBirthday = false; 44 mBirthday = false;
45 mAnniversary = false; 45 mAnniversary = false;
46 46
47} 47}
48 48
49Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) 49Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
50{ 50{
51// TODO: reenable attributes currently commented out. 51// TODO: reenable attributes currently commented out.
52 mRevision = i.mRevision; 52 mRevision = i.mRevision;
53 mCreated = i.mCreated; 53 mCreated = i.mCreated;
54 mDescription = i.mDescription; 54 mDescription = i.mDescription;
55 mSummary = i.mSummary; 55 mSummary = i.mSummary;
56 mCategories = i.mCategories; 56 mCategories = i.mCategories;
57// Incidence *mRelatedTo; Incidence *mRelatedTo; 57// Incidence *mRelatedTo; Incidence *mRelatedTo;
58 mRelatedTo = 0; 58 mRelatedTo = 0;
59 mRelatedToUid = i.mRelatedToUid; 59 mRelatedToUid = i.mRelatedToUid;
60// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; 60// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations;
61 mExDates = i.mExDates; 61 mExDates = i.mExDates;
62 QPtrListIterator<Attachment> itat( i.mAttachments ); 62 QPtrListIterator<Attachment> itat( i.mAttachments );
63 Attachment *at; 63 Attachment *at;
64 while( (at = itat.current()) ) { 64 while( (at = itat.current()) ) {
65 Attachment *a = new Attachment( *at ); 65 Attachment *a = new Attachment( *at );
66 mAttachments.append( a ); 66 mAttachments.append( a );
67 ++itat; 67 ++itat;
68 } 68 }
69 mAttachments.setAutoDelete( true ); 69 mAttachments.setAutoDelete( true );
70 mResources = i.mResources; 70 mResources = i.mResources;
71 mSecrecy = i.mSecrecy; 71 mSecrecy = i.mSecrecy;
72 mPriority = i.mPriority; 72 mPriority = i.mPriority;
73 mLocation = i.mLocation; 73 mLocation = i.mLocation;
74 mCancelled = i.mCancelled; 74 mCancelled = i.mCancelled;
75 mHasStartDate = i.mHasStartDate; 75 mHasStartDate = i.mHasStartDate;
76 QPtrListIterator<Alarm> it( i.mAlarms ); 76 QPtrListIterator<Alarm> it( i.mAlarms );
77 const Alarm *a; 77 const Alarm *a;
78 while( (a = it.current()) ) { 78 while( (a = it.current()) ) {
79 Alarm *b = new Alarm( *a ); 79 Alarm *b = new Alarm( *a );
80 b->setParent( this ); 80 b->setParent( this );
81 mAlarms.append( b ); 81 mAlarms.append( b );
82 82
83 ++it; 83 ++it;
84 } 84 }
85 mAlarms.setAutoDelete(true); 85 mAlarms.setAutoDelete(true);
86 mHasRecurrenceID = i.mHasRecurrenceID; 86 mHasRecurrenceID = i.mHasRecurrenceID;
87 mRecurrenceID = i.mRecurrenceID; 87 mRecurrenceID = i.mRecurrenceID;
88 if ( i.mRecurrence ) 88 if ( i.mRecurrence )
89 mRecurrence = new Recurrence( *(i.mRecurrence), this ); 89 mRecurrence = new Recurrence( *(i.mRecurrence), this );
90 else 90 else
91 mRecurrence = 0; 91 mRecurrence = 0;
92 mHoliday = i.mHoliday ; 92 mHoliday = i.mHoliday ;
93 mBirthday = i.mBirthday; 93 mBirthday = i.mBirthday;
94 mAnniversary = i.mAnniversary; 94 mAnniversary = i.mAnniversary;
95} 95}
96 96
97Incidence::~Incidence() 97Incidence::~Incidence()
98{ 98{
99 99
100 Incidence *ev; 100 Incidence *ev;
101 QPtrList<Incidence> Relations = relations(); 101 QPtrList<Incidence> Relations = relations();
102 for (ev=Relations.first();ev;ev=Relations.next()) { 102 for (ev=Relations.first();ev;ev=Relations.next()) {
103 if (ev->relatedTo() == this) ev->setRelatedTo(0); 103 if (ev->relatedTo() == this) ev->setRelatedTo(0);
104 } 104 }
105 if (relatedTo()) relatedTo()->removeRelation(this); 105 if (relatedTo()) relatedTo()->removeRelation(this);
106 if ( mRecurrence ) 106 if ( mRecurrence )
107 delete mRecurrence; 107 delete mRecurrence;
108 108
109} 109}
110QString Incidence::durationText() 110QString Incidence::durationText()
111{ 111{
112 return "---"; 112 return "---";
113} 113}
114QString Incidence::durationText4Time( int offset ) 114QString Incidence::durationText4Time( int offset )
115{ 115{
116 int min = offset/60; 116 int min = offset/60;
117 int hours = min /60; 117 int hours = min /60;
118 min = min % 60; 118 min = min % 60;
119 int days = hours /24; 119 int days = hours /24;
120 hours = hours % 24; 120 hours = hours % 24;
121 121
122 if ( doesFloat() || ( min == 0 && hours == 0 ) ) { 122 if ( doesFloat() || ( min == 0 && hours == 0 ) ) {
123 if ( days == 1 ) 123 if ( days == 1 )
124 return "1" + i18n(" day"); 124 return "1" + i18n(" day");
125 else 125 else
126 return QString::number( days )+ i18n(" days"); 126 return QString::number( days )+ i18n(" days");
127 127
128 } 128 }
129 QString message = QString::number ( hours ) +":"; 129 QString message = QString::number ( hours ) +":";
130 if ( min < 10 ) message += "0"; 130 if ( min < 10 ) message += "0";
131 message += QString::number ( min ); 131 message += QString::number ( min );
132 if ( days > 0 ) { 132 if ( days > 0 ) {
133 if ( days == 1 ) 133 if ( days == 1 )
134 message = "1" + i18n(" day") + " "+message; 134 message = "1" + i18n(" day") + " "+message;
135 else 135 else
136 message = QString::number( days )+ i18n(" days") + " "+message; 136 message = QString::number( days )+ i18n(" days") + " "+message;
137 } 137 }
138 return message; 138 return message;
139} 139}
140bool Incidence::isHoliday() const 140bool Incidence::isHoliday() const
141{ 141{
142 return mHoliday; 142 return mHoliday;
143} 143}
144bool Incidence::isBirthday() const 144bool Incidence::isBirthday() const
145{ 145{
146 146
147 return mBirthday ; 147 return mBirthday ;
148} 148}
149bool Incidence::isAnniversary() const 149bool Incidence::isAnniversary() const
150{ 150{
151 return mAnniversary ; 151 return mAnniversary ;
152 152
153} 153}
154 154
155bool Incidence::hasRecurrenceID() const 155bool Incidence::hasRecurrenceID() const
156{ 156{
157 return mHasRecurrenceID; 157 return mHasRecurrenceID;
158} 158}
159 159
160void Incidence::setHasRecurrenceID( bool b ) 160void Incidence::setHasRecurrenceID( bool b )
161{ 161{
162 mHasRecurrenceID = b; 162 mHasRecurrenceID = b;
163} 163}
164 164
165void Incidence::setRecurrenceID(QDateTime d) 165void Incidence::setRecurrenceID(QDateTime d)
166{ 166{
167 mRecurrenceID = d; 167 mRecurrenceID = d;
168 mHasRecurrenceID = true; 168 mHasRecurrenceID = true;
169 updated(); 169 updated();
170} 170}
171QDateTime Incidence::recurrenceID () const 171QDateTime Incidence::recurrenceID () const
172{ 172{
173 return mRecurrenceID; 173 return mRecurrenceID;
174} 174}
175 175
176bool Incidence::cancelled() const 176bool Incidence::cancelled() const
177{ 177{
178 return mCancelled; 178 return mCancelled;
179} 179}
180void Incidence::setCancelled( bool b ) 180void Incidence::setCancelled( bool b )
181{ 181{
182 mCancelled = b; 182 mCancelled = b;
183 updated(); 183 updated();
184} 184}
185bool Incidence::hasStartDate() const 185bool Incidence::hasStartDate() const
186{ 186{
187 return mHasStartDate; 187 return mHasStartDate;
188} 188}
189 189
190void Incidence::setHasStartDate(bool f) 190void Incidence::setHasStartDate(bool f)
191{ 191{
192 if (mReadOnly) return; 192 if (mReadOnly) return;
193 mHasStartDate = f; 193 mHasStartDate = f;
194 updated(); 194 updated();
195} 195}
196 196
197// A string comparison that considers that null and empty are the same 197// A string comparison that considers that null and empty are the same
198static bool stringCompare( const QString& s1, const QString& s2 ) 198static bool stringCompare( const QString& s1, const QString& s2 )
199{ 199{
200 if ( s1.isEmpty() && s2.isEmpty() ) 200 if ( s1.isEmpty() && s2.isEmpty() )
201 return true; 201 return true;
202 return s1 == s2; 202 return s1 == s2;
203} 203}
204 204
205bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) 205bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
206{ 206{
207 207
208 if( i1.alarms().count() != i2.alarms().count() ) { 208 if( i1.alarms().count() != i2.alarms().count() ) {
209 return false; // no need to check further 209 return false; // no need to check further
210 } 210 }
211 if ( i1.alarms().count() > 0 ) { 211 if ( i1.alarms().count() > 0 ) {
212 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) 212 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) )
213 { 213 {
214 qDebug("alarm not equal "); 214 qDebug("alarm not equal ");
215 return false; 215 return false;
216 } 216 }
217 } 217 }
218#if 0 218#if 0
219 QPtrListIterator<Alarm> a1( i1.alarms() ); 219 QPtrListIterator<Alarm> a1( i1.alarms() );
220 QPtrListIterator<Alarm> a2( i2.alarms() ); 220 QPtrListIterator<Alarm> a2( i2.alarms() );
221 for( ; a1.current() && a2.current(); ++a1, ++a2 ) { 221 for( ; a1.current() && a2.current(); ++a1, ++a2 ) {
222 if( *a1.current() == *a2.current() ) { 222 if( *a1.current() == *a2.current() ) {
223 continue; 223 continue;
224 } 224 }
225 else { 225 else {
226 return false; 226 return false;
227 } 227 }
228 } 228 }
229#endif 229#endif
230 230
231 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { 231 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) {
232 if ( i1.hasRecurrenceID() ) { 232 if ( i1.hasRecurrenceID() ) {
233 if ( i1.recurrenceID() != i2.recurrenceID() ) 233 if ( i1.recurrenceID() != i2.recurrenceID() )
234 return false; 234 return false;
235 } 235 }
236 236
237 } else { 237 } else {
238 return false; 238 return false;
239 } 239 }
240 240
241 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) 241 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) )
242 return false; 242 return false;
243 if ( i1.hasStartDate() == i2.hasStartDate() ) { 243 if ( i1.hasStartDate() == i2.hasStartDate() ) {
244 if ( i1.hasStartDate() ) { 244 if ( i1.hasStartDate() ) {
245 if ( i1.dtStart() != i2.dtStart() ) 245 if ( i1.dtStart() != i2.dtStart() )
246 return false; 246 return false;
247 } 247 }
248 } else { 248 } else {
249 return false; 249 return false;
250 } 250 }
251 if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) { 251 if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) {
252 if (!( *i1.mRecurrence == *i2.mRecurrence) ) { 252 if (!( *i1.mRecurrence == *i2.mRecurrence) ) {
253 //qDebug("recurrence is NOT equal "); 253 //qDebug("recurrence is NOT equal ");
254 return false; 254 return false;
255 } 255 }
256 } else { 256 } else {
257 // one ( or both ) recurrence is 0 257 // one ( or both ) recurrence is 0
258 if ( i1.mRecurrence == 0 ) { 258 if ( i1.mRecurrence == 0 ) {
259 if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone ) 259 if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone )
260 return false; 260 return false;
261 } else { 261 } else {
262 // i1.mRecurrence != 0 262 // i1.mRecurrence != 0
263 // i2.mRecurrence == 0 263 // i2.mRecurrence == 0
264 if ( i1.mRecurrence->doesRecur() != Recurrence::rNone ) 264 if ( i1.mRecurrence->doesRecur() != Recurrence::rNone )
265 return false; 265 return false;
266 } 266 }
267 } 267 }
268 268
269 return 269 return
270 // i1.created() == i2.created() && 270 // i1.created() == i2.created() &&
271 stringCompare( i1.description(), i2.description() ) && 271 stringCompare( i1.description(), i2.description() ) &&
272 stringCompare( i1.summary(), i2.summary() ) && 272 stringCompare( i1.summary(), i2.summary() ) &&
273 i1.categories() == i2.categories() && 273 i1.categories() == i2.categories() &&
274 // no need to compare mRelatedTo 274 // no need to compare mRelatedTo
275 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && 275 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) &&
276 // i1.relations() == i2.relations() && 276 // i1.relations() == i2.relations() &&
277 i1.exDates() == i2.exDates() && 277 i1.exDates() == i2.exDates() &&
278 i1.attachments() == i2.attachments() && 278 i1.attachments() == i2.attachments() &&
279 i1.resources() == i2.resources() && 279 i1.resources() == i2.resources() &&
280 i1.secrecy() == i2.secrecy() && 280 i1.secrecy() == i2.secrecy() &&
281 i1.priority() == i2.priority() && 281 i1.priority() == i2.priority() &&
282 i1.cancelled() == i2.cancelled() && 282 i1.cancelled() == i2.cancelled() &&
283 stringCompare( i1.location(), i2.location() ); 283 stringCompare( i1.location(), i2.location() );
284} 284}
285 285
286Incidence* Incidence::recreateCloneException( QDate d ) 286Incidence* Incidence::recreateCloneException( QDate d )
287{ 287{
288 Incidence* newInc = clone(); 288 Incidence* newInc = clone();
289 newInc->recreate(); 289 newInc->recreate();
290 if ( doesRecur() ) { 290 if ( doesRecur() ) {
291 addExDate( d ); 291 addExDate( d );
292 newInc->recurrence()->unsetRecurs(); 292 newInc->recurrence()->unsetRecurs();
293 if ( typeID() == eventID ) { 293 if ( typeID() == eventID ) {
294 int len = dtStart().secsTo( ((Event*)this)->dtEnd()); 294 int len = dtStart().secsTo( ((Event*)this)->dtEnd());
295 QTime tim = dtStart().time(); 295 QTime tim = dtStart().time();
296 newInc->setDtStart( QDateTime(d, tim) ); 296 newInc->setDtStart( QDateTime(d, tim) );
297 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 297 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
298 } else { 298 } else {
299 int len = dtStart().secsTo( ((Todo*)this)->dtDue()); 299 int len = dtStart().secsTo( ((Todo*)this)->dtDue());
300 QTime tim = ((Todo*)this)->dtDue().time(); 300 QTime tim = ((Todo*)this)->dtDue().time();
301 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); 301 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) );
302 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); 302 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) );
303 ((Todo*)this)->setRecurDates(); 303 ((Todo*)this)->setRecurDates();
304 } 304 }
305 newInc->setExDates( DateList () ); 305 newInc->setExDates( DateList () );
306 } 306 }
307 return newInc; 307 return newInc;
308} 308}
309 309
310void Incidence::recreate() 310void Incidence::recreate()
311{ 311{
312 setCreated(QDateTime::currentDateTime()); 312 setCreated(QDateTime::currentDateTime());
313 313
314 setUid(CalFormat::createUniqueId()); 314 setUid(CalFormat::createUniqueId());
315 315
316 setRevision(0); 316 setRevision(0);
317 setIDStr( ":" ); 317 setIDStr( ":" );
318 setLastModified(QDateTime::currentDateTime()); 318 setLastModified(QDateTime::currentDateTime());
319} 319}
320void Incidence::cloneRelations( Incidence * newInc ) 320void Incidence::cloneRelations( Incidence * newInc )
321{ 321{
322 // newInc is already a clone of this incidence 322 // newInc is already a clone of this incidence
323 Incidence * inc; 323 Incidence * inc;
324 Incidence * cloneInc; 324 Incidence * cloneInc;
325 QPtrList<Incidence> Relations = relations(); 325 QPtrList<Incidence> Relations = relations();
326 for (inc=Relations.first();inc;inc=Relations.next()) { 326 for (inc=Relations.first();inc;inc=Relations.next()) {
327 cloneInc = inc->clone(); 327 cloneInc = inc->clone();
328 cloneInc->recreate(); 328 cloneInc->recreate();
329 cloneInc->setRelatedTo( newInc ); 329 cloneInc->setRelatedTo( newInc );
330 inc->cloneRelations( cloneInc ); 330 inc->cloneRelations( cloneInc );
331 } 331 }
332} 332}
333void Incidence::setReadOnly( bool readOnly ) 333void Incidence::setReadOnly( bool readOnly )
334{ 334{
335 IncidenceBase::setReadOnly( readOnly ); 335 IncidenceBase::setReadOnly( readOnly );
336 if ( mRecurrence ) 336 if ( mRecurrence )
337 mRecurrence->setRecurReadOnly( readOnly); 337 mRecurrence->setRecurReadOnly( readOnly);
338} 338}
339void Incidence::setLastModifiedSubInvalid() 339void Incidence::setLastModifiedSubInvalid()
340{ 340{
341 mLastModifiedSub = QDateTime(); 341 mLastModifiedSub = QDateTime();
342 if ( mRelatedTo ) 342 if ( mRelatedTo )
343 mRelatedTo->setLastModifiedSubInvalid(); 343 mRelatedTo->setLastModifiedSubInvalid();
344} 344}
345QString Incidence::lastModifiedSubSortKey() const
346{
347 if ( mLastModifiedSubSortKey.isEmpty() )
348 return lastModifiedSortKey();
349 return mLastModifiedSubSortKey;
350}
345QDateTime Incidence::lastModifiedSub() 351QDateTime Incidence::lastModifiedSub()
346{ 352{
347 if ( !mRelations.count() ) 353 if ( !mRelations.count() )
348 return lastModified(); 354 return lastModified();
349 if ( mLastModifiedSub.isValid() ) 355 if ( mLastModifiedSub.isValid() )
350 return mLastModifiedSub; 356 return mLastModifiedSub;
351 mLastModifiedSub = lastModified(); 357 mLastModifiedSub = lastModified();
352 Incidence * inc; 358 Incidence * inc;
353 QPtrList<Incidence> Relations = relations(); 359 QPtrList<Incidence> Relations = relations();
354 for (inc=Relations.first();inc;inc=Relations.next()) { 360 for (inc=Relations.first();inc;inc=Relations.next()) {
355 if ( inc->lastModifiedSub() > mLastModifiedSub ) 361 if ( inc->lastModifiedSub() > mLastModifiedSub )
356 mLastModifiedSub = inc->lastModifiedSub(); 362 mLastModifiedSub = inc->lastModifiedSub();
357 } 363 }
364 mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d",
365 mLastModifiedSub.date().year(),
366 mLastModifiedSub.date().month(),
367 mLastModifiedSub.date().day(),
368 mLastModifiedSub.time().hour(),
369 mLastModifiedSub.time().minute(),
370 mLastModifiedSub.time().second() );
358 return mLastModifiedSub; 371 return mLastModifiedSub;
359} 372}
360void Incidence::setCreated(QDateTime created) 373void Incidence::setCreated(QDateTime created)
361{ 374{
362 if (mReadOnly) return; 375 if (mReadOnly) return;
363 mCreated = getEvenTime(created); 376 mCreated = getEvenTime(created);
364} 377}
365 378
366QDateTime Incidence::created() const 379QDateTime Incidence::created() const
367{ 380{
368 return mCreated; 381 return mCreated;
369} 382}
370 383
371void Incidence::setRevision(int rev) 384void Incidence::setRevision(int rev)
372{ 385{
373 if (mReadOnly) return; 386 if (mReadOnly) return;
374 mRevision = rev; 387 mRevision = rev;
375 388
376 updated(); 389 updated();
377} 390}
378 391
379int Incidence::revision() const 392int Incidence::revision() const
380{ 393{
381 return mRevision; 394 return mRevision;
382} 395}
383 396
384void Incidence::setDtStart(const QDateTime &dtStart) 397void Incidence::setDtStart(const QDateTime &dtStart)
385{ 398{
386 399
387 QDateTime dt = getEvenTime(dtStart); 400 QDateTime dt = getEvenTime(dtStart);
388 401
389 if ( mRecurrence ) 402 if ( mRecurrence )
390 mRecurrence->setRecurStart( dt); 403 mRecurrence->setRecurStart( dt);
391 IncidenceBase::setDtStart( dt ); 404 IncidenceBase::setDtStart( dt );
392} 405}
393 406
394void Incidence::setDescription(const QString &description) 407void Incidence::setDescription(const QString &description)
395{ 408{
396 if (mReadOnly) return; 409 if (mReadOnly) return;
397 mDescription = description; 410 mDescription = description;
398 updated(); 411 updated();
399} 412}
400 413
401QString Incidence::description() const 414QString Incidence::description() const
402{ 415{
403 return mDescription; 416 return mDescription;
404} 417}
405 418
406 419
407void Incidence::setSummary(const QString &summary) 420void Incidence::setSummary(const QString &summary)
408{ 421{
409 if (mReadOnly) return; 422 if (mReadOnly) return;
410 mSummary = summary; 423 mSummary = summary;
411 updated(); 424 updated();
412} 425}
413 426
414QString Incidence::summary() const 427QString Incidence::summary() const
415{ 428{
416 return mSummary; 429 return mSummary;
417} 430}
418void Incidence::checkCategories() 431void Incidence::checkCategories()
419{ 432{
420 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); 433 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday"));
421 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); 434 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday"));
422 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); 435 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary"));
423} 436}
424 437
425void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false 438void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false
426{ 439{
427 if (mReadOnly) return; 440 if (mReadOnly) return;
428 int i; 441 int i;
429 for( i = 0; i < categories.count(); ++i ) { 442 for( i = 0; i < categories.count(); ++i ) {
430 if ( !mCategories.contains (categories[i])) 443 if ( !mCategories.contains (categories[i]))
431 mCategories.append( categories[i] ); 444 mCategories.append( categories[i] );
432 } 445 }
433 checkCategories(); 446 checkCategories();
434 updated(); 447 updated();
435 if ( addToRelations ) { 448 if ( addToRelations ) {
436 Incidence * inc; 449 Incidence * inc;
437 QPtrList<Incidence> Relations = relations(); 450 QPtrList<Incidence> Relations = relations();
438 for (inc=Relations.first();inc;inc=Relations.next()) { 451 for (inc=Relations.first();inc;inc=Relations.next()) {
439 inc->addCategories( categories, true ); 452 inc->addCategories( categories, true );
440 } 453 }
441 } 454 }
442} 455}
443 456
444void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false 457void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false
445{ 458{
446 if (mReadOnly) return; 459 if (mReadOnly) return;
447 mCategories = categories; 460 mCategories = categories;
448 checkCategories(); 461 checkCategories();
449 updated(); 462 updated();
450 if ( setForRelations ) { 463 if ( setForRelations ) {
451 Incidence * inc; 464 Incidence * inc;
452 QPtrList<Incidence> Relations = relations(); 465 QPtrList<Incidence> Relations = relations();
453 for (inc=Relations.first();inc;inc=Relations.next()) { 466 for (inc=Relations.first();inc;inc=Relations.next()) {
454 inc->setCategories( categories, true ); 467 inc->setCategories( categories, true );
455 } 468 }
456 } 469 }
457} 470}
458 471
459// TODO: remove setCategories(QString) function 472// TODO: remove setCategories(QString) function
460void Incidence::setCategories(const QString &catStr) 473void Incidence::setCategories(const QString &catStr)
461{ 474{
462 if (mReadOnly) return; 475 if (mReadOnly) return;
463 mCategories.clear(); 476 mCategories.clear();
464 477
465 if (catStr.isEmpty()) return; 478 if (catStr.isEmpty()) return;
466 479
467 mCategories = QStringList::split(",",catStr); 480 mCategories = QStringList::split(",",catStr);
468 481
469 QStringList::Iterator it; 482 QStringList::Iterator it;
470 for(it = mCategories.begin();it != mCategories.end(); ++it) { 483 for(it = mCategories.begin();it != mCategories.end(); ++it) {
471 *it = (*it).stripWhiteSpace(); 484 *it = (*it).stripWhiteSpace();
472 } 485 }
473 checkCategories(); 486 checkCategories();
474 updated(); 487 updated();
475} 488}
476// using this makes filtering 3 times faster 489// using this makes filtering 3 times faster
477QStringList* Incidence::categoriesP() 490QStringList* Incidence::categoriesP()
478{ 491{
479 return &mCategories; 492 return &mCategories;
480} 493}
481 494
482QStringList Incidence::categories() const 495QStringList Incidence::categories() const
483{ 496{
484 return mCategories; 497 return mCategories;
485} 498}
486 499
487QString Incidence::categoriesStr() 500QString Incidence::categoriesStr()
488{ 501{
489 return mCategories.join(","); 502 return mCategories.join(",");
490} 503}
491QString Incidence::categoriesStrWithSpace() 504QString Incidence::categoriesStrWithSpace()
492{ 505{
493 return mCategories.join(", "); 506 return mCategories.join(", ");
494} 507}
495 508
496void Incidence::setRelatedToUid(const QString &relatedToUid) 509void Incidence::setRelatedToUid(const QString &relatedToUid)
497{ 510{
498 if (mReadOnly) return; 511 if (mReadOnly) return;
499 mRelatedToUid = relatedToUid; 512 mRelatedToUid = relatedToUid;
500} 513}
501void Incidence::clearRelations() 514void Incidence::clearRelations()
502{ 515{
503 mRelatedTo = 0; 516 mRelatedTo = 0;
504 mRelations.clear(); 517 mRelations.clear();
505} 518}
506QString Incidence::relatedToUid() const 519QString Incidence::relatedToUid() const
507{ 520{
508 return mRelatedToUid; 521 return mRelatedToUid;
509} 522}
510 523
511void Incidence::setRelatedTo(Incidence *relatedTo) 524void Incidence::setRelatedTo(Incidence *relatedTo)
512{ 525{
513 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 526 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
514 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 527 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
515 if (mReadOnly || mRelatedTo == relatedTo) return; 528 if (mReadOnly || mRelatedTo == relatedTo) return;
516 if(mRelatedTo) { 529 if(mRelatedTo) {
517 // updated(); 530 // updated();
518 mRelatedTo->removeRelation(this); 531 mRelatedTo->removeRelation(this);
519 } 532 }
520 mRelatedTo = relatedTo; 533 mRelatedTo = relatedTo;
521 if (mRelatedTo) { 534 if (mRelatedTo) {
522 mRelatedTo->addRelation(this); 535 mRelatedTo->addRelation(this);
523 mRelatedToUid = mRelatedTo->uid(); 536 mRelatedToUid = mRelatedTo->uid();
524 } else { 537 } else {
525 mRelatedToUid = ""; 538 mRelatedToUid = "";
526 } 539 }
527} 540}
528 541
529Incidence *Incidence::relatedTo() const 542Incidence *Incidence::relatedTo() const
530{ 543{
531 return mRelatedTo; 544 return mRelatedTo;
532} 545}
533 546
534QPtrList<Incidence> Incidence::relations() const 547QPtrList<Incidence> Incidence::relations() const
535{ 548{
536 return mRelations; 549 return mRelations;
537} 550}
538 551
539void Incidence::addRelationsToList(QPtrList<Incidence> *rel) 552void Incidence::addRelationsToList(QPtrList<Incidence> *rel)
540{ 553{
541 Incidence* inc; 554 Incidence* inc;
542 QPtrList<Incidence> Relations = relations(); 555 QPtrList<Incidence> Relations = relations();
543 for (inc=Relations.first();inc;inc=Relations.next()) { 556 for (inc=Relations.first();inc;inc=Relations.next()) {
544 inc->addRelationsToList( rel ); 557 inc->addRelationsToList( rel );
545 } 558 }
546 if ( rel->findRef( this ) == -1 ) 559 if ( rel->findRef( this ) == -1 )
547 rel->append( this ); 560 rel->append( this );
548} 561}
549 562
550void Incidence::addRelation(Incidence *event) 563void Incidence::addRelation(Incidence *event)
551{ 564{
552 setLastModifiedSubInvalid(); 565 setLastModifiedSubInvalid();
553 if( mRelations.findRef( event ) == -1 ) { 566 if( mRelations.findRef( event ) == -1 ) {
554 mRelations.append(event); 567 mRelations.append(event);
555 //updated(); 568 //updated();
556 } 569 }
557} 570}
558 571
559void Incidence::removeRelation(Incidence *event) 572void Incidence::removeRelation(Incidence *event)
560{ 573{
561 setLastModifiedSubInvalid(); 574 setLastModifiedSubInvalid();
562 mRelations.removeRef(event); 575 mRelations.removeRef(event);
563// if (event->getRelatedTo() == this) event->setRelatedTo(0); 576// if (event->getRelatedTo() == this) event->setRelatedTo(0);
564} 577}
565 578
566bool Incidence::recursOn(const QDate &qd) const 579bool Incidence::recursOn(const QDate &qd) const
567{ 580{
568 if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; 581 if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true;
569 else return false; 582 else return false;
570} 583}
571 584
572void Incidence::setExDates(const DateList &exDates) 585void Incidence::setExDates(const DateList &exDates)
573{ 586{
574 if (mReadOnly) return; 587 if (mReadOnly) return;
575 mExDates = exDates; 588 mExDates = exDates;
576 recurrence()->setRecurExDatesCount(mExDates.count()); 589 recurrence()->setRecurExDatesCount(mExDates.count());
577 590
578 updated(); 591 updated();
579} 592}
580 593
581void Incidence::addExDate(const QDate &date) 594void Incidence::addExDate(const QDate &date)
582{ 595{
583 if (mReadOnly) return; 596 if (mReadOnly) return;
584 mExDates.append(date); 597 mExDates.append(date);
585 598
586 recurrence()->setRecurExDatesCount(mExDates.count()); 599 recurrence()->setRecurExDatesCount(mExDates.count());
587 600
588 updated(); 601 updated();
589} 602}
590 603
591DateList Incidence::exDates() const 604DateList Incidence::exDates() const
592{ 605{
593 return mExDates; 606 return mExDates;
594} 607}
595 608
596bool Incidence::isException(const QDate &date) const 609bool Incidence::isException(const QDate &date) const
597{ 610{
598 DateList::ConstIterator it; 611 DateList::ConstIterator it;
599 for( it = mExDates.begin(); it != mExDates.end(); ++it ) { 612 for( it = mExDates.begin(); it != mExDates.end(); ++it ) {
600 if ( (*it) == date ) { 613 if ( (*it) == date ) {
601 return true; 614 return true;
602 } 615 }
603 } 616 }
604 617
605 return false; 618 return false;
606} 619}
607 620
608void Incidence::addAttachment(Attachment *attachment) 621void Incidence::addAttachment(Attachment *attachment)
609{ 622{
610 if (mReadOnly || !attachment) return; 623 if (mReadOnly || !attachment) return;
611 mAttachments.append(attachment); 624 mAttachments.append(attachment);
612 updated(); 625 updated();
613} 626}
614 627
615void Incidence::deleteAttachment(Attachment *attachment) 628void Incidence::deleteAttachment(Attachment *attachment)
616{ 629{
617 mAttachments.removeRef(attachment); 630 mAttachments.removeRef(attachment);
618} 631}
619 632
620void Incidence::deleteAttachments(const QString& mime) 633void Incidence::deleteAttachments(const QString& mime)
621{ 634{
622 Attachment *at = mAttachments.first(); 635 Attachment *at = mAttachments.first();
623 while (at) { 636 while (at) {
624 if (at->mimeType() == mime) 637 if (at->mimeType() == mime)
625 mAttachments.remove(); 638 mAttachments.remove();
626 else 639 else
627 at = mAttachments.next(); 640 at = mAttachments.next();
628 } 641 }
629} 642}
630 643
631QPtrList<Attachment> Incidence::attachments() const 644QPtrList<Attachment> Incidence::attachments() const
632{ 645{
633 return mAttachments; 646 return mAttachments;
634} 647}
635 648
636QPtrList<Attachment> Incidence::attachments(const QString& mime) const 649QPtrList<Attachment> Incidence::attachments(const QString& mime) const
637{ 650{
638 QPtrList<Attachment> attachments; 651 QPtrList<Attachment> attachments;
639 QPtrListIterator<Attachment> it( mAttachments ); 652 QPtrListIterator<Attachment> it( mAttachments );
640 Attachment *at; 653 Attachment *at;
641 while ( (at = it.current()) ) { 654 while ( (at = it.current()) ) {
642 if (at->mimeType() == mime) 655 if (at->mimeType() == mime)
643 attachments.append(at); 656 attachments.append(at);
644 ++it; 657 ++it;
645 } 658 }
646 659
647 return attachments; 660 return attachments;
648} 661}
649 662
650void Incidence::setResources(const QStringList &resources) 663void Incidence::setResources(const QStringList &resources)
651{ 664{
652 if (mReadOnly) return; 665 if (mReadOnly) return;
653 mResources = resources; 666 mResources = resources;
654 updated(); 667 updated();
655} 668}
656 669
657QStringList Incidence::resources() const 670QStringList Incidence::resources() const
658{ 671{
659 return mResources; 672 return mResources;
660} 673}
661 674
662 675
663void Incidence::setPriority(int priority) 676void Incidence::setPriority(int priority)
664{ 677{
665 if (mReadOnly) return; 678 if (mReadOnly) return;
666 mPriority = priority; 679 mPriority = priority;
667 updated(); 680 updated();
668} 681}
669 682
670int Incidence::priority() const 683int Incidence::priority() const
671{ 684{
672 return mPriority; 685 return mPriority;
673} 686}
674 687
675void Incidence::setSecrecy(int sec) 688void Incidence::setSecrecy(int sec)
676{ 689{
677 if (mReadOnly) return; 690 if (mReadOnly) return;
678 mSecrecy = sec; 691 mSecrecy = sec;
679 updated(); 692 updated();
680} 693}
681 694
682int Incidence::secrecy() const 695int Incidence::secrecy() const
683{ 696{
684 return mSecrecy; 697 return mSecrecy;
685} 698}
686 699
687QString Incidence::secrecyStr() const 700QString Incidence::secrecyStr() const
688{ 701{
689 return secrecyName(mSecrecy); 702 return secrecyName(mSecrecy);
690} 703}
691 704
692QString Incidence::secrecyName(int secrecy) 705QString Incidence::secrecyName(int secrecy)
693{ 706{
694 switch (secrecy) { 707 switch (secrecy) {
695 case SecrecyPublic: 708 case SecrecyPublic:
696 return i18n("Public"); 709 return i18n("Public");
697 break; 710 break;
698 case SecrecyPrivate: 711 case SecrecyPrivate:
699 return i18n("Private"); 712 return i18n("Private");
700 break; 713 break;
701 case SecrecyConfidential: 714 case SecrecyConfidential:
702 return i18n("Confidential"); 715 return i18n("Confidential");
703 break; 716 break;
704 default: 717 default:
705 return i18n("Undefined"); 718 return i18n("Undefined");
706 break; 719 break;
707 } 720 }
708} 721}
709 722
710QStringList Incidence::secrecyList() 723QStringList Incidence::secrecyList()
711{ 724{
712 QStringList list; 725 QStringList list;
713 list << secrecyName(SecrecyPublic); 726 list << secrecyName(SecrecyPublic);
714 list << secrecyName(SecrecyPrivate); 727 list << secrecyName(SecrecyPrivate);
715 list << secrecyName(SecrecyConfidential); 728 list << secrecyName(SecrecyConfidential);
716 729
717 return list; 730 return list;
718} 731}
719 732
720 733
721QPtrList<Alarm> Incidence::alarms() const 734QPtrList<Alarm> Incidence::alarms() const
722{ 735{
723 return mAlarms; 736 return mAlarms;
724} 737}
725 738
726Alarm* Incidence::newAlarm() 739Alarm* Incidence::newAlarm()
727{ 740{
728 Alarm* alarm = new Alarm(this); 741 Alarm* alarm = new Alarm(this);
729 mAlarms.append(alarm); 742 mAlarms.append(alarm);
730// updated(); 743// updated();
731 return alarm; 744 return alarm;
732} 745}
733 746
734void Incidence::addAlarm(Alarm *alarm) 747void Incidence::addAlarm(Alarm *alarm)
735{ 748{
736 mAlarms.append(alarm); 749 mAlarms.append(alarm);
737 updated(); 750 updated();
738} 751}
739 752
740void Incidence::removeAlarm(Alarm *alarm) 753void Incidence::removeAlarm(Alarm *alarm)
741{ 754{
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index eef9e64..dc49640 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -1,324 +1,326 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef INCIDENCE_H 20#ifndef INCIDENCE_H
21#define INCIDENCE_H 21#define INCIDENCE_H
22// 22//
23// Incidence - base class of calendaring components 23// Incidence - base class of calendaring components
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29 29
30#include "recurrence.h" 30#include "recurrence.h"
31#include "alarm.h" 31#include "alarm.h"
32#include "attachment.h" 32#include "attachment.h"
33#include "listbase.h" 33#include "listbase.h"
34#include "incidencebase.h" 34#include "incidencebase.h"
35 35
36namespace KCal { 36namespace KCal {
37 37
38class Event; 38class Event;
39class Todo; 39class Todo;
40class Journal; 40class Journal;
41 41
42/** 42/**
43 This class provides the base class common to all calendar components. 43 This class provides the base class common to all calendar components.
44*/ 44*/
45class Incidence : public IncidenceBase 45class Incidence : public IncidenceBase
46{ 46{
47 public: 47 public:
48 /** 48 /**
49 This class provides the interface for a visitor of calendar components. It 49 This class provides the interface for a visitor of calendar components. It
50 serves as base class for concrete visitors, which implement certain actions on 50 serves as base class for concrete visitors, which implement certain actions on
51 calendar components. It allows to add functions, which operate on the concrete 51 calendar components. It allows to add functions, which operate on the concrete
52 types of calendar components, without changing the calendar component classes. 52 types of calendar components, without changing the calendar component classes.
53 */ 53 */
54 class Visitor 54 class Visitor
55 { 55 {
56 public: 56 public:
57 /** Destruct Incidence::Visitor */ 57 /** Destruct Incidence::Visitor */
58 virtual ~Visitor() {} 58 virtual ~Visitor() {}
59 59
60 /** 60 /**
61 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions 61 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions
62 on an Event object. 62 on an Event object.
63 */ 63 */
64 virtual bool visit(Event *) { return false; } 64 virtual bool visit(Event *) { return false; }
65 /** 65 /**
66 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions 66 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions
67 on an Todo object. 67 on an Todo object.
68 */ 68 */
69 virtual bool visit(Todo *) { return false; } 69 virtual bool visit(Todo *) { return false; }
70 /** 70 /**
71 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions 71 Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions
72 on an Journal object. 72 on an Journal object.
73 */ 73 */
74 virtual bool visit(Journal *) { return false; } 74 virtual bool visit(Journal *) { return false; }
75 75
76 protected: 76 protected:
77 /** Constructor is protected to prevent direct creation of visitor base class. */ 77 /** Constructor is protected to prevent direct creation of visitor base class. */
78 Visitor() {} 78 Visitor() {}
79 }; 79 };
80 80
81 /** 81 /**
82 This class implements a visitor for adding an Incidence to a resource 82 This class implements a visitor for adding an Incidence to a resource
83 supporting addEvent(), addTodo() and addJournal() calls. 83 supporting addEvent(), addTodo() and addJournal() calls.
84 */ 84 */
85 template<class T> 85 template<class T>
86 class AddVisitor : public Visitor 86 class AddVisitor : public Visitor
87 { 87 {
88 public: 88 public:
89 AddVisitor( T *r ) : mResource( r ) {} 89 AddVisitor( T *r ) : mResource( r ) {}
90 bool visit( Event *e ) { return mResource->addEvent( e ); } 90 bool visit( Event *e ) { return mResource->addEvent( e ); }
91 bool visit( Todo *t ) { return mResource->addTodo( t ); } 91 bool visit( Todo *t ) { return mResource->addTodo( t ); }
92 bool visit( Journal *j ) { return mResource->addJournal( j ); } 92 bool visit( Journal *j ) { return mResource->addJournal( j ); }
93 93
94 private: 94 private:
95 T *mResource; 95 T *mResource;
96 }; 96 };
97 97
98 /** enumeration for describing an event's secrecy. */ 98 /** enumeration for describing an event's secrecy. */
99 enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; 99 enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 };
100 typedef ListBase<Incidence> List; 100 typedef ListBase<Incidence> List;
101 Incidence(); 101 Incidence();
102 Incidence(const Incidence &); 102 Incidence(const Incidence &);
103 ~Incidence(); 103 ~Incidence();
104 104
105 /** 105 /**
106 Accept IncidenceVisitor. A class taking part in the visitor mechanism has to 106 Accept IncidenceVisitor. A class taking part in the visitor mechanism has to
107 provide this implementation: 107 provide this implementation:
108 <pre> 108 <pre>
109 bool accept(Visitor &v) { return v.visit(this); } 109 bool accept(Visitor &v) { return v.visit(this); }
110 </pre> 110 </pre>
111 */ 111 */
112 virtual bool accept(Visitor &) { return false; } 112 virtual bool accept(Visitor &) { return false; }
113 113
114 virtual Incidence *clone() = 0; 114 virtual Incidence *clone() = 0;
115 virtual void cloneRelations( Incidence * ); 115 virtual void cloneRelations( Incidence * );
116 void addRelationsToList(QPtrList<Incidence> *rel); 116 void addRelationsToList(QPtrList<Incidence> *rel);
117 void clearRelations(); 117 void clearRelations();
118 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; 118 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0;
119 void setReadOnly( bool ); 119 void setReadOnly( bool );
120 120
121 /** 121 /**
122 Recreate event. The event is made a new unique event, but already stored 122 Recreate event. The event is made a new unique event, but already stored
123 event information is preserved. Sets uniquie id, creation date, last 123 event information is preserved. Sets uniquie id, creation date, last
124 modification date and revision number. 124 modification date and revision number.
125 */ 125 */
126 void recreate(); 126 void recreate();
127 Incidence* recreateCloneException(QDate); 127 Incidence* recreateCloneException(QDate);
128 128
129 /** set creation date */ 129 /** set creation date */
130 void setCreated(QDateTime); 130 void setCreated(QDateTime);
131 /** return time and date of creation. */ 131 /** return time and date of creation. */
132 QDateTime created() const; 132 QDateTime created() const;
133 133
134 /** set the number of revisions this event has seen */ 134 /** set the number of revisions this event has seen */
135 void setRevision(int rev); 135 void setRevision(int rev);
136 /** return the number of revisions this event has seen */ 136 /** return the number of revisions this event has seen */
137 int revision() const; 137 int revision() const;
138 138
139 /** Set starting date/time. */ 139 /** Set starting date/time. */
140 virtual void setDtStart(const QDateTime &dtStart); 140 virtual void setDtStart(const QDateTime &dtStart);
141 /** Return the incidence's ending date/time as a QDateTime. */ 141 /** Return the incidence's ending date/time as a QDateTime. */
142 virtual QDateTime dtEnd() const { return QDateTime(); } 142 virtual QDateTime dtEnd() const { return QDateTime(); }
143 143
144 /** sets the event's lengthy description. */ 144 /** sets the event's lengthy description. */
145 void setDescription(const QString &description); 145 void setDescription(const QString &description);
146 /** returns a reference to the event's description. */ 146 /** returns a reference to the event's description. */
147 QString description() const; 147 QString description() const;
148 148
149 /** sets the event's short summary. */ 149 /** sets the event's short summary. */
150 void setSummary(const QString &summary); 150 void setSummary(const QString &summary);
151 /** returns a reference to the event's summary. */ 151 /** returns a reference to the event's summary. */
152 QString summary() const; 152 QString summary() const;
153 153
154 /** set event's applicable categories */ 154 /** set event's applicable categories */
155 void setCategories(const QStringList &categories, bool setForRelations = false); 155 void setCategories(const QStringList &categories, bool setForRelations = false);
156 void addCategories(const QStringList &categories, bool addToRelations = false); 156 void addCategories(const QStringList &categories, bool addToRelations = false);
157 /** set event's categories based on a comma delimited string */ 157 /** set event's categories based on a comma delimited string */
158 void setCategories(const QString &catStr); 158 void setCategories(const QString &catStr);
159 /** return categories in a list */ 159 /** return categories in a list */
160 QStringList categories() const; 160 QStringList categories() const;
161 QStringList* categoriesP(); 161 QStringList* categoriesP();
162 /** return categories as a comma separated string */ 162 /** return categories as a comma separated string */
163 QString categoriesStr(); 163 QString categoriesStr();
164 QString categoriesStrWithSpace(); 164 QString categoriesStrWithSpace();
165 165
166 /** point at some other event to which the event relates. This function should 166 /** point at some other event to which the event relates. This function should
167 * only be used when constructing a calendar before the related Event 167 * only be used when constructing a calendar before the related Event
168 * exists. */ 168 * exists. */
169 void setRelatedToUid(const QString &); 169 void setRelatedToUid(const QString &);
170 /** what event does this one relate to? This function should 170 /** what event does this one relate to? This function should
171 * only be used when constructing a calendar before the related Event 171 * only be used when constructing a calendar before the related Event
172 * exists. */ 172 * exists. */
173 QString relatedToUid() const; 173 QString relatedToUid() const;
174 /** point at some other event to which the event relates */ 174 /** point at some other event to which the event relates */
175 void setRelatedTo(Incidence *relatedTo); 175 void setRelatedTo(Incidence *relatedTo);
176 /** what event does this one relate to? */ 176 /** what event does this one relate to? */
177 Incidence *relatedTo() const; 177 Incidence *relatedTo() const;
178 /** All events that are related to this event */ 178 /** All events that are related to this event */
179 QPtrList<Incidence> relations() const; 179 QPtrList<Incidence> relations() const;
180 /** Add an event which is related to this event */ 180 /** Add an event which is related to this event */
181 void addRelation(Incidence *); 181 void addRelation(Incidence *);
182 /** Remove event that is related to this event */ 182 /** Remove event that is related to this event */
183 void removeRelation(Incidence *); 183 void removeRelation(Incidence *);
184 184
185 /** returns the list of dates which are exceptions to the recurrence rule */ 185 /** returns the list of dates which are exceptions to the recurrence rule */
186 DateList exDates() const; 186 DateList exDates() const;
187 /** sets the list of dates which are exceptions to the recurrence rule */ 187 /** sets the list of dates which are exceptions to the recurrence rule */
188 void setExDates(const DateList &_exDates); 188 void setExDates(const DateList &_exDates);
189 void setExDates(const char *dates); 189 void setExDates(const char *dates);
190 /** Add a date to the list of exceptions of the recurrence rule. */ 190 /** Add a date to the list of exceptions of the recurrence rule. */
191 void addExDate(const QDate &date); 191 void addExDate(const QDate &date);
192 192
193 /** returns true if there is an exception for this date in the recurrence 193 /** returns true if there is an exception for this date in the recurrence
194 rule set, or false otherwise. */ 194 rule set, or false otherwise. */
195 bool isException(const QDate &qd) const; 195 bool isException(const QDate &qd) const;
196 196
197 /** add attachment to this event */ 197 /** add attachment to this event */
198 void addAttachment(Attachment *attachment); 198 void addAttachment(Attachment *attachment);
199 /** remove and delete a specific attachment */ 199 /** remove and delete a specific attachment */
200 void deleteAttachment(Attachment *attachment); 200 void deleteAttachment(Attachment *attachment);
201 /** remove and delete all attachments with this mime type */ 201 /** remove and delete all attachments with this mime type */
202 void deleteAttachments(const QString& mime); 202 void deleteAttachments(const QString& mime);
203 /** return list of all associated attachments */ 203 /** return list of all associated attachments */
204 QPtrList<Attachment> attachments() const; 204 QPtrList<Attachment> attachments() const;
205 /** find a list of attachments with this mime type */ 205 /** find a list of attachments with this mime type */
206 QPtrList<Attachment> attachments(const QString& mime) const; 206 QPtrList<Attachment> attachments(const QString& mime) const;
207 207
208 /** sets the event's status the value specified. See the enumeration 208 /** sets the event's status the value specified. See the enumeration
209 * above for possible values. */ 209 * above for possible values. */
210 void setSecrecy(int); 210 void setSecrecy(int);
211 /** return the event's secrecy. */ 211 /** return the event's secrecy. */
212 int secrecy() const; 212 int secrecy() const;
213 /** return the event's secrecy in string format. */ 213 /** return the event's secrecy in string format. */
214 QString secrecyStr() const; 214 QString secrecyStr() const;
215 /** return list of all availbale secrecy classes */ 215 /** return list of all availbale secrecy classes */
216 static QStringList secrecyList(); 216 static QStringList secrecyList();
217 /** return human-readable name of secrecy class */ 217 /** return human-readable name of secrecy class */
218 static QString secrecyName(int); 218 static QString secrecyName(int);
219 219
220 /** returns TRUE if the date specified is one on which the event will 220 /** returns TRUE if the date specified is one on which the event will
221 * recur. */ 221 * recur. */
222 bool recursOn(const QDate &qd) const; 222 bool recursOn(const QDate &qd) const;
223 223
224 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): 224 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?):
225 225
226 /** set resources used, such as Office, Car, etc. */ 226 /** set resources used, such as Office, Car, etc. */
227 void setResources(const QStringList &resources); 227 void setResources(const QStringList &resources);
228 /** return list of current resources */ 228 /** return list of current resources */
229 QStringList resources() const; 229 QStringList resources() const;
230 230
231 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ 231 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */
232 void setPriority(int priority); 232 void setPriority(int priority);
233 /** get the event's priority */ 233 /** get the event's priority */
234 int priority() const; 234 int priority() const;
235 235
236 /** All alarms that are associated with this incidence */ 236 /** All alarms that are associated with this incidence */
237 QPtrList<Alarm> alarms() const; 237 QPtrList<Alarm> alarms() const;
238 /** Create a new alarm which is associated with this incidence */ 238 /** Create a new alarm which is associated with this incidence */
239 Alarm* newAlarm(); 239 Alarm* newAlarm();
240 /** Add an alarm which is associated with this incidence */ 240 /** Add an alarm which is associated with this incidence */
241 void addAlarm(Alarm*); 241 void addAlarm(Alarm*);
242 /** Remove an alarm that is associated with this incidence */ 242 /** Remove an alarm that is associated with this incidence */
243 void removeAlarm(Alarm*); 243 void removeAlarm(Alarm*);
244 /** Remove all alarms that are associated with this incidence */ 244 /** Remove all alarms that are associated with this incidence */
245 void clearAlarms(); 245 void clearAlarms();
246 /** return whether any alarm associated with this incidence is enabled */ 246 /** return whether any alarm associated with this incidence is enabled */
247 bool isAlarmEnabled() const; 247 bool isAlarmEnabled() const;
248 248
249 /** 249 /**
250 Return the recurrence rule associated with this incidence. If there is 250 Return the recurrence rule associated with this incidence. If there is
251 none, returns an appropriate (non-0) object. 251 none, returns an appropriate (non-0) object.
252 */ 252 */
253 Recurrence *recurrence(); 253 Recurrence *recurrence();
254 void setRecurrence(Recurrence * r); 254 void setRecurrence(Recurrence * r);
255 /** 255 /**
256 Forward to Recurrence::doesRecur(). 256 Forward to Recurrence::doesRecur().
257 */ 257 */
258 ushort doesRecur() const; 258 ushort doesRecur() const;
259 259
260 /** set the event's/todo's location. Do _not_ use it with journal */ 260 /** set the event's/todo's location. Do _not_ use it with journal */
261 void setLocation(const QString &location); 261 void setLocation(const QString &location);
262 /** return the event's/todo's location. Do _not_ use it with journal */ 262 /** return the event's/todo's location. Do _not_ use it with journal */
263 QString location() const; 263 QString location() const;
264 /** returns TRUE or FALSE depending on whether the todo has a start date */ 264 /** returns TRUE or FALSE depending on whether the todo has a start date */
265 bool hasStartDate() const; 265 bool hasStartDate() const;
266 /** sets the event's hasStartDate value. */ 266 /** sets the event's hasStartDate value. */
267 void setHasStartDate(bool f); 267 void setHasStartDate(bool f);
268 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; 268 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const;
269 bool cancelled() const; 269 bool cancelled() const;
270 void setCancelled( bool b ); 270 void setCancelled( bool b );
271 271
272 bool hasRecurrenceID() const; 272 bool hasRecurrenceID() const;
273 void setHasRecurrenceID( bool b ); 273 void setHasRecurrenceID( bool b );
274 274
275 void setRecurrenceID(QDateTime); 275 void setRecurrenceID(QDateTime);
276 QDateTime recurrenceID () const; 276 QDateTime recurrenceID () const;
277 QDateTime dtStart() const; 277 QDateTime dtStart() const;
278 bool isHoliday() const; 278 bool isHoliday() const;
279 bool isBirthday() const; 279 bool isBirthday() const;
280 bool isAnniversary() const; 280 bool isAnniversary() const;
281 QDateTime lastModifiedSub(); 281 QDateTime lastModifiedSub();
282 QString lastModifiedSubSortKey() const;
282 QString recurrenceText() const; 283 QString recurrenceText() const;
283 void setLastModifiedSubInvalid(); 284 void setLastModifiedSubInvalid();
284 285
285 virtual QString durationText(); 286 virtual QString durationText();
286 QString durationText4Time( int secs ); 287 QString durationText4Time( int secs );
287 Recurrence *mRecurrence; 288 Recurrence *mRecurrence;
288protected: 289protected:
289 QPtrList<Alarm> mAlarms; 290 QPtrList<Alarm> mAlarms;
290 QPtrList<Incidence> mRelations; 291 QPtrList<Incidence> mRelations;
291 QDateTime mRecurrenceID; 292 QDateTime mRecurrenceID;
292 bool mHasRecurrenceID; 293 bool mHasRecurrenceID;
293 private: 294 private:
294 void checkCategories(); 295 void checkCategories();
296 QString mLastModifiedSubSortKey;
295 bool mHoliday, mBirthday, mAnniversary; 297 bool mHoliday, mBirthday, mAnniversary;
296 int mRevision; 298 int mRevision;
297 bool mCancelled; 299 bool mCancelled;
298 300
299 // base components of jounal, event and todo 301 // base components of jounal, event and todo
300 QDateTime mCreated; 302 QDateTime mCreated;
301 QDateTime mLastModifiedSub; 303 QDateTime mLastModifiedSub;
302 QString mDescription; 304 QString mDescription;
303 QString mSummary; 305 QString mSummary;
304 QStringList mCategories; 306 QStringList mCategories;
305 Incidence *mRelatedTo; 307 Incidence *mRelatedTo;
306 QString mRelatedToUid; 308 QString mRelatedToUid;
307 DateList mExDates; 309 DateList mExDates;
308 QPtrList<Attachment> mAttachments; 310 QPtrList<Attachment> mAttachments;
309 QStringList mResources; 311 QStringList mResources;
310 bool mHasStartDate; // if todo has associated start date 312 bool mHasStartDate; // if todo has associated start date
311 313
312 int mSecrecy; 314 int mSecrecy;
313 int mPriority; // 1 = highest, 2 = less, etc. 315 int mPriority; // 1 = highest, 2 = less, etc.
314 316
315 //QPtrList<Alarm> mAlarms; 317 //QPtrList<Alarm> mAlarms;
316 318
317 QString mLocation; 319 QString mLocation;
318}; 320};
319 321
320bool operator==( const Incidence&, const Incidence& ); 322bool operator==( const Incidence&, const Incidence& );
321 323
322} 324}
323 325
324#endif 326#endif
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 022dead..cfef973 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -1,482 +1,493 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24#include <kidmanager.h> 24#include <kidmanager.h>
25 25
26#include "calformat.h" 26#include "calformat.h"
27#include "syncdefines.h" 27#include "syncdefines.h"
28 28
29#include "incidencebase.h" 29#include "incidencebase.h"
30 30
31using namespace KCal; 31using namespace KCal;
32 32
33IncidenceBase::IncidenceBase() : 33IncidenceBase::IncidenceBase() :
34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), 34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
35 mPilotId(0), mSyncStatus(SYNCMOD) 35 mPilotId(0), mSyncStatus(SYNCMOD)
36{ 36{
37 blockLastModified = false; 37 blockLastModified = false;
38 setUid(CalFormat::createUniqueId()); 38 setUid(CalFormat::createUniqueId());
39 mOrganizer = ""; 39 mOrganizer = "";
40 mFloats = false; 40 mFloats = false;
41 mDuration = 0; 41 mDuration = 0;
42 mHasDuration = false; 42 mHasDuration = false;
43 mPilotId = 0; 43 mPilotId = 0;
44 mExternalId = ":"; 44 mExternalId = ":";
45 mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 45 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
46 mSyncStatus = 0; 46 mSyncStatus = 0;
47 mAttendees.setAutoDelete( true ); 47 mAttendees.setAutoDelete( true );
48 mCalEnabled = true; 48 mCalEnabled = true;
49 mAlarmEnabled = true; 49 mAlarmEnabled = true;
50 mCalID = 0; 50 mCalID = 0;
51} 51}
52 52
53IncidenceBase::IncidenceBase(const IncidenceBase &i) : 53IncidenceBase::IncidenceBase(const IncidenceBase &i) :
54 CustomProperties( i ) 54 CustomProperties( i )
55{ 55{
56 56
57 blockLastModified = false; 57 blockLastModified = false;
58 mReadOnly = i.mReadOnly; 58 mReadOnly = i.mReadOnly;
59 mDtStart = i.mDtStart; 59 mDtStart = i.mDtStart;
60 mDuration = i.mDuration; 60 mDuration = i.mDuration;
61 mHasDuration = i.mHasDuration; 61 mHasDuration = i.mHasDuration;
62 mOrganizer = i.mOrganizer; 62 mOrganizer = i.mOrganizer;
63 mUid = i.mUid; 63 mUid = i.mUid;
64 mCalEnabled = i.mCalEnabled; 64 mCalEnabled = i.mCalEnabled;
65 mAlarmEnabled = i.mAlarmEnabled; 65 mAlarmEnabled = i.mAlarmEnabled;
66 mCalID = i.mCalID; 66 mCalID = i.mCalID;
67 QPtrList<Attendee> attendees = i.attendees(); 67 QPtrList<Attendee> attendees = i.attendees();
68 for( Attendee *a = attendees.first(); a; a = attendees.next() ) { 68 for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
69 mAttendees.append( new Attendee( *a ) ); 69 mAttendees.append( new Attendee( *a ) );
70 } 70 }
71 mFloats = i.mFloats; 71 mFloats = i.mFloats;
72 mLastModified = i.mLastModified; 72 mLastModified = i.mLastModified;
73 mPilotId = i.mPilotId; 73 mPilotId = i.mPilotId;
74 mTempSyncStat = i.mTempSyncStat; 74 mTempSyncStat = i.mTempSyncStat;
75 mSyncStatus = i.mSyncStatus; 75 mSyncStatus = i.mSyncStatus;
76 mExternalId = i.mExternalId; 76 mExternalId = i.mExternalId;
77 // The copied object is a new one, so it isn't observed by the observer 77 // The copied object is a new one, so it isn't observed by the observer
78 // of the original object. 78 // of the original object.
79 mObservers.clear(); 79 mObservers.clear();
80 80
81 mAttendees.setAutoDelete( true ); 81 mAttendees.setAutoDelete( true );
82} 82}
83 83
84IncidenceBase::~IncidenceBase() 84IncidenceBase::~IncidenceBase()
85{ 85{
86} 86}
87 87
88 88
89bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 89bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
90{ 90{
91 // do not compare mSyncStatus and mExternalId 91 // do not compare mSyncStatus and mExternalId
92 if( i1.attendees().count() != i2.attendees().count() ) { 92 if( i1.attendees().count() != i2.attendees().count() ) {
93 return false; // no need to check further 93 return false; // no need to check further
94 } 94 }
95 if ( i1.attendees().count() > 0 ) { 95 if ( i1.attendees().count() > 0 ) {
96 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; 96 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
97 while ( a1 ) { 97 while ( a1 ) {
98 if ( !( (*a1) == (*a2)) ) 98 if ( !( (*a1) == (*a2)) )
99 { 99 {
100 //qDebug("Attendee not equal "); 100 //qDebug("Attendee not equal ");
101 return false; 101 return false;
102 } 102 }
103 a1 = i1.attendees().next(); 103 a1 = i1.attendees().next();
104 a2 = i2.attendees().next(); 104 a2 = i2.attendees().next();
105 } 105 }
106 } 106 }
107 //if ( i1.dtStart() != i2.dtStart() ) 107 //if ( i1.dtStart() != i2.dtStart() )
108 // return false; 108 // return false;
109#if 0 109#if 0
110 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); 110 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
111 qDebug("1 %d ",i1.duration() == i2.duration() ); 111 qDebug("1 %d ",i1.duration() == i2.duration() );
112 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); 112 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
113 qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); 113 qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
114 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); 114 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
115 qDebug("6 %d ",i1.organizer() == i2.organizer() ); 115 qDebug("6 %d ",i1.organizer() == i2.organizer() );
116 116
117#endif 117#endif
118 if ( i1.hasDuration() == i2.hasDuration() ) { 118 if ( i1.hasDuration() == i2.hasDuration() ) {
119 if ( i1.hasDuration() ) { 119 if ( i1.hasDuration() ) {
120 if ( i1.duration() != i2.duration() ) 120 if ( i1.duration() != i2.duration() )
121 return false; 121 return false;
122 } 122 }
123 } else { 123 } else {
124 return false; 124 return false;
125 } 125 }
126 126
127 return ( i1.organizer() == i2.organizer() && 127 return ( i1.organizer() == i2.organizer() &&
128 // i1.uid() == i2.uid() && 128 // i1.uid() == i2.uid() &&
129 // Don't compare lastModified, otherwise the operator is not 129 // Don't compare lastModified, otherwise the operator is not
130 // of much use. We are not comparing for identity, after all. 130 // of much use. We are not comparing for identity, after all.
131 i1.doesFloat() == i2.doesFloat() && 131 i1.doesFloat() == i2.doesFloat() &&
132 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); 132 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
133 // no need to compare mObserver 133 // no need to compare mObserver
134} 134}
135 135
136 136
137QDateTime IncidenceBase::getEvenTime( QDateTime dt ) 137QDateTime IncidenceBase::getEvenTime( QDateTime dt )
138{ 138{
139 QTime t = dt.time(); 139 QTime t = dt.time();
140 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 140 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
141 return dt; 141 return dt;
142} 142}
143 143
144bool IncidenceBase::isTagged() const 144bool IncidenceBase::isTagged() const
145{ 145{
146 return mIsTagged; 146 return mIsTagged;
147} 147}
148void IncidenceBase::setTagged( bool b) 148void IncidenceBase::setTagged( bool b)
149{ 149{
150 mIsTagged = b; 150 mIsTagged = b;
151} 151}
152void IncidenceBase::setCalID( int id ) 152void IncidenceBase::setCalID( int id )
153{ 153{
154 if ( mCalID > 0 ) { 154 if ( mCalID > 0 ) {
155 blockLastModified = true; 155 blockLastModified = true;
156 updated(); 156 updated();
157 blockLastModified = false; 157 blockLastModified = false;
158 } 158 }
159 mCalID = id; 159 mCalID = id;
160} 160}
161int IncidenceBase::calID() const 161int IncidenceBase::calID() const
162{ 162{
163 return mCalID; 163 return mCalID;
164} 164}
165void IncidenceBase::setCalEnabled( bool b ) 165void IncidenceBase::setCalEnabled( bool b )
166{ 166{
167 mCalEnabled = b; 167 mCalEnabled = b;
168} 168}
169bool IncidenceBase::calEnabled() const 169bool IncidenceBase::calEnabled() const
170{ 170{
171 return mCalEnabled; 171 return mCalEnabled;
172} 172}
173 173
174void IncidenceBase::setAlarmEnabled( bool b ) 174void IncidenceBase::setAlarmEnabled( bool b )
175{ 175{
176 mAlarmEnabled = b; 176 mAlarmEnabled = b;
177} 177}
178bool IncidenceBase::alarmEnabled() const 178bool IncidenceBase::alarmEnabled() const
179{ 179{
180 return mAlarmEnabled; 180 return mAlarmEnabled;
181} 181}
182 182
183 183
184void IncidenceBase::setUid(const QString &uid) 184void IncidenceBase::setUid(const QString &uid)
185{ 185{
186 mUid = uid; 186 mUid = uid;
187 updated(); 187 updated();
188} 188}
189 189
190QString IncidenceBase::uid() const 190QString IncidenceBase::uid() const
191{ 191{
192 return mUid; 192 return mUid;
193} 193}
194void IncidenceBase::setLastModifiedSubInvalid() 194void IncidenceBase::setLastModifiedSubInvalid()
195{ 195{
196 196 // virtual method
197} 197}
198void IncidenceBase::setLastModified(const QDateTime &lm) 198void IncidenceBase::setLastModified(const QDateTime &lm)
199{ 199{
200 if ( blockLastModified ) return; 200 if ( blockLastModified ) return;
201 // DON'T! updated() because we call this from 201 // DON'T! updated() because we call this from
202 // Calendar::updateEvent(). 202 // Calendar::updateEvent().
203 mLastModified = getEvenTime(lm); 203 mLastModified = getEvenTime(lm);
204 mLastModifiedKey.sprintf("%04d%02d%02d%02d%02d%02d",
205 mLastModified.date().year(),
206 mLastModified.date().month(),
207 mLastModified.date().day(),
208 mLastModified.time().hour(),
209 mLastModified.time().minute(),
210 mLastModified.time().second() );
204 setLastModifiedSubInvalid(); 211 setLastModifiedSubInvalid();
205 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); 212 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
206} 213}
214QString IncidenceBase::lastModifiedSortKey() const
215{
216 return mLastModifiedKey;
217}
207 218
208QDateTime IncidenceBase::lastModified() const 219QDateTime IncidenceBase::lastModified() const
209{ 220{
210 return mLastModified; 221 return mLastModified;
211} 222}
212 223
213void IncidenceBase::setOrganizer(const QString &o) 224void IncidenceBase::setOrganizer(const QString &o)
214{ 225{
215 // we don't check for readonly here, because it is 226 // we don't check for readonly here, because it is
216 // possible that by setting the organizer we are changing 227 // possible that by setting the organizer we are changing
217 // the event's readonly status... 228 // the event's readonly status...
218 mOrganizer = o; 229 mOrganizer = o;
219 if (mOrganizer.left(7).upper() == "MAILTO:") 230 if (mOrganizer.left(7).upper() == "MAILTO:")
220 mOrganizer = mOrganizer.remove(0,7); 231 mOrganizer = mOrganizer.remove(0,7);
221 232
222 updated(); 233 updated();
223} 234}
224 235
225QString IncidenceBase::organizer() const 236QString IncidenceBase::organizer() const
226{ 237{
227 return mOrganizer; 238 return mOrganizer;
228} 239}
229 240
230void IncidenceBase::setReadOnly( bool readOnly ) 241void IncidenceBase::setReadOnly( bool readOnly )
231{ 242{
232 mReadOnly = readOnly; 243 mReadOnly = readOnly;
233} 244}
234 245
235void IncidenceBase::setDtStart(const QDateTime &dtStart) 246void IncidenceBase::setDtStart(const QDateTime &dtStart)
236{ 247{
237// if (mReadOnly) return; 248// if (mReadOnly) return;
238 mDtStart = getEvenTime(dtStart); 249 mDtStart = getEvenTime(dtStart);
239 updated(); 250 updated();
240} 251}
241 252
242 253
243QDateTime IncidenceBase::dtStart() const 254QDateTime IncidenceBase::dtStart() const
244{ 255{
245 return mDtStart; 256 return mDtStart;
246} 257}
247 258
248QString IncidenceBase::dtStartTimeStr() const 259QString IncidenceBase::dtStartTimeStr() const
249{ 260{
250 return KGlobal::locale()->formatTime(dtStart().time()); 261 return KGlobal::locale()->formatTime(dtStart().time());
251} 262}
252 263
253QString IncidenceBase::dtStartDateStr(bool shortfmt) const 264QString IncidenceBase::dtStartDateStr(bool shortfmt) const
254{ 265{
255 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 266 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
256} 267}
257 268
258QString IncidenceBase::dtStartStr(bool shortfmt) const 269QString IncidenceBase::dtStartStr(bool shortfmt) const
259{ 270{
260 if ( doesFloat() ) 271 if ( doesFloat() )
261 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 272 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
262 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); 273 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt);
263} 274}
264 275
265 276
266bool IncidenceBase::doesFloat() const 277bool IncidenceBase::doesFloat() const
267{ 278{
268 return mFloats; 279 return mFloats;
269} 280}
270 281
271void IncidenceBase::setFloats(bool f) 282void IncidenceBase::setFloats(bool f)
272{ 283{
273 if (mReadOnly) return; 284 if (mReadOnly) return;
274 mFloats = f; 285 mFloats = f;
275 updated(); 286 updated();
276} 287}
277 288
278 289
279bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) 290bool IncidenceBase::addAttendee(Attendee *a, bool doupdate)
280{ 291{
281 if (mReadOnly) return false; 292 if (mReadOnly) return false;
282 if (a->name().left(7).upper() == "MAILTO:") 293 if (a->name().left(7).upper() == "MAILTO:")
283 a->setName(a->name().remove(0,7)); 294 a->setName(a->name().remove(0,7));
284 295
285 QPtrListIterator<Attendee> qli(mAttendees); 296 QPtrListIterator<Attendee> qli(mAttendees);
286 297
287 qli.toFirst(); 298 qli.toFirst();
288 while (qli) { 299 while (qli) {
289 if (*qli.current() == *a) 300 if (*qli.current() == *a)
290 return false; 301 return false;
291 ++qli; 302 ++qli;
292 } 303 }
293 mAttendees.append(a); 304 mAttendees.append(a);
294 if (doupdate) updated(); 305 if (doupdate) updated();
295 return true; 306 return true;
296} 307}
297 308
298#if 0 309#if 0
299void IncidenceBase::removeAttendee(Attendee *a) 310void IncidenceBase::removeAttendee(Attendee *a)
300{ 311{
301 if (mReadOnly) return; 312 if (mReadOnly) return;
302 mAttendees.removeRef(a); 313 mAttendees.removeRef(a);
303 updated(); 314 updated();
304} 315}
305 316
306void IncidenceBase::removeAttendee(const char *n) 317void IncidenceBase::removeAttendee(const char *n)
307{ 318{
308 Attendee *a; 319 Attendee *a;
309 320
310 if (mReadOnly) return; 321 if (mReadOnly) return;
311 for (a = mAttendees.first(); a; a = mAttendees.next()) 322 for (a = mAttendees.first(); a; a = mAttendees.next())
312 if (a->getName() == n) { 323 if (a->getName() == n) {
313 mAttendees.remove(); 324 mAttendees.remove();
314 break; 325 break;
315 } 326 }
316} 327}
317#endif 328#endif
318 329
319void IncidenceBase::clearAttendees() 330void IncidenceBase::clearAttendees()
320{ 331{
321 if (mReadOnly) return; 332 if (mReadOnly) return;
322 mAttendees.clear(); 333 mAttendees.clear();
323} 334}
324 335
325#if 0 336#if 0
326Attendee *IncidenceBase::getAttendee(const char *n) const 337Attendee *IncidenceBase::getAttendee(const char *n) const
327{ 338{
328 QPtrListIterator<Attendee> qli(mAttendees); 339 QPtrListIterator<Attendee> qli(mAttendees);
329 340
330 qli.toFirst(); 341 qli.toFirst();
331 while (qli) { 342 while (qli) {
332 if (qli.current()->getName() == n) 343 if (qli.current()->getName() == n)
333 return qli.current(); 344 return qli.current();
334 ++qli; 345 ++qli;
335 } 346 }
336 return 0L; 347 return 0L;
337} 348}
338#endif 349#endif
339 350
340Attendee *IncidenceBase::attendeeByMail(const QString &email) 351Attendee *IncidenceBase::attendeeByMail(const QString &email)
341{ 352{
342 QPtrListIterator<Attendee> qli(mAttendees); 353 QPtrListIterator<Attendee> qli(mAttendees);
343 354
344 qli.toFirst(); 355 qli.toFirst();
345 while (qli) { 356 while (qli) {
346 if (qli.current()->email().lower() == email.lower()) 357 if (qli.current()->email().lower() == email.lower())
347 return qli.current(); 358 return qli.current();
348 ++qli; 359 ++qli;
349 } 360 }
350 return 0L; 361 return 0L;
351} 362}
352 363
353Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) 364Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email)
354{ 365{
355 QPtrListIterator<Attendee> qli(mAttendees); 366 QPtrListIterator<Attendee> qli(mAttendees);
356 367
357 QStringList mails = emails; 368 QStringList mails = emails;
358 if (!email.isEmpty()) { 369 if (!email.isEmpty()) {
359 mails.append(email); 370 mails.append(email);
360 } 371 }
361 qli.toFirst(); 372 qli.toFirst();
362 while (qli) { 373 while (qli) {
363 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { 374 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) {
364 if (qli.current()->email().lower() == (*it).lower()) 375 if (qli.current()->email().lower() == (*it).lower())
365 return qli.current(); 376 return qli.current();
366 } 377 }
367 378
368 ++qli; 379 ++qli;
369 } 380 }
370 return 0L; 381 return 0L;
371} 382}
372 383
373void IncidenceBase::setDuration(int seconds) 384void IncidenceBase::setDuration(int seconds)
374{ 385{
375 mDuration = seconds; 386 mDuration = seconds;
376 setHasDuration(true); 387 setHasDuration(true);
377} 388}
378 389
379int IncidenceBase::duration() const 390int IncidenceBase::duration() const
380{ 391{
381 return mDuration; 392 return mDuration;
382} 393}
383 394
384void IncidenceBase::setHasDuration(bool b) 395void IncidenceBase::setHasDuration(bool b)
385{ 396{
386 mHasDuration = b; 397 mHasDuration = b;
387} 398}
388 399
389bool IncidenceBase::hasDuration() const 400bool IncidenceBase::hasDuration() const
390{ 401{
391 return mHasDuration; 402 return mHasDuration;
392} 403}
393 404
394void IncidenceBase::setSyncStatus(int stat) 405void IncidenceBase::setSyncStatus(int stat)
395{ 406{
396 if (mReadOnly) return; 407 if (mReadOnly) return;
397 mSyncStatus = stat; 408 mSyncStatus = stat;
398} 409}
399 410
400int IncidenceBase::syncStatus() const 411int IncidenceBase::syncStatus() const
401{ 412{
402 return mSyncStatus; 413 return mSyncStatus;
403} 414}
404 415
405void IncidenceBase::setPilotId( int id ) 416void IncidenceBase::setPilotId( int id )
406{ 417{
407 if (mReadOnly) return; 418 if (mReadOnly) return;
408 mPilotId = id; 419 mPilotId = id;
409} 420}
410 421
411int IncidenceBase::pilotId() const 422int IncidenceBase::pilotId() const
412{ 423{
413 return mPilotId; 424 return mPilotId;
414} 425}
415 426
416int IncidenceBase::tempSyncStat() const 427int IncidenceBase::tempSyncStat() const
417{ 428{
418 return mTempSyncStat; 429 return mTempSyncStat;
419} 430}
420void IncidenceBase::setTempSyncStat( int id ) 431void IncidenceBase::setTempSyncStat( int id )
421{ 432{
422 if (mReadOnly) return; 433 if (mReadOnly) return;
423 mTempSyncStat = id; 434 mTempSyncStat = id;
424} 435}
425 436
426void IncidenceBase::removeID(const QString &prof) 437void IncidenceBase::removeID(const QString &prof)
427{ 438{
428 if ( prof.isEmpty() ) 439 if ( prof.isEmpty() )
429 mExternalId = ":"; 440 mExternalId = ":";
430 else 441 else
431 mExternalId = KIdManager::removeId ( mExternalId, prof); 442 mExternalId = KIdManager::removeId ( mExternalId, prof);
432 443
433} 444}
434void IncidenceBase::setID( const QString & prof , const QString & id ) 445void IncidenceBase::setID( const QString & prof , const QString & id )
435{ 446{
436 mExternalId = KIdManager::setId ( mExternalId, prof, id ); 447 mExternalId = KIdManager::setId ( mExternalId, prof, id );
437} 448}
438QString IncidenceBase::getID( const QString & prof) 449QString IncidenceBase::getID( const QString & prof)
439{ 450{
440 return KIdManager::getId ( mExternalId, prof ); 451 return KIdManager::getId ( mExternalId, prof );
441} 452}
442 453
443// example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: 454// example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0:
444// format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 455// format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0
445void IncidenceBase::setCsum( const QString & prof , const QString & id ) 456void IncidenceBase::setCsum( const QString & prof , const QString & id )
446{ 457{
447 mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); 458 mExternalId = KIdManager::setCsum ( mExternalId, prof, id );
448} 459}
449QString IncidenceBase::getCsum( const QString & prof) 460QString IncidenceBase::getCsum( const QString & prof)
450{ 461{
451 return KIdManager::getCsum ( mExternalId, prof ); 462 return KIdManager::getCsum ( mExternalId, prof );
452} 463}
453 464
454void IncidenceBase::setIDStr( const QString & s ) 465void IncidenceBase::setIDStr( const QString & s )
455{ 466{
456 if (mReadOnly) return; 467 if (mReadOnly) return;
457 mExternalId = s; 468 mExternalId = s;
458} 469}
459 470
460QString IncidenceBase::IDStr() const 471QString IncidenceBase::IDStr() const
461{ 472{
462 return mExternalId ; 473 return mExternalId ;
463} 474}
464void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) 475void IncidenceBase::registerObserver( IncidenceBase::Observer *observer )
465{ 476{
466 if( !mObservers.contains(observer) ) mObservers.append( observer ); 477 if( !mObservers.contains(observer) ) mObservers.append( observer );
467} 478}
468 479
469void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) 480void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer )
470{ 481{
471 mObservers.remove( observer ); 482 mObservers.remove( observer );
472} 483}
473 484
474void IncidenceBase::updated() 485void IncidenceBase::updated()
475{ 486{
476 QPtrListIterator<Observer> it(mObservers); 487 QPtrListIterator<Observer> it(mObservers);
477 while( it.current() ) { 488 while( it.current() ) {
478 Observer *o = it.current(); 489 Observer *o = it.current();
479 ++it; 490 ++it;
480 o->incidenceUpdated( this ); 491 o->incidenceUpdated( this );
481 } 492 }
482} 493}
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 665c1f6..444d4c4 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -1,187 +1,189 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KCAL_INCIDENCEBASE_H 20#ifndef KCAL_INCIDENCEBASE_H
21#define KCAL_INCIDENCEBASE_H 21#define KCAL_INCIDENCEBASE_H
22// 22//
23// Incidence - base class of calendaring components 23// Incidence - base class of calendaring components
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "attendee.h" 32#include "attendee.h"
33 33
34namespace KCal { 34namespace KCal {
35 35
36typedef QValueList<QDate> DateList; 36typedef QValueList<QDate> DateList;
37 enum IncTypeID { eventID,todoID,journalID,freebusyID }; 37 enum IncTypeID { eventID,todoID,journalID,freebusyID };
38 38
39/** 39/**
40 This class provides the base class common to all calendar components. 40 This class provides the base class common to all calendar components.
41*/ 41*/
42class IncidenceBase : public CustomProperties 42class IncidenceBase : public CustomProperties
43{ 43{
44 public: 44 public:
45 class Observer { 45 class Observer {
46 public: 46 public:
47 virtual void incidenceUpdated( IncidenceBase * ) = 0; 47 virtual void incidenceUpdated( IncidenceBase * ) = 0;
48 }; 48 };
49 49
50 IncidenceBase(); 50 IncidenceBase();
51 IncidenceBase(const IncidenceBase &); 51 IncidenceBase(const IncidenceBase &);
52 virtual ~IncidenceBase(); 52 virtual ~IncidenceBase();
53 53
54 virtual QCString type() const = 0; 54 virtual QCString type() const = 0;
55 virtual IncTypeID typeID() const = 0; 55 virtual IncTypeID typeID() const = 0;
56 56
57 /** Set the unique id for the event */ 57 /** Set the unique id for the event */
58 void setUid(const QString &); 58 void setUid(const QString &);
59 /** Return the unique id for the event */ 59 /** Return the unique id for the event */
60 QString uid() const; 60 QString uid() const;
61 61
62 /** Sets the time the incidence was last modified. */ 62 /** Sets the time the incidence was last modified. */
63 void setLastModified(const QDateTime &lm); 63 void setLastModified(const QDateTime &lm);
64 /** Return the time the incidence was last modified. */ 64 /** Return the time the incidence was last modified. */
65 QDateTime lastModified() const; 65 QDateTime lastModified() const;
66 QString lastModifiedSortKey() const;
66 67
67 /** sets the organizer for the event */ 68 /** sets the organizer for the event */
68 void setOrganizer(const QString &o); 69 void setOrganizer(const QString &o);
69 QString organizer() const; 70 QString organizer() const;
70 71
71 /** Set readonly status. */ 72 /** Set readonly status. */
72 virtual void setReadOnly( bool ); 73 virtual void setReadOnly( bool );
73 /** Return if the object is read-only. */ 74 /** Return if the object is read-only. */
74 bool isReadOnly() const { return mReadOnly; } 75 bool isReadOnly() const { return mReadOnly; }
75 76
76 /** for setting the event's starting date/time with a QDateTime. */ 77 /** for setting the event's starting date/time with a QDateTime. */
77 virtual void setDtStart(const QDateTime &dtStart); 78 virtual void setDtStart(const QDateTime &dtStart);
78 /** returns an event's starting date/time as a QDateTime. */ 79 /** returns an event's starting date/time as a QDateTime. */
79 virtual QDateTime dtStart() const; 80 virtual QDateTime dtStart() const;
80 /** returns an event's starting time as a string formatted according to the 81 /** returns an event's starting time as a string formatted according to the
81 users locale settings */ 82 users locale settings */
82 QString dtStartTimeStr() const; 83 QString dtStartTimeStr() const;
83 /** returns an event's starting date as a string formatted according to the 84 /** returns an event's starting date as a string formatted according to the
84 users locale settings */ 85 users locale settings */
85 QString dtStartDateStr(bool shortfmt=true) const; 86 QString dtStartDateStr(bool shortfmt=true) const;
86 /** returns an event's starting date and time as a string formatted according 87 /** returns an event's starting date and time as a string formatted according
87 to the users locale settings */ 88 to the users locale settings */
88 QString dtStartStr(bool shortfmt=true) const; 89 QString dtStartStr(bool shortfmt=true) const;
89 90
90 virtual void setDuration(int seconds); 91 virtual void setDuration(int seconds);
91 int duration() const; 92 int duration() const;
92 void setHasDuration(bool); 93 void setHasDuration(bool);
93 bool hasDuration() const; 94 bool hasDuration() const;
94 95
95 /** Return true or false depending on whether the incidence "floats," 96 /** Return true or false depending on whether the incidence "floats,"
96 * i.e. has a date but no time attached to it. */ 97 * i.e. has a date but no time attached to it. */
97 bool doesFloat() const; 98 bool doesFloat() const;
98 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ 99 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */
99 void setFloats(bool f); 100 void setFloats(bool f);
100 101
101 /** 102 /**
102 Add Attendee to this incidence. IncidenceBase takes ownership of the 103 Add Attendee to this incidence. IncidenceBase takes ownership of the
103 Attendee object. 104 Attendee object.
104 */ 105 */
105 bool addAttendee(Attendee *a, bool doupdate=true ); 106 bool addAttendee(Attendee *a, bool doupdate=true );
106// void removeAttendee(Attendee *a); 107// void removeAttendee(Attendee *a);
107// void removeAttendee(const char *n); 108// void removeAttendee(const char *n);
108 /** Remove all Attendees. */ 109 /** Remove all Attendees. */
109 void clearAttendees(); 110 void clearAttendees();
110 /** Return list of attendees. */ 111 /** Return list of attendees. */
111 QPtrList<Attendee> attendees() const { return mAttendees; }; 112 QPtrList<Attendee> attendees() const { return mAttendees; };
112 /** Return number of attendees. */ 113 /** Return number of attendees. */
113 int attendeeCount() const { return mAttendees.count(); }; 114 int attendeeCount() const { return mAttendees.count(); };
114 /** Return the Attendee with this email */ 115 /** Return the Attendee with this email */
115 Attendee* attendeeByMail(const QString &); 116 Attendee* attendeeByMail(const QString &);
116 /** Return first Attendee with one of this emails */ 117 /** Return first Attendee with one of this emails */
117 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); 118 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null);
118 119
119 /** pilot syncronization states */ 120 /** pilot syncronization states */
120 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; 121 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
121 /** Set synchronisation satus. */ 122 /** Set synchronisation satus. */
122 void setSyncStatus(int stat); 123 void setSyncStatus(int stat);
123 /** Return synchronisation status. */ 124 /** Return synchronisation status. */
124 int syncStatus() const; 125 int syncStatus() const;
125 126
126 /** Set Pilot Id. */ 127 /** Set Pilot Id. */
127 void setPilotId(int id); 128 void setPilotId(int id);
128 /** Return Pilot Id. */ 129 /** Return Pilot Id. */
129 int pilotId() const; 130 int pilotId() const;
130 131
131 void setTempSyncStat(int id); 132 void setTempSyncStat(int id);
132 int tempSyncStat() const; 133 int tempSyncStat() const;
133 void setIDStr( const QString & ); 134 void setIDStr( const QString & );
134 QString IDStr() const; 135 QString IDStr() const;
135 void setID( const QString &, const QString & ); 136 void setID( const QString &, const QString & );
136 QString getID( const QString & ); 137 QString getID( const QString & );
137 void setCsum( const QString &, const QString & ); 138 void setCsum( const QString &, const QString & );
138 QString getCsum( const QString & ); 139 QString getCsum( const QString & );
139 void removeID(const QString &); 140 void removeID(const QString &);
140 141
141 void registerObserver( Observer * ); 142 void registerObserver( Observer * );
142 void unRegisterObserver( Observer * ); 143 void unRegisterObserver( Observer * );
143 void updated(); 144 void updated();
144 void setCalID( int id ); 145 void setCalID( int id );
145 int calID() const; 146 int calID() const;
146 void setCalEnabled( bool ); 147 void setCalEnabled( bool );
147 bool calEnabled() const; 148 bool calEnabled() const;
148 void setAlarmEnabled( bool ); 149 void setAlarmEnabled( bool );
149 bool alarmEnabled() const; 150 bool alarmEnabled() const;
150 bool isTagged() const; 151 bool isTagged() const;
151 void setTagged( bool ); 152 void setTagged( bool );
152 virtual void setLastModifiedSubInvalid(); 153 virtual void setLastModifiedSubInvalid();
153 protected: 154 protected:
154 bool blockLastModified; 155 bool blockLastModified;
155 bool mIsTagged; 156 bool mIsTagged;
156 QDateTime mDtStart; 157 QDateTime mDtStart;
157 bool mReadOnly; 158 bool mReadOnly;
158 QDateTime getEvenTime( QDateTime ); 159 QDateTime getEvenTime( QDateTime );
159 160
160 private: 161 private:
161 // base components 162 // base components
162 QString mOrganizer; 163 QString mOrganizer;
164 QString mLastModifiedKey;
163 QString mUid; 165 QString mUid;
164 int mCalID; 166 int mCalID;
165 bool mCalEnabled; 167 bool mCalEnabled;
166 bool mAlarmEnabled; 168 bool mAlarmEnabled;
167 QDateTime mLastModified; 169 QDateTime mLastModified;
168 QPtrList<Attendee> mAttendees; 170 QPtrList<Attendee> mAttendees;
169 171
170 bool mFloats; 172 bool mFloats;
171 173
172 int mDuration; 174 int mDuration;
173 bool mHasDuration; 175 bool mHasDuration;
174 QString mExternalId; 176 QString mExternalId;
175 int mTempSyncStat; 177 int mTempSyncStat;
176 178
177 // PILOT SYNCHRONIZATION STUFF 179 // PILOT SYNCHRONIZATION STUFF
178 int mPilotId; // unique id for pilot sync 180 int mPilotId; // unique id for pilot sync
179 int mSyncStatus; // status (for sync) 181 int mSyncStatus; // status (for sync)
180 182
181 QPtrList<Observer> mObservers; 183 QPtrList<Observer> mObservers;
182}; 184};
183 185
184bool operator==( const IncidenceBase&, const IncidenceBase& ); 186bool operator==( const IncidenceBase&, const IncidenceBase& );
185} 187}
186 188
187#endif 189#endif