summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp107
1 files changed, 104 insertions, 3 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 83027ac..9505a23 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -110,76 +110,114 @@ $Id$
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118 118
119 119
120#include <kresources/selectdialog.h> 120#include <kresources/selectdialog.h>
121#include <kmessagebox.h> 121#include <kmessagebox.h>
122 122
123#include <picture.h> 123#include <picture.h>
124#include <resource.h> 124#include <resource.h>
125 125
126//US#include <qsplitter.h> 126//US#include <qsplitter.h>
127#include <qmap.h> 127#include <qmap.h>
128#include <qdir.h> 128#include <qdir.h>
129#include <qfile.h> 129#include <qfile.h>
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134#include <qradiobutton.h>
135#include <qbuttongroup.h>
134 136
135#include <libkdepim/categoryselectdialog.h> 137#include <libkdepim/categoryselectdialog.h>
138#include <libkdepim/categoryeditdialog.h>
136#include <kabc/vcardconverter.h> 139#include <kabc/vcardconverter.h>
137 140
138 141
139#include "addresseeutil.h" 142#include "addresseeutil.h"
140#include "undocmds.h" 143#include "undocmds.h"
141#include "addresseeeditordialog.h" 144#include "addresseeeditordialog.h"
142#include "viewmanager.h" 145#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 146#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 147#include "kabprefs.h"
145#include "xxportmanager.h" 148#include "xxportmanager.h"
146#include "incsearchwidget.h" 149#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 150#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 151#include "extensionmanager.h"
149#include "addresseeconfig.h" 152#include "addresseeconfig.h"
150#include <kcmultidialog.h> 153#include <kcmultidialog.h>
151 154
152#ifdef _WIN32_ 155#ifdef _WIN32_
153 156
154#include "kaimportoldialog.h" 157#include "kaimportoldialog.h"
155#else 158#else
156#include <unistd.h> 159#include <unistd.h>
157#endif 160#endif
158// sync includes 161// sync includes
159#include <libkdepim/ksyncprofile.h> 162#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 163#include <libkdepim/ksyncprefsdialog.h>
161 164
165
166class KABCatPrefs : public QDialog
167{
168 public:
169 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
170 QDialog( parent, name, true )
171 {
172 setCaption( i18n("Manage new Categories") );
173 QVBoxLayout* lay = new QVBoxLayout( this );
174 lay->setSpacing( 3 );
175 lay->setMargin( 3 );
176 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
177 lay->addWidget( lab );
178 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
179 lay->addWidget( format );
180 format->setExclusive ( true ) ;
181 addCatBut = new QRadioButton(i18n("Add to category list"), format );
182 new QRadioButton(i18n("Remove from addressees"), format );
183 addCatBut->setChecked( true );
184 QPushButton * ok = new QPushButton( i18n("OK"), this );
185 lay->addWidget( ok );
186 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
187 lay->addWidget( cancel );
188 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
189 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
190 resize( 200, 200 );
191 }
192
193 bool addCat() { return addCatBut->isChecked(); }
194private:
195 QRadioButton* addCatBut;
196};
197
198
199
162class KAex2phonePrefs : public QDialog 200class KAex2phonePrefs : public QDialog
163{ 201{
164 public: 202 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 203 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 204 QDialog( parent, name, true )
167 { 205 {
168 setCaption( i18n("Export to phone options") ); 206 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 207 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 208 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 209 lay->setMargin( 3 );
172 QLabel *lab; 210 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 211 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 212 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 213 QHBox* temphb;
176 temphb = new QHBox( this ); 214 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 215 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 216 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 217 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 218 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 219 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 220 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 221 lay->addWidget( temphb );
184 temphb = new QHBox( this ); 222 temphb = new QHBox( this );
185 new QLabel( i18n("Model(opt.): "), temphb ); 223 new QLabel( i18n("Model(opt.): "), temphb );
@@ -935,81 +973,84 @@ void KABCore::pasteContacts( KABC::Addressee::List &list )
935 KABC::Addressee::List::Iterator it; 973 KABC::Addressee::List::Iterator it;
936 for ( it = list.begin(); it != list.end(); ++it ) 974 for ( it = list.begin(); it != list.end(); ++it )
937 (*it).setResource( resource ); 975 (*it).setResource( resource );
938 976
939 PwPasteCommand *command = new PwPasteCommand( this, list ); 977 PwPasteCommand *command = new PwPasteCommand( this, list );
940 UndoStack::instance()->push( command ); 978 UndoStack::instance()->push( command );
941 RedoStack::instance()->clear(); 979 RedoStack::instance()->clear();
942 980
943 setModified( true ); 981 setModified( true );
944} 982}
945 983
946void KABCore::setWhoAmI() 984void KABCore::setWhoAmI()
947{ 985{
948 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 986 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
949 987
950 if ( addrList.count() > 1 ) { 988 if ( addrList.count() > 1 ) {
951 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 989 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
952 return; 990 return;
953 } 991 }
954 992
955 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 993 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 ) 994 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
957 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 995 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
958} 996}
959 997void KABCore::editCategories()
998{
999 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1000 dlg.exec();
1001}
960void KABCore::setCategories() 1002void KABCore::setCategories()
961{ 1003{
962 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1004 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
963 if ( !dlg.exec() ) { 1005 if ( !dlg.exec() ) {
964 message( i18n("Setting categories cancelled") ); 1006 message( i18n("Setting categories cancelled") );
965 return; 1007 return;
966 } 1008 }
967 bool merge = false; 1009 bool merge = false;
968 QString msg = i18n( "Merge with existing categories?" ); 1010 QString msg = i18n( "Merge with existing categories?" );
969 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1011 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
970 merge = true; 1012 merge = true;
971 1013
972 message( i18n("Setting categories ... please wait!") ); 1014 message( i18n("Setting categories ... please wait!") );
973 QStringList categories = dlg.selectedCategories(); 1015 QStringList categories = dlg.selectedCategories();
974 1016
975 QStringList uids = mViewManager->selectedUids(); 1017 QStringList uids = mViewManager->selectedUids();
976 QStringList::Iterator it; 1018 QStringList::Iterator it;
977 for ( it = uids.begin(); it != uids.end(); ++it ) { 1019 for ( it = uids.begin(); it != uids.end(); ++it ) {
978 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1020 KABC::Addressee addr = mAddressBook->findByUid( *it );
979 if ( !addr.isEmpty() ) { 1021 if ( !addr.isEmpty() ) {
980 if ( !merge ) 1022 if ( !merge )
981 addr.setCategories( categories ); 1023 addr.setCategories( categories );
982 else { 1024 else {
983 QStringList addrCategories = addr.categories(); 1025 QStringList addrCategories = addr.categories();
984 QStringList::Iterator catIt; 1026 QStringList::Iterator catIt;
985 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1027 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
986 if ( !addrCategories.contains( *catIt ) ) 1028 if ( !addrCategories.contains( *catIt ) )
987 addrCategories.append( *catIt ); 1029 addrCategories.append( *catIt );
988 } 1030 }
989 addr.setCategories( addrCategories ); 1031 addr.setCategories( addrCategories );
990 } 1032 }
991
992 mAddressBook->insertAddressee( addr ); 1033 mAddressBook->insertAddressee( addr );
993 } 1034 }
994 } 1035 }
995 1036
996 if ( uids.count() > 0 ) 1037 if ( uids.count() > 0 )
997 setModified( true ); 1038 setModified( true );
998 message( i18n("Setting categories completed!") ); 1039 message( i18n("Setting categories completed!") );
999} 1040}
1000 1041
1001void KABCore::setSearchFields( const KABC::Field::List &fields ) 1042void KABCore::setSearchFields( const KABC::Field::List &fields )
1002{ 1043{
1003 mIncSearchWidget->setFields( fields ); 1044 mIncSearchWidget->setFields( fields );
1004} 1045}
1005 1046
1006void KABCore::incrementalSearch( const QString& text ) 1047void KABCore::incrementalSearch( const QString& text )
1007{ 1048{
1008 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1049 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1009} 1050}
1010 1051
1011void KABCore::setModified() 1052void KABCore::setModified()
1012{ 1053{
1013 setModified( true ); 1054 setModified( true );
1014} 1055}
1015 1056
@@ -1861,48 +1902,51 @@ void KABCore::initActions()
1861 "kaddressbook_beam_rec" ); 1902 "kaddressbook_beam_rec" );
1862 1903
1863 1904
1864 // misc 1905 // misc
1865 // only enable LDAP lookup if we can handle the protocol 1906 // only enable LDAP lookup if we can handle the protocol
1866#ifndef KAB_EMBEDDED 1907#ifndef KAB_EMBEDDED
1867 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1908 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1868 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1909 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1869 this, SLOT( openLDAPDialog() ), actionCollection(), 1910 this, SLOT( openLDAPDialog() ), actionCollection(),
1870 "ldap_lookup" ); 1911 "ldap_lookup" );
1871 } 1912 }
1872#else //KAB_EMBEDDED 1913#else //KAB_EMBEDDED
1873 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1914 //qDebug("KABCore::initActions() LDAP has to be implemented");
1874#endif //KAB_EMBEDDED 1915#endif //KAB_EMBEDDED
1875 1916
1876 1917
1877 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1918 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1878 SLOT( setWhoAmI() ), actionCollection(), 1919 SLOT( setWhoAmI() ), actionCollection(),
1879 "set_personal" ); 1920 "set_personal" );
1880 1921
1881 1922
1882 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1923 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1883 SLOT( setCategories() ), actionCollection(), 1924 SLOT( setCategories() ), actionCollection(),
1884 "edit_set_categories" ); 1925 "edit_set_categories" );
1926 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
1927 SLOT( editCategories() ), actionCollection(),
1928 "edit__categories" );
1885 1929
1886 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1930 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1887 SLOT( removeVoice() ), actionCollection(), 1931 SLOT( removeVoice() ), actionCollection(),
1888 "remove_voice" ); 1932 "remove_voice" );
1889 1933
1890 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 1934 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
1891 SLOT( manageCategories() ), actionCollection(), 1935 SLOT( manageCategories() ), actionCollection(),
1892 "remove_voice" ); 1936 "remove_voice" );
1893 1937
1894 1938
1895 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1939 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1896 SLOT( importFromOL() ), actionCollection(), 1940 SLOT( importFromOL() ), actionCollection(),
1897 "import_OL" ); 1941 "import_OL" );
1898#ifdef KAB_EMBEDDED 1942#ifdef KAB_EMBEDDED
1899 mActionLicence = new KAction( i18n( "Licence" ), 0, 1943 mActionLicence = new KAction( i18n( "Licence" ), 0,
1900 this, SLOT( showLicence() ), actionCollection(), 1944 this, SLOT( showLicence() ), actionCollection(),
1901 "licence_about_data" ); 1945 "licence_about_data" );
1902 mActionFaq = new KAction( i18n( "Faq" ), 0, 1946 mActionFaq = new KAction( i18n( "Faq" ), 0,
1903 this, SLOT( faq() ), actionCollection(), 1947 this, SLOT( faq() ), actionCollection(),
1904 "faq_about_data" ); 1948 "faq_about_data" );
1905 mActionWN = new KAction( i18n( "What's New?" ), 0, 1949 mActionWN = new KAction( i18n( "What's New?" ), 0,
1906 this, SLOT( whatsnew() ), actionCollection(), 1950 this, SLOT( whatsnew() ), actionCollection(),
1907 "wn" ); 1951 "wn" );
1908 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 1952 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
@@ -2029,48 +2073,49 @@ void KABCore::addActionsManually()
2029 2073
2030 mActionConfigKAddressbook->plug( settingsMenu ); 2074 mActionConfigKAddressbook->plug( settingsMenu );
2031 2075
2032 if ( mIsPart ) { 2076 if ( mIsPart ) {
2033 //US not implemented yet 2077 //US not implemented yet
2034 //mActionConfigShortcuts->plug( settingsMenu ); 2078 //mActionConfigShortcuts->plug( settingsMenu );
2035 //mActionConfigureToolbars->plug( settingsMenu ); 2079 //mActionConfigureToolbars->plug( settingsMenu );
2036 2080
2037 } else { 2081 } else {
2038 //US not implemented yet 2082 //US not implemented yet
2039 //mActionKeyBindings->plug( settingsMenu ); 2083 //mActionKeyBindings->plug( settingsMenu );
2040 } 2084 }
2041 2085
2042 settingsMenu->insertSeparator(); 2086 settingsMenu->insertSeparator();
2043 2087
2044 mActionJumpBar->plug( settingsMenu ); 2088 mActionJumpBar->plug( settingsMenu );
2045 mActionDetails->plug( settingsMenu ); 2089 mActionDetails->plug( settingsMenu );
2046 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2090 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2047 mActionDetails->plug( tb ); 2091 mActionDetails->plug( tb );
2048 settingsMenu->insertSeparator(); 2092 settingsMenu->insertSeparator();
2049 mActionBR->plug(settingsMenu ); 2093 mActionBR->plug(settingsMenu );
2050 settingsMenu->insertSeparator(); 2094 settingsMenu->insertSeparator();
2051 2095
2052 mActionWhoAmI->plug( settingsMenu ); 2096 mActionWhoAmI->plug( settingsMenu );
2097 mActionEditCategories->plug( settingsMenu );
2053 mActionCategories->plug( settingsMenu ); 2098 mActionCategories->plug( settingsMenu );
2054 mActionManageCategories->plug( settingsMenu ); 2099 mActionManageCategories->plug( settingsMenu );
2055 2100
2056 2101
2057 mActionWN->plug( helpMenu ); 2102 mActionWN->plug( helpMenu );
2058 mActionSyncHowto->plug( helpMenu ); 2103 mActionSyncHowto->plug( helpMenu );
2059 mActionKdeSyncHowto->plug( helpMenu ); 2104 mActionKdeSyncHowto->plug( helpMenu );
2060 mActionMultiSyncHowto->plug( helpMenu ); 2105 mActionMultiSyncHowto->plug( helpMenu );
2061 mActionFaq->plug( helpMenu ); 2106 mActionFaq->plug( helpMenu );
2062 mActionLicence->plug( helpMenu ); 2107 mActionLicence->plug( helpMenu );
2063 mActionAboutKAddressbook->plug( helpMenu ); 2108 mActionAboutKAddressbook->plug( helpMenu );
2064 2109
2065 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2110 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2066 2111
2067 mActionSave->plug( tb ); 2112 mActionSave->plug( tb );
2068 mViewManager->getFilterAction()->plug ( tb); 2113 mViewManager->getFilterAction()->plug ( tb);
2069 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2114 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2070 mActionUndo->plug( tb ); 2115 mActionUndo->plug( tb );
2071 mActionDelete->plug( tb ); 2116 mActionDelete->plug( tb );
2072 mActionRedo->plug( tb ); 2117 mActionRedo->plug( tb );
2073 } 2118 }
2074 } else { 2119 } else {
2075 mActionSave->plug( tb ); 2120 mActionSave->plug( tb );
2076 tb->enableMoving(false); 2121 tb->enableMoving(false);
@@ -2086,49 +2131,105 @@ void KABCore::addActionsManually()
2086 mIncSearchWidget = new IncSearchWidget( tb ); 2131 mIncSearchWidget = new IncSearchWidget( tb );
2087 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2132 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2088 SLOT( incrementalSearch( const QString& ) ) ); 2133 SLOT( incrementalSearch( const QString& ) ) );
2089 2134
2090 mJumpButtonBar = new JumpButtonBar( this, this ); 2135 mJumpButtonBar = new JumpButtonBar( this, this );
2091 2136
2092//US topLayout->addWidget( mJumpButtonBar ); 2137//US topLayout->addWidget( mJumpButtonBar );
2093 this->layout()->add( mJumpButtonBar ); 2138 this->layout()->add( mJumpButtonBar );
2094*/ 2139*/
2095 2140
2096#endif //KAB_EMBEDDED 2141#endif //KAB_EMBEDDED
2097 2142
2098 mActionExport2phone->plug( ExportMenu ); 2143 mActionExport2phone->plug( ExportMenu );
2099 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2144 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2100 syncManager->fillSyncMenu(); 2145 syncManager->fillSyncMenu();
2101 2146
2102} 2147}
2103void KABCore::showLicence() 2148void KABCore::showLicence()
2104{ 2149{
2105 KApplication::showLicence(); 2150 KApplication::showLicence();
2106} 2151}
2107 2152
2108void KABCore::manageCategories( ) 2153void KABCore::manageCategories( )
2109{ 2154{
2110 2155 KABCatPrefs* cp = new KABCatPrefs();
2156 cp->show();
2157 int w =cp->sizeHint().width() ;
2158 int h = cp->sizeHint().height() ;
2159 int dw = QApplication::desktop()->width();
2160 int dh = QApplication::desktop()->height();
2161 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2162 if ( !cp->exec() ) {
2163 delete cp;
2164 return;
2165 }
2166 int count = 0;
2167 message( i18n("Please wait, processing categories..."));
2168 if ( cp->addCat() ) {
2169 KABC::AddressBook::Iterator it;
2170 QStringList catList = KABPrefs::instance()->mCustomCategories;
2171 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2172 QStringList catIncList = (*it).categories();
2173 int i;
2174 for( i = 0; i< catIncList.count(); ++i ) {
2175 if ( !catList.contains (catIncList[i])) {
2176 catList.append( catIncList[i] );
2177 //qDebug("add cat %s ", catIncList[i].latin1());
2178 ++count;
2179 }
2180 }
2181 }
2182 catList.sort();
2183 KABPrefs::instance()->mCustomCategories = catList;
2184 KABPrefs::instance()->writeConfig();
2185 message(QString::number( count )+ i18n(" categories added to list! "));
2186 } else {
2187 QStringList catList = KABPrefs::instance()->mCustomCategories;
2188 QStringList catIncList;
2189 QStringList newCatList;
2190 KABC::AddressBook::Iterator it;
2191 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2192 QStringList catIncList = (*it).categories();
2193 int i;
2194 if ( catIncList.count() ) {
2195 newCatList.clear();
2196 for( i = 0; i< catIncList.count(); ++i ) {
2197 if ( catList.contains (catIncList[i])) {
2198 newCatList.append( catIncList[i] );
2199 }
2200 }
2201 newCatList.sort();
2202 (*it).setCategories( newCatList );
2203 mAddressBook->insertAddressee( (*it) );
2204 }
2205 }
2206 setModified( true );
2207 mViewManager->refreshView();
2208 mDetails->refreshView();
2209 message( i18n("Removing categories done!"));
2210 }
2211 delete cp;
2111} 2212}
2112void KABCore::removeVoice() 2213void KABCore::removeVoice()
2113{ 2214{
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 ) 2215 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 )
2115 return; 2216 return;
2116 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2217 KABC::Addressee::List list = mViewManager->selectedAddressees();
2117 KABC::Addressee::List::Iterator it; 2218 KABC::Addressee::List::Iterator it;
2118 for ( it = list.begin(); it != list.end(); ++it ) { 2219 for ( it = list.begin(); it != list.end(); ++it ) {
2119 2220
2120 if ( (*it).removeVoice() ) 2221 if ( (*it).removeVoice() )
2121 contactModified((*it) ); 2222 contactModified((*it) );
2122 } 2223 }
2123} 2224}
2124 2225
2125 2226
2126 2227
2127void KABCore::clipboardDataChanged() 2228void KABCore::clipboardDataChanged()
2128{ 2229{
2129 2230
2130 if ( mReadWrite ) 2231 if ( mReadWrite )
2131 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2232 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2132 2233
2133} 2234}
2134 2235