summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp4
-rw-r--r--kabc/addressee.h2
-rw-r--r--kabc/field.cpp6
-rw-r--r--kaddressbook/kabcore.cpp54
-rw-r--r--kaddressbook/kabcore.h5
5 files changed, 68 insertions, 3 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index eec0f1f..3ce733d 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1996,6 +1996,10 @@ QString Addressee::resourceLabel()
{
return i18n("Resource");
}
+QString Addressee::categoryLabel()
+{
+ return i18n("Category");
+}
void Addressee::setChanged( bool value )
{
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 2c81c1a..08d2f56 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -823,7 +823,7 @@ class Addressee
*/
//US
static QString resourceLabel();
-
+ static QString categoryLabel();
/**
Mark addressee as changed.
*/
diff --git a/kabc/field.cpp b/kabc/field.cpp
index d95cd19..89d0b77 100644
--- a/kabc/field.cpp
+++ b/kabc/field.cpp
@@ -57,6 +57,7 @@ class Field::FieldImpl
Suffix,
NickName,
Birthday,
+ Category,
HomeAddressStreet,
HomeAddressLocality,
HomeAddressRegion,
@@ -195,6 +196,8 @@ QString Field::label()
return Addressee::urlLabel();
case FieldImpl::Resource:
return Addressee::resourceLabel();
+ case FieldImpl::Category:
+ return Addressee::categoryLabel();
case FieldImpl::Sip:
return Addressee::sipLabel();
case FieldImpl::CustomField:
@@ -277,6 +280,8 @@ QString Field::value( const KABC::Addressee &a )
//US
case FieldImpl::Resource:
return a.resource()->resourceName();
+ case FieldImpl::Category:
+ return a.categories().join(",");
case FieldImpl::HomePhone:
return a.phoneNumber( PhoneNumber::Home ).number();
case FieldImpl::BusinessPhone:
@@ -395,6 +400,7 @@ Field::List Field::allFields()
createField( FieldImpl::Suffix );
createField( FieldImpl::NickName, Personal );
createField( FieldImpl::Birthday, Personal );
+ createField( FieldImpl::Category );
createField( FieldImpl::HomeAddressStreet, Address|Personal );
createField( FieldImpl::HomeAddressLocality, Address|Personal );
createField( FieldImpl::HomeAddressRegion, Address|Personal );
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index e6bdde9..2c2f1a0 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1876,8 +1876,6 @@ void KABCore::initActions()
"set_personal" );
-
-
mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
SLOT( setCategories() ), actionCollection(),
"edit_set_categories" );
@@ -1885,6 +1883,16 @@ void KABCore::initActions()
mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
SLOT( removeVoice() ), actionCollection(),
"remove_voice" );
+
+ mActionSetCat= new KAction( i18n( "Set categories..." ), 0, this,
+ SLOT( setCat() ), actionCollection(),
+ "remove_voice" );
+
+
+ mActionAddCat= new KAction( i18n( "Add categories..." ), 0, this,
+ SLOT( addCat() ), actionCollection(),
+ "remove_voice" );
+
mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
SLOT( importFromOL() ), actionCollection(),
"import_OL" );
@@ -2014,6 +2022,8 @@ void KABCore::addActionsManually()
mActionSelectAll->plug( editMenu );
mActionRemoveVoice->plug( changeMenu );
+ mActionSetCat->plug( changeMenu );
+ mActionAddCat->plug( changeMenu );
// settings menu
//US special menuentry to configure the addressbook resources. On KDE
// you do that through the control center !!!
@@ -2096,6 +2106,46 @@ void KABCore::showLicence()
{
KApplication::showLicence();
}
+void KABCore::setCat()
+{
+ setCategories( true );
+}
+void KABCore::addCat()
+{
+ setCategories( false );
+}
+void KABCore::setCategories( bool removeOld )
+{
+ KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KABPrefs::instance(), 0 );
+ if (! csd->exec()) {
+ message( i18n("Setting categories cancelled") );
+ delete csd;
+ return;
+ }
+ message( i18n("Setting categories ... please wait!") );
+ QStringList catList = csd->selectedCategories();
+ delete csd;
+ catList.sort();
+ QStringList newList;
+ KABC::Addressee::List list = mViewManager->selectedAddressees();
+ KABC::Addressee::List::Iterator it;
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ if ( removeOld ) {
+ (*it).setCategories( catList );
+ } else {
+ newList = (*it).categories();
+ int i;
+ for( i = 0; i< catList.count(); ++i ) {
+ if ( !newList.contains (catList[i]))
+ newList.append( catList[i] );
+ }
+ newList.sort();
+ (*it).setCategories( newList );
+ }
+ contactModified((*it) );
+ }
+ message( i18n("Setting categories completed!") );
+}
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 )
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index c01d598..1bdae5f 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -370,6 +370,9 @@ class KABCore : public QWidget, public KSyncInterface
void updateActionMenu();
void configureKeyBindings();
void removeVoice();
+ void setCat();
+ void addCat();
+ void setCategories( bool removeOld );
#ifdef KAB_EMBEDDED
void configureResources();
#endif //KAB_EMBEDDED
@@ -470,6 +473,8 @@ class KABCore : public QWidget, public KSyncInterface
QPopupMenu *ExportMenu;
//LR additional methods
KAction *mActionRemoveVoice;
+ KAction *mActionSetCat;
+ KAction *mActionAddCat;
KAction * mActionImportOL;
#ifndef KAB_EMBEDDED