summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 15cab73..b7edccd 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1413,769 +1413,771 @@ void KABCore::setDetailsVisible( bool visible )
1413 if ( addrList.count() > 0 ) 1413 if ( addrList.count() > 0 )
1414 mDetails->setAddressee( addrList[ 0 ] ); 1414 mDetails->setAddressee( addrList[ 0 ] );
1415 } 1415 }
1416 1416
1417 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1417 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1418 // the listview and the detailview. We do that by changing the splitbar size. 1418 // the listview and the detailview. We do that by changing the splitbar size.
1419 if (mMultipleViewsAtOnce) 1419 if (mMultipleViewsAtOnce)
1420 { 1420 {
1421 if ( visible ) 1421 if ( visible )
1422 mDetails->show(); 1422 mDetails->show();
1423 else 1423 else
1424 mDetails->hide(); 1424 mDetails->hide();
1425 } 1425 }
1426 else 1426 else
1427 { 1427 {
1428 if ( visible ) { 1428 if ( visible ) {
1429 mViewManager->hide(); 1429 mViewManager->hide();
1430 mDetails->show(); 1430 mDetails->show();
1431 mIncSearchWidget->setFocus(); 1431 mIncSearchWidget->setFocus();
1432 } 1432 }
1433 else { 1433 else {
1434 mViewManager->show(); 1434 mViewManager->show();
1435 mDetails->hide(); 1435 mDetails->hide();
1436 mViewManager->setFocusAV(); 1436 mViewManager->setFocusAV();
1437 } 1437 }
1438 setJumpButtonBarVisible( !visible ); 1438 setJumpButtonBarVisible( !visible );
1439 } 1439 }
1440 1440
1441} 1441}
1442 1442
1443void KABCore::extensionChanged( int id ) 1443void KABCore::extensionChanged( int id )
1444{ 1444{
1445 //change the details view only for non desktop systems 1445 //change the details view only for non desktop systems
1446#ifndef DESKTOP_VERSION 1446#ifndef DESKTOP_VERSION
1447 1447
1448 if (id == 0) 1448 if (id == 0)
1449 { 1449 {
1450 //the user disabled the extension. 1450 //the user disabled the extension.
1451 1451
1452 if (mMultipleViewsAtOnce) 1452 if (mMultipleViewsAtOnce)
1453 { // enable detailsview again 1453 { // enable detailsview again
1454 setDetailsVisible( true ); 1454 setDetailsVisible( true );
1455 mActionDetails->setChecked( true ); 1455 mActionDetails->setChecked( true );
1456 } 1456 }
1457 else 1457 else
1458 { //go back to the listview 1458 { //go back to the listview
1459 setDetailsVisible( false ); 1459 setDetailsVisible( false );
1460 mActionDetails->setChecked( false ); 1460 mActionDetails->setChecked( false );
1461 mActionDetails->setEnabled(true); 1461 mActionDetails->setEnabled(true);
1462 } 1462 }
1463 1463
1464 } 1464 }
1465 else 1465 else
1466 { 1466 {
1467 //the user enabled the extension. 1467 //the user enabled the extension.
1468 setDetailsVisible( false ); 1468 setDetailsVisible( false );
1469 mActionDetails->setChecked( false ); 1469 mActionDetails->setChecked( false );
1470 1470
1471 if (!mMultipleViewsAtOnce) 1471 if (!mMultipleViewsAtOnce)
1472 { 1472 {
1473 mActionDetails->setEnabled(false); 1473 mActionDetails->setEnabled(false);
1474 } 1474 }
1475 1475
1476 mExtensionManager->setSelectionChanged(); 1476 mExtensionManager->setSelectionChanged();
1477 1477
1478 } 1478 }
1479 1479
1480#endif// DESKTOP_VERSION 1480#endif// DESKTOP_VERSION
1481 1481
1482} 1482}
1483 1483
1484 1484
1485void KABCore::extensionModified( const KABC::Addressee::List &list ) 1485void KABCore::extensionModified( const KABC::Addressee::List &list )
1486{ 1486{
1487 1487
1488 if ( list.count() != 0 ) { 1488 if ( list.count() != 0 ) {
1489 KABC::Addressee::List::ConstIterator it; 1489 KABC::Addressee::List::ConstIterator it;
1490 for ( it = list.begin(); it != list.end(); ++it ) 1490 for ( it = list.begin(); it != list.end(); ++it )
1491 mAddressBook->insertAddressee( *it ); 1491 mAddressBook->insertAddressee( *it );
1492 if ( list.count() > 1 ) 1492 if ( list.count() > 1 )
1493 setModified(); 1493 setModified();
1494 else 1494 else
1495 setModifiedWOrefresh(); 1495 setModifiedWOrefresh();
1496 } 1496 }
1497 if ( list.count() == 0 ) 1497 if ( list.count() == 0 )
1498 mViewManager->refreshView(); 1498 mViewManager->refreshView();
1499 else 1499 else
1500 mViewManager->refreshView( list[ 0 ].uid() ); 1500 mViewManager->refreshView( list[ 0 ].uid() );
1501 1501
1502 1502
1503 1503
1504} 1504}
1505 1505
1506QString KABCore::getNameByPhone( const QString &phone ) 1506QString KABCore::getNameByPhone( const QString &phone )
1507{ 1507{
1508#ifndef KAB_EMBEDDED 1508#ifndef KAB_EMBEDDED
1509 QRegExp r( "[/*/-/ ]" ); 1509 QRegExp r( "[/*/-/ ]" );
1510 QString localPhone( phone ); 1510 QString localPhone( phone );
1511 1511
1512 bool found = false; 1512 bool found = false;
1513 QString ownerName = ""; 1513 QString ownerName = "";
1514 KABC::AddressBook::Iterator iter; 1514 KABC::AddressBook::Iterator iter;
1515 KABC::PhoneNumber::List::Iterator phoneIter; 1515 KABC::PhoneNumber::List::Iterator phoneIter;
1516 KABC::PhoneNumber::List phoneList; 1516 KABC::PhoneNumber::List phoneList;
1517 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1517 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1518 phoneList = (*iter).phoneNumbers(); 1518 phoneList = (*iter).phoneNumbers();
1519 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1519 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1520 ++phoneIter) { 1520 ++phoneIter) {
1521 // Get rid of separator chars so just the numbers are compared. 1521 // Get rid of separator chars so just the numbers are compared.
1522 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1522 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1523 ownerName = (*iter).formattedName(); 1523 ownerName = (*iter).formattedName();
1524 found = true; 1524 found = true;
1525 } 1525 }
1526 } 1526 }
1527 } 1527 }
1528 1528
1529 return ownerName; 1529 return ownerName;
1530#else //KAB_EMBEDDED 1530#else //KAB_EMBEDDED
1531 qDebug("KABCore::getNameByPhone finsih method"); 1531 qDebug("KABCore::getNameByPhone finsih method");
1532 return ""; 1532 return "";
1533#endif //KAB_EMBEDDED 1533#endif //KAB_EMBEDDED
1534 1534
1535} 1535}
1536 1536
1537void KABCore::openConfigDialog() 1537void KABCore::openConfigDialog()
1538{ 1538{
1539 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1539 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1540 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1540 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1541 ConfigureDialog->addModule(kabcfg ); 1541 ConfigureDialog->addModule(kabcfg );
1542 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1542 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1543 ConfigureDialog->addModule(kdelibcfg ); 1543 ConfigureDialog->addModule(kdelibcfg );
1544 1544
1545 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1545 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1546 this, SLOT( configurationChanged() ) ); 1546 this, SLOT( configurationChanged() ) );
1547 connect( ConfigureDialog, SIGNAL( okClicked() ), 1547 connect( ConfigureDialog, SIGNAL( okClicked() ),
1548 this, SLOT( configurationChanged() ) ); 1548 this, SLOT( configurationChanged() ) );
1549 saveSettings(); 1549 saveSettings();
1550#ifndef DESKTOP_VERSION 1550#ifndef DESKTOP_VERSION
1551 ConfigureDialog->showMaximized(); 1551 ConfigureDialog->showMaximized();
1552#endif 1552#endif
1553 if ( ConfigureDialog->exec() ) 1553 if ( ConfigureDialog->exec() )
1554 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1554 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1555 delete ConfigureDialog; 1555 delete ConfigureDialog;
1556} 1556}
1557 1557
1558void KABCore::openLDAPDialog() 1558void KABCore::openLDAPDialog()
1559{ 1559{
1560#ifndef KAB_EMBEDDED 1560#ifndef KAB_EMBEDDED
1561 if ( !mLdapSearchDialog ) { 1561 if ( !mLdapSearchDialog ) {
1562 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1562 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1563 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1563 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1564 SLOT( refreshView() ) ); 1564 SLOT( refreshView() ) );
1565 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1565 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1566 SLOT( setModified() ) ); 1566 SLOT( setModified() ) );
1567 } else 1567 } else
1568 mLdapSearchDialog->restoreSettings(); 1568 mLdapSearchDialog->restoreSettings();
1569 1569
1570 if ( mLdapSearchDialog->isOK() ) 1570 if ( mLdapSearchDialog->isOK() )
1571 mLdapSearchDialog->exec(); 1571 mLdapSearchDialog->exec();
1572#else //KAB_EMBEDDED 1572#else //KAB_EMBEDDED
1573 qDebug("KABCore::openLDAPDialog() finsih method"); 1573 qDebug("KABCore::openLDAPDialog() finsih method");
1574#endif //KAB_EMBEDDED 1574#endif //KAB_EMBEDDED
1575} 1575}
1576 1576
1577void KABCore::print() 1577void KABCore::print()
1578{ 1578{
1579#ifndef KAB_EMBEDDED 1579#ifndef KAB_EMBEDDED
1580 KPrinter printer; 1580 KPrinter printer;
1581 if ( !printer.setup( this ) ) 1581 if ( !printer.setup( this ) )
1582 return; 1582 return;
1583 1583
1584 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1584 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1585 mViewManager->selectedUids(), this ); 1585 mViewManager->selectedUids(), this );
1586 1586
1587 wizard.exec(); 1587 wizard.exec();
1588#else //KAB_EMBEDDED 1588#else //KAB_EMBEDDED
1589 qDebug("KABCore::print() finsih method"); 1589 qDebug("KABCore::print() finsih method");
1590#endif //KAB_EMBEDDED 1590#endif //KAB_EMBEDDED
1591 1591
1592} 1592}
1593 1593
1594 1594
1595void KABCore::addGUIClient( KXMLGUIClient *client ) 1595void KABCore::addGUIClient( KXMLGUIClient *client )
1596{ 1596{
1597 if ( mGUIClient ) 1597 if ( mGUIClient )
1598 mGUIClient->insertChildClient( client ); 1598 mGUIClient->insertChildClient( client );
1599 else 1599 else
1600 KMessageBox::error( this, "no KXMLGUICLient"); 1600 KMessageBox::error( this, "no KXMLGUICLient");
1601} 1601}
1602 1602
1603 1603
1604void KABCore::configurationChanged() 1604void KABCore::configurationChanged()
1605{ 1605{
1606 mExtensionManager->reconfigure(); 1606 mExtensionManager->reconfigure();
1607} 1607}
1608 1608
1609void KABCore::addressBookChanged() 1609void KABCore::addressBookChanged()
1610{ 1610{
1611/*US 1611/*US
1612 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1612 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1613 while ( it.current() ) { 1613 while ( it.current() ) {
1614 if ( it.current()->dirty() ) { 1614 if ( it.current()->dirty() ) {
1615 QString text = i18n( "Data has been changed externally. Unsaved " 1615 QString text = i18n( "Data has been changed externally. Unsaved "
1616 "changes will be lost." ); 1616 "changes will be lost." );
1617 KMessageBox::information( this, text ); 1617 KMessageBox::information( this, text );
1618 } 1618 }
1619 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1619 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1620 ++it; 1620 ++it;
1621 } 1621 }
1622*/ 1622*/
1623 if (mEditorDialog) 1623 if (mEditorDialog)
1624 { 1624 {
1625 if (mEditorDialog->dirty()) 1625 if (mEditorDialog->dirty())
1626 { 1626 {
1627 QString text = i18n( "Data has been changed externally. Unsaved " 1627 QString text = i18n( "Data has been changed externally. Unsaved "
1628 "changes will be lost." ); 1628 "changes will be lost." );
1629 KMessageBox::information( this, text ); 1629 KMessageBox::information( this, text );
1630 } 1630 }
1631 QString currentuid = mEditorDialog->addressee().uid(); 1631 QString currentuid = mEditorDialog->addressee().uid();
1632 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1632 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1633 } 1633 }
1634 mViewManager->refreshView(); 1634 mViewManager->refreshView();
1635// mDetails->refreshView(); 1635// mDetails->refreshView();
1636 1636
1637 1637
1638} 1638}
1639 1639
1640AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1640AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1641 const char *name ) 1641 const char *name )
1642{ 1642{
1643 1643
1644 if ( mEditorDialog == 0 ) { 1644 if ( mEditorDialog == 0 ) {
1645 mEditorDialog = new AddresseeEditorDialog( this, parent, 1645 mEditorDialog = new AddresseeEditorDialog( this, parent,
1646 name ? name : "editorDialog" ); 1646 name ? name : "editorDialog" );
1647 1647
1648 1648
1649 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1649 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1650 SLOT( contactModified( const KABC::Addressee& ) ) ); 1650 SLOT( contactModified( const KABC::Addressee& ) ) );
1651 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1651 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1652 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1652 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1653 } 1653 }
1654 1654
1655 return mEditorDialog; 1655 return mEditorDialog;
1656} 1656}
1657 1657
1658void KABCore::slotEditorDestroyed( const QString &uid ) 1658void KABCore::slotEditorDestroyed( const QString &uid )
1659{ 1659{
1660 //mEditorDict.remove( uid ); 1660 //mEditorDict.remove( uid );
1661} 1661}
1662 1662
1663void KABCore::initGUI() 1663void KABCore::initGUI()
1664{ 1664{
1665#ifndef KAB_EMBEDDED 1665#ifndef KAB_EMBEDDED
1666 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1666 QHBoxLayout *topLayout = new QHBoxLayout( this );
1667 topLayout->setSpacing( KDialogBase::spacingHint() ); 1667 topLayout->setSpacing( KDialogBase::spacingHint() );
1668 1668
1669 mExtensionBarSplitter = new QSplitter( this ); 1669 mExtensionBarSplitter = new QSplitter( this );
1670 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1670 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1671 1671
1672 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1672 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1673 1673
1674 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1674 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1675 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1675 mIncSearchWidget = new IncSearchWidget( viewSpace );
1676 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1676 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1677 SLOT( incrementalSearch( const QString& ) ) ); 1677 SLOT( incrementalSearch( const QString& ) ) );
1678 1678
1679 mViewManager = new ViewManager( this, viewSpace ); 1679 mViewManager = new ViewManager( this, viewSpace );
1680 viewSpace->setStretchFactor( mViewManager, 1 ); 1680 viewSpace->setStretchFactor( mViewManager, 1 );
1681 1681
1682 mDetails = new ViewContainer( mDetailsSplitter ); 1682 mDetails = new ViewContainer( mDetailsSplitter );
1683 1683
1684 mJumpButtonBar = new JumpButtonBar( this, this ); 1684 mJumpButtonBar = new JumpButtonBar( this, this );
1685 1685
1686 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1686 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1687 1687
1688 topLayout->addWidget( mExtensionBarSplitter ); 1688 topLayout->addWidget( mExtensionBarSplitter );
1689 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1689 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1690 topLayout->addWidget( mJumpButtonBar ); 1690 topLayout->addWidget( mJumpButtonBar );
1691 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1691 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1692 1692
1693 mXXPortManager = new XXPortManager( this, this ); 1693 mXXPortManager = new XXPortManager( this, this );
1694 1694
1695#else //KAB_EMBEDDED 1695#else //KAB_EMBEDDED
1696 //US initialize viewMenu before settingup viewmanager. 1696 //US initialize viewMenu before settingup viewmanager.
1697 // Viewmanager needs this menu to plugin submenues. 1697 // Viewmanager needs this menu to plugin submenues.
1698 viewMenu = new QPopupMenu( this ); 1698 viewMenu = new QPopupMenu( this );
1699 settingsMenu = new QPopupMenu( this ); 1699 settingsMenu = new QPopupMenu( this );
1700 //filterMenu = new QPopupMenu( this ); 1700 //filterMenu = new QPopupMenu( this );
1701 ImportMenu = new QPopupMenu( this ); 1701 ImportMenu = new QPopupMenu( this );
1702 ExportMenu = new QPopupMenu( this ); 1702 ExportMenu = new QPopupMenu( this );
1703 syncMenu = new QPopupMenu( this ); 1703 syncMenu = new QPopupMenu( this );
1704 changeMenu= new QPopupMenu( this ); 1704 changeMenu= new QPopupMenu( this );
1705 beamMenu= new QPopupMenu( this ); 1705 beamMenu= new QPopupMenu( this );
1706 1706
1707//US since we have no splitter for the embedded system, setup 1707//US since we have no splitter for the embedded system, setup
1708// a layout with two frames. One left and one right. 1708// a layout with two frames. One left and one right.
1709 1709
1710 QBoxLayout *topLayout; 1710 QBoxLayout *topLayout;
1711 1711
1712 // = new QHBoxLayout( this ); 1712 // = new QHBoxLayout( this );
1713// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1713// QBoxLayout *topLayout = (QBoxLayout*)layout();
1714 1714
1715// QWidget *mainBox = new QWidget( this ); 1715// QWidget *mainBox = new QWidget( this );
1716// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1716// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1717 1717
1718#ifdef DESKTOP_VERSION 1718#ifdef DESKTOP_VERSION
1719 topLayout = new QHBoxLayout( this ); 1719 topLayout = new QHBoxLayout( this );
1720 1720
1721 1721
1722 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1722 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1723 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1723 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1724 1724
1725 topLayout->addWidget(mMiniSplitter ); 1725 topLayout->addWidget(mMiniSplitter );
1726 1726
1727 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1727 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1728 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1728 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1729 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1729 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1730 mDetails = new ViewContainer( mMiniSplitter ); 1730 mDetails = new ViewContainer( mMiniSplitter );
1731 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1731 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1732#else 1732#else
1733 if ( QApplication::desktop()->width() > 480 ) { 1733 if ( QApplication::desktop()->width() > 480 ) {
1734 topLayout = new QHBoxLayout( this ); 1734 topLayout = new QHBoxLayout( this );
1735 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1735 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1736 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1736 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1737 } else { 1737 } else {
1738 1738
1739 topLayout = new QHBoxLayout( this ); 1739 topLayout = new QHBoxLayout( this );
1740 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1740 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1741 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1741 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1742 } 1742 }
1743 1743
1744 topLayout->addWidget(mMiniSplitter ); 1744 topLayout->addWidget(mMiniSplitter );
1745 mViewManager = new ViewManager( this, mMiniSplitter ); 1745 mViewManager = new ViewManager( this, mMiniSplitter );
1746 mDetails = new ViewContainer( mMiniSplitter ); 1746 mDetails = new ViewContainer( mMiniSplitter );
1747 1747
1748 1748
1749 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1749 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1750#endif 1750#endif
1751 //eh->hide(); 1751 //eh->hide();
1752 // topLayout->addWidget(mExtensionManager ); 1752 // topLayout->addWidget(mExtensionManager );
1753 1753
1754 1754
1755/*US 1755/*US
1756#ifndef KAB_NOSPLITTER 1756#ifndef KAB_NOSPLITTER
1757 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1757 QHBoxLayout *topLayout = new QHBoxLayout( this );
1758//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1758//US topLayout->setSpacing( KDialogBase::spacingHint() );
1759 topLayout->setSpacing( 10 ); 1759 topLayout->setSpacing( 10 );
1760 1760
1761 mDetailsSplitter = new QSplitter( this ); 1761 mDetailsSplitter = new QSplitter( this );
1762 1762
1763 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1763 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1764 1764
1765 mViewManager = new ViewManager( this, viewSpace ); 1765 mViewManager = new ViewManager( this, viewSpace );
1766 viewSpace->setStretchFactor( mViewManager, 1 ); 1766 viewSpace->setStretchFactor( mViewManager, 1 );
1767 1767
1768 mDetails = new ViewContainer( mDetailsSplitter ); 1768 mDetails = new ViewContainer( mDetailsSplitter );
1769 1769
1770 topLayout->addWidget( mDetailsSplitter ); 1770 topLayout->addWidget( mDetailsSplitter );
1771 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1771 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1772#else //KAB_NOSPLITTER 1772#else //KAB_NOSPLITTER
1773 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1773 QHBoxLayout *topLayout = new QHBoxLayout( this );
1774//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1774//US topLayout->setSpacing( KDialogBase::spacingHint() );
1775 topLayout->setSpacing( 10 ); 1775 topLayout->setSpacing( 10 );
1776 1776
1777// mDetailsSplitter = new QSplitter( this ); 1777// mDetailsSplitter = new QSplitter( this );
1778 1778
1779 QVBox *viewSpace = new QVBox( this ); 1779 QVBox *viewSpace = new QVBox( this );
1780 1780
1781 mViewManager = new ViewManager( this, viewSpace ); 1781 mViewManager = new ViewManager( this, viewSpace );
1782 viewSpace->setStretchFactor( mViewManager, 1 ); 1782 viewSpace->setStretchFactor( mViewManager, 1 );
1783 1783
1784 mDetails = new ViewContainer( this ); 1784 mDetails = new ViewContainer( this );
1785 1785
1786 topLayout->addWidget( viewSpace ); 1786 topLayout->addWidget( viewSpace );
1787// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1787// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1788 topLayout->addWidget( mDetails ); 1788 topLayout->addWidget( mDetails );
1789#endif //KAB_NOSPLITTER 1789#endif //KAB_NOSPLITTER
1790*/ 1790*/
1791 1791
1792 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1792 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1793 syncManager->setBlockSave(false); 1793 syncManager->setBlockSave(false);
1794 1794
1795 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1795 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1796 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1796 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1797 syncManager->setDefaultFileName( sentSyncFile()); 1797 QString sync_file = sentSyncFile();
1798 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1799 syncManager->setDefaultFileName( sync_file );
1798 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1800 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1799 1801
1800#endif //KAB_EMBEDDED 1802#endif //KAB_EMBEDDED
1801 initActions(); 1803 initActions();
1802 1804
1803#ifdef KAB_EMBEDDED 1805#ifdef KAB_EMBEDDED
1804 addActionsManually(); 1806 addActionsManually();
1805 //US make sure the export and import menues are initialized before creating the xxPortManager. 1807 //US make sure the export and import menues are initialized before creating the xxPortManager.
1806 mXXPortManager = new XXPortManager( this, this ); 1808 mXXPortManager = new XXPortManager( this, this );
1807 1809
1808 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1810 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1809 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1811 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1810 // mActionQuit->plug ( mMainWindow->toolBar()); 1812 // mActionQuit->plug ( mMainWindow->toolBar());
1811 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1813 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1812 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1814 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1813 // mIncSearchWidget->hide(); 1815 // mIncSearchWidget->hide();
1814 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1816 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1815 SLOT( incrementalSearch( const QString& ) ) ); 1817 SLOT( incrementalSearch( const QString& ) ) );
1816 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1818 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1817 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1819 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1818 1820
1819 mJumpButtonBar = new JumpButtonBar( this, this ); 1821 mJumpButtonBar = new JumpButtonBar( this, this );
1820 1822
1821 topLayout->addWidget( mJumpButtonBar ); 1823 topLayout->addWidget( mJumpButtonBar );
1822//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1824//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1823 1825
1824// mMainWindow->getIconToolBar()->raise(); 1826// mMainWindow->getIconToolBar()->raise();
1825 1827
1826#endif //KAB_EMBEDDED 1828#endif //KAB_EMBEDDED
1827 1829
1828} 1830}
1829void KABCore::initActions() 1831void KABCore::initActions()
1830{ 1832{
1831//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1833//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1832 1834
1833#ifndef KAB_EMBEDDED 1835#ifndef KAB_EMBEDDED
1834 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1836 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1835 SLOT( clipboardDataChanged() ) ); 1837 SLOT( clipboardDataChanged() ) );
1836#endif //KAB_EMBEDDED 1838#endif //KAB_EMBEDDED
1837 1839
1838 // file menu 1840 // file menu
1839 if ( mIsPart ) { 1841 if ( mIsPart ) {
1840 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1842 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1841 SLOT( sendMail() ), actionCollection(), 1843 SLOT( sendMail() ), actionCollection(),
1842 "kaddressbook_mail" ); 1844 "kaddressbook_mail" );
1843 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1845 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1844 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1846 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1845 1847
1846 } else { 1848 } else {
1847 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1849 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1848 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1850 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1849 } 1851 }
1850 1852
1851 1853
1852 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1854 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1853 SLOT( save() ), actionCollection(), "file_sync" ); 1855 SLOT( save() ), actionCollection(), "file_sync" );
1854 1856
1855 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1857 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1856 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1858 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1857 1859
1858 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1860 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1859 this, SLOT( mailVCard() ), 1861 this, SLOT( mailVCard() ),
1860 actionCollection(), "file_mail_vcard"); 1862 actionCollection(), "file_mail_vcard");
1861 1863
1862 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1864 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1863 SLOT( export2phone() ), actionCollection(), 1865 SLOT( export2phone() ), actionCollection(),
1864 "kaddressbook_ex2phone" ); 1866 "kaddressbook_ex2phone" );
1865 1867
1866 mActionBeamVCard = 0; 1868 mActionBeamVCard = 0;
1867 mActionBeam = 0; 1869 mActionBeam = 0;
1868 1870
1869#ifndef DESKTOP_VERSION 1871#ifndef DESKTOP_VERSION
1870 if ( Ir::supported() ) { 1872 if ( Ir::supported() ) {
1871 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1873 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1872 SLOT( beamVCard() ), actionCollection(), 1874 SLOT( beamVCard() ), actionCollection(),
1873 "kaddressbook_beam_vcard" ); 1875 "kaddressbook_beam_vcard" );
1874 1876
1875 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1877 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1876 SLOT( beamMySelf() ), actionCollection(), 1878 SLOT( beamMySelf() ), actionCollection(),
1877 "kaddressbook_beam_myself" ); 1879 "kaddressbook_beam_myself" );
1878 } 1880 }
1879#endif 1881#endif
1880 1882
1881 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1883 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1882 this, SLOT( editContact2() ), 1884 this, SLOT( editContact2() ),
1883 actionCollection(), "file_properties" ); 1885 actionCollection(), "file_properties" );
1884 1886
1885#ifdef KAB_EMBEDDED 1887#ifdef KAB_EMBEDDED
1886 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1888 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1887 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1889 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1888 mMainWindow, SLOT( exit() ), 1890 mMainWindow, SLOT( exit() ),
1889 actionCollection(), "quit" ); 1891 actionCollection(), "quit" );
1890#endif //KAB_EMBEDDED 1892#endif //KAB_EMBEDDED
1891 1893
1892 // edit menu 1894 // edit menu
1893 if ( mIsPart ) { 1895 if ( mIsPart ) {
1894 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1896 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1895 SLOT( copyContacts() ), actionCollection(), 1897 SLOT( copyContacts() ), actionCollection(),
1896 "kaddressbook_copy" ); 1898 "kaddressbook_copy" );
1897 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1899 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1898 SLOT( cutContacts() ), actionCollection(), 1900 SLOT( cutContacts() ), actionCollection(),
1899 "kaddressbook_cut" ); 1901 "kaddressbook_cut" );
1900 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1902 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1901 SLOT( pasteContacts() ), actionCollection(), 1903 SLOT( pasteContacts() ), actionCollection(),
1902 "kaddressbook_paste" ); 1904 "kaddressbook_paste" );
1903 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1905 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1904 SLOT( selectAllContacts() ), actionCollection(), 1906 SLOT( selectAllContacts() ), actionCollection(),
1905 "kaddressbook_select_all" ); 1907 "kaddressbook_select_all" );
1906 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1908 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1907 SLOT( undo() ), actionCollection(), 1909 SLOT( undo() ), actionCollection(),
1908 "kaddressbook_undo" ); 1910 "kaddressbook_undo" );
1909 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1911 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1910 this, SLOT( redo() ), actionCollection(), 1912 this, SLOT( redo() ), actionCollection(),
1911 "kaddressbook_redo" ); 1913 "kaddressbook_redo" );
1912 } else { 1914 } else {
1913 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1915 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1914 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1916 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1915 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1917 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1916 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1918 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1917 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1919 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1918 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1920 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1919 } 1921 }
1920 1922
1921 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1923 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1922 Key_Delete, this, SLOT( deleteContacts() ), 1924 Key_Delete, this, SLOT( deleteContacts() ),
1923 actionCollection(), "edit_delete" ); 1925 actionCollection(), "edit_delete" );
1924 1926
1925 mActionUndo->setEnabled( false ); 1927 mActionUndo->setEnabled( false );
1926 mActionRedo->setEnabled( false ); 1928 mActionRedo->setEnabled( false );
1927 1929
1928 // settings menu 1930 // settings menu
1929#ifdef KAB_EMBEDDED 1931#ifdef KAB_EMBEDDED
1930//US special menuentry to configure the addressbook resources. On KDE 1932//US special menuentry to configure the addressbook resources. On KDE
1931// you do that through the control center !!! 1933// you do that through the control center !!!
1932 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1934 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1933 SLOT( configureResources() ), actionCollection(), 1935 SLOT( configureResources() ), actionCollection(),
1934 "kaddressbook_configure_resources" ); 1936 "kaddressbook_configure_resources" );
1935#endif //KAB_EMBEDDED 1937#endif //KAB_EMBEDDED
1936 1938
1937 if ( mIsPart ) { 1939 if ( mIsPart ) {
1938 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1940 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1939 SLOT( openConfigDialog() ), actionCollection(), 1941 SLOT( openConfigDialog() ), actionCollection(),
1940 "kaddressbook_configure" ); 1942 "kaddressbook_configure" );
1941 1943
1942 //US not implemented yet 1944 //US not implemented yet
1943 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1945 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1944 // this, SLOT( configureKeyBindings() ), actionCollection(), 1946 // this, SLOT( configureKeyBindings() ), actionCollection(),
1945 // "kaddressbook_configure_shortcuts" ); 1947 // "kaddressbook_configure_shortcuts" );
1946#ifdef KAB_EMBEDDED 1948#ifdef KAB_EMBEDDED
1947 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1949 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1948 mActionConfigureToolbars->setEnabled( false ); 1950 mActionConfigureToolbars->setEnabled( false );
1949#endif //KAB_EMBEDDED 1951#endif //KAB_EMBEDDED
1950 1952
1951 } else { 1953 } else {
1952 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1954 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1953 1955
1954 //US not implemented yet 1956 //US not implemented yet
1955 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1957 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1956 } 1958 }
1957 1959
1958 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1960 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1959 actionCollection(), "options_show_jump_bar" ); 1961 actionCollection(), "options_show_jump_bar" );
1960 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1962 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1961 1963
1962 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1964 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1963 actionCollection(), "options_show_details" ); 1965 actionCollection(), "options_show_details" );
1964 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1966 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1965 1967
1966 1968
1967 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 1969 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
1968 SLOT( toggleBeamReceive() ), actionCollection(), 1970 SLOT( toggleBeamReceive() ), actionCollection(),
1969 "kaddressbook_beam_rec" ); 1971 "kaddressbook_beam_rec" );
1970 1972
1971 1973
1972 // misc 1974 // misc
1973 // only enable LDAP lookup if we can handle the protocol 1975 // only enable LDAP lookup if we can handle the protocol
1974#ifndef KAB_EMBEDDED 1976#ifndef KAB_EMBEDDED
1975 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1977 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1976 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1978 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1977 this, SLOT( openLDAPDialog() ), actionCollection(), 1979 this, SLOT( openLDAPDialog() ), actionCollection(),
1978 "ldap_lookup" ); 1980 "ldap_lookup" );
1979 } 1981 }
1980#else //KAB_EMBEDDED 1982#else //KAB_EMBEDDED
1981 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1983 //qDebug("KABCore::initActions() LDAP has to be implemented");
1982#endif //KAB_EMBEDDED 1984#endif //KAB_EMBEDDED
1983 1985
1984 1986
1985 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1987 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1986 SLOT( setWhoAmI() ), actionCollection(), 1988 SLOT( setWhoAmI() ), actionCollection(),
1987 "set_personal" ); 1989 "set_personal" );
1988 1990
1989 1991
1990 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1992 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1991 SLOT( setCategories() ), actionCollection(), 1993 SLOT( setCategories() ), actionCollection(),
1992 "edit_set_categories" ); 1994 "edit_set_categories" );
1993 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, 1995 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
1994 SLOT( editCategories() ), actionCollection(), 1996 SLOT( editCategories() ), actionCollection(),
1995 "edit__categories" ); 1997 "edit__categories" );
1996 1998
1997 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1999 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1998 SLOT( removeVoice() ), actionCollection(), 2000 SLOT( removeVoice() ), actionCollection(),
1999 "remove_voice" ); 2001 "remove_voice" );
2000 2002
2001 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2003 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2002 SLOT( manageCategories() ), actionCollection(), 2004 SLOT( manageCategories() ), actionCollection(),
2003 "remove_voice" ); 2005 "remove_voice" );
2004 2006
2005 2007
2006 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2008 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2007 SLOT( importFromOL() ), actionCollection(), 2009 SLOT( importFromOL() ), actionCollection(),
2008 "import_OL" ); 2010 "import_OL" );
2009#ifdef KAB_EMBEDDED 2011#ifdef KAB_EMBEDDED
2010 mActionLicence = new KAction( i18n( "Licence" ), 0, 2012 mActionLicence = new KAction( i18n( "Licence" ), 0,
2011 this, SLOT( showLicence() ), actionCollection(), 2013 this, SLOT( showLicence() ), actionCollection(),
2012 "licence_about_data" ); 2014 "licence_about_data" );
2013 mActionFaq = new KAction( i18n( "Faq" ), 0, 2015 mActionFaq = new KAction( i18n( "Faq" ), 0,
2014 this, SLOT( faq() ), actionCollection(), 2016 this, SLOT( faq() ), actionCollection(),
2015 "faq_about_data" ); 2017 "faq_about_data" );
2016 mActionWN = new KAction( i18n( "What's New?" ), 0, 2018 mActionWN = new KAction( i18n( "What's New?" ), 0,
2017 this, SLOT( whatsnew() ), actionCollection(), 2019 this, SLOT( whatsnew() ), actionCollection(),
2018 "wn" ); 2020 "wn" );
2019 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2021 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2020 this, SLOT( synchowto() ), actionCollection(), 2022 this, SLOT( synchowto() ), actionCollection(),
2021 "sync" ); 2023 "sync" );
2022 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2024 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2023 this, SLOT( kdesynchowto() ), actionCollection(), 2025 this, SLOT( kdesynchowto() ), actionCollection(),
2024 "kdesync" ); 2026 "kdesync" );
2025 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2027 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2026 this, SLOT( multisynchowto() ), actionCollection(), 2028 this, SLOT( multisynchowto() ), actionCollection(),
2027 "multisync" ); 2029 "multisync" );
2028 2030
2029 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2031 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2030 this, SLOT( createAboutData() ), actionCollection(), 2032 this, SLOT( createAboutData() ), actionCollection(),
2031 "kaddressbook_about_data" ); 2033 "kaddressbook_about_data" );
2032#endif //KAB_EMBEDDED 2034#endif //KAB_EMBEDDED
2033 2035
2034 clipboardDataChanged(); 2036 clipboardDataChanged();
2035 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2037 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2036 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2038 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2037} 2039}
2038 2040
2039//US we need this function, to plug all actions into the correct menues. 2041//US we need this function, to plug all actions into the correct menues.
2040// KDE uses a XML format to plug the actions, but we work her without this overhead. 2042// KDE uses a XML format to plug the actions, but we work her without this overhead.
2041void KABCore::addActionsManually() 2043void KABCore::addActionsManually()
2042{ 2044{
2043//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2045//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2044 2046
2045#ifdef KAB_EMBEDDED 2047#ifdef KAB_EMBEDDED
2046 QPopupMenu *fileMenu = new QPopupMenu( this ); 2048 QPopupMenu *fileMenu = new QPopupMenu( this );
2047 QPopupMenu *editMenu = new QPopupMenu( this ); 2049 QPopupMenu *editMenu = new QPopupMenu( this );
2048 QPopupMenu *helpMenu = new QPopupMenu( this ); 2050 QPopupMenu *helpMenu = new QPopupMenu( this );
2049 2051
2050 KToolBar* tb = mMainWindow->toolBar(); 2052 KToolBar* tb = mMainWindow->toolBar();
2051 2053
2052#ifndef DESKTOP_VERSION 2054#ifndef DESKTOP_VERSION
2053 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2055 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2054#endif 2056#endif
2055 QMenuBar* mb = mMainWindow->menuBar(); 2057 QMenuBar* mb = mMainWindow->menuBar();
2056 2058
2057 //US setup menubar. 2059 //US setup menubar.
2058 //Disable the following block if you do not want to have a menubar. 2060 //Disable the following block if you do not want to have a menubar.
2059 mb->insertItem( i18n("&File"), fileMenu ); 2061 mb->insertItem( i18n("&File"), fileMenu );
2060 mb->insertItem( i18n("&Edit"), editMenu ); 2062 mb->insertItem( i18n("&Edit"), editMenu );
2061 mb->insertItem( i18n("&View"), viewMenu ); 2063 mb->insertItem( i18n("&View"), viewMenu );
2062 mb->insertItem( i18n("&Settings"), settingsMenu ); 2064 mb->insertItem( i18n("&Settings"), settingsMenu );
2063 mb->insertItem( i18n("Synchronize"), syncMenu ); 2065 mb->insertItem( i18n("Synchronize"), syncMenu );
2064 //mb->insertItem( i18n("&Change"), changeMenu ); 2066 //mb->insertItem( i18n("&Change"), changeMenu );
2065 mb->insertItem( i18n("&Help"), helpMenu ); 2067 mb->insertItem( i18n("&Help"), helpMenu );
2066 mIncSearchWidget = new IncSearchWidget( tb ); 2068 mIncSearchWidget = new IncSearchWidget( tb );
2067 // tb->insertWidget(-1, 0, mIncSearchWidget); 2069 // tb->insertWidget(-1, 0, mIncSearchWidget);
2068#ifndef DESKTOP_VERSION 2070#ifndef DESKTOP_VERSION
2069 } else { 2071 } else {
2070 //US setup toolbar 2072 //US setup toolbar
2071 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2073 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2072 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2074 QPopupMenu *popupBarTB = new QPopupMenu( this );
2073 menuBarTB->insertItem( "ME", popupBarTB); 2075 menuBarTB->insertItem( "ME", popupBarTB);
2074 tb->insertWidget(-1, 0, menuBarTB); 2076 tb->insertWidget(-1, 0, menuBarTB);
2075 mIncSearchWidget = new IncSearchWidget( tb ); 2077 mIncSearchWidget = new IncSearchWidget( tb );
2076 2078
2077 tb->enableMoving(false); 2079 tb->enableMoving(false);
2078 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2080 popupBarTB->insertItem( i18n("&File"), fileMenu );
2079 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2081 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2080 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2082 popupBarTB->insertItem( i18n("&View"), viewMenu );
2081 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2083 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2082 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2084 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2083 mViewManager->getFilterAction()->plug ( popupBarTB); 2085 mViewManager->getFilterAction()->plug ( popupBarTB);
2084 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2086 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2085 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2087 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2086 if (QApplication::desktop()->width() > 320 ) { 2088 if (QApplication::desktop()->width() > 320 ) {
2087 // mViewManager->getFilterAction()->plug ( tb); 2089 // mViewManager->getFilterAction()->plug ( tb);
2088 } 2090 }
2089 } 2091 }
2090#endif 2092#endif
2091 // mActionQuit->plug ( mMainWindow->toolBar()); 2093 // mActionQuit->plug ( mMainWindow->toolBar());
2092 2094
2093 2095
2094 2096
2095 //US Now connect the actions with the menue entries. 2097 //US Now connect the actions with the menue entries.
2096 mActionPrint->plug( fileMenu ); 2098 mActionPrint->plug( fileMenu );
2097 mActionMail->plug( fileMenu ); 2099 mActionMail->plug( fileMenu );
2098 fileMenu->insertSeparator(); 2100 fileMenu->insertSeparator();
2099 2101
2100 mActionNewContact->plug( fileMenu ); 2102 mActionNewContact->plug( fileMenu );
2101 mActionNewContact->plug( tb ); 2103 mActionNewContact->plug( tb );
2102 2104
2103 mActionEditAddressee->plug( fileMenu ); 2105 mActionEditAddressee->plug( fileMenu );
2104 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2106 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2105 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2107 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2106 mActionEditAddressee->plug( tb ); 2108 mActionEditAddressee->plug( tb );
2107 2109
2108 fileMenu->insertSeparator(); 2110 fileMenu->insertSeparator();
2109 mActionSave->plug( fileMenu ); 2111 mActionSave->plug( fileMenu );
2110 fileMenu->insertItem( "&Import", ImportMenu ); 2112 fileMenu->insertItem( "&Import", ImportMenu );
2111 fileMenu->insertItem( "&Export", ExportMenu ); 2113 fileMenu->insertItem( "&Export", ExportMenu );
2112 fileMenu->insertItem( i18n("&Change"), changeMenu ); 2114 fileMenu->insertItem( i18n("&Change"), changeMenu );
2113#ifndef DESKTOP_VERSION 2115#ifndef DESKTOP_VERSION
2114 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2116 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2115#endif 2117#endif
2116 2118
2117 fileMenu->insertSeparator(); 2119 fileMenu->insertSeparator();
2118 mActionMailVCard->plug( fileMenu ); 2120 mActionMailVCard->plug( fileMenu );
2119#ifndef DESKTOP_VERSION 2121#ifndef DESKTOP_VERSION
2120 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2122 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2121 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2123 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2122 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2124 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2123#endif 2125#endif
2124 fileMenu->insertSeparator(); 2126 fileMenu->insertSeparator();
2125 mActionQuit->plug( fileMenu ); 2127 mActionQuit->plug( fileMenu );
2126#ifdef _WIN32_ 2128#ifdef _WIN32_
2127 mActionImportOL->plug( ImportMenu ); 2129 mActionImportOL->plug( ImportMenu );
2128#endif 2130#endif
2129 // edit menu 2131 // edit menu
2130 mActionUndo->plug( editMenu ); 2132 mActionUndo->plug( editMenu );
2131 mActionRedo->plug( editMenu ); 2133 mActionRedo->plug( editMenu );
2132 editMenu->insertSeparator(); 2134 editMenu->insertSeparator();
2133 mActionCut->plug( editMenu ); 2135 mActionCut->plug( editMenu );
2134 mActionCopy->plug( editMenu ); 2136 mActionCopy->plug( editMenu );
2135 mActionPaste->plug( editMenu ); 2137 mActionPaste->plug( editMenu );
2136 mActionDelete->plug( editMenu ); 2138 mActionDelete->plug( editMenu );
2137 editMenu->insertSeparator(); 2139 editMenu->insertSeparator();
2138 mActionSelectAll->plug( editMenu ); 2140 mActionSelectAll->plug( editMenu );
2139 2141
2140 mActionRemoveVoice->plug( changeMenu ); 2142 mActionRemoveVoice->plug( changeMenu );
2141 // settings menu 2143 // settings menu
2142//US special menuentry to configure the addressbook resources. On KDE 2144//US special menuentry to configure the addressbook resources. On KDE
2143// you do that through the control center !!! 2145// you do that through the control center !!!
2144 mActionConfigResources->plug( settingsMenu ); 2146 mActionConfigResources->plug( settingsMenu );
2145 settingsMenu->insertSeparator(); 2147 settingsMenu->insertSeparator();
2146 2148
2147 mActionConfigKAddressbook->plug( settingsMenu ); 2149 mActionConfigKAddressbook->plug( settingsMenu );
2148 2150
2149 if ( mIsPart ) { 2151 if ( mIsPart ) {
2150 //US not implemented yet 2152 //US not implemented yet
2151 //mActionConfigShortcuts->plug( settingsMenu ); 2153 //mActionConfigShortcuts->plug( settingsMenu );
2152 //mActionConfigureToolbars->plug( settingsMenu ); 2154 //mActionConfigureToolbars->plug( settingsMenu );
2153 2155
2154 } else { 2156 } else {
2155 //US not implemented yet 2157 //US not implemented yet
2156 //mActionKeyBindings->plug( settingsMenu ); 2158 //mActionKeyBindings->plug( settingsMenu );
2157 } 2159 }
2158 2160
2159 settingsMenu->insertSeparator(); 2161 settingsMenu->insertSeparator();
2160 2162
2161 mActionJumpBar->plug( settingsMenu ); 2163 mActionJumpBar->plug( settingsMenu );
2162 mActionDetails->plug( settingsMenu ); 2164 mActionDetails->plug( settingsMenu );
2163 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2165 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2164 mActionDetails->plug( tb ); 2166 mActionDetails->plug( tb );
2165 settingsMenu->insertSeparator(); 2167 settingsMenu->insertSeparator();
2166#ifndef DESKTOP_VERSION 2168#ifndef DESKTOP_VERSION
2167 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2169 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2168#endif 2170#endif
2169 settingsMenu->insertSeparator(); 2171 settingsMenu->insertSeparator();
2170 2172
2171 mActionWhoAmI->plug( settingsMenu ); 2173 mActionWhoAmI->plug( settingsMenu );
2172 mActionEditCategories->plug( settingsMenu ); 2174 mActionEditCategories->plug( settingsMenu );
2173 mActionEditCategories->plug( changeMenu ); 2175 mActionEditCategories->plug( changeMenu );
2174 mActionCategories->plug( changeMenu ); 2176 mActionCategories->plug( changeMenu );
2175 mActionManageCategories->plug( changeMenu ); 2177 mActionManageCategories->plug( changeMenu );
2176 2178
2177 mActionCategories->plug( settingsMenu ); 2179 mActionCategories->plug( settingsMenu );
2178 mActionManageCategories->plug( settingsMenu ); 2180 mActionManageCategories->plug( settingsMenu );
2179 2181
2180 2182
2181 mActionWN->plug( helpMenu ); 2183 mActionWN->plug( helpMenu );
@@ -2625,548 +2627,552 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
2625 } 2627 }
2626 2628
2627 } 2629 }
2628 } 2630 }
2629 full = true; 2631 full = true;
2630 if ( mode < SYNC_PREF_ASK ) 2632 if ( mode < SYNC_PREF_ASK )
2631 mode = SYNC_PREF_ASK; 2633 mode = SYNC_PREF_ASK;
2632 } else { 2634 } else {
2633 if ( localMod == remoteMod ) 2635 if ( localMod == remoteMod )
2634 return 0; 2636 return 0;
2635 2637
2636 } 2638 }
2637 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2639 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2638 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2640 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2639 //full = true; //debug only 2641 //full = true; //debug only
2640 if ( full ) { 2642 if ( full ) {
2641 bool equ = ( (*local) == (*remote) ); 2643 bool equ = ( (*local) == (*remote) );
2642 if ( equ ) { 2644 if ( equ ) {
2643 //qDebug("equal "); 2645 //qDebug("equal ");
2644 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2646 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2645 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2647 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2646 } 2648 }
2647 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2649 if ( mode < SYNC_PREF_FORCE_LOCAL )
2648 return 0; 2650 return 0;
2649 2651
2650 }//else //debug only 2652 }//else //debug only
2651 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2653 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2652 } 2654 }
2653 int result; 2655 int result;
2654 bool localIsNew; 2656 bool localIsNew;
2655 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2657 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2656 2658
2657 if ( full && mode < SYNC_PREF_NEWEST ) 2659 if ( full && mode < SYNC_PREF_NEWEST )
2658 mode = SYNC_PREF_ASK; 2660 mode = SYNC_PREF_ASK;
2659 2661
2660 switch( mode ) { 2662 switch( mode ) {
2661 case SYNC_PREF_LOCAL: 2663 case SYNC_PREF_LOCAL:
2662 if ( lastSync > remoteMod ) 2664 if ( lastSync > remoteMod )
2663 return 1; 2665 return 1;
2664 if ( lastSync > localMod ) 2666 if ( lastSync > localMod )
2665 return 2; 2667 return 2;
2666 return 1; 2668 return 1;
2667 break; 2669 break;
2668 case SYNC_PREF_REMOTE: 2670 case SYNC_PREF_REMOTE:
2669 if ( lastSync > remoteMod ) 2671 if ( lastSync > remoteMod )
2670 return 1; 2672 return 1;
2671 if ( lastSync > localMod ) 2673 if ( lastSync > localMod )
2672 return 2; 2674 return 2;
2673 return 2; 2675 return 2;
2674 break; 2676 break;
2675 case SYNC_PREF_NEWEST: 2677 case SYNC_PREF_NEWEST:
2676 if ( localMod > remoteMod ) 2678 if ( localMod > remoteMod )
2677 return 1; 2679 return 1;
2678 else 2680 else
2679 return 2; 2681 return 2;
2680 break; 2682 break;
2681 case SYNC_PREF_ASK: 2683 case SYNC_PREF_ASK:
2682 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2684 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2683 if ( lastSync > remoteMod ) 2685 if ( lastSync > remoteMod )
2684 return 1; 2686 return 1;
2685 if ( lastSync > localMod ) 2687 if ( lastSync > localMod )
2686 return 2; 2688 return 2;
2687 localIsNew = localMod >= remoteMod; 2689 localIsNew = localMod >= remoteMod;
2688 //qDebug("conflict! ************************************** "); 2690 //qDebug("conflict! ************************************** ");
2689 { 2691 {
2690 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2692 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2691 result = acd.executeD(localIsNew); 2693 result = acd.executeD(localIsNew);
2692 return result; 2694 return result;
2693 } 2695 }
2694 break; 2696 break;
2695 case SYNC_PREF_FORCE_LOCAL: 2697 case SYNC_PREF_FORCE_LOCAL:
2696 return 1; 2698 return 1;
2697 break; 2699 break;
2698 case SYNC_PREF_FORCE_REMOTE: 2700 case SYNC_PREF_FORCE_REMOTE:
2699 return 2; 2701 return 2;
2700 break; 2702 break;
2701 2703
2702 default: 2704 default:
2703 // SYNC_PREF_TAKE_BOTH not implemented 2705 // SYNC_PREF_TAKE_BOTH not implemented
2704 break; 2706 break;
2705 } 2707 }
2706 return 0; 2708 return 0;
2707} 2709}
2708 2710
2709 2711
2710bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2712bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2711{ 2713{
2712 bool syncOK = true; 2714 bool syncOK = true;
2713 int addedAddressee = 0; 2715 int addedAddressee = 0;
2714 int addedAddresseeR = 0; 2716 int addedAddresseeR = 0;
2715 int deletedAddresseeR = 0; 2717 int deletedAddresseeR = 0;
2716 int deletedAddresseeL = 0; 2718 int deletedAddresseeL = 0;
2717 int changedLocal = 0; 2719 int changedLocal = 0;
2718 int changedRemote = 0; 2720 int changedRemote = 0;
2719 2721
2720 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2722 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2721 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2723 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2722 2724
2723 //QPtrList<Addressee> el = local->rawAddressees(); 2725 //QPtrList<Addressee> el = local->rawAddressees();
2724 Addressee addresseeR; 2726 Addressee addresseeR;
2725 QString uid; 2727 QString uid;
2726 int take; 2728 int take;
2727 Addressee addresseeL; 2729 Addressee addresseeL;
2728 Addressee addresseeRSync; 2730 Addressee addresseeRSync;
2729 Addressee addresseeLSync; 2731 Addressee addresseeLSync;
2730 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2732 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2731 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2733 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2732 bool fullDateRange = false; 2734 bool fullDateRange = false;
2733 local->resetTempSyncStat(); 2735 local->resetTempSyncStat();
2734 mLastAddressbookSync = QDateTime::currentDateTime(); 2736 mLastAddressbookSync = QDateTime::currentDateTime();
2735 if ( syncManager->syncWithDesktop() ) { 2737 if ( syncManager->syncWithDesktop() ) {
2736 // remote->removeSyncInfo( QString());//remove all info 2738 // remote->removeSyncInfo( QString());//remove all info
2737 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2739 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2738 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2740 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2739 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2741 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2740 } else { 2742 } else {
2741 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2743 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2742 } 2744 }
2743 } 2745 }
2744 QDateTime modifiedCalendar = mLastAddressbookSync; 2746 QDateTime modifiedCalendar = mLastAddressbookSync;
2745 addresseeLSync = getLastSyncAddressee(); 2747 addresseeLSync = getLastSyncAddressee();
2746 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2748 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2747 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2749 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2748 if ( !addresseeR.isEmpty() ) { 2750 if ( !addresseeR.isEmpty() ) {
2749 addresseeRSync = addresseeR; 2751 addresseeRSync = addresseeR;
2750 remote->removeAddressee(addresseeR ); 2752 remote->removeAddressee(addresseeR );
2751 2753
2752 } else { 2754 } else {
2753 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2755 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2754 addresseeRSync = addresseeLSync ; 2756 addresseeRSync = addresseeLSync ;
2755 } else { 2757 } else {
2756 //qDebug("FULLDATE 1"); 2758 //qDebug("FULLDATE 1");
2757 fullDateRange = true; 2759 fullDateRange = true;
2758 Addressee newAdd; 2760 Addressee newAdd;
2759 addresseeRSync = newAdd; 2761 addresseeRSync = newAdd;
2760 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2762 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2761 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2763 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2762 addresseeRSync.setRevision( mLastAddressbookSync ); 2764 addresseeRSync.setRevision( mLastAddressbookSync );
2763 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2765 addresseeRSync.setCategories( i18n("SyncAddressee") );
2764 } 2766 }
2765 } 2767 }
2766 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2768 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2767 // qDebug("FULLDATE 2"); 2769 // qDebug("FULLDATE 2");
2768 fullDateRange = true; 2770 fullDateRange = true;
2769 } 2771 }
2770 if ( ! fullDateRange ) { 2772 if ( ! fullDateRange ) {
2771 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2773 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2772 2774
2773 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2775 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2774 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2776 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2775 fullDateRange = true; 2777 fullDateRange = true;
2776 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2778 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2777 } 2779 }
2778 } 2780 }
2779 // fullDateRange = true; // debug only! 2781 // fullDateRange = true; // debug only!
2780 if ( fullDateRange ) 2782 if ( fullDateRange )
2781 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2783 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2782 else 2784 else
2783 mLastAddressbookSync = addresseeLSync.revision(); 2785 mLastAddressbookSync = addresseeLSync.revision();
2784 // for resyncing if own file has changed 2786 // for resyncing if own file has changed
2785 // PENDING fixme later when implemented 2787 // PENDING fixme later when implemented
2786#if 0 2788#if 0
2787 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2789 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2788 mLastAddressbookSync = loadedFileVersion; 2790 mLastAddressbookSync = loadedFileVersion;
2789 qDebug("setting mLastAddressbookSync "); 2791 qDebug("setting mLastAddressbookSync ");
2790 } 2792 }
2791#endif 2793#endif
2792 2794
2793 //qDebug("*************************** "); 2795 //qDebug("*************************** ");
2794 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2796 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2795 QStringList er = remote->uidList(); 2797 QStringList er = remote->uidList();
2796 Addressee inR ;//= er.first(); 2798 Addressee inR ;//= er.first();
2797 Addressee inL; 2799 Addressee inL;
2798 2800
2799 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2801 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2800 2802
2801 int modulo = (er.count()/10)+1; 2803 int modulo = (er.count()/10)+1;
2802 int incCounter = 0; 2804 int incCounter = 0;
2803 while ( incCounter < er.count()) { 2805 while ( incCounter < er.count()) {
2804 if (syncManager->isProgressBarCanceled()) 2806 if (syncManager->isProgressBarCanceled())
2805 return false; 2807 return false;
2806 if ( incCounter % modulo == 0 ) 2808 if ( incCounter % modulo == 0 )
2807 syncManager->showProgressBar(incCounter); 2809 syncManager->showProgressBar(incCounter);
2808 2810
2809 uid = er[ incCounter ]; 2811 uid = er[ incCounter ];
2810 bool skipIncidence = false; 2812 bool skipIncidence = false;
2811 if ( uid.left(19) == QString("last-syncAddressee-") ) 2813 if ( uid.left(19) == QString("last-syncAddressee-") )
2812 skipIncidence = true; 2814 skipIncidence = true;
2813 QString idS,OidS; 2815 QString idS,OidS;
2814 qApp->processEvents(); 2816 qApp->processEvents();
2815 if ( !skipIncidence ) { 2817 if ( !skipIncidence ) {
2816 inL = local->findByUid( uid ); 2818 inL = local->findByUid( uid );
2817 inR = remote->findByUid( uid ); 2819 inR = remote->findByUid( uid );
2818 //inL.setResource( 0 ); 2820 //inL.setResource( 0 );
2819 //inR.setResource( 0 ); 2821 //inR.setResource( 0 );
2820 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2822 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2821 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2823 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2822 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2824 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2823 //qDebug("take %d %s ", take, inL.summary().latin1()); 2825 //qDebug("take %d %s ", take, inL.summary().latin1());
2824 if ( take == 3 ) 2826 if ( take == 3 )
2825 return false; 2827 return false;
2826 if ( take == 1 ) {// take local ********************** 2828 if ( take == 1 ) {// take local **********************
2827 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2829 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2828 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2830 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2829 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2831 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2830 local->insertAddressee( inL, false ); 2832 local->insertAddressee( inL, false );
2831 idS = inR.externalUID(); 2833 idS = inR.externalUID();
2832 OidS = inR.originalExternalUID(); 2834 OidS = inR.originalExternalUID();
2833 } 2835 }
2834 else 2836 else
2835 idS = inR.IDStr(); 2837 idS = inR.IDStr();
2836 remote->removeAddressee( inR ); 2838 remote->removeAddressee( inR );
2837 inR = inL; 2839 inR = inL;
2838 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2840 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2839 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2841 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2840 inR.setOriginalExternalUID( OidS ); 2842 inR.setOriginalExternalUID( OidS );
2841 inR.setExternalUID( idS ); 2843 inR.setExternalUID( idS );
2842 if ( syncManager->syncWithDesktop() ) { 2844 if ( syncManager->syncWithDesktop() ) {
2843 inR.setIDStr("changed" ); 2845 inR.setIDStr("changed" );
2844 } 2846 }
2845 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2847 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2846 } else { 2848 } else {
2847 inR.setIDStr( idS ); 2849 inR.setIDStr( idS );
2848 } 2850 }
2849 inR.setResource( 0 ); 2851 inR.setResource( 0 );
2850 remote->insertAddressee( inR , false); 2852 remote->insertAddressee( inR , false);
2851 ++changedRemote; 2853 ++changedRemote;
2852 } else { // take == 2 take remote ********************** 2854 } else { // take == 2 take remote **********************
2853 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2855 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2854 if ( inR.revision().date().year() < 2004 ) 2856 if ( inR.revision().date().year() < 2004 )
2855 inR.setRevision( modifiedCalendar ); 2857 inR.setRevision( modifiedCalendar );
2856 } 2858 }
2857 idS = inL.IDStr(); 2859 idS = inL.IDStr();
2858 local->removeAddressee( inL ); 2860 local->removeAddressee( inL );
2859 inL = inR; 2861 inL = inR;
2860 inL.setIDStr( idS ); 2862 inL.setIDStr( idS );
2861 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2863 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2862 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2864 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2863 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2865 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2864 } 2866 }
2865 inL.setResource( 0 ); 2867 inL.setResource( 0 );
2866 local->insertAddressee( inL , false ); 2868 local->insertAddressee( inL , false );
2867 ++changedLocal; 2869 ++changedLocal;
2868 } 2870 }
2869 } 2871 }
2870 } 2872 }
2871 } else { // no conflict ********** add or delete remote 2873 } else { // no conflict ********** add or delete remote
2872 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2874 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2873 QString des = addresseeLSync.note(); 2875 QString des = addresseeLSync.note();
2874 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2876 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2875 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2877 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2876 remote->insertAddressee( inR, false ); 2878 remote->insertAddressee( inR, false );
2877 ++deletedAddresseeR; 2879 ++deletedAddresseeR;
2878 } else { 2880 } else {
2879 inR.setRevision( modifiedCalendar ); 2881 inR.setRevision( modifiedCalendar );
2880 remote->insertAddressee( inR, false ); 2882 remote->insertAddressee( inR, false );
2881 inL = inR; 2883 inL = inR;
2882 inL.setIDStr( ":" ); 2884 inL.setIDStr( ":" );
2883 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2885 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2884 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2886 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2885 inL.setResource( 0 ); 2887 inL.setResource( 0 );
2886 local->insertAddressee( inL , false); 2888 local->insertAddressee( inL , false);
2887 ++addedAddressee; 2889 ++addedAddressee;
2888 } 2890 }
2889 } else { 2891 } else {
2890 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2892 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2891 inR.setRevision( modifiedCalendar ); 2893 inR.setRevision( modifiedCalendar );
2892 remote->insertAddressee( inR, false ); 2894 remote->insertAddressee( inR, false );
2893 inR.setResource( 0 ); 2895 inR.setResource( 0 );
2894 local->insertAddressee( inR, false ); 2896 local->insertAddressee( inR, false );
2895 ++addedAddressee; 2897 ++addedAddressee;
2896 } else { 2898 } else {
2897 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2899 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2898 remote->removeAddressee( inR ); 2900 remote->removeAddressee( inR );
2899 ++deletedAddresseeR; 2901 ++deletedAddresseeR;
2900 } 2902 }
2901 } 2903 }
2902 } 2904 }
2903 } 2905 }
2904 ++incCounter; 2906 ++incCounter;
2905 } 2907 }
2906 er.clear(); 2908 er.clear();
2907 QStringList el = local->uidList(); 2909 QStringList el = local->uidList();
2908 modulo = (el.count()/10)+1; 2910 modulo = (el.count()/10)+1;
2909 2911
2910 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2912 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2911 incCounter = 0; 2913 incCounter = 0;
2912 while ( incCounter < el.count()) { 2914 while ( incCounter < el.count()) {
2913 qApp->processEvents(); 2915 qApp->processEvents();
2914 if (syncManager->isProgressBarCanceled()) 2916 if (syncManager->isProgressBarCanceled())
2915 return false; 2917 return false;
2916 if ( incCounter % modulo == 0 ) 2918 if ( incCounter % modulo == 0 )
2917 syncManager->showProgressBar(incCounter); 2919 syncManager->showProgressBar(incCounter);
2918 uid = el[ incCounter ]; 2920 uid = el[ incCounter ];
2919 bool skipIncidence = false; 2921 bool skipIncidence = false;
2920 if ( uid.left(19) == QString("last-syncAddressee-") ) 2922 if ( uid.left(19) == QString("last-syncAddressee-") )
2921 skipIncidence = true; 2923 skipIncidence = true;
2922 if ( !skipIncidence ) { 2924 if ( !skipIncidence ) {
2923 inL = local->findByUid( uid ); 2925 inL = local->findByUid( uid );
2924 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2926 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2925 inR = remote->findByUid( uid ); 2927 inR = remote->findByUid( uid );
2926 if ( inR.isEmpty() ) { // no conflict ********** add or delete local 2928 if ( inR.isEmpty() ) { // no conflict ********** add or delete local
2927 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2929 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2928 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2930 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2929 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2931 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2930 local->removeAddressee( inL ); 2932 local->removeAddressee( inL );
2931 ++deletedAddresseeL; 2933 ++deletedAddresseeL;
2932 } else { 2934 } else {
2933 if ( ! syncManager->mWriteBackExistingOnly ) { 2935 if ( ! syncManager->mWriteBackExistingOnly ) {
2934 inL.removeID(mCurrentSyncDevice ); 2936 inL.removeID(mCurrentSyncDevice );
2935 ++addedAddresseeR; 2937 ++addedAddresseeR;
2936 inL.setRevision( modifiedCalendar ); 2938 inL.setRevision( modifiedCalendar );
2937 local->insertAddressee( inL, false ); 2939 local->insertAddressee( inL, false );
2938 inR = inL; 2940 inR = inL;
2939 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2941 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2940 inR.setResource( 0 ); 2942 inR.setResource( 0 );
2941 remote->insertAddressee( inR, false ); 2943 remote->insertAddressee( inR, false );
2942 } 2944 }
2943 } 2945 }
2944 } else { 2946 } else {
2945 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2947 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2946 //qDebug("data %s ", inL.revision().toString().latin1()); 2948 //qDebug("data %s ", inL.revision().toString().latin1());
2947 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2949 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2948 local->removeAddressee( inL ); 2950 local->removeAddressee( inL );
2949 ++deletedAddresseeL; 2951 ++deletedAddresseeL;
2950 } else { 2952 } else {
2951 if ( ! syncManager->mWriteBackExistingOnly ) { 2953 if ( ! syncManager->mWriteBackExistingOnly ) {
2952 ++addedAddresseeR; 2954 ++addedAddresseeR;
2953 inL.setRevision( modifiedCalendar ); 2955 inL.setRevision( modifiedCalendar );
2954 local->insertAddressee( inL, false ); 2956 local->insertAddressee( inL, false );
2955 inR = inL; 2957 inR = inL;
2956 inR.setIDStr( ":" ); 2958 inR.setIDStr( ":" );
2957 inR.setResource( 0 ); 2959 inR.setResource( 0 );
2958 remote->insertAddressee( inR, false ); 2960 remote->insertAddressee( inR, false );
2959 } 2961 }
2960 } 2962 }
2961 } 2963 }
2962 } 2964 }
2963 } 2965 }
2964 } 2966 }
2965 ++incCounter; 2967 ++incCounter;
2966 } 2968 }
2967 el.clear(); 2969 el.clear();
2968 syncManager->hideProgressBar(); 2970 syncManager->hideProgressBar();
2969 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2971 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2970 // get rid of micro seconds 2972 // get rid of micro seconds
2971 QTime t = mLastAddressbookSync.time(); 2973 QTime t = mLastAddressbookSync.time();
2972 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2974 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2973 addresseeLSync.setRevision( mLastAddressbookSync ); 2975 addresseeLSync.setRevision( mLastAddressbookSync );
2974 addresseeRSync.setRevision( mLastAddressbookSync ); 2976 addresseeRSync.setRevision( mLastAddressbookSync );
2975 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2977 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2976 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2978 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2977 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2979 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2978 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2980 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2979 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2981 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2980 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2982 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2981 addresseeRSync.setNote( "" ) ; 2983 addresseeRSync.setNote( "" ) ;
2982 addresseeLSync.setNote( "" ); 2984 addresseeLSync.setNote( "" );
2983 2985
2984 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2986 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2985 remote->insertAddressee( addresseeRSync, false ); 2987 remote->insertAddressee( addresseeRSync, false );
2986 local->insertAddressee( addresseeLSync, false ); 2988 local->insertAddressee( addresseeLSync, false );
2987 QString mes; 2989 QString mes;
2988 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2990 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2989 qDebug( mes ); 2991 qDebug( mes );
2990 mes = i18n("Local addressbook changed!\n") +mes; 2992 mes = i18n("Local addressbook changed!\n") +mes;
2991 if ( syncManager->mShowSyncSummary ) { 2993 if ( syncManager->mShowSyncSummary ) {
2992 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 2994 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
2993 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 2995 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
2994 qDebug("cancelled "); 2996 qDebug("cancelled ");
2995 return false; 2997 return false;
2996 } 2998 }
2997 } 2999 }
2998 return syncOK; 3000 return syncOK;
2999} 3001}
3000 3002
3001 3003
3002//this is a overwritten callbackmethods from the syncinterface 3004//this is a overwritten callbackmethods from the syncinterface
3003bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3005bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3004{ 3006{
3005 3007
3006 //pending prepare addresseeview for output 3008 //pending prepare addresseeview for output
3007 //pending detect, if remote file has REV field. if not switch to external sync 3009 //pending detect, if remote file has REV field. if not switch to external sync
3008 mGlobalSyncMode = SYNC_MODE_NORMAL; 3010 mGlobalSyncMode = SYNC_MODE_NORMAL;
3011 if ( manager != syncManager )
3012 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3009 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3013 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3010 3014
3011 AddressBook abLocal(filename,"syncContact"); 3015 AddressBook abLocal(filename,"syncContact");
3012 bool syncOK = false; 3016 bool syncOK = false;
3013 if ( abLocal.load() ) { 3017 if ( abLocal.load() ) {
3014 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 3018 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
3015 bool external = false; 3019 bool external = false;
3016 bool isXML = false; 3020 bool isXML = false;
3017 if ( filename.right(4) == ".xml") { 3021 if ( filename.right(4) == ".xml") {
3018 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3022 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3019 isXML = true; 3023 isXML = true;
3020 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3024 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3021 } else { 3025 } else {
3022 external = !manager->mIsKapiFile; 3026 external = !manager->mIsKapiFile;
3023 if ( external ) { 3027 if ( external ) {
3024 qDebug("Setting vcf mode to external "); 3028 qDebug("Setting vcf mode to external ");
3025 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3029 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3026 AddressBook::Iterator it; 3030 AddressBook::Iterator it;
3027 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3031 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3028 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3032 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3029 (*it).computeCsum( mCurrentSyncDevice ); 3033 (*it).computeCsum( mCurrentSyncDevice );
3030 } 3034 }
3031 } 3035 }
3032 } 3036 }
3033 //AddressBook::Iterator it; 3037 //AddressBook::Iterator it;
3034 //QStringList vcards; 3038 //QStringList vcards;
3035 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3039 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3036 // qDebug("Name %s ", (*it).familyName().latin1()); 3040 // qDebug("Name %s ", (*it).familyName().latin1());
3037 //} 3041 //}
3038 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3042 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3039 if ( syncOK ) { 3043 if ( syncOK ) {
3040 if ( syncManager->mWriteBackFile ) 3044 if ( syncManager->mWriteBackFile )
3041 { 3045 {
3042 if ( external ) 3046 if ( external )
3043 abLocal.removeSyncAddressees( !isXML); 3047 abLocal.removeSyncAddressees( !isXML);
3044 qDebug("Saving remote AB "); 3048 qDebug("Saving remote AB ");
3045 if ( ! abLocal.saveAB()) 3049 if ( ! abLocal.saveAB())
3046 qDebug("Error writing back AB to file "); 3050 qDebug("Error writing back AB to file ");
3047 if ( external ) { 3051 if ( external ) {
3048 // afterwrite processing 3052 // afterwrite processing
3049 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3053 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3050 } 3054 }
3051 } 3055 }
3052 } 3056 }
3053 setModified(); 3057 setModified();
3054 3058
3055 } 3059 }
3056 abLocal.removeResources(); 3060 abLocal.removeResources();
3057 if ( syncOK ) 3061 if ( syncOK )
3058 mViewManager->refreshView(); 3062 mViewManager->refreshView();
3059 return syncOK; 3063 return syncOK;
3060 3064
3061} 3065}
3062void KABCore::removeSyncInfo( QString syncProfile) 3066void KABCore::removeSyncInfo( QString syncProfile)
3063{ 3067{
3064 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3068 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3065 mAddressBook->removeSyncInfo( syncProfile ); 3069 mAddressBook->removeSyncInfo( syncProfile );
3066 setModified(); 3070 setModified();
3067} 3071}
3068 3072
3069 3073
3070//this is a overwritten callbackmethods from the syncinterface 3074//this is a overwritten callbackmethods from the syncinterface
3071bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3075bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3072{ 3076{
3073 if ( resource == "phone" ) 3077 if ( resource == "phone" )
3074 return syncPhone(); 3078 return syncPhone();
3075 disableBR( true ); 3079 disableBR( true );
3080 if ( manager != syncManager )
3081 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3076 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3082 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3077 3083
3078 AddressBook abLocal( resource,"syncContact"); 3084 AddressBook abLocal( resource,"syncContact");
3079 bool syncOK = false; 3085 bool syncOK = false;
3080 if ( abLocal.load() ) { 3086 if ( abLocal.load() ) {
3081 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3087 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3082 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3088 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3083 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3089 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3084 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3090 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3085 if ( syncOK ) { 3091 if ( syncOK ) {
3086 if ( syncManager->mWriteBackFile ) { 3092 if ( syncManager->mWriteBackFile ) {
3087 abLocal.removeSyncAddressees( false ); 3093 abLocal.removeSyncAddressees( false );
3088 abLocal.saveAB(); 3094 abLocal.saveAB();
3089 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3095 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3090 } 3096 }
3091 } else 3097 } else
3092 message( i18n("Sync cancelled or failed.") ); 3098 message( i18n("Sync cancelled or failed.") );
3093 setModified(); 3099 setModified();
3094 } 3100 }
3095 abLocal.removeResources(); 3101 abLocal.removeResources();
3096 if ( syncOK ) 3102 if ( syncOK )
3097 mViewManager->refreshView(); 3103 mViewManager->refreshView();
3098 disableBR( false ); 3104 disableBR( false );
3099 return syncOK; 3105 return syncOK;
3100 3106
3101} 3107}
3102void KABCore::message( QString m ) 3108void KABCore::message( QString m )
3103{ 3109{
3104 topLevelWidget()->setCaption( m ); 3110 topLevelWidget()->setCaption( m );
3105 mMessageTimer->start( 15000, true ); 3111 mMessageTimer->start( 15000, true );
3106} 3112}
3107bool KABCore::syncPhone() 3113bool KABCore::syncPhone()
3108{ 3114{
3109 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3115 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3110 QString fileName = getPhoneFile(); 3116 QString fileName = getPhoneFile();
3111 if ( !PhoneAccess::readFromPhone( fileName) ) { 3117 if ( !PhoneAccess::readFromPhone( fileName) ) {
3112 message(i18n("Phone access failed!")); 3118 message(i18n("Phone access failed!"));
3113 return false; 3119 return false;
3114 } 3120 }
3115 AddressBook abLocal( fileName,"syncContact"); 3121 AddressBook abLocal( fileName,"syncContact");
3116 bool syncOK = false; 3122 bool syncOK = false;
3117 { 3123 {
3118 abLocal.importFromFile( fileName ); 3124 abLocal.importFromFile( fileName );
3119 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3125 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3120 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3126 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3121 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3127 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3122 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3128 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3123 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3129 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3124 if ( syncOK ) { 3130 if ( syncOK ) {
3125 if ( syncManager->mWriteBackFile ) { 3131 if ( syncManager->mWriteBackFile ) {
3126 abLocal.removeSyncAddressees( true ); 3132 abLocal.removeSyncAddressees( true );
3127 abLocal.saveABphone( fileName ); 3133 abLocal.saveABphone( fileName );
3128 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3134 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3129 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3135 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3130 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3136 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3131 } 3137 }
3132 } 3138 }
3133 setModified(); 3139 setModified();
3134 } 3140 }
3135 abLocal.removeResources(); 3141 abLocal.removeResources();
3136 if ( syncOK ) 3142 if ( syncOK )
3137 mViewManager->refreshView(); 3143 mViewManager->refreshView();
3138 return syncOK; 3144 return syncOK;
3139} 3145}
3140void KABCore::getFile( bool success ) 3146void KABCore::getFile( bool success )
3141{ 3147{
3142 if ( ! success ) { 3148 if ( ! success ) {
3143 message( i18n("Error receiving file. Nothing changed!") ); 3149 message( i18n("Error receiving file. Nothing changed!") );
3144 return; 3150 return;
3145 } 3151 }
3146 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3152 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3147 if ( count ) 3153 if ( count )
3148 setModified( true ); 3154 setModified( true );
3149 message( i18n("Pi-Sync successful!") ); 3155 message( i18n("Pi-Sync successful!") );
3150 mViewManager->refreshView(); 3156 mViewManager->refreshView();
3151} 3157}
3152void KABCore::syncFileRequest() 3158void KABCore::syncFileRequest()
3153{ 3159{
3154 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3160 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3155 syncManager->slotSyncMenu( 999 ); 3161 syncManager->slotSyncMenu( 999 );
3156 } 3162 }
3157 mAddressBook->export2File( sentSyncFile() ); 3163 mAddressBook->export2File( sentSyncFile() );
3158} 3164}
3159QString KABCore::sentSyncFile() 3165QString KABCore::sentSyncFile()
3160{ 3166{
3161#ifdef DESKTOP_VERSION 3167#ifdef DESKTOP_VERSION
3162 return locateLocal( "tmp", "copysyncab.vcf" ); 3168 return locateLocal( "tmp", "copysyncab.vcf" );
3163#else 3169#else
3164 return QString( "/tmp/copysyncab.vcf" ); 3170 return QString( "/tmp/copysyncab.vcf" );
3165#endif 3171#endif
3166} 3172}
3167 3173
3168void KABCore::setCaptionBack() 3174void KABCore::setCaptionBack()
3169{ 3175{
3170 mMessageTimer->stop(); 3176 mMessageTimer->stop();
3171 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3177 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3172} 3178}