summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2004-10-30 01:46:35 (UTC)
committer zautrix <zautrix>2004-10-30 01:46:35 (UTC)
commit6c755a7a8a1e9d9a747267eadf914a6030c9b711 (patch) (side-by-side diff)
tree14b1b8ed39f50683f095ca5fb7656abd3326854e /kaddressbook
parentc477fa8ba7eacfaba3d154a72153acc7bc46abdc (diff)
downloadkdepimpi-6c755a7a8a1e9d9a747267eadf914a6030c9b711.zip
kdepimpi-6c755a7a8a1e9d9a747267eadf914a6030c9b711.tar.gz
kdepimpi-6c755a7a8a1e9d9a747267eadf914a6030c9b711.tar.bz2
better cat management in kapi
Diffstat (limited to 'kaddressbook') (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$
#include <qlayout.h>
#include <qclipboard.h>
#include <qtextstream.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
#include <libkdepim/categoryselectdialog.h>
+#include <libkdepim/categoryeditdialog.h>
#include <kabc/vcardconverter.h>
@@ -159,6 +162,41 @@ $Id$
#include <libkdepim/ksyncprofile.h>
#include <libkdepim/ksyncprefsdialog.h>
+
+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
{
public:
@@ -956,7 +994,11 @@ void KABCore::setWhoAmI()
if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
}
-
+void KABCore::editCategories()
+{
+ KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
+ dlg.exec();
+}
void KABCore::setCategories()
{
KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
@@ -988,7 +1030,6 @@ void KABCore::setCategories()
}
addr.setCategories( addrCategories );
}
-
mAddressBook->insertAddressee( addr );
}
}
@@ -1882,6 +1923,9 @@ void KABCore::initActions()
mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
SLOT( setCategories() ), actionCollection(),
"edit_set_categories" );
+ mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
+ SLOT( editCategories() ), actionCollection(),
+ "edit__categories" );
mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
SLOT( removeVoice() ), actionCollection(),
@@ -2050,6 +2094,7 @@ void KABCore::addActionsManually()
settingsMenu->insertSeparator();
mActionWhoAmI->plug( settingsMenu );
+ mActionEditCategories->plug( settingsMenu );
mActionCategories->plug( settingsMenu );
mActionManageCategories->plug( settingsMenu );
@@ -2107,7 +2152,63 @@ void KABCore::showLicence()
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;
}
void KABCore::removeVoice()
{
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
*/
void setCategories();
void manageCategories();
+ void editCategories();
/**
Sets the field list of the Incremental Search Widget.
@@ -452,6 +453,7 @@ class KABCore : public QWidget, public KSyncInterface
KToggleAction *mActionDetails;
KAction *mActionWhoAmI;
KAction *mActionCategories;
+ KAction *mActionEditCategories;
KAction *mActionManageCategories;
KAction *mActionAboutKAddressbook;
KAction *mActionLicence;