-rw-r--r-- | libkcal/incidencebase.cpp | 81 |
1 files changed, 79 insertions, 2 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 707d666..d7c4595 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -35,16 +35,17 @@ IncidenceBase::IncidenceBase() : | |||
35 | setUid(CalFormat::createUniqueId()); | 35 | setUid(CalFormat::createUniqueId()); |
36 | mOrganizer = ""; | 36 | mOrganizer = ""; |
37 | mFloats = false; | 37 | mFloats = false; |
38 | mDuration = 0; | 38 | mDuration = 0; |
39 | mHasDuration = false; | 39 | mHasDuration = false; |
40 | mPilotId = 0; | 40 | mPilotId = 0; |
41 | mZaurusId = -1; | 41 | mZaurusId = -1; |
42 | mZaurusUid = 0; | 42 | mZaurusUid = 0; |
43 | mExternalId = ":"; | ||
43 | mTempSyncStat = 0; | 44 | mTempSyncStat = 0; |
44 | mSyncStatus = 0; | 45 | mSyncStatus = 0; |
45 | mAttendees.setAutoDelete( true ); | 46 | mAttendees.setAutoDelete( true ); |
46 | } | 47 | } |
47 | 48 | ||
48 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : | 49 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : |
49 | CustomProperties( i ) | 50 | CustomProperties( i ) |
50 | { | 51 | { |
@@ -60,32 +61,32 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) : | |||
60 | } | 61 | } |
61 | mFloats = i.mFloats; | 62 | mFloats = i.mFloats; |
62 | mLastModified = i.mLastModified; | 63 | mLastModified = i.mLastModified; |
63 | mPilotId = i.mPilotId; | 64 | mPilotId = i.mPilotId; |
64 | mZaurusId = i.mZaurusId; | 65 | mZaurusId = i.mZaurusId; |
65 | mZaurusUid = i.mZaurusUid; | 66 | mZaurusUid = i.mZaurusUid; |
66 | mTempSyncStat = i.mTempSyncStat; | 67 | mTempSyncStat = i.mTempSyncStat; |
67 | mSyncStatus = i.mSyncStatus; | 68 | mSyncStatus = i.mSyncStatus; |
68 | 69 | mExternalId = i.mExternalId; | |
69 | // The copied object is a new one, so it isn't observed by the observer | 70 | // The copied object is a new one, so it isn't observed by the observer |
70 | // of the original object. | 71 | // of the original object. |
71 | mObservers.clear(); | 72 | mObservers.clear(); |
72 | 73 | ||
73 | mAttendees.setAutoDelete( true ); | 74 | mAttendees.setAutoDelete( true ); |
74 | } | 75 | } |
75 | 76 | ||
76 | IncidenceBase::~IncidenceBase() | 77 | IncidenceBase::~IncidenceBase() |
77 | { | 78 | { |
78 | } | 79 | } |
79 | 80 | ||
80 | 81 | ||
81 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | 82 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) |
82 | { | 83 | { |
83 | 84 | // do not compare mSyncStatus and mExternalId | |
84 | if( i1.attendees().count() != i2.attendees().count() ) { | 85 | if( i1.attendees().count() != i2.attendees().count() ) { |
85 | return false; // no need to check further | 86 | return false; // no need to check further |
86 | } | 87 | } |
87 | if ( i1.attendees().count() > 0 ) { | 88 | if ( i1.attendees().count() > 0 ) { |
88 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; | 89 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; |
89 | while ( a1 ) { | 90 | while ( a1 ) { |
90 | if ( !( (*a1) == (*a2)) ) | 91 | if ( !( (*a1) == (*a2)) ) |
91 | { | 92 | { |
@@ -367,16 +368,92 @@ int IncidenceBase::tempSyncStat() const | |||
367 | return mTempSyncStat; | 368 | return mTempSyncStat; |
368 | } | 369 | } |
369 | void IncidenceBase::setTempSyncStat( int id ) | 370 | void IncidenceBase::setTempSyncStat( int id ) |
370 | { | 371 | { |
371 | if (mReadOnly) return; | 372 | if (mReadOnly) return; |
372 | mTempSyncStat = id; | 373 | mTempSyncStat = id; |
373 | } | 374 | } |
374 | 375 | ||
376 | void IncidenceBase::setID( const QString & prof , int id ) | ||
377 | { | ||
378 | int num = mExternalId.find( ":"+prof+";" ); | ||
379 | if ( num >= 0 ) { | ||
380 | int len = prof.length()+2; | ||
381 | int end = mExternalId.find( ";", num+len ); | ||
382 | if ( end > 0 ) { | ||
383 | mExternalId = mExternalId.left( num+len ) +QString::number( id)+mExternalId.mid( end ); | ||
384 | } else | ||
385 | qDebug("Error in IncidenceBase::setID "); | ||
386 | } else { | ||
387 | mExternalId += prof+";"+QString::number( id) +";0:"; | ||
388 | } | ||
389 | } | ||
390 | int IncidenceBase::getID( const QString & prof) | ||
391 | { | ||
392 | int ret = -1; | ||
393 | int num = mExternalId.find(":"+ prof+";" ); | ||
394 | if ( num >= 0 ) { | ||
395 | int len = prof.length()+2; | ||
396 | int end = mExternalId.find( ";", num+len ); | ||
397 | if ( end > 0 ) { | ||
398 | bool ok; | ||
399 | ret = mExternalId.mid ( num + len,end-len-num).toInt( &ok ); | ||
400 | if (!ok) | ||
401 | return -1; | ||
402 | } | ||
403 | } | ||
404 | return ret; | ||
405 | } | ||
406 | |||
407 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: | ||
408 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 | ||
409 | void IncidenceBase::setCsum( const QString & prof , int id ) | ||
410 | { | ||
411 | int num = mExternalId.find( ":"+prof+";"); | ||
412 | if ( num >= 0 ) { | ||
413 | int len = prof.length()+2; | ||
414 | num = mExternalId.find( ";", num+len ); | ||
415 | int end = mExternalId.find( ":", num+1 ); | ||
416 | if ( end > 0 ) { | ||
417 | mExternalId = mExternalId.left( num ) +QString::number(id)+mExternalId.mid( end ); | ||
418 | } else | ||
419 | qDebug("Error in IncidenceBase::setCsum "); | ||
420 | } else { | ||
421 | mExternalId += prof+";-1;"+QString::number( id) +":"; | ||
422 | } | ||
423 | } | ||
424 | int IncidenceBase::getCsum( const QString & prof) | ||
425 | { | ||
426 | int ret = -1; | ||
427 | int num = mExternalId.find( ":"+prof+";" ); | ||
428 | if ( num >= 0 ) { | ||
429 | int len = prof.length()+2; | ||
430 | num = mExternalId.find( ";", num+len ); | ||
431 | int end = mExternalId.find( ":", num+1 ); | ||
432 | if ( end > 0 ) { | ||
433 | bool ok; | ||
434 | ret = mExternalId.mid ( num ,end-num).toInt( &ok ); | ||
435 | if (!ok) | ||
436 | return -1; | ||
437 | } | ||
438 | } | ||
439 | return ret; | ||
440 | } | ||
441 | |||
442 | void IncidenceBase::setIDStr( const QString & s ) | ||
443 | { | ||
444 | if (mReadOnly) return; | ||
445 | mExternalId = s; | ||
446 | } | ||
447 | |||
448 | QString IncidenceBase::IDStr() const | ||
449 | { | ||
450 | return mExternalId ; | ||
451 | } | ||
375 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) | 452 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) |
376 | { | 453 | { |
377 | if( !mObservers.contains(observer) ) mObservers.append( observer ); | 454 | if( !mObservers.contains(observer) ) mObservers.append( observer ); |
378 | } | 455 | } |
379 | 456 | ||
380 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) | 457 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) |
381 | { | 458 | { |
382 | mObservers.remove( observer ); | 459 | mObservers.remove( observer ); |