summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 2dea619..5d377bf 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1555,769 +1555,769 @@ void KABCore::setDetailsVisible( bool visible )
1555 if ( visible ) 1555 if ( visible )
1556 mDetails->show(); 1556 mDetails->show();
1557 else 1557 else
1558 mDetails->hide(); 1558 mDetails->hide();
1559 } 1559 }
1560 else 1560 else
1561 { 1561 {
1562 if ( visible ) { 1562 if ( visible ) {
1563 mViewManager->hide(); 1563 mViewManager->hide();
1564 mDetails->show(); 1564 mDetails->show();
1565 mIncSearchWidget->setFocus(); 1565 mIncSearchWidget->setFocus();
1566 } 1566 }
1567 else { 1567 else {
1568 mViewManager->show(); 1568 mViewManager->show();
1569 mDetails->hide(); 1569 mDetails->hide();
1570 mViewManager->setFocusAV(); 1570 mViewManager->setFocusAV();
1571 } 1571 }
1572 setJumpButtonBarVisible( !visible ); 1572 setJumpButtonBarVisible( !visible );
1573 } 1573 }
1574 1574
1575} 1575}
1576 1576
1577void KABCore::extensionChanged( int id ) 1577void KABCore::extensionChanged( int id )
1578{ 1578{
1579 //change the details view only for non desktop systems 1579 //change the details view only for non desktop systems
1580#ifndef DESKTOP_VERSION 1580#ifndef DESKTOP_VERSION
1581 1581
1582 if (id == 0) 1582 if (id == 0)
1583 { 1583 {
1584 //the user disabled the extension. 1584 //the user disabled the extension.
1585 1585
1586 if (mMultipleViewsAtOnce) 1586 if (mMultipleViewsAtOnce)
1587 { // enable detailsview again 1587 { // enable detailsview again
1588 setDetailsVisible( true ); 1588 setDetailsVisible( true );
1589 mActionDetails->setChecked( true ); 1589 mActionDetails->setChecked( true );
1590 } 1590 }
1591 else 1591 else
1592 { //go back to the listview 1592 { //go back to the listview
1593 setDetailsVisible( false ); 1593 setDetailsVisible( false );
1594 mActionDetails->setChecked( false ); 1594 mActionDetails->setChecked( false );
1595 mActionDetails->setEnabled(true); 1595 mActionDetails->setEnabled(true);
1596 } 1596 }
1597 1597
1598 } 1598 }
1599 else 1599 else
1600 { 1600 {
1601 //the user enabled the extension. 1601 //the user enabled the extension.
1602 setDetailsVisible( false ); 1602 setDetailsVisible( false );
1603 mActionDetails->setChecked( false ); 1603 mActionDetails->setChecked( false );
1604 1604
1605 if (!mMultipleViewsAtOnce) 1605 if (!mMultipleViewsAtOnce)
1606 { 1606 {
1607 mActionDetails->setEnabled(false); 1607 mActionDetails->setEnabled(false);
1608 } 1608 }
1609 1609
1610 mExtensionManager->setSelectionChanged(); 1610 mExtensionManager->setSelectionChanged();
1611 1611
1612 } 1612 }
1613 1613
1614#endif// DESKTOP_VERSION 1614#endif// DESKTOP_VERSION
1615 1615
1616} 1616}
1617 1617
1618 1618
1619void KABCore::extensionModified( const KABC::Addressee::List &list ) 1619void KABCore::extensionModified( const KABC::Addressee::List &list )
1620{ 1620{
1621 1621
1622 if ( list.count() != 0 ) { 1622 if ( list.count() != 0 ) {
1623 KABC::Addressee::List::ConstIterator it; 1623 KABC::Addressee::List::ConstIterator it;
1624 for ( it = list.begin(); it != list.end(); ++it ) 1624 for ( it = list.begin(); it != list.end(); ++it )
1625 mAddressBook->insertAddressee( *it ); 1625 mAddressBook->insertAddressee( *it );
1626 if ( list.count() > 1 ) 1626 if ( list.count() > 1 )
1627 setModified(); 1627 setModified();
1628 else 1628 else
1629 setModifiedWOrefresh(); 1629 setModifiedWOrefresh();
1630 } 1630 }
1631 if ( list.count() == 0 ) 1631 if ( list.count() == 0 )
1632 mViewManager->refreshView(); 1632 mViewManager->refreshView();
1633 else 1633 else
1634 mViewManager->refreshView( list[ 0 ].uid() ); 1634 mViewManager->refreshView( list[ 0 ].uid() );
1635 1635
1636 1636
1637 1637
1638} 1638}
1639 1639
1640QString KABCore::getNameByPhone( const QString &phone ) 1640QString KABCore::getNameByPhone( const QString &phone )
1641{ 1641{
1642#ifndef KAB_EMBEDDED 1642#ifndef KAB_EMBEDDED
1643 QRegExp r( "[/*/-/ ]" ); 1643 QRegExp r( "[/*/-/ ]" );
1644 QString localPhone( phone ); 1644 QString localPhone( phone );
1645 1645
1646 bool found = false; 1646 bool found = false;
1647 QString ownerName = ""; 1647 QString ownerName = "";
1648 KABC::AddressBook::Iterator iter; 1648 KABC::AddressBook::Iterator iter;
1649 KABC::PhoneNumber::List::Iterator phoneIter; 1649 KABC::PhoneNumber::List::Iterator phoneIter;
1650 KABC::PhoneNumber::List phoneList; 1650 KABC::PhoneNumber::List phoneList;
1651 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1651 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1652 phoneList = (*iter).phoneNumbers(); 1652 phoneList = (*iter).phoneNumbers();
1653 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1653 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1654 ++phoneIter) { 1654 ++phoneIter) {
1655 // Get rid of separator chars so just the numbers are compared. 1655 // Get rid of separator chars so just the numbers are compared.
1656 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1656 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1657 ownerName = (*iter).formattedName(); 1657 ownerName = (*iter).formattedName();
1658 found = true; 1658 found = true;
1659 } 1659 }
1660 } 1660 }
1661 } 1661 }
1662 1662
1663 return ownerName; 1663 return ownerName;
1664#else //KAB_EMBEDDED 1664#else //KAB_EMBEDDED
1665 qDebug("KABCore::getNameByPhone finsih method"); 1665 qDebug("KABCore::getNameByPhone finsih method");
1666 return ""; 1666 return "";
1667#endif //KAB_EMBEDDED 1667#endif //KAB_EMBEDDED
1668 1668
1669} 1669}
1670void KABCore::openConfigGlobalDialog() 1670void KABCore::openConfigGlobalDialog()
1671{ 1671{
1672 KPimPrefsGlobalDialog gc ( this ); 1672 KPimPrefsGlobalDialog gc ( this );
1673 gc.exec(); 1673 gc.exec();
1674} 1674}
1675void KABCore::openConfigDialog() 1675void KABCore::openConfigDialog()
1676{ 1676{
1677 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); 1677 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true);
1678 1678
1679 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" ); 1679 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" );
1680 ConfigureDialog->setMainWidget( kabcfg ); 1680 ConfigureDialog->setMainWidget( kabcfg );
1681 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1681 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1682 this, SLOT( configurationChanged() ) ); 1682 this, SLOT( configurationChanged() ) );
1683 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1683 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1684 kabcfg, SLOT( save() ) ); 1684 kabcfg, SLOT( save() ) );
1685 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1685 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1686 this, SLOT( configurationChanged() ) ); 1686 this, SLOT( configurationChanged() ) );
1687 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1687 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1688 kabcfg, SLOT( save() ) ); 1688 kabcfg, SLOT( save() ) );
1689 connect( ConfigureDialog, SIGNAL( defaultClicked() ), 1689 connect( ConfigureDialog, SIGNAL( defaultClicked() ),
1690 kabcfg, SLOT( defaults() ) ); 1690 kabcfg, SLOT( defaults() ) );
1691 saveSettings(); 1691 saveSettings();
1692 kabcfg->load(); 1692 kabcfg->load();
1693#ifndef DESKTOP_VERSION 1693#ifndef DESKTOP_VERSION
1694 if ( QApplication::desktop()->height() <= 480 ) 1694 if ( QApplication::desktop()->height() <= 480 )
1695 ConfigureDialog->hideButtons(); 1695 ConfigureDialog->hideButtons();
1696 ConfigureDialog->showMaximized(); 1696 ConfigureDialog->showMaximized();
1697#endif 1697#endif
1698 if ( ConfigureDialog->exec() ) 1698 if ( ConfigureDialog->exec() )
1699 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1699 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1700 delete ConfigureDialog; 1700 delete ConfigureDialog;
1701} 1701}
1702 1702
1703void KABCore::openLDAPDialog() 1703void KABCore::openLDAPDialog()
1704{ 1704{
1705#ifndef KAB_EMBEDDED 1705#ifndef KAB_EMBEDDED
1706 if ( !mLdapSearchDialog ) { 1706 if ( !mLdapSearchDialog ) {
1707 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1707 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1708 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1708 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1709 SLOT( refreshView() ) ); 1709 SLOT( refreshView() ) );
1710 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1710 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1711 SLOT( setModified() ) ); 1711 SLOT( setModified() ) );
1712 } else 1712 } else
1713 mLdapSearchDialog->restoreSettings(); 1713 mLdapSearchDialog->restoreSettings();
1714 1714
1715 if ( mLdapSearchDialog->isOK() ) 1715 if ( mLdapSearchDialog->isOK() )
1716 mLdapSearchDialog->exec(); 1716 mLdapSearchDialog->exec();
1717#else //KAB_EMBEDDED 1717#else //KAB_EMBEDDED
1718 qDebug("KABCore::openLDAPDialog() finsih method"); 1718 qDebug("KABCore::openLDAPDialog() finsih method");
1719#endif //KAB_EMBEDDED 1719#endif //KAB_EMBEDDED
1720} 1720}
1721 1721
1722void KABCore::print() 1722void KABCore::print()
1723{ 1723{
1724#ifndef KAB_EMBEDDED 1724#ifndef KAB_EMBEDDED
1725 KPrinter printer; 1725 KPrinter printer;
1726 if ( !printer.setup( this ) ) 1726 if ( !printer.setup( this ) )
1727 return; 1727 return;
1728 1728
1729 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1729 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1730 mViewManager->selectedUids(), this ); 1730 mViewManager->selectedUids(), this );
1731 1731
1732 wizard.exec(); 1732 wizard.exec();
1733#else //KAB_EMBEDDED 1733#else //KAB_EMBEDDED
1734 qDebug("KABCore::print() finsih method"); 1734 qDebug("KABCore::print() finsih method");
1735#endif //KAB_EMBEDDED 1735#endif //KAB_EMBEDDED
1736 1736
1737} 1737}
1738 1738
1739 1739
1740void KABCore::addGUIClient( KXMLGUIClient *client ) 1740void KABCore::addGUIClient( KXMLGUIClient *client )
1741{ 1741{
1742 if ( mGUIClient ) 1742 if ( mGUIClient )
1743 mGUIClient->insertChildClient( client ); 1743 mGUIClient->insertChildClient( client );
1744 else 1744 else
1745 KMessageBox::error( this, "no KXMLGUICLient"); 1745 KMessageBox::error( this, "no KXMLGUICLient");
1746} 1746}
1747 1747
1748 1748
1749void KABCore::configurationChanged() 1749void KABCore::configurationChanged()
1750{ 1750{
1751 mExtensionManager->reconfigure(); 1751 mExtensionManager->reconfigure();
1752} 1752}
1753 1753
1754void KABCore::addressBookChanged() 1754void KABCore::addressBookChanged()
1755{ 1755{
1756/*US 1756/*US
1757 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1757 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1758 while ( it.current() ) { 1758 while ( it.current() ) {
1759 if ( it.current()->dirty() ) { 1759 if ( it.current()->dirty() ) {
1760 QString text = i18n( "Data has been changed externally. Unsaved " 1760 QString text = i18n( "Data has been changed externally. Unsaved "
1761 "changes will be lost." ); 1761 "changes will be lost." );
1762 KMessageBox::information( this, text ); 1762 KMessageBox::information( this, text );
1763 } 1763 }
1764 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1764 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1765 ++it; 1765 ++it;
1766 } 1766 }
1767*/ 1767*/
1768 if (mEditorDialog) 1768 if (mEditorDialog)
1769 { 1769 {
1770 if (mEditorDialog->dirty()) 1770 if (mEditorDialog->dirty())
1771 { 1771 {
1772 QString text = i18n( "Data has been changed externally. Unsaved " 1772 QString text = i18n( "Data has been changed externally. Unsaved "
1773 "changes will be lost." ); 1773 "changes will be lost." );
1774 KMessageBox::information( this, text ); 1774 KMessageBox::information( this, text );
1775 } 1775 }
1776 QString currentuid = mEditorDialog->addressee().uid(); 1776 QString currentuid = mEditorDialog->addressee().uid();
1777 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1777 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1778 } 1778 }
1779 mViewManager->refreshView(); 1779 mViewManager->refreshView();
1780 1780
1781 1781
1782} 1782}
1783 1783
1784AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1784AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1785 const char *name ) 1785 const char *name )
1786{ 1786{
1787 1787
1788 if ( mEditorDialog == 0 ) { 1788 if ( mEditorDialog == 0 ) {
1789 mEditorDialog = new AddresseeEditorDialog( this, parent, 1789 mEditorDialog = new AddresseeEditorDialog( this, parent,
1790 name ? name : "editorDialog" ); 1790 name ? name : "editorDialog" );
1791 1791
1792 1792
1793 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1793 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1794 SLOT( contactModified( const KABC::Addressee& ) ) ); 1794 SLOT( contactModified( const KABC::Addressee& ) ) );
1795 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1795 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1796 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1796 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1797 } 1797 }
1798 1798
1799 return mEditorDialog; 1799 return mEditorDialog;
1800} 1800}
1801 1801
1802void KABCore::slotEditorDestroyed( const QString &uid ) 1802void KABCore::slotEditorDestroyed( const QString &uid )
1803{ 1803{
1804 //mEditorDict.remove( uid ); 1804 //mEditorDict.remove( uid );
1805} 1805}
1806 1806
1807void KABCore::initGUI() 1807void KABCore::initGUI()
1808{ 1808{
1809#ifndef KAB_EMBEDDED 1809#ifndef KAB_EMBEDDED
1810 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1810 QHBoxLayout *topLayout = new QHBoxLayout( this );
1811 topLayout->setSpacing( KDialogBase::spacingHint() ); 1811 topLayout->setSpacing( KDialogBase::spacingHint() );
1812 1812
1813 mExtensionBarSplitter = new QSplitter( this ); 1813 mExtensionBarSplitter = new QSplitter( this );
1814 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1814 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1815 1815
1816 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1816 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1817 1817
1818 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1818 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1819 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1819 mIncSearchWidget = new IncSearchWidget( viewSpace );
1820 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1820 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1821 SLOT( incrementalSearch( const QString& ) ) ); 1821 SLOT( incrementalSearch( const QString& ) ) );
1822 1822
1823 mViewManager = new ViewManager( this, viewSpace ); 1823 mViewManager = new ViewManager( this, viewSpace );
1824 viewSpace->setStretchFactor( mViewManager, 1 ); 1824 viewSpace->setStretchFactor( mViewManager, 1 );
1825 1825
1826 mDetails = new ViewContainer( mDetailsSplitter ); 1826 mDetails = new ViewContainer( mDetailsSplitter );
1827 1827
1828 mJumpButtonBar = new JumpButtonBar( this, this ); 1828 mJumpButtonBar = new JumpButtonBar( this, this );
1829 1829
1830 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1830 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1831 1831
1832 topLayout->addWidget( mExtensionBarSplitter ); 1832 topLayout->addWidget( mExtensionBarSplitter );
1833 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1833 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1834 topLayout->addWidget( mJumpButtonBar ); 1834 topLayout->addWidget( mJumpButtonBar );
1835 //topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1835 //topLayout->setStretchFactor( mJumpButtonBar, 1 );
1836 1836
1837 mXXPortManager = new XXPortManager( this, this ); 1837 mXXPortManager = new XXPortManager( this, this );
1838 1838
1839#else //KAB_EMBEDDED 1839#else //KAB_EMBEDDED
1840 //US initialize viewMenu before settingup viewmanager. 1840 //US initialize viewMenu before settingup viewmanager.
1841 // Viewmanager needs this menu to plugin submenues. 1841 // Viewmanager needs this menu to plugin submenues.
1842 viewMenu = new QPopupMenu( this ); 1842 viewMenu = new QPopupMenu( this );
1843 settingsMenu = new QPopupMenu( this ); 1843 settingsMenu = new QPopupMenu( this );
1844 //filterMenu = new QPopupMenu( this ); 1844 //filterMenu = new QPopupMenu( this );
1845 ImportMenu = new QPopupMenu( this ); 1845 ImportMenu = new QPopupMenu( this );
1846 ExportMenu = new QPopupMenu( this ); 1846 ExportMenu = new QPopupMenu( this );
1847 syncMenu = new QPopupMenu( this ); 1847 syncMenu = new QPopupMenu( this );
1848 changeMenu= new QPopupMenu( this ); 1848 changeMenu= new QPopupMenu( this );
1849 beamMenu= new QPopupMenu( this ); 1849 beamMenu= new QPopupMenu( this );
1850 1850
1851//US since we have no splitter for the embedded system, setup 1851//US since we have no splitter for the embedded system, setup
1852// a layout with two frames. One left and one right. 1852// a layout with two frames. One left and one right.
1853 1853
1854 QBoxLayout *topLayout; 1854 QBoxLayout *topLayout;
1855 1855
1856 // = new QHBoxLayout( this ); 1856 // = new QHBoxLayout( this );
1857// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1857// QBoxLayout *topLayout = (QBoxLayout*)layout();
1858 1858
1859// QWidget *mainBox = new QWidget( this ); 1859// QWidget *mainBox = new QWidget( this );
1860// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1860// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1861 1861
1862#ifdef DESKTOP_VERSION 1862#ifdef DESKTOP_VERSION
1863 topLayout = new QHBoxLayout( this ); 1863 topLayout = new QHBoxLayout( this );
1864 1864
1865 1865
1866 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1866 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1867 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1867 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1868 1868
1869 topLayout->addWidget(mMiniSplitter ); 1869 topLayout->addWidget(mMiniSplitter );
1870 1870
1871 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1871 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1872 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1872 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1873 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1873 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1874 mDetails = new ViewContainer( mMiniSplitter ); 1874 mDetails = new ViewContainer( mMiniSplitter );
1875 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1875 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1876#else 1876#else
1877 if ( QApplication::desktop()->width() > 480 ) { 1877 if ( QApplication::desktop()->width() > 480 ) {
1878 topLayout = new QHBoxLayout( this ); 1878 topLayout = new QHBoxLayout( this );
1879 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1879 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1880 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1880 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1881 } else { 1881 } else {
1882 1882
1883 topLayout = new QHBoxLayout( this ); 1883 topLayout = new QHBoxLayout( this );
1884 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1884 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1885 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1885 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1886 } 1886 }
1887 1887
1888 topLayout->addWidget(mMiniSplitter ); 1888 topLayout->addWidget(mMiniSplitter );
1889 mViewManager = new ViewManager( this, mMiniSplitter ); 1889 mViewManager = new ViewManager( this, mMiniSplitter );
1890 mDetails = new ViewContainer( mMiniSplitter ); 1890 mDetails = new ViewContainer( mMiniSplitter );
1891 1891
1892 1892
1893 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1893 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1894#endif 1894#endif
1895 //eh->hide(); 1895 //eh->hide();
1896 // topLayout->addWidget(mExtensionManager ); 1896 // topLayout->addWidget(mExtensionManager );
1897 1897
1898 1898
1899/*US 1899/*US
1900#ifndef KAB_NOSPLITTER 1900#ifndef KAB_NOSPLITTER
1901 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1901 QHBoxLayout *topLayout = new QHBoxLayout( this );
1902//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1902//US topLayout->setSpacing( KDialogBase::spacingHint() );
1903 topLayout->setSpacing( 10 ); 1903 topLayout->setSpacing( 10 );
1904 1904
1905 mDetailsSplitter = new QSplitter( this ); 1905 mDetailsSplitter = new QSplitter( this );
1906 1906
1907 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1907 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1908 1908
1909 mViewManager = new ViewManager( this, viewSpace ); 1909 mViewManager = new ViewManager( this, viewSpace );
1910 viewSpace->setStretchFactor( mViewManager, 1 ); 1910 viewSpace->setStretchFactor( mViewManager, 1 );
1911 1911
1912 mDetails = new ViewContainer( mDetailsSplitter ); 1912 mDetails = new ViewContainer( mDetailsSplitter );
1913 1913
1914 topLayout->addWidget( mDetailsSplitter ); 1914 topLayout->addWidget( mDetailsSplitter );
1915 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1915 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1916#else //KAB_NOSPLITTER 1916#else //KAB_NOSPLITTER
1917 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1917 QHBoxLayout *topLayout = new QHBoxLayout( this );
1918//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1918//US topLayout->setSpacing( KDialogBase::spacingHint() );
1919 topLayout->setSpacing( 10 ); 1919 topLayout->setSpacing( 10 );
1920 1920
1921// mDetailsSplitter = new QSplitter( this ); 1921// mDetailsSplitter = new QSplitter( this );
1922 1922
1923 QVBox *viewSpace = new QVBox( this ); 1923 QVBox *viewSpace = new QVBox( this );
1924 1924
1925 mViewManager = new ViewManager( this, viewSpace ); 1925 mViewManager = new ViewManager( this, viewSpace );
1926 viewSpace->setStretchFactor( mViewManager, 1 ); 1926 viewSpace->setStretchFactor( mViewManager, 1 );
1927 1927
1928 mDetails = new ViewContainer( this ); 1928 mDetails = new ViewContainer( this );
1929 1929
1930 topLayout->addWidget( viewSpace ); 1930 topLayout->addWidget( viewSpace );
1931// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1931// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1932 topLayout->addWidget( mDetails ); 1932 topLayout->addWidget( mDetails );
1933#endif //KAB_NOSPLITTER 1933#endif //KAB_NOSPLITTER
1934*/ 1934*/
1935 1935
1936 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1936 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1937 syncManager->setBlockSave(false); 1937 syncManager->setBlockSave(false);
1938 1938
1939 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1939 connect(syncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) );
1940 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1940 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1941 QString sync_file = sentSyncFile(); 1941 QString sync_file = sentSyncFile();
1942 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1942 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1943 syncManager->setDefaultFileName( sync_file ); 1943 syncManager->setDefaultFileName( sync_file );
1944 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1944 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1945 1945
1946#endif //KAB_EMBEDDED 1946#endif //KAB_EMBEDDED
1947 initActions(); 1947 initActions();
1948 1948
1949#ifdef KAB_EMBEDDED 1949#ifdef KAB_EMBEDDED
1950 addActionsManually(); 1950 addActionsManually();
1951 //US make sure the export and import menues are initialized before creating the xxPortManager. 1951 //US make sure the export and import menues are initialized before creating the xxPortManager.
1952 mXXPortManager = new XXPortManager( this, this ); 1952 mXXPortManager = new XXPortManager( this, this );
1953 1953
1954 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1954 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1955 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1955 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1956 // mActionQuit->plug ( mMainWindow->toolBar()); 1956 // mActionQuit->plug ( mMainWindow->toolBar());
1957 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1957 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1958 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1958 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1959 // mIncSearchWidget->hide(); 1959 // mIncSearchWidget->hide();
1960 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1960 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1961 SLOT( incrementalSearch( const QString& ) ) ); 1961 SLOT( incrementalSearch( const QString& ) ) );
1962 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1962 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1963 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1963 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1964 1964
1965 mJumpButtonBar = new JumpButtonBar( this, this ); 1965 mJumpButtonBar = new JumpButtonBar( this, this );
1966 1966
1967 topLayout->addWidget( mJumpButtonBar ); 1967 topLayout->addWidget( mJumpButtonBar );
1968//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1968//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1969 1969
1970// mMainWindow->getIconToolBar()->raise(); 1970// mMainWindow->getIconToolBar()->raise();
1971 1971
1972#endif //KAB_EMBEDDED 1972#endif //KAB_EMBEDDED
1973 1973
1974} 1974}
1975void KABCore::initActions() 1975void KABCore::initActions()
1976{ 1976{
1977//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1977//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1978 1978
1979#ifndef KAB_EMBEDDED 1979#ifndef KAB_EMBEDDED
1980 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1980 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1981 SLOT( clipboardDataChanged() ) ); 1981 SLOT( clipboardDataChanged() ) );
1982#endif //KAB_EMBEDDED 1982#endif //KAB_EMBEDDED
1983 1983
1984 // file menu 1984 // file menu
1985 1985
1986 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1986 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1987 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1987 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1988 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1988 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1989 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1989 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1990 1990
1991 1991
1992 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1992 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1993 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1993 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1994 1994
1995 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1995 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1996 SLOT( save() ), actionCollection(), "file_sync" ); 1996 SLOT( save() ), actionCollection(), "file_sync" );
1997 1997
1998 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1998 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1999 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1999 SLOT( newContact() ), actionCollection(), "file_new_contact" );
2000 2000
2001 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 2001 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
2002 this, SLOT( mailVCard() ), 2002 this, SLOT( mailVCard() ),
2003 actionCollection(), "file_mail_vcard"); 2003 actionCollection(), "file_mail_vcard");
2004 2004
2005 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 2005 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
2006 SLOT( export2phone() ), actionCollection(), 2006 SLOT( export2phone() ), actionCollection(),
2007 "kaddressbook_ex2phone" ); 2007 "kaddressbook_ex2phone" );
2008 2008
2009 mActionBeamVCard = 0; 2009 mActionBeamVCard = 0;
2010 mActionBeam = 0; 2010 mActionBeam = 0;
2011 2011
2012#ifndef DESKTOP_VERSION 2012#ifndef DESKTOP_VERSION
2013 if ( Ir::supported() ) { 2013 if ( Ir::supported() ) {
2014 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 2014 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
2015 SLOT( beamVCard() ), actionCollection(), 2015 SLOT( beamVCard() ), actionCollection(),
2016 "kaddressbook_beam_vcard" ); 2016 "kaddressbook_beam_vcard" );
2017 2017
2018 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 2018 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
2019 SLOT( beamMySelf() ), actionCollection(), 2019 SLOT( beamMySelf() ), actionCollection(),
2020 "kaddressbook_beam_myself" ); 2020 "kaddressbook_beam_myself" );
2021 } 2021 }
2022#endif 2022#endif
2023 2023
2024 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 2024 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
2025 this, SLOT( editContact2() ), 2025 this, SLOT( editContact2() ),
2026 actionCollection(), "file_properties" ); 2026 actionCollection(), "file_properties" );
2027 2027
2028#ifdef KAB_EMBEDDED 2028#ifdef KAB_EMBEDDED
2029 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 2029 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
2030 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 2030 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
2031 mMainWindow, SLOT( exit() ), 2031 mMainWindow, SLOT( exit() ),
2032 actionCollection(), "quit" ); 2032 actionCollection(), "quit" );
2033#endif //KAB_EMBEDDED 2033#endif //KAB_EMBEDDED
2034 2034
2035 // edit menu 2035 // edit menu
2036 if ( mIsPart ) { 2036 if ( mIsPart ) {
2037 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 2037 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
2038 SLOT( copyContacts() ), actionCollection(), 2038 SLOT( copyContacts() ), actionCollection(),
2039 "kaddressbook_copy" ); 2039 "kaddressbook_copy" );
2040 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 2040 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
2041 SLOT( cutContacts() ), actionCollection(), 2041 SLOT( cutContacts() ), actionCollection(),
2042 "kaddressbook_cut" ); 2042 "kaddressbook_cut" );
2043 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 2043 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
2044 SLOT( pasteContacts() ), actionCollection(), 2044 SLOT( pasteContacts() ), actionCollection(),
2045 "kaddressbook_paste" ); 2045 "kaddressbook_paste" );
2046 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 2046 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
2047 SLOT( selectAllContacts() ), actionCollection(), 2047 SLOT( selectAllContacts() ), actionCollection(),
2048 "kaddressbook_select_all" ); 2048 "kaddressbook_select_all" );
2049 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 2049 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
2050 SLOT( undo() ), actionCollection(), 2050 SLOT( undo() ), actionCollection(),
2051 "kaddressbook_undo" ); 2051 "kaddressbook_undo" );
2052 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 2052 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
2053 this, SLOT( redo() ), actionCollection(), 2053 this, SLOT( redo() ), actionCollection(),
2054 "kaddressbook_redo" ); 2054 "kaddressbook_redo" );
2055 } else { 2055 } else {
2056 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 2056 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
2057 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 2057 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
2058 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 2058 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
2059 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 2059 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
2060 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 2060 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
2061 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 2061 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
2062 } 2062 }
2063 2063
2064 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 2064 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
2065 Key_Delete, this, SLOT( deleteContacts() ), 2065 Key_Delete, this, SLOT( deleteContacts() ),
2066 actionCollection(), "edit_delete" ); 2066 actionCollection(), "edit_delete" );
2067 2067
2068 mActionUndo->setEnabled( false ); 2068 mActionUndo->setEnabled( false );
2069 mActionRedo->setEnabled( false ); 2069 mActionRedo->setEnabled( false );
2070 2070
2071 // settings menu 2071 // settings menu
2072#ifdef KAB_EMBEDDED 2072#ifdef KAB_EMBEDDED
2073//US special menuentry to configure the addressbook resources. On KDE 2073//US special menuentry to configure the addressbook resources. On KDE
2074// you do that through the control center !!! 2074// you do that through the control center !!!
2075 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 2075 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
2076 SLOT( configureResources() ), actionCollection(), 2076 SLOT( configureResources() ), actionCollection(),
2077 "kaddressbook_configure_resources" ); 2077 "kaddressbook_configure_resources" );
2078#endif //KAB_EMBEDDED 2078#endif //KAB_EMBEDDED
2079 2079
2080 if ( mIsPart ) { 2080 if ( mIsPart ) {
2081 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 2081 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
2082 SLOT( openConfigDialog() ), actionCollection(), 2082 SLOT( openConfigDialog() ), actionCollection(),
2083 "kaddressbook_configure" ); 2083 "kaddressbook_configure" );
2084 2084
2085 //US not implemented yet 2085 //US not implemented yet
2086 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 2086 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
2087 // this, SLOT( configureKeyBindings() ), actionCollection(), 2087 // this, SLOT( configureKeyBindings() ), actionCollection(),
2088 // "kaddressbook_configure_shortcuts" ); 2088 // "kaddressbook_configure_shortcuts" );
2089#ifdef KAB_EMBEDDED 2089#ifdef KAB_EMBEDDED
2090 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 2090 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
2091 mActionConfigureToolbars->setEnabled( false ); 2091 mActionConfigureToolbars->setEnabled( false );
2092#endif //KAB_EMBEDDED 2092#endif //KAB_EMBEDDED
2093 2093
2094 } else { 2094 } else {
2095 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this, 2095 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this,
2096 SLOT( openConfigDialog() ), actionCollection(), 2096 SLOT( openConfigDialog() ), actionCollection(),
2097 "kaddressbook_configure" ); 2097 "kaddressbook_configure" );
2098 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this, 2098 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this,
2099 SLOT( openConfigGlobalDialog() ), actionCollection(), 2099 SLOT( openConfigGlobalDialog() ), actionCollection(),
2100 "kaddressbook_configure" ); 2100 "kaddressbook_configure" );
2101 } 2101 }
2102 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2102 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2103 actionCollection(), "options_show_jump_bar" ); 2103 actionCollection(), "options_show_jump_bar" );
2104 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); 2104 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) );
2105 2105
2106 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2106 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2107 actionCollection(), "options_show_details" ); 2107 actionCollection(), "options_show_details" );
2108 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2108 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2109 2109
2110 2110
2111 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2111 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2112 SLOT( toggleBeamReceive() ), actionCollection(), 2112 SLOT( toggleBeamReceive() ), actionCollection(),
2113 "kaddressbook_beam_rec" ); 2113 "kaddressbook_beam_rec" );
2114 2114
2115 2115
2116 // misc 2116 // misc
2117 // only enable LDAP lookup if we can handle the protocol 2117 // only enable LDAP lookup if we can handle the protocol
2118#ifndef KAB_EMBEDDED 2118#ifndef KAB_EMBEDDED
2119 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2119 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2120 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2120 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2121 this, SLOT( openLDAPDialog() ), actionCollection(), 2121 this, SLOT( openLDAPDialog() ), actionCollection(),
2122 "ldap_lookup" ); 2122 "ldap_lookup" );
2123 } 2123 }
2124#else //KAB_EMBEDDED 2124#else //KAB_EMBEDDED
2125 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2125 //qDebug("KABCore::initActions() LDAP has to be implemented");
2126#endif //KAB_EMBEDDED 2126#endif //KAB_EMBEDDED
2127 2127
2128 2128
2129 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2129 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2130 SLOT( setWhoAmI() ), actionCollection(), 2130 SLOT( setWhoAmI() ), actionCollection(),
2131 "set_personal" ); 2131 "set_personal" );
2132 2132
2133 2133
2134 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, 2134 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this,
2135 SLOT( setCategories() ), actionCollection(), 2135 SLOT( setCategories() ), actionCollection(),
2136 "edit_set_categories" ); 2136 "edit_set_categories" );
2137 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, 2137 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this,
2138 SLOT( editCategories() ), actionCollection(), 2138 SLOT( editCategories() ), actionCollection(),
2139 "edit__categories" ); 2139 "edit__categories" );
2140 2140
2141 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2141 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2142 SLOT( removeVoice() ), actionCollection(), 2142 SLOT( removeVoice() ), actionCollection(),
2143 "remove_voice" ); 2143 "remove_voice" );
2144 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2144 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2145 SLOT( setFormattedName() ), actionCollection(), 2145 SLOT( setFormattedName() ), actionCollection(),
2146 "set_formatted" ); 2146 "set_formatted" );
2147 2147
2148 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2148 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2149 SLOT( manageCategories() ), actionCollection(), 2149 SLOT( manageCategories() ), actionCollection(),
2150 "remove_voice" ); 2150 "remove_voice" );
2151 2151
2152 2152
2153 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2153 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2154 SLOT( importFromOL() ), actionCollection(), 2154 SLOT( importFromOL() ), actionCollection(),
2155 "import_OL" ); 2155 "import_OL" );
2156#ifdef KAB_EMBEDDED 2156#ifdef KAB_EMBEDDED
2157 mActionLicence = new KAction( i18n( "Licence" ), 0, 2157 mActionLicence = new KAction( i18n( "Licence" ), 0,
2158 this, SLOT( showLicence() ), actionCollection(), 2158 this, SLOT( showLicence() ), actionCollection(),
2159 "licence_about_data" ); 2159 "licence_about_data" );
2160 mActionFaq = new KAction( i18n( "Faq" ), 0, 2160 mActionFaq = new KAction( i18n( "Faq" ), 0,
2161 this, SLOT( faq() ), actionCollection(), 2161 this, SLOT( faq() ), actionCollection(),
2162 "faq_about_data" ); 2162 "faq_about_data" );
2163 mActionWN = new KAction( i18n( "What's New?" ), 0, 2163 mActionWN = new KAction( i18n( "What's New?" ), 0,
2164 this, SLOT( whatsnew() ), actionCollection(), 2164 this, SLOT( whatsnew() ), actionCollection(),
2165 "wn" ); 2165 "wn" );
2166 2166
2167 2167
2168 2168
2169 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, 2169 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0,
2170 this, SLOT( storagehowto() ), actionCollection(), 2170 this, SLOT( storagehowto() ), actionCollection(),
2171 "storage" ); 2171 "storage" );
2172 2172
2173 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2173 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2174 this, SLOT( synchowto() ), actionCollection(), 2174 this, SLOT( synchowto() ), actionCollection(),
2175 "sync" ); 2175 "sync" );
2176 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2176 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2177 this, SLOT( kdesynchowto() ), actionCollection(), 2177 this, SLOT( kdesynchowto() ), actionCollection(),
2178 "kdesync" ); 2178 "kdesync" );
2179 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2179 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2180 this, SLOT( multisynchowto() ), actionCollection(), 2180 this, SLOT( multisynchowto() ), actionCollection(),
2181 "multisync" ); 2181 "multisync" );
2182 2182
2183 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2183 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2184 this, SLOT( createAboutData() ), actionCollection(), 2184 this, SLOT( createAboutData() ), actionCollection(),
2185 "kaddressbook_about_data" ); 2185 "kaddressbook_about_data" );
2186#endif //KAB_EMBEDDED 2186#endif //KAB_EMBEDDED
2187 2187
2188 clipboardDataChanged(); 2188 clipboardDataChanged();
2189 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2189 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2190 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2190 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2191} 2191}
2192 2192
2193//US we need this function, to plug all actions into the correct menues. 2193//US we need this function, to plug all actions into the correct menues.
2194// KDE uses a XML format to plug the actions, but we work her without this overhead. 2194// KDE uses a XML format to plug the actions, but we work her without this overhead.
2195void KABCore::addActionsManually() 2195void KABCore::addActionsManually()
2196{ 2196{
2197//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2197//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2198 2198
2199#ifdef KAB_EMBEDDED 2199#ifdef KAB_EMBEDDED
2200 QPopupMenu *fileMenu = new QPopupMenu( this ); 2200 QPopupMenu *fileMenu = new QPopupMenu( this );
2201 QPopupMenu *editMenu = new QPopupMenu( this ); 2201 QPopupMenu *editMenu = new QPopupMenu( this );
2202 QPopupMenu *helpMenu = new QPopupMenu( this ); 2202 QPopupMenu *helpMenu = new QPopupMenu( this );
2203 2203
2204 KToolBar* tb = mMainWindow->toolBar(); 2204 KToolBar* tb = mMainWindow->toolBar();
2205 mMainWindow->setToolBarsMovable (false ); 2205 mMainWindow->setToolBarsMovable (false );
2206#ifndef DESKTOP_VERSION 2206#ifndef DESKTOP_VERSION
2207 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2207 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2208#endif 2208#endif
2209 QMenuBar* mb = mMainWindow->menuBar(); 2209 QMenuBar* mb = mMainWindow->menuBar();
2210 2210
2211 //US setup menubar. 2211 //US setup menubar.
2212 //Disable the following block if you do not want to have a menubar. 2212 //Disable the following block if you do not want to have a menubar.
2213 mb->insertItem( i18n("&File"), fileMenu ); 2213 mb->insertItem( i18n("&File"), fileMenu );
2214 mb->insertItem( i18n("&Edit"), editMenu ); 2214 mb->insertItem( i18n("&Edit"), editMenu );
2215 mb->insertItem( i18n("&View"), viewMenu ); 2215 mb->insertItem( i18n("&View"), viewMenu );
2216 mb->insertItem( i18n("&Settings"), settingsMenu ); 2216 mb->insertItem( i18n("&Settings"), settingsMenu );
2217#ifdef DESKTOP_VERSION 2217#ifdef DESKTOP_VERSION
2218 mb->insertItem( i18n("Synchronize"), syncMenu ); 2218 mb->insertItem( i18n("Synchronize"), syncMenu );
2219#else 2219#else
2220 mb->insertItem( i18n("Sync"), syncMenu ); 2220 mb->insertItem( i18n("Sync"), syncMenu );
2221#endif 2221#endif
2222 //mb->insertItem( i18n("&Change"), changeMenu ); 2222 //mb->insertItem( i18n("&Change"), changeMenu );
2223 mb->insertItem( i18n("&Help"), helpMenu ); 2223 mb->insertItem( i18n("&Help"), helpMenu );
2224 mIncSearchWidget = new IncSearchWidget( tb ); 2224 mIncSearchWidget = new IncSearchWidget( tb );
2225 // tb->insertWidget(-1, 0, mIncSearchWidget); 2225 // tb->insertWidget(-1, 0, mIncSearchWidget);
2226#ifndef DESKTOP_VERSION 2226#ifndef DESKTOP_VERSION
2227 } else { 2227 } else {
2228 //US setup toolbar 2228 //US setup toolbar
2229 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2229 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2230 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2230 QPopupMenu *popupBarTB = new QPopupMenu( this );
2231 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); 2231 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB);
2232 tb->insertWidget(-1, 0, menuBarTB); 2232 tb->insertWidget(-1, 0, menuBarTB);
2233 mIncSearchWidget = new IncSearchWidget( tb ); 2233 mIncSearchWidget = new IncSearchWidget( tb );
2234 tb->enableMoving(false); 2234 tb->enableMoving(false);
2235 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2235 popupBarTB->insertItem( i18n("&File"), fileMenu );
2236 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2236 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2237 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2237 popupBarTB->insertItem( i18n("&View"), viewMenu );
2238 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2238 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2239 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2239 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2240 mViewManager->getFilterAction()->plug ( popupBarTB); 2240 mViewManager->getFilterAction()->plug ( popupBarTB);
2241 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2241 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2242 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2242 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2243 if (QApplication::desktop()->width() > 320 ) { 2243 if (QApplication::desktop()->width() > 320 ) {
2244 // mViewManager->getFilterAction()->plug ( tb); 2244 // mViewManager->getFilterAction()->plug ( tb);
2245 } 2245 }
2246 } 2246 }
2247#endif 2247#endif
2248 mIncSearchWidget->setSize(); 2248 mIncSearchWidget->setSize();
2249 // mActionQuit->plug ( mMainWindow->toolBar()); 2249 // mActionQuit->plug ( mMainWindow->toolBar());
2250 2250
2251 2251
2252 2252
2253 //US Now connect the actions with the menue entries. 2253 //US Now connect the actions with the menue entries.
2254#ifdef DESKTOP_VERSION 2254#ifdef DESKTOP_VERSION
2255 mActionPrint->plug( fileMenu ); 2255 mActionPrint->plug( fileMenu );
2256 mActionPrintDetails->plug( fileMenu ); 2256 mActionPrintDetails->plug( fileMenu );
2257 fileMenu->insertSeparator(); 2257 fileMenu->insertSeparator();
2258#endif 2258#endif
2259 mActionMail->plug( fileMenu ); 2259 mActionMail->plug( fileMenu );
2260 fileMenu->insertSeparator(); 2260 fileMenu->insertSeparator();
2261 2261
2262 mActionNewContact->plug( editMenu ); 2262 mActionNewContact->plug( editMenu );
2263 mActionNewContact->plug( tb ); 2263 mActionNewContact->plug( tb );
2264 2264
2265 mActionEditAddressee->plug( editMenu ); 2265 mActionEditAddressee->plug( editMenu );
2266 editMenu->insertSeparator(); 2266 editMenu->insertSeparator();
2267 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2267 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2268 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2268 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2269 mActionEditAddressee->plug( tb ); 2269 mActionEditAddressee->plug( tb );
2270 2270
2271 // fileMenu->insertSeparator(); 2271 // fileMenu->insertSeparator();
2272 mActionSave->plug( fileMenu ); 2272 mActionSave->plug( fileMenu );
2273 fileMenu->insertItem( "&Import", ImportMenu ); 2273 fileMenu->insertItem( "&Import", ImportMenu );
2274 fileMenu->insertItem( "&Export", ExportMenu ); 2274 fileMenu->insertItem( "&Export", ExportMenu );
2275 editMenu->insertItem( i18n("&Change"), changeMenu ); 2275 editMenu->insertItem( i18n("&Change"), changeMenu );
2276 editMenu->insertSeparator(); 2276 editMenu->insertSeparator();
2277#ifndef DESKTOP_VERSION 2277#ifndef DESKTOP_VERSION
2278 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2278 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2279#endif 2279#endif
2280#if 0 2280#if 0
2281 // PENDING fix MailVCard 2281 // PENDING fix MailVCard
2282 fileMenu->insertSeparator(); 2282 fileMenu->insertSeparator();
2283 mActionMailVCard->plug( fileMenu ); 2283 mActionMailVCard->plug( fileMenu );
2284#endif 2284#endif
2285#ifndef DESKTOP_VERSION 2285#ifndef DESKTOP_VERSION
2286 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2286 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2287 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2287 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2288 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2288 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2289#endif 2289#endif
2290 fileMenu->insertSeparator(); 2290 fileMenu->insertSeparator();
2291 mActionQuit->plug( fileMenu ); 2291 mActionQuit->plug( fileMenu );
2292#ifdef _OL_IMPORT_ 2292#ifdef _OL_IMPORT_
2293 mActionImportOL->plug( ImportMenu ); 2293 mActionImportOL->plug( ImportMenu );
2294#endif 2294#endif
2295 // edit menu 2295 // edit menu
2296 mActionUndo->plug( editMenu ); 2296 mActionUndo->plug( editMenu );
2297 mActionRedo->plug( editMenu ); 2297 mActionRedo->plug( editMenu );
2298 editMenu->insertSeparator(); 2298 editMenu->insertSeparator();
2299 mActionCut->plug( editMenu ); 2299 mActionCut->plug( editMenu );
2300 mActionCopy->plug( editMenu ); 2300 mActionCopy->plug( editMenu );
2301 mActionPaste->plug( editMenu ); 2301 mActionPaste->plug( editMenu );
2302 mActionDelete->plug( editMenu ); 2302 mActionDelete->plug( editMenu );
2303 editMenu->insertSeparator(); 2303 editMenu->insertSeparator();
2304 mActionSelectAll->plug( editMenu ); 2304 mActionSelectAll->plug( editMenu );
2305 2305
2306 mActionSetFormattedName->plug( changeMenu ); 2306 mActionSetFormattedName->plug( changeMenu );
2307 mActionRemoveVoice->plug( changeMenu ); 2307 mActionRemoveVoice->plug( changeMenu );
2308 // settingsmings menu 2308 // settingsmings menu
2309//US special menuentry to configure the addressbook resources. On KDE 2309//US special menuentry to configure the addressbook resources. On KDE
2310// you do that through the control center !!! 2310// you do that through the control center !!!
2311 // settingsMenu->insertSeparator(); 2311 // settingsMenu->insertSeparator();
2312 2312
2313 mActionConfigKAddressbook->plug( settingsMenu, 0 ); 2313 mActionConfigKAddressbook->plug( settingsMenu, 0 );
2314 mActionConfigGlobal->plug( settingsMenu, 1 ); 2314 mActionConfigGlobal->plug( settingsMenu, 1 );
2315 mActionConfigResources->plug( settingsMenu,2 ); 2315 mActionConfigResources->plug( settingsMenu,2 );
2316 settingsMenu->insertSeparator(3); 2316 settingsMenu->insertSeparator(3);
2317 2317
2318 if ( mIsPart ) { 2318 if ( mIsPart ) {
2319 //US not implemented yet 2319 //US not implemented yet
2320 //mActionConfigShortcuts->plug( settingsMenu ); 2320 //mActionConfigShortcuts->plug( settingsMenu );
2321 //mActionConfigureToolbars->plug( settingsMenu ); 2321 //mActionConfigureToolbars->plug( settingsMenu );
2322 2322
2323 } else { 2323 } else {
@@ -3091,405 +3091,410 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
3091 Addressee inR ;//= er.first(); 3091 Addressee inR ;//= er.first();
3092 Addressee inL; 3092 Addressee inL;
3093 3093
3094 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3094 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3095 3095
3096 int modulo = (er.count()/10)+1; 3096 int modulo = (er.count()/10)+1;
3097 int incCounter = 0; 3097 int incCounter = 0;
3098 while ( incCounter < er.count()) { 3098 while ( incCounter < er.count()) {
3099 if (syncManager->isProgressBarCanceled()) 3099 if (syncManager->isProgressBarCanceled())
3100 return false; 3100 return false;
3101 if ( incCounter % modulo == 0 ) 3101 if ( incCounter % modulo == 0 )
3102 syncManager->showProgressBar(incCounter); 3102 syncManager->showProgressBar(incCounter);
3103 3103
3104 uid = er[ incCounter ]; 3104 uid = er[ incCounter ];
3105 bool skipIncidence = false; 3105 bool skipIncidence = false;
3106 if ( uid.left(19) == QString("last-syncAddressee-") ) 3106 if ( uid.left(19) == QString("last-syncAddressee-") )
3107 skipIncidence = true; 3107 skipIncidence = true;
3108 QString idS,OidS; 3108 QString idS,OidS;
3109 qApp->processEvents(); 3109 qApp->processEvents();
3110 if ( !skipIncidence ) { 3110 if ( !skipIncidence ) {
3111 inL = local->findByUid( uid ); 3111 inL = local->findByUid( uid );
3112 inR = remote->findByUid( uid ); 3112 inR = remote->findByUid( uid );
3113 //inL.setResource( 0 ); 3113 //inL.setResource( 0 );
3114 //inR.setResource( 0 ); 3114 //inR.setResource( 0 );
3115 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 3115 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
3116 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3116 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3117 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 3117 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
3118 //qDebug("take %d %s ", take, inL.summary().latin1()); 3118 //qDebug("take %d %s ", take, inL.summary().latin1());
3119 if ( take == 3 ) 3119 if ( take == 3 )
3120 return false; 3120 return false;
3121 if ( take == 1 ) {// take local ********************** 3121 if ( take == 1 ) {// take local **********************
3122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3123 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3123 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3124 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3124 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3125 local->insertAddressee( inL, false ); 3125 local->insertAddressee( inL, false );
3126 idS = inR.externalUID(); 3126 idS = inR.externalUID();
3127 OidS = inR.originalExternalUID(); 3127 OidS = inR.originalExternalUID();
3128 } 3128 }
3129 else 3129 else
3130 idS = inR.IDStr(); 3130 idS = inR.IDStr();
3131 remote->removeAddressee( inR ); 3131 remote->removeAddressee( inR );
3132 inR = inL; 3132 inR = inL;
3133 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 3133 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
3134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3135 inR.setOriginalExternalUID( OidS ); 3135 inR.setOriginalExternalUID( OidS );
3136 inR.setExternalUID( idS ); 3136 inR.setExternalUID( idS );
3137 if ( syncManager->syncWithDesktop() ) { 3137 if ( syncManager->syncWithDesktop() ) {
3138 inR.setIDStr("changed" ); 3138 inR.setIDStr("changed" );
3139 } 3139 }
3140 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 3140 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
3141 } else { 3141 } else {
3142 inR.setIDStr( idS ); 3142 inR.setIDStr( idS );
3143 } 3143 }
3144 inR.setResource( 0 ); 3144 inR.setResource( 0 );
3145 remote->insertAddressee( inR , false); 3145 remote->insertAddressee( inR , false);
3146 ++changedRemote; 3146 ++changedRemote;
3147 } else { // take == 2 take remote ********************** 3147 } else { // take == 2 take remote **********************
3148 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3148 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3149 if ( inR.revision().date().year() < 2004 ) 3149 if ( inR.revision().date().year() < 2004 )
3150 inR.setRevision( modifiedCalendar ); 3150 inR.setRevision( modifiedCalendar );
3151 } 3151 }
3152 idS = inL.IDStr(); 3152 idS = inL.IDStr();
3153 local->removeAddressee( inL ); 3153 local->removeAddressee( inL );
3154 inL = inR; 3154 inL = inR;
3155 inL.setIDStr( idS ); 3155 inL.setIDStr( idS );
3156 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3156 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3157 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3157 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3158 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3158 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3159 } 3159 }
3160 inL.setResource( 0 ); 3160 inL.setResource( 0 );
3161 local->insertAddressee( inL , false ); 3161 local->insertAddressee( inL , false );
3162 ++changedLocal; 3162 ++changedLocal;
3163 } 3163 }
3164 } 3164 }
3165 } 3165 }
3166 } else { // no conflict ********** add or delete remote 3166 } else { // no conflict ********** add or delete remote
3167 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 3167 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
3168 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3168 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3169 QString des = addresseeLSync.note(); 3169 QString des = addresseeLSync.note();
3170 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 3170 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
3171 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3171 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
3172 remote->insertAddressee( inR, false ); 3172 remote->insertAddressee( inR, false );
3173 ++deletedAddresseeR; 3173 ++deletedAddresseeR;
3174 } else { 3174 } else {
3175 inR.setRevision( modifiedCalendar ); 3175 inR.setRevision( modifiedCalendar );
3176 remote->insertAddressee( inR, false ); 3176 remote->insertAddressee( inR, false );
3177 inL = inR; 3177 inL = inR;
3178 inL.setIDStr( ":" ); 3178 inL.setIDStr( ":" );
3179 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3179 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3180 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3180 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3181 inL.setResource( 0 ); 3181 inL.setResource( 0 );
3182 local->insertAddressee( inL , false); 3182 local->insertAddressee( inL , false);
3183 ++addedAddressee; 3183 ++addedAddressee;
3184 } 3184 }
3185 } else { 3185 } else {
3186 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3186 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3187 inR.setRevision( modifiedCalendar ); 3187 inR.setRevision( modifiedCalendar );
3188 remote->insertAddressee( inR, false ); 3188 remote->insertAddressee( inR, false );
3189 inR.setResource( 0 ); 3189 inR.setResource( 0 );
3190 local->insertAddressee( inR, false ); 3190 local->insertAddressee( inR, false );
3191 ++addedAddressee; 3191 ++addedAddressee;
3192 } else { 3192 } else {
3193 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3193 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3194 remote->removeAddressee( inR ); 3194 remote->removeAddressee( inR );
3195 ++deletedAddresseeR; 3195 ++deletedAddresseeR;
3196 } 3196 }
3197 } 3197 }
3198 } else { 3198 } else {
3199 ++filteredIN; 3199 ++filteredIN;
3200 } 3200 }
3201 } 3201 }
3202 } 3202 }
3203 ++incCounter; 3203 ++incCounter;
3204 } 3204 }
3205 er.clear(); 3205 er.clear();
3206 QStringList el = local->uidList(); 3206 QStringList el = local->uidList();
3207 modulo = (el.count()/10)+1; 3207 modulo = (el.count()/10)+1;
3208 3208
3209 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3209 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3210 incCounter = 0; 3210 incCounter = 0;
3211 while ( incCounter < el.count()) { 3211 while ( incCounter < el.count()) {
3212 qApp->processEvents(); 3212 qApp->processEvents();
3213 if (syncManager->isProgressBarCanceled()) 3213 if (syncManager->isProgressBarCanceled())
3214 return false; 3214 return false;
3215 if ( incCounter % modulo == 0 ) 3215 if ( incCounter % modulo == 0 )
3216 syncManager->showProgressBar(incCounter); 3216 syncManager->showProgressBar(incCounter);
3217 uid = el[ incCounter ]; 3217 uid = el[ incCounter ];
3218 bool skipIncidence = false; 3218 bool skipIncidence = false;
3219 if ( uid.left(19) == QString("last-syncAddressee-") ) 3219 if ( uid.left(19) == QString("last-syncAddressee-") )
3220 skipIncidence = true; 3220 skipIncidence = true;
3221 if ( !skipIncidence ) { 3221 if ( !skipIncidence ) {
3222 inL = local->findByUid( uid ); 3222 inL = local->findByUid( uid );
3223 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3223 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3224 inR = remote->findByUid( uid ); 3224 inR = remote->findByUid( uid );
3225 if ( inR.isEmpty() ){ 3225 if ( inR.isEmpty() ){
3226 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3226 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3227 // no conflict ********** add or delete local 3227 // no conflict ********** add or delete local
3228 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3228 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3229 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3229 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3230 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3230 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3231 local->removeAddressee( inL ); 3231 local->removeAddressee( inL );
3232 ++deletedAddresseeL; 3232 ++deletedAddresseeL;
3233 } else { 3233 } else {
3234 if ( ! syncManager->mWriteBackExistingOnly ) { 3234 if ( ! syncManager->mWriteBackExistingOnly ) {
3235 inL.removeID(mCurrentSyncDevice ); 3235 inL.removeID(mCurrentSyncDevice );
3236 ++addedAddresseeR; 3236 ++addedAddresseeR;
3237 inL.setRevision( modifiedCalendar ); 3237 inL.setRevision( modifiedCalendar );
3238 local->insertAddressee( inL, false ); 3238 local->insertAddressee( inL, false );
3239 inR = inL; 3239 inR = inL;
3240 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3240 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3241 inR.setResource( 0 ); 3241 inR.setResource( 0 );
3242 remote->insertAddressee( inR, false ); 3242 remote->insertAddressee( inR, false );
3243 } 3243 }
3244 } 3244 }
3245 } else { 3245 } else {
3246 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3246 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3247 //qDebug("data %s ", inL.revision().toString().latin1()); 3247 //qDebug("data %s ", inL.revision().toString().latin1());
3248 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3248 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3249 local->removeAddressee( inL ); 3249 local->removeAddressee( inL );
3250 ++deletedAddresseeL; 3250 ++deletedAddresseeL;
3251 } else { 3251 } else {
3252 if ( ! syncManager->mWriteBackExistingOnly ) { 3252 if ( ! syncManager->mWriteBackExistingOnly ) {
3253 ++addedAddresseeR; 3253 ++addedAddresseeR;
3254 inL.setRevision( modifiedCalendar ); 3254 inL.setRevision( modifiedCalendar );
3255 local->insertAddressee( inL, false ); 3255 local->insertAddressee( inL, false );
3256 inR = inL; 3256 inR = inL;
3257 inR.setIDStr( ":" ); 3257 inR.setIDStr( ":" );
3258 inR.setResource( 0 ); 3258 inR.setResource( 0 );
3259 remote->insertAddressee( inR, false ); 3259 remote->insertAddressee( inR, false );
3260 } 3260 }
3261 } 3261 }
3262 } 3262 }
3263 } else { 3263 } else {
3264 ++filteredOUT; 3264 ++filteredOUT;
3265 } 3265 }
3266 } 3266 }
3267 } 3267 }
3268 } 3268 }
3269 ++incCounter; 3269 ++incCounter;
3270 } 3270 }
3271 el.clear(); 3271 el.clear();
3272 syncManager->hideProgressBar(); 3272 syncManager->hideProgressBar();
3273 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3273 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3274 // get rid of micro seconds 3274 // get rid of micro seconds
3275 QTime t = mLastAddressbookSync.time(); 3275 QTime t = mLastAddressbookSync.time();
3276 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3276 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3277 addresseeLSync.setRevision( mLastAddressbookSync ); 3277 addresseeLSync.setRevision( mLastAddressbookSync );
3278 addresseeRSync.setRevision( mLastAddressbookSync ); 3278 addresseeRSync.setRevision( mLastAddressbookSync );
3279 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3279 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3280 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3280 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3281 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3281 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3282 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3282 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3283 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3283 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3284 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3284 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3285 addresseeRSync.setNote( "" ) ; 3285 addresseeRSync.setNote( "" ) ;
3286 addresseeLSync.setNote( "" ); 3286 addresseeLSync.setNote( "" );
3287 3287
3288 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3288 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3289 remote->insertAddressee( addresseeRSync, false ); 3289 remote->insertAddressee( addresseeRSync, false );
3290 local->insertAddressee( addresseeLSync, false ); 3290 local->insertAddressee( addresseeLSync, false );
3291 QString mes; 3291 QString mes;
3292 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3292 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3293 qDebug( mes ); 3293 qDebug( mes );
3294 mes = i18n("Local addressbook changed!\n") +mes; 3294 mes = i18n("Local addressbook changed!\n") +mes;
3295 if ( syncManager->mShowSyncSummary ) { 3295 if ( syncManager->mShowSyncSummary ) {
3296 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3296 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3297 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3297 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3298 qDebug("KA: WB cancelled "); 3298 qDebug("KA: WB cancelled ");
3299 syncManager->mWriteBackFile = false; 3299 syncManager->mWriteBackFile = false;
3300 return syncOK; 3300 return syncOK;
3301 } 3301 }
3302 } 3302 }
3303 return syncOK; 3303 return syncOK;
3304} 3304}
3305 3305
3306 3306
3307//this is a overwritten callbackmethods from the syncinterface 3307//this is a overwritten callbackmethods from the syncinterface
3308bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource) 3308bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource)
3309{ 3309{
3310 3310
3311 //pending prepare addresseeview for output 3311 //pending prepare addresseeview for output
3312 //pending detect, if remote file has REV field. if not switch to external sync 3312 //pending detect, if remote file has REV field. if not switch to external sync
3313 mGlobalSyncMode = SYNC_MODE_NORMAL; 3313 mGlobalSyncMode = SYNC_MODE_NORMAL;
3314 if ( manager != syncManager ) 3314 if ( manager != syncManager )
3315 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3315 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3316 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3316 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3317 3317
3318 AddressBook abLocal(filename,"syncContact"); 3318 AddressBook abLocal(filename,"syncContact");
3319 bool syncOK = false; 3319 bool syncOK = false;
3320 if ( abLocal.load() ) { 3320 if ( abLocal.load() ) {
3321 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); 3321 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3322 bool external = false; 3322 bool external = false;
3323 bool isXML = false; 3323 bool isXML = false;
3324 if ( filename.right(4) == ".xml") { 3324 if ( filename.right(4) == ".xml") {
3325 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3325 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3326 isXML = true; 3326 isXML = true;
3327 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3327 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3328 } else { 3328 } else {
3329 external = !manager->mIsKapiFile; 3329 external = !manager->mIsKapiFile;
3330 if ( external ) { 3330 if ( external ) {
3331 qDebug("KA: Sync::Setting vcf mode to external "); 3331 qDebug("KA: Sync::Setting vcf mode to external ");
3332 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3332 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3333 AddressBook::Iterator it; 3333 AddressBook::Iterator it;
3334 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3334 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3335 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3335 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3336 (*it).computeCsum( mCurrentSyncDevice ); 3336 (*it).computeCsum( mCurrentSyncDevice );
3337 } 3337 }
3338 } 3338 }
3339 } 3339 }
3340 //AddressBook::Iterator it; 3340 //AddressBook::Iterator it;
3341 //QStringList vcards; 3341 //QStringList vcards;
3342 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3342 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3343 // qDebug("Name %s ", (*it).familyName().latin1()); 3343 // qDebug("Name %s ", (*it).familyName().latin1());
3344 //} 3344 //}
3345 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3345 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3346 syncManager->hideProgressBar(); 3346 syncManager->hideProgressBar();
3347 if ( syncOK ) { 3347 if ( syncOK ) {
3348 if ( syncManager->mWriteBackFile ) 3348 if ( syncManager->mWriteBackFile )
3349 { 3349 {
3350 if ( external ) 3350 if ( external )
3351 abLocal.removeSyncAddressees( !isXML); 3351 abLocal.removeSyncAddressees( !isXML);
3352 qDebug("KA: Sync::Saving remote AB "); 3352 qDebug("KA: Sync::Saving remote AB ");
3353 if ( ! abLocal.saveAB()) 3353 if ( ! abLocal.saveAB())
3354 qDebug("KA: sync::Error writing back AB to file "); 3354 qDebug("KA: sync::Error writing back AB to file ");
3355 if ( external ) { 3355 if ( external ) {
3356 // afterwrite processing 3356 // afterwrite processing
3357 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3357 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3358 } 3358 }
3359 } 3359 }
3360 } 3360 }
3361 setModified(); 3361 setModified();
3362 3362
3363 } 3363 }
3364 abLocal.removeResources(); 3364 abLocal.removeResources();
3365 if ( syncOK ) 3365 if ( syncOK )
3366 mViewManager->refreshView(); 3366 mViewManager->refreshView();
3367 return syncOK; 3367 return syncOK;
3368 3368
3369} 3369}
3370void KABCore::removeSyncInfo( QString syncProfile) 3370void KABCore::removeSyncInfo( QString syncProfile)
3371{ 3371{
3372 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3372 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3373 mAddressBook->removeSyncInfo( syncProfile ); 3373 mAddressBook->removeSyncInfo( syncProfile );
3374 setModified(); 3374 setModified();
3375} 3375}
3376 3376
3377 3377
3378//this is a overwritten callbackmethods from the syncinterface 3378//this is a overwritten callbackmethods from the syncinterface
3379bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3379bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3380{ 3380{
3381 if ( resource == "phone" ) 3381 if ( resource == "phone" )
3382 return syncPhone(); 3382 return syncPhone();
3383 disableBR( true ); 3383 disableBR( true );
3384 if ( manager != syncManager ) 3384 if ( manager != syncManager )
3385 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3385 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3386 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3386 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3387 3387
3388 AddressBook abLocal( resource,"syncContact"); 3388 AddressBook abLocal( resource,"syncContact");
3389 bool syncOK = false; 3389 bool syncOK = false;
3390 message(i18n("Loading DTM address data..."), false); 3390 message(i18n("Loading DTM address data..."), false);
3391 if ( abLocal.load() ) { 3391 if ( abLocal.load() ) {
3392 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3392 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3393 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3393 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3394 message(i18n("Sync preprocessing..."),false); 3394 message(i18n("Sync preprocessing..."),false);
3395 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3395 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3396 message(i18n("Synchronizing..."),false); 3396 message(i18n("Synchronizing..."),false);
3397 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3397 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3398 syncManager->hideProgressBar(); 3398 syncManager->hideProgressBar();
3399 if ( syncOK ) { 3399 if ( syncOK ) {
3400 if ( syncManager->mWriteBackFile ) { 3400 if ( syncManager->mWriteBackFile ) {
3401 abLocal.removeSyncAddressees( false ); 3401 abLocal.removeSyncAddressees( false );
3402 message(i18n("Saving DTM address data..."),false); 3402 message(i18n("Saving DTM address data..."),false);
3403 abLocal.saveAB(); 3403 abLocal.saveAB();
3404 message(i18n("Sync postprocessing..."),false); 3404 message(i18n("Sync postprocessing..."),false);
3405 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3405 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3406 } 3406 }
3407 } else 3407 } else
3408 message( i18n("Sync cancelled or failed.") ); 3408 message( i18n("Sync cancelled or failed.") );
3409 setModified(); 3409 setModified();
3410 } 3410 }
3411 abLocal.removeResources(); 3411 abLocal.removeResources();
3412 if ( syncOK ) { 3412 if ( syncOK ) {
3413 mViewManager->refreshView(); 3413 mViewManager->refreshView();
3414 message(i18n("DTM syncing finished.")); 3414 message(i18n("DTM syncing finished."));
3415 } 3415 }
3416 disableBR( false ); 3416 disableBR( false );
3417 return syncOK; 3417 return syncOK;
3418 3418
3419} 3419}
3420void KABCore::message( QString m, bool startTimer) 3420void KABCore::message( QString m, bool startTimer)
3421{ 3421{
3422 topLevelWidget()->setCaption( m ); 3422 topLevelWidget()->setCaption( m );
3423 qApp->processEvents(); 3423 qApp->processEvents();
3424 if ( startTimer ) 3424 if ( startTimer )
3425 mMessageTimer->start( 15000, true ); 3425 mMessageTimer->start( 15000, true );
3426 else 3426 else
3427 mMessageTimer->stop(); 3427 mMessageTimer->stop();
3428} 3428}
3429bool KABCore::syncPhone() 3429bool KABCore::syncPhone()
3430{ 3430{
3431 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3431 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3432 QString fileName = getPhoneFile(); 3432 QString fileName = getPhoneFile();
3433 if ( !PhoneAccess::readFromPhone( fileName) ) { 3433 if ( !PhoneAccess::readFromPhone( fileName) ) {
3434 message(i18n("Phone access failed!")); 3434 message(i18n("Phone access failed!"));
3435 return false; 3435 return false;
3436 } 3436 }
3437 AddressBook abLocal( fileName,"syncContact"); 3437 AddressBook abLocal( fileName,"syncContact");
3438 bool syncOK = false; 3438 bool syncOK = false;
3439 { 3439 {
3440 abLocal.importFromFile( fileName ); 3440 abLocal.importFromFile( fileName );
3441 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3441 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3442 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3442 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3443 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3443 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3444 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3444 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3445 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3445 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3446 syncManager->hideProgressBar(); 3446 syncManager->hideProgressBar();
3447 if ( syncOK ) { 3447 if ( syncOK ) {
3448 if ( syncManager->mWriteBackFile ) { 3448 if ( syncManager->mWriteBackFile ) {
3449 abLocal.removeSyncAddressees( true ); 3449 abLocal.removeSyncAddressees( true );
3450 abLocal.saveABphone( fileName ); 3450 abLocal.saveABphone( fileName );
3451 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3451 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3452 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3452 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3453 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3453 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3454 } 3454 }
3455 } 3455 }
3456 setModified(); 3456 setModified();
3457 } 3457 }
3458 abLocal.removeResources(); 3458 abLocal.removeResources();
3459 if ( syncOK ) 3459 if ( syncOK )
3460 mViewManager->refreshView(); 3460 mViewManager->refreshView();
3461 return syncOK; 3461 return syncOK;
3462} 3462}
3463void KABCore::getFile( bool success ) 3463void KABCore::getFile( bool success )
3464{ 3464{
3465 if ( ! success ) { 3465 if ( ! success ) {
3466 message( i18n("Error receiving file. Nothing changed!") ); 3466 message( i18n("Error receiving file. Nothing changed!") );
3467 return; 3467 return;
3468 } 3468 }
3469 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3469 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3470 if ( count ) 3470 if ( count )
3471 setModified( true ); 3471 setModified( true );
3472 message( i18n("Pi-Sync successful!") ); 3472 message( i18n("Pi-Sync successful!") );
3473 mViewManager->refreshView(); 3473 mViewManager->refreshView();
3474} 3474}
3475void KABCore::syncFileRequest() 3475void KABCore::syncFileRequest(const QString & resource)
3476{ 3476{
3477 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3477 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3478 syncManager->slotSyncMenu( 999 ); 3478 syncManager->slotSyncMenu( 999 );
3479 } 3479 }
3480 mAddressBook->export2File( sentSyncFile() ); 3480
3481 if ( resource == "ALL" ) {
3482 mAddressBook->export2File( sentSyncFile() );
3483 }
3484 else
3485 mAddressBook->export2File( sentSyncFile(), resource);
3481} 3486}
3482QString KABCore::sentSyncFile() 3487QString KABCore::sentSyncFile()
3483{ 3488{
3484#ifdef DESKTOP_VERSION 3489#ifdef DESKTOP_VERSION
3485 return locateLocal( "tmp", "copysyncab.vcf" ); 3490 return locateLocal( "tmp", "copysyncab.vcf" );
3486#else 3491#else
3487 return QString( "/tmp/copysyncab.vcf" ); 3492 return QString( "/tmp/copysyncab.vcf" );
3488#endif 3493#endif
3489} 3494}
3490 3495
3491void KABCore::setCaptionBack() 3496void KABCore::setCaptionBack()
3492{ 3497{
3493 mMessageTimer->stop(); 3498 mMessageTimer->stop();
3494 topLevelWidget()->setCaption( i18n("KA/Pi") ); 3499 topLevelWidget()->setCaption( i18n("KA/Pi") );
3495} 3500}