-rw-r--r-- | libkcal/incidence.cpp | 8 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 56c9801..55ac6d4 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -81,519 +81,523 @@ Incidence::~Incidence() | |||
81 | Incidence *ev; | 81 | Incidence *ev; |
82 | QPtrList<Incidence> Relations = relations(); | 82 | QPtrList<Incidence> Relations = relations(); |
83 | for (ev=Relations.first();ev;ev=Relations.next()) { | 83 | for (ev=Relations.first();ev;ev=Relations.next()) { |
84 | if (ev->relatedTo() == this) ev->setRelatedTo(0); | 84 | if (ev->relatedTo() == this) ev->setRelatedTo(0); |
85 | } | 85 | } |
86 | if (relatedTo()) relatedTo()->removeRelation(this); | 86 | if (relatedTo()) relatedTo()->removeRelation(this); |
87 | delete mRecurrence; | 87 | delete mRecurrence; |
88 | 88 | ||
89 | } | 89 | } |
90 | 90 | ||
91 | bool Incidence::cancelled() const | 91 | bool Incidence::cancelled() const |
92 | { | 92 | { |
93 | return mCancelled; | 93 | return mCancelled; |
94 | } | 94 | } |
95 | void Incidence::setCancelled( bool b ) | 95 | void Incidence::setCancelled( bool b ) |
96 | { | 96 | { |
97 | mCancelled = b; | 97 | mCancelled = b; |
98 | updated(); | 98 | updated(); |
99 | } | 99 | } |
100 | bool Incidence::hasStartDate() const | 100 | bool Incidence::hasStartDate() const |
101 | { | 101 | { |
102 | return mHasStartDate; | 102 | return mHasStartDate; |
103 | } | 103 | } |
104 | 104 | ||
105 | void Incidence::setHasStartDate(bool f) | 105 | void Incidence::setHasStartDate(bool f) |
106 | { | 106 | { |
107 | if (mReadOnly) return; | 107 | if (mReadOnly) return; |
108 | mHasStartDate = f; | 108 | mHasStartDate = f; |
109 | updated(); | 109 | updated(); |
110 | } | 110 | } |
111 | 111 | ||
112 | // A string comparison that considers that null and empty are the same | 112 | // A string comparison that considers that null and empty are the same |
113 | static bool stringCompare( const QString& s1, const QString& s2 ) | 113 | static bool stringCompare( const QString& s1, const QString& s2 ) |
114 | { | 114 | { |
115 | if ( s1.isEmpty() && s2.isEmpty() ) | 115 | if ( s1.isEmpty() && s2.isEmpty() ) |
116 | return true; | 116 | return true; |
117 | return s1 == s2; | 117 | return s1 == s2; |
118 | } | 118 | } |
119 | 119 | ||
120 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | 120 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) |
121 | { | 121 | { |
122 | 122 | ||
123 | if( i1.alarms().count() != i2.alarms().count() ) { | 123 | if( i1.alarms().count() != i2.alarms().count() ) { |
124 | return false; // no need to check further | 124 | return false; // no need to check further |
125 | } | 125 | } |
126 | if ( i1.alarms().count() > 0 ) { | 126 | if ( i1.alarms().count() > 0 ) { |
127 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 127 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
128 | { | 128 | { |
129 | qDebug("alarm not equal "); | 129 | qDebug("alarm not equal "); |
130 | return false; | 130 | return false; |
131 | } | 131 | } |
132 | } | 132 | } |
133 | #if 0 | 133 | #if 0 |
134 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 134 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
135 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 135 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
136 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 136 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
137 | if( *a1.current() == *a2.current() ) { | 137 | if( *a1.current() == *a2.current() ) { |
138 | continue; | 138 | continue; |
139 | } | 139 | } |
140 | else { | 140 | else { |
141 | return false; | 141 | return false; |
142 | } | 142 | } |
143 | } | 143 | } |
144 | #endif | 144 | #endif |
145 | 145 | ||
146 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) | 146 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) |
147 | return false; | 147 | return false; |
148 | if ( i1.hasStartDate() == i2.hasStartDate() ) { | 148 | if ( i1.hasStartDate() == i2.hasStartDate() ) { |
149 | if ( i1.hasStartDate() ) { | 149 | if ( i1.hasStartDate() ) { |
150 | if ( i1.dtStart() != i2.dtStart() ) | 150 | if ( i1.dtStart() != i2.dtStart() ) |
151 | return false; | 151 | return false; |
152 | } | 152 | } |
153 | } else { | 153 | } else { |
154 | return false; | 154 | return false; |
155 | } | 155 | } |
156 | if (!( *i1.recurrence() == *i2.recurrence()) ) { | 156 | if (!( *i1.recurrence() == *i2.recurrence()) ) { |
157 | qDebug("recurrence is NOT equal "); | 157 | qDebug("recurrence is NOT equal "); |
158 | return false; | 158 | return false; |
159 | } | 159 | } |
160 | return | 160 | return |
161 | // i1.created() == i2.created() && | 161 | // i1.created() == i2.created() && |
162 | stringCompare( i1.description(), i2.description() ) && | 162 | stringCompare( i1.description(), i2.description() ) && |
163 | stringCompare( i1.summary(), i2.summary() ) && | 163 | stringCompare( i1.summary(), i2.summary() ) && |
164 | i1.categories() == i2.categories() && | 164 | i1.categories() == i2.categories() && |
165 | // no need to compare mRelatedTo | 165 | // no need to compare mRelatedTo |
166 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 166 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
167 | // i1.relations() == i2.relations() && | 167 | // i1.relations() == i2.relations() && |
168 | i1.exDates() == i2.exDates() && | 168 | i1.exDates() == i2.exDates() && |
169 | i1.attachments() == i2.attachments() && | 169 | i1.attachments() == i2.attachments() && |
170 | i1.resources() == i2.resources() && | 170 | i1.resources() == i2.resources() && |
171 | i1.secrecy() == i2.secrecy() && | 171 | i1.secrecy() == i2.secrecy() && |
172 | i1.priority() == i2.priority() && | 172 | i1.priority() == i2.priority() && |
173 | stringCompare( i1.location(), i2.location() ); | 173 | stringCompare( i1.location(), i2.location() ); |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
177 | void Incidence::recreate() | 177 | void Incidence::recreate() |
178 | { | 178 | { |
179 | setCreated(QDateTime::currentDateTime()); | 179 | setCreated(QDateTime::currentDateTime()); |
180 | 180 | ||
181 | setUid(CalFormat::createUniqueId()); | 181 | setUid(CalFormat::createUniqueId()); |
182 | 182 | ||
183 | setRevision(0); | 183 | setRevision(0); |
184 | 184 | ||
185 | setLastModified(QDateTime::currentDateTime()); | 185 | setLastModified(QDateTime::currentDateTime()); |
186 | } | 186 | } |
187 | 187 | ||
188 | void Incidence::setReadOnly( bool readOnly ) | 188 | void Incidence::setReadOnly( bool readOnly ) |
189 | { | 189 | { |
190 | IncidenceBase::setReadOnly( readOnly ); | 190 | IncidenceBase::setReadOnly( readOnly ); |
191 | recurrence()->setRecurReadOnly( readOnly); | 191 | recurrence()->setRecurReadOnly( readOnly); |
192 | } | 192 | } |
193 | 193 | ||
194 | void Incidence::setCreated(QDateTime created) | 194 | void Incidence::setCreated(QDateTime created) |
195 | { | 195 | { |
196 | if (mReadOnly) return; | 196 | if (mReadOnly) return; |
197 | mCreated = getEvenTime(created); | 197 | mCreated = getEvenTime(created); |
198 | } | 198 | } |
199 | 199 | ||
200 | QDateTime Incidence::created() const | 200 | QDateTime Incidence::created() const |
201 | { | 201 | { |
202 | return mCreated; | 202 | return mCreated; |
203 | } | 203 | } |
204 | 204 | ||
205 | void Incidence::setRevision(int rev) | 205 | void Incidence::setRevision(int rev) |
206 | { | 206 | { |
207 | if (mReadOnly) return; | 207 | if (mReadOnly) return; |
208 | mRevision = rev; | 208 | mRevision = rev; |
209 | 209 | ||
210 | updated(); | 210 | updated(); |
211 | } | 211 | } |
212 | 212 | ||
213 | int Incidence::revision() const | 213 | int Incidence::revision() const |
214 | { | 214 | { |
215 | return mRevision; | 215 | return mRevision; |
216 | } | 216 | } |
217 | 217 | ||
218 | void Incidence::setDtStart(const QDateTime &dtStart) | 218 | void Incidence::setDtStart(const QDateTime &dtStart) |
219 | { | 219 | { |
220 | 220 | ||
221 | QDateTime dt = getEvenTime(dtStart); | 221 | QDateTime dt = getEvenTime(dtStart); |
222 | recurrence()->setRecurStart( dt); | 222 | recurrence()->setRecurStart( dt); |
223 | IncidenceBase::setDtStart( dt ); | 223 | IncidenceBase::setDtStart( dt ); |
224 | } | 224 | } |
225 | 225 | ||
226 | void Incidence::setDescription(const QString &description) | 226 | void Incidence::setDescription(const QString &description) |
227 | { | 227 | { |
228 | if (mReadOnly) return; | 228 | if (mReadOnly) return; |
229 | mDescription = description; | 229 | mDescription = description; |
230 | updated(); | 230 | updated(); |
231 | } | 231 | } |
232 | 232 | ||
233 | QString Incidence::description() const | 233 | QString Incidence::description() const |
234 | { | 234 | { |
235 | return mDescription; | 235 | return mDescription; |
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
239 | void Incidence::setSummary(const QString &summary) | 239 | void Incidence::setSummary(const QString &summary) |
240 | { | 240 | { |
241 | if (mReadOnly) return; | 241 | if (mReadOnly) return; |
242 | mSummary = summary; | 242 | mSummary = summary; |
243 | updated(); | 243 | updated(); |
244 | } | 244 | } |
245 | 245 | ||
246 | QString Incidence::summary() const | 246 | QString Incidence::summary() const |
247 | { | 247 | { |
248 | return mSummary; | 248 | return mSummary; |
249 | } | 249 | } |
250 | 250 | ||
251 | void Incidence::setCategories(const QStringList &categories) | 251 | void Incidence::setCategories(const QStringList &categories) |
252 | { | 252 | { |
253 | if (mReadOnly) return; | 253 | if (mReadOnly) return; |
254 | mCategories = categories; | 254 | mCategories = categories; |
255 | updated(); | 255 | updated(); |
256 | } | 256 | } |
257 | 257 | ||
258 | // TODO: remove setCategories(QString) function | 258 | // TODO: remove setCategories(QString) function |
259 | void Incidence::setCategories(const QString &catStr) | 259 | void Incidence::setCategories(const QString &catStr) |
260 | { | 260 | { |
261 | if (mReadOnly) return; | 261 | if (mReadOnly) return; |
262 | mCategories.clear(); | 262 | mCategories.clear(); |
263 | 263 | ||
264 | if (catStr.isEmpty()) return; | 264 | if (catStr.isEmpty()) return; |
265 | 265 | ||
266 | mCategories = QStringList::split(",",catStr); | 266 | mCategories = QStringList::split(",",catStr); |
267 | 267 | ||
268 | QStringList::Iterator it; | 268 | QStringList::Iterator it; |
269 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 269 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
270 | *it = (*it).stripWhiteSpace(); | 270 | *it = (*it).stripWhiteSpace(); |
271 | } | 271 | } |
272 | 272 | ||
273 | updated(); | 273 | updated(); |
274 | } | 274 | } |
275 | 275 | ||
276 | QStringList Incidence::categories() const | 276 | QStringList Incidence::categories() const |
277 | { | 277 | { |
278 | return mCategories; | 278 | return mCategories; |
279 | } | 279 | } |
280 | 280 | ||
281 | QString Incidence::categoriesStr() | 281 | QString Incidence::categoriesStr() |
282 | { | 282 | { |
283 | return mCategories.join(","); | 283 | return mCategories.join(","); |
284 | } | 284 | } |
285 | 285 | ||
286 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 286 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
287 | { | 287 | { |
288 | if (mReadOnly) return; | 288 | if (mReadOnly) return; |
289 | mRelatedToUid = relatedToUid; | 289 | mRelatedToUid = relatedToUid; |
290 | } | 290 | } |
291 | 291 | ||
292 | QString Incidence::relatedToUid() const | 292 | QString Incidence::relatedToUid() const |
293 | { | 293 | { |
294 | return mRelatedToUid; | 294 | return mRelatedToUid; |
295 | } | 295 | } |
296 | 296 | ||
297 | void Incidence::setRelatedTo(Incidence *relatedTo) | 297 | void Incidence::setRelatedTo(Incidence *relatedTo) |
298 | { | 298 | { |
299 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 299 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
300 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 300 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
301 | if (mReadOnly || mRelatedTo == relatedTo) return; | 301 | if (mReadOnly || mRelatedTo == relatedTo) return; |
302 | if(mRelatedTo) { | 302 | if(mRelatedTo) { |
303 | // updated(); | 303 | // updated(); |
304 | mRelatedTo->removeRelation(this); | 304 | mRelatedTo->removeRelation(this); |
305 | } | 305 | } |
306 | mRelatedTo = relatedTo; | 306 | mRelatedTo = relatedTo; |
307 | if (mRelatedTo) mRelatedTo->addRelation(this); | 307 | if (mRelatedTo) mRelatedTo->addRelation(this); |
308 | } | 308 | } |
309 | 309 | ||
310 | Incidence *Incidence::relatedTo() const | 310 | Incidence *Incidence::relatedTo() const |
311 | { | 311 | { |
312 | return mRelatedTo; | 312 | return mRelatedTo; |
313 | } | 313 | } |
314 | 314 | ||
315 | QPtrList<Incidence> Incidence::relations() const | 315 | QPtrList<Incidence> Incidence::relations() const |
316 | { | 316 | { |
317 | return mRelations; | 317 | return mRelations; |
318 | } | 318 | } |
319 | 319 | ||
320 | void Incidence::addRelation(Incidence *event) | 320 | void Incidence::addRelation(Incidence *event) |
321 | { | 321 | { |
322 | if( mRelations.findRef( event ) == -1 ) { | 322 | if( mRelations.findRef( event ) == -1 ) { |
323 | mRelations.append(event); | 323 | mRelations.append(event); |
324 | //updated(); | 324 | //updated(); |
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | void Incidence::removeRelation(Incidence *event) | 328 | void Incidence::removeRelation(Incidence *event) |
329 | { | 329 | { |
330 | 330 | ||
331 | mRelations.removeRef(event); | 331 | mRelations.removeRef(event); |
332 | 332 | ||
333 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 333 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
334 | } | 334 | } |
335 | 335 | ||
336 | bool Incidence::recursOn(const QDate &qd) const | 336 | bool Incidence::recursOn(const QDate &qd) const |
337 | { | 337 | { |
338 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 338 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
339 | else return false; | 339 | else return false; |
340 | } | 340 | } |
341 | 341 | ||
342 | void Incidence::setExDates(const DateList &exDates) | 342 | void Incidence::setExDates(const DateList &exDates) |
343 | { | 343 | { |
344 | if (mReadOnly) return; | 344 | if (mReadOnly) return; |
345 | mExDates = exDates; | 345 | mExDates = exDates; |
346 | 346 | ||
347 | recurrence()->setRecurExDatesCount(mExDates.count()); | 347 | recurrence()->setRecurExDatesCount(mExDates.count()); |
348 | 348 | ||
349 | updated(); | 349 | updated(); |
350 | } | 350 | } |
351 | 351 | ||
352 | void Incidence::addExDate(const QDate &date) | 352 | void Incidence::addExDate(const QDate &date) |
353 | { | 353 | { |
354 | if (mReadOnly) return; | 354 | if (mReadOnly) return; |
355 | mExDates.append(date); | 355 | mExDates.append(date); |
356 | 356 | ||
357 | recurrence()->setRecurExDatesCount(mExDates.count()); | 357 | recurrence()->setRecurExDatesCount(mExDates.count()); |
358 | 358 | ||
359 | updated(); | 359 | updated(); |
360 | } | 360 | } |
361 | 361 | ||
362 | DateList Incidence::exDates() const | 362 | DateList Incidence::exDates() const |
363 | { | 363 | { |
364 | return mExDates; | 364 | return mExDates; |
365 | } | 365 | } |
366 | 366 | ||
367 | bool Incidence::isException(const QDate &date) const | 367 | bool Incidence::isException(const QDate &date) const |
368 | { | 368 | { |
369 | DateList::ConstIterator it; | 369 | DateList::ConstIterator it; |
370 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 370 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
371 | if ( (*it) == date ) { | 371 | if ( (*it) == date ) { |
372 | return true; | 372 | return true; |
373 | } | 373 | } |
374 | } | 374 | } |
375 | 375 | ||
376 | return false; | 376 | return false; |
377 | } | 377 | } |
378 | 378 | ||
379 | void Incidence::addAttachment(Attachment *attachment) | 379 | void Incidence::addAttachment(Attachment *attachment) |
380 | { | 380 | { |
381 | if (mReadOnly || !attachment) return; | 381 | if (mReadOnly || !attachment) return; |
382 | mAttachments.append(attachment); | 382 | mAttachments.append(attachment); |
383 | updated(); | 383 | updated(); |
384 | } | 384 | } |
385 | 385 | ||
386 | void Incidence::deleteAttachment(Attachment *attachment) | 386 | void Incidence::deleteAttachment(Attachment *attachment) |
387 | { | 387 | { |
388 | mAttachments.removeRef(attachment); | 388 | mAttachments.removeRef(attachment); |
389 | } | 389 | } |
390 | 390 | ||
391 | void Incidence::deleteAttachments(const QString& mime) | 391 | void Incidence::deleteAttachments(const QString& mime) |
392 | { | 392 | { |
393 | Attachment *at = mAttachments.first(); | 393 | Attachment *at = mAttachments.first(); |
394 | while (at) { | 394 | while (at) { |
395 | if (at->mimeType() == mime) | 395 | if (at->mimeType() == mime) |
396 | mAttachments.remove(); | 396 | mAttachments.remove(); |
397 | else | 397 | else |
398 | at = mAttachments.next(); | 398 | at = mAttachments.next(); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
402 | QPtrList<Attachment> Incidence::attachments() const | 402 | QPtrList<Attachment> Incidence::attachments() const |
403 | { | 403 | { |
404 | return mAttachments; | 404 | return mAttachments; |
405 | } | 405 | } |
406 | 406 | ||
407 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 407 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
408 | { | 408 | { |
409 | QPtrList<Attachment> attachments; | 409 | QPtrList<Attachment> attachments; |
410 | QPtrListIterator<Attachment> it( mAttachments ); | 410 | QPtrListIterator<Attachment> it( mAttachments ); |
411 | Attachment *at; | 411 | Attachment *at; |
412 | while ( (at = it.current()) ) { | 412 | while ( (at = it.current()) ) { |
413 | if (at->mimeType() == mime) | 413 | if (at->mimeType() == mime) |
414 | attachments.append(at); | 414 | attachments.append(at); |
415 | ++it; | 415 | ++it; |
416 | } | 416 | } |
417 | 417 | ||
418 | return attachments; | 418 | return attachments; |
419 | } | 419 | } |
420 | 420 | ||
421 | void Incidence::setResources(const QStringList &resources) | 421 | void Incidence::setResources(const QStringList &resources) |
422 | { | 422 | { |
423 | if (mReadOnly) return; | 423 | if (mReadOnly) return; |
424 | mResources = resources; | 424 | mResources = resources; |
425 | updated(); | 425 | updated(); |
426 | } | 426 | } |
427 | 427 | ||
428 | QStringList Incidence::resources() const | 428 | QStringList Incidence::resources() const |
429 | { | 429 | { |
430 | return mResources; | 430 | return mResources; |
431 | } | 431 | } |
432 | 432 | ||
433 | 433 | ||
434 | void Incidence::setPriority(int priority) | 434 | void Incidence::setPriority(int priority) |
435 | { | 435 | { |
436 | if (mReadOnly) return; | 436 | if (mReadOnly) return; |
437 | mPriority = priority; | 437 | mPriority = priority; |
438 | updated(); | 438 | updated(); |
439 | } | 439 | } |
440 | 440 | ||
441 | int Incidence::priority() const | 441 | int Incidence::priority() const |
442 | { | 442 | { |
443 | return mPriority; | 443 | return mPriority; |
444 | } | 444 | } |
445 | 445 | ||
446 | void Incidence::setSecrecy(int sec) | 446 | void Incidence::setSecrecy(int sec) |
447 | { | 447 | { |
448 | if (mReadOnly) return; | 448 | if (mReadOnly) return; |
449 | mSecrecy = sec; | 449 | mSecrecy = sec; |
450 | updated(); | 450 | updated(); |
451 | } | 451 | } |
452 | 452 | ||
453 | int Incidence::secrecy() const | 453 | int Incidence::secrecy() const |
454 | { | 454 | { |
455 | return mSecrecy; | 455 | return mSecrecy; |
456 | } | 456 | } |
457 | 457 | ||
458 | QString Incidence::secrecyStr() const | 458 | QString Incidence::secrecyStr() const |
459 | { | 459 | { |
460 | return secrecyName(mSecrecy); | 460 | return secrecyName(mSecrecy); |
461 | } | 461 | } |
462 | 462 | ||
463 | QString Incidence::secrecyName(int secrecy) | 463 | QString Incidence::secrecyName(int secrecy) |
464 | { | 464 | { |
465 | switch (secrecy) { | 465 | switch (secrecy) { |
466 | case SecrecyPublic: | 466 | case SecrecyPublic: |
467 | return i18n("Public"); | 467 | return i18n("Public"); |
468 | break; | 468 | break; |
469 | case SecrecyPrivate: | 469 | case SecrecyPrivate: |
470 | return i18n("Private"); | 470 | return i18n("Private"); |
471 | break; | 471 | break; |
472 | case SecrecyConfidential: | 472 | case SecrecyConfidential: |
473 | return i18n("Confidential"); | 473 | return i18n("Confidential"); |
474 | break; | 474 | break; |
475 | default: | 475 | default: |
476 | return i18n("Undefined"); | 476 | return i18n("Undefined"); |
477 | break; | 477 | break; |
478 | } | 478 | } |
479 | } | 479 | } |
480 | 480 | ||
481 | QStringList Incidence::secrecyList() | 481 | QStringList Incidence::secrecyList() |
482 | { | 482 | { |
483 | QStringList list; | 483 | QStringList list; |
484 | list << secrecyName(SecrecyPublic); | 484 | list << secrecyName(SecrecyPublic); |
485 | list << secrecyName(SecrecyPrivate); | 485 | list << secrecyName(SecrecyPrivate); |
486 | list << secrecyName(SecrecyConfidential); | 486 | list << secrecyName(SecrecyConfidential); |
487 | 487 | ||
488 | return list; | 488 | return list; |
489 | } | 489 | } |
490 | 490 | ||
491 | 491 | ||
492 | QPtrList<Alarm> Incidence::alarms() const | 492 | QPtrList<Alarm> Incidence::alarms() const |
493 | { | 493 | { |
494 | return mAlarms; | 494 | return mAlarms; |
495 | } | 495 | } |
496 | 496 | ||
497 | Alarm* Incidence::newAlarm() | 497 | Alarm* Incidence::newAlarm() |
498 | { | 498 | { |
499 | Alarm* alarm = new Alarm(this); | 499 | Alarm* alarm = new Alarm(this); |
500 | mAlarms.append(alarm); | 500 | mAlarms.append(alarm); |
501 | // updated(); | 501 | // updated(); |
502 | return alarm; | 502 | return alarm; |
503 | } | 503 | } |
504 | 504 | ||
505 | void Incidence::addAlarm(Alarm *alarm) | 505 | void Incidence::addAlarm(Alarm *alarm) |
506 | { | 506 | { |
507 | mAlarms.append(alarm); | 507 | mAlarms.append(alarm); |
508 | updated(); | 508 | updated(); |
509 | } | 509 | } |
510 | 510 | ||
511 | void Incidence::removeAlarm(Alarm *alarm) | 511 | void Incidence::removeAlarm(Alarm *alarm) |
512 | { | 512 | { |
513 | mAlarms.removeRef(alarm); | 513 | mAlarms.removeRef(alarm); |
514 | updated(); | 514 | updated(); |
515 | } | 515 | } |
516 | 516 | ||
517 | void Incidence::clearAlarms() | 517 | void Incidence::clearAlarms() |
518 | { | 518 | { |
519 | mAlarms.clear(); | 519 | mAlarms.clear(); |
520 | updated(); | 520 | updated(); |
521 | } | 521 | } |
522 | 522 | ||
523 | bool Incidence::isAlarmEnabled() const | 523 | bool Incidence::isAlarmEnabled() const |
524 | { | 524 | { |
525 | Alarm* alarm; | 525 | Alarm* alarm; |
526 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 526 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
527 | if (alarm->enabled()) | 527 | if (alarm->enabled()) |
528 | return true; | 528 | return true; |
529 | } | 529 | } |
530 | return false; | 530 | return false; |
531 | } | 531 | } |
532 | 532 | ||
533 | Recurrence *Incidence::recurrence() const | 533 | Recurrence *Incidence::recurrence() const |
534 | { | 534 | { |
535 | return mRecurrence; | 535 | return mRecurrence; |
536 | } | 536 | } |
537 | void Incidence::setRecurrence( Recurrence * r) | 537 | void Incidence::setRecurrence( Recurrence * r) |
538 | { | 538 | { |
539 | delete mRecurrence; | 539 | delete mRecurrence; |
540 | mRecurrence = r; | 540 | mRecurrence = r; |
541 | } | 541 | } |
542 | 542 | ||
543 | void Incidence::setLocation(const QString &location) | 543 | void Incidence::setLocation(const QString &location) |
544 | { | 544 | { |
545 | if (mReadOnly) return; | 545 | if (mReadOnly) return; |
546 | mLocation = location; | 546 | mLocation = location; |
547 | updated(); | 547 | updated(); |
548 | } | 548 | } |
549 | 549 | ||
550 | QString Incidence::location() const | 550 | QString Incidence::location() const |
551 | { | 551 | { |
552 | return mLocation; | 552 | return mLocation; |
553 | } | 553 | } |
554 | 554 | ||
555 | ushort Incidence::doesRecur() const | 555 | ushort Incidence::doesRecur() const |
556 | { | 556 | { |
557 | if ( mRecurrence ) return mRecurrence->doesRecur(); | 557 | if ( mRecurrence ) return mRecurrence->doesRecur(); |
558 | else return Recurrence::rNone; | 558 | else return Recurrence::rNone; |
559 | } | 559 | } |
560 | 560 | ||
561 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | 561 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const |
562 | { | 562 | { |
563 | QDateTime incidenceStart = dt; | 563 | QDateTime incidenceStart = dt; |
564 | *ok = false; | 564 | *ok = false; |
565 | if ( doesRecur() ) { | 565 | if ( doesRecur() ) { |
566 | bool last; | 566 | bool last; |
567 | recurrence()->getPreviousDateTime( incidenceStart , &last ); | 567 | recurrence()->getPreviousDateTime( incidenceStart , &last ); |
568 | int count = 0; | 568 | int count = 0; |
569 | if ( !last ) { | 569 | if ( !last ) { |
570 | while ( !last ) { | 570 | while ( !last ) { |
571 | ++count; | 571 | ++count; |
572 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); | 572 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); |
573 | if ( recursOn( incidenceStart.date() ) ) { | 573 | if ( recursOn( incidenceStart.date() ) ) { |
574 | last = true; // exit while llop | 574 | last = true; // exit while llop |
575 | } else { | 575 | } else { |
576 | if ( last ) { // no alarm on last recurrence | 576 | if ( last ) { // no alarm on last recurrence |
577 | return QDateTime (); | 577 | return QDateTime (); |
578 | } | 578 | } |
579 | int year = incidenceStart.date().year(); | 579 | int year = incidenceStart.date().year(); |
580 | // workaround for bug in recurrence | 580 | // workaround for bug in recurrence |
581 | if ( count == 100 || year < 1980 || year > 5000 ) { | 581 | if ( count == 100 || year < 1980 || year > 5000 ) { |
582 | return QDateTime (); | 582 | return QDateTime (); |
583 | } | 583 | } |
584 | incidenceStart = incidenceStart.addSecs( 1 ); | 584 | incidenceStart = incidenceStart.addSecs( 1 ); |
585 | } | 585 | } |
586 | } | 586 | } |
587 | } else { | 587 | } else { |
588 | return QDateTime (); | 588 | return QDateTime (); |
589 | } | 589 | } |
590 | } else { | 590 | } else { |
591 | if ( hasStartDate () ) { | 591 | if ( hasStartDate () ) { |
592 | incidenceStart = dtStart(); | 592 | incidenceStart = dtStart(); |
593 | 593 | } | |
594 | } | 594 | if ( type() =="Todo" ) { |
595 | if ( ((Todo*)this)->hasDueDate() ) | ||
596 | incidenceStart = ((Todo*)this)->dtDue(); | ||
597 | |||
598 | } | ||
595 | } | 599 | } |
596 | if ( incidenceStart > dt ) | 600 | if ( incidenceStart > dt ) |
597 | *ok = true; | 601 | *ok = true; |
598 | return incidenceStart; | 602 | return incidenceStart; |
599 | } | 603 | } |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 64a343c..b36dc1a 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -1,407 +1,407 @@ | |||
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 | ||
31 | using namespace KCal; | 31 | using namespace KCal; |
32 | 32 | ||
33 | IncidenceBase::IncidenceBase() : | 33 | IncidenceBase::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 | setUid(CalFormat::createUniqueId()); | 37 | setUid(CalFormat::createUniqueId()); |
38 | mOrganizer = ""; | 38 | mOrganizer = ""; |
39 | mFloats = false; | 39 | mFloats = false; |
40 | mDuration = 0; | 40 | mDuration = 0; |
41 | mHasDuration = false; | 41 | mHasDuration = false; |
42 | mPilotId = 0; | 42 | mPilotId = 0; |
43 | mExternalId = ":"; | 43 | mExternalId = ":"; |
44 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 44 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
45 | mSyncStatus = 0; | 45 | mSyncStatus = 0; |
46 | mAttendees.setAutoDelete( true ); | 46 | mAttendees.setAutoDelete( true ); |
47 | } | 47 | } |
48 | 48 | ||
49 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : | 49 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : |
50 | CustomProperties( i ) | 50 | CustomProperties( i ) |
51 | { | 51 | { |
52 | mReadOnly = i.mReadOnly; | 52 | mReadOnly = i.mReadOnly; |
53 | mDtStart = i.mDtStart; | 53 | mDtStart = i.mDtStart; |
54 | mDuration = i.mDuration; | 54 | mDuration = i.mDuration; |
55 | mHasDuration = i.mHasDuration; | 55 | mHasDuration = i.mHasDuration; |
56 | mOrganizer = i.mOrganizer; | 56 | mOrganizer = i.mOrganizer; |
57 | mUid = i.mUid; | 57 | mUid = i.mUid; |
58 | QPtrList<Attendee> attendees = i.attendees(); | 58 | QPtrList<Attendee> attendees = i.attendees(); |
59 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { | 59 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { |
60 | mAttendees.append( new Attendee( *a ) ); | 60 | mAttendees.append( new Attendee( *a ) ); |
61 | } | 61 | } |
62 | mFloats = i.mFloats; | 62 | mFloats = i.mFloats; |
63 | mLastModified = i.mLastModified; | 63 | mLastModified = i.mLastModified; |
64 | mPilotId = i.mPilotId; | 64 | mPilotId = i.mPilotId; |
65 | mTempSyncStat = i.mTempSyncStat; | 65 | mTempSyncStat = i.mTempSyncStat; |
66 | mSyncStatus = i.mSyncStatus; | 66 | mSyncStatus = i.mSyncStatus; |
67 | mExternalId = i.mExternalId; | 67 | mExternalId = i.mExternalId; |
68 | // The copied object is a new one, so it isn't observed by the observer | 68 | // The copied object is a new one, so it isn't observed by the observer |
69 | // of the original object. | 69 | // of the original object. |
70 | mObservers.clear(); | 70 | mObservers.clear(); |
71 | 71 | ||
72 | mAttendees.setAutoDelete( true ); | 72 | mAttendees.setAutoDelete( true ); |
73 | } | 73 | } |
74 | 74 | ||
75 | IncidenceBase::~IncidenceBase() | 75 | IncidenceBase::~IncidenceBase() |
76 | { | 76 | { |
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | 80 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) |
81 | { | 81 | { |
82 | // do not compare mSyncStatus and mExternalId | 82 | // do not compare mSyncStatus and mExternalId |
83 | if( i1.attendees().count() != i2.attendees().count() ) { | 83 | if( i1.attendees().count() != i2.attendees().count() ) { |
84 | return false; // no need to check further | 84 | return false; // no need to check further |
85 | } | 85 | } |
86 | if ( i1.attendees().count() > 0 ) { | 86 | if ( i1.attendees().count() > 0 ) { |
87 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; | 87 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; |
88 | while ( a1 ) { | 88 | while ( a1 ) { |
89 | if ( !( (*a1) == (*a2)) ) | 89 | if ( !( (*a1) == (*a2)) ) |
90 | { | 90 | { |
91 | //qDebug("Attendee not equal "); | 91 | //qDebug("Attendee not equal "); |
92 | return false; | 92 | return false; |
93 | } | 93 | } |
94 | a1 = i1.attendees().next(); | 94 | a1 = i1.attendees().next(); |
95 | a2 = i2.attendees().next(); | 95 | a2 = i2.attendees().next(); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | //if ( i1.dtStart() != i2.dtStart() ) | 98 | //if ( i1.dtStart() != i2.dtStart() ) |
99 | // return false; | 99 | // return false; |
100 | #if 0 | 100 | #if 0 |
101 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); | 101 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); |
102 | qDebug("1 %d ",i1.duration() == i2.duration() ); | 102 | qDebug("1 %d ",i1.duration() == i2.duration() ); |
103 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); | 103 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); |
104 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); | 104 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); |
105 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); | 105 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); |
106 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); | 106 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); |
107 | 107 | ||
108 | #endif | 108 | #endif |
109 | return ( i1.organizer() == i2.organizer() && | 109 | return ( i1.organizer() == i2.organizer() && |
110 | // i1.uid() == i2.uid() && | 110 | // i1.uid() == i2.uid() && |
111 | // Don't compare lastModified, otherwise the operator is not | 111 | // Don't compare lastModified, otherwise the operator is not |
112 | // of much use. We are not comparing for identity, after all. | 112 | // of much use. We are not comparing for identity, after all. |
113 | i1.doesFloat() == i2.doesFloat() && | 113 | i1.doesFloat() == i2.doesFloat() && |
114 | i1.duration() == i2.duration() && | 114 | i1.duration() == i2.duration() && |
115 | i1.hasDuration() == i2.hasDuration() && | 115 | i1.hasDuration() == i2.hasDuration() && |
116 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); | 116 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); |
117 | // no need to compare mObserver | 117 | // no need to compare mObserver |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) | 121 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) |
122 | { | 122 | { |
123 | QTime t = dt.time(); | 123 | QTime t = dt.time(); |
124 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 124 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
125 | return dt; | 125 | return dt; |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | void IncidenceBase::setUid(const QString &uid) | 129 | void IncidenceBase::setUid(const QString &uid) |
130 | { | 130 | { |
131 | mUid = uid; | 131 | mUid = uid; |
132 | updated(); | 132 | updated(); |
133 | } | 133 | } |
134 | 134 | ||
135 | QString IncidenceBase::uid() const | 135 | QString IncidenceBase::uid() const |
136 | { | 136 | { |
137 | return mUid; | 137 | return mUid; |
138 | } | 138 | } |
139 | 139 | ||
140 | void IncidenceBase::setLastModified(const QDateTime &lm) | 140 | void IncidenceBase::setLastModified(const QDateTime &lm) |
141 | { | 141 | { |
142 | // DON'T! updated() because we call this from | 142 | // DON'T! updated() because we call this from |
143 | // Calendar::updateEvent(). | 143 | // Calendar::updateEvent(). |
144 | mLastModified = getEvenTime(lm); | 144 | mLastModified = getEvenTime(lm); |
145 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); | 145 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); |
146 | } | 146 | } |
147 | 147 | ||
148 | QDateTime IncidenceBase::lastModified() const | 148 | QDateTime IncidenceBase::lastModified() const |
149 | { | 149 | { |
150 | return mLastModified; | 150 | return mLastModified; |
151 | } | 151 | } |
152 | 152 | ||
153 | void IncidenceBase::setOrganizer(const QString &o) | 153 | void IncidenceBase::setOrganizer(const QString &o) |
154 | { | 154 | { |
155 | // we don't check for readonly here, because it is | 155 | // we don't check for readonly here, because it is |
156 | // possible that by setting the organizer we are changing | 156 | // possible that by setting the organizer we are changing |
157 | // the event's readonly status... | 157 | // the event's readonly status... |
158 | mOrganizer = o; | 158 | mOrganizer = o; |
159 | if (mOrganizer.left(7).upper() == "MAILTO:") | 159 | if (mOrganizer.left(7).upper() == "MAILTO:") |
160 | mOrganizer = mOrganizer.remove(0,7); | 160 | mOrganizer = mOrganizer.remove(0,7); |
161 | 161 | ||
162 | updated(); | 162 | updated(); |
163 | } | 163 | } |
164 | 164 | ||
165 | QString IncidenceBase::organizer() const | 165 | QString IncidenceBase::organizer() const |
166 | { | 166 | { |
167 | return mOrganizer; | 167 | return mOrganizer; |
168 | } | 168 | } |
169 | 169 | ||
170 | void IncidenceBase::setReadOnly( bool readOnly ) | 170 | void IncidenceBase::setReadOnly( bool readOnly ) |
171 | { | 171 | { |
172 | mReadOnly = readOnly; | 172 | mReadOnly = readOnly; |
173 | } | 173 | } |
174 | 174 | ||
175 | void IncidenceBase::setDtStart(const QDateTime &dtStart) | 175 | void IncidenceBase::setDtStart(const QDateTime &dtStart) |
176 | { | 176 | { |
177 | // if (mReadOnly) return; | 177 | // if (mReadOnly) return; |
178 | mDtStart = getEvenTime(dtStart); | 178 | mDtStart = getEvenTime(dtStart); |
179 | updated(); | 179 | updated(); |
180 | } | 180 | } |
181 | 181 | ||
182 | QDateTime IncidenceBase::dtStart() const | 182 | QDateTime IncidenceBase::dtStart() const |
183 | { | 183 | { |
184 | return mDtStart; | 184 | return mDtStart; |
185 | } | 185 | } |
186 | 186 | ||
187 | QString IncidenceBase::dtStartTimeStr() const | 187 | QString IncidenceBase::dtStartTimeStr() const |
188 | { | 188 | { |
189 | return KGlobal::locale()->formatTime(dtStart().time()); | 189 | return KGlobal::locale()->formatTime(dtStart().time()); |
190 | } | 190 | } |
191 | 191 | ||
192 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const | 192 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const |
193 | { | 193 | { |
194 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 194 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
195 | } | 195 | } |
196 | 196 | ||
197 | QString IncidenceBase::dtStartStr(bool shortfmt) const | 197 | QString IncidenceBase::dtStartStr(bool shortfmt) const |
198 | { | 198 | { |
199 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); | 199 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); |
200 | } | 200 | } |
201 | 201 | ||
202 | 202 | ||
203 | bool IncidenceBase::doesFloat() const | 203 | bool IncidenceBase::doesFloat() const |
204 | { | 204 | { |
205 | return mFloats; | 205 | return mFloats; |
206 | } | 206 | } |
207 | 207 | ||
208 | void IncidenceBase::setFloats(bool f) | 208 | void IncidenceBase::setFloats(bool f) |
209 | { | 209 | { |
210 | if (mReadOnly) return; | 210 | if (mReadOnly) return; |
211 | mFloats = f; | 211 | mFloats = f; |
212 | updated(); | 212 | updated(); |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | void IncidenceBase::addAttendee(Attendee *a, bool doupdate) | 216 | void IncidenceBase::addAttendee(Attendee *a, bool doupdate) |
217 | { | 217 | { |
218 | if (mReadOnly) return; | 218 | if (mReadOnly) return; |
219 | if (a->name().left(7).upper() == "MAILTO:") | 219 | if (a->name().left(7).upper() == "MAILTO:") |
220 | a->setName(a->name().remove(0,7)); | 220 | a->setName(a->name().remove(0,7)); |
221 | 221 | ||
222 | mAttendees.append(a); | 222 | mAttendees.append(a); |
223 | if (doupdate) updated(); | 223 | if (doupdate) updated(); |
224 | } | 224 | } |
225 | 225 | ||
226 | #if 0 | 226 | #if 0 |
227 | void IncidenceBase::removeAttendee(Attendee *a) | 227 | void IncidenceBase::removeAttendee(Attendee *a) |
228 | { | 228 | { |
229 | if (mReadOnly) return; | 229 | if (mReadOnly) return; |
230 | mAttendees.removeRef(a); | 230 | mAttendees.removeRef(a); |
231 | updated(); | 231 | updated(); |
232 | } | 232 | } |
233 | 233 | ||
234 | void IncidenceBase::removeAttendee(const char *n) | 234 | void IncidenceBase::removeAttendee(const char *n) |
235 | { | 235 | { |
236 | Attendee *a; | 236 | Attendee *a; |
237 | 237 | ||
238 | if (mReadOnly) return; | 238 | if (mReadOnly) return; |
239 | for (a = mAttendees.first(); a; a = mAttendees.next()) | 239 | for (a = mAttendees.first(); a; a = mAttendees.next()) |
240 | if (a->getName() == n) { | 240 | if (a->getName() == n) { |
241 | mAttendees.remove(); | 241 | mAttendees.remove(); |
242 | break; | 242 | break; |
243 | } | 243 | } |
244 | } | 244 | } |
245 | #endif | 245 | #endif |
246 | 246 | ||
247 | void IncidenceBase::clearAttendees() | 247 | void IncidenceBase::clearAttendees() |
248 | { | 248 | { |
249 | if (mReadOnly) return; | 249 | if (mReadOnly) return; |
250 | mAttendees.clear(); | 250 | mAttendees.clear(); |
251 | } | 251 | } |
252 | 252 | ||
253 | #if 0 | 253 | #if 0 |
254 | Attendee *IncidenceBase::getAttendee(const char *n) const | 254 | Attendee *IncidenceBase::getAttendee(const char *n) const |
255 | { | 255 | { |
256 | QPtrListIterator<Attendee> qli(mAttendees); | 256 | QPtrListIterator<Attendee> qli(mAttendees); |
257 | 257 | ||
258 | qli.toFirst(); | 258 | qli.toFirst(); |
259 | while (qli) { | 259 | while (qli) { |
260 | if (qli.current()->getName() == n) | 260 | if (qli.current()->getName() == n) |
261 | return qli.current(); | 261 | return qli.current(); |
262 | ++qli; | 262 | ++qli; |
263 | } | 263 | } |
264 | return 0L; | 264 | return 0L; |
265 | } | 265 | } |
266 | #endif | 266 | #endif |
267 | 267 | ||
268 | Attendee *IncidenceBase::attendeeByMail(const QString &email) | 268 | Attendee *IncidenceBase::attendeeByMail(const QString &email) |
269 | { | 269 | { |
270 | QPtrListIterator<Attendee> qli(mAttendees); | 270 | QPtrListIterator<Attendee> qli(mAttendees); |
271 | 271 | ||
272 | qli.toFirst(); | 272 | qli.toFirst(); |
273 | while (qli) { | 273 | while (qli) { |
274 | if (qli.current()->email() == email) | 274 | if (qli.current()->email().lower() == email.lower()) |
275 | return qli.current(); | 275 | return qli.current(); |
276 | ++qli; | 276 | ++qli; |
277 | } | 277 | } |
278 | return 0L; | 278 | return 0L; |
279 | } | 279 | } |
280 | 280 | ||
281 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) | 281 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) |
282 | { | 282 | { |
283 | QPtrListIterator<Attendee> qli(mAttendees); | 283 | QPtrListIterator<Attendee> qli(mAttendees); |
284 | 284 | ||
285 | QStringList mails = emails; | 285 | QStringList mails = emails; |
286 | if (!email.isEmpty()) { | 286 | if (!email.isEmpty()) { |
287 | mails.append(email); | 287 | mails.append(email); |
288 | } | 288 | } |
289 | qli.toFirst(); | 289 | qli.toFirst(); |
290 | while (qli) { | 290 | while (qli) { |
291 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { | 291 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { |
292 | if (qli.current()->email() == *it) | 292 | if (qli.current()->email().lower() == (*it).lower()) |
293 | return qli.current(); | 293 | return qli.current(); |
294 | } | 294 | } |
295 | 295 | ||
296 | ++qli; | 296 | ++qli; |
297 | } | 297 | } |
298 | return 0L; | 298 | return 0L; |
299 | } | 299 | } |
300 | 300 | ||
301 | void IncidenceBase::setDuration(int seconds) | 301 | void IncidenceBase::setDuration(int seconds) |
302 | { | 302 | { |
303 | mDuration = seconds; | 303 | mDuration = seconds; |
304 | setHasDuration(true); | 304 | setHasDuration(true); |
305 | } | 305 | } |
306 | 306 | ||
307 | int IncidenceBase::duration() const | 307 | int IncidenceBase::duration() const |
308 | { | 308 | { |
309 | return mDuration; | 309 | return mDuration; |
310 | } | 310 | } |
311 | 311 | ||
312 | void IncidenceBase::setHasDuration(bool b) | 312 | void IncidenceBase::setHasDuration(bool b) |
313 | { | 313 | { |
314 | mHasDuration = b; | 314 | mHasDuration = b; |
315 | } | 315 | } |
316 | 316 | ||
317 | bool IncidenceBase::hasDuration() const | 317 | bool IncidenceBase::hasDuration() const |
318 | { | 318 | { |
319 | return mHasDuration; | 319 | return mHasDuration; |
320 | } | 320 | } |
321 | 321 | ||
322 | void IncidenceBase::setSyncStatus(int stat) | 322 | void IncidenceBase::setSyncStatus(int stat) |
323 | { | 323 | { |
324 | if (mReadOnly) return; | 324 | if (mReadOnly) return; |
325 | mSyncStatus = stat; | 325 | mSyncStatus = stat; |
326 | } | 326 | } |
327 | 327 | ||
328 | int IncidenceBase::syncStatus() const | 328 | int IncidenceBase::syncStatus() const |
329 | { | 329 | { |
330 | return mSyncStatus; | 330 | return mSyncStatus; |
331 | } | 331 | } |
332 | 332 | ||
333 | void IncidenceBase::setPilotId( int id ) | 333 | void IncidenceBase::setPilotId( int id ) |
334 | { | 334 | { |
335 | if (mReadOnly) return; | 335 | if (mReadOnly) return; |
336 | mPilotId = id; | 336 | mPilotId = id; |
337 | } | 337 | } |
338 | 338 | ||
339 | int IncidenceBase::pilotId() const | 339 | int IncidenceBase::pilotId() const |
340 | { | 340 | { |
341 | return mPilotId; | 341 | return mPilotId; |
342 | } | 342 | } |
343 | 343 | ||
344 | int IncidenceBase::tempSyncStat() const | 344 | int IncidenceBase::tempSyncStat() const |
345 | { | 345 | { |
346 | return mTempSyncStat; | 346 | return mTempSyncStat; |
347 | } | 347 | } |
348 | void IncidenceBase::setTempSyncStat( int id ) | 348 | void IncidenceBase::setTempSyncStat( int id ) |
349 | { | 349 | { |
350 | if (mReadOnly) return; | 350 | if (mReadOnly) return; |
351 | mTempSyncStat = id; | 351 | mTempSyncStat = id; |
352 | } | 352 | } |
353 | 353 | ||
354 | void IncidenceBase::removeID(const QString &prof) | 354 | void IncidenceBase::removeID(const QString &prof) |
355 | { | 355 | { |
356 | mExternalId = KIdManager::removeId ( mExternalId, prof); | 356 | mExternalId = KIdManager::removeId ( mExternalId, prof); |
357 | 357 | ||
358 | } | 358 | } |
359 | void IncidenceBase::setID( const QString & prof , const QString & id ) | 359 | void IncidenceBase::setID( const QString & prof , const QString & id ) |
360 | { | 360 | { |
361 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); | 361 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); |
362 | } | 362 | } |
363 | QString IncidenceBase::getID( const QString & prof) | 363 | QString IncidenceBase::getID( const QString & prof) |
364 | { | 364 | { |
365 | return KIdManager::getId ( mExternalId, prof ); | 365 | return KIdManager::getId ( mExternalId, prof ); |
366 | } | 366 | } |
367 | 367 | ||
368 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: | 368 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: |
369 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 | 369 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 |
370 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) | 370 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) |
371 | { | 371 | { |
372 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); | 372 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); |
373 | } | 373 | } |
374 | QString IncidenceBase::getCsum( const QString & prof) | 374 | QString IncidenceBase::getCsum( const QString & prof) |
375 | { | 375 | { |
376 | return KIdManager::getCsum ( mExternalId, prof ); | 376 | return KIdManager::getCsum ( mExternalId, prof ); |
377 | } | 377 | } |
378 | 378 | ||
379 | void IncidenceBase::setIDStr( const QString & s ) | 379 | void IncidenceBase::setIDStr( const QString & s ) |
380 | { | 380 | { |
381 | if (mReadOnly) return; | 381 | if (mReadOnly) return; |
382 | mExternalId = s; | 382 | mExternalId = s; |
383 | } | 383 | } |
384 | 384 | ||
385 | QString IncidenceBase::IDStr() const | 385 | QString IncidenceBase::IDStr() const |
386 | { | 386 | { |
387 | return mExternalId ; | 387 | return mExternalId ; |
388 | } | 388 | } |
389 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) | 389 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) |
390 | { | 390 | { |
391 | if( !mObservers.contains(observer) ) mObservers.append( observer ); | 391 | if( !mObservers.contains(observer) ) mObservers.append( observer ); |
392 | } | 392 | } |
393 | 393 | ||
394 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) | 394 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) |
395 | { | 395 | { |
396 | mObservers.remove( observer ); | 396 | mObservers.remove( observer ); |
397 | } | 397 | } |
398 | 398 | ||
399 | void IncidenceBase::updated() | 399 | void IncidenceBase::updated() |
400 | { | 400 | { |
401 | QPtrListIterator<Observer> it(mObservers); | 401 | QPtrListIterator<Observer> it(mObservers); |
402 | while( it.current() ) { | 402 | while( it.current() ) { |
403 | Observer *o = it.current(); | 403 | Observer *o = it.current(); |
404 | ++it; | 404 | ++it; |
405 | o->incidenceUpdated( this ); | 405 | o->incidenceUpdated( this ); |
406 | } | 406 | } |
407 | } | 407 | } |