summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.cpp
Unidiff
Diffstat (limited to 'libkcal/incidence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index fe9f854..7dd9bd2 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -1,866 +1,872 @@
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 345QString Incidence::lastModifiedSubSortKey() const
346{ 346{
347 if ( mLastModifiedSubSortKey.isEmpty() ) 347 if ( mLastModifiedSubSortKey.isEmpty() )
348 return lastModifiedSortKey(); 348 return lastModifiedSortKey();
349 return mLastModifiedSubSortKey; 349 return mLastModifiedSubSortKey;
350} 350}
351QDateTime Incidence::lastModifiedSub() 351QDateTime Incidence::lastModifiedSub()
352{ 352{
353 if ( !mRelations.count() ) 353 if ( !mRelations.count() )
354 return lastModified(); 354 return lastModified();
355 if ( mLastModifiedSub.isValid() ) 355 if ( mLastModifiedSub.isValid() )
356 return mLastModifiedSub; 356 return mLastModifiedSub;
357 mLastModifiedSub = lastModified(); 357 mLastModifiedSub = lastModified();
358 Incidence * inc; 358 Incidence * inc;
359 QPtrList<Incidence> Relations = relations(); 359 QPtrList<Incidence> Relations = relations();
360 for (inc=Relations.first();inc;inc=Relations.next()) { 360 for (inc=Relations.first();inc;inc=Relations.next()) {
361 if ( inc->lastModifiedSub() > mLastModifiedSub ) 361 if ( inc->lastModifiedSub() > mLastModifiedSub )
362 mLastModifiedSub = inc->lastModifiedSub(); 362 mLastModifiedSub = inc->lastModifiedSub();
363 } 363 }
364 mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d", 364 mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d",
365 mLastModifiedSub.date().year(), 365 mLastModifiedSub.date().year(),
366 mLastModifiedSub.date().month(), 366 mLastModifiedSub.date().month(),
367 mLastModifiedSub.date().day(), 367 mLastModifiedSub.date().day(),
368 mLastModifiedSub.time().hour(), 368 mLastModifiedSub.time().hour(),
369 mLastModifiedSub.time().minute(), 369 mLastModifiedSub.time().minute(),
370 mLastModifiedSub.time().second() ); 370 mLastModifiedSub.time().second() );
371 return mLastModifiedSub; 371 return mLastModifiedSub;
372} 372}
373void Incidence::setCreated(QDateTime created) 373void Incidence::setCreated(QDateTime created)
374{ 374{
375 if (mReadOnly) return; 375 if (mReadOnly) return;
376 mCreated = getEvenTime(created); 376 mCreated = getEvenTime(created);
377} 377}
378 378
379QDateTime Incidence::created() const 379QDateTime Incidence::created() const
380{ 380{
381 return mCreated; 381 return mCreated;
382} 382}
383 383
384void Incidence::setRevision(int rev) 384void Incidence::setRevision(int rev)
385{ 385{
386 if (mReadOnly) return; 386 if (mReadOnly) return;
387 mRevision = rev; 387 mRevision = rev;
388 388
389 updated(); 389 updated();
390} 390}
391 391
392int Incidence::revision() const 392int Incidence::revision() const
393{ 393{
394 return mRevision; 394 return mRevision;
395} 395}
396 396
397void Incidence::setDtStart(const QDateTime &dtStart) 397void Incidence::setDtStart(const QDateTime &dtStart)
398{ 398{
399 399
400 QDateTime dt = getEvenTime(dtStart); 400 QDateTime dt = getEvenTime(dtStart);
401 401
402 if ( mRecurrence ) 402 if ( mRecurrence )
403 mRecurrence->setRecurStart( dt); 403 mRecurrence->setRecurStart( dt);
404 IncidenceBase::setDtStart( dt ); 404 IncidenceBase::setDtStart( dt );
405} 405}
406 406
407void Incidence::setDescription(const QString &description) 407void Incidence::setDescription(const QString &description)
408{ 408{
409 if (mReadOnly) return; 409 if (mReadOnly) return;
410 mDescription = description; 410 mDescription = description;
411 updated(); 411 updated();
412} 412}
413 413
414QString Incidence::description() const 414QString Incidence::description() const
415{ 415{
416 return mDescription; 416 return mDescription;
417} 417}
418 418
419 419
420void Incidence::setSummary(const QString &summary) 420void Incidence::setSummary(const QString &summary)
421{ 421{
422 if (mReadOnly) return; 422 if (mReadOnly) return;
423 mSummary = summary; 423 mSummary = summary;
424 updated(); 424 updated();
425} 425}
426 426
427QString Incidence::summary() const 427QString Incidence::summary() const
428{ 428{
429 return mSummary; 429 return mSummary;
430} 430}
431void Incidence::checkCategories() 431void Incidence::checkCategories()
432{ 432{
433 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); 433 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday"));
434 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); 434 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday"));
435 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); 435 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary"));
436} 436}
437 437
438void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false 438void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false
439{ 439{
440 if (mReadOnly) return; 440 if (mReadOnly) return;
441 int i; 441 int i;
442 for( i = 0; i < categories.count(); ++i ) { 442 for( i = 0; i < categories.count(); ++i ) {
443 if ( !mCategories.contains (categories[i])) 443 if ( !mCategories.contains (categories[i]))
444 mCategories.append( categories[i] ); 444 mCategories.append( categories[i] );
445 } 445 }
446 checkCategories(); 446 checkCategories();
447 updated(); 447 updated();
448 if ( addToRelations ) { 448 if ( addToRelations ) {
449 Incidence * inc; 449 Incidence * inc;
450 QPtrList<Incidence> Relations = relations(); 450 QPtrList<Incidence> Relations = relations();
451 for (inc=Relations.first();inc;inc=Relations.next()) { 451 for (inc=Relations.first();inc;inc=Relations.next()) {
452 inc->addCategories( categories, true ); 452 inc->addCategories( categories, true );
453 } 453 }
454 } 454 }
455} 455}
456 456
457void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false 457void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false
458{ 458{
459 if (mReadOnly) return; 459 if (mReadOnly) return;
460 mCategories = categories; 460 mCategories = categories;
461 checkCategories(); 461 checkCategories();
462 updated(); 462 updated();
463 if ( setForRelations ) { 463 if ( setForRelations ) {
464 Incidence * inc; 464 Incidence * inc;
465 QPtrList<Incidence> Relations = relations(); 465 QPtrList<Incidence> Relations = relations();
466 for (inc=Relations.first();inc;inc=Relations.next()) { 466 for (inc=Relations.first();inc;inc=Relations.next()) {
467 inc->setCategories( categories, true ); 467 inc->setCategories( categories, true );
468 } 468 }
469 } 469 }
470} 470}
471 471
472// TODO: remove setCategories(QString) function 472// TODO: remove setCategories(QString) function
473void Incidence::setCategories(const QString &catStr) 473void Incidence::setCategories(const QString &catStr)
474{ 474{
475 if (mReadOnly) return; 475 if (mReadOnly) return;
476 mCategories.clear(); 476 mCategories.clear();
477 477
478 if (catStr.isEmpty()) return; 478 if (catStr.isEmpty()) return;
479 479
480 mCategories = QStringList::split(",",catStr); 480 mCategories = QStringList::split(",",catStr);
481 481
482 QStringList::Iterator it; 482 QStringList::Iterator it;
483 for(it = mCategories.begin();it != mCategories.end(); ++it) { 483 for(it = mCategories.begin();it != mCategories.end(); ++it) {
484 *it = (*it).stripWhiteSpace(); 484 *it = (*it).stripWhiteSpace();
485 } 485 }
486 checkCategories(); 486 checkCategories();
487 updated(); 487 updated();
488} 488}
489// using this makes filtering 3 times faster 489// using this makes filtering 3 times faster
490QStringList* Incidence::categoriesP() 490QStringList* Incidence::categoriesP()
491{ 491{
492 return &mCategories; 492 return &mCategories;
493} 493}
494 494
495QStringList Incidence::categories() const 495QStringList Incidence::categories() const
496{ 496{
497 return mCategories; 497 return mCategories;
498} 498}
499 499
500QString Incidence::categoriesStr() 500QString Incidence::categoriesStr()
501{ 501{
502 return mCategories.join(","); 502 return mCategories.join(",");
503} 503}
504QString Incidence::categoriesStrWithSpace() 504QString Incidence::categoriesStrWithSpace()
505{ 505{
506 return mCategories.join(", "); 506 return mCategories.join(", ");
507} 507}
508 508
509void Incidence::setRelatedToUid(const QString &relatedToUid) 509void Incidence::setRelatedToUid(const QString &relatedToUid)
510{ 510{
511 if (mReadOnly) return; 511 if (mReadOnly) return;
512 mRelatedToUid = relatedToUid; 512 mRelatedToUid = relatedToUid;
513} 513}
514void Incidence::clearRelations() 514void Incidence::clearRelations()
515{ 515{
516 mRelatedTo = 0; 516 mRelatedTo = 0;
517 mRelations.clear(); 517 mRelations.clear();
518} 518}
519QString Incidence::relatedToUid() const 519QString Incidence::relatedToUid() const
520{ 520{
521 return mRelatedToUid; 521 return mRelatedToUid;
522} 522}
523void Incidence::resetRelatedTo()
524{
525 QString store = mRelatedToUid;
526 setRelatedTo( 0 );
527 mRelatedToUid = store;
528}
523 529
524void Incidence::setRelatedTo(Incidence *relatedTo) 530void Incidence::setRelatedTo(Incidence *relatedTo)
525{ 531{
526 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 532 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
527 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 533 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
528 if (mReadOnly || mRelatedTo == relatedTo) return; 534 if (mReadOnly || mRelatedTo == relatedTo) return;
529 if(mRelatedTo) { 535 if(mRelatedTo) {
530 // updated(); 536 // updated();
531 mRelatedTo->removeRelation(this); 537 mRelatedTo->removeRelation(this);
532 } 538 }
533 mRelatedTo = relatedTo; 539 mRelatedTo = relatedTo;
534 if (mRelatedTo) { 540 if (mRelatedTo) {
535 mRelatedTo->addRelation(this); 541 mRelatedTo->addRelation(this);
536 mRelatedToUid = mRelatedTo->uid(); 542 mRelatedToUid = mRelatedTo->uid();
537 } else { 543 } else {
538 mRelatedToUid = ""; 544 mRelatedToUid = "";
539 } 545 }
540} 546}
541 547
542Incidence *Incidence::relatedTo() const 548Incidence *Incidence::relatedTo() const
543{ 549{
544 return mRelatedTo; 550 return mRelatedTo;
545} 551}
546 552
547QPtrList<Incidence> Incidence::relations() const 553QPtrList<Incidence> Incidence::relations() const
548{ 554{
549 return mRelations; 555 return mRelations;
550} 556}
551 557
552void Incidence::addRelationsToList(QPtrList<Incidence> *rel) 558void Incidence::addRelationsToList(QPtrList<Incidence> *rel)
553{ 559{
554 Incidence* inc; 560 Incidence* inc;
555 QPtrList<Incidence> Relations = relations(); 561 QPtrList<Incidence> Relations = relations();
556 for (inc=Relations.first();inc;inc=Relations.next()) { 562 for (inc=Relations.first();inc;inc=Relations.next()) {
557 inc->addRelationsToList( rel ); 563 inc->addRelationsToList( rel );
558 } 564 }
559 if ( rel->findRef( this ) == -1 ) 565 if ( rel->findRef( this ) == -1 )
560 rel->append( this ); 566 rel->append( this );
561} 567}
562 568
563void Incidence::addRelation(Incidence *event) 569void Incidence::addRelation(Incidence *event)
564{ 570{
565 setLastModifiedSubInvalid(); 571 setLastModifiedSubInvalid();
566 if( mRelations.findRef( event ) == -1 ) { 572 if( mRelations.findRef( event ) == -1 ) {
567 mRelations.append(event); 573 mRelations.append(event);
568 //updated(); 574 //updated();
569 } 575 }
570} 576}
571 577
572void Incidence::removeRelation(Incidence *event) 578void Incidence::removeRelation(Incidence *event)
573{ 579{
574 setLastModifiedSubInvalid(); 580 setLastModifiedSubInvalid();
575 mRelations.removeRef(event); 581 mRelations.removeRef(event);
576// if (event->getRelatedTo() == this) event->setRelatedTo(0); 582// if (event->getRelatedTo() == this) event->setRelatedTo(0);
577} 583}
578 584
579bool Incidence::recursOn(const QDate &qd) const 585bool Incidence::recursOn(const QDate &qd) const
580{ 586{
581 if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; 587 if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true;
582 else return false; 588 else return false;
583} 589}
584 590
585void Incidence::setExDates(const DateList &exDates) 591void Incidence::setExDates(const DateList &exDates)
586{ 592{
587 if (mReadOnly) return; 593 if (mReadOnly) return;
588 mExDates = exDates; 594 mExDates = exDates;
589 recurrence()->setRecurExDatesCount(mExDates.count()); 595 recurrence()->setRecurExDatesCount(mExDates.count());
590 596
591 updated(); 597 updated();
592} 598}
593 599
594void Incidence::addExDate(const QDate &date) 600void Incidence::addExDate(const QDate &date)
595{ 601{
596 if (mReadOnly) return; 602 if (mReadOnly) return;
597 mExDates.append(date); 603 mExDates.append(date);
598 604
599 recurrence()->setRecurExDatesCount(mExDates.count()); 605 recurrence()->setRecurExDatesCount(mExDates.count());
600 606
601 updated(); 607 updated();
602} 608}
603 609
604DateList Incidence::exDates() const 610DateList Incidence::exDates() const
605{ 611{
606 return mExDates; 612 return mExDates;
607} 613}
608 614
609bool Incidence::isException(const QDate &date) const 615bool Incidence::isException(const QDate &date) const
610{ 616{
611 DateList::ConstIterator it; 617 DateList::ConstIterator it;
612 for( it = mExDates.begin(); it != mExDates.end(); ++it ) { 618 for( it = mExDates.begin(); it != mExDates.end(); ++it ) {
613 if ( (*it) == date ) { 619 if ( (*it) == date ) {
614 return true; 620 return true;
615 } 621 }
616 } 622 }
617 623
618 return false; 624 return false;
619} 625}
620 626
621void Incidence::addAttachment(Attachment *attachment) 627void Incidence::addAttachment(Attachment *attachment)
622{ 628{
623 if (mReadOnly || !attachment) return; 629 if (mReadOnly || !attachment) return;
624 mAttachments.append(attachment); 630 mAttachments.append(attachment);
625 updated(); 631 updated();
626} 632}
627 633
628void Incidence::deleteAttachment(Attachment *attachment) 634void Incidence::deleteAttachment(Attachment *attachment)
629{ 635{
630 mAttachments.removeRef(attachment); 636 mAttachments.removeRef(attachment);
631} 637}
632 638
633void Incidence::deleteAttachments(const QString& mime) 639void Incidence::deleteAttachments(const QString& mime)
634{ 640{
635 Attachment *at = mAttachments.first(); 641 Attachment *at = mAttachments.first();
636 while (at) { 642 while (at) {
637 if (at->mimeType() == mime) 643 if (at->mimeType() == mime)
638 mAttachments.remove(); 644 mAttachments.remove();
639 else 645 else
640 at = mAttachments.next(); 646 at = mAttachments.next();
641 } 647 }
642} 648}
643 649
644QPtrList<Attachment> Incidence::attachments() const 650QPtrList<Attachment> Incidence::attachments() const
645{ 651{
646 return mAttachments; 652 return mAttachments;
647} 653}
648 654
649QPtrList<Attachment> Incidence::attachments(const QString& mime) const 655QPtrList<Attachment> Incidence::attachments(const QString& mime) const
650{ 656{
651 QPtrList<Attachment> attachments; 657 QPtrList<Attachment> attachments;
652 QPtrListIterator<Attachment> it( mAttachments ); 658 QPtrListIterator<Attachment> it( mAttachments );
653 Attachment *at; 659 Attachment *at;
654 while ( (at = it.current()) ) { 660 while ( (at = it.current()) ) {
655 if (at->mimeType() == mime) 661 if (at->mimeType() == mime)
656 attachments.append(at); 662 attachments.append(at);
657 ++it; 663 ++it;
658 } 664 }
659 665
660 return attachments; 666 return attachments;
661} 667}
662 668
663void Incidence::setResources(const QStringList &resources) 669void Incidence::setResources(const QStringList &resources)
664{ 670{
665 if (mReadOnly) return; 671 if (mReadOnly) return;
666 mResources = resources; 672 mResources = resources;
667 updated(); 673 updated();
668} 674}
669 675
670QStringList Incidence::resources() const 676QStringList Incidence::resources() const
671{ 677{
672 return mResources; 678 return mResources;
673} 679}
674 680
675 681
676void Incidence::setPriority(int priority) 682void Incidence::setPriority(int priority)
677{ 683{
678 if (mReadOnly) return; 684 if (mReadOnly) return;
679 mPriority = priority; 685 mPriority = priority;
680 updated(); 686 updated();
681} 687}
682 688
683int Incidence::priority() const 689int Incidence::priority() const
684{ 690{
685 return mPriority; 691 return mPriority;
686} 692}
687 693
688void Incidence::setSecrecy(int sec) 694void Incidence::setSecrecy(int sec)
689{ 695{
690 if (mReadOnly) return; 696 if (mReadOnly) return;
691 mSecrecy = sec; 697 mSecrecy = sec;
692 updated(); 698 updated();
693} 699}
694 700
695int Incidence::secrecy() const 701int Incidence::secrecy() const
696{ 702{
697 return mSecrecy; 703 return mSecrecy;
698} 704}
699 705
700QString Incidence::secrecyStr() const 706QString Incidence::secrecyStr() const
701{ 707{
702 return secrecyName(mSecrecy); 708 return secrecyName(mSecrecy);
703} 709}
704 710
705QString Incidence::secrecyName(int secrecy) 711QString Incidence::secrecyName(int secrecy)
706{ 712{
707 switch (secrecy) { 713 switch (secrecy) {
708 case SecrecyPublic: 714 case SecrecyPublic:
709 return i18n("Public"); 715 return i18n("Public");
710 break; 716 break;
711 case SecrecyPrivate: 717 case SecrecyPrivate:
712 return i18n("Private"); 718 return i18n("Private");
713 break; 719 break;
714 case SecrecyConfidential: 720 case SecrecyConfidential:
715 return i18n("Confidential"); 721 return i18n("Confidential");
716 break; 722 break;
717 default: 723 default:
718 return i18n("Undefined"); 724 return i18n("Undefined");
719 break; 725 break;
720 } 726 }
721} 727}
722 728
723QStringList Incidence::secrecyList() 729QStringList Incidence::secrecyList()
724{ 730{
725 QStringList list; 731 QStringList list;
726 list << secrecyName(SecrecyPublic); 732 list << secrecyName(SecrecyPublic);
727 list << secrecyName(SecrecyPrivate); 733 list << secrecyName(SecrecyPrivate);
728 list << secrecyName(SecrecyConfidential); 734 list << secrecyName(SecrecyConfidential);
729 735
730 return list; 736 return list;
731} 737}
732 738
733 739
734QPtrList<Alarm> Incidence::alarms() const 740QPtrList<Alarm> Incidence::alarms() const
735{ 741{
736 return mAlarms; 742 return mAlarms;
737} 743}
738 744
739Alarm* Incidence::newAlarm() 745Alarm* Incidence::newAlarm()
740{ 746{
741 Alarm* alarm = new Alarm(this); 747 Alarm* alarm = new Alarm(this);
742 mAlarms.append(alarm); 748 mAlarms.append(alarm);
743// updated(); 749// updated();
744 return alarm; 750 return alarm;
745} 751}
746 752
747void Incidence::addAlarm(Alarm *alarm) 753void Incidence::addAlarm(Alarm *alarm)
748{ 754{
749 mAlarms.append(alarm); 755 mAlarms.append(alarm);
750 updated(); 756 updated();
751} 757}
752 758
753void Incidence::removeAlarm(Alarm *alarm) 759void Incidence::removeAlarm(Alarm *alarm)
754{ 760{
755 mAlarms.removeRef(alarm); 761 mAlarms.removeRef(alarm);
756 updated(); 762 updated();
757} 763}
758 764
759void Incidence::clearAlarms() 765void Incidence::clearAlarms()
760{ 766{
761 mAlarms.clear(); 767 mAlarms.clear();
762 updated(); 768 updated();
763} 769}
764 770
765bool Incidence::isAlarmEnabled() const 771bool Incidence::isAlarmEnabled() const
766{ 772{
767 Alarm* alarm; 773 Alarm* alarm;
768 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 774 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
769 if (alarm->enabled()) 775 if (alarm->enabled())
770 return true; 776 return true;
771 } 777 }
772 return false; 778 return false;
773} 779}
774#include <stdlib.h> 780#include <stdlib.h>
775Recurrence *Incidence::recurrence() 781Recurrence *Incidence::recurrence()
776{ 782{
777 if ( ! mRecurrence ) { 783 if ( ! mRecurrence ) {
778 mRecurrence = new Recurrence(this); 784 mRecurrence = new Recurrence(this);
779 mRecurrence->setRecurStart( dtStart() ); 785 mRecurrence->setRecurStart( dtStart() );
780 mRecurrence->setRecurReadOnly( isReadOnly()); 786 mRecurrence->setRecurReadOnly( isReadOnly());
781 //qDebug("creating new recurence "); 787 //qDebug("creating new recurence ");
782 //abort(); 788 //abort();
783 } 789 }
784 return mRecurrence; 790 return mRecurrence;
785} 791}
786void Incidence::setRecurrence( Recurrence * r) 792void Incidence::setRecurrence( Recurrence * r)
787{ 793{
788 if ( mRecurrence ) 794 if ( mRecurrence )
789 delete mRecurrence; 795 delete mRecurrence;
790 mRecurrence = r; 796 mRecurrence = r;
791} 797}
792 798
793void Incidence::setLocation(const QString &location) 799void Incidence::setLocation(const QString &location)
794{ 800{
795 if (mReadOnly) return; 801 if (mReadOnly) return;
796 mLocation = location; 802 mLocation = location;
797 updated(); 803 updated();
798} 804}
799 805
800QString Incidence::location() const 806QString Incidence::location() const
801{ 807{
802 return mLocation; 808 return mLocation;
803} 809}
804QString Incidence::recurrenceText() const 810QString Incidence::recurrenceText() const
805{ 811{
806 if ( mRecurrence ) return mRecurrence->recurrenceText(); 812 if ( mRecurrence ) return mRecurrence->recurrenceText();
807 return i18n("No"); 813 return i18n("No");
808} 814}
809 815
810ushort Incidence::doesRecur() const 816ushort Incidence::doesRecur() const
811{ 817{
812 if ( mRecurrence ) return mRecurrence->doesRecur(); 818 if ( mRecurrence ) return mRecurrence->doesRecur();
813 else return Recurrence::rNone; 819 else return Recurrence::rNone;
814} 820}
815 821
816QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const 822QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
817{ 823{
818 QDateTime incidenceStart = dt; 824 QDateTime incidenceStart = dt;
819 *ok = false; 825 *ok = false;
820 if ( doesRecur() ) { 826 if ( doesRecur() ) {
821 bool last; 827 bool last;
822 mRecurrence->getPreviousDateTime( incidenceStart , &last ); 828 mRecurrence->getPreviousDateTime( incidenceStart , &last );
823 int count = 0; 829 int count = 0;
824 if ( !last ) { 830 if ( !last ) {
825 while ( !last ) { 831 while ( !last ) {
826 ++count; 832 ++count;
827 incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last ); 833 incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last );
828 if ( recursOn( incidenceStart.date() ) ) { 834 if ( recursOn( incidenceStart.date() ) ) {
829 last = true; // exit while llop 835 last = true; // exit while llop
830 } else { 836 } else {
831 if ( last ) { // no alarm on last recurrence 837 if ( last ) { // no alarm on last recurrence
832 return QDateTime (); 838 return QDateTime ();
833 } 839 }
834 int year = incidenceStart.date().year(); 840 int year = incidenceStart.date().year();
835 // workaround for bug in recurrence 841 // workaround for bug in recurrence
836 if ( count == 100 || year < 1000 || year > 5000 ) { 842 if ( count == 100 || year < 1000 || year > 5000 ) {
837 return QDateTime (); 843 return QDateTime ();
838 } 844 }
839 incidenceStart = incidenceStart.addSecs( 1 ); 845 incidenceStart = incidenceStart.addSecs( 1 );
840 } 846 }
841 } 847 }
842 } else { 848 } else {
843 return QDateTime (); 849 return QDateTime ();
844 } 850 }
845 } else { 851 } else {
846 if ( hasStartDate () ) { 852 if ( hasStartDate () ) {
847 incidenceStart = dtStart(); 853 incidenceStart = dtStart();
848 } 854 }
849 if ( typeID() == todoID ) { 855 if ( typeID() == todoID ) {
850 if ( ((Todo*)this)->hasDueDate() ) 856 if ( ((Todo*)this)->hasDueDate() )
851 incidenceStart = ((Todo*)this)->dtDue(); 857 incidenceStart = ((Todo*)this)->dtDue();
852 } 858 }
853 } 859 }
854 if ( incidenceStart > dt ) 860 if ( incidenceStart > dt )
855 *ok = true; 861 *ok = true;
856 return incidenceStart; 862 return incidenceStart;
857} 863}
858QDateTime Incidence::dtStart() const 864QDateTime Incidence::dtStart() const
859{ 865{
860 if ( doesRecur() ) { 866 if ( doesRecur() ) {
861 if ( typeID() == todoID ) { 867 if ( typeID() == todoID ) {
862 ((Todo*)this)->checkSetCompletedFalse(); 868 ((Todo*)this)->checkSetCompletedFalse();
863 } 869 }
864 } 870 }
865 return mDtStart; 871 return mDtStart;
866} 872}