author | ulf69 <ulf69> | 2004-10-03 23:29:56 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-03 23:29:56 (UTC) |
commit | aaea91151fe9a747e9eddfb8ba7d5896744faf30 (patch) (unidiff) | |
tree | b2b064757d65bc83427e7a86692601364051b631 /kaddressbook | |
parent | a5c204da5a2dba950fc5ad2c45861dbe56849c09 (diff) | |
download | kdepimpi-aaea91151fe9a747e9eddfb8ba7d5896744faf30.zip kdepimpi-aaea91151fe9a747e9eddfb8ba7d5896744faf30.tar.gz kdepimpi-aaea91151fe9a747e9eddfb8ba7d5896744faf30.tar.bz2 |
moved sync related progressbar management to ksyncmanager, and proceeded with
the sync implementation of pwmanager
-rw-r--r-- | kaddressbook/kabcore.cpp | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index f222234..f8359de 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1075,15 +1075,16 @@ void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | |||
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | void KABCore::save() | 1077 | void KABCore::save() |
1078 | { | 1078 | { |
1079 | if (syncManager->blockSave()) | 1079 | if (syncManager->blockSave()) |
1080 | return; | 1080 | return; |
1081 | syncManager->setBlockSave(true); | ||
1082 | if ( !mModified ) | 1081 | if ( !mModified ) |
1083 | return; | 1082 | return; |
1083 | |||
1084 | syncManager->setBlockSave(true); | ||
1084 | QString text = i18n( "There was an error while attempting to save\n the " | 1085 | QString text = i18n( "There was an error while attempting to save\n the " |
1085 | "address book. Please check that some \nother application is " | 1086 | "address book. Please check that some \nother application is " |
1086 | "not using it. " ); | 1087 | "not using it. " ); |
1087 | statusMessage(i18n("Saving addressbook ... ")); | 1088 | statusMessage(i18n("Saving addressbook ... ")); |
1088 | #ifndef KAB_EMBEDDED | 1089 | #ifndef KAB_EMBEDDED |
1089 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1090 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
@@ -2331,30 +2332,23 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2331 | 2332 | ||
2332 | //qDebug("*************************** "); | 2333 | //qDebug("*************************** "); |
2333 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2334 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2334 | QStringList er = remote->uidList(); | 2335 | QStringList er = remote->uidList(); |
2335 | Addressee inR ;//= er.first(); | 2336 | Addressee inR ;//= er.first(); |
2336 | Addressee inL; | 2337 | Addressee inL; |
2337 | QProgressBar bar( er.count(),0 ); | 2338 | |
2338 | bar.setCaption (i18n("Syncing - close to abort!") ); | 2339 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2339 | 2340 | ||
2340 | int w = 300; | ||
2341 | if ( QApplication::desktop()->width() < 320 ) | ||
2342 | w = 220; | ||
2343 | int h = bar.sizeHint().height() ; | ||
2344 | int dw = QApplication::desktop()->width(); | ||
2345 | int dh = QApplication::desktop()->height(); | ||
2346 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
2347 | bar.show(); | ||
2348 | int modulo = (er.count()/10)+1; | 2341 | int modulo = (er.count()/10)+1; |
2349 | int incCounter = 0; | 2342 | int incCounter = 0; |
2350 | while ( incCounter < er.count()) { | 2343 | while ( incCounter < er.count()) { |
2351 | if ( ! bar.isVisible() ) | 2344 | if (syncManager->isProgressBarCanceled()) |
2352 | return false; | 2345 | return false; |
2353 | if ( incCounter % modulo == 0 ) | 2346 | if ( incCounter % modulo == 0 ) |
2354 | bar.setProgress( incCounter ); | 2347 | syncManager->showProgressBar(incCounter); |
2348 | |||
2355 | uid = er[ incCounter ]; | 2349 | uid = er[ incCounter ]; |
2356 | bool skipIncidence = false; | 2350 | bool skipIncidence = false; |
2357 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2351 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2358 | skipIncidence = true; | 2352 | skipIncidence = true; |
2359 | QString idS,OidS; | 2353 | QString idS,OidS; |
2360 | qApp->processEvents(); | 2354 | qApp->processEvents(); |
@@ -2440,22 +2434,21 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2440 | } | 2434 | } |
2441 | ++incCounter; | 2435 | ++incCounter; |
2442 | } | 2436 | } |
2443 | er.clear(); | 2437 | er.clear(); |
2444 | QStringList el = local->uidList(); | 2438 | QStringList el = local->uidList(); |
2445 | modulo = (el.count()/10)+1; | 2439 | modulo = (el.count()/10)+1; |
2446 | bar.setCaption (i18n("Add / remove addressees") ); | 2440 | |
2447 | bar.setTotalSteps ( el.count() ) ; | 2441 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2448 | bar.show(); | ||
2449 | incCounter = 0; | 2442 | incCounter = 0; |
2450 | while ( incCounter < el.count()) { | 2443 | while ( incCounter < el.count()) { |
2451 | qApp->processEvents(); | 2444 | qApp->processEvents(); |
2452 | if ( ! bar.isVisible() ) | 2445 | if (syncManager->isProgressBarCanceled()) |
2453 | return false; | 2446 | return false; |
2454 | if ( incCounter % modulo == 0 ) | 2447 | if ( incCounter % modulo == 0 ) |
2455 | bar.setProgress( incCounter ); | 2448 | syncManager->showProgressBar(incCounter); |
2456 | uid = el[ incCounter ]; | 2449 | uid = el[ incCounter ]; |
2457 | bool skipIncidence = false; | 2450 | bool skipIncidence = false; |
2458 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2451 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2459 | skipIncidence = true; | 2452 | skipIncidence = true; |
2460 | if ( !skipIncidence ) { | 2453 | if ( !skipIncidence ) { |
2461 | inL = local->findByUid( uid ); | 2454 | inL = local->findByUid( uid ); |
@@ -2496,13 +2489,13 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2496 | } | 2489 | } |
2497 | } | 2490 | } |
2498 | } | 2491 | } |
2499 | ++incCounter; | 2492 | ++incCounter; |
2500 | } | 2493 | } |
2501 | el.clear(); | 2494 | el.clear(); |
2502 | bar.hide(); | 2495 | syncManager->hideProgressBar(); |
2503 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2496 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2504 | // get rid of micro seconds | 2497 | // get rid of micro seconds |
2505 | QTime t = mLastAddressbookSync.time(); | 2498 | QTime t = mLastAddressbookSync.time(); |
2506 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2499 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2507 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2500 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2508 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2501 | addresseeRSync.setRevision( mLastAddressbookSync ); |