summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/icalformatimpl.cpp16
-rw-r--r--libkcal/incidencebase.cpp81
-rw-r--r--libkcal/incidencebase.h8
3 files changed, 92 insertions, 13 deletions
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index df05ab3..c23978d 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -269,9 +269,6 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
269 } 269 }
270 if (incidence->zaurusId() >= 0) { 270 if ( !incidence->IDStr().isEmpty()) {
271 incidence->setNonKDECustomProperty("X-ZAURUSID", QString::number(incidence->zaurusId())); 271 incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() );
272 } 272 }
273 273
274 if (incidence->zaurusUid() > 0) {
275 incidence->setNonKDECustomProperty("X-ZAURUSUID", QString::number(incidence->zaurusUid()));
276 }
277 274
@@ -1282,10 +1279,7 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence)
1282 } 1279 }
1283 kp = incidence->nonKDECustomProperty("X-ZAURUSID");
1284 if (!kp.isNull()) {
1285 incidence->setZaurusId(kp.toInt());
1286 }
1287 1280
1288 kp = incidence->nonKDECustomProperty("X-ZAURUSUID"); 1281
1282 kp = incidence->nonKDECustomProperty("X-KOPIEXTID");
1289 if (!kp.isNull()) { 1283 if (!kp.isNull()) {
1290 incidence->setZaurusUid(kp.toInt()); 1284 incidence->setIDStr(kp);
1291 } 1285 }
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 707d666..d7c4595 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -42,2 +42,3 @@ IncidenceBase::IncidenceBase() :
42 mZaurusUid = 0; 42 mZaurusUid = 0;
43 mExternalId = ":";
43 mTempSyncStat = 0; 44 mTempSyncStat = 0;
@@ -67,3 +68,3 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) :
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
@@ -82,3 +83,3 @@ 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() ) {
@@ -374,2 +375,78 @@ void IncidenceBase::setTempSyncStat( int id )
374 375
376void 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}
390int 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
409void 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}
424int 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
442void IncidenceBase::setIDStr( const QString & s )
443{
444 if (mReadOnly) return;
445 mExternalId = s;
446}
447
448QString IncidenceBase::IDStr() const
449{
450 return mExternalId ;
451}
375void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) 452void IncidenceBase::registerObserver( IncidenceBase::Observer *observer )
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index ce6e254..2f85df6 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -134,2 +134,9 @@ class IncidenceBase : public CustomProperties
134 int tempSyncStat() const; 134 int tempSyncStat() const;
135 void setIDStr( const QString & );
136 QString IDStr() const;
137 void setID( const QString &, int );
138 int getID( const QString & );
139 void setCsum( const QString &, int );
140 int getCsum( const QString & );
141
135 142
@@ -155,2 +162,3 @@ class IncidenceBase : public CustomProperties
155 bool mHasDuration; 162 bool mHasDuration;
163 QString mExternalId;
156 int mZaurusId; 164 int mZaurusId;