author | zautrix <zautrix> | 2005-12-02 09:42:53 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-12-02 09:42:53 (UTC) |
commit | a75d2c26aba6cffae8c3f61e173940240042427b (patch) (side-by-side diff) | |
tree | 68f4b61c150bc263a98c78fdf8671bbbc17cdaf8 | |
parent | 64be8d64fc26d1025a24150d065197ba5d608f3d (diff) | |
download | kdepimpi-a75d2c26aba6cffae8c3f61e173940240042427b.zip kdepimpi-a75d2c26aba6cffae8c3f61e173940240042427b.tar.gz kdepimpi-a75d2c26aba6cffae8c3f61e173940240042427b.tar.bz2 |
more sync
-rw-r--r-- | kabc/addressbook.cpp | 42 | ||||
-rw-r--r-- | kabc/addressbook.h | 4 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 6 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 2 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 4 |
5 files changed, 41 insertions, 17 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index e04f4b1..bdc2762 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -484,9 +484,9 @@ 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 ) { if ( removeOld ) - setUntagged( true ); + setUntagged( true, resource ); KABC::Addressee::List list; QFile file( fileName ); @@ -504,9 +504,23 @@ int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool remo list = tool.parseVCards( data ); 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 ) { QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); if ( !id.isEmpty() ) (*it).setIDStr(id ); - (*it).setResource( 0 ); + (*it).setResource( setRes ); if ( replaceLabel ) (*it).removeVoice(); @@ -519,15 +533,25 @@ int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool remo return list.count(); } -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 @@ -149,6 +149,6 @@ class AddressBook : public QObject void export2File( QString fileName, QString resourceName = "" ); 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(); void findNewExtIds( QString fileName, QString currentSyncDevice ); diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 5d377bf..7d8586a 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -1938,5 +1938,5 @@ void KABCore::initGUI() connect(syncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); - connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); + connect(syncManager , SIGNAL( getFile( bool ,const QString &)), this, SLOT(getFile( bool ,const QString &) ) ); QString sync_file = sentSyncFile(); //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); @@ -3461,5 +3461,5 @@ bool KABCore::syncPhone() return syncOK; } -void KABCore::getFile( bool success ) +void KABCore::getFile( bool success ,const QString & resource) { if ( ! success ) { @@ -3467,5 +3467,5 @@ void KABCore::getFile( bool success ) return; } - int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); + int count = mAddressBook->importFromFile( sentSyncFile() , false, true ,resource); if ( count ) setModified( true ); diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 2d1505f..e69cb60 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -357,5 +357,5 @@ class KABCore : public QWidget, public KSyncInterface void loadDataAfterStart(); void recieve(QString cmsg ); - void getFile( bool success ); + void getFile( bool success,const QString & ); void syncFileRequest(const QString &); void setDetailsVisible( bool visible ); diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index e615cbe..7197b30 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -442,6 +442,6 @@ void KSyncManager::enableQuick( bool ask ) mPrefs->writeConfig(); } - connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); - connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); + //connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); + //connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); |