summaryrefslogtreecommitdiffabout
path: root/kabc
Side-by-side diff
Diffstat (limited to 'kabc') (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
4 files changed, 41 insertions, 4 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 1050f55..ff05f7e 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -405,8 +405,9 @@ void AddressBook::export2File( QString fileName )
}
-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 );
@@ -428,7 +429,26 @@ void AddressBook::importFromFile( QString fileName, bool 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
@@ -145,3 +145,5 @@ class AddressBook : public QObject
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();
/**
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 3f3d5c0..607ae26 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -90,2 +90,3 @@ struct Addressee::AddresseeData : public KShared
bool changed :1;
+ bool tagged :1;
};
@@ -1823,2 +1824,13 @@ 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
@@ -835,2 +835,5 @@ class Addressee
+ void setTagged( bool value );
+ bool tagged() const;
+
private: