-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 | |||
@@ -40,6 +40,7 @@ IncidenceBase::IncidenceBase() : | |||
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 ); |
@@ -65,7 +66,7 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) : | |||
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(); |
@@ -80,7 +81,7 @@ IncidenceBase::~IncidenceBase() | |||
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 | } |
@@ -372,6 +373,82 @@ void IncidenceBase::setTempSyncStat( int id ) | |||
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 ); |