author | zautrix <zautrix> | 2004-10-09 16:58:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-09 16:58:08 (UTC) |
commit | 59ed933d6c43ecb0ddd3dec53cc289ee8aa68482 (patch) (side-by-side diff) | |
tree | 8b1cbcf9c420e7dffd1e1293bcfa69e8e821f3fa /kabc/addressbook.cpp | |
parent | b80a099d9432bdc3d4eea778b1813b82b2680ecf (diff) | |
download | kdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.zip kdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.tar.gz kdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.tar.bz2 |
fixed sync bug
-rw-r--r-- | kabc/addressbook.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 1050f55..ff05f7e 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -394,52 +394,72 @@ void AddressBook::export2File( QString fileName ) if ( !(*it).IDStr().isEmpty() ) { (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); } KABC::VCardConverter converter; QString vcard; //Resource *resource() const; converter.addresseeToVCard( *it, vcard, version ); t << vcard << "\r\n"; } t << "\r\n\r\n"; outFile.close(); } -void AddressBook::importFromFile( QString fileName, bool replaceLabel ) +void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) { + if ( removeOld ) + setUntagged(); KABC::Addressee::List list; QFile file( fileName ); - file.open( IO_ReadOnly ); QByteArray rawData = file.readAll(); file.close(); QString data; if ( replaceLabel ) { data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); data.replace ( QRegExp("LABEL") , "ADR" ); data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); } else data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); KABC::VCardTool tool; list = tool.parseVCards( data ); KABC::Addressee::List::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { (*it).setResource( 0 ); if ( replaceLabel ) (*it).removeVoice(); + if ( removeOld ) + (*it).setTagged( true ); insertAddressee( (*it), false, true ); } - + if ( removeOld ) + removeUntagged(); +} +void AddressBook::setUntagged() +{ + Iterator ait; + for ( ait = begin(); ait != end(); ++ait ) { + (*ait).setTagged( false ); + } +} +void AddressBook::removeUntagged() +{ + Iterator ait; + for ( ait = begin(); ait != end(); ++ait ) { + if (!(*ait).tagged()) + removeAddressee( ait ); } + deleteRemovedAddressees(); +} bool AddressBook::saveAB() { bool ok = true; 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; |