-rw-r--r-- | kabc/addressbook.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index ec9f893..46a9cf4 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -345,5 +345,10 @@ bool AddressBook::load() Addressee::List::Iterator addrIt; - for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) + for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { (*addrIt).setChanged( false ); - + QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); + if ( !id.isEmpty() ) { + //qDebug("setId aa %s ", id.latin1()); + (*addrIt).setIDStr(id ); + } + } blockLSEchange = true; @@ -368,3 +373,8 @@ bool AddressBook::saveAB() deleteRemovedAddressees(); - + Iterator ait; + for ( ait = begin(); ait != end(); ++ait ) { + if ( !(*ait).IDStr().isEmpty() ) { + (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); + } + } KRES::Manager<Resource>::ActiveIterator it; @@ -452,4 +462,6 @@ void AddressBook::insertAddressee( const Addressee &a, bool setRev ) if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { + //qDebug("block insert "); return; } + //qDebug("inserting.... %s ",a.uid().latin1() ); bool found = false; @@ -482,3 +494,3 @@ void AddressBook::insertAddressee( const Addressee &a, bool setRev ) } else { - if ( (*it).uid() == QString("last-syncAddressee-") ) { + if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { QString name = (*it).uid().mid( 19 ); @@ -518,3 +530,3 @@ void AddressBook::removeAddressee( const Addressee &a ) } else { - if ( (*it).uid() == QString("last-syncAddressee-") ) { + if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { QString name = (*it).uid().mid( 19 ); @@ -547,9 +559,14 @@ void AddressBook::removeDeletedAddressees() (*it).setRevision( dt ); - if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { + (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); + (*it).setIDStr(""); + if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { it2 = it; + //qDebug("removing %s ",(*it).uid().latin1() ); ++it; removeAddressee( it2 ); - } else + } else { + //qDebug("skipping %s ",(*it).uid().latin1() ); ++it; } + } deleteRemovedAddressees(); |