author | zautrix <zautrix> | 2004-10-29 23:13:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-29 23:13:22 (UTC) |
commit | da80b510e4643fa3f78cf3f97af108e87097583d (patch) (side-by-side diff) | |
tree | 01c328362a6bf1898853ba26fd5d48eb5cff1e27 | |
parent | aafa695508796e86e9f267633ea5e6965d876031 (diff) | |
download | kdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.zip kdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.tar.gz kdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.tar.bz2 |
added better category handling to kapi
-rw-r--r-- | kabc/addressee.cpp | 4 | ||||
-rw-r--r-- | kabc/addressee.h | 2 | ||||
-rw-r--r-- | kabc/field.cpp | 6 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 54 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 5 |
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 @@ -1998,2 +1998,6 @@ QString Addressee::resourceLabel() } +QString Addressee::categoryLabel() +{ + return i18n("Category"); +} diff --git a/kabc/addressee.h b/kabc/addressee.h index 2c81c1a..08d2f56 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h @@ -825,3 +825,3 @@ class Addressee static QString resourceLabel(); - + static QString categoryLabel(); /** diff --git a/kabc/field.cpp b/kabc/field.cpp index d95cd19..89d0b77 100644 --- a/kabc/field.cpp +++ b/kabc/field.cpp @@ -59,2 +59,3 @@ class Field::FieldImpl Birthday, + Category, HomeAddressStreet, @@ -197,2 +198,4 @@ QString Field::label() return Addressee::resourceLabel(); + case FieldImpl::Category: + return Addressee::categoryLabel(); case FieldImpl::Sip: @@ -279,2 +282,4 @@ QString Field::value( const KABC::Addressee &a ) return a.resource()->resourceName(); + case FieldImpl::Category: + return a.categories().join(","); case FieldImpl::HomePhone: @@ -397,2 +402,3 @@ Field::List Field::allFields() createField( FieldImpl::Birthday, Personal ); + createField( FieldImpl::Category ); createField( FieldImpl::HomeAddressStreet, Address|Personal ); diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index e6bdde9..2c2f1a0 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -1878,4 +1878,2 @@ void KABCore::initActions() - - mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, @@ -1887,2 +1885,12 @@ void KABCore::initActions() "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, @@ -2016,2 +2024,4 @@ void KABCore::addActionsManually() mActionRemoveVoice->plug( changeMenu ); + mActionSetCat->plug( changeMenu ); + mActionAddCat->plug( changeMenu ); // settings menu @@ -2098,2 +2108,42 @@ void KABCore::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() diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index c01d598..1bdae5f 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -372,2 +372,5 @@ class KABCore : public QWidget, public KSyncInterface void removeVoice(); + void setCat(); + void addCat(); + void setCategories( bool removeOld ); #ifdef KAB_EMBEDDED @@ -472,2 +475,4 @@ class KABCore : public QWidget, public KSyncInterface KAction *mActionRemoveVoice; + KAction *mActionSetCat; + KAction *mActionAddCat; KAction * mActionImportOL; |