author | zautrix <zautrix> | 2005-03-29 14:22:53 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-29 14:22:53 (UTC) |
commit | c873163eca527625ce22ed461ee5d4fec61b3b18 (patch) (unidiff) | |
tree | 5d9724d4d1dd26794faae7b102c649eb8375ad36 | |
parent | 7046b36fb5dd14598ece00b575554eba2956ef84 (diff) | |
download | kdepimpi-c873163eca527625ce22ed461ee5d4fec61b3b18.zip kdepimpi-c873163eca527625ce22ed461ee5d4fec61b3b18.tar.gz kdepimpi-c873163eca527625ce22ed461ee5d4fec61b3b18.tar.bz2 |
fix
-rw-r--r-- | kaddressbook/kabcore.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 09d8523..db19dd5 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1743,1537 +1743,1549 @@ void KABCore::initGUI() | |||
1743 | 1743 | ||
1744 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1744 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1745 | 1745 | ||
1746 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1746 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1747 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1747 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1748 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1748 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1749 | SLOT( incrementalSearch( const QString& ) ) ); | 1749 | SLOT( incrementalSearch( const QString& ) ) ); |
1750 | 1750 | ||
1751 | mViewManager = new ViewManager( this, viewSpace ); | 1751 | mViewManager = new ViewManager( this, viewSpace ); |
1752 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1752 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1753 | 1753 | ||
1754 | mDetails = new ViewContainer( mDetailsSplitter ); | 1754 | mDetails = new ViewContainer( mDetailsSplitter ); |
1755 | 1755 | ||
1756 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1756 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1757 | 1757 | ||
1758 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1758 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1759 | 1759 | ||
1760 | topLayout->addWidget( mExtensionBarSplitter ); | 1760 | topLayout->addWidget( mExtensionBarSplitter ); |
1761 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1761 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1762 | topLayout->addWidget( mJumpButtonBar ); | 1762 | topLayout->addWidget( mJumpButtonBar ); |
1763 | //topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1763 | //topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1764 | 1764 | ||
1765 | mXXPortManager = new XXPortManager( this, this ); | 1765 | mXXPortManager = new XXPortManager( this, this ); |
1766 | 1766 | ||
1767 | #else //KAB_EMBEDDED | 1767 | #else //KAB_EMBEDDED |
1768 | //US initialize viewMenu before settingup viewmanager. | 1768 | //US initialize viewMenu before settingup viewmanager. |
1769 | // Viewmanager needs this menu to plugin submenues. | 1769 | // Viewmanager needs this menu to plugin submenues. |
1770 | viewMenu = new QPopupMenu( this ); | 1770 | viewMenu = new QPopupMenu( this ); |
1771 | settingsMenu = new QPopupMenu( this ); | 1771 | settingsMenu = new QPopupMenu( this ); |
1772 | //filterMenu = new QPopupMenu( this ); | 1772 | //filterMenu = new QPopupMenu( this ); |
1773 | ImportMenu = new QPopupMenu( this ); | 1773 | ImportMenu = new QPopupMenu( this ); |
1774 | ExportMenu = new QPopupMenu( this ); | 1774 | ExportMenu = new QPopupMenu( this ); |
1775 | syncMenu = new QPopupMenu( this ); | 1775 | syncMenu = new QPopupMenu( this ); |
1776 | changeMenu= new QPopupMenu( this ); | 1776 | changeMenu= new QPopupMenu( this ); |
1777 | beamMenu= new QPopupMenu( this ); | 1777 | beamMenu= new QPopupMenu( this ); |
1778 | 1778 | ||
1779 | //US since we have no splitter for the embedded system, setup | 1779 | //US since we have no splitter for the embedded system, setup |
1780 | // a layout with two frames. One left and one right. | 1780 | // a layout with two frames. One left and one right. |
1781 | 1781 | ||
1782 | QBoxLayout *topLayout; | 1782 | QBoxLayout *topLayout; |
1783 | 1783 | ||
1784 | // = new QHBoxLayout( this ); | 1784 | // = new QHBoxLayout( this ); |
1785 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1785 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1786 | 1786 | ||
1787 | // QWidget *mainBox = new QWidget( this ); | 1787 | // QWidget *mainBox = new QWidget( this ); |
1788 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1788 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1789 | 1789 | ||
1790 | #ifdef DESKTOP_VERSION | 1790 | #ifdef DESKTOP_VERSION |
1791 | topLayout = new QHBoxLayout( this ); | 1791 | topLayout = new QHBoxLayout( this ); |
1792 | 1792 | ||
1793 | 1793 | ||
1794 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1794 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1795 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1795 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1796 | 1796 | ||
1797 | topLayout->addWidget(mMiniSplitter ); | 1797 | topLayout->addWidget(mMiniSplitter ); |
1798 | 1798 | ||
1799 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1799 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1800 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1800 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1801 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1801 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1802 | mDetails = new ViewContainer( mMiniSplitter ); | 1802 | mDetails = new ViewContainer( mMiniSplitter ); |
1803 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1803 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1804 | #else | 1804 | #else |
1805 | if ( QApplication::desktop()->width() > 480 ) { | 1805 | if ( QApplication::desktop()->width() > 480 ) { |
1806 | topLayout = new QHBoxLayout( this ); | 1806 | topLayout = new QHBoxLayout( this ); |
1807 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1807 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1808 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1808 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1809 | } else { | 1809 | } else { |
1810 | 1810 | ||
1811 | topLayout = new QHBoxLayout( this ); | 1811 | topLayout = new QHBoxLayout( this ); |
1812 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1812 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1813 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1813 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1814 | } | 1814 | } |
1815 | 1815 | ||
1816 | topLayout->addWidget(mMiniSplitter ); | 1816 | topLayout->addWidget(mMiniSplitter ); |
1817 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1817 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1818 | mDetails = new ViewContainer( mMiniSplitter ); | 1818 | mDetails = new ViewContainer( mMiniSplitter ); |
1819 | 1819 | ||
1820 | 1820 | ||
1821 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1821 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1822 | #endif | 1822 | #endif |
1823 | //eh->hide(); | 1823 | //eh->hide(); |
1824 | // topLayout->addWidget(mExtensionManager ); | 1824 | // topLayout->addWidget(mExtensionManager ); |
1825 | 1825 | ||
1826 | 1826 | ||
1827 | /*US | 1827 | /*US |
1828 | #ifndef KAB_NOSPLITTER | 1828 | #ifndef KAB_NOSPLITTER |
1829 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1829 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1830 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1830 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1831 | topLayout->setSpacing( 10 ); | 1831 | topLayout->setSpacing( 10 ); |
1832 | 1832 | ||
1833 | mDetailsSplitter = new QSplitter( this ); | 1833 | mDetailsSplitter = new QSplitter( this ); |
1834 | 1834 | ||
1835 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1835 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1836 | 1836 | ||
1837 | mViewManager = new ViewManager( this, viewSpace ); | 1837 | mViewManager = new ViewManager( this, viewSpace ); |
1838 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1838 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1839 | 1839 | ||
1840 | mDetails = new ViewContainer( mDetailsSplitter ); | 1840 | mDetails = new ViewContainer( mDetailsSplitter ); |
1841 | 1841 | ||
1842 | topLayout->addWidget( mDetailsSplitter ); | 1842 | topLayout->addWidget( mDetailsSplitter ); |
1843 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1843 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1844 | #else //KAB_NOSPLITTER | 1844 | #else //KAB_NOSPLITTER |
1845 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1845 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1846 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1846 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1847 | topLayout->setSpacing( 10 ); | 1847 | topLayout->setSpacing( 10 ); |
1848 | 1848 | ||
1849 | // mDetailsSplitter = new QSplitter( this ); | 1849 | // mDetailsSplitter = new QSplitter( this ); |
1850 | 1850 | ||
1851 | QVBox *viewSpace = new QVBox( this ); | 1851 | QVBox *viewSpace = new QVBox( this ); |
1852 | 1852 | ||
1853 | mViewManager = new ViewManager( this, viewSpace ); | 1853 | mViewManager = new ViewManager( this, viewSpace ); |
1854 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1854 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1855 | 1855 | ||
1856 | mDetails = new ViewContainer( this ); | 1856 | mDetails = new ViewContainer( this ); |
1857 | 1857 | ||
1858 | topLayout->addWidget( viewSpace ); | 1858 | topLayout->addWidget( viewSpace ); |
1859 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1859 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1860 | topLayout->addWidget( mDetails ); | 1860 | topLayout->addWidget( mDetails ); |
1861 | #endif //KAB_NOSPLITTER | 1861 | #endif //KAB_NOSPLITTER |
1862 | */ | 1862 | */ |
1863 | 1863 | ||
1864 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1864 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1865 | syncManager->setBlockSave(false); | 1865 | syncManager->setBlockSave(false); |
1866 | 1866 | ||
1867 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1867 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1868 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1868 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1869 | QString sync_file = sentSyncFile(); | 1869 | QString sync_file = sentSyncFile(); |
1870 | //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); | 1870 | //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); |
1871 | syncManager->setDefaultFileName( sync_file ); | 1871 | syncManager->setDefaultFileName( sync_file ); |
1872 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1872 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1873 | 1873 | ||
1874 | #endif //KAB_EMBEDDED | 1874 | #endif //KAB_EMBEDDED |
1875 | initActions(); | 1875 | initActions(); |
1876 | 1876 | ||
1877 | #ifdef KAB_EMBEDDED | 1877 | #ifdef KAB_EMBEDDED |
1878 | addActionsManually(); | 1878 | addActionsManually(); |
1879 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1879 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1880 | mXXPortManager = new XXPortManager( this, this ); | 1880 | mXXPortManager = new XXPortManager( this, this ); |
1881 | 1881 | ||
1882 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1882 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1883 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1883 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1884 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1884 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1885 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1885 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1886 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1886 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1887 | // mIncSearchWidget->hide(); | 1887 | // mIncSearchWidget->hide(); |
1888 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1888 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1889 | SLOT( incrementalSearch( const QString& ) ) ); | 1889 | SLOT( incrementalSearch( const QString& ) ) ); |
1890 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1890 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1891 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1891 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1892 | 1892 | ||
1893 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1893 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1894 | 1894 | ||
1895 | topLayout->addWidget( mJumpButtonBar ); | 1895 | topLayout->addWidget( mJumpButtonBar ); |
1896 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1896 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1897 | 1897 | ||
1898 | // mMainWindow->getIconToolBar()->raise(); | 1898 | // mMainWindow->getIconToolBar()->raise(); |
1899 | 1899 | ||
1900 | #endif //KAB_EMBEDDED | 1900 | #endif //KAB_EMBEDDED |
1901 | 1901 | ||
1902 | } | 1902 | } |
1903 | void KABCore::initActions() | 1903 | void KABCore::initActions() |
1904 | { | 1904 | { |
1905 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1905 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1906 | 1906 | ||
1907 | #ifndef KAB_EMBEDDED | 1907 | #ifndef KAB_EMBEDDED |
1908 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1908 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1909 | SLOT( clipboardDataChanged() ) ); | 1909 | SLOT( clipboardDataChanged() ) ); |
1910 | #endif //KAB_EMBEDDED | 1910 | #endif //KAB_EMBEDDED |
1911 | 1911 | ||
1912 | // file menu | 1912 | // file menu |
1913 | 1913 | ||
1914 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1914 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1915 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1915 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1916 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, | 1916 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, |
1917 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); | 1917 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); |
1918 | 1918 | ||
1919 | 1919 | ||
1920 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, | 1920 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, |
1921 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); | 1921 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); |
1922 | 1922 | ||
1923 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1923 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1924 | SLOT( save() ), actionCollection(), "file_sync" ); | 1924 | SLOT( save() ), actionCollection(), "file_sync" ); |
1925 | 1925 | ||
1926 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1926 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1927 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1927 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1928 | 1928 | ||
1929 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1929 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1930 | this, SLOT( mailVCard() ), | 1930 | this, SLOT( mailVCard() ), |
1931 | actionCollection(), "file_mail_vcard"); | 1931 | actionCollection(), "file_mail_vcard"); |
1932 | 1932 | ||
1933 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, | 1933 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, |
1934 | SLOT( export2phone() ), actionCollection(), | 1934 | SLOT( export2phone() ), actionCollection(), |
1935 | "kaddressbook_ex2phone" ); | 1935 | "kaddressbook_ex2phone" ); |
1936 | 1936 | ||
1937 | mActionBeamVCard = 0; | 1937 | mActionBeamVCard = 0; |
1938 | mActionBeam = 0; | 1938 | mActionBeam = 0; |
1939 | 1939 | ||
1940 | #ifndef DESKTOP_VERSION | 1940 | #ifndef DESKTOP_VERSION |
1941 | if ( Ir::supported() ) { | 1941 | if ( Ir::supported() ) { |
1942 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, | 1942 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, |
1943 | SLOT( beamVCard() ), actionCollection(), | 1943 | SLOT( beamVCard() ), actionCollection(), |
1944 | "kaddressbook_beam_vcard" ); | 1944 | "kaddressbook_beam_vcard" ); |
1945 | 1945 | ||
1946 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1946 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1947 | SLOT( beamMySelf() ), actionCollection(), | 1947 | SLOT( beamMySelf() ), actionCollection(), |
1948 | "kaddressbook_beam_myself" ); | 1948 | "kaddressbook_beam_myself" ); |
1949 | } | 1949 | } |
1950 | #endif | 1950 | #endif |
1951 | 1951 | ||
1952 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1952 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1953 | this, SLOT( editContact2() ), | 1953 | this, SLOT( editContact2() ), |
1954 | actionCollection(), "file_properties" ); | 1954 | actionCollection(), "file_properties" ); |
1955 | 1955 | ||
1956 | #ifdef KAB_EMBEDDED | 1956 | #ifdef KAB_EMBEDDED |
1957 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1957 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1958 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1958 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1959 | mMainWindow, SLOT( exit() ), | 1959 | mMainWindow, SLOT( exit() ), |
1960 | actionCollection(), "quit" ); | 1960 | actionCollection(), "quit" ); |
1961 | #endif //KAB_EMBEDDED | 1961 | #endif //KAB_EMBEDDED |
1962 | 1962 | ||
1963 | // edit menu | 1963 | // edit menu |
1964 | if ( mIsPart ) { | 1964 | if ( mIsPart ) { |
1965 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1965 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1966 | SLOT( copyContacts() ), actionCollection(), | 1966 | SLOT( copyContacts() ), actionCollection(), |
1967 | "kaddressbook_copy" ); | 1967 | "kaddressbook_copy" ); |
1968 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1968 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1969 | SLOT( cutContacts() ), actionCollection(), | 1969 | SLOT( cutContacts() ), actionCollection(), |
1970 | "kaddressbook_cut" ); | 1970 | "kaddressbook_cut" ); |
1971 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1971 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1972 | SLOT( pasteContacts() ), actionCollection(), | 1972 | SLOT( pasteContacts() ), actionCollection(), |
1973 | "kaddressbook_paste" ); | 1973 | "kaddressbook_paste" ); |
1974 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1974 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1975 | SLOT( selectAllContacts() ), actionCollection(), | 1975 | SLOT( selectAllContacts() ), actionCollection(), |
1976 | "kaddressbook_select_all" ); | 1976 | "kaddressbook_select_all" ); |
1977 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1977 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1978 | SLOT( undo() ), actionCollection(), | 1978 | SLOT( undo() ), actionCollection(), |
1979 | "kaddressbook_undo" ); | 1979 | "kaddressbook_undo" ); |
1980 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1980 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1981 | this, SLOT( redo() ), actionCollection(), | 1981 | this, SLOT( redo() ), actionCollection(), |
1982 | "kaddressbook_redo" ); | 1982 | "kaddressbook_redo" ); |
1983 | } else { | 1983 | } else { |
1984 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1984 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1985 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1985 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1986 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1986 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1987 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1987 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1988 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1988 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1989 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1989 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1990 | } | 1990 | } |
1991 | 1991 | ||
1992 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1992 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1993 | Key_Delete, this, SLOT( deleteContacts() ), | 1993 | Key_Delete, this, SLOT( deleteContacts() ), |
1994 | actionCollection(), "edit_delete" ); | 1994 | actionCollection(), "edit_delete" ); |
1995 | 1995 | ||
1996 | mActionUndo->setEnabled( false ); | 1996 | mActionUndo->setEnabled( false ); |
1997 | mActionRedo->setEnabled( false ); | 1997 | mActionRedo->setEnabled( false ); |
1998 | 1998 | ||
1999 | // settings menu | 1999 | // settings menu |
2000 | #ifdef KAB_EMBEDDED | 2000 | #ifdef KAB_EMBEDDED |
2001 | //US special menuentry to configure the addressbook resources. On KDE | 2001 | //US special menuentry to configure the addressbook resources. On KDE |
2002 | // you do that through the control center !!! | 2002 | // you do that through the control center !!! |
2003 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 2003 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
2004 | SLOT( configureResources() ), actionCollection(), | 2004 | SLOT( configureResources() ), actionCollection(), |
2005 | "kaddressbook_configure_resources" ); | 2005 | "kaddressbook_configure_resources" ); |
2006 | #endif //KAB_EMBEDDED | 2006 | #endif //KAB_EMBEDDED |
2007 | 2007 | ||
2008 | if ( mIsPart ) { | 2008 | if ( mIsPart ) { |
2009 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 2009 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
2010 | SLOT( openConfigDialog() ), actionCollection(), | 2010 | SLOT( openConfigDialog() ), actionCollection(), |
2011 | "kaddressbook_configure" ); | 2011 | "kaddressbook_configure" ); |
2012 | 2012 | ||
2013 | //US not implemented yet | 2013 | //US not implemented yet |
2014 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 2014 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
2015 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 2015 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
2016 | // "kaddressbook_configure_shortcuts" ); | 2016 | // "kaddressbook_configure_shortcuts" ); |
2017 | #ifdef KAB_EMBEDDED | 2017 | #ifdef KAB_EMBEDDED |
2018 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 2018 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
2019 | mActionConfigureToolbars->setEnabled( false ); | 2019 | mActionConfigureToolbars->setEnabled( false ); |
2020 | #endif //KAB_EMBEDDED | 2020 | #endif //KAB_EMBEDDED |
2021 | 2021 | ||
2022 | } else { | 2022 | } else { |
2023 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 2023 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
2024 | 2024 | ||
2025 | //US not implemented yet | 2025 | //US not implemented yet |
2026 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 2026 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
2027 | } | 2027 | } |
2028 | 2028 | ||
2029 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 2029 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
2030 | actionCollection(), "options_show_jump_bar" ); | 2030 | actionCollection(), "options_show_jump_bar" ); |
2031 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); | 2031 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); |
2032 | 2032 | ||
2033 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 2033 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
2034 | actionCollection(), "options_show_details" ); | 2034 | actionCollection(), "options_show_details" ); |
2035 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 2035 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
2036 | 2036 | ||
2037 | 2037 | ||
2038 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 2038 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
2039 | SLOT( toggleBeamReceive() ), actionCollection(), | 2039 | SLOT( toggleBeamReceive() ), actionCollection(), |
2040 | "kaddressbook_beam_rec" ); | 2040 | "kaddressbook_beam_rec" ); |
2041 | 2041 | ||
2042 | 2042 | ||
2043 | // misc | 2043 | // misc |
2044 | // only enable LDAP lookup if we can handle the protocol | 2044 | // only enable LDAP lookup if we can handle the protocol |
2045 | #ifndef KAB_EMBEDDED | 2045 | #ifndef KAB_EMBEDDED |
2046 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 2046 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
2047 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 2047 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
2048 | this, SLOT( openLDAPDialog() ), actionCollection(), | 2048 | this, SLOT( openLDAPDialog() ), actionCollection(), |
2049 | "ldap_lookup" ); | 2049 | "ldap_lookup" ); |
2050 | } | 2050 | } |
2051 | #else //KAB_EMBEDDED | 2051 | #else //KAB_EMBEDDED |
2052 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 2052 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
2053 | #endif //KAB_EMBEDDED | 2053 | #endif //KAB_EMBEDDED |
2054 | 2054 | ||
2055 | 2055 | ||
2056 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 2056 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
2057 | SLOT( setWhoAmI() ), actionCollection(), | 2057 | SLOT( setWhoAmI() ), actionCollection(), |
2058 | "set_personal" ); | 2058 | "set_personal" ); |
2059 | 2059 | ||
2060 | 2060 | ||
2061 | mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, | 2061 | mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, |
2062 | SLOT( setCategories() ), actionCollection(), | 2062 | SLOT( setCategories() ), actionCollection(), |
2063 | "edit_set_categories" ); | 2063 | "edit_set_categories" ); |
2064 | mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, | 2064 | mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, |
2065 | SLOT( editCategories() ), actionCollection(), | 2065 | SLOT( editCategories() ), actionCollection(), |
2066 | "edit__categories" ); | 2066 | "edit__categories" ); |
2067 | 2067 | ||
2068 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 2068 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
2069 | SLOT( removeVoice() ), actionCollection(), | 2069 | SLOT( removeVoice() ), actionCollection(), |
2070 | "remove_voice" ); | 2070 | "remove_voice" ); |
2071 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, | 2071 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, |
2072 | SLOT( setFormattedName() ), actionCollection(), | 2072 | SLOT( setFormattedName() ), actionCollection(), |
2073 | "set_formatted" ); | 2073 | "set_formatted" ); |
2074 | 2074 | ||
2075 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 2075 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
2076 | SLOT( manageCategories() ), actionCollection(), | 2076 | SLOT( manageCategories() ), actionCollection(), |
2077 | "remove_voice" ); | 2077 | "remove_voice" ); |
2078 | 2078 | ||
2079 | 2079 | ||
2080 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 2080 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
2081 | SLOT( importFromOL() ), actionCollection(), | 2081 | SLOT( importFromOL() ), actionCollection(), |
2082 | "import_OL" ); | 2082 | "import_OL" ); |
2083 | #ifdef KAB_EMBEDDED | 2083 | #ifdef KAB_EMBEDDED |
2084 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 2084 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
2085 | this, SLOT( showLicence() ), actionCollection(), | 2085 | this, SLOT( showLicence() ), actionCollection(), |
2086 | "licence_about_data" ); | 2086 | "licence_about_data" ); |
2087 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 2087 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
2088 | this, SLOT( faq() ), actionCollection(), | 2088 | this, SLOT( faq() ), actionCollection(), |
2089 | "faq_about_data" ); | 2089 | "faq_about_data" ); |
2090 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 2090 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
2091 | this, SLOT( whatsnew() ), actionCollection(), | 2091 | this, SLOT( whatsnew() ), actionCollection(), |
2092 | "wn" ); | 2092 | "wn" ); |
2093 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2093 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2094 | this, SLOT( synchowto() ), actionCollection(), | 2094 | this, SLOT( synchowto() ), actionCollection(), |
2095 | "sync" ); | 2095 | "sync" ); |
2096 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2096 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2097 | this, SLOT( kdesynchowto() ), actionCollection(), | 2097 | this, SLOT( kdesynchowto() ), actionCollection(), |
2098 | "kdesync" ); | 2098 | "kdesync" ); |
2099 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2099 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2100 | this, SLOT( multisynchowto() ), actionCollection(), | 2100 | this, SLOT( multisynchowto() ), actionCollection(), |
2101 | "multisync" ); | 2101 | "multisync" ); |
2102 | 2102 | ||
2103 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2103 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2104 | this, SLOT( createAboutData() ), actionCollection(), | 2104 | this, SLOT( createAboutData() ), actionCollection(), |
2105 | "kaddressbook_about_data" ); | 2105 | "kaddressbook_about_data" ); |
2106 | #endif //KAB_EMBEDDED | 2106 | #endif //KAB_EMBEDDED |
2107 | 2107 | ||
2108 | clipboardDataChanged(); | 2108 | clipboardDataChanged(); |
2109 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2109 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2110 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2110 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2111 | } | 2111 | } |
2112 | 2112 | ||
2113 | //US we need this function, to plug all actions into the correct menues. | 2113 | //US we need this function, to plug all actions into the correct menues. |
2114 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2114 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2115 | void KABCore::addActionsManually() | 2115 | void KABCore::addActionsManually() |
2116 | { | 2116 | { |
2117 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2117 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
2118 | 2118 | ||
2119 | #ifdef KAB_EMBEDDED | 2119 | #ifdef KAB_EMBEDDED |
2120 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 2120 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
2121 | QPopupMenu *editMenu = new QPopupMenu( this ); | 2121 | QPopupMenu *editMenu = new QPopupMenu( this ); |
2122 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 2122 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
2123 | 2123 | ||
2124 | KToolBar* tb = mMainWindow->toolBar(); | 2124 | KToolBar* tb = mMainWindow->toolBar(); |
2125 | 2125 | ||
2126 | #ifndef DESKTOP_VERSION | 2126 | #ifndef DESKTOP_VERSION |
2127 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 2127 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
2128 | #endif | 2128 | #endif |
2129 | QMenuBar* mb = mMainWindow->menuBar(); | 2129 | QMenuBar* mb = mMainWindow->menuBar(); |
2130 | 2130 | ||
2131 | //US setup menubar. | 2131 | //US setup menubar. |
2132 | //Disable the following block if you do not want to have a menubar. | 2132 | //Disable the following block if you do not want to have a menubar. |
2133 | mb->insertItem( i18n("&File"), fileMenu ); | 2133 | mb->insertItem( i18n("&File"), fileMenu ); |
2134 | mb->insertItem( i18n("&Edit"), editMenu ); | 2134 | mb->insertItem( i18n("&Edit"), editMenu ); |
2135 | mb->insertItem( i18n("&View"), viewMenu ); | 2135 | mb->insertItem( i18n("&View"), viewMenu ); |
2136 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2136 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2137 | #ifdef DESKTOP_VERSION | 2137 | #ifdef DESKTOP_VERSION |
2138 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2138 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2139 | #else | 2139 | #else |
2140 | mb->insertItem( i18n("Sync"), syncMenu ); | 2140 | mb->insertItem( i18n("Sync"), syncMenu ); |
2141 | #endif | 2141 | #endif |
2142 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2142 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2143 | mb->insertItem( i18n("&Help"), helpMenu ); | 2143 | mb->insertItem( i18n("&Help"), helpMenu ); |
2144 | mIncSearchWidget = new IncSearchWidget( tb ); | 2144 | mIncSearchWidget = new IncSearchWidget( tb ); |
2145 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2145 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2146 | #ifndef DESKTOP_VERSION | 2146 | #ifndef DESKTOP_VERSION |
2147 | } else { | 2147 | } else { |
2148 | //US setup toolbar | 2148 | //US setup toolbar |
2149 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2149 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2150 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2150 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2151 | menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); | 2151 | menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); |
2152 | tb->insertWidget(-1, 0, menuBarTB); | 2152 | tb->insertWidget(-1, 0, menuBarTB); |
2153 | mIncSearchWidget = new IncSearchWidget( tb ); | 2153 | mIncSearchWidget = new IncSearchWidget( tb ); |
2154 | tb->enableMoving(false); | 2154 | tb->enableMoving(false); |
2155 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2155 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2156 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2156 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2157 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2157 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2158 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2158 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2159 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2159 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2160 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2160 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2161 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2161 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2162 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2162 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2163 | if (QApplication::desktop()->width() > 320 ) { | 2163 | if (QApplication::desktop()->width() > 320 ) { |
2164 | // mViewManager->getFilterAction()->plug ( tb); | 2164 | // mViewManager->getFilterAction()->plug ( tb); |
2165 | } | 2165 | } |
2166 | } | 2166 | } |
2167 | #endif | 2167 | #endif |
2168 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2168 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2169 | 2169 | ||
2170 | 2170 | ||
2171 | 2171 | ||
2172 | //US Now connect the actions with the menue entries. | 2172 | //US Now connect the actions with the menue entries. |
2173 | #ifdef DESKTOP_VERSION | 2173 | #ifdef DESKTOP_VERSION |
2174 | mActionPrint->plug( fileMenu ); | 2174 | mActionPrint->plug( fileMenu ); |
2175 | mActionPrintDetails->plug( fileMenu ); | 2175 | mActionPrintDetails->plug( fileMenu ); |
2176 | fileMenu->insertSeparator(); | 2176 | fileMenu->insertSeparator(); |
2177 | #endif | 2177 | #endif |
2178 | mActionMail->plug( fileMenu ); | 2178 | mActionMail->plug( fileMenu ); |
2179 | fileMenu->insertSeparator(); | 2179 | fileMenu->insertSeparator(); |
2180 | 2180 | ||
2181 | mActionNewContact->plug( fileMenu ); | 2181 | mActionNewContact->plug( fileMenu ); |
2182 | mActionNewContact->plug( tb ); | 2182 | mActionNewContact->plug( tb ); |
2183 | 2183 | ||
2184 | mActionEditAddressee->plug( fileMenu ); | 2184 | mActionEditAddressee->plug( fileMenu ); |
2185 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2185 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2186 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2186 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2187 | mActionEditAddressee->plug( tb ); | 2187 | mActionEditAddressee->plug( tb ); |
2188 | 2188 | ||
2189 | fileMenu->insertSeparator(); | 2189 | fileMenu->insertSeparator(); |
2190 | mActionSave->plug( fileMenu ); | 2190 | mActionSave->plug( fileMenu ); |
2191 | fileMenu->insertItem( "&Import", ImportMenu ); | 2191 | fileMenu->insertItem( "&Import", ImportMenu ); |
2192 | fileMenu->insertItem( "&Export", ExportMenu ); | 2192 | fileMenu->insertItem( "&Export", ExportMenu ); |
2193 | fileMenu->insertItem( i18n("&Change"), changeMenu ); | 2193 | fileMenu->insertItem( i18n("&Change"), changeMenu ); |
2194 | #ifndef DESKTOP_VERSION | 2194 | #ifndef DESKTOP_VERSION |
2195 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2195 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2196 | #endif | 2196 | #endif |
2197 | #if 0 | 2197 | #if 0 |
2198 | // PENDING fix MailVCard | 2198 | // PENDING fix MailVCard |
2199 | fileMenu->insertSeparator(); | 2199 | fileMenu->insertSeparator(); |
2200 | mActionMailVCard->plug( fileMenu ); | 2200 | mActionMailVCard->plug( fileMenu ); |
2201 | #endif | 2201 | #endif |
2202 | #ifndef DESKTOP_VERSION | 2202 | #ifndef DESKTOP_VERSION |
2203 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2203 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2204 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2204 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2205 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2205 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2206 | #endif | 2206 | #endif |
2207 | fileMenu->insertSeparator(); | 2207 | fileMenu->insertSeparator(); |
2208 | mActionQuit->plug( fileMenu ); | 2208 | mActionQuit->plug( fileMenu ); |
2209 | #ifdef _OL_IMPORT_ | 2209 | #ifdef _OL_IMPORT_ |
2210 | mActionImportOL->plug( ImportMenu ); | 2210 | mActionImportOL->plug( ImportMenu ); |
2211 | #endif | 2211 | #endif |
2212 | // edit menu | 2212 | // edit menu |
2213 | mActionUndo->plug( editMenu ); | 2213 | mActionUndo->plug( editMenu ); |
2214 | mActionRedo->plug( editMenu ); | 2214 | mActionRedo->plug( editMenu ); |
2215 | editMenu->insertSeparator(); | 2215 | editMenu->insertSeparator(); |
2216 | mActionCut->plug( editMenu ); | 2216 | mActionCut->plug( editMenu ); |
2217 | mActionCopy->plug( editMenu ); | 2217 | mActionCopy->plug( editMenu ); |
2218 | mActionPaste->plug( editMenu ); | 2218 | mActionPaste->plug( editMenu ); |
2219 | mActionDelete->plug( editMenu ); | 2219 | mActionDelete->plug( editMenu ); |
2220 | editMenu->insertSeparator(); | 2220 | editMenu->insertSeparator(); |
2221 | mActionSelectAll->plug( editMenu ); | 2221 | mActionSelectAll->plug( editMenu ); |
2222 | 2222 | ||
2223 | mActionSetFormattedName->plug( changeMenu ); | 2223 | mActionSetFormattedName->plug( changeMenu ); |
2224 | mActionRemoveVoice->plug( changeMenu ); | 2224 | mActionRemoveVoice->plug( changeMenu ); |
2225 | // settingsmings menu | 2225 | // settingsmings menu |
2226 | //US special menuentry to configure the addressbook resources. On KDE | 2226 | //US special menuentry to configure the addressbook resources. On KDE |
2227 | // you do that through the control center !!! | 2227 | // you do that through the control center !!! |
2228 | // settingsMenu->insertSeparator(); | 2228 | // settingsMenu->insertSeparator(); |
2229 | 2229 | ||
2230 | mActionConfigKAddressbook->plug( settingsMenu, 0 ); | 2230 | mActionConfigKAddressbook->plug( settingsMenu, 0 ); |
2231 | mActionConfigResources->plug( settingsMenu,1 ); | 2231 | mActionConfigResources->plug( settingsMenu,1 ); |
2232 | settingsMenu->insertSeparator(2); | 2232 | settingsMenu->insertSeparator(2); |
2233 | 2233 | ||
2234 | if ( mIsPart ) { | 2234 | if ( mIsPart ) { |
2235 | //US not implemented yet | 2235 | //US not implemented yet |
2236 | //mActionConfigShortcuts->plug( settingsMenu ); | 2236 | //mActionConfigShortcuts->plug( settingsMenu ); |
2237 | //mActionConfigureToolbars->plug( settingsMenu ); | 2237 | //mActionConfigureToolbars->plug( settingsMenu ); |
2238 | 2238 | ||
2239 | } else { | 2239 | } else { |
2240 | //US not implemented yet | 2240 | //US not implemented yet |
2241 | //mActionKeyBindings->plug( settingsMenu ); | 2241 | //mActionKeyBindings->plug( settingsMenu ); |
2242 | } | 2242 | } |
2243 | 2243 | ||
2244 | settingsMenu->insertSeparator(); | 2244 | settingsMenu->insertSeparator(); |
2245 | 2245 | ||
2246 | mActionJumpBar->plug( settingsMenu ); | 2246 | mActionJumpBar->plug( settingsMenu ); |
2247 | mActionDetails->plug( settingsMenu ); | 2247 | mActionDetails->plug( settingsMenu ); |
2248 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2248 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2249 | mActionDetails->plug( tb ); | 2249 | mActionDetails->plug( tb ); |
2250 | settingsMenu->insertSeparator(); | 2250 | settingsMenu->insertSeparator(); |
2251 | #ifndef DESKTOP_VERSION | 2251 | #ifndef DESKTOP_VERSION |
2252 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2252 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2253 | settingsMenu->insertSeparator(); | 2253 | settingsMenu->insertSeparator(); |
2254 | #endif | 2254 | #endif |
2255 | 2255 | ||
2256 | mActionWhoAmI->plug( settingsMenu ); | 2256 | mActionWhoAmI->plug( settingsMenu ); |
2257 | mActionEditCategories->plug( settingsMenu ); | 2257 | mActionEditCategories->plug( settingsMenu ); |
2258 | mActionEditCategories->plug( changeMenu ); | 2258 | mActionEditCategories->plug( changeMenu ); |
2259 | mActionCategories->plug( changeMenu ); | 2259 | mActionCategories->plug( changeMenu ); |
2260 | mActionManageCategories->plug( changeMenu ); | 2260 | mActionManageCategories->plug( changeMenu ); |
2261 | 2261 | ||
2262 | mActionCategories->plug( settingsMenu ); | 2262 | mActionCategories->plug( settingsMenu ); |
2263 | mActionManageCategories->plug( settingsMenu ); | 2263 | mActionManageCategories->plug( settingsMenu ); |
2264 | 2264 | ||
2265 | 2265 | ||
2266 | mActionWN->plug( helpMenu ); | 2266 | mActionWN->plug( helpMenu ); |
2267 | mActionSyncHowto->plug( helpMenu ); | 2267 | mActionSyncHowto->plug( helpMenu ); |
2268 | mActionKdeSyncHowto->plug( helpMenu ); | 2268 | mActionKdeSyncHowto->plug( helpMenu ); |
2269 | mActionMultiSyncHowto->plug( helpMenu ); | 2269 | mActionMultiSyncHowto->plug( helpMenu ); |
2270 | mActionFaq->plug( helpMenu ); | 2270 | mActionFaq->plug( helpMenu ); |
2271 | mActionLicence->plug( helpMenu ); | 2271 | mActionLicence->plug( helpMenu ); |
2272 | mActionAboutKAddressbook->plug( helpMenu ); | 2272 | mActionAboutKAddressbook->plug( helpMenu ); |
2273 | 2273 | ||
2274 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2274 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2275 | 2275 | ||
2276 | mActionSave->plug( tb ); | 2276 | mActionSave->plug( tb ); |
2277 | mViewManager->getFilterAction()->plug ( tb); | 2277 | mViewManager->getFilterAction()->plug ( tb); |
2278 | //LR hide filteraction on started in 480x640 | 2278 | //LR hide filteraction on started in 480x640 |
2279 | if (QApplication::desktop()->width() == 480 ) { | 2279 | if (QApplication::desktop()->width() == 480 ) { |
2280 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 2280 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2281 | } | 2281 | } |
2282 | mActionUndo->plug( tb ); | 2282 | mActionUndo->plug( tb ); |
2283 | mActionDelete->plug( tb ); | 2283 | mActionDelete->plug( tb ); |
2284 | mActionRedo->plug( tb ); | 2284 | mActionRedo->plug( tb ); |
2285 | } else { | 2285 | } else { |
2286 | mActionSave->plug( tb ); | 2286 | mActionSave->plug( tb ); |
2287 | tb->enableMoving(false); | 2287 | tb->enableMoving(false); |
2288 | } | 2288 | } |
2289 | //mActionQuit->plug ( tb ); | 2289 | //mActionQuit->plug ( tb ); |
2290 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2290 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2291 | 2291 | ||
2292 | //US link the searchwidget first to this. | 2292 | //US link the searchwidget first to this. |
2293 | // The real linkage to the toolbar happens later. | 2293 | // The real linkage to the toolbar happens later. |
2294 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2294 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2295 | //US tb->insertItem( mIncSearchWidget ); | 2295 | //US tb->insertItem( mIncSearchWidget ); |
2296 | /*US | 2296 | /*US |
2297 | mIncSearchWidget = new IncSearchWidget( tb ); | 2297 | mIncSearchWidget = new IncSearchWidget( tb ); |
2298 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2298 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2299 | SLOT( incrementalSearch( const QString& ) ) ); | 2299 | SLOT( incrementalSearch( const QString& ) ) ); |
2300 | 2300 | ||
2301 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2301 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2302 | 2302 | ||
2303 | //US topLayout->addWidget( mJumpButtonBar ); | 2303 | //US topLayout->addWidget( mJumpButtonBar ); |
2304 | this->layout()->add( mJumpButtonBar ); | 2304 | this->layout()->add( mJumpButtonBar ); |
2305 | */ | 2305 | */ |
2306 | 2306 | ||
2307 | #endif //KAB_EMBEDDED | 2307 | #endif //KAB_EMBEDDED |
2308 | 2308 | ||
2309 | mActionExport2phone->plug( ExportMenu ); | 2309 | mActionExport2phone->plug( ExportMenu ); |
2310 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2310 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2311 | syncManager->fillSyncMenu(); | 2311 | syncManager->fillSyncMenu(); |
2312 | 2312 | ||
2313 | } | 2313 | } |
2314 | void KABCore::showLicence() | 2314 | void KABCore::showLicence() |
2315 | { | 2315 | { |
2316 | KApplication::showLicence(); | 2316 | KApplication::showLicence(); |
2317 | } | 2317 | } |
2318 | 2318 | ||
2319 | void KABCore::manageCategories( ) | 2319 | void KABCore::manageCategories( ) |
2320 | { | 2320 | { |
2321 | KABCatPrefs* cp = new KABCatPrefs(); | 2321 | KABCatPrefs* cp = new KABCatPrefs(); |
2322 | cp->show(); | 2322 | cp->show(); |
2323 | int w =cp->sizeHint().width() ; | 2323 | int w =cp->sizeHint().width() ; |
2324 | int h = cp->sizeHint().height() ; | 2324 | int h = cp->sizeHint().height() ; |
2325 | int dw = QApplication::desktop()->width(); | 2325 | int dw = QApplication::desktop()->width(); |
2326 | int dh = QApplication::desktop()->height(); | 2326 | int dh = QApplication::desktop()->height(); |
2327 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2327 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2328 | if ( !cp->exec() ) { | 2328 | if ( !cp->exec() ) { |
2329 | delete cp; | 2329 | delete cp; |
2330 | return; | 2330 | return; |
2331 | } | 2331 | } |
2332 | int count = 0; | 2332 | int count = 0; |
2333 | int cc = 0; | 2333 | int cc = 0; |
2334 | message( i18n("Please wait, processing categories...")); | 2334 | message( i18n("Please wait, processing categories...")); |
2335 | if ( cp->addCat() ) { | 2335 | if ( cp->addCat() ) { |
2336 | KABC::AddressBook::Iterator it; | 2336 | KABC::AddressBook::Iterator it; |
2337 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2337 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2338 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2338 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2339 | ++cc; | 2339 | ++cc; |
2340 | if ( cc %10 == 0) | 2340 | if ( cc %10 == 0) |
2341 | message(i18n("Processing contact #%1").arg(cc)); | 2341 | message(i18n("Processing contact #%1").arg(cc)); |
2342 | QStringList catIncList = (*it).categories(); | 2342 | QStringList catIncList = (*it).categories(); |
2343 | int i; | 2343 | int i; |
2344 | for( i = 0; i< catIncList.count(); ++i ) { | 2344 | for( i = 0; i< catIncList.count(); ++i ) { |
2345 | if ( !catList.contains (catIncList[i])) { | 2345 | if ( !catList.contains (catIncList[i])) { |
2346 | catList.append( catIncList[i] ); | 2346 | catList.append( catIncList[i] ); |
2347 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2347 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2348 | ++count; | 2348 | ++count; |
2349 | } | 2349 | } |
2350 | } | 2350 | } |
2351 | } | 2351 | } |
2352 | catList.sort(); | 2352 | catList.sort(); |
2353 | KABPrefs::instance()->mCustomCategories = catList; | 2353 | KABPrefs::instance()->mCustomCategories = catList; |
2354 | KABPrefs::instance()->writeConfig(); | 2354 | KABPrefs::instance()->writeConfig(); |
2355 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2355 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2356 | } else { | 2356 | } else { |
2357 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2357 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2358 | QStringList catIncList; | 2358 | QStringList catIncList; |
2359 | QStringList newCatList; | 2359 | QStringList newCatList; |
2360 | KABC::AddressBook::Iterator it; | 2360 | KABC::AddressBook::Iterator it; |
2361 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2361 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2362 | ++cc; | 2362 | ++cc; |
2363 | if ( cc %10 == 0) | 2363 | if ( cc %10 == 0) |
2364 | message(i18n("Processing contact #%1").arg(cc)); | 2364 | message(i18n("Processing contact #%1").arg(cc)); |
2365 | QStringList catIncList = (*it).categories(); | 2365 | QStringList catIncList = (*it).categories(); |
2366 | int i; | 2366 | int i; |
2367 | if ( catIncList.count() ) { | 2367 | if ( catIncList.count() ) { |
2368 | newCatList.clear(); | 2368 | newCatList.clear(); |
2369 | for( i = 0; i< catIncList.count(); ++i ) { | 2369 | for( i = 0; i< catIncList.count(); ++i ) { |
2370 | if ( catList.contains (catIncList[i])) { | 2370 | if ( catList.contains (catIncList[i])) { |
2371 | newCatList.append( catIncList[i] ); | 2371 | newCatList.append( catIncList[i] ); |
2372 | } | 2372 | } |
2373 | } | 2373 | } |
2374 | newCatList.sort(); | 2374 | newCatList.sort(); |
2375 | (*it).setCategories( newCatList ); | 2375 | (*it).setCategories( newCatList ); |
2376 | mAddressBook->insertAddressee( (*it) ); | 2376 | mAddressBook->insertAddressee( (*it) ); |
2377 | } | 2377 | } |
2378 | } | 2378 | } |
2379 | setModified( true ); | 2379 | setModified( true ); |
2380 | mViewManager->refreshView(); | 2380 | mViewManager->refreshView(); |
2381 | message( i18n("Removing categories done!")); | 2381 | message( i18n("Removing categories done!")); |
2382 | } | 2382 | } |
2383 | delete cp; | 2383 | delete cp; |
2384 | } | 2384 | } |
2385 | void KABCore::removeVoice() | 2385 | void KABCore::removeVoice() |
2386 | { | 2386 | { |
2387 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2387 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2388 | return; | 2388 | return; |
2389 | XXPortSelectDialog dlg( this, false, this ); | 2389 | XXPortSelectDialog dlg( this, false, this ); |
2390 | if ( !dlg.exec() ) | 2390 | if ( !dlg.exec() ) |
2391 | return; | 2391 | return; |
2392 | mAddressBook->setUntagged(); | 2392 | mAddressBook->setUntagged(); |
2393 | dlg.tagSelected(); | 2393 | dlg.tagSelected(); |
2394 | message(i18n("Removing voice..."), false ); | 2394 | message(i18n("Removing voice..."), false ); |
2395 | KABC::AddressBook::Iterator it; | 2395 | KABC::AddressBook::Iterator it; |
2396 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2396 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2397 | if ( (*it).tagged() ) { | 2397 | if ( (*it).tagged() ) { |
2398 | (*it).removeVoice(); | 2398 | (*it).removeVoice(); |
2399 | } | 2399 | } |
2400 | } | 2400 | } |
2401 | message(i18n("Refreshing view...") ); | 2401 | message(i18n("Refreshing view...") ); |
2402 | qApp->processEvents(); | 2402 | qApp->processEvents(); |
2403 | mViewManager->refreshView( "" ); | 2403 | mViewManager->refreshView( "" ); |
2404 | Addressee add; | 2404 | Addressee add; |
2405 | mDetails->setAddressee( add ); | 2405 | mDetails->setAddressee( add ); |
2406 | message(i18n("Remove voice completed!") ); | 2406 | message(i18n("Remove voice completed!") ); |
2407 | 2407 | ||
2408 | 2408 | ||
2409 | 2409 | ||
2410 | } | 2410 | } |
2411 | 2411 | ||
2412 | void KABCore::setFormattedName() | 2412 | void KABCore::setFormattedName() |
2413 | { | 2413 | { |
2414 | KABFormatPrefs setpref; | 2414 | KABFormatPrefs setpref; |
2415 | if ( !setpref.exec() ) { | 2415 | if ( !setpref.exec() ) { |
2416 | return; | 2416 | return; |
2417 | } | 2417 | } |
2418 | XXPortSelectDialog dlg( this, false, this ); | 2418 | XXPortSelectDialog dlg( this, false, this ); |
2419 | if ( !dlg.exec() ) | 2419 | if ( !dlg.exec() ) |
2420 | return; | 2420 | return; |
2421 | mAddressBook->setUntagged(); | 2421 | mAddressBook->setUntagged(); |
2422 | dlg.tagSelected(); | 2422 | dlg.tagSelected(); |
2423 | int count = 0; | 2423 | int count = 0; |
2424 | KABC::AddressBook::Iterator it; | 2424 | KABC::AddressBook::Iterator it; |
2425 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2425 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2426 | if ( (*it).tagged() ) { | 2426 | if ( (*it).tagged() ) { |
2427 | ++count; | 2427 | ++count; |
2428 | if ( count %10 == 0 ) | 2428 | if ( count %10 == 0 ) |
2429 | message(i18n("Changing contact #%1").arg( count ) ); | 2429 | message(i18n("Changing contact #%1").arg( count ) ); |
2430 | qApp->processEvents(); | 2430 | qApp->processEvents(); |
2431 | QString fName; | 2431 | QString fName; |
2432 | if ( setpref.simple->isChecked() ) | 2432 | if ( setpref.simple->isChecked() ) |
2433 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2433 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2434 | else if ( setpref.full->isChecked() ) | 2434 | else if ( setpref.full->isChecked() ) |
2435 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2435 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2436 | else if ( setpref.reverse->isChecked() ) | 2436 | else if ( setpref.reverse->isChecked() ) |
2437 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2437 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2438 | else | 2438 | else |
2439 | fName = (*it).organization(); | 2439 | fName = (*it).organization(); |
2440 | if ( setpref.setCompany->isChecked() ) | 2440 | if ( setpref.setCompany->isChecked() ) |
2441 | if ( fName.isEmpty() || fName =="," ) | 2441 | if ( fName.isEmpty() || fName =="," ) |
2442 | fName = (*it).organization(); | 2442 | fName = (*it).organization(); |
2443 | (*it).setFormattedName( fName ); | 2443 | (*it).setFormattedName( fName ); |
2444 | } | 2444 | } |
2445 | } | 2445 | } |
2446 | message(i18n("Refreshing view...") ); | 2446 | message(i18n("Refreshing view...") ); |
2447 | qApp->processEvents(); | 2447 | qApp->processEvents(); |
2448 | mViewManager->refreshView( "" ); | 2448 | mViewManager->refreshView( "" ); |
2449 | Addressee add; | 2449 | Addressee add; |
2450 | mDetails->setAddressee( add ); | 2450 | mDetails->setAddressee( add ); |
2451 | message(i18n("Setting formatted name completed!") ); | 2451 | message(i18n("Setting formatted name completed!") ); |
2452 | } | 2452 | } |
2453 | 2453 | ||
2454 | void KABCore::clipboardDataChanged() | 2454 | void KABCore::clipboardDataChanged() |
2455 | { | 2455 | { |
2456 | 2456 | ||
2457 | if ( mReadWrite ) | 2457 | if ( mReadWrite ) |
2458 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2458 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2459 | 2459 | ||
2460 | } | 2460 | } |
2461 | 2461 | ||
2462 | void KABCore::updateActionMenu() | 2462 | void KABCore::updateActionMenu() |
2463 | { | 2463 | { |
2464 | UndoStack *undo = UndoStack::instance(); | 2464 | UndoStack *undo = UndoStack::instance(); |
2465 | RedoStack *redo = RedoStack::instance(); | 2465 | RedoStack *redo = RedoStack::instance(); |
2466 | 2466 | ||
2467 | if ( undo->isEmpty() ) | 2467 | if ( undo->isEmpty() ) |
2468 | mActionUndo->setText( i18n( "Undo" ) ); | 2468 | mActionUndo->setText( i18n( "Undo" ) ); |
2469 | else | 2469 | else |
2470 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2470 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2471 | 2471 | ||
2472 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2472 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2473 | 2473 | ||
2474 | if ( !redo->top() ) | 2474 | if ( !redo->top() ) |
2475 | mActionRedo->setText( i18n( "Redo" ) ); | 2475 | mActionRedo->setText( i18n( "Redo" ) ); |
2476 | else | 2476 | else |
2477 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2477 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2478 | 2478 | ||
2479 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2479 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2480 | } | 2480 | } |
2481 | 2481 | ||
2482 | void KABCore::configureKeyBindings() | 2482 | void KABCore::configureKeyBindings() |
2483 | { | 2483 | { |
2484 | #ifndef KAB_EMBEDDED | 2484 | #ifndef KAB_EMBEDDED |
2485 | KKeyDialog::configure( actionCollection(), true ); | 2485 | KKeyDialog::configure( actionCollection(), true ); |
2486 | #else //KAB_EMBEDDED | 2486 | #else //KAB_EMBEDDED |
2487 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2487 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2488 | #endif //KAB_EMBEDDED | 2488 | #endif //KAB_EMBEDDED |
2489 | } | 2489 | } |
2490 | 2490 | ||
2491 | #ifdef KAB_EMBEDDED | 2491 | #ifdef KAB_EMBEDDED |
2492 | void KABCore::configureResources() | 2492 | void KABCore::configureResources() |
2493 | { | 2493 | { |
2494 | KRES::KCMKResources dlg( this, "" , 0 ); | 2494 | KRES::KCMKResources dlg( this, "" , 0 ); |
2495 | 2495 | ||
2496 | if ( !dlg.exec() ) | 2496 | if ( !dlg.exec() ) |
2497 | return; | 2497 | return; |
2498 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2498 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2499 | } | 2499 | } |
2500 | #endif //KAB_EMBEDDED | 2500 | #endif //KAB_EMBEDDED |
2501 | 2501 | ||
2502 | 2502 | ||
2503 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2503 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2504 | * for the attendees list of an event. | 2504 | * for the attendees list of an event. |
2505 | */ | 2505 | */ |
2506 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2506 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2507 | { | 2507 | { |
2508 | QStringList nameList; | 2508 | QStringList nameList; |
2509 | QStringList emailList; | 2509 | QStringList emailList; |
2510 | QStringList uidList; | 2510 | QStringList uidList; |
2511 | bool ok = false; | ||
2512 | int wid = uid.toInt( &ok ); | ||
2513 | if ( ok ) { | ||
2514 | if ( wid != QApplication::desktop()->width() ) { | ||
2515 | qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); | ||
2516 | raise(); | ||
2517 | qApp->processEvents(); | ||
2518 | } | ||
2511 | 2519 | ||
2520 | } else { | ||
2521 | qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); | ||
2522 | } | ||
2523 | |||
2512 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2524 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2513 | uint i=0; | 2525 | uint i=0; |
2514 | for (i=0; i < list.count(); i++) | 2526 | for (i=0; i < list.count(); i++) |
2515 | { | 2527 | { |
2516 | nameList.append(list[i].realName()); | 2528 | nameList.append(list[i].realName()); |
2517 | emailList.append(list[i].preferredEmail()); | 2529 | emailList.append(list[i].preferredEmail()); |
2518 | uidList.append(list[i].uid()); | 2530 | uidList.append(list[i].uid()); |
2519 | } | 2531 | } |
2520 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); | 2532 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); |
2521 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2533 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2522 | 2534 | ||
2523 | } | 2535 | } |
2524 | 2536 | ||
2525 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2537 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2526 | * to put them into the calendar. | 2538 | * to put them into the calendar. |
2527 | */ | 2539 | */ |
2528 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2540 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2529 | { | 2541 | { |
2530 | // qDebug("KABCore::requestForBirthdayList"); | 2542 | // qDebug("KABCore::requestForBirthdayList"); |
2531 | QStringList birthdayList; | 2543 | QStringList birthdayList; |
2532 | QStringList anniversaryList; | 2544 | QStringList anniversaryList; |
2533 | QStringList realNameList; | 2545 | QStringList realNameList; |
2534 | QStringList preferredEmailList; | 2546 | QStringList preferredEmailList; |
2535 | QStringList assembledNameList; | 2547 | QStringList assembledNameList; |
2536 | QStringList uidList; | 2548 | QStringList uidList; |
2537 | 2549 | ||
2538 | KABC::AddressBook::Iterator it; | 2550 | KABC::AddressBook::Iterator it; |
2539 | 2551 | ||
2540 | int count = 0; | 2552 | int count = 0; |
2541 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2553 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2542 | ++count; | 2554 | ++count; |
2543 | } | 2555 | } |
2544 | QProgressBar bar(count,0 ); | 2556 | QProgressBar bar(count,0 ); |
2545 | int w = 300; | 2557 | int w = 300; |
2546 | if ( QApplication::desktop()->width() < 320 ) | 2558 | if ( QApplication::desktop()->width() < 320 ) |
2547 | w = 220; | 2559 | w = 220; |
2548 | int h = bar.sizeHint().height() ; | 2560 | int h = bar.sizeHint().height() ; |
2549 | int dw = QApplication::desktop()->width(); | 2561 | int dw = QApplication::desktop()->width(); |
2550 | int dh = QApplication::desktop()->height(); | 2562 | int dh = QApplication::desktop()->height(); |
2551 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2563 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2552 | bar.show(); | 2564 | bar.show(); |
2553 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2565 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2554 | qApp->processEvents(); | 2566 | qApp->processEvents(); |
2555 | 2567 | ||
2556 | QDate bday; | 2568 | QDate bday; |
2557 | QString anni; | 2569 | QString anni; |
2558 | QString formattedbday; | 2570 | QString formattedbday; |
2559 | 2571 | ||
2560 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2572 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2561 | { | 2573 | { |
2562 | if ( ! bar.isVisible() ) | 2574 | if ( ! bar.isVisible() ) |
2563 | return; | 2575 | return; |
2564 | bar.setProgress( count++ ); | 2576 | bar.setProgress( count++ ); |
2565 | qApp->processEvents(); | 2577 | qApp->processEvents(); |
2566 | bday = (*it).birthday().date(); | 2578 | bday = (*it).birthday().date(); |
2567 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2579 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2568 | 2580 | ||
2569 | if ( bday.isValid() || !anni.isEmpty()) | 2581 | if ( bday.isValid() || !anni.isEmpty()) |
2570 | { | 2582 | { |
2571 | if (bday.isValid()) | 2583 | if (bday.isValid()) |
2572 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2584 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2573 | else | 2585 | else |
2574 | formattedbday = "NOTVALID"; | 2586 | formattedbday = "NOTVALID"; |
2575 | if (anni.isEmpty()) | 2587 | if (anni.isEmpty()) |
2576 | anni = "INVALID"; | 2588 | anni = "INVALID"; |
2577 | 2589 | ||
2578 | birthdayList.append(formattedbday); | 2590 | birthdayList.append(formattedbday); |
2579 | anniversaryList.append(anni); //should be ISODate | 2591 | anniversaryList.append(anni); //should be ISODate |
2580 | realNameList.append((*it).realName()); | 2592 | realNameList.append((*it).realName()); |
2581 | preferredEmailList.append((*it).preferredEmail()); | 2593 | preferredEmailList.append((*it).preferredEmail()); |
2582 | assembledNameList.append((*it).assembledName()); | 2594 | assembledNameList.append((*it).assembledName()); |
2583 | uidList.append((*it).uid()); | 2595 | uidList.append((*it).uid()); |
2584 | 2596 | ||
2585 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2597 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2586 | } | 2598 | } |
2587 | } | 2599 | } |
2588 | 2600 | ||
2589 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2601 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2590 | 2602 | ||
2591 | } | 2603 | } |
2592 | 2604 | ||
2593 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2605 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2594 | */ | 2606 | */ |
2595 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2607 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2596 | { | 2608 | { |
2597 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2609 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2598 | 2610 | ||
2599 | QString foundUid = QString::null; | 2611 | QString foundUid = QString::null; |
2600 | if ( ! uid.isEmpty() ) { | 2612 | if ( ! uid.isEmpty() ) { |
2601 | Addressee adrr = mAddressBook->findByUid( uid ); | 2613 | Addressee adrr = mAddressBook->findByUid( uid ); |
2602 | if ( !adrr.isEmpty() ) { | 2614 | if ( !adrr.isEmpty() ) { |
2603 | foundUid = uid; | 2615 | foundUid = uid; |
2604 | } | 2616 | } |
2605 | if ( email == "sendbacklist" ) { | 2617 | if ( email == "sendbacklist" ) { |
2606 | //qDebug("ssssssssssssssssssssssend "); | 2618 | //qDebug("ssssssssssssssssssssssend "); |
2607 | QStringList nameList; | 2619 | QStringList nameList; |
2608 | QStringList emailList; | 2620 | QStringList emailList; |
2609 | QStringList uidList; | 2621 | QStringList uidList; |
2610 | nameList.append(adrr.realName()); | 2622 | nameList.append(adrr.realName()); |
2611 | emailList = adrr.emails(); | 2623 | emailList = adrr.emails(); |
2612 | uidList.append( adrr.preferredEmail()); | 2624 | uidList.append( adrr.preferredEmail()); |
2613 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2625 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2614 | return; | 2626 | return; |
2615 | } | 2627 | } |
2616 | 2628 | ||
2617 | } | 2629 | } |
2618 | 2630 | ||
2619 | if ( email == "sendbacklist" ) | 2631 | if ( email == "sendbacklist" ) |
2620 | return; | 2632 | return; |
2621 | if (foundUid.isEmpty()) | 2633 | if (foundUid.isEmpty()) |
2622 | { | 2634 | { |
2623 | //find the uid of the person first | 2635 | //find the uid of the person first |
2624 | Addressee::List namelist; | 2636 | Addressee::List namelist; |
2625 | Addressee::List emaillist; | 2637 | Addressee::List emaillist; |
2626 | 2638 | ||
2627 | if (!name.isEmpty()) | 2639 | if (!name.isEmpty()) |
2628 | namelist = mAddressBook->findByName( name ); | 2640 | namelist = mAddressBook->findByName( name ); |
2629 | 2641 | ||
2630 | if (!email.isEmpty()) | 2642 | if (!email.isEmpty()) |
2631 | emaillist = mAddressBook->findByEmail( email ); | 2643 | emaillist = mAddressBook->findByEmail( email ); |
2632 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2644 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2633 | //check if we have a match in Namelist and Emaillist | 2645 | //check if we have a match in Namelist and Emaillist |
2634 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2646 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2635 | foundUid = emaillist[0].uid(); | 2647 | foundUid = emaillist[0].uid(); |
2636 | } | 2648 | } |
2637 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2649 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2638 | foundUid = namelist[0].uid(); | 2650 | foundUid = namelist[0].uid(); |
2639 | else | 2651 | else |
2640 | { | 2652 | { |
2641 | for (int i = 0; i < namelist.count(); i++) | 2653 | for (int i = 0; i < namelist.count(); i++) |
2642 | { | 2654 | { |
2643 | for (int j = 0; j < emaillist.count(); j++) | 2655 | for (int j = 0; j < emaillist.count(); j++) |
2644 | { | 2656 | { |
2645 | if (namelist[i] == emaillist[j]) | 2657 | if (namelist[i] == emaillist[j]) |
2646 | { | 2658 | { |
2647 | foundUid = namelist[i].uid(); | 2659 | foundUid = namelist[i].uid(); |
2648 | } | 2660 | } |
2649 | } | 2661 | } |
2650 | } | 2662 | } |
2651 | } | 2663 | } |
2652 | } | 2664 | } |
2653 | else | 2665 | else |
2654 | { | 2666 | { |
2655 | foundUid = uid; | 2667 | foundUid = uid; |
2656 | } | 2668 | } |
2657 | 2669 | ||
2658 | if (!foundUid.isEmpty()) | 2670 | if (!foundUid.isEmpty()) |
2659 | { | 2671 | { |
2660 | 2672 | ||
2661 | // raise Ka/Pi if it is in the background | 2673 | // raise Ka/Pi if it is in the background |
2662 | #ifndef DESKTOP_VERSION | 2674 | #ifndef DESKTOP_VERSION |
2663 | #ifndef KORG_NODCOP | 2675 | #ifndef KORG_NODCOP |
2664 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2676 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2665 | #endif | 2677 | #endif |
2666 | #endif | 2678 | #endif |
2667 | 2679 | ||
2668 | mMainWindow->showMaximized(); | 2680 | mMainWindow->showMaximized(); |
2669 | mMainWindow-> raise(); | 2681 | mMainWindow-> raise(); |
2670 | 2682 | ||
2671 | mViewManager->setSelected( "", false); | 2683 | mViewManager->setSelected( "", false); |
2672 | mViewManager->refreshView( "" ); | 2684 | mViewManager->refreshView( "" ); |
2673 | mViewManager->setSelected( foundUid, true ); | 2685 | mViewManager->setSelected( foundUid, true ); |
2674 | mViewManager->refreshView( foundUid ); | 2686 | mViewManager->refreshView( foundUid ); |
2675 | 2687 | ||
2676 | if ( !mMultipleViewsAtOnce ) | 2688 | if ( !mMultipleViewsAtOnce ) |
2677 | { | 2689 | { |
2678 | setDetailsVisible( true ); | 2690 | setDetailsVisible( true ); |
2679 | mActionDetails->setChecked(true); | 2691 | mActionDetails->setChecked(true); |
2680 | } | 2692 | } |
2681 | } | 2693 | } |
2682 | } | 2694 | } |
2683 | 2695 | ||
2684 | void KABCore::whatsnew() | 2696 | void KABCore::whatsnew() |
2685 | { | 2697 | { |
2686 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2698 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2687 | } | 2699 | } |
2688 | void KABCore::synchowto() | 2700 | void KABCore::synchowto() |
2689 | { | 2701 | { |
2690 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2702 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2691 | } | 2703 | } |
2692 | void KABCore::kdesynchowto() | 2704 | void KABCore::kdesynchowto() |
2693 | { | 2705 | { |
2694 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2706 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2695 | } | 2707 | } |
2696 | void KABCore::multisynchowto() | 2708 | void KABCore::multisynchowto() |
2697 | { | 2709 | { |
2698 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2710 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2699 | } | 2711 | } |
2700 | void KABCore::faq() | 2712 | void KABCore::faq() |
2701 | { | 2713 | { |
2702 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2714 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2703 | } | 2715 | } |
2704 | 2716 | ||
2705 | #include <libkcal/syncdefines.h> | 2717 | #include <libkcal/syncdefines.h> |
2706 | 2718 | ||
2707 | KABC::Addressee KABCore::getLastSyncAddressee() | 2719 | KABC::Addressee KABCore::getLastSyncAddressee() |
2708 | { | 2720 | { |
2709 | Addressee lse; | 2721 | Addressee lse; |
2710 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2722 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2711 | 2723 | ||
2712 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2724 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2713 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2725 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2714 | if (lse.isEmpty()) { | 2726 | if (lse.isEmpty()) { |
2715 | qDebug("KA: Creating new last-syncAddressee "); | 2727 | qDebug("KA: Creating new last-syncAddressee "); |
2716 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2728 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2717 | QString sum = ""; | 2729 | QString sum = ""; |
2718 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2730 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2719 | sum = "E: "; | 2731 | sum = "E: "; |
2720 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2732 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2721 | lse.setRevision( mLastAddressbookSync ); | 2733 | lse.setRevision( mLastAddressbookSync ); |
2722 | lse.setCategories( i18n("SyncEvent") ); | 2734 | lse.setCategories( i18n("SyncEvent") ); |
2723 | mAddressBook->insertAddressee( lse ); | 2735 | mAddressBook->insertAddressee( lse ); |
2724 | } | 2736 | } |
2725 | return lse; | 2737 | return lse; |
2726 | } | 2738 | } |
2727 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2739 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2728 | { | 2740 | { |
2729 | 2741 | ||
2730 | //void setZaurusId(int id); | 2742 | //void setZaurusId(int id); |
2731 | // int zaurusId() const; | 2743 | // int zaurusId() const; |
2732 | // void setZaurusUid(int id); | 2744 | // void setZaurusUid(int id); |
2733 | // int zaurusUid() const; | 2745 | // int zaurusUid() const; |
2734 | // void setZaurusStat(int id); | 2746 | // void setZaurusStat(int id); |
2735 | // int zaurusStat() const; | 2747 | // int zaurusStat() const; |
2736 | // 0 equal | 2748 | // 0 equal |
2737 | // 1 take local | 2749 | // 1 take local |
2738 | // 2 take remote | 2750 | // 2 take remote |
2739 | // 3 cancel | 2751 | // 3 cancel |
2740 | QDateTime lastSync = mLastAddressbookSync; | 2752 | QDateTime lastSync = mLastAddressbookSync; |
2741 | QDateTime localMod = local->revision(); | 2753 | QDateTime localMod = local->revision(); |
2742 | QDateTime remoteMod = remote->revision(); | 2754 | QDateTime remoteMod = remote->revision(); |
2743 | 2755 | ||
2744 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2756 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2745 | 2757 | ||
2746 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2758 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2747 | bool remCh, locCh; | 2759 | bool remCh, locCh; |
2748 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2760 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2749 | //if ( remCh ) | 2761 | //if ( remCh ) |
2750 | // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2762 | // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2751 | locCh = ( localMod > mLastAddressbookSync ); | 2763 | locCh = ( localMod > mLastAddressbookSync ); |
2752 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); | 2764 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); |
2753 | if ( !remCh && ! locCh ) { | 2765 | if ( !remCh && ! locCh ) { |
2754 | //qDebug("both not changed "); | 2766 | //qDebug("both not changed "); |
2755 | lastSync = localMod.addDays(1); | 2767 | lastSync = localMod.addDays(1); |
2756 | if ( mode <= SYNC_PREF_ASK ) | 2768 | if ( mode <= SYNC_PREF_ASK ) |
2757 | return 0; | 2769 | return 0; |
2758 | } else { | 2770 | } else { |
2759 | if ( locCh ) { | 2771 | if ( locCh ) { |
2760 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2772 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2761 | lastSync = localMod.addDays( -1 ); | 2773 | lastSync = localMod.addDays( -1 ); |
2762 | if ( !remCh ) | 2774 | if ( !remCh ) |
2763 | remoteMod =( lastSync.addDays( -1 ) ); | 2775 | remoteMod =( lastSync.addDays( -1 ) ); |
2764 | } else { | 2776 | } else { |
2765 | //qDebug(" not loc changed "); | 2777 | //qDebug(" not loc changed "); |
2766 | lastSync = localMod.addDays( 1 ); | 2778 | lastSync = localMod.addDays( 1 ); |
2767 | if ( remCh ) { | 2779 | if ( remCh ) { |
2768 | //qDebug("rem changed "); | 2780 | //qDebug("rem changed "); |
2769 | remoteMod =( lastSync.addDays( 1 ) ); | 2781 | remoteMod =( lastSync.addDays( 1 ) ); |
2770 | } | 2782 | } |
2771 | 2783 | ||
2772 | } | 2784 | } |
2773 | } | 2785 | } |
2774 | full = true; | 2786 | full = true; |
2775 | if ( mode < SYNC_PREF_ASK ) | 2787 | if ( mode < SYNC_PREF_ASK ) |
2776 | mode = SYNC_PREF_ASK; | 2788 | mode = SYNC_PREF_ASK; |
2777 | } else { | 2789 | } else { |
2778 | if ( localMod == remoteMod ) | 2790 | if ( localMod == remoteMod ) |
2779 | return 0; | 2791 | return 0; |
2780 | 2792 | ||
2781 | } | 2793 | } |
2782 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2794 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2783 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2795 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2784 | //full = true; //debug only | 2796 | //full = true; //debug only |
2785 | if ( full ) { | 2797 | if ( full ) { |
2786 | bool equ = ( (*local) == (*remote) ); | 2798 | bool equ = ( (*local) == (*remote) ); |
2787 | if ( equ ) { | 2799 | if ( equ ) { |
2788 | //qDebug("equal "); | 2800 | //qDebug("equal "); |
2789 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2801 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2790 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2802 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2791 | } | 2803 | } |
2792 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2804 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2793 | return 0; | 2805 | return 0; |
2794 | 2806 | ||
2795 | }//else //debug only | 2807 | }//else //debug only |
2796 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2808 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2797 | } | 2809 | } |
2798 | int result; | 2810 | int result; |
2799 | bool localIsNew; | 2811 | bool localIsNew; |
2800 | //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() ); | 2812 | //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() ); |
2801 | 2813 | ||
2802 | if ( full && mode < SYNC_PREF_NEWEST ) | 2814 | if ( full && mode < SYNC_PREF_NEWEST ) |
2803 | mode = SYNC_PREF_ASK; | 2815 | mode = SYNC_PREF_ASK; |
2804 | 2816 | ||
2805 | switch( mode ) { | 2817 | switch( mode ) { |
2806 | case SYNC_PREF_LOCAL: | 2818 | case SYNC_PREF_LOCAL: |
2807 | if ( lastSync > remoteMod ) | 2819 | if ( lastSync > remoteMod ) |
2808 | return 1; | 2820 | return 1; |
2809 | if ( lastSync > localMod ) | 2821 | if ( lastSync > localMod ) |
2810 | return 2; | 2822 | return 2; |
2811 | return 1; | 2823 | return 1; |
2812 | break; | 2824 | break; |
2813 | case SYNC_PREF_REMOTE: | 2825 | case SYNC_PREF_REMOTE: |
2814 | if ( lastSync > remoteMod ) | 2826 | if ( lastSync > remoteMod ) |
2815 | return 1; | 2827 | return 1; |
2816 | if ( lastSync > localMod ) | 2828 | if ( lastSync > localMod ) |
2817 | return 2; | 2829 | return 2; |
2818 | return 2; | 2830 | return 2; |
2819 | break; | 2831 | break; |
2820 | case SYNC_PREF_NEWEST: | 2832 | case SYNC_PREF_NEWEST: |
2821 | if ( localMod > remoteMod ) | 2833 | if ( localMod > remoteMod ) |
2822 | return 1; | 2834 | return 1; |
2823 | else | 2835 | else |
2824 | return 2; | 2836 | return 2; |
2825 | break; | 2837 | break; |
2826 | case SYNC_PREF_ASK: | 2838 | case SYNC_PREF_ASK: |
2827 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2839 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2828 | if ( lastSync > remoteMod ) | 2840 | if ( lastSync > remoteMod ) |
2829 | return 1; | 2841 | return 1; |
2830 | if ( lastSync > localMod ) { | 2842 | if ( lastSync > localMod ) { |
2831 | return 2; | 2843 | return 2; |
2832 | } | 2844 | } |
2833 | localIsNew = localMod >= remoteMod; | 2845 | localIsNew = localMod >= remoteMod; |
2834 | //qDebug("conflict! ************************************** "); | 2846 | //qDebug("conflict! ************************************** "); |
2835 | { | 2847 | { |
2836 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2848 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2837 | result = acd.executeD(localIsNew); | 2849 | result = acd.executeD(localIsNew); |
2838 | return result; | 2850 | return result; |
2839 | } | 2851 | } |
2840 | break; | 2852 | break; |
2841 | case SYNC_PREF_FORCE_LOCAL: | 2853 | case SYNC_PREF_FORCE_LOCAL: |
2842 | return 1; | 2854 | return 1; |
2843 | break; | 2855 | break; |
2844 | case SYNC_PREF_FORCE_REMOTE: | 2856 | case SYNC_PREF_FORCE_REMOTE: |
2845 | return 2; | 2857 | return 2; |
2846 | break; | 2858 | break; |
2847 | 2859 | ||
2848 | default: | 2860 | default: |
2849 | // SYNC_PREF_TAKE_BOTH not implemented | 2861 | // SYNC_PREF_TAKE_BOTH not implemented |
2850 | break; | 2862 | break; |
2851 | } | 2863 | } |
2852 | return 0; | 2864 | return 0; |
2853 | } | 2865 | } |
2854 | 2866 | ||
2855 | 2867 | ||
2856 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2868 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2857 | { | 2869 | { |
2858 | bool syncOK = true; | 2870 | bool syncOK = true; |
2859 | int addedAddressee = 0; | 2871 | int addedAddressee = 0; |
2860 | int addedAddresseeR = 0; | 2872 | int addedAddresseeR = 0; |
2861 | int deletedAddresseeR = 0; | 2873 | int deletedAddresseeR = 0; |
2862 | int deletedAddresseeL = 0; | 2874 | int deletedAddresseeL = 0; |
2863 | int changedLocal = 0; | 2875 | int changedLocal = 0; |
2864 | int changedRemote = 0; | 2876 | int changedRemote = 0; |
2865 | int filteredIN = 0; | 2877 | int filteredIN = 0; |
2866 | int filteredOUT = 0; | 2878 | int filteredOUT = 0; |
2867 | 2879 | ||
2868 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2880 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2869 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2881 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2870 | 2882 | ||
2871 | //QPtrList<Addressee> el = local->rawAddressees(); | 2883 | //QPtrList<Addressee> el = local->rawAddressees(); |
2872 | Addressee addresseeR; | 2884 | Addressee addresseeR; |
2873 | QString uid; | 2885 | QString uid; |
2874 | int take; | 2886 | int take; |
2875 | Addressee addresseeL; | 2887 | Addressee addresseeL; |
2876 | Addressee addresseeRSync; | 2888 | Addressee addresseeRSync; |
2877 | Addressee addresseeLSync; | 2889 | Addressee addresseeLSync; |
2878 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2890 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2879 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2891 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2880 | bool fullDateRange = false; | 2892 | bool fullDateRange = false; |
2881 | local->resetTempSyncStat(); | 2893 | local->resetTempSyncStat(); |
2882 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2894 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2883 | if ( syncManager->syncWithDesktop() ) { | 2895 | if ( syncManager->syncWithDesktop() ) { |
2884 | // remote->removeSyncInfo( QString());//remove all info | 2896 | // remote->removeSyncInfo( QString());//remove all info |
2885 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2897 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2886 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2898 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2887 | qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2899 | qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2888 | } else { | 2900 | } else { |
2889 | qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2901 | qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2890 | } | 2902 | } |
2891 | } | 2903 | } |
2892 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2904 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2893 | addresseeLSync = getLastSyncAddressee(); | 2905 | addresseeLSync = getLastSyncAddressee(); |
2894 | qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2906 | qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2895 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2907 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2896 | if ( !addresseeR.isEmpty() ) { | 2908 | if ( !addresseeR.isEmpty() ) { |
2897 | addresseeRSync = addresseeR; | 2909 | addresseeRSync = addresseeR; |
2898 | remote->removeAddressee(addresseeR ); | 2910 | remote->removeAddressee(addresseeR ); |
2899 | 2911 | ||
2900 | } else { | 2912 | } else { |
2901 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2913 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2902 | addresseeRSync = addresseeLSync ; | 2914 | addresseeRSync = addresseeLSync ; |
2903 | } else { | 2915 | } else { |
2904 | //qDebug("FULLDATE 1"); | 2916 | //qDebug("FULLDATE 1"); |
2905 | fullDateRange = true; | 2917 | fullDateRange = true; |
2906 | Addressee newAdd; | 2918 | Addressee newAdd; |
2907 | addresseeRSync = newAdd; | 2919 | addresseeRSync = newAdd; |
2908 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2920 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2909 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2921 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2910 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2922 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2911 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2923 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2912 | } | 2924 | } |
2913 | } | 2925 | } |
2914 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2926 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2915 | // qDebug("FULLDATE 2"); | 2927 | // qDebug("FULLDATE 2"); |
2916 | fullDateRange = true; | 2928 | fullDateRange = true; |
2917 | } | 2929 | } |
2918 | if ( ! fullDateRange ) { | 2930 | if ( ! fullDateRange ) { |
2919 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2931 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2920 | 2932 | ||
2921 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2933 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2922 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2934 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2923 | fullDateRange = true; | 2935 | fullDateRange = true; |
2924 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2936 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2925 | } | 2937 | } |
2926 | } | 2938 | } |
2927 | // fullDateRange = true; // debug only! | 2939 | // fullDateRange = true; // debug only! |
2928 | if ( fullDateRange ) | 2940 | if ( fullDateRange ) |
2929 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2941 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2930 | else | 2942 | else |
2931 | mLastAddressbookSync = addresseeLSync.revision(); | 2943 | mLastAddressbookSync = addresseeLSync.revision(); |
2932 | // for resyncing if own file has changed | 2944 | // for resyncing if own file has changed |
2933 | // PENDING fixme later when implemented | 2945 | // PENDING fixme later when implemented |
2934 | #if 0 | 2946 | #if 0 |
2935 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2947 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2936 | mLastAddressbookSync = loadedFileVersion; | 2948 | mLastAddressbookSync = loadedFileVersion; |
2937 | qDebug("setting mLastAddressbookSync "); | 2949 | qDebug("setting mLastAddressbookSync "); |
2938 | } | 2950 | } |
2939 | #endif | 2951 | #endif |
2940 | 2952 | ||
2941 | 2953 | ||
2942 | // ********** setting filters **************** | 2954 | // ********** setting filters **************** |
2943 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); | 2955 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); |
2944 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); | 2956 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); |
2945 | 2957 | ||
2946 | //qDebug("*************************** "); | 2958 | //qDebug("*************************** "); |
2947 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2959 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2948 | QStringList er = remote->uidList(); | 2960 | QStringList er = remote->uidList(); |
2949 | Addressee inR ;//= er.first(); | 2961 | Addressee inR ;//= er.first(); |
2950 | Addressee inL; | 2962 | Addressee inL; |
2951 | 2963 | ||
2952 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2964 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2953 | 2965 | ||
2954 | int modulo = (er.count()/10)+1; | 2966 | int modulo = (er.count()/10)+1; |
2955 | int incCounter = 0; | 2967 | int incCounter = 0; |
2956 | while ( incCounter < er.count()) { | 2968 | while ( incCounter < er.count()) { |
2957 | if (syncManager->isProgressBarCanceled()) | 2969 | if (syncManager->isProgressBarCanceled()) |
2958 | return false; | 2970 | return false; |
2959 | if ( incCounter % modulo == 0 ) | 2971 | if ( incCounter % modulo == 0 ) |
2960 | syncManager->showProgressBar(incCounter); | 2972 | syncManager->showProgressBar(incCounter); |
2961 | 2973 | ||
2962 | uid = er[ incCounter ]; | 2974 | uid = er[ incCounter ]; |
2963 | bool skipIncidence = false; | 2975 | bool skipIncidence = false; |
2964 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2976 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2965 | skipIncidence = true; | 2977 | skipIncidence = true; |
2966 | QString idS,OidS; | 2978 | QString idS,OidS; |
2967 | qApp->processEvents(); | 2979 | qApp->processEvents(); |
2968 | if ( !skipIncidence ) { | 2980 | if ( !skipIncidence ) { |
2969 | inL = local->findByUid( uid ); | 2981 | inL = local->findByUid( uid ); |
2970 | inR = remote->findByUid( uid ); | 2982 | inR = remote->findByUid( uid ); |
2971 | //inL.setResource( 0 ); | 2983 | //inL.setResource( 0 ); |
2972 | //inR.setResource( 0 ); | 2984 | //inR.setResource( 0 ); |
2973 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2985 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2974 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2986 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2975 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { | 2987 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
2976 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2988 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2977 | if ( take == 3 ) | 2989 | if ( take == 3 ) |
2978 | return false; | 2990 | return false; |
2979 | if ( take == 1 ) {// take local ********************** | 2991 | if ( take == 1 ) {// take local ********************** |
2980 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2992 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2981 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2993 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2982 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2994 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2983 | local->insertAddressee( inL, false ); | 2995 | local->insertAddressee( inL, false ); |
2984 | idS = inR.externalUID(); | 2996 | idS = inR.externalUID(); |
2985 | OidS = inR.originalExternalUID(); | 2997 | OidS = inR.originalExternalUID(); |
2986 | } | 2998 | } |
2987 | else | 2999 | else |
2988 | idS = inR.IDStr(); | 3000 | idS = inR.IDStr(); |
2989 | remote->removeAddressee( inR ); | 3001 | remote->removeAddressee( inR ); |
2990 | inR = inL; | 3002 | inR = inL; |
2991 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 3003 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2992 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3004 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2993 | inR.setOriginalExternalUID( OidS ); | 3005 | inR.setOriginalExternalUID( OidS ); |
2994 | inR.setExternalUID( idS ); | 3006 | inR.setExternalUID( idS ); |
2995 | if ( syncManager->syncWithDesktop() ) { | 3007 | if ( syncManager->syncWithDesktop() ) { |
2996 | inR.setIDStr("changed" ); | 3008 | inR.setIDStr("changed" ); |
2997 | } | 3009 | } |
2998 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 3010 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2999 | } else { | 3011 | } else { |
3000 | inR.setIDStr( idS ); | 3012 | inR.setIDStr( idS ); |
3001 | } | 3013 | } |
3002 | inR.setResource( 0 ); | 3014 | inR.setResource( 0 ); |
3003 | remote->insertAddressee( inR , false); | 3015 | remote->insertAddressee( inR , false); |
3004 | ++changedRemote; | 3016 | ++changedRemote; |
3005 | } else { // take == 2 take remote ********************** | 3017 | } else { // take == 2 take remote ********************** |
3006 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3018 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3007 | if ( inR.revision().date().year() < 2004 ) | 3019 | if ( inR.revision().date().year() < 2004 ) |
3008 | inR.setRevision( modifiedCalendar ); | 3020 | inR.setRevision( modifiedCalendar ); |
3009 | } | 3021 | } |
3010 | idS = inL.IDStr(); | 3022 | idS = inL.IDStr(); |
3011 | local->removeAddressee( inL ); | 3023 | local->removeAddressee( inL ); |
3012 | inL = inR; | 3024 | inL = inR; |
3013 | inL.setIDStr( idS ); | 3025 | inL.setIDStr( idS ); |
3014 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3026 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3015 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3027 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3016 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3028 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3017 | } | 3029 | } |
3018 | inL.setResource( 0 ); | 3030 | inL.setResource( 0 ); |
3019 | local->insertAddressee( inL , false ); | 3031 | local->insertAddressee( inL , false ); |
3020 | ++changedLocal; | 3032 | ++changedLocal; |
3021 | } | 3033 | } |
3022 | } | 3034 | } |
3023 | } | 3035 | } |
3024 | } else { // no conflict ********** add or delete remote | 3036 | } else { // no conflict ********** add or delete remote |
3025 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { | 3037 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { |
3026 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3038 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3027 | QString des = addresseeLSync.note(); | 3039 | QString des = addresseeLSync.note(); |
3028 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 3040 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
3029 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 3041 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
3030 | remote->insertAddressee( inR, false ); | 3042 | remote->insertAddressee( inR, false ); |
3031 | ++deletedAddresseeR; | 3043 | ++deletedAddresseeR; |
3032 | } else { | 3044 | } else { |
3033 | inR.setRevision( modifiedCalendar ); | 3045 | inR.setRevision( modifiedCalendar ); |
3034 | remote->insertAddressee( inR, false ); | 3046 | remote->insertAddressee( inR, false ); |
3035 | inL = inR; | 3047 | inL = inR; |
3036 | inL.setIDStr( ":" ); | 3048 | inL.setIDStr( ":" ); |
3037 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3049 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3038 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3050 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3039 | inL.setResource( 0 ); | 3051 | inL.setResource( 0 ); |
3040 | local->insertAddressee( inL , false); | 3052 | local->insertAddressee( inL , false); |
3041 | ++addedAddressee; | 3053 | ++addedAddressee; |
3042 | } | 3054 | } |
3043 | } else { | 3055 | } else { |
3044 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 3056 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
3045 | inR.setRevision( modifiedCalendar ); | 3057 | inR.setRevision( modifiedCalendar ); |
3046 | remote->insertAddressee( inR, false ); | 3058 | remote->insertAddressee( inR, false ); |
3047 | inR.setResource( 0 ); | 3059 | inR.setResource( 0 ); |
3048 | local->insertAddressee( inR, false ); | 3060 | local->insertAddressee( inR, false ); |
3049 | ++addedAddressee; | 3061 | ++addedAddressee; |
3050 | } else { | 3062 | } else { |
3051 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 3063 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
3052 | remote->removeAddressee( inR ); | 3064 | remote->removeAddressee( inR ); |
3053 | ++deletedAddresseeR; | 3065 | ++deletedAddresseeR; |
3054 | } | 3066 | } |
3055 | } | 3067 | } |
3056 | } else { | 3068 | } else { |
3057 | ++filteredIN; | 3069 | ++filteredIN; |
3058 | } | 3070 | } |
3059 | } | 3071 | } |
3060 | } | 3072 | } |
3061 | ++incCounter; | 3073 | ++incCounter; |
3062 | } | 3074 | } |
3063 | er.clear(); | 3075 | er.clear(); |
3064 | QStringList el = local->uidList(); | 3076 | QStringList el = local->uidList(); |
3065 | modulo = (el.count()/10)+1; | 3077 | modulo = (el.count()/10)+1; |
3066 | 3078 | ||
3067 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3079 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
3068 | incCounter = 0; | 3080 | incCounter = 0; |
3069 | while ( incCounter < el.count()) { | 3081 | while ( incCounter < el.count()) { |
3070 | qApp->processEvents(); | 3082 | qApp->processEvents(); |
3071 | if (syncManager->isProgressBarCanceled()) | 3083 | if (syncManager->isProgressBarCanceled()) |
3072 | return false; | 3084 | return false; |
3073 | if ( incCounter % modulo == 0 ) | 3085 | if ( incCounter % modulo == 0 ) |
3074 | syncManager->showProgressBar(incCounter); | 3086 | syncManager->showProgressBar(incCounter); |
3075 | uid = el[ incCounter ]; | 3087 | uid = el[ incCounter ]; |
3076 | bool skipIncidence = false; | 3088 | bool skipIncidence = false; |
3077 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3089 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3078 | skipIncidence = true; | 3090 | skipIncidence = true; |
3079 | if ( !skipIncidence ) { | 3091 | if ( !skipIncidence ) { |
3080 | inL = local->findByUid( uid ); | 3092 | inL = local->findByUid( uid ); |
3081 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3093 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3082 | inR = remote->findByUid( uid ); | 3094 | inR = remote->findByUid( uid ); |
3083 | if ( inR.isEmpty() ){ | 3095 | if ( inR.isEmpty() ){ |
3084 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { | 3096 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { |
3085 | // no conflict ********** add or delete local | 3097 | // no conflict ********** add or delete local |
3086 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3098 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3087 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3099 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3088 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3100 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3089 | local->removeAddressee( inL ); | 3101 | local->removeAddressee( inL ); |
3090 | ++deletedAddresseeL; | 3102 | ++deletedAddresseeL; |
3091 | } else { | 3103 | } else { |
3092 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3104 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3093 | inL.removeID(mCurrentSyncDevice ); | 3105 | inL.removeID(mCurrentSyncDevice ); |
3094 | ++addedAddresseeR; | 3106 | ++addedAddresseeR; |
3095 | inL.setRevision( modifiedCalendar ); | 3107 | inL.setRevision( modifiedCalendar ); |
3096 | local->insertAddressee( inL, false ); | 3108 | local->insertAddressee( inL, false ); |
3097 | inR = inL; | 3109 | inR = inL; |
3098 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3110 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3099 | inR.setResource( 0 ); | 3111 | inR.setResource( 0 ); |
3100 | remote->insertAddressee( inR, false ); | 3112 | remote->insertAddressee( inR, false ); |
3101 | } | 3113 | } |
3102 | } | 3114 | } |
3103 | } else { | 3115 | } else { |
3104 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3116 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3105 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3117 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3106 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3118 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3107 | local->removeAddressee( inL ); | 3119 | local->removeAddressee( inL ); |
3108 | ++deletedAddresseeL; | 3120 | ++deletedAddresseeL; |
3109 | } else { | 3121 | } else { |
3110 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3122 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3111 | ++addedAddresseeR; | 3123 | ++addedAddresseeR; |
3112 | inL.setRevision( modifiedCalendar ); | 3124 | inL.setRevision( modifiedCalendar ); |
3113 | local->insertAddressee( inL, false ); | 3125 | local->insertAddressee( inL, false ); |
3114 | inR = inL; | 3126 | inR = inL; |
3115 | inR.setIDStr( ":" ); | 3127 | inR.setIDStr( ":" ); |
3116 | inR.setResource( 0 ); | 3128 | inR.setResource( 0 ); |
3117 | remote->insertAddressee( inR, false ); | 3129 | remote->insertAddressee( inR, false ); |
3118 | } | 3130 | } |
3119 | } | 3131 | } |
3120 | } | 3132 | } |
3121 | } else { | 3133 | } else { |
3122 | ++filteredOUT; | 3134 | ++filteredOUT; |
3123 | } | 3135 | } |
3124 | } | 3136 | } |
3125 | } | 3137 | } |
3126 | } | 3138 | } |
3127 | ++incCounter; | 3139 | ++incCounter; |
3128 | } | 3140 | } |
3129 | el.clear(); | 3141 | el.clear(); |
3130 | syncManager->hideProgressBar(); | 3142 | syncManager->hideProgressBar(); |
3131 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3143 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3132 | // get rid of micro seconds | 3144 | // get rid of micro seconds |
3133 | QTime t = mLastAddressbookSync.time(); | 3145 | QTime t = mLastAddressbookSync.time(); |
3134 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3146 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3135 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3147 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3136 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3148 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3137 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3149 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3138 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3150 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3139 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3151 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3140 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3152 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3141 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3153 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3142 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3154 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3143 | addresseeRSync.setNote( "" ) ; | 3155 | addresseeRSync.setNote( "" ) ; |
3144 | addresseeLSync.setNote( "" ); | 3156 | addresseeLSync.setNote( "" ); |
3145 | 3157 | ||
3146 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3158 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3147 | remote->insertAddressee( addresseeRSync, false ); | 3159 | remote->insertAddressee( addresseeRSync, false ); |
3148 | local->insertAddressee( addresseeLSync, false ); | 3160 | local->insertAddressee( addresseeLSync, false ); |
3149 | QString mes; | 3161 | QString mes; |
3150 | 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 ); | 3162 | 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 ); |
3151 | qDebug( mes ); | 3163 | qDebug( mes ); |
3152 | mes = i18n("Local addressbook changed!\n") +mes; | 3164 | mes = i18n("Local addressbook changed!\n") +mes; |
3153 | if ( syncManager->mShowSyncSummary ) { | 3165 | if ( syncManager->mShowSyncSummary ) { |
3154 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3166 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3155 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3167 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3156 | qDebug("KA: WB cancelled "); | 3168 | qDebug("KA: WB cancelled "); |
3157 | syncManager->mWriteBackFile = false; | 3169 | syncManager->mWriteBackFile = false; |
3158 | return syncOK; | 3170 | return syncOK; |
3159 | } | 3171 | } |
3160 | } | 3172 | } |
3161 | return syncOK; | 3173 | return syncOK; |
3162 | } | 3174 | } |
3163 | 3175 | ||
3164 | 3176 | ||
3165 | //this is a overwritten callbackmethods from the syncinterface | 3177 | //this is a overwritten callbackmethods from the syncinterface |
3166 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3178 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
3167 | { | 3179 | { |
3168 | 3180 | ||
3169 | //pending prepare addresseeview for output | 3181 | //pending prepare addresseeview for output |
3170 | //pending detect, if remote file has REV field. if not switch to external sync | 3182 | //pending detect, if remote file has REV field. if not switch to external sync |
3171 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3183 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3172 | if ( manager != syncManager ) | 3184 | if ( manager != syncManager ) |
3173 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3185 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3174 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3186 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3175 | 3187 | ||
3176 | AddressBook abLocal(filename,"syncContact"); | 3188 | AddressBook abLocal(filename,"syncContact"); |
3177 | bool syncOK = false; | 3189 | bool syncOK = false; |
3178 | if ( abLocal.load() ) { | 3190 | if ( abLocal.load() ) { |
3179 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3191 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3180 | bool external = false; | 3192 | bool external = false; |
3181 | bool isXML = false; | 3193 | bool isXML = false; |
3182 | if ( filename.right(4) == ".xml") { | 3194 | if ( filename.right(4) == ".xml") { |
3183 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3195 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3184 | isXML = true; | 3196 | isXML = true; |
3185 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3197 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3186 | } else { | 3198 | } else { |
3187 | external = !manager->mIsKapiFile; | 3199 | external = !manager->mIsKapiFile; |
3188 | if ( external ) { | 3200 | if ( external ) { |
3189 | qDebug("KA: Sync::Setting vcf mode to external "); | 3201 | qDebug("KA: Sync::Setting vcf mode to external "); |
3190 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3202 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3191 | AddressBook::Iterator it; | 3203 | AddressBook::Iterator it; |
3192 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3204 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3193 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3205 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3194 | (*it).computeCsum( mCurrentSyncDevice ); | 3206 | (*it).computeCsum( mCurrentSyncDevice ); |
3195 | } | 3207 | } |
3196 | } | 3208 | } |
3197 | } | 3209 | } |
3198 | //AddressBook::Iterator it; | 3210 | //AddressBook::Iterator it; |
3199 | //QStringList vcards; | 3211 | //QStringList vcards; |
3200 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3212 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3201 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3213 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3202 | //} | 3214 | //} |
3203 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3215 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3204 | syncManager->hideProgressBar(); | 3216 | syncManager->hideProgressBar(); |
3205 | if ( syncOK ) { | 3217 | if ( syncOK ) { |
3206 | if ( syncManager->mWriteBackFile ) | 3218 | if ( syncManager->mWriteBackFile ) |
3207 | { | 3219 | { |
3208 | if ( external ) | 3220 | if ( external ) |
3209 | abLocal.removeSyncAddressees( !isXML); | 3221 | abLocal.removeSyncAddressees( !isXML); |
3210 | qDebug("KA: Sync::Saving remote AB "); | 3222 | qDebug("KA: Sync::Saving remote AB "); |
3211 | if ( ! abLocal.saveAB()) | 3223 | if ( ! abLocal.saveAB()) |
3212 | qDebug("KA: sync::Error writing back AB to file "); | 3224 | qDebug("KA: sync::Error writing back AB to file "); |
3213 | if ( external ) { | 3225 | if ( external ) { |
3214 | // afterwrite processing | 3226 | // afterwrite processing |
3215 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3227 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3216 | } | 3228 | } |
3217 | } | 3229 | } |
3218 | } | 3230 | } |
3219 | setModified(); | 3231 | setModified(); |
3220 | 3232 | ||
3221 | } | 3233 | } |
3222 | abLocal.removeResources(); | 3234 | abLocal.removeResources(); |
3223 | if ( syncOK ) | 3235 | if ( syncOK ) |
3224 | mViewManager->refreshView(); | 3236 | mViewManager->refreshView(); |
3225 | return syncOK; | 3237 | return syncOK; |
3226 | 3238 | ||
3227 | } | 3239 | } |
3228 | void KABCore::removeSyncInfo( QString syncProfile) | 3240 | void KABCore::removeSyncInfo( QString syncProfile) |
3229 | { | 3241 | { |
3230 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3242 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3231 | mAddressBook->removeSyncInfo( syncProfile ); | 3243 | mAddressBook->removeSyncInfo( syncProfile ); |
3232 | setModified(); | 3244 | setModified(); |
3233 | } | 3245 | } |
3234 | 3246 | ||
3235 | 3247 | ||
3236 | //this is a overwritten callbackmethods from the syncinterface | 3248 | //this is a overwritten callbackmethods from the syncinterface |
3237 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3249 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3238 | { | 3250 | { |
3239 | if ( resource == "phone" ) | 3251 | if ( resource == "phone" ) |
3240 | return syncPhone(); | 3252 | return syncPhone(); |
3241 | disableBR( true ); | 3253 | disableBR( true ); |
3242 | if ( manager != syncManager ) | 3254 | if ( manager != syncManager ) |
3243 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3255 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3244 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3256 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3245 | 3257 | ||
3246 | AddressBook abLocal( resource,"syncContact"); | 3258 | AddressBook abLocal( resource,"syncContact"); |
3247 | bool syncOK = false; | 3259 | bool syncOK = false; |
3248 | message(i18n("Loading DTM address data..."), false); | 3260 | message(i18n("Loading DTM address data..."), false); |
3249 | if ( abLocal.load() ) { | 3261 | if ( abLocal.load() ) { |
3250 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3262 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3251 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3263 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3252 | message(i18n("Sync preprocessing..."),false); | 3264 | message(i18n("Sync preprocessing..."),false); |
3253 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3265 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3254 | message(i18n("Synchronizing..."),false); | 3266 | message(i18n("Synchronizing..."),false); |
3255 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3267 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3256 | syncManager->hideProgressBar(); | 3268 | syncManager->hideProgressBar(); |
3257 | if ( syncOK ) { | 3269 | if ( syncOK ) { |
3258 | if ( syncManager->mWriteBackFile ) { | 3270 | if ( syncManager->mWriteBackFile ) { |
3259 | abLocal.removeSyncAddressees( false ); | 3271 | abLocal.removeSyncAddressees( false ); |
3260 | message(i18n("Saving DTM address data..."),false); | 3272 | message(i18n("Saving DTM address data..."),false); |
3261 | abLocal.saveAB(); | 3273 | abLocal.saveAB(); |
3262 | message(i18n("Sync postprocessing..."),false); | 3274 | message(i18n("Sync postprocessing..."),false); |
3263 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3275 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3264 | } | 3276 | } |
3265 | } else | 3277 | } else |
3266 | message( i18n("Sync cancelled or failed.") ); | 3278 | message( i18n("Sync cancelled or failed.") ); |
3267 | setModified(); | 3279 | setModified(); |
3268 | } | 3280 | } |
3269 | abLocal.removeResources(); | 3281 | abLocal.removeResources(); |
3270 | if ( syncOK ) { | 3282 | if ( syncOK ) { |
3271 | mViewManager->refreshView(); | 3283 | mViewManager->refreshView(); |
3272 | message(i18n("DTM syncing finished.")); | 3284 | message(i18n("DTM syncing finished.")); |
3273 | } | 3285 | } |
3274 | disableBR( false ); | 3286 | disableBR( false ); |
3275 | return syncOK; | 3287 | return syncOK; |
3276 | 3288 | ||
3277 | } | 3289 | } |
3278 | void KABCore::message( QString m, bool startTimer) | 3290 | void KABCore::message( QString m, bool startTimer) |
3279 | { | 3291 | { |