summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show 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$
#include <qtextstream.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
#include <libkdepim/categoryselectdialog.h>
+#include <libkdepim/categoryeditdialog.h>
#include <kabc/vcardconverter.h>
@@ -161,2 +164,37 @@ $Id$
+
+class KABCatPrefs : public QDialog
+{
+ public:
+ KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
+ QDialog( parent, name, true )
+ {
+ setCaption( i18n("Manage new Categories") );
+ QVBoxLayout* lay = new QVBoxLayout( this );
+ lay->setSpacing( 3 );
+ lay->setMargin( 3 );
+ 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 );
+ lay->addWidget( lab );
+ QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
+ lay->addWidget( format );
+ format->setExclusive ( true ) ;
+ addCatBut = new QRadioButton(i18n("Add to category list"), format );
+ new QRadioButton(i18n("Remove from addressees"), format );
+ addCatBut->setChecked( true );
+ QPushButton * ok = new QPushButton( i18n("OK"), this );
+ lay->addWidget( ok );
+ QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
+ lay->addWidget( cancel );
+ connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
+ connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
+ resize( 200, 200 );
+ }
+
+ bool addCat() { return addCatBut->isChecked(); }
+private:
+ QRadioButton* addCatBut;
+};
+
+
+
class KAex2phonePrefs : public QDialog
@@ -958,3 +996,7 @@ void KABCore::setWhoAmI()
}
-
+void KABCore::editCategories()
+{
+ KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
+ dlg.exec();
+}
void KABCore::setCategories()
@@ -990,3 +1032,2 @@ void KABCore::setCategories()
}
-
mAddressBook->insertAddressee( addr );
@@ -1884,2 +1925,5 @@ void KABCore::initActions()
"edit_set_categories" );
+ mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
+ SLOT( editCategories() ), actionCollection(),
+ "edit__categories" );
@@ -2052,2 +2096,3 @@ void KABCore::addActionsManually()
mActionWhoAmI->plug( settingsMenu );
+ mActionEditCategories->plug( settingsMenu );
mActionCategories->plug( settingsMenu );
@@ -2109,3 +2154,59 @@ void KABCore::manageCategories( )
{
-
+ KABCatPrefs* cp = new KABCatPrefs();
+ cp->show();
+ int w =cp->sizeHint().width() ;
+ int h = cp->sizeHint().height() ;
+ int dw = QApplication::desktop()->width();
+ int dh = QApplication::desktop()->height();
+ cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+ if ( !cp->exec() ) {
+ delete cp;
+ return;
+ }
+ int count = 0;
+ message( i18n("Please wait, processing categories..."));
+ if ( cp->addCat() ) {
+ KABC::AddressBook::Iterator it;
+ QStringList catList = KABPrefs::instance()->mCustomCategories;
+ for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
+ QStringList catIncList = (*it).categories();
+ int i;
+ for( i = 0; i< catIncList.count(); ++i ) {
+ if ( !catList.contains (catIncList[i])) {
+ catList.append( catIncList[i] );
+ //qDebug("add cat %s ", catIncList[i].latin1());
+ ++count;
+ }
+ }
+ }
+ catList.sort();
+ KABPrefs::instance()->mCustomCategories = catList;
+ KABPrefs::instance()->writeConfig();
+ message(QString::number( count )+ i18n(" categories added to list! "));
+ } else {
+ QStringList catList = KABPrefs::instance()->mCustomCategories;
+ QStringList catIncList;
+ QStringList newCatList;
+ KABC::AddressBook::Iterator it;
+ for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
+ QStringList catIncList = (*it).categories();
+ int i;
+ if ( catIncList.count() ) {
+ newCatList.clear();
+ for( i = 0; i< catIncList.count(); ++i ) {
+ if ( catList.contains (catIncList[i])) {
+ newCatList.append( catIncList[i] );
+ }
+ }
+ newCatList.sort();
+ (*it).setCategories( newCatList );
+ mAddressBook->insertAddressee( (*it) );
+ }
+ }
+ setModified( true );
+ mViewManager->refreshView();
+ mDetails->refreshView();
+ message( i18n("Removing categories done!"));
+ }
+ delete cp;
}
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
void manageCategories();
+ void editCategories();
@@ -454,2 +455,3 @@ class KABCore : public QWidget, public KSyncInterface
KAction *mActionCategories;
+ KAction *mActionEditCategories;
KAction *mActionManageCategories;