summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-07 11:30:06 (UTC)
committer zautrix <zautrix>2004-08-07 11:30:06 (UTC)
commit835cc1b2c671bf2ab228362cf4ea2e4a04a1d5e5 (patch) (side-by-side diff)
tree816191299c688a7de051703af11d0ba4f8c8247f
parent55ad0e5d505055016a0e5032bcc8f9355dfff210 (diff)
downloadkdepimpi-835cc1b2c671bf2ab228362cf4ea2e4a04a1d5e5.zip
kdepimpi-835cc1b2c671bf2ab228362cf4ea2e4a04a1d5e5.tar.gz
kdepimpi-835cc1b2c671bf2ab228362cf4ea2e4a04a1d5e5.tar.bz2
More sync stuff converted
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp20
-rw-r--r--libkcal/incidencebase.cpp88
-rw-r--r--libkcal/incidencebase.h13
-rw-r--r--libkcal/sharpformat.cpp20
4 files changed, 41 insertions, 100 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index fab4540..5150455 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -729,3 +729,3 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
bool remCh, locCh;
- remCh = ( remote->zaurusUid() != local->zaurusUid() );
+ remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
locCh = ( local->lastModified() > mLastCalendarSync );
@@ -775,3 +775,3 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
- local->setZaurusUid( remote->zaurusUid() );
+ local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
}
@@ -897,4 +897,4 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t
while ( eve ) {
- int id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
- if ( id >= 0 ) {
+ QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
+ if ( !id.isEmpty() ) {
QString des = eve->description();
@@ -903,3 +903,3 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t
pref = "t";
- des += pref+ QString::number ( id ) + ",";
+ des += pref+ id + ",";
eve->setReadOnly( false );
@@ -1015,3 +1015,3 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
if ( take == 1 ) {// take local
- inL->setZaurusUid( inR->zaurusUid() );
+ inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
remote->deleteIncidence( inR );
@@ -1035,3 +1035,3 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
pref = "t";
- if ( des.find(pref+QString::number( inR->getID(mCurrentSyncDevice) ) +"," ) >= 0 && mode != 5) { // delete it
+ if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
@@ -1085,3 +1085,3 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
- if ( inL->getID(mCurrentSyncDevice) >= 0 && mode != 4 ) {
+ if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
local->deleteIncidence( inL );
@@ -1090,3 +1090,3 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
- inL->setID(mCurrentSyncDevice, -1 );
+ inL->removeID(mCurrentSyncDevice );
++addedEventR;
@@ -1210,3 +1210,3 @@ void CalendarView::syncSharp()
loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
- loc->setZaurusUid( inc->zaurusUid() );
+ loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
}
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 @@
#include <kdebug.h>
+#include <kidmanager.h>
@@ -40,3 +41,2 @@ IncidenceBase::IncidenceBase() :
mPilotId = 0;
- mZaurusUid = 0;
mExternalId = ":";
@@ -63,3 +63,2 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) :
mPilotId = i.mPilotId;
- mZaurusUid = i.mZaurusUid;
mTempSyncStat = i.mTempSyncStat;
@@ -343,12 +342,2 @@ int IncidenceBase::pilotId() const
-int IncidenceBase::zaurusUid() const
-{
- return mZaurusUid;
-}
-void IncidenceBase::setZaurusUid( int id )
-{
- if (mReadOnly) return;
- mZaurusUid = id;
-}
-
int IncidenceBase::tempSyncStat() const
@@ -363,33 +352,14 @@ void IncidenceBase::setTempSyncStat( int id )
-void IncidenceBase::setID( const QString & prof , int id )
+void IncidenceBase::removeID(const QString &prof)
{
- int num = mExternalId.find( ":"+prof+";" );
- if ( num >= 0 ) {
- int len = prof.length()+2;
- int end = mExternalId.find( ";", num+len );
- if ( end > 0 ) {
- mExternalId = mExternalId.left( num+len ) +QString::number( id)+mExternalId.mid( end );
- } else
- qDebug("Error in IncidenceBase::setID ");
- } else {
- mExternalId += prof+";"+QString::number( id) +";0:";
- }
- qDebug("setID*%s*%d*%s* ", prof.latin1(), id,mExternalId.latin1() );
+ mExternalId = KIdManager::removeId ( mExternalId, prof);
+
}
-int IncidenceBase::getID( const QString & prof)
+void IncidenceBase::setID( const QString & prof , const QString & id )
{
- int ret = -1;
- int num = mExternalId.find(":"+ prof+";" );
- if ( num >= 0 ) {
- int len = prof.length()+2;
- int end = mExternalId.find( ";", num+len );
- if ( end > 0 ) {
- bool ok;
- ret = mExternalId.mid ( num + len,end-len-num).toInt( &ok );
- if (!ok)
- ret = -1;
- }
+ mExternalId = KIdManager::setId ( mExternalId, prof, id );
}
- qDebug("getID*%s*%d*%s* ", prof.latin1(), ret,mExternalId.latin1() );
- return ret;
+QString IncidenceBase::getID( const QString & prof)
+{
+ return KIdManager::getId ( mExternalId, prof );
}
@@ -398,35 +368,9 @@ int IncidenceBase::getID( const QString & prof)
// format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0
-void IncidenceBase::setCsum( const QString & prof , int id )
-{
- int num = mExternalId.find( ":"+prof+";");
- if ( num >= 0 ) {
- int len = prof.length()+2;
- num = mExternalId.find( ";", num+len );
- int end = mExternalId.find( ":", num+1 );
- if ( end > 0 ) {
- mExternalId = mExternalId.left( num ) +QString::number(id)+mExternalId.mid( end );
- } else
- qDebug("Error in IncidenceBase::setCsum ");
- } else {
- mExternalId += prof+";-1;"+QString::number( id) +":";
- }
- qDebug("setCsum*%s*%d*%s* ", prof.latin1(), id,mExternalId.latin1() );
-}
-int IncidenceBase::getCsum( const QString & prof)
-{
- int ret = -1;
- int num = mExternalId.find( ":"+prof+";" );
- if ( num >= 0 ) {
- int len = prof.length()+2;
- num = mExternalId.find( ";", num+len );
- int end = mExternalId.find( ":", num+1 );
- if ( end > 0 ) {
- bool ok;
- ret = mExternalId.mid ( num ,end-num).toInt( &ok );
- if (!ok)
- ret = -1;
- }
- }
- qDebug("getCsum*%s*%d*%s* ", prof.latin1(), ret,mExternalId.latin1() );
- return ret;
+void IncidenceBase::setCsum( const QString & prof , const QString & id )
+{
+ mExternalId = KIdManager::setCsum ( mExternalId, prof, id );
+}
+QString IncidenceBase::getCsum( const QString & prof)
+{
+ return KIdManager::getCsum ( mExternalId, prof );
}
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
- void setZaurusUid(int id);
- int zaurusUid() const;
void setTempSyncStat(int id);
@@ -134,7 +132,7 @@ class IncidenceBase : public CustomProperties
QString IDStr() const;
- void setID( const QString &, int );
- int getID( const QString & );
- void setCsum( const QString &, int );
- int getCsum( const QString & );
-
+ void setID( const QString &, const QString & );
+ QString getID( const QString & );
+ void setCsum( const QString &, const QString & );
+ QString getCsum( const QString & );
+ void removeID(const QString &);
@@ -161,3 +159,2 @@ class IncidenceBase : public CustomProperties
QString mExternalId;
- int mZaurusUid;
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
event = new Event;
- event->setID("Sharp_DTM", attList[0].toInt() );
- event->setZaurusUid( cSum );
+ event->setID("Sharp_DTM", attList[0] );
+ event->setCsum( "Sharp_DTM", QString::number( cSum ));
event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
@@ -203,4 +203,4 @@ class SharpParser : public QObject
- todo->setID( "Sharp_DTM", attList[0].toInt() );
- todo->setZaurusUid( cSum );
+ todo->setID( "Sharp_DTM", attList[0]);
+ todo->setCsum( "Sharp_DTM", QString::number( cSum ));
todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
@@ -468,4 +468,4 @@ int SharpFormat::getNumFromRecord( QString answer, Incidence* inc )
retval = newnum;
- inc->setID( "Sharp_DTM",newnum );
- inc->setZaurusUid( getCsum( templist ) );
+ inc->setID( "Sharp_DTM",templist[0] );
+ inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) ));
inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
@@ -522,3 +522,3 @@ bool SharpFormat::save( Calendar *calendar)
}
- else if ( ev->getID("Sharp_DTM") == -1 ) { // add new
+ else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new
command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
@@ -608,3 +608,3 @@ bool SharpFormat::save( Calendar *calendar)
}
- else if ( to->getID("Sharp_DTM") == -1 ) { // add new
+ else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new
command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName;
@@ -698,3 +698,3 @@ QString SharpFormat::getEventString( Event* event )
QStringList list;
- list.append( QString::number(event->getID("Sharp_DTM") ) );
+ list.append( event->getID("Sharp_DTM") );
list.append( event->categories().join(",") );
@@ -862,3 +862,3 @@ QString SharpFormat::getTodoString( Todo* todo )
QStringList list;
- list.append( QString::number( todo->getID("Sharp_DTM") ) );
+ list.append( todo->getID("Sharp_DTM") );
list.append( todo->categories().join(",") );