summaryrefslogtreecommitdiffabout
Side-by-side diff
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
@@ -128,14 +128,17 @@ $Id$
#include <qdir.h>
#include <qfile.h>
#include <qvbox.h>
#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>
#include "addresseeutil.h"
#include "undocmds.h"
#include "addresseeeditordialog.h"
@@ -156,12 +159,47 @@ $Id$
#include <unistd.h>
#endif
// sync includes
#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:
KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
QDialog( parent, name, true )
{
@@ -953,13 +991,17 @@ void KABCore::setWhoAmI()
}
QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
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 );
if ( !dlg.exec() ) {
message( i18n("Setting categories cancelled") );
return;
@@ -985,13 +1027,12 @@ void KABCore::setCategories()
for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
if ( !addrCategories.contains( *catIt ) )
addrCategories.append( *catIt );
}
addr.setCategories( addrCategories );
}
-
mAddressBook->insertAddressee( addr );
}
}
if ( uids.count() > 0 )
setModified( true );
@@ -1879,12 +1920,15 @@ void KABCore::initActions()
"set_personal" );
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(),
"remove_voice" );
mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
@@ -2047,12 +2091,13 @@ void KABCore::addActionsManually()
mActionDetails->plug( tb );
settingsMenu->insertSeparator();
mActionBR->plug(settingsMenu );
settingsMenu->insertSeparator();
mActionWhoAmI->plug( settingsMenu );
+ mActionEditCategories->plug( settingsMenu );
mActionCategories->plug( settingsMenu );
mActionManageCategories->plug( settingsMenu );
mActionWN->plug( helpMenu );
mActionSyncHowto->plug( helpMenu );
@@ -2104,13 +2149,69 @@ void KABCore::showLicence()
{
KApplication::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()
{
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 )
return;
KABC::Addressee::List list = mViewManager->selectedAddressees();
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index bf5398b..d2ee45d 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -241,12 +241,13 @@ class KABCore : public QWidget, public KSyncInterface
/**
Displays the category dialog and applies the result to all
selected contacts.
*/
void setCategories();
void manageCategories();
+ void editCategories();
/**
Sets the field list of the Incremental Search Widget.
*/
void setSearchFields( const KABC::Field::List &fields );
@@ -449,12 +450,13 @@ class KABCore : public QWidget, public KSyncInterface
KAction *mActionConfigureToolbars;
KAction *mActionKeyBindings;
KToggleAction *mActionJumpBar;
KToggleAction *mActionDetails;
KAction *mActionWhoAmI;
KAction *mActionCategories;
+ KAction *mActionEditCategories;
KAction *mActionManageCategories;
KAction *mActionAboutKAddressbook;
KAction *mActionLicence;
KAction *mActionFaq;
KAction *mActionWN;
KAction *mActionSyncHowto;