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 @@ -1991,16 +1991,20 @@ Resource *Addressee::resource() const return mData->resource; } //US QString Addressee::resourceLabel() { return i18n("Resource"); } +QString Addressee::categoryLabel() +{ + return i18n("Category"); +} void Addressee::setChanged( bool value ) { detach(); mData->changed = value; } bool Addressee::changed() const diff --git a/kabc/addressee.h b/kabc/addressee.h index 2c81c1a..08d2f56 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h @@ -818,17 +818,17 @@ class Addressee */ Resource *resource() const; /** Return resourcelabel. */ //US static QString resourceLabel(); - + static QString categoryLabel(); /** Mark addressee as changed. */ void setChanged( bool value ); /** Return whether the addressee is changed. */ diff --git a/kabc/field.cpp b/kabc/field.cpp index d95cd19..89d0b77 100644 --- a/kabc/field.cpp +++ b/kabc/field.cpp @@ -52,16 +52,17 @@ class Field::FieldImpl FormattedName, FamilyName, GivenName, AdditionalName, Prefix, Suffix, NickName, Birthday, + Category, HomeAddressStreet, HomeAddressLocality, HomeAddressRegion, HomeAddressPostalCode, HomeAddressCountry, HomeAddressLabel, BusinessAddressStreet, BusinessAddressLocality, @@ -190,16 +191,18 @@ QString Field::label() case FieldImpl::Organization: return Addressee::organizationLabel(); case FieldImpl::Note: return Addressee::noteLabel(); case FieldImpl::Url: return Addressee::urlLabel(); case FieldImpl::Resource: return Addressee::resourceLabel(); + case FieldImpl::Category: + return Addressee::categoryLabel(); case FieldImpl::Sip: return Addressee::sipLabel(); case FieldImpl::CustomField: return mImpl->label(); default: return i18n("Unknown Field"); } } @@ -272,16 +275,18 @@ QString Field::value( const KABC::Addressee &a ) } else return QString::null; case FieldImpl::Url: return a.url().prettyURL(); //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: return a.phoneNumber( PhoneNumber::Work ).number(); case FieldImpl::MobilePhone: return a.phoneNumber( PhoneNumber::Cell ).number(); case FieldImpl::HomeFax: return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); @@ -390,16 +395,17 @@ Field::List Field::allFields() createField( FieldImpl::FormattedName, Frequent ); createField( FieldImpl::FamilyName, Frequent ); createField( FieldImpl::GivenName, Frequent ); createField( FieldImpl::AdditionalName ); createField( FieldImpl::Prefix ); 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 ); createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); createField( FieldImpl::HomeAddressCountry, Address|Personal ); createField( FieldImpl::HomeAddressLabel, Address|Personal ); createField( FieldImpl::BusinessAddressStreet, Address|Organization ); createField( FieldImpl::BusinessAddressLocality, Address|Organization ); diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index e6bdde9..2c2f1a0 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -1871,25 +1871,33 @@ void KABCore::initActions() #endif //KAB_EMBEDDED mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, SLOT( setWhoAmI() ), actionCollection(), "set_personal" ); - - mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, SLOT( setCategories() ), actionCollection(), "edit_set_categories" ); 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" ); #ifdef KAB_EMBEDDED mActionLicence = new KAction( i18n( "Licence" ), 0, this, SLOT( showLicence() ), actionCollection(), "licence_about_data" ); mActionFaq = new KAction( i18n( "Faq" ), 0, @@ -2009,16 +2017,18 @@ void KABCore::addActionsManually() mActionCut->plug( editMenu ); mActionCopy->plug( editMenu ); mActionPaste->plug( editMenu ); mActionDelete->plug( editMenu ); editMenu->insertSeparator(); 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 !!! mActionConfigResources->plug( settingsMenu ); settingsMenu->insertSeparator(); mActionConfigKAddressbook->plug( settingsMenu ); @@ -2091,16 +2101,56 @@ void KABCore::addActionsManually() connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); syncManager->fillSyncMenu(); } 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 ) return; KABC::Addressee::List list = mViewManager->selectedAddressees(); KABC::Addressee::List::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index c01d598..1bdae5f 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -365,16 +365,19 @@ class KABCore : public QWidget, public KSyncInterface void setCaptionBack(); void importFromOL(); void extensionModified( const KABC::Addressee::List &list ); void extensionChanged( int id ); void clipboardDataChanged(); void updateActionMenu(); void configureKeyBindings(); void removeVoice(); + void setCat(); + void addCat(); + void setCategories( bool removeOld ); #ifdef KAB_EMBEDDED void configureResources(); #endif //KAB_EMBEDDED void slotEditorDestroyed( const QString &uid ); void configurationChanged(); void addressBookChanged(); @@ -465,16 +468,18 @@ class KABCore : public QWidget, public KSyncInterface QPopupMenu *filterMenu; QPopupMenu *settingsMenu; QPopupMenu *changeMenu; //US QAction *mActionSave; QPopupMenu *ImportMenu; QPopupMenu *ExportMenu; //LR additional methods KAction *mActionRemoveVoice; + KAction *mActionSetCat; + KAction *mActionAddCat; KAction * mActionImportOL; #ifndef KAB_EMBEDDED KAddressBookService *mAddressBookService; #endif //KAB_EMBEDDED class KABCorePrivate; KABCorePrivate *d; |