summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/incidencebase.cpp88
-rw-r--r--libkcal/incidencebase.h13
-rw-r--r--libkcal/sharpformat.cpp20
3 files changed, 31 insertions, 90 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 5d8785b..15c4fa8 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -23,2 +23,3 @@
23#include <kdebug.h> 23#include <kdebug.h>
24#include <kidmanager.h>
24 25
@@ -40,3 +41,2 @@ IncidenceBase::IncidenceBase() :
40 mPilotId = 0; 41 mPilotId = 0;
41 mZaurusUid = 0;
42 mExternalId = ":"; 42 mExternalId = ":";
@@ -63,3 +63,2 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) :
63 mPilotId = i.mPilotId; 63 mPilotId = i.mPilotId;
64 mZaurusUid = i.mZaurusUid;
65 mTempSyncStat = i.mTempSyncStat; 64 mTempSyncStat = i.mTempSyncStat;
@@ -343,12 +342,2 @@ int IncidenceBase::pilotId() const
343 342
344int IncidenceBase::zaurusUid() const
345{
346 return mZaurusUid;
347}
348void IncidenceBase::setZaurusUid( int id )
349{
350 if (mReadOnly) return;
351 mZaurusUid = id;
352}
353
354int IncidenceBase::tempSyncStat() const 343int IncidenceBase::tempSyncStat() const
@@ -363,33 +352,14 @@ void IncidenceBase::setTempSyncStat( int id )
363 352
364void IncidenceBase::setID( const QString & prof , int id ) 353void IncidenceBase::removeID(const QString &prof)
365{ 354{
366 int num = mExternalId.find( ":"+prof+";" ); 355 mExternalId = KIdManager::removeId ( mExternalId, prof);
367 if ( num >= 0 ) { 356
368 int len = prof.length()+2;
369 int end = mExternalId.find( ";", num+len );
370 if ( end > 0 ) {
371 mExternalId = mExternalId.left( num+len ) +QString::number( id)+mExternalId.mid( end );
372 } else
373 qDebug("Error in IncidenceBase::setID ");
374 } else {
375 mExternalId += prof+";"+QString::number( id) +";0:";
376 }
377 qDebug("setID*%s*%d*%s* ", prof.latin1(), id,mExternalId.latin1() );
378} 357}
379int IncidenceBase::getID( const QString & prof) 358void IncidenceBase::setID( const QString & prof , const QString & id )
380{ 359{
381 int ret = -1; 360 mExternalId = KIdManager::setId ( mExternalId, prof, id );
382 int num = mExternalId.find(":"+ prof+";" );
383 if ( num >= 0 ) {
384 int len = prof.length()+2;
385 int end = mExternalId.find( ";", num+len );
386 if ( end > 0 ) {
387 bool ok;
388 ret = mExternalId.mid ( num + len,end-len-num).toInt( &ok );
389 if (!ok)
390 ret = -1;
391 }
392 } 361 }
393 qDebug("getID*%s*%d*%s* ", prof.latin1(), ret,mExternalId.latin1() ); 362QString IncidenceBase::getID( const QString & prof)
394 return ret; 363{
364 return KIdManager::getId ( mExternalId, prof );
395} 365}
@@ -398,35 +368,9 @@ int IncidenceBase::getID( const QString & prof)
398// format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 368// format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0
399void IncidenceBase::setCsum( const QString & prof , int id ) 369void IncidenceBase::setCsum( const QString & prof , const QString & id )
400{ 370{
401 int num = mExternalId.find( ":"+prof+";"); 371 mExternalId = KIdManager::setCsum ( mExternalId, prof, id );
402 if ( num >= 0 ) { 372}
403 int len = prof.length()+2; 373QString IncidenceBase::getCsum( const QString & prof)
404 num = mExternalId.find( ";", num+len ); 374{
405 int end = mExternalId.find( ":", num+1 ); 375 return KIdManager::getCsum ( mExternalId, prof );
406 if ( end > 0 ) {
407 mExternalId = mExternalId.left( num ) +QString::number(id)+mExternalId.mid( end );
408 } else
409 qDebug("Error in IncidenceBase::setCsum ");
410 } else {
411 mExternalId += prof+";-1;"+QString::number( id) +":";
412 }
413 qDebug("setCsum*%s*%d*%s* ", prof.latin1(), id,mExternalId.latin1() );
414}
415int IncidenceBase::getCsum( const QString & prof)
416{
417 int ret = -1;
418 int num = mExternalId.find( ":"+prof+";" );
419 if ( num >= 0 ) {
420 int len = prof.length()+2;
421 num = mExternalId.find( ";", num+len );
422 int end = mExternalId.find( ":", num+1 );
423 if ( end > 0 ) {
424 bool ok;
425 ret = mExternalId.mid ( num ,end-num).toInt( &ok );
426 if (!ok)
427 ret = -1;
428 }
429 }
430 qDebug("getCsum*%s*%d*%s* ", prof.latin1(), ret,mExternalId.latin1() );
431 return ret;
432} 376}
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index e2950d3..e02d03a 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -128,4 +128,2 @@ class IncidenceBase : public CustomProperties
128 128
129 void setZaurusUid(int id);
130 int zaurusUid() const;
131 void setTempSyncStat(int id); 129 void setTempSyncStat(int id);
@@ -134,7 +132,7 @@ class IncidenceBase : public CustomProperties
134 QString IDStr() const; 132 QString IDStr() const;
135 void setID( const QString &, int ); 133 void setID( const QString &, const QString & );
136 int getID( const QString & ); 134 QString getID( const QString & );
137 void setCsum( const QString &, int ); 135 void setCsum( const QString &, const QString & );
138 int getCsum( const QString & ); 136 QString getCsum( const QString & );
139 137 void removeID(const QString &);
140 138
@@ -161,3 +159,2 @@ class IncidenceBase : public CustomProperties
161 QString mExternalId; 159 QString mExternalId;
162 int mZaurusUid;
163 int mTempSyncStat; 160 int mTempSyncStat;
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index 605a54d..e8934bf 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -92,4 +92,4 @@ class SharpParser : public QObject
92 event = new Event; 92 event = new Event;
93 event->setID("Sharp_DTM", attList[0].toInt() ); 93 event->setID("Sharp_DTM", attList[0] );
94 event->setZaurusUid( cSum ); 94 event->setCsum( "Sharp_DTM", QString::number( cSum ));
95 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); 95 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
@@ -203,4 +203,4 @@ class SharpParser : public QObject
203 203
204 todo->setID( "Sharp_DTM", attList[0].toInt() ); 204 todo->setID( "Sharp_DTM", attList[0]);
205 todo->setZaurusUid( cSum ); 205 todo->setCsum( "Sharp_DTM", QString::number( cSum ));
206 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 206 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
@@ -468,4 +468,4 @@ int SharpFormat::getNumFromRecord( QString answer, Incidence* inc )
468 retval = newnum; 468 retval = newnum;
469 inc->setID( "Sharp_DTM",newnum ); 469 inc->setID( "Sharp_DTM",templist[0] );
470 inc->setZaurusUid( getCsum( templist ) ); 470 inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) ));
471 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 471 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
@@ -522,3 +522,3 @@ bool SharpFormat::save( Calendar *calendar)
522 } 522 }
523 else if ( ev->getID("Sharp_DTM") == -1 ) { // add new 523 else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new
524 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 524 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
@@ -608,3 +608,3 @@ bool SharpFormat::save( Calendar *calendar)
608 } 608 }
609 else if ( to->getID("Sharp_DTM") == -1 ) { // add new 609 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new
610 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; 610 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName;
@@ -698,3 +698,3 @@ QString SharpFormat::getEventString( Event* event )
698 QStringList list; 698 QStringList list;
699 list.append( QString::number(event->getID("Sharp_DTM") ) ); 699 list.append( event->getID("Sharp_DTM") );
700 list.append( event->categories().join(",") ); 700 list.append( event->categories().join(",") );
@@ -862,3 +862,3 @@ QString SharpFormat::getTodoString( Todo* todo )
862 QStringList list; 862 QStringList list;
863 list.append( QString::number( todo->getID("Sharp_DTM") ) ); 863 list.append( todo->getID("Sharp_DTM") );
864 list.append( todo->categories().join(",") ); 864 list.append( todo->categories().join(",") );