summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index cd833cf..b107e2d 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1534,195 +1534,195 @@ void KABCore::extensionChanged( int id )
1534 mActionDetails->setChecked( true ); 1534 mActionDetails->setChecked( true );
1535 } 1535 }
1536 else 1536 else
1537 { //go back to the listview 1537 { //go back to the listview
1538 setDetailsVisible( false ); 1538 setDetailsVisible( false );
1539 mActionDetails->setChecked( false ); 1539 mActionDetails->setChecked( false );
1540 mActionDetails->setEnabled(true); 1540 mActionDetails->setEnabled(true);
1541 } 1541 }
1542 1542
1543 } 1543 }
1544 else 1544 else
1545 { 1545 {
1546 //the user enabled the extension. 1546 //the user enabled the extension.
1547 setDetailsVisible( false ); 1547 setDetailsVisible( false );
1548 mActionDetails->setChecked( false ); 1548 mActionDetails->setChecked( false );
1549 1549
1550 if (!mMultipleViewsAtOnce) 1550 if (!mMultipleViewsAtOnce)
1551 { 1551 {
1552 mActionDetails->setEnabled(false); 1552 mActionDetails->setEnabled(false);
1553 } 1553 }
1554 1554
1555 mExtensionManager->setSelectionChanged(); 1555 mExtensionManager->setSelectionChanged();
1556 1556
1557 } 1557 }
1558 1558
1559#endif// DESKTOP_VERSION 1559#endif// DESKTOP_VERSION
1560 1560
1561} 1561}
1562 1562
1563 1563
1564void KABCore::extensionModified( const KABC::Addressee::List &list ) 1564void KABCore::extensionModified( const KABC::Addressee::List &list )
1565{ 1565{
1566 1566
1567 if ( list.count() != 0 ) { 1567 if ( list.count() != 0 ) {
1568 KABC::Addressee::List::ConstIterator it; 1568 KABC::Addressee::List::ConstIterator it;
1569 for ( it = list.begin(); it != list.end(); ++it ) 1569 for ( it = list.begin(); it != list.end(); ++it )
1570 mAddressBook->insertAddressee( *it ); 1570 mAddressBook->insertAddressee( *it );
1571 if ( list.count() > 1 ) 1571 if ( list.count() > 1 )
1572 setModified(); 1572 setModified();
1573 else 1573 else
1574 setModifiedWOrefresh(); 1574 setModifiedWOrefresh();
1575 } 1575 }
1576 if ( list.count() == 0 ) 1576 if ( list.count() == 0 )
1577 mViewManager->refreshView(); 1577 mViewManager->refreshView();
1578 else 1578 else
1579 mViewManager->refreshView( list[ 0 ].uid() ); 1579 mViewManager->refreshView( list[ 0 ].uid() );
1580 1580
1581 1581
1582 1582
1583} 1583}
1584 1584
1585QString KABCore::getNameByPhone( const QString &phone ) 1585QString KABCore::getNameByPhone( const QString &phone )
1586{ 1586{
1587#ifndef KAB_EMBEDDED 1587#ifndef KAB_EMBEDDED
1588 QRegExp r( "[/*/-/ ]" ); 1588 QRegExp r( "[/*/-/ ]" );
1589 QString localPhone( phone ); 1589 QString localPhone( phone );
1590 1590
1591 bool found = false; 1591 bool found = false;
1592 QString ownerName = ""; 1592 QString ownerName = "";
1593 KABC::AddressBook::Iterator iter; 1593 KABC::AddressBook::Iterator iter;
1594 KABC::PhoneNumber::List::Iterator phoneIter; 1594 KABC::PhoneNumber::List::Iterator phoneIter;
1595 KABC::PhoneNumber::List phoneList; 1595 KABC::PhoneNumber::List phoneList;
1596 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1596 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1597 phoneList = (*iter).phoneNumbers(); 1597 phoneList = (*iter).phoneNumbers();
1598 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1598 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1599 ++phoneIter) { 1599 ++phoneIter) {
1600 // Get rid of separator chars so just the numbers are compared. 1600 // Get rid of separator chars so just the numbers are compared.
1601 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1601 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1602 ownerName = (*iter).formattedName(); 1602 ownerName = (*iter).formattedName();
1603 found = true; 1603 found = true;
1604 } 1604 }
1605 } 1605 }
1606 } 1606 }
1607 1607
1608 return ownerName; 1608 return ownerName;
1609#else //KAB_EMBEDDED 1609#else //KAB_EMBEDDED
1610 qDebug("KABCore::getNameByPhone finsih method"); 1610 qDebug("KABCore::getNameByPhone finsih method");
1611 return ""; 1611 return "";
1612#endif //KAB_EMBEDDED 1612#endif //KAB_EMBEDDED
1613 1613
1614} 1614}
1615void KABCore::openConfigGlobalDialog() 1615void KABCore::openConfigGlobalDialog()
1616{ 1616{
1617 KPimPrefsGlobalDialog gc ( this ); 1617 KPimPrefsGlobalDialog gc ( this );
1618 gc.exec(); 1618 gc.exec();
1619} 1619}
1620void KABCore::openConfigDialog() 1620void KABCore::openConfigDialog()
1621{ 1621{
1622 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); 1622 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true);
1623 1623
1624 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" ); 1624 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" );
1625 ConfigureDialog->setMainWidget( kabcfg ); 1625 ConfigureDialog->setMainWidget( kabcfg );
1626 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1626 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1627 this, SLOT( configurationChanged() ) ); 1627 this, SLOT( configurationChanged() ) );
1628 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1628 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1629 kabcfg, SLOT( save() ) ); 1629 kabcfg, SLOT( save() ) );
1630 connect( ConfigureDialog, SIGNAL( okClicked() ), 1630 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1631 this, SLOT( configurationChanged() ) ); 1631 this, SLOT( configurationChanged() ) );
1632 connect( ConfigureDialog, SIGNAL( okClicked() ), 1632 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1633 kabcfg, SLOT( save() ) ); 1633 kabcfg, SLOT( save() ) );
1634 connect( ConfigureDialog, SIGNAL( defaultClicked() ), 1634 connect( ConfigureDialog, SIGNAL( defaultClicked() ),
1635 kabcfg, SLOT( defaults() ) ); 1635 kabcfg, SLOT( defaults() ) );
1636 saveSettings(); 1636 saveSettings();
1637 kabcfg->load(); 1637 kabcfg->load();
1638#ifndef DESKTOP_VERSION 1638#ifndef DESKTOP_VERSION
1639 if ( QApplication::desktop()->height() <= 480 ) 1639 if ( QApplication::desktop()->height() <= 480 )
1640 ConfigureDialog->hideButtons(); 1640 ConfigureDialog->hideButtons();
1641 ConfigureDialog->showMaximized(); 1641 ConfigureDialog->showMaximized();
1642#endif 1642#endif
1643 if ( ConfigureDialog->exec() ) 1643 if ( ConfigureDialog->exec() )
1644 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1644 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1645 delete ConfigureDialog; 1645 delete ConfigureDialog;
1646} 1646}
1647 1647
1648void KABCore::openLDAPDialog() 1648void KABCore::openLDAPDialog()
1649{ 1649{
1650#ifndef KAB_EMBEDDED 1650#ifndef KAB_EMBEDDED
1651 if ( !mLdapSearchDialog ) { 1651 if ( !mLdapSearchDialog ) {
1652 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1652 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1653 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1653 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1654 SLOT( refreshView() ) ); 1654 SLOT( refreshView() ) );
1655 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1655 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1656 SLOT( setModified() ) ); 1656 SLOT( setModified() ) );
1657 } else 1657 } else
1658 mLdapSearchDialog->restoreSettings(); 1658 mLdapSearchDialog->restoreSettings();
1659 1659
1660 if ( mLdapSearchDialog->isOK() ) 1660 if ( mLdapSearchDialog->isOK() )
1661 mLdapSearchDialog->exec(); 1661 mLdapSearchDialog->exec();
1662#else //KAB_EMBEDDED 1662#else //KAB_EMBEDDED
1663 qDebug("KABCore::openLDAPDialog() finsih method"); 1663 qDebug("KABCore::openLDAPDialog() finsih method");
1664#endif //KAB_EMBEDDED 1664#endif //KAB_EMBEDDED
1665} 1665}
1666 1666
1667void KABCore::print() 1667void KABCore::print()
1668{ 1668{
1669#ifndef KAB_EMBEDDED 1669#ifndef KAB_EMBEDDED
1670 KPrinter printer; 1670 KPrinter printer;
1671 if ( !printer.setup( this ) ) 1671 if ( !printer.setup( this ) )
1672 return; 1672 return;
1673 1673
1674 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1674 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1675 mViewManager->selectedUids(), this ); 1675 mViewManager->selectedUids(), this );
1676 1676
1677 wizard.exec(); 1677 wizard.exec();
1678#else //KAB_EMBEDDED 1678#else //KAB_EMBEDDED
1679 qDebug("KABCore::print() finsih method"); 1679 qDebug("KABCore::print() finsih method");
1680#endif //KAB_EMBEDDED 1680#endif //KAB_EMBEDDED
1681 1681
1682} 1682}
1683 1683
1684 1684
1685void KABCore::addGUIClient( KXMLGUIClient *client ) 1685void KABCore::addGUIClient( KXMLGUIClient *client )
1686{ 1686{
1687 if ( mGUIClient ) 1687 if ( mGUIClient )
1688 mGUIClient->insertChildClient( client ); 1688 mGUIClient->insertChildClient( client );
1689 else 1689 else
1690 KMessageBox::error( this, "no KXMLGUICLient"); 1690 KMessageBox::error( this, "no KXMLGUICLient");
1691} 1691}
1692 1692
1693 1693
1694void KABCore::configurationChanged() 1694void KABCore::configurationChanged()
1695{ 1695{
1696 mExtensionManager->reconfigure(); 1696 mExtensionManager->reconfigure();
1697} 1697}
1698 1698
1699void KABCore::addressBookChanged() 1699void KABCore::addressBookChanged()
1700{ 1700{
1701/*US 1701/*US
1702 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1702 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1703 while ( it.current() ) { 1703 while ( it.current() ) {
1704 if ( it.current()->dirty() ) { 1704 if ( it.current()->dirty() ) {
1705 QString text = i18n( "Data has been changed externally. Unsaved " 1705 QString text = i18n( "Data has been changed externally. Unsaved "
1706 "changes will be lost." ); 1706 "changes will be lost." );
1707 KMessageBox::information( this, text ); 1707 KMessageBox::information( this, text );
1708 } 1708 }
1709 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1709 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1710 ++it; 1710 ++it;
1711 } 1711 }
1712*/ 1712*/
1713 if (mEditorDialog) 1713 if (mEditorDialog)
1714 { 1714 {
1715 if (mEditorDialog->dirty()) 1715 if (mEditorDialog->dirty())
1716 { 1716 {
1717 QString text = i18n( "Data has been changed externally. Unsaved " 1717 QString text = i18n( "Data has been changed externally. Unsaved "
1718 "changes will be lost." ); 1718 "changes will be lost." );
1719 KMessageBox::information( this, text ); 1719 KMessageBox::information( this, text );
1720 } 1720 }
1721 QString currentuid = mEditorDialog->addressee().uid(); 1721 QString currentuid = mEditorDialog->addressee().uid();
1722 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1722 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1723 } 1723 }
1724 mViewManager->refreshView(); 1724 mViewManager->refreshView();
1725 1725
1726 1726
1727} 1727}
1728 1728
@@ -3337,98 +3337,98 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3337 syncManager->hideProgressBar(); 3337 syncManager->hideProgressBar();
3338 if ( syncOK ) { 3338 if ( syncOK ) {
3339 if ( syncManager->mWriteBackFile ) { 3339 if ( syncManager->mWriteBackFile ) {
3340 abLocal.removeSyncAddressees( false ); 3340 abLocal.removeSyncAddressees( false );
3341 message(i18n("Saving DTM address data..."),false); 3341 message(i18n("Saving DTM address data..."),false);
3342 abLocal.saveAB(); 3342 abLocal.saveAB();
3343 message(i18n("Sync postprocessing..."),false); 3343 message(i18n("Sync postprocessing..."),false);
3344 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3344 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3345 } 3345 }
3346 } else 3346 } else
3347 message( i18n("Sync cancelled or failed.") ); 3347 message( i18n("Sync cancelled or failed.") );
3348 setModified(); 3348 setModified();
3349 } 3349 }
3350 abLocal.removeResources(); 3350 abLocal.removeResources();
3351 if ( syncOK ) { 3351 if ( syncOK ) {
3352 mViewManager->refreshView(); 3352 mViewManager->refreshView();
3353 message(i18n("DTM syncing finished.")); 3353 message(i18n("DTM syncing finished."));
3354 } 3354 }
3355 disableBR( false ); 3355 disableBR( false );
3356 return syncOK; 3356 return syncOK;
3357 3357
3358} 3358}
3359void KABCore::message( QString m, bool startTimer) 3359void KABCore::message( QString m, bool startTimer)
3360{ 3360{
3361 topLevelWidget()->setCaption( m ); 3361 topLevelWidget()->setCaption( m );
3362 qApp->processEvents(); 3362 qApp->processEvents();
3363 if ( startTimer ) 3363 if ( startTimer )
3364 mMessageTimer->start( 15000, true ); 3364 mMessageTimer->start( 15000, true );
3365 else 3365 else
3366 mMessageTimer->stop(); 3366 mMessageTimer->stop();
3367} 3367}
3368bool KABCore::syncPhone() 3368bool KABCore::syncPhone()
3369{ 3369{
3370 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3370 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3371 QString fileName = getPhoneFile(); 3371 QString fileName = getPhoneFile();
3372 if ( !PhoneAccess::readFromPhone( fileName) ) { 3372 if ( !PhoneAccess::readFromPhone( fileName) ) {
3373 message(i18n("Phone access failed!")); 3373 message(i18n("Phone access failed!"));
3374 return false; 3374 return false;
3375 } 3375 }
3376 AddressBook abLocal( fileName,"syncContact"); 3376 AddressBook abLocal( fileName,"syncContact");
3377 bool syncOK = false; 3377 bool syncOK = false;
3378 { 3378 {
3379 abLocal.importFromFile( fileName ); 3379 abLocal.importFromFile( fileName );
3380 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3380 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3381 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3381 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3382 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3382 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3383 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3383 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3384 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3384 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3385 syncManager->hideProgressBar(); 3385 syncManager->hideProgressBar();
3386 if ( syncOK ) { 3386 if ( syncOK ) {
3387 if ( syncManager->mWriteBackFile ) { 3387 if ( syncManager->mWriteBackFile ) {
3388 abLocal.removeSyncAddressees( true ); 3388 abLocal.removeSyncAddressees( true );
3389 abLocal.saveABphone( fileName ); 3389 abLocal.saveABphone( fileName );
3390 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3390 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3391 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3391 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3392 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3392 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3393 } 3393 }
3394 } 3394 }
3395 setModified(); 3395 setModified();
3396 } 3396 }
3397 abLocal.removeResources(); 3397 abLocal.removeResources();
3398 if ( syncOK ) 3398 if ( syncOK )
3399 mViewManager->refreshView(); 3399 mViewManager->refreshView();
3400 return syncOK; 3400 return syncOK;
3401} 3401}
3402void KABCore::getFile( bool success ) 3402void KABCore::getFile( bool success )
3403{ 3403{
3404 if ( ! success ) { 3404 if ( ! success ) {
3405 message( i18n("Error receiving file. Nothing changed!") ); 3405 message( i18n("Error receiving file. Nothing changed!") );
3406 return; 3406 return;
3407 } 3407 }
3408 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3408 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3409 if ( count ) 3409 if ( count )
3410 setModified( true ); 3410 setModified( true );
3411 message( i18n("Pi-Sync successful!") ); 3411 message( i18n("Pi-Sync successful!") );
3412 mViewManager->refreshView(); 3412 mViewManager->refreshView();
3413} 3413}
3414void KABCore::syncFileRequest() 3414void KABCore::syncFileRequest()
3415{ 3415{
3416 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3416 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3417 syncManager->slotSyncMenu( 999 ); 3417 syncManager->slotSyncMenu( 999 );
3418 } 3418 }
3419 mAddressBook->export2File( sentSyncFile() ); 3419 mAddressBook->export2File( sentSyncFile() );
3420} 3420}
3421QString KABCore::sentSyncFile() 3421QString KABCore::sentSyncFile()
3422{ 3422{
3423#ifdef DESKTOP_VERSION 3423#ifdef DESKTOP_VERSION
3424 return locateLocal( "tmp", "copysyncab.vcf" ); 3424 return locateLocal( "tmp", "copysyncab.vcf" );
3425#else 3425#else
3426 return QString( "/tmp/copysyncab.vcf" ); 3426 return QString( "/tmp/copysyncab.vcf" );
3427#endif 3427#endif
3428} 3428}
3429 3429
3430void KABCore::setCaptionBack() 3430void KABCore::setCaptionBack()
3431{ 3431{
3432 mMessageTimer->stop(); 3432 mMessageTimer->stop();
3433 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3433 topLevelWidget()->setCaption( i18n("KA/Pi") );
3434} 3434}