summaryrefslogtreecommitdiffabout
path: root/kabc
Side-by-side diff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp42
-rw-r--r--kabc/addressbook.h4
2 files changed, 35 insertions, 11 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 );
+ }
}
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 4a0d0a3..e6daa5e 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -150,4 +150,4 @@ class AddressBook : public QObject
bool export2PhoneFormat( QStringList uids ,QString fileName );
- int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false );
- void setUntagged( bool setNonSyncTagged = false );
+ int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false, QString resource = "" );
+ void setUntagged( bool setNonSyncTagged = false, QString resource = "" );
void removeUntagged();