summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 42e147f..d970ff1 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2308,107 +2308,117 @@ void KABCore::manageCategories( )
2308 message(i18n("Processing contact #%1").arg(cc)); 2308 message(i18n("Processing contact #%1").arg(cc));
2309 QStringList catIncList = (*it).categories(); 2309 QStringList catIncList = (*it).categories();
2310 int i; 2310 int i;
2311 for( i = 0; i< catIncList.count(); ++i ) { 2311 for( i = 0; i< catIncList.count(); ++i ) {
2312 if ( !catList.contains (catIncList[i])) { 2312 if ( !catList.contains (catIncList[i])) {
2313 catList.append( catIncList[i] ); 2313 catList.append( catIncList[i] );
2314 //qDebug("add cat %s ", catIncList[i].latin1()); 2314 //qDebug("add cat %s ", catIncList[i].latin1());
2315 ++count; 2315 ++count;
2316 } 2316 }
2317 } 2317 }
2318 } 2318 }
2319 catList.sort(); 2319 catList.sort();
2320 KABPrefs::instance()->mCustomCategories = catList; 2320 KABPrefs::instance()->mCustomCategories = catList;
2321 KABPrefs::instance()->writeConfig(); 2321 KABPrefs::instance()->writeConfig();
2322 message(QString::number( count )+ i18n(" categories added to list! ")); 2322 message(QString::number( count )+ i18n(" categories added to list! "));
2323 } else { 2323 } else {
2324 QStringList catList = KABPrefs::instance()->mCustomCategories; 2324 QStringList catList = KABPrefs::instance()->mCustomCategories;
2325 QStringList catIncList; 2325 QStringList catIncList;
2326 QStringList newCatList; 2326 QStringList newCatList;
2327 KABC::AddressBook::Iterator it; 2327 KABC::AddressBook::Iterator it;
2328 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2328 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2329 ++cc; 2329 ++cc;
2330 if ( cc %10 == 0) 2330 if ( cc %10 == 0)
2331 message(i18n("Processing contact #%1").arg(cc)); 2331 message(i18n("Processing contact #%1").arg(cc));
2332 QStringList catIncList = (*it).categories(); 2332 QStringList catIncList = (*it).categories();
2333 int i; 2333 int i;
2334 if ( catIncList.count() ) { 2334 if ( catIncList.count() ) {
2335 newCatList.clear(); 2335 newCatList.clear();
2336 for( i = 0; i< catIncList.count(); ++i ) { 2336 for( i = 0; i< catIncList.count(); ++i ) {
2337 if ( catList.contains (catIncList[i])) { 2337 if ( catList.contains (catIncList[i])) {
2338 newCatList.append( catIncList[i] ); 2338 newCatList.append( catIncList[i] );
2339 } 2339 }
2340 } 2340 }
2341 newCatList.sort(); 2341 newCatList.sort();
2342 (*it).setCategories( newCatList ); 2342 (*it).setCategories( newCatList );
2343 mAddressBook->insertAddressee( (*it) ); 2343 mAddressBook->insertAddressee( (*it) );
2344 } 2344 }
2345 } 2345 }
2346 setModified( true ); 2346 setModified( true );
2347 mViewManager->refreshView(); 2347 mViewManager->refreshView();
2348 message( i18n("Removing categories done!")); 2348 message( i18n("Removing categories done!"));
2349 } 2349 }
2350 delete cp; 2350 delete cp;
2351} 2351}
2352void KABCore::removeVoice() 2352void KABCore::removeVoice()
2353{ 2353{
2354 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2354 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2355 return; 2355 return;
2356 KABC::Addressee::List list;
2357 XXPortSelectDialog dlg( this, false, this ); 2356 XXPortSelectDialog dlg( this, false, this );
2358 if ( dlg.exec() ) 2357 if ( !dlg.exec() )
2359 list = dlg.contacts();
2360 else
2361 return; 2358 return;
2362 KABC::Addressee::List::Iterator it; 2359 mAddressBook->setUntagged();
2363 for ( it = list.begin(); it != list.end(); ++it ) { 2360 dlg.tagSelected();
2364 if ( (*it).removeVoice() ) 2361 message(i18n("Removing voice..."), false );
2365 addrModified((*it), false ); 2362 KABC::AddressBook::Iterator it;
2363 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2364 if ( (*it).tagged() ) {
2365 (*it).removeVoice();
2366 }
2366 } 2367 }
2368 message(i18n("Refreshing view...") );
2369 qApp->processEvents();
2370 mViewManager->refreshView( "" );
2371 Addressee add;
2372 mDetails->setAddressee( add );
2373 message(i18n("Remove voice completed!") );
2374
2375
2376
2367} 2377}
2368 2378
2369void KABCore::setFormattedName() 2379void KABCore::setFormattedName()
2370{ 2380{
2371 KABFormatPrefs setpref; 2381 KABFormatPrefs setpref;
2372 if ( !setpref.exec() ) { 2382 if ( !setpref.exec() ) {
2373 return; 2383 return;
2374 } 2384 }
2375 XXPortSelectDialog dlg( this, false, this ); 2385 XXPortSelectDialog dlg( this, false, this );
2376 if ( !dlg.exec() ) 2386 if ( !dlg.exec() )
2377 return; 2387 return;
2378 mAddressBook->setUntagged(); 2388 mAddressBook->setUntagged();
2379 dlg.tagSelected(); 2389 dlg.tagSelected();
2380 int count = 0; 2390 int count = 0;
2381 KABC::AddressBook::Iterator it; 2391 KABC::AddressBook::Iterator it;
2382 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2392 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2383 if ( (*it).tagged() ) { 2393 if ( (*it).tagged() ) {
2384 ++count; 2394 ++count;
2385 if ( count %10 == 0 ) 2395 if ( count %10 == 0 )
2386 message(i18n("Changing contact #%1").arg( count ) ); 2396 message(i18n("Changing contact #%1").arg( count ) );
2387 qApp->processEvents(); 2397 qApp->processEvents();
2388 QString fName; 2398 QString fName;
2389 if ( setpref.simple->isChecked() ) 2399 if ( setpref.simple->isChecked() )
2390 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2400 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2391 else if ( setpref.full->isChecked() ) 2401 else if ( setpref.full->isChecked() )
2392 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2402 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2393 else if ( setpref.reverse->isChecked() ) 2403 else if ( setpref.reverse->isChecked() )
2394 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2404 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2395 else 2405 else
2396 fName = (*it).organization(); 2406 fName = (*it).organization();
2397 if ( setpref.setCompany->isChecked() ) 2407 if ( setpref.setCompany->isChecked() )
2398 if ( fName.isEmpty() || fName =="," ) 2408 if ( fName.isEmpty() || fName =="," )
2399 fName = (*it).organization(); 2409 fName = (*it).organization();
2400 (*it).setFormattedName( fName ); 2410 (*it).setFormattedName( fName );
2401 } 2411 }
2402 } 2412 }
2403 message(i18n("Refreshing view...") ); 2413 message(i18n("Refreshing view...") );
2404 qApp->processEvents(); 2414 qApp->processEvents();
2405 mViewManager->refreshView( "" ); 2415 mViewManager->refreshView( "" );
2406 Addressee add; 2416 Addressee add;
2407 mDetails->setAddressee( add ); 2417 mDetails->setAddressee( add );
2408 message(i18n("Setting formatted name completed!") ); 2418 message(i18n("Setting formatted name completed!") );
2409} 2419}
2410 2420
2411void KABCore::clipboardDataChanged() 2421void KABCore::clipboardDataChanged()
2412{ 2422{
2413 2423
2414 if ( mReadWrite ) 2424 if ( mReadWrite )
@@ -3086,127 +3096,127 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
3086 syncManager->hideProgressBar(); 3096 syncManager->hideProgressBar();
3087 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3097 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3088 // get rid of micro seconds 3098 // get rid of micro seconds
3089 QTime t = mLastAddressbookSync.time(); 3099 QTime t = mLastAddressbookSync.time();
3090 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3100 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3091 addresseeLSync.setRevision( mLastAddressbookSync ); 3101 addresseeLSync.setRevision( mLastAddressbookSync );
3092 addresseeRSync.setRevision( mLastAddressbookSync ); 3102 addresseeRSync.setRevision( mLastAddressbookSync );
3093 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3103 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3094 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3104 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3095 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3105 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3096 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3106 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3097 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3107 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3098 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3108 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3099 addresseeRSync.setNote( "" ) ; 3109 addresseeRSync.setNote( "" ) ;
3100 addresseeLSync.setNote( "" ); 3110 addresseeLSync.setNote( "" );
3101 3111
3102 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3112 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3103 remote->insertAddressee( addresseeRSync, false ); 3113 remote->insertAddressee( addresseeRSync, false );
3104 local->insertAddressee( addresseeLSync, false ); 3114 local->insertAddressee( addresseeLSync, false );
3105 QString mes; 3115 QString mes;
3106 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3116 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3107 qDebug( mes ); 3117 qDebug( mes );
3108 mes = i18n("Local addressbook changed!\n") +mes; 3118 mes = i18n("Local addressbook changed!\n") +mes;
3109 if ( syncManager->mShowSyncSummary ) { 3119 if ( syncManager->mShowSyncSummary ) {
3110 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3120 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3111 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3121 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3112 qDebug("cancelled "); 3122 qDebug("cancelled ");
3113 return false; 3123 return false;
3114 } 3124 }
3115 } 3125 }
3116 return syncOK; 3126 return syncOK;
3117} 3127}
3118 3128
3119 3129
3120//this is a overwritten callbackmethods from the syncinterface 3130//this is a overwritten callbackmethods from the syncinterface
3121bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3131bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3122{ 3132{
3123 3133
3124 //pending prepare addresseeview for output 3134 //pending prepare addresseeview for output
3125 //pending detect, if remote file has REV field. if not switch to external sync 3135 //pending detect, if remote file has REV field. if not switch to external sync
3126 mGlobalSyncMode = SYNC_MODE_NORMAL; 3136 mGlobalSyncMode = SYNC_MODE_NORMAL;
3127 if ( manager != syncManager ) 3137 if ( manager != syncManager )
3128 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3138 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3129 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3139 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3130 3140
3131 AddressBook abLocal(filename,"syncContact"); 3141 AddressBook abLocal(filename,"syncContact");
3132 bool syncOK = false; 3142 bool syncOK = false;
3133 if ( abLocal.load() ) { 3143 if ( abLocal.load() ) {
3134 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 3144 qDebug("Sync:AB loaded %s,sync mode %d",filename.latin1(), mode );
3135 bool external = false; 3145 bool external = false;
3136 bool isXML = false; 3146 bool isXML = false;
3137 if ( filename.right(4) == ".xml") { 3147 if ( filename.right(4) == ".xml") {
3138 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3148 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3139 isXML = true; 3149 isXML = true;
3140 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3150 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3141 } else { 3151 } else {
3142 external = !manager->mIsKapiFile; 3152 external = !manager->mIsKapiFile;
3143 if ( external ) { 3153 if ( external ) {
3144 qDebug("Setting vcf mode to external "); 3154 qDebug("Sync:Setting vcf mode to external ");
3145 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3155 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3146 AddressBook::Iterator it; 3156 AddressBook::Iterator it;
3147 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3157 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3148 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3158 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3149 (*it).computeCsum( mCurrentSyncDevice ); 3159 (*it).computeCsum( mCurrentSyncDevice );
3150 } 3160 }
3151 } 3161 }
3152 } 3162 }
3153 //AddressBook::Iterator it; 3163 //AddressBook::Iterator it;
3154 //QStringList vcards; 3164 //QStringList vcards;
3155 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3165 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3156 // qDebug("Name %s ", (*it).familyName().latin1()); 3166 // qDebug("Name %s ", (*it).familyName().latin1());
3157 //} 3167 //}
3158 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3168 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3159 if ( syncOK ) { 3169 if ( syncOK ) {
3160 if ( syncManager->mWriteBackFile ) 3170 if ( syncManager->mWriteBackFile )
3161 { 3171 {
3162 if ( external ) 3172 if ( external )
3163 abLocal.removeSyncAddressees( !isXML); 3173 abLocal.removeSyncAddressees( !isXML);
3164 qDebug("Saving remote AB "); 3174 qDebug("Sync:Saving remote AB ");
3165 if ( ! abLocal.saveAB()) 3175 if ( ! abLocal.saveAB())
3166 qDebug("Error writing back AB to file "); 3176 qDebug("Error writing back AB to file ");
3167 if ( external ) { 3177 if ( external ) {
3168 // afterwrite processing 3178 // afterwrite processing
3169 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3179 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3170 } 3180 }
3171 } 3181 }
3172 } 3182 }
3173 setModified(); 3183 setModified();
3174 3184
3175 } 3185 }
3176 abLocal.removeResources(); 3186 abLocal.removeResources();
3177 if ( syncOK ) 3187 if ( syncOK )
3178 mViewManager->refreshView(); 3188 mViewManager->refreshView();
3179 return syncOK; 3189 return syncOK;
3180 3190
3181} 3191}
3182void KABCore::removeSyncInfo( QString syncProfile) 3192void KABCore::removeSyncInfo( QString syncProfile)
3183{ 3193{
3184 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3194 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3185 mAddressBook->removeSyncInfo( syncProfile ); 3195 mAddressBook->removeSyncInfo( syncProfile );
3186 setModified(); 3196 setModified();
3187} 3197}
3188 3198
3189 3199
3190//this is a overwritten callbackmethods from the syncinterface 3200//this is a overwritten callbackmethods from the syncinterface
3191bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3201bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3192{ 3202{
3193 if ( resource == "phone" ) 3203 if ( resource == "phone" )
3194 return syncPhone(); 3204 return syncPhone();
3195 disableBR( true ); 3205 disableBR( true );
3196 if ( manager != syncManager ) 3206 if ( manager != syncManager )
3197 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3207 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3198 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3208 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3199 3209
3200 AddressBook abLocal( resource,"syncContact"); 3210 AddressBook abLocal( resource,"syncContact");
3201 bool syncOK = false; 3211 bool syncOK = false;
3202 message(i18n("Loading DTM address data..."), false); 3212 message(i18n("Loading DTM address data..."), false);
3203 if ( abLocal.load() ) { 3213 if ( abLocal.load() ) {
3204 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3214 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3205 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3215 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3206 message(i18n("Sync preprocessing..."),false); 3216 message(i18n("Sync preprocessing..."),false);
3207 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3217 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3208 message(i18n("Synchronizing..."),false); 3218 message(i18n("Synchronizing..."),false);
3209 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3219 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3210 if ( syncOK ) { 3220 if ( syncOK ) {
3211 if ( syncManager->mWriteBackFile ) { 3221 if ( syncManager->mWriteBackFile ) {
3212 abLocal.removeSyncAddressees( false ); 3222 abLocal.removeSyncAddressees( false );