-rw-r--r-- | libkcal/incidencebase.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 56c0560..f11ec54 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -1,99 +1,101 @@ | |||
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 | //Added by qt3to4: | ||
31 | #include <Q3PtrList> | ||
30 | 32 | ||
31 | using namespace KCal; | 33 | using namespace KCal; |
32 | 34 | ||
33 | IncidenceBase::IncidenceBase() : | 35 | IncidenceBase::IncidenceBase() : |
34 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), | 36 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), |
35 | mPilotId(0), mSyncStatus(SYNCMOD) | 37 | mPilotId(0), mSyncStatus(SYNCMOD) |
36 | { | 38 | { |
37 | blockLastModified = false; | 39 | blockLastModified = false; |
38 | setUid(CalFormat::createUniqueId()); | 40 | setUid(CalFormat::createUniqueId()); |
39 | mOrganizer = ""; | 41 | mOrganizer = ""; |
40 | mFloats = false; | 42 | mFloats = false; |
41 | mDuration = 0; | 43 | mDuration = 0; |
42 | mHasDuration = false; | 44 | mHasDuration = false; |
43 | mPilotId = 0; | 45 | mPilotId = 0; |
44 | mExternalId = ":"; | 46 | mExternalId = ":"; |
45 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 47 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
46 | mSyncStatus = 0; | 48 | mSyncStatus = 0; |
47 | mAttendees.setAutoDelete( true ); | 49 | mAttendees.setAutoDelete( true ); |
48 | mCalEnabled = true; | 50 | mCalEnabled = true; |
49 | mAlarmEnabled = true; | 51 | mAlarmEnabled = true; |
50 | mCalID = 0; | 52 | mCalID = 0; |
51 | } | 53 | } |
52 | 54 | ||
53 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : | 55 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : |
54 | CustomProperties( i ) | 56 | CustomProperties( i ) |
55 | { | 57 | { |
56 | 58 | ||
57 | blockLastModified = false; | 59 | blockLastModified = false; |
58 | mReadOnly = i.mReadOnly; | 60 | mReadOnly = i.mReadOnly; |
59 | mDtStart = i.mDtStart; | 61 | mDtStart = i.mDtStart; |
60 | mDuration = i.mDuration; | 62 | mDuration = i.mDuration; |
61 | mHasDuration = i.mHasDuration; | 63 | mHasDuration = i.mHasDuration; |
62 | mOrganizer = i.mOrganizer; | 64 | mOrganizer = i.mOrganizer; |
63 | mUid = i.mUid; | 65 | mUid = i.mUid; |
64 | mCalEnabled = i.mCalEnabled; | 66 | mCalEnabled = i.mCalEnabled; |
65 | mAlarmEnabled = i.mAlarmEnabled; | 67 | mAlarmEnabled = i.mAlarmEnabled; |
66 | mCalID = i.mCalID; | 68 | mCalID = i.mCalID; |
67 | QPtrList<Attendee> attendees = i.attendees(); | 69 | Q3PtrList<Attendee> attendees = i.attendees(); |
68 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { | 70 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { |
69 | mAttendees.append( new Attendee( *a ) ); | 71 | mAttendees.append( new Attendee( *a ) ); |
70 | } | 72 | } |
71 | mFloats = i.mFloats; | 73 | mFloats = i.mFloats; |
72 | mLastModified = i.mLastModified; | 74 | mLastModified = i.mLastModified; |
73 | mPilotId = i.mPilotId; | 75 | mPilotId = i.mPilotId; |
74 | mTempSyncStat = i.mTempSyncStat; | 76 | mTempSyncStat = i.mTempSyncStat; |
75 | mSyncStatus = i.mSyncStatus; | 77 | mSyncStatus = i.mSyncStatus; |
76 | mExternalId = i.mExternalId; | 78 | mExternalId = i.mExternalId; |
77 | // The copied object is a new one, so it isn't observed by the observer | 79 | // The copied object is a new one, so it isn't observed by the observer |
78 | // of the original object. | 80 | // of the original object. |
79 | mObservers.clear(); | 81 | mObservers.clear(); |
80 | 82 | ||
81 | mAttendees.setAutoDelete( true ); | 83 | mAttendees.setAutoDelete( true ); |
82 | } | 84 | } |
83 | 85 | ||
84 | IncidenceBase::~IncidenceBase() | 86 | IncidenceBase::~IncidenceBase() |
85 | { | 87 | { |
86 | } | 88 | } |
87 | 89 | ||
88 | 90 | ||
89 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | 91 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) |
90 | { | 92 | { |
91 | // do not compare mSyncStatus and mExternalId | 93 | // do not compare mSyncStatus and mExternalId |
92 | if( i1.attendees().count() != i2.attendees().count() ) { | 94 | if( i1.attendees().count() != i2.attendees().count() ) { |
93 | return false; // no need to check further | 95 | return false; // no need to check further |
94 | } | 96 | } |
95 | if ( i1.attendees().count() > 0 ) { | 97 | if ( i1.attendees().count() > 0 ) { |
96 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; | 98 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; |
97 | while ( a1 ) { | 99 | while ( a1 ) { |
98 | if ( !( (*a1) == (*a2)) ) | 100 | if ( !( (*a1) == (*a2)) ) |
99 | { | 101 | { |
@@ -271,135 +273,135 @@ QString IncidenceBase::dtStartTimeStr() const | |||
271 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const | 273 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const |
272 | { | 274 | { |
273 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 275 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
274 | } | 276 | } |
275 | 277 | ||
276 | QString IncidenceBase::dtStartStr(bool shortfmt) const | 278 | QString IncidenceBase::dtStartStr(bool shortfmt) const |
277 | { | 279 | { |
278 | if ( doesFloat() ) | 280 | if ( doesFloat() ) |
279 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 281 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
280 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); | 282 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); |
281 | } | 283 | } |
282 | 284 | ||
283 | 285 | ||
284 | bool IncidenceBase::doesFloat() const | 286 | bool IncidenceBase::doesFloat() const |
285 | { | 287 | { |
286 | return mFloats; | 288 | return mFloats; |
287 | } | 289 | } |
288 | 290 | ||
289 | void IncidenceBase::setFloats(bool f) | 291 | void IncidenceBase::setFloats(bool f) |
290 | { | 292 | { |
291 | if (mReadOnly) return; | 293 | if (mReadOnly) return; |
292 | mFloats = f; | 294 | mFloats = f; |
293 | updated(); | 295 | updated(); |
294 | } | 296 | } |
295 | 297 | ||
296 | 298 | ||
297 | bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) | 299 | bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) |
298 | { | 300 | { |
299 | if (mReadOnly) return false; | 301 | if (mReadOnly) return false; |
300 | if (a->name().left(7).upper() == "MAILTO:") | 302 | if (a->name().left(7).upper() == "MAILTO:") |
301 | a->setName(a->name().remove(0,7)); | 303 | a->setName(a->name().remove(0,7)); |
302 | 304 | ||
303 | QPtrListIterator<Attendee> qli(mAttendees); | 305 | Q3PtrListIterator<Attendee> qli(mAttendees); |
304 | 306 | ||
305 | qli.toFirst(); | 307 | qli.toFirst(); |
306 | while (qli) { | 308 | while (qli) { |
307 | if (*qli.current() == *a) | 309 | if (*qli.current() == *a) |
308 | return false; | 310 | return false; |
309 | ++qli; | 311 | ++qli; |
310 | } | 312 | } |
311 | mAttendees.append(a); | 313 | mAttendees.append(a); |
312 | if (doupdate) updated(); | 314 | if (doupdate) updated(); |
313 | return true; | 315 | return true; |
314 | } | 316 | } |
315 | 317 | ||
316 | #if 0 | 318 | #if 0 |
317 | void IncidenceBase::removeAttendee(Attendee *a) | 319 | void IncidenceBase::removeAttendee(Attendee *a) |
318 | { | 320 | { |
319 | if (mReadOnly) return; | 321 | if (mReadOnly) return; |
320 | mAttendees.removeRef(a); | 322 | mAttendees.removeRef(a); |
321 | updated(); | 323 | updated(); |
322 | } | 324 | } |
323 | 325 | ||
324 | void IncidenceBase::removeAttendee(const char *n) | 326 | void IncidenceBase::removeAttendee(const char *n) |
325 | { | 327 | { |
326 | Attendee *a; | 328 | Attendee *a; |
327 | 329 | ||
328 | if (mReadOnly) return; | 330 | if (mReadOnly) return; |
329 | for (a = mAttendees.first(); a; a = mAttendees.next()) | 331 | for (a = mAttendees.first(); a; a = mAttendees.next()) |
330 | if (a->getName() == n) { | 332 | if (a->getName() == n) { |
331 | mAttendees.remove(); | 333 | mAttendees.remove(); |
332 | break; | 334 | break; |
333 | } | 335 | } |
334 | } | 336 | } |
335 | #endif | 337 | #endif |
336 | 338 | ||
337 | void IncidenceBase::clearAttendees() | 339 | void IncidenceBase::clearAttendees() |
338 | { | 340 | { |
339 | if (mReadOnly) return; | 341 | if (mReadOnly) return; |
340 | mAttendees.clear(); | 342 | mAttendees.clear(); |
341 | } | 343 | } |
342 | 344 | ||
343 | #if 0 | 345 | #if 0 |
344 | Attendee *IncidenceBase::getAttendee(const char *n) const | 346 | Attendee *IncidenceBase::getAttendee(const char *n) const |
345 | { | 347 | { |
346 | QPtrListIterator<Attendee> qli(mAttendees); | 348 | Q3PtrListIterator<Attendee> qli(mAttendees); |
347 | 349 | ||
348 | qli.toFirst(); | 350 | qli.toFirst(); |
349 | while (qli) { | 351 | while (qli) { |
350 | if (qli.current()->getName() == n) | 352 | if (qli.current()->getName() == n) |
351 | return qli.current(); | 353 | return qli.current(); |
352 | ++qli; | 354 | ++qli; |
353 | } | 355 | } |
354 | return 0L; | 356 | return 0L; |
355 | } | 357 | } |
356 | #endif | 358 | #endif |
357 | 359 | ||
358 | Attendee *IncidenceBase::attendeeByMail(const QString &email) | 360 | Attendee *IncidenceBase::attendeeByMail(const QString &email) |
359 | { | 361 | { |
360 | QPtrListIterator<Attendee> qli(mAttendees); | 362 | Q3PtrListIterator<Attendee> qli(mAttendees); |
361 | 363 | ||
362 | qli.toFirst(); | 364 | qli.toFirst(); |
363 | while (qli) { | 365 | while (qli) { |
364 | if (qli.current()->email().lower() == email.lower()) | 366 | if (qli.current()->email().lower() == email.lower()) |
365 | return qli.current(); | 367 | return qli.current(); |
366 | ++qli; | 368 | ++qli; |
367 | } | 369 | } |
368 | return 0L; | 370 | return 0L; |
369 | } | 371 | } |
370 | 372 | ||
371 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) | 373 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) |
372 | { | 374 | { |
373 | QPtrListIterator<Attendee> qli(mAttendees); | 375 | Q3PtrListIterator<Attendee> qli(mAttendees); |
374 | 376 | ||
375 | QStringList mails = emails; | 377 | QStringList mails = emails; |
376 | if (!email.isEmpty()) { | 378 | if (!email.isEmpty()) { |
377 | mails.append(email); | 379 | mails.append(email); |
378 | } | 380 | } |
379 | qli.toFirst(); | 381 | qli.toFirst(); |
380 | while (qli) { | 382 | while (qli) { |
381 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { | 383 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { |
382 | if (qli.current()->email().lower() == (*it).lower()) | 384 | if (qli.current()->email().lower() == (*it).lower()) |
383 | return qli.current(); | 385 | return qli.current(); |
384 | } | 386 | } |
385 | 387 | ||
386 | ++qli; | 388 | ++qli; |
387 | } | 389 | } |
388 | return 0L; | 390 | return 0L; |
389 | } | 391 | } |
390 | 392 | ||
391 | void IncidenceBase::setDuration(int seconds) | 393 | void IncidenceBase::setDuration(int seconds) |
392 | { | 394 | { |
393 | mDuration = seconds; | 395 | mDuration = seconds; |
394 | setHasDuration(true); | 396 | setHasDuration(true); |
395 | } | 397 | } |
396 | 398 | ||
397 | int IncidenceBase::duration() const | 399 | int IncidenceBase::duration() const |
398 | { | 400 | { |
399 | return mDuration; | 401 | return mDuration; |
400 | } | 402 | } |
401 | 403 | ||
402 | void IncidenceBase::setHasDuration(bool b) | 404 | void IncidenceBase::setHasDuration(bool b) |
403 | { | 405 | { |
404 | mHasDuration = b; | 406 | mHasDuration = b; |
405 | } | 407 | } |
@@ -462,39 +464,39 @@ QString IncidenceBase::getID( const QString & prof) | |||
462 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 | 464 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 |
463 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) | 465 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) |
464 | { | 466 | { |
465 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); | 467 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); |
466 | } | 468 | } |
467 | QString IncidenceBase::getCsum( const QString & prof) | 469 | QString IncidenceBase::getCsum( const QString & prof) |
468 | { | 470 | { |
469 | return KIdManager::getCsum ( mExternalId, prof ); | 471 | return KIdManager::getCsum ( mExternalId, prof ); |
470 | } | 472 | } |
471 | 473 | ||
472 | void IncidenceBase::setIDStr( const QString & s ) | 474 | void IncidenceBase::setIDStr( const QString & s ) |
473 | { | 475 | { |
474 | if (mReadOnly) return; | 476 | if (mReadOnly) return; |
475 | mExternalId = s; | 477 | mExternalId = s; |
476 | } | 478 | } |
477 | 479 | ||
478 | QString IncidenceBase::IDStr() const | 480 | QString IncidenceBase::IDStr() const |
479 | { | 481 | { |
480 | return mExternalId ; | 482 | return mExternalId ; |
481 | } | 483 | } |
482 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) | 484 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) |
483 | { | 485 | { |
484 | if( !mObservers.contains(observer) ) mObservers.append( observer ); | 486 | if( !mObservers.contains(observer) ) mObservers.append( observer ); |
485 | } | 487 | } |
486 | 488 | ||
487 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) | 489 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) |
488 | { | 490 | { |
489 | mObservers.remove( observer ); | 491 | mObservers.remove( observer ); |
490 | } | 492 | } |
491 | 493 | ||
492 | void IncidenceBase::updated() | 494 | void IncidenceBase::updated() |
493 | { | 495 | { |
494 | QPtrListIterator<Observer> it(mObservers); | 496 | Q3PtrListIterator<Observer> it(mObservers); |
495 | while( it.current() ) { | 497 | while( it.current() ) { |
496 | Observer *o = it.current(); | 498 | Observer *o = it.current(); |
497 | ++it; | 499 | ++it; |
498 | o->incidenceUpdated( this ); | 500 | o->incidenceUpdated( this ); |
499 | } | 501 | } |
500 | } | 502 | } |