summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp61
1 files changed, 12 insertions, 49 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 2c2f1a0..83027ac 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -939,81 +939,84 @@ void KABCore::pasteContacts( KABC::Addressee::List &list )
939 PwPasteCommand *command = new PwPasteCommand( this, list ); 939 PwPasteCommand *command = new PwPasteCommand( this, list );
940 UndoStack::instance()->push( command ); 940 UndoStack::instance()->push( command );
941 RedoStack::instance()->clear(); 941 RedoStack::instance()->clear();
942 942
943 setModified( true ); 943 setModified( true );
944} 944}
945 945
946void KABCore::setWhoAmI() 946void KABCore::setWhoAmI()
947{ 947{
948 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 948 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
949 949
950 if ( addrList.count() > 1 ) { 950 if ( addrList.count() > 1 ) {
951 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 951 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
952 return; 952 return;
953 } 953 }
954 954
955 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 955 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
956 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 956 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
957 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 957 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
958} 958}
959 959
960void KABCore::setCategories() 960void KABCore::setCategories()
961{ 961{
962 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 962 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
963 if ( !dlg.exec() ) 963 if ( !dlg.exec() ) {
964 return; 964 message( i18n("Setting categories cancelled") );
965 965 return;
966 }
966 bool merge = false; 967 bool merge = false;
967 QString msg = i18n( "Merge with existing categories?" ); 968 QString msg = i18n( "Merge with existing categories?" );
968 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 969 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
969 merge = true; 970 merge = true;
970 971
972 message( i18n("Setting categories ... please wait!") );
971 QStringList categories = dlg.selectedCategories(); 973 QStringList categories = dlg.selectedCategories();
972 974
973 QStringList uids = mViewManager->selectedUids(); 975 QStringList uids = mViewManager->selectedUids();
974 QStringList::Iterator it; 976 QStringList::Iterator it;
975 for ( it = uids.begin(); it != uids.end(); ++it ) { 977 for ( it = uids.begin(); it != uids.end(); ++it ) {
976 KABC::Addressee addr = mAddressBook->findByUid( *it ); 978 KABC::Addressee addr = mAddressBook->findByUid( *it );
977 if ( !addr.isEmpty() ) { 979 if ( !addr.isEmpty() ) {
978 if ( !merge ) 980 if ( !merge )
979 addr.setCategories( categories ); 981 addr.setCategories( categories );
980 else { 982 else {
981 QStringList addrCategories = addr.categories(); 983 QStringList addrCategories = addr.categories();
982 QStringList::Iterator catIt; 984 QStringList::Iterator catIt;
983 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 985 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
984 if ( !addrCategories.contains( *catIt ) ) 986 if ( !addrCategories.contains( *catIt ) )
985 addrCategories.append( *catIt ); 987 addrCategories.append( *catIt );
986 } 988 }
987 addr.setCategories( addrCategories ); 989 addr.setCategories( addrCategories );
988 } 990 }
989 991
990 mAddressBook->insertAddressee( addr ); 992 mAddressBook->insertAddressee( addr );
991 } 993 }
992 } 994 }
993 995
994 if ( uids.count() > 0 ) 996 if ( uids.count() > 0 )
995 setModified( true ); 997 setModified( true );
998 message( i18n("Setting categories completed!") );
996} 999}
997 1000
998void KABCore::setSearchFields( const KABC::Field::List &fields ) 1001void KABCore::setSearchFields( const KABC::Field::List &fields )
999{ 1002{
1000 mIncSearchWidget->setFields( fields ); 1003 mIncSearchWidget->setFields( fields );
1001} 1004}
1002 1005
1003void KABCore::incrementalSearch( const QString& text ) 1006void KABCore::incrementalSearch( const QString& text )
1004{ 1007{
1005 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1008 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1006} 1009}
1007 1010
1008void KABCore::setModified() 1011void KABCore::setModified()
1009{ 1012{
1010 setModified( true ); 1013 setModified( true );
1011} 1014}
1012 1015
1013void KABCore::setModifiedWOrefresh() 1016void KABCore::setModifiedWOrefresh()
1014{ 1017{
1015 // qDebug("KABCore::setModifiedWOrefresh() "); 1018 // qDebug("KABCore::setModifiedWOrefresh() ");
1016 mModified = true; 1019 mModified = true;
1017 mActionSave->setEnabled( mModified ); 1020 mActionSave->setEnabled( mModified );
1018#ifdef DESKTOP_VERSION 1021#ifdef DESKTOP_VERSION
1019 mDetails->refreshView(); 1022 mDetails->refreshView();
@@ -1863,57 +1866,53 @@ void KABCore::initActions()
1863#ifndef KAB_EMBEDDED 1866#ifndef KAB_EMBEDDED
1864 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1867 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1865 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1868 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1866 this, SLOT( openLDAPDialog() ), actionCollection(), 1869 this, SLOT( openLDAPDialog() ), actionCollection(),
1867 "ldap_lookup" ); 1870 "ldap_lookup" );
1868 } 1871 }
1869#else //KAB_EMBEDDED 1872#else //KAB_EMBEDDED
1870 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1873 //qDebug("KABCore::initActions() LDAP has to be implemented");
1871#endif //KAB_EMBEDDED 1874#endif //KAB_EMBEDDED
1872 1875
1873 1876
1874 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1877 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1875 SLOT( setWhoAmI() ), actionCollection(), 1878 SLOT( setWhoAmI() ), actionCollection(),
1876 "set_personal" ); 1879 "set_personal" );
1877 1880
1878 1881
1879 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1882 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1880 SLOT( setCategories() ), actionCollection(), 1883 SLOT( setCategories() ), actionCollection(),
1881 "edit_set_categories" ); 1884 "edit_set_categories" );
1882 1885
1883 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1886 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1884 SLOT( removeVoice() ), actionCollection(), 1887 SLOT( removeVoice() ), actionCollection(),
1885 "remove_voice" ); 1888 "remove_voice" );
1886 1889
1887 mActionSetCat= new KAction( i18n( "Set categories..." ), 0, this, 1890 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
1888 SLOT( setCat() ), actionCollection(), 1891 SLOT( manageCategories() ), actionCollection(),
1889 "remove_voice" ); 1892 "remove_voice" );
1890 1893
1891 1894
1892 mActionAddCat= new KAction( i18n( "Add categories..." ), 0, this,
1893 SLOT( addCat() ), actionCollection(),
1894 "remove_voice" );
1895
1896 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1895 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1897 SLOT( importFromOL() ), actionCollection(), 1896 SLOT( importFromOL() ), actionCollection(),
1898 "import_OL" ); 1897 "import_OL" );
1899#ifdef KAB_EMBEDDED 1898#ifdef KAB_EMBEDDED
1900 mActionLicence = new KAction( i18n( "Licence" ), 0, 1899 mActionLicence = new KAction( i18n( "Licence" ), 0,
1901 this, SLOT( showLicence() ), actionCollection(), 1900 this, SLOT( showLicence() ), actionCollection(),
1902 "licence_about_data" ); 1901 "licence_about_data" );
1903 mActionFaq = new KAction( i18n( "Faq" ), 0, 1902 mActionFaq = new KAction( i18n( "Faq" ), 0,
1904 this, SLOT( faq() ), actionCollection(), 1903 this, SLOT( faq() ), actionCollection(),
1905 "faq_about_data" ); 1904 "faq_about_data" );
1906 mActionWN = new KAction( i18n( "What's New?" ), 0, 1905 mActionWN = new KAction( i18n( "What's New?" ), 0,
1907 this, SLOT( whatsnew() ), actionCollection(), 1906 this, SLOT( whatsnew() ), actionCollection(),
1908 "wn" ); 1907 "wn" );
1909 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 1908 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
1910 this, SLOT( synchowto() ), actionCollection(), 1909 this, SLOT( synchowto() ), actionCollection(),
1911 "sync" ); 1910 "sync" );
1912 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 1911 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
1913 this, SLOT( kdesynchowto() ), actionCollection(), 1912 this, SLOT( kdesynchowto() ), actionCollection(),
1914 "kdesync" ); 1913 "kdesync" );
1915 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 1914 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
1916 this, SLOT( multisynchowto() ), actionCollection(), 1915 this, SLOT( multisynchowto() ), actionCollection(),
1917 "multisync" ); 1916 "multisync" );
1918 1917
1919 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1918 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
@@ -2001,80 +2000,79 @@ void KABCore::addActionsManually()
2001 fileMenu->insertItem( "&Export", ExportMenu ); 2000 fileMenu->insertItem( "&Export", ExportMenu );
2002 fileMenu->insertSeparator(); 2001 fileMenu->insertSeparator();
2003 mActionMailVCard->plug( fileMenu ); 2002 mActionMailVCard->plug( fileMenu );
2004#ifndef DESKTOP_VERSION 2003#ifndef DESKTOP_VERSION
2005 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 2004 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
2006 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 2005 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
2007#endif 2006#endif
2008 fileMenu->insertSeparator(); 2007 fileMenu->insertSeparator();
2009 mActionQuit->plug( fileMenu ); 2008 mActionQuit->plug( fileMenu );
2010#ifdef _WIN32_ 2009#ifdef _WIN32_
2011 mActionImportOL->plug( ImportMenu ); 2010 mActionImportOL->plug( ImportMenu );
2012#endif 2011#endif
2013 // edit menu 2012 // edit menu
2014 mActionUndo->plug( editMenu ); 2013 mActionUndo->plug( editMenu );
2015 mActionRedo->plug( editMenu ); 2014 mActionRedo->plug( editMenu );
2016 editMenu->insertSeparator(); 2015 editMenu->insertSeparator();
2017 mActionCut->plug( editMenu ); 2016 mActionCut->plug( editMenu );
2018 mActionCopy->plug( editMenu ); 2017 mActionCopy->plug( editMenu );
2019 mActionPaste->plug( editMenu ); 2018 mActionPaste->plug( editMenu );
2020 mActionDelete->plug( editMenu ); 2019 mActionDelete->plug( editMenu );
2021 editMenu->insertSeparator(); 2020 editMenu->insertSeparator();
2022 mActionSelectAll->plug( editMenu ); 2021 mActionSelectAll->plug( editMenu );
2023 2022
2024 mActionRemoveVoice->plug( changeMenu ); 2023 mActionRemoveVoice->plug( changeMenu );
2025 mActionSetCat->plug( changeMenu );
2026 mActionAddCat->plug( changeMenu );
2027 // settings menu 2024 // settings menu
2028//US special menuentry to configure the addressbook resources. On KDE 2025//US special menuentry to configure the addressbook resources. On KDE
2029// you do that through the control center !!! 2026// you do that through the control center !!!
2030 mActionConfigResources->plug( settingsMenu ); 2027 mActionConfigResources->plug( settingsMenu );
2031 settingsMenu->insertSeparator(); 2028 settingsMenu->insertSeparator();
2032 2029
2033 mActionConfigKAddressbook->plug( settingsMenu ); 2030 mActionConfigKAddressbook->plug( settingsMenu );
2034 2031
2035 if ( mIsPart ) { 2032 if ( mIsPart ) {
2036 //US not implemented yet 2033 //US not implemented yet
2037 //mActionConfigShortcuts->plug( settingsMenu ); 2034 //mActionConfigShortcuts->plug( settingsMenu );
2038 //mActionConfigureToolbars->plug( settingsMenu ); 2035 //mActionConfigureToolbars->plug( settingsMenu );
2039 2036
2040 } else { 2037 } else {
2041 //US not implemented yet 2038 //US not implemented yet
2042 //mActionKeyBindings->plug( settingsMenu ); 2039 //mActionKeyBindings->plug( settingsMenu );
2043 } 2040 }
2044 2041
2045 settingsMenu->insertSeparator(); 2042 settingsMenu->insertSeparator();
2046 2043
2047 mActionJumpBar->plug( settingsMenu ); 2044 mActionJumpBar->plug( settingsMenu );
2048 mActionDetails->plug( settingsMenu ); 2045 mActionDetails->plug( settingsMenu );
2049 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2046 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2050 mActionDetails->plug( tb ); 2047 mActionDetails->plug( tb );
2051 settingsMenu->insertSeparator(); 2048 settingsMenu->insertSeparator();
2052 mActionBR->plug(settingsMenu ); 2049 mActionBR->plug(settingsMenu );
2053 settingsMenu->insertSeparator(); 2050 settingsMenu->insertSeparator();
2054 2051
2055 mActionWhoAmI->plug( settingsMenu ); 2052 mActionWhoAmI->plug( settingsMenu );
2056 mActionCategories->plug( settingsMenu ); 2053 mActionCategories->plug( settingsMenu );
2054 mActionManageCategories->plug( settingsMenu );
2057 2055
2058 2056
2059 mActionWN->plug( helpMenu ); 2057 mActionWN->plug( helpMenu );
2060 mActionSyncHowto->plug( helpMenu ); 2058 mActionSyncHowto->plug( helpMenu );
2061 mActionKdeSyncHowto->plug( helpMenu ); 2059 mActionKdeSyncHowto->plug( helpMenu );
2062 mActionMultiSyncHowto->plug( helpMenu ); 2060 mActionMultiSyncHowto->plug( helpMenu );
2063 mActionFaq->plug( helpMenu ); 2061 mActionFaq->plug( helpMenu );
2064 mActionLicence->plug( helpMenu ); 2062 mActionLicence->plug( helpMenu );
2065 mActionAboutKAddressbook->plug( helpMenu ); 2063 mActionAboutKAddressbook->plug( helpMenu );
2066 2064
2067 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2065 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2068 2066
2069 mActionSave->plug( tb ); 2067 mActionSave->plug( tb );
2070 mViewManager->getFilterAction()->plug ( tb); 2068 mViewManager->getFilterAction()->plug ( tb);
2071 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2069 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2072 mActionUndo->plug( tb ); 2070 mActionUndo->plug( tb );
2073 mActionDelete->plug( tb ); 2071 mActionDelete->plug( tb );
2074 mActionRedo->plug( tb ); 2072 mActionRedo->plug( tb );
2075 } 2073 }
2076 } else { 2074 } else {
2077 mActionSave->plug( tb ); 2075 mActionSave->plug( tb );
2078 tb->enableMoving(false); 2076 tb->enableMoving(false);
2079 } 2077 }
2080 //mActionQuit->plug ( tb ); 2078 //mActionQuit->plug ( tb );
@@ -2085,87 +2083,52 @@ void KABCore::addActionsManually()
2085//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2083//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2086//US tb->insertItem( mIncSearchWidget ); 2084//US tb->insertItem( mIncSearchWidget );
2087/*US 2085/*US
2088 mIncSearchWidget = new IncSearchWidget( tb ); 2086 mIncSearchWidget = new IncSearchWidget( tb );
2089 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2087 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2090 SLOT( incrementalSearch( const QString& ) ) ); 2088 SLOT( incrementalSearch( const QString& ) ) );
2091 2089
2092 mJumpButtonBar = new JumpButtonBar( this, this ); 2090 mJumpButtonBar = new JumpButtonBar( this, this );
2093 2091
2094//US topLayout->addWidget( mJumpButtonBar ); 2092//US topLayout->addWidget( mJumpButtonBar );
2095 this->layout()->add( mJumpButtonBar ); 2093 this->layout()->add( mJumpButtonBar );
2096*/ 2094*/
2097 2095
2098#endif //KAB_EMBEDDED 2096#endif //KAB_EMBEDDED
2099 2097
2100 mActionExport2phone->plug( ExportMenu ); 2098 mActionExport2phone->plug( ExportMenu );
2101 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2099 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2102 syncManager->fillSyncMenu(); 2100 syncManager->fillSyncMenu();
2103 2101
2104} 2102}
2105void KABCore::showLicence() 2103void KABCore::showLicence()
2106{ 2104{
2107 KApplication::showLicence(); 2105 KApplication::showLicence();
2108} 2106}
2109void KABCore::setCat() 2107
2110{ 2108void KABCore::manageCategories( )
2111 setCategories( true );
2112}
2113void KABCore::addCat()
2114{
2115 setCategories( false );
2116}
2117void KABCore::setCategories( bool removeOld )
2118{ 2109{
2119 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KABPrefs::instance(), 0 ); 2110
2120 if (! csd->exec()) {
2121 message( i18n("Setting categories cancelled") );
2122 delete csd;
2123 return;
2124 }
2125 message( i18n("Setting categories ... please wait!") );
2126 QStringList catList = csd->selectedCategories();
2127 delete csd;
2128 catList.sort();
2129 QStringList newList;
2130 KABC::Addressee::List list = mViewManager->selectedAddressees();
2131 KABC::Addressee::List::Iterator it;
2132 for ( it = list.begin(); it != list.end(); ++it ) {
2133 if ( removeOld ) {
2134 (*it).setCategories( catList );
2135 } else {
2136 newList = (*it).categories();
2137 int i;
2138 for( i = 0; i< catList.count(); ++i ) {
2139 if ( !newList.contains (catList[i]))
2140 newList.append( catList[i] );
2141 }
2142 newList.sort();
2143 (*it).setCategories( newList );
2144 }
2145 contactModified((*it) );
2146 }
2147 message( i18n("Setting categories completed!") );
2148} 2111}
2149void KABCore::removeVoice() 2112void KABCore::removeVoice()
2150{ 2113{
2151 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 ) 2114 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 )
2152 return; 2115 return;
2153 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2116 KABC::Addressee::List list = mViewManager->selectedAddressees();
2154 KABC::Addressee::List::Iterator it; 2117 KABC::Addressee::List::Iterator it;
2155 for ( it = list.begin(); it != list.end(); ++it ) { 2118 for ( it = list.begin(); it != list.end(); ++it ) {
2156 2119
2157 if ( (*it).removeVoice() ) 2120 if ( (*it).removeVoice() )
2158 contactModified((*it) ); 2121 contactModified((*it) );
2159 } 2122 }
2160} 2123}
2161 2124
2162 2125
2163 2126
2164void KABCore::clipboardDataChanged() 2127void KABCore::clipboardDataChanged()
2165{ 2128{
2166 2129
2167 if ( mReadWrite ) 2130 if ( mReadWrite )
2168 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2131 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2169 2132
2170} 2133}
2171 2134