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
@@ -133,4 +133,7 @@ $Id$
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>
@@ -161,2 +164,37 @@ $Id$
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
@@ -958,3 +996,7 @@ void KABCore::setWhoAmI()
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()
@@ -990,3 +1032,2 @@ void KABCore::setCategories()
990 } 1032 }
991
992 mAddressBook->insertAddressee( addr ); 1033 mAddressBook->insertAddressee( addr );
@@ -1884,2 +1925,5 @@ void KABCore::initActions()
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
@@ -2052,2 +2096,3 @@ void KABCore::addActionsManually()
2052 mActionWhoAmI->plug( settingsMenu ); 2096 mActionWhoAmI->plug( settingsMenu );
2097 mActionEditCategories->plug( settingsMenu );
2053 mActionCategories->plug( settingsMenu ); 2098 mActionCategories->plug( settingsMenu );
@@ -2109,3 +2154,59 @@ void 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}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index bf5398b..d2ee45d 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -246,2 +246,3 @@ class KABCore : public QWidget, public KSyncInterface
246 void manageCategories(); 246 void manageCategories();
247 void editCategories();
247 248
@@ -454,2 +455,3 @@ class KABCore : public QWidget, public KSyncInterface
454 KAction *mActionCategories; 455 KAction *mActionCategories;
456 KAction *mActionEditCategories;
455 KAction *mActionManageCategories; 457 KAction *mActionManageCategories;