summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp107
-rw-r--r--kaddressbook/kabcore.h2
2 files changed, 106 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
@@ -131,8 +131,11 @@ $Id$
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
@@ -159,6 +162,41 @@ $Id$
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:
@@ -956,7 +994,11 @@ void KABCore::setWhoAmI()
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 );
@@ -988,7 +1030,6 @@ void KABCore::setCategories()
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 }
@@ -1882,6 +1923,9 @@ void KABCore::initActions()
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(),
@@ -2050,6 +2094,7 @@ void KABCore::addActionsManually()
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
@@ -2107,7 +2152,63 @@ void KABCore::showLicence()
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{
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index bf5398b..d2ee45d 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -244,6 +244,7 @@ class KABCore : public QWidget, public KSyncInterface
244 */ 244 */
245 void setCategories(); 245 void setCategories();
246 void manageCategories(); 246 void manageCategories();
247 void editCategories();
247 248
248 /** 249 /**
249 Sets the field list of the Incremental Search Widget. 250 Sets the field list of the Incremental Search Widget.
@@ -452,6 +453,7 @@ class KABCore : public QWidget, public KSyncInterface
452 KToggleAction *mActionDetails; 453 KToggleAction *mActionDetails;
453 KAction *mActionWhoAmI; 454 KAction *mActionWhoAmI;
454 KAction *mActionCategories; 455 KAction *mActionCategories;
456 KAction *mActionEditCategories;
455 KAction *mActionManageCategories; 457 KAction *mActionManageCategories;
456 KAction *mActionAboutKAddressbook; 458 KAction *mActionAboutKAddressbook;
457 KAction *mActionLicence; 459 KAction *mActionLicence;