summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /libkcal/incidence.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'libkcal/incidence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 7dd9bd2..8fcdc69 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -1,872 +1,874 @@
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//Added by qt3to4:
30#include <Q3PtrList>
29 31
30using namespace KCal; 32using namespace KCal;
31 33
32Incidence::Incidence() : 34Incidence::Incidence() :
33 IncidenceBase(), 35 IncidenceBase(),
34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) 36 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3)
35{ 37{
36 mRecurrence = 0;//new Recurrence(this); 38 mRecurrence = 0;//new Recurrence(this);
37 mCancelled = false; 39 mCancelled = false;
38 recreate(); 40 recreate();
39 mHasStartDate = true; 41 mHasStartDate = true;
40 mAlarms.setAutoDelete(true); 42 mAlarms.setAutoDelete(true);
41 mAttachments.setAutoDelete(true); 43 mAttachments.setAutoDelete(true);
42 mHasRecurrenceID = false; 44 mHasRecurrenceID = false;
43 mHoliday = false; 45 mHoliday = false;
44 mBirthday = false; 46 mBirthday = false;
45 mAnniversary = false; 47 mAnniversary = false;
46 48
47} 49}
48 50
49Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) 51Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
50{ 52{
51// TODO: reenable attributes currently commented out. 53// TODO: reenable attributes currently commented out.
52 mRevision = i.mRevision; 54 mRevision = i.mRevision;
53 mCreated = i.mCreated; 55 mCreated = i.mCreated;
54 mDescription = i.mDescription; 56 mDescription = i.mDescription;
55 mSummary = i.mSummary; 57 mSummary = i.mSummary;
56 mCategories = i.mCategories; 58 mCategories = i.mCategories;
57// Incidence *mRelatedTo; Incidence *mRelatedTo; 59// Incidence *mRelatedTo; Incidence *mRelatedTo;
58 mRelatedTo = 0; 60 mRelatedTo = 0;
59 mRelatedToUid = i.mRelatedToUid; 61 mRelatedToUid = i.mRelatedToUid;
60// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; 62// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations;
61 mExDates = i.mExDates; 63 mExDates = i.mExDates;
62 QPtrListIterator<Attachment> itat( i.mAttachments ); 64 Q3PtrListIterator<Attachment> itat( i.mAttachments );
63 Attachment *at; 65 Attachment *at;
64 while( (at = itat.current()) ) { 66 while( (at = itat.current()) ) {
65 Attachment *a = new Attachment( *at ); 67 Attachment *a = new Attachment( *at );
66 mAttachments.append( a ); 68 mAttachments.append( a );
67 ++itat; 69 ++itat;
68 } 70 }
69 mAttachments.setAutoDelete( true ); 71 mAttachments.setAutoDelete( true );
70 mResources = i.mResources; 72 mResources = i.mResources;
71 mSecrecy = i.mSecrecy; 73 mSecrecy = i.mSecrecy;
72 mPriority = i.mPriority; 74 mPriority = i.mPriority;
73 mLocation = i.mLocation; 75 mLocation = i.mLocation;
74 mCancelled = i.mCancelled; 76 mCancelled = i.mCancelled;
75 mHasStartDate = i.mHasStartDate; 77 mHasStartDate = i.mHasStartDate;
76 QPtrListIterator<Alarm> it( i.mAlarms ); 78 Q3PtrListIterator<Alarm> it( i.mAlarms );
77 const Alarm *a; 79 const Alarm *a;
78 while( (a = it.current()) ) { 80 while( (a = it.current()) ) {
79 Alarm *b = new Alarm( *a ); 81 Alarm *b = new Alarm( *a );
80 b->setParent( this ); 82 b->setParent( this );
81 mAlarms.append( b ); 83 mAlarms.append( b );
82 84
83 ++it; 85 ++it;
84 } 86 }
85 mAlarms.setAutoDelete(true); 87 mAlarms.setAutoDelete(true);
86 mHasRecurrenceID = i.mHasRecurrenceID; 88 mHasRecurrenceID = i.mHasRecurrenceID;
87 mRecurrenceID = i.mRecurrenceID; 89 mRecurrenceID = i.mRecurrenceID;
88 if ( i.mRecurrence ) 90 if ( i.mRecurrence )
89 mRecurrence = new Recurrence( *(i.mRecurrence), this ); 91 mRecurrence = new Recurrence( *(i.mRecurrence), this );
90 else 92 else
91 mRecurrence = 0; 93 mRecurrence = 0;
92 mHoliday = i.mHoliday ; 94 mHoliday = i.mHoliday ;
93 mBirthday = i.mBirthday; 95 mBirthday = i.mBirthday;
94 mAnniversary = i.mAnniversary; 96 mAnniversary = i.mAnniversary;
95} 97}
96 98
97Incidence::~Incidence() 99Incidence::~Incidence()
98{ 100{
99 101
100 Incidence *ev; 102 Incidence *ev;
101 QPtrList<Incidence> Relations = relations(); 103 Q3PtrList<Incidence> Relations = relations();
102 for (ev=Relations.first();ev;ev=Relations.next()) { 104 for (ev=Relations.first();ev;ev=Relations.next()) {
103 if (ev->relatedTo() == this) ev->setRelatedTo(0); 105 if (ev->relatedTo() == this) ev->setRelatedTo(0);
104 } 106 }
105 if (relatedTo()) relatedTo()->removeRelation(this); 107 if (relatedTo()) relatedTo()->removeRelation(this);
106 if ( mRecurrence ) 108 if ( mRecurrence )
107 delete mRecurrence; 109 delete mRecurrence;
108 110
109} 111}
110QString Incidence::durationText() 112QString Incidence::durationText()
111{ 113{
112 return "---"; 114 return "---";
113} 115}
114QString Incidence::durationText4Time( int offset ) 116QString Incidence::durationText4Time( int offset )
115{ 117{
116 int min = offset/60; 118 int min = offset/60;
117 int hours = min /60; 119 int hours = min /60;
118 min = min % 60; 120 min = min % 60;
119 int days = hours /24; 121 int days = hours /24;
120 hours = hours % 24; 122 hours = hours % 24;
121 123
122 if ( doesFloat() || ( min == 0 && hours == 0 ) ) { 124 if ( doesFloat() || ( min == 0 && hours == 0 ) ) {
123 if ( days == 1 ) 125 if ( days == 1 )
124 return "1" + i18n(" day"); 126 return "1" + i18n(" day");
125 else 127 else
126 return QString::number( days )+ i18n(" days"); 128 return QString::number( days )+ i18n(" days");
127 129
128 } 130 }
129 QString message = QString::number ( hours ) +":"; 131 QString message = QString::number ( hours ) +":";
130 if ( min < 10 ) message += "0"; 132 if ( min < 10 ) message += "0";
131 message += QString::number ( min ); 133 message += QString::number ( min );
132 if ( days > 0 ) { 134 if ( days > 0 ) {
133 if ( days == 1 ) 135 if ( days == 1 )
134 message = "1" + i18n(" day") + " "+message; 136 message = "1" + i18n(" day") + " "+message;
135 else 137 else
136 message = QString::number( days )+ i18n(" days") + " "+message; 138 message = QString::number( days )+ i18n(" days") + " "+message;
137 } 139 }
138 return message; 140 return message;
139} 141}
140bool Incidence::isHoliday() const 142bool Incidence::isHoliday() const
141{ 143{
142 return mHoliday; 144 return mHoliday;
143} 145}
144bool Incidence::isBirthday() const 146bool Incidence::isBirthday() const
145{ 147{
146 148
147 return mBirthday ; 149 return mBirthday ;
148} 150}
149bool Incidence::isAnniversary() const 151bool Incidence::isAnniversary() const
150{ 152{
151 return mAnniversary ; 153 return mAnniversary ;
152 154
153} 155}
154 156
155bool Incidence::hasRecurrenceID() const 157bool Incidence::hasRecurrenceID() const
156{ 158{
157 return mHasRecurrenceID; 159 return mHasRecurrenceID;
158} 160}
159 161
160void Incidence::setHasRecurrenceID( bool b ) 162void Incidence::setHasRecurrenceID( bool b )
161{ 163{
162 mHasRecurrenceID = b; 164 mHasRecurrenceID = b;
163} 165}
164 166
165void Incidence::setRecurrenceID(QDateTime d) 167void Incidence::setRecurrenceID(QDateTime d)
166{ 168{
167 mRecurrenceID = d; 169 mRecurrenceID = d;
168 mHasRecurrenceID = true; 170 mHasRecurrenceID = true;
169 updated(); 171 updated();
170} 172}
171QDateTime Incidence::recurrenceID () const 173QDateTime Incidence::recurrenceID () const
172{ 174{
173 return mRecurrenceID; 175 return mRecurrenceID;
174} 176}
175 177
176bool Incidence::cancelled() const 178bool Incidence::cancelled() const
177{ 179{
178 return mCancelled; 180 return mCancelled;
179} 181}
180void Incidence::setCancelled( bool b ) 182void Incidence::setCancelled( bool b )
181{ 183{
182 mCancelled = b; 184 mCancelled = b;
183 updated(); 185 updated();
184} 186}
185bool Incidence::hasStartDate() const 187bool Incidence::hasStartDate() const
186{ 188{
187 return mHasStartDate; 189 return mHasStartDate;
188} 190}
189 191
190void Incidence::setHasStartDate(bool f) 192void Incidence::setHasStartDate(bool f)
191{ 193{
192 if (mReadOnly) return; 194 if (mReadOnly) return;
193 mHasStartDate = f; 195 mHasStartDate = f;
194 updated(); 196 updated();
195} 197}
196 198
197// A string comparison that considers that null and empty are the same 199// A string comparison that considers that null and empty are the same
198static bool stringCompare( const QString& s1, const QString& s2 ) 200static bool stringCompare( const QString& s1, const QString& s2 )
199{ 201{
200 if ( s1.isEmpty() && s2.isEmpty() ) 202 if ( s1.isEmpty() && s2.isEmpty() )
201 return true; 203 return true;
202 return s1 == s2; 204 return s1 == s2;
203} 205}
204 206
205bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) 207bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
206{ 208{
207 209
208 if( i1.alarms().count() != i2.alarms().count() ) { 210 if( i1.alarms().count() != i2.alarms().count() ) {
209 return false; // no need to check further 211 return false; // no need to check further
210 } 212 }
211 if ( i1.alarms().count() > 0 ) { 213 if ( i1.alarms().count() > 0 ) {
212 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) 214 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) )
213 { 215 {
214 qDebug("alarm not equal "); 216 qDebug("alarm not equal ");
215 return false; 217 return false;
216 } 218 }
217 } 219 }
218#if 0 220#if 0
219 QPtrListIterator<Alarm> a1( i1.alarms() ); 221 Q3PtrListIterator<Alarm> a1( i1.alarms() );
220 QPtrListIterator<Alarm> a2( i2.alarms() ); 222 Q3PtrListIterator<Alarm> a2( i2.alarms() );
221 for( ; a1.current() && a2.current(); ++a1, ++a2 ) { 223 for( ; a1.current() && a2.current(); ++a1, ++a2 ) {
222 if( *a1.current() == *a2.current() ) { 224 if( *a1.current() == *a2.current() ) {
223 continue; 225 continue;
224 } 226 }
225 else { 227 else {
226 return false; 228 return false;
227 } 229 }
228 } 230 }
229#endif 231#endif
230 232
231 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { 233 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) {
232 if ( i1.hasRecurrenceID() ) { 234 if ( i1.hasRecurrenceID() ) {
233 if ( i1.recurrenceID() != i2.recurrenceID() ) 235 if ( i1.recurrenceID() != i2.recurrenceID() )
234 return false; 236 return false;
235 } 237 }
236 238
237 } else { 239 } else {
238 return false; 240 return false;
239 } 241 }
240 242
241 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) 243 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) )
242 return false; 244 return false;
243 if ( i1.hasStartDate() == i2.hasStartDate() ) { 245 if ( i1.hasStartDate() == i2.hasStartDate() ) {
244 if ( i1.hasStartDate() ) { 246 if ( i1.hasStartDate() ) {
245 if ( i1.dtStart() != i2.dtStart() ) 247 if ( i1.dtStart() != i2.dtStart() )
246 return false; 248 return false;
247 } 249 }
248 } else { 250 } else {
249 return false; 251 return false;
250 } 252 }
251 if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) { 253 if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) {
252 if (!( *i1.mRecurrence == *i2.mRecurrence) ) { 254 if (!( *i1.mRecurrence == *i2.mRecurrence) ) {
253 //qDebug("recurrence is NOT equal "); 255 //qDebug("recurrence is NOT equal ");
254 return false; 256 return false;
255 } 257 }
256 } else { 258 } else {
257 // one ( or both ) recurrence is 0 259 // one ( or both ) recurrence is 0
258 if ( i1.mRecurrence == 0 ) { 260 if ( i1.mRecurrence == 0 ) {
259 if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone ) 261 if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone )
260 return false; 262 return false;
261 } else { 263 } else {
262 // i1.mRecurrence != 0 264 // i1.mRecurrence != 0
263 // i2.mRecurrence == 0 265 // i2.mRecurrence == 0
264 if ( i1.mRecurrence->doesRecur() != Recurrence::rNone ) 266 if ( i1.mRecurrence->doesRecur() != Recurrence::rNone )
265 return false; 267 return false;
266 } 268 }
267 } 269 }
268 270
269 return 271 return
270 // i1.created() == i2.created() && 272 // i1.created() == i2.created() &&
271 stringCompare( i1.description(), i2.description() ) && 273 stringCompare( i1.description(), i2.description() ) &&
272 stringCompare( i1.summary(), i2.summary() ) && 274 stringCompare( i1.summary(), i2.summary() ) &&
273 i1.categories() == i2.categories() && 275 i1.categories() == i2.categories() &&
274 // no need to compare mRelatedTo 276 // no need to compare mRelatedTo
275 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && 277 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) &&
276 // i1.relations() == i2.relations() && 278 // i1.relations() == i2.relations() &&
277 i1.exDates() == i2.exDates() && 279 i1.exDates() == i2.exDates() &&
278 i1.attachments() == i2.attachments() && 280 i1.attachments() == i2.attachments() &&
279 i1.resources() == i2.resources() && 281 i1.resources() == i2.resources() &&
280 i1.secrecy() == i2.secrecy() && 282 i1.secrecy() == i2.secrecy() &&
281 i1.priority() == i2.priority() && 283 i1.priority() == i2.priority() &&
282 i1.cancelled() == i2.cancelled() && 284 i1.cancelled() == i2.cancelled() &&
283 stringCompare( i1.location(), i2.location() ); 285 stringCompare( i1.location(), i2.location() );
284} 286}
285 287
286Incidence* Incidence::recreateCloneException( QDate d ) 288Incidence* Incidence::recreateCloneException( QDate d )
287{ 289{
288 Incidence* newInc = clone(); 290 Incidence* newInc = clone();
289 newInc->recreate(); 291 newInc->recreate();
290 if ( doesRecur() ) { 292 if ( doesRecur() ) {
291 addExDate( d ); 293 addExDate( d );
292 newInc->recurrence()->unsetRecurs(); 294 newInc->recurrence()->unsetRecurs();
293 if ( typeID() == eventID ) { 295 if ( typeID() == eventID ) {
294 int len = dtStart().secsTo( ((Event*)this)->dtEnd()); 296 int len = dtStart().secsTo( ((Event*)this)->dtEnd());
295 QTime tim = dtStart().time(); 297 QTime tim = dtStart().time();
296 newInc->setDtStart( QDateTime(d, tim) ); 298 newInc->setDtStart( QDateTime(d, tim) );
297 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 299 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
298 } else { 300 } else {
299 int len = dtStart().secsTo( ((Todo*)this)->dtDue()); 301 int len = dtStart().secsTo( ((Todo*)this)->dtDue());
300 QTime tim = ((Todo*)this)->dtDue().time(); 302 QTime tim = ((Todo*)this)->dtDue().time();
301 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); 303 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) );
302 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); 304 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) );
303 ((Todo*)this)->setRecurDates(); 305 ((Todo*)this)->setRecurDates();
304 } 306 }
305 newInc->setExDates( DateList () ); 307 newInc->setExDates( DateList () );
306 } 308 }
307 return newInc; 309 return newInc;
308} 310}
309 311
310void Incidence::recreate() 312void Incidence::recreate()
311{ 313{
312 setCreated(QDateTime::currentDateTime()); 314 setCreated(QDateTime::currentDateTime());
313 315
314 setUid(CalFormat::createUniqueId()); 316 setUid(CalFormat::createUniqueId());
315 317
316 setRevision(0); 318 setRevision(0);
317 setIDStr( ":" ); 319 setIDStr( ":" );
318 setLastModified(QDateTime::currentDateTime()); 320 setLastModified(QDateTime::currentDateTime());
319} 321}
320void Incidence::cloneRelations( Incidence * newInc ) 322void Incidence::cloneRelations( Incidence * newInc )
321{ 323{
322 // newInc is already a clone of this incidence 324 // newInc is already a clone of this incidence
323 Incidence * inc; 325 Incidence * inc;
324 Incidence * cloneInc; 326 Incidence * cloneInc;
325 QPtrList<Incidence> Relations = relations(); 327 Q3PtrList<Incidence> Relations = relations();
326 for (inc=Relations.first();inc;inc=Relations.next()) { 328 for (inc=Relations.first();inc;inc=Relations.next()) {
327 cloneInc = inc->clone(); 329 cloneInc = inc->clone();
328 cloneInc->recreate(); 330 cloneInc->recreate();
329 cloneInc->setRelatedTo( newInc ); 331 cloneInc->setRelatedTo( newInc );
330 inc->cloneRelations( cloneInc ); 332 inc->cloneRelations( cloneInc );
331 } 333 }
332} 334}
333void Incidence::setReadOnly( bool readOnly ) 335void Incidence::setReadOnly( bool readOnly )
334{ 336{
335 IncidenceBase::setReadOnly( readOnly ); 337 IncidenceBase::setReadOnly( readOnly );
336 if ( mRecurrence ) 338 if ( mRecurrence )
337 mRecurrence->setRecurReadOnly( readOnly); 339 mRecurrence->setRecurReadOnly( readOnly);
338} 340}
339void Incidence::setLastModifiedSubInvalid() 341void Incidence::setLastModifiedSubInvalid()
340{ 342{
341 mLastModifiedSub = QDateTime(); 343 mLastModifiedSub = QDateTime();
342 if ( mRelatedTo ) 344 if ( mRelatedTo )
343 mRelatedTo->setLastModifiedSubInvalid(); 345 mRelatedTo->setLastModifiedSubInvalid();
344} 346}
345QString Incidence::lastModifiedSubSortKey() const 347QString Incidence::lastModifiedSubSortKey() const
346{ 348{
347 if ( mLastModifiedSubSortKey.isEmpty() ) 349 if ( mLastModifiedSubSortKey.isEmpty() )
348 return lastModifiedSortKey(); 350 return lastModifiedSortKey();
349 return mLastModifiedSubSortKey; 351 return mLastModifiedSubSortKey;
350} 352}
351QDateTime Incidence::lastModifiedSub() 353QDateTime Incidence::lastModifiedSub()
352{ 354{
353 if ( !mRelations.count() ) 355 if ( !mRelations.count() )
354 return lastModified(); 356 return lastModified();
355 if ( mLastModifiedSub.isValid() ) 357 if ( mLastModifiedSub.isValid() )
356 return mLastModifiedSub; 358 return mLastModifiedSub;
357 mLastModifiedSub = lastModified(); 359 mLastModifiedSub = lastModified();
358 Incidence * inc; 360 Incidence * inc;
359 QPtrList<Incidence> Relations = relations(); 361 Q3PtrList<Incidence> Relations = relations();
360 for (inc=Relations.first();inc;inc=Relations.next()) { 362 for (inc=Relations.first();inc;inc=Relations.next()) {
361 if ( inc->lastModifiedSub() > mLastModifiedSub ) 363 if ( inc->lastModifiedSub() > mLastModifiedSub )
362 mLastModifiedSub = inc->lastModifiedSub(); 364 mLastModifiedSub = inc->lastModifiedSub();
363 } 365 }
364 mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d", 366 mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d",
365 mLastModifiedSub.date().year(), 367 mLastModifiedSub.date().year(),
366 mLastModifiedSub.date().month(), 368 mLastModifiedSub.date().month(),
367 mLastModifiedSub.date().day(), 369 mLastModifiedSub.date().day(),
368 mLastModifiedSub.time().hour(), 370 mLastModifiedSub.time().hour(),
369 mLastModifiedSub.time().minute(), 371 mLastModifiedSub.time().minute(),
370 mLastModifiedSub.time().second() ); 372 mLastModifiedSub.time().second() );
371 return mLastModifiedSub; 373 return mLastModifiedSub;
372} 374}
373void Incidence::setCreated(QDateTime created) 375void Incidence::setCreated(QDateTime created)
374{ 376{
375 if (mReadOnly) return; 377 if (mReadOnly) return;
376 mCreated = getEvenTime(created); 378 mCreated = getEvenTime(created);
377} 379}
378 380
379QDateTime Incidence::created() const 381QDateTime Incidence::created() const
380{ 382{
381 return mCreated; 383 return mCreated;
382} 384}
383 385
384void Incidence::setRevision(int rev) 386void Incidence::setRevision(int rev)
385{ 387{
386 if (mReadOnly) return; 388 if (mReadOnly) return;
387 mRevision = rev; 389 mRevision = rev;
388 390
389 updated(); 391 updated();
390} 392}
391 393
392int Incidence::revision() const 394int Incidence::revision() const
393{ 395{
394 return mRevision; 396 return mRevision;
395} 397}
396 398
397void Incidence::setDtStart(const QDateTime &dtStart) 399void Incidence::setDtStart(const QDateTime &dtStart)
398{ 400{
399 401
400 QDateTime dt = getEvenTime(dtStart); 402 QDateTime dt = getEvenTime(dtStart);
401 403
402 if ( mRecurrence ) 404 if ( mRecurrence )
403 mRecurrence->setRecurStart( dt); 405 mRecurrence->setRecurStart( dt);
404 IncidenceBase::setDtStart( dt ); 406 IncidenceBase::setDtStart( dt );
405} 407}
406 408
407void Incidence::setDescription(const QString &description) 409void Incidence::setDescription(const QString &description)
408{ 410{
409 if (mReadOnly) return; 411 if (mReadOnly) return;
410 mDescription = description; 412 mDescription = description;
411 updated(); 413 updated();
412} 414}
413 415
414QString Incidence::description() const 416QString Incidence::description() const
415{ 417{
416 return mDescription; 418 return mDescription;
417} 419}
418 420
419 421
420void Incidence::setSummary(const QString &summary) 422void Incidence::setSummary(const QString &summary)
421{ 423{
422 if (mReadOnly) return; 424 if (mReadOnly) return;
423 mSummary = summary; 425 mSummary = summary;
424 updated(); 426 updated();
425} 427}
426 428
427QString Incidence::summary() const 429QString Incidence::summary() const
428{ 430{
429 return mSummary; 431 return mSummary;
430} 432}
431void Incidence::checkCategories() 433void Incidence::checkCategories()
432{ 434{
433 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); 435 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday"));
434 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); 436 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday"));
435 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); 437 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary"));
436} 438}
437 439
438void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false 440void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false
439{ 441{
440 if (mReadOnly) return; 442 if (mReadOnly) return;
441 int i; 443 int i;
442 for( i = 0; i < categories.count(); ++i ) { 444 for( i = 0; i < categories.count(); ++i ) {
443 if ( !mCategories.contains (categories[i])) 445 if ( !mCategories.contains (categories[i]))
444 mCategories.append( categories[i] ); 446 mCategories.append( categories[i] );
445 } 447 }
446 checkCategories(); 448 checkCategories();
447 updated(); 449 updated();
448 if ( addToRelations ) { 450 if ( addToRelations ) {
449 Incidence * inc; 451 Incidence * inc;
450 QPtrList<Incidence> Relations = relations(); 452 Q3PtrList<Incidence> Relations = relations();
451 for (inc=Relations.first();inc;inc=Relations.next()) { 453 for (inc=Relations.first();inc;inc=Relations.next()) {
452 inc->addCategories( categories, true ); 454 inc->addCategories( categories, true );
453 } 455 }
454 } 456 }
455} 457}
456 458
457void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false 459void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false
458{ 460{
459 if (mReadOnly) return; 461 if (mReadOnly) return;
460 mCategories = categories; 462 mCategories = categories;
461 checkCategories(); 463 checkCategories();
462 updated(); 464 updated();
463 if ( setForRelations ) { 465 if ( setForRelations ) {
464 Incidence * inc; 466 Incidence * inc;
465 QPtrList<Incidence> Relations = relations(); 467 Q3PtrList<Incidence> Relations = relations();
466 for (inc=Relations.first();inc;inc=Relations.next()) { 468 for (inc=Relations.first();inc;inc=Relations.next()) {
467 inc->setCategories( categories, true ); 469 inc->setCategories( categories, true );
468 } 470 }
469 } 471 }
470} 472}
471 473
472// TODO: remove setCategories(QString) function 474// TODO: remove setCategories(QString) function
473void Incidence::setCategories(const QString &catStr) 475void Incidence::setCategories(const QString &catStr)
474{ 476{
475 if (mReadOnly) return; 477 if (mReadOnly) return;
476 mCategories.clear(); 478 mCategories.clear();
477 479
478 if (catStr.isEmpty()) return; 480 if (catStr.isEmpty()) return;
479 481
480 mCategories = QStringList::split(",",catStr); 482 mCategories = QStringList::split(",",catStr);
481 483
482 QStringList::Iterator it; 484 QStringList::Iterator it;
483 for(it = mCategories.begin();it != mCategories.end(); ++it) { 485 for(it = mCategories.begin();it != mCategories.end(); ++it) {
484 *it = (*it).stripWhiteSpace(); 486 *it = (*it).stripWhiteSpace();
485 } 487 }
486 checkCategories(); 488 checkCategories();
487 updated(); 489 updated();
488} 490}
489// using this makes filtering 3 times faster 491// using this makes filtering 3 times faster
490QStringList* Incidence::categoriesP() 492QStringList* Incidence::categoriesP()
491{ 493{
492 return &mCategories; 494 return &mCategories;
493} 495}
494 496
495QStringList Incidence::categories() const 497QStringList Incidence::categories() const
496{ 498{
497 return mCategories; 499 return mCategories;
498} 500}
499 501
500QString Incidence::categoriesStr() 502QString Incidence::categoriesStr()
501{ 503{
502 return mCategories.join(","); 504 return mCategories.join(",");
503} 505}
504QString Incidence::categoriesStrWithSpace() 506QString Incidence::categoriesStrWithSpace()
505{ 507{
506 return mCategories.join(", "); 508 return mCategories.join(", ");
507} 509}
508 510
509void Incidence::setRelatedToUid(const QString &relatedToUid) 511void Incidence::setRelatedToUid(const QString &relatedToUid)
510{ 512{
511 if (mReadOnly) return; 513 if (mReadOnly) return;
512 mRelatedToUid = relatedToUid; 514 mRelatedToUid = relatedToUid;
513} 515}
514void Incidence::clearRelations() 516void Incidence::clearRelations()
515{ 517{
516 mRelatedTo = 0; 518 mRelatedTo = 0;
517 mRelations.clear(); 519 mRelations.clear();
518} 520}
519QString Incidence::relatedToUid() const 521QString Incidence::relatedToUid() const
520{ 522{
521 return mRelatedToUid; 523 return mRelatedToUid;
522} 524}
523void Incidence::resetRelatedTo() 525void Incidence::resetRelatedTo()
524{ 526{
525 QString store = mRelatedToUid; 527 QString store = mRelatedToUid;
526 setRelatedTo( 0 ); 528 setRelatedTo( 0 );
527 mRelatedToUid = store; 529 mRelatedToUid = store;
528} 530}
529 531
530void Incidence::setRelatedTo(Incidence *relatedTo) 532void Incidence::setRelatedTo(Incidence *relatedTo)
531{ 533{
532 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 534 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
533 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 535 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
534 if (mReadOnly || mRelatedTo == relatedTo) return; 536 if (mReadOnly || mRelatedTo == relatedTo) return;
535 if(mRelatedTo) { 537 if(mRelatedTo) {
536 // updated(); 538 // updated();
537 mRelatedTo->removeRelation(this); 539 mRelatedTo->removeRelation(this);
538 } 540 }
539 mRelatedTo = relatedTo; 541 mRelatedTo = relatedTo;
540 if (mRelatedTo) { 542 if (mRelatedTo) {
541 mRelatedTo->addRelation(this); 543 mRelatedTo->addRelation(this);
542 mRelatedToUid = mRelatedTo->uid(); 544 mRelatedToUid = mRelatedTo->uid();
543 } else { 545 } else {
544 mRelatedToUid = ""; 546 mRelatedToUid = "";
545 } 547 }
546} 548}
547 549
548Incidence *Incidence::relatedTo() const 550Incidence *Incidence::relatedTo() const
549{ 551{
550 return mRelatedTo; 552 return mRelatedTo;
551} 553}
552 554
553QPtrList<Incidence> Incidence::relations() const 555Q3PtrList<Incidence> Incidence::relations() const
554{ 556{
555 return mRelations; 557 return mRelations;
556} 558}
557 559
558void Incidence::addRelationsToList(QPtrList<Incidence> *rel) 560void Incidence::addRelationsToList(Q3PtrList<Incidence> *rel)
559{ 561{
560 Incidence* inc; 562 Incidence* inc;
561 QPtrList<Incidence> Relations = relations(); 563 Q3PtrList<Incidence> Relations = relations();
562 for (inc=Relations.first();inc;inc=Relations.next()) { 564 for (inc=Relations.first();inc;inc=Relations.next()) {
563 inc->addRelationsToList( rel ); 565 inc->addRelationsToList( rel );
564 } 566 }
565 if ( rel->findRef( this ) == -1 ) 567 if ( rel->findRef( this ) == -1 )
566 rel->append( this ); 568 rel->append( this );
567} 569}
568 570
569void Incidence::addRelation(Incidence *event) 571void Incidence::addRelation(Incidence *event)
570{ 572{
571 setLastModifiedSubInvalid(); 573 setLastModifiedSubInvalid();
572 if( mRelations.findRef( event ) == -1 ) { 574 if( mRelations.findRef( event ) == -1 ) {
573 mRelations.append(event); 575 mRelations.append(event);
574 //updated(); 576 //updated();
575 } 577 }
576} 578}
577 579
578void Incidence::removeRelation(Incidence *event) 580void Incidence::removeRelation(Incidence *event)
579{ 581{
580 setLastModifiedSubInvalid(); 582 setLastModifiedSubInvalid();
581 mRelations.removeRef(event); 583 mRelations.removeRef(event);
582// if (event->getRelatedTo() == this) event->setRelatedTo(0); 584// if (event->getRelatedTo() == this) event->setRelatedTo(0);
583} 585}
584 586
585bool Incidence::recursOn(const QDate &qd) const 587bool Incidence::recursOn(const QDate &qd) const
586{ 588{
587 if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; 589 if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true;
588 else return false; 590 else return false;
589} 591}
590 592
591void Incidence::setExDates(const DateList &exDates) 593void Incidence::setExDates(const DateList &exDates)
592{ 594{
593 if (mReadOnly) return; 595 if (mReadOnly) return;
594 mExDates = exDates; 596 mExDates = exDates;
595 recurrence()->setRecurExDatesCount(mExDates.count()); 597 recurrence()->setRecurExDatesCount(mExDates.count());
596 598
597 updated(); 599 updated();
598} 600}
599 601
600void Incidence::addExDate(const QDate &date) 602void Incidence::addExDate(const QDate &date)
601{ 603{
602 if (mReadOnly) return; 604 if (mReadOnly) return;
603 mExDates.append(date); 605 mExDates.append(date);
604 606
605 recurrence()->setRecurExDatesCount(mExDates.count()); 607 recurrence()->setRecurExDatesCount(mExDates.count());
606 608
607 updated(); 609 updated();
608} 610}
609 611
610DateList Incidence::exDates() const 612DateList Incidence::exDates() const
611{ 613{
612 return mExDates; 614 return mExDates;
613} 615}
614 616
615bool Incidence::isException(const QDate &date) const 617bool Incidence::isException(const QDate &date) const
616{ 618{
617 DateList::ConstIterator it; 619 DateList::ConstIterator it;
618 for( it = mExDates.begin(); it != mExDates.end(); ++it ) { 620 for( it = mExDates.begin(); it != mExDates.end(); ++it ) {
619 if ( (*it) == date ) { 621 if ( (*it) == date ) {
620 return true; 622 return true;
621 } 623 }
622 } 624 }
623 625
624 return false; 626 return false;
625} 627}
626 628
627void Incidence::addAttachment(Attachment *attachment) 629void Incidence::addAttachment(Attachment *attachment)
628{ 630{
629 if (mReadOnly || !attachment) return; 631 if (mReadOnly || !attachment) return;
630 mAttachments.append(attachment); 632 mAttachments.append(attachment);
631 updated(); 633 updated();
632} 634}
633 635
634void Incidence::deleteAttachment(Attachment *attachment) 636void Incidence::deleteAttachment(Attachment *attachment)
635{ 637{
636 mAttachments.removeRef(attachment); 638 mAttachments.removeRef(attachment);
637} 639}
638 640
639void Incidence::deleteAttachments(const QString& mime) 641void Incidence::deleteAttachments(const QString& mime)
640{ 642{
641 Attachment *at = mAttachments.first(); 643 Attachment *at = mAttachments.first();
642 while (at) { 644 while (at) {
643 if (at->mimeType() == mime) 645 if (at->mimeType() == mime)
644 mAttachments.remove(); 646 mAttachments.remove();
645 else 647 else
646 at = mAttachments.next(); 648 at = mAttachments.next();
647 } 649 }
648} 650}
649 651
650QPtrList<Attachment> Incidence::attachments() const 652Q3PtrList<Attachment> Incidence::attachments() const
651{ 653{
652 return mAttachments; 654 return mAttachments;
653} 655}
654 656
655QPtrList<Attachment> Incidence::attachments(const QString& mime) const 657Q3PtrList<Attachment> Incidence::attachments(const QString& mime) const
656{ 658{
657 QPtrList<Attachment> attachments; 659 Q3PtrList<Attachment> attachments;
658 QPtrListIterator<Attachment> it( mAttachments ); 660 Q3PtrListIterator<Attachment> it( mAttachments );
659 Attachment *at; 661 Attachment *at;
660 while ( (at = it.current()) ) { 662 while ( (at = it.current()) ) {
661 if (at->mimeType() == mime) 663 if (at->mimeType() == mime)
662 attachments.append(at); 664 attachments.append(at);
663 ++it; 665 ++it;
664 } 666 }
665 667
666 return attachments; 668 return attachments;
667} 669}
668 670
669void Incidence::setResources(const QStringList &resources) 671void Incidence::setResources(const QStringList &resources)
670{ 672{
671 if (mReadOnly) return; 673 if (mReadOnly) return;
672 mResources = resources; 674 mResources = resources;
673 updated(); 675 updated();
674} 676}
675 677
676QStringList Incidence::resources() const 678QStringList Incidence::resources() const
677{ 679{
678 return mResources; 680 return mResources;
679} 681}
680 682
681 683
682void Incidence::setPriority(int priority) 684void Incidence::setPriority(int priority)
683{ 685{
684 if (mReadOnly) return; 686 if (mReadOnly) return;
685 mPriority = priority; 687 mPriority = priority;
686 updated(); 688 updated();
687} 689}
688 690
689int Incidence::priority() const 691int Incidence::priority() const
690{ 692{
691 return mPriority; 693 return mPriority;
692} 694}
693 695
694void Incidence::setSecrecy(int sec) 696void Incidence::setSecrecy(int sec)
695{ 697{
696 if (mReadOnly) return; 698 if (mReadOnly) return;
697 mSecrecy = sec; 699 mSecrecy = sec;
698 updated(); 700 updated();
699} 701}
700 702
701int Incidence::secrecy() const 703int Incidence::secrecy() const
702{ 704{
703 return mSecrecy; 705 return mSecrecy;
704} 706}
705 707
706QString Incidence::secrecyStr() const 708QString Incidence::secrecyStr() const
707{ 709{
708 return secrecyName(mSecrecy); 710 return secrecyName(mSecrecy);
709} 711}
710 712
711QString Incidence::secrecyName(int secrecy) 713QString Incidence::secrecyName(int secrecy)
712{ 714{
713 switch (secrecy) { 715 switch (secrecy) {
714 case SecrecyPublic: 716 case SecrecyPublic:
715 return i18n("Public"); 717 return i18n("Public");
716 break; 718 break;
717 case SecrecyPrivate: 719 case SecrecyPrivate:
718 return i18n("Private"); 720 return i18n("Private");
719 break; 721 break;
720 case SecrecyConfidential: 722 case SecrecyConfidential:
721 return i18n("Confidential"); 723 return i18n("Confidential");
722 break; 724 break;
723 default: 725 default:
724 return i18n("Undefined"); 726 return i18n("Undefined");
725 break; 727 break;
726 } 728 }
727} 729}
728 730
729QStringList Incidence::secrecyList() 731QStringList Incidence::secrecyList()
730{ 732{
731 QStringList list; 733 QStringList list;
732 list << secrecyName(SecrecyPublic); 734 list << secrecyName(SecrecyPublic);
733 list << secrecyName(SecrecyPrivate); 735 list << secrecyName(SecrecyPrivate);
734 list << secrecyName(SecrecyConfidential); 736 list << secrecyName(SecrecyConfidential);
735 737
736 return list; 738 return list;
737} 739}
738 740
739 741
740QPtrList<Alarm> Incidence::alarms() const 742Q3PtrList<Alarm> Incidence::alarms() const
741{ 743{
742 return mAlarms; 744 return mAlarms;
743} 745}
744 746
745Alarm* Incidence::newAlarm() 747Alarm* Incidence::newAlarm()
746{ 748{
747 Alarm* alarm = new Alarm(this); 749 Alarm* alarm = new Alarm(this);
748 mAlarms.append(alarm); 750 mAlarms.append(alarm);
749// updated(); 751// updated();
750 return alarm; 752 return alarm;
751} 753}
752 754
753void Incidence::addAlarm(Alarm *alarm) 755void Incidence::addAlarm(Alarm *alarm)
754{ 756{
755 mAlarms.append(alarm); 757 mAlarms.append(alarm);
756 updated(); 758 updated();
757} 759}
758 760
759void Incidence::removeAlarm(Alarm *alarm) 761void Incidence::removeAlarm(Alarm *alarm)
760{ 762{
761 mAlarms.removeRef(alarm); 763 mAlarms.removeRef(alarm);
762 updated(); 764 updated();
763} 765}
764 766
765void Incidence::clearAlarms() 767void Incidence::clearAlarms()
766{ 768{
767 mAlarms.clear(); 769 mAlarms.clear();
768 updated(); 770 updated();
769} 771}
770 772
771bool Incidence::isAlarmEnabled() const 773bool Incidence::isAlarmEnabled() const
772{ 774{
773 Alarm* alarm; 775 Alarm* alarm;
774 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 776 for (Q3PtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
775 if (alarm->enabled()) 777 if (alarm->enabled())
776 return true; 778 return true;
777 } 779 }
778 return false; 780 return false;
779} 781}
780#include <stdlib.h> 782#include <stdlib.h>
781Recurrence *Incidence::recurrence() 783Recurrence *Incidence::recurrence()
782{ 784{
783 if ( ! mRecurrence ) { 785 if ( ! mRecurrence ) {
784 mRecurrence = new Recurrence(this); 786 mRecurrence = new Recurrence(this);
785 mRecurrence->setRecurStart( dtStart() ); 787 mRecurrence->setRecurStart( dtStart() );
786 mRecurrence->setRecurReadOnly( isReadOnly()); 788 mRecurrence->setRecurReadOnly( isReadOnly());
787 //qDebug("creating new recurence "); 789 //qDebug("creating new recurence ");
788 //abort(); 790 //abort();
789 } 791 }
790 return mRecurrence; 792 return mRecurrence;
791} 793}
792void Incidence::setRecurrence( Recurrence * r) 794void Incidence::setRecurrence( Recurrence * r)
793{ 795{
794 if ( mRecurrence ) 796 if ( mRecurrence )
795 delete mRecurrence; 797 delete mRecurrence;
796 mRecurrence = r; 798 mRecurrence = r;
797} 799}
798 800
799void Incidence::setLocation(const QString &location) 801void Incidence::setLocation(const QString &location)
800{ 802{
801 if (mReadOnly) return; 803 if (mReadOnly) return;
802 mLocation = location; 804 mLocation = location;
803 updated(); 805 updated();
804} 806}
805 807
806QString Incidence::location() const 808QString Incidence::location() const
807{ 809{
808 return mLocation; 810 return mLocation;
809} 811}
810QString Incidence::recurrenceText() const 812QString Incidence::recurrenceText() const
811{ 813{
812 if ( mRecurrence ) return mRecurrence->recurrenceText(); 814 if ( mRecurrence ) return mRecurrence->recurrenceText();
813 return i18n("No"); 815 return i18n("No");
814} 816}
815 817
816ushort Incidence::doesRecur() const 818ushort Incidence::doesRecur() const
817{ 819{
818 if ( mRecurrence ) return mRecurrence->doesRecur(); 820 if ( mRecurrence ) return mRecurrence->doesRecur();
819 else return Recurrence::rNone; 821 else return Recurrence::rNone;
820} 822}
821 823
822QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const 824QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
823{ 825{
824 QDateTime incidenceStart = dt; 826 QDateTime incidenceStart = dt;
825 *ok = false; 827 *ok = false;
826 if ( doesRecur() ) { 828 if ( doesRecur() ) {
827 bool last; 829 bool last;
828 mRecurrence->getPreviousDateTime( incidenceStart , &last ); 830 mRecurrence->getPreviousDateTime( incidenceStart , &last );
829 int count = 0; 831 int count = 0;
830 if ( !last ) { 832 if ( !last ) {
831 while ( !last ) { 833 while ( !last ) {
832 ++count; 834 ++count;
833 incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last ); 835 incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last );
834 if ( recursOn( incidenceStart.date() ) ) { 836 if ( recursOn( incidenceStart.date() ) ) {
835 last = true; // exit while llop 837 last = true; // exit while llop
836 } else { 838 } else {
837 if ( last ) { // no alarm on last recurrence 839 if ( last ) { // no alarm on last recurrence
838 return QDateTime (); 840 return QDateTime ();
839 } 841 }
840 int year = incidenceStart.date().year(); 842 int year = incidenceStart.date().year();
841 // workaround for bug in recurrence 843 // workaround for bug in recurrence
842 if ( count == 100 || year < 1000 || year > 5000 ) { 844 if ( count == 100 || year < 1000 || year > 5000 ) {
843 return QDateTime (); 845 return QDateTime ();
844 } 846 }
845 incidenceStart = incidenceStart.addSecs( 1 ); 847 incidenceStart = incidenceStart.addSecs( 1 );
846 } 848 }
847 } 849 }
848 } else { 850 } else {
849 return QDateTime (); 851 return QDateTime ();
850 } 852 }
851 } else { 853 } else {
852 if ( hasStartDate () ) { 854 if ( hasStartDate () ) {
853 incidenceStart = dtStart(); 855 incidenceStart = dtStart();
854 } 856 }
855 if ( typeID() == todoID ) { 857 if ( typeID() == todoID ) {
856 if ( ((Todo*)this)->hasDueDate() ) 858 if ( ((Todo*)this)->hasDueDate() )
857 incidenceStart = ((Todo*)this)->dtDue(); 859 incidenceStart = ((Todo*)this)->dtDue();
858 } 860 }
859 } 861 }
860 if ( incidenceStart > dt ) 862 if ( incidenceStart > dt )
861 *ok = true; 863 *ok = true;
862 return incidenceStart; 864 return incidenceStart;
863} 865}
864QDateTime Incidence::dtStart() const 866QDateTime Incidence::dtStart() const
865{ 867{
866 if ( doesRecur() ) { 868 if ( doesRecur() ) {
867 if ( typeID() == todoID ) { 869 if ( typeID() == todoID ) {
868 ((Todo*)this)->checkSetCompletedFalse(); 870 ((Todo*)this)->checkSetCompletedFalse();
869 } 871 }
870 } 872 }
871 return mDtStart; 873 return mDtStart;
872} 874}