summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-09 16:58:08 (UTC)
committer zautrix <zautrix>2004-10-09 16:58:08 (UTC)
commit59ed933d6c43ecb0ddd3dec53cc289ee8aa68482 (patch) (side-by-side diff)
tree8b1cbcf9c420e7dffd1e1293bcfa69e8e821f3fa
parentb80a099d9432bdc3d4eea778b1813b82b2680ecf (diff)
downloadkdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.zip
kdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.tar.gz
kdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.tar.bz2
fixed sync bug
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/addressbook.cpp26
-rw-r--r--kabc/addressbook.h4
-rw-r--r--kabc/addressee.cpp12
-rw-r--r--kabc/addressee.h3
-rw-r--r--kaddressbook/kabcore.cpp2
5 files changed, 42 insertions, 5 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 1050f55..ff05f7e 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -404,10 +404,11 @@ void AddressBook::export2File( QString fileName )
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();
@@ -427,9 +428,28 @@ void AddressBook::importFromFile( QString fileName, bool replaceLabel )
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()
{
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index cea1b03..532e05d 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -144,5 +144,7 @@ class AddressBook : public QObject
bool saveAB( );
void export2File( QString fileName );
- void importFromFile( QString fileName, bool replaceLabel = false );
+ void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false );
+ void setUntagged();
+ void removeUntagged();
/**
Returns a iterator for first entry of address book.
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 3f3d5c0..607ae26 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -89,4 +89,5 @@ struct Addressee::AddresseeData : public KShared
bool empty :1;
bool changed :1;
+ bool tagged :1;
};
@@ -1822,4 +1823,15 @@ bool Addressee::changed() const
}
+void Addressee::setTagged( bool value )
+{
+ detach();
+ mData->tagged = value;
+}
+
+bool Addressee::tagged() const
+{
+ return mData->tagged;
+}
+
QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
{
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 9336edc..0aa2c51 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -834,4 +834,7 @@ class Addressee
bool changed() const;
+ void setTagged( bool value );
+ bool tagged() const;
+
private:
Addressee copy();
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 7ec3fca..452f1bc 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2877,5 +2877,5 @@ void KABCore::getFile( bool success )
return;
}
- mAddressBook->importFromFile( sentSyncFile() );
+ mAddressBook->importFromFile( sentSyncFile() , false, true );
topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
mViewManager->refreshView();