summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Side-by-side diff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp42
1 files changed, 33 insertions, 9 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index e04f4b1..bdc2762 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -485,3 +485,3 @@ bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName )
}
-int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld )
+int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld, QString resource )
{
@@ -489,3 +489,3 @@ int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool remo
if ( removeOld )
- setUntagged( true );
+ setUntagged( true, resource );
KABC::Addressee::List list;
@@ -505,2 +505,16 @@ int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool remo
KABC::Addressee::List::Iterator it;
+
+ Resource * setRes = 0;
+ if ( !resource.isEmpty() ) {
+ KRES::Manager<Resource>::ActiveIterator it;
+ KRES::Manager<Resource> *manager = d->mManager;
+ for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
+ qDebug("SaveAB::checking resource..." );
+ if ( (*it)->name() == resource ) {
+ setRes = (*it);
+ qDebug("Inserting imported contacs to resource %s", resource.latin1());
+ break;
+ }
+ }
+ }
for ( it = list.begin(); it != list.end(); ++it ) {
@@ -509,3 +523,3 @@ int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool remo
(*it).setIDStr(id );
- (*it).setResource( 0 );
+ (*it).setResource( setRes );
if ( replaceLabel )
@@ -520,13 +534,23 @@ int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool remo
}
-void AddressBook::setUntagged(bool setNonSyncTagged) // = false)
+void AddressBook::setUntagged(bool setNonSyncTagged, QString resource) // = false , "")
{
Iterator ait;
- for ( ait = begin(); ait != end(); ++ait ) {
- if ( setNonSyncTagged ) {
- if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) {
+ if ( !resource.isEmpty() ) {
+ for ( ait = begin(); ait != end(); ++ait ) {
+ if ( (*ait).resource() && (*ait).resource()->name() == resource ) {
+ (*ait).setTagged( false );
+ }
+ else
(*ait).setTagged( true );
+ }
+ } else {
+ for ( ait = begin(); ait != end(); ++ait ) {
+ if ( setNonSyncTagged ) {
+ if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) {
+ (*ait).setTagged( true );
+ } else
+ (*ait).setTagged( false );
} else
(*ait).setTagged( false );
- } else
- (*ait).setTagged( false );
+ }
}