-rw-r--r-- | kaddressbook/kabcore.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index b9830b1..c670b1f 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -382,51 +382,74 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const | |||
382 | #ifndef KAB_EMBEDDED | 382 | #ifndef KAB_EMBEDDED |
383 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 383 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
384 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 384 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
385 | 385 | ||
386 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 386 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
387 | SLOT( browse( const QString& ) ) ); | 387 | SLOT( browse( const QString& ) ) ); |
388 | 388 | ||
389 | 389 | ||
390 | mAddressBookService = new KAddressBookService( this ); | 390 | mAddressBookService = new KAddressBookService( this ); |
391 | 391 | ||
392 | #endif //KAB_EMBEDDED | 392 | #endif //KAB_EMBEDDED |
393 | 393 | ||
394 | mMessageTimer = new QTimer( this ); | 394 | mMessageTimer = new QTimer( this ); |
395 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 395 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
396 | mEditorDialog = 0; | 396 | mEditorDialog = 0; |
397 | createAddresseeEditorDialog( this ); | 397 | createAddresseeEditorDialog( this ); |
398 | setModified( false ); | 398 | setModified( false ); |
399 | mBRdisabled = false; | 399 | mBRdisabled = false; |
400 | #ifndef DESKTOP_VERSION | 400 | #ifndef DESKTOP_VERSION |
401 | infrared = 0; | 401 | infrared = 0; |
402 | #endif | 402 | #endif |
403 | //toggleBeamReceive( ); | 403 | //toggleBeamReceive( ); |
404 | mMainWindow->toolBar()->show(); | 404 | mMainWindow->toolBar()->show(); |
405 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi | 405 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi |
406 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 406 | //QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
407 | QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() )); | ||
408 | } | ||
409 | void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data ) | ||
410 | { | ||
411 | qDebug("KO: QCOP start message received: %s ", cmsg.data() ); | ||
412 | mCStringMess = cmsg; | ||
413 | mByteData = data; | ||
407 | } | 414 | } |
408 | 415 | ||
416 | void KABCore::loadDataAfterStart() | ||
417 | { | ||
418 | qDebug("KABCore::loadDataAfterStart() "); | ||
419 | ((StdAddressBook*)mAddressBook)->init( true ); | ||
420 | mViewManager->refreshView(); | ||
421 | |||
422 | #ifndef DESKTOP_VERSION | ||
423 | disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); | ||
424 | |||
425 | QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | ||
426 | if ( !mCStringMess.isEmpty() ) | ||
427 | ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); | ||
428 | #endif | ||
429 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | ||
430 | setCaptionBack(); | ||
431 | } | ||
409 | void KABCore::updateToolBar() | 432 | void KABCore::updateToolBar() |
410 | { | 433 | { |
411 | static int iii = 0; | 434 | static int iii = 0; |
412 | ++iii; | 435 | ++iii; |
413 | mMainWindow->toolBar()->repaintMe(); | 436 | mMainWindow->toolBar()->repaintMe(); |
414 | if ( iii < 4 ) | 437 | if ( iii < 4 ) |
415 | QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); | 438 | QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); |
416 | } | 439 | } |
417 | KABCore::~KABCore() | 440 | KABCore::~KABCore() |
418 | { | 441 | { |
419 | // save(); | 442 | // save(); |
420 | //saveSettings(); | 443 | //saveSettings(); |
421 | //KABPrefs::instance()->writeConfig(); | 444 | //KABPrefs::instance()->writeConfig(); |
422 | delete AddresseeConfig::instance(); | 445 | delete AddresseeConfig::instance(); |
423 | mAddressBook = 0; | 446 | mAddressBook = 0; |
424 | KABC::StdAddressBook::close(); | 447 | KABC::StdAddressBook::close(); |
425 | 448 | ||
426 | delete syncManager; | 449 | delete syncManager; |
427 | #ifndef DESKTOP_VERSION | 450 | #ifndef DESKTOP_VERSION |
428 | if ( infrared ) | 451 | if ( infrared ) |
429 | delete infrared; | 452 | delete infrared; |
430 | #endif | 453 | #endif |
431 | } | 454 | } |
432 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 455 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
@@ -2424,101 +2447,98 @@ void KABCore::manageCategories( ) | |||
2424 | } | 2447 | } |
2425 | setModified( true ); | 2448 | setModified( true ); |
2426 | mViewManager->refreshView(); | 2449 | mViewManager->refreshView(); |
2427 | message( i18n("Removing categories done!")); | 2450 | message( i18n("Removing categories done!")); |
2428 | } | 2451 | } |
2429 | delete cp; | 2452 | delete cp; |
2430 | } | 2453 | } |
2431 | void KABCore::removeVoice() | 2454 | void KABCore::removeVoice() |
2432 | { | 2455 | { |
2433 | 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 ) | 2456 | 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 ) |
2434 | return; | 2457 | return; |
2435 | XXPortSelectDialog dlg( this, false, this ); | 2458 | XXPortSelectDialog dlg( this, false, this ); |
2436 | if ( !dlg.exec() ) | 2459 | if ( !dlg.exec() ) |
2437 | return; | 2460 | return; |
2438 | mAddressBook->setUntagged(); | 2461 | mAddressBook->setUntagged(); |
2439 | dlg.tagSelected(); | 2462 | dlg.tagSelected(); |
2440 | message(i18n("Removing voice..."), false ); | 2463 | message(i18n("Removing voice..."), false ); |
2441 | KABC::AddressBook::Iterator it; | 2464 | KABC::AddressBook::Iterator it; |
2442 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2465 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2443 | if ( (*it).tagged() ) { | 2466 | if ( (*it).tagged() ) { |
2444 | (*it).removeVoice(); | 2467 | (*it).removeVoice(); |
2445 | } | 2468 | } |
2446 | } | 2469 | } |
2447 | message(i18n("Refreshing view...") ); | 2470 | message(i18n("Refreshing view...") ); |
2448 | qApp->processEvents(); | ||
2449 | mViewManager->refreshView( "" ); | 2471 | mViewManager->refreshView( "" ); |
2450 | Addressee add; | 2472 | Addressee add; |
2451 | mDetails->setAddressee( add ); | 2473 | mDetails->setAddressee( add ); |
2452 | message(i18n("Remove voice completed!") ); | 2474 | message(i18n("Remove voice completed!") ); |
2453 | 2475 | ||
2454 | 2476 | ||
2455 | 2477 | ||
2456 | } | 2478 | } |
2457 | 2479 | ||
2458 | void KABCore::setFormattedName() | 2480 | void KABCore::setFormattedName() |
2459 | { | 2481 | { |
2460 | KABFormatPrefs setpref; | 2482 | KABFormatPrefs setpref; |
2461 | if ( !setpref.exec() ) { | 2483 | if ( !setpref.exec() ) { |
2462 | return; | 2484 | return; |
2463 | } | 2485 | } |
2464 | XXPortSelectDialog dlg( this, false, this ); | 2486 | XXPortSelectDialog dlg( this, false, this ); |
2465 | if ( !dlg.exec() ) | 2487 | if ( !dlg.exec() ) |
2466 | return; | 2488 | return; |
2467 | mAddressBook->setUntagged(); | 2489 | mAddressBook->setUntagged(); |
2468 | dlg.tagSelected(); | 2490 | dlg.tagSelected(); |
2469 | int count = 0; | 2491 | int count = 0; |
2470 | KABC::AddressBook::Iterator it; | 2492 | KABC::AddressBook::Iterator it; |
2471 | bool modified = false; | 2493 | bool modified = false; |
2472 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2494 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2473 | if ( (*it).tagged() ) { | 2495 | if ( (*it).tagged() ) { |
2474 | if ( (*it).uid().left( 2 ) == "la" ) | 2496 | if ( (*it).uid().left( 2 ) == "la" ) |
2475 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) | 2497 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) |
2476 | continue; | 2498 | continue; |
2477 | ++count; | 2499 | ++count; |
2478 | if ( count %10 == 0 ) | 2500 | if ( count %10 == 0 ) |
2479 | message(i18n("Changing contact #%1").arg( count ) ); | 2501 | message(i18n("Changing contact #%1").arg( count ) ); |
2480 | qApp->processEvents(); | ||
2481 | QString fName; | 2502 | QString fName; |
2482 | if ( setpref.simple->isChecked() ) | 2503 | if ( setpref.simple->isChecked() ) |
2483 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2504 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2484 | else if ( setpref.full->isChecked() ) | 2505 | else if ( setpref.full->isChecked() ) |
2485 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2506 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2486 | else if ( setpref.reverse->isChecked() ) | 2507 | else if ( setpref.reverse->isChecked() ) |
2487 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2508 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2488 | else | 2509 | else |
2489 | fName = (*it).organization(); | 2510 | fName = (*it).organization(); |
2490 | if ( setpref.setCompany->isChecked() ) | 2511 | if ( setpref.setCompany->isChecked() ) |
2491 | if ( fName.isEmpty() || fName =="," ) | 2512 | if ( fName.isEmpty() || fName =="," ) |
2492 | fName = (*it).organization(); | 2513 | fName = (*it).organization(); |
2493 | (*it).setFormattedName( fName ); | 2514 | (*it).setFormattedName( fName ); |
2494 | (*it).setChanged( true ); | 2515 | (*it).setChanged( true ); |
2495 | modified = true; | 2516 | modified = true; |
2496 | (*it).setRevision( QDateTime::currentDateTime() ); | 2517 | (*it).setRevision( QDateTime::currentDateTime() ); |
2497 | } | 2518 | } |
2498 | } | 2519 | } |
2499 | message(i18n("Refreshing view...") ); | 2520 | message(i18n("Refreshing view...") ); |
2500 | qApp->processEvents(); | ||
2501 | if ( modified ) | 2521 | if ( modified ) |
2502 | setModified( true ); | 2522 | setModified( true ); |
2503 | Addressee add; | 2523 | Addressee add; |
2504 | mDetails->setAddressee( add ); | 2524 | mDetails->setAddressee( add ); |
2505 | if ( count == 0 ) | 2525 | if ( count == 0 ) |
2506 | message(i18n("No contact changed!") ); | 2526 | message(i18n("No contact changed!") ); |
2507 | else | 2527 | else |
2508 | message(i18n("%1 contacts changed!").arg( count ) ); | 2528 | message(i18n("%1 contacts changed!").arg( count ) ); |
2509 | } | 2529 | } |
2510 | 2530 | ||
2511 | void KABCore::clipboardDataChanged() | 2531 | void KABCore::clipboardDataChanged() |
2512 | { | 2532 | { |
2513 | 2533 | ||
2514 | if ( mReadWrite ) | 2534 | if ( mReadWrite ) |
2515 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2535 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2516 | 2536 | ||
2517 | } | 2537 | } |
2518 | 2538 | ||
2519 | void KABCore::updateActionMenu() | 2539 | void KABCore::updateActionMenu() |
2520 | { | 2540 | { |
2521 | UndoStack *undo = UndoStack::instance(); | 2541 | UndoStack *undo = UndoStack::instance(); |
2522 | RedoStack *redo = RedoStack::instance(); | 2542 | RedoStack *redo = RedoStack::instance(); |
2523 | 2543 | ||
2524 | if ( undo->isEmpty() ) | 2544 | if ( undo->isEmpty() ) |