author | zautrix <zautrix> | 2004-10-29 23:13:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-29 23:13:22 (UTC) |
commit | da80b510e4643fa3f78cf3f97af108e87097583d (patch) (unidiff) | |
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 | |||
1991 | return mData->resource; | 1991 | return mData->resource; |
1992 | } | 1992 | } |
1993 | 1993 | ||
1994 | //US | 1994 | //US |
1995 | QString Addressee::resourceLabel() | 1995 | QString Addressee::resourceLabel() |
1996 | { | 1996 | { |
1997 | return i18n("Resource"); | 1997 | return i18n("Resource"); |
1998 | } | 1998 | } |
1999 | QString Addressee::categoryLabel() | ||
2000 | { | ||
2001 | return i18n("Category"); | ||
2002 | } | ||
1999 | 2003 | ||
2000 | void Addressee::setChanged( bool value ) | 2004 | void Addressee::setChanged( bool value ) |
2001 | { | 2005 | { |
2002 | detach(); | 2006 | detach(); |
2003 | mData->changed = value; | 2007 | mData->changed = value; |
2004 | } | 2008 | } |
2005 | 2009 | ||
2006 | bool Addressee::changed() const | 2010 | 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 | |||
818 | */ | 818 | */ |
819 | Resource *resource() const; | 819 | Resource *resource() const; |
820 | 820 | ||
821 | /** | 821 | /** |
822 | Return resourcelabel. | 822 | Return resourcelabel. |
823 | */ | 823 | */ |
824 | //US | 824 | //US |
825 | static QString resourceLabel(); | 825 | static QString resourceLabel(); |
826 | 826 | static QString categoryLabel(); | |
827 | /** | 827 | /** |
828 | Mark addressee as changed. | 828 | Mark addressee as changed. |
829 | */ | 829 | */ |
830 | void setChanged( bool value ); | 830 | void setChanged( bool value ); |
831 | 831 | ||
832 | /** | 832 | /** |
833 | Return whether the addressee is changed. | 833 | Return whether the addressee is changed. |
834 | */ | 834 | */ |
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 | |||
52 | FormattedName, | 52 | FormattedName, |
53 | FamilyName, | 53 | FamilyName, |
54 | GivenName, | 54 | GivenName, |
55 | AdditionalName, | 55 | AdditionalName, |
56 | Prefix, | 56 | Prefix, |
57 | Suffix, | 57 | Suffix, |
58 | NickName, | 58 | NickName, |
59 | Birthday, | 59 | Birthday, |
60 | Category, | ||
60 | HomeAddressStreet, | 61 | HomeAddressStreet, |
61 | HomeAddressLocality, | 62 | HomeAddressLocality, |
62 | HomeAddressRegion, | 63 | HomeAddressRegion, |
63 | HomeAddressPostalCode, | 64 | HomeAddressPostalCode, |
64 | HomeAddressCountry, | 65 | HomeAddressCountry, |
65 | HomeAddressLabel, | 66 | HomeAddressLabel, |
66 | BusinessAddressStreet, | 67 | BusinessAddressStreet, |
67 | BusinessAddressLocality, | 68 | BusinessAddressLocality, |
@@ -190,16 +191,18 @@ QString Field::label() | |||
190 | case FieldImpl::Organization: | 191 | case FieldImpl::Organization: |
191 | return Addressee::organizationLabel(); | 192 | return Addressee::organizationLabel(); |
192 | case FieldImpl::Note: | 193 | case FieldImpl::Note: |
193 | return Addressee::noteLabel(); | 194 | return Addressee::noteLabel(); |
194 | case FieldImpl::Url: | 195 | case FieldImpl::Url: |
195 | return Addressee::urlLabel(); | 196 | return Addressee::urlLabel(); |
196 | case FieldImpl::Resource: | 197 | case FieldImpl::Resource: |
197 | return Addressee::resourceLabel(); | 198 | return Addressee::resourceLabel(); |
199 | case FieldImpl::Category: | ||
200 | return Addressee::categoryLabel(); | ||
198 | case FieldImpl::Sip: | 201 | case FieldImpl::Sip: |
199 | return Addressee::sipLabel(); | 202 | return Addressee::sipLabel(); |
200 | case FieldImpl::CustomField: | 203 | case FieldImpl::CustomField: |
201 | return mImpl->label(); | 204 | return mImpl->label(); |
202 | default: | 205 | default: |
203 | return i18n("Unknown Field"); | 206 | return i18n("Unknown Field"); |
204 | } | 207 | } |
205 | } | 208 | } |
@@ -272,16 +275,18 @@ QString Field::value( const KABC::Addressee &a ) | |||
272 | } | 275 | } |
273 | else | 276 | else |
274 | return QString::null; | 277 | return QString::null; |
275 | case FieldImpl::Url: | 278 | case FieldImpl::Url: |
276 | return a.url().prettyURL(); | 279 | return a.url().prettyURL(); |
277 | //US | 280 | //US |
278 | case FieldImpl::Resource: | 281 | case FieldImpl::Resource: |
279 | return a.resource()->resourceName(); | 282 | return a.resource()->resourceName(); |
283 | case FieldImpl::Category: | ||
284 | return a.categories().join(","); | ||
280 | case FieldImpl::HomePhone: | 285 | case FieldImpl::HomePhone: |
281 | return a.phoneNumber( PhoneNumber::Home ).number(); | 286 | return a.phoneNumber( PhoneNumber::Home ).number(); |
282 | case FieldImpl::BusinessPhone: | 287 | case FieldImpl::BusinessPhone: |
283 | return a.phoneNumber( PhoneNumber::Work ).number(); | 288 | return a.phoneNumber( PhoneNumber::Work ).number(); |
284 | case FieldImpl::MobilePhone: | 289 | case FieldImpl::MobilePhone: |
285 | return a.phoneNumber( PhoneNumber::Cell ).number(); | 290 | return a.phoneNumber( PhoneNumber::Cell ).number(); |
286 | case FieldImpl::HomeFax: | 291 | case FieldImpl::HomeFax: |
287 | return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); | 292 | return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); |
@@ -390,16 +395,17 @@ Field::List Field::allFields() | |||
390 | createField( FieldImpl::FormattedName, Frequent ); | 395 | createField( FieldImpl::FormattedName, Frequent ); |
391 | createField( FieldImpl::FamilyName, Frequent ); | 396 | createField( FieldImpl::FamilyName, Frequent ); |
392 | createField( FieldImpl::GivenName, Frequent ); | 397 | createField( FieldImpl::GivenName, Frequent ); |
393 | createField( FieldImpl::AdditionalName ); | 398 | createField( FieldImpl::AdditionalName ); |
394 | createField( FieldImpl::Prefix ); | 399 | createField( FieldImpl::Prefix ); |
395 | createField( FieldImpl::Suffix ); | 400 | createField( FieldImpl::Suffix ); |
396 | createField( FieldImpl::NickName, Personal ); | 401 | createField( FieldImpl::NickName, Personal ); |
397 | createField( FieldImpl::Birthday, Personal ); | 402 | createField( FieldImpl::Birthday, Personal ); |
403 | createField( FieldImpl::Category ); | ||
398 | createField( FieldImpl::HomeAddressStreet, Address|Personal ); | 404 | createField( FieldImpl::HomeAddressStreet, Address|Personal ); |
399 | createField( FieldImpl::HomeAddressLocality, Address|Personal ); | 405 | createField( FieldImpl::HomeAddressLocality, Address|Personal ); |
400 | createField( FieldImpl::HomeAddressRegion, Address|Personal ); | 406 | createField( FieldImpl::HomeAddressRegion, Address|Personal ); |
401 | createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); | 407 | createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); |
402 | createField( FieldImpl::HomeAddressCountry, Address|Personal ); | 408 | createField( FieldImpl::HomeAddressCountry, Address|Personal ); |
403 | createField( FieldImpl::HomeAddressLabel, Address|Personal ); | 409 | createField( FieldImpl::HomeAddressLabel, Address|Personal ); |
404 | createField( FieldImpl::BusinessAddressStreet, Address|Organization ); | 410 | createField( FieldImpl::BusinessAddressStreet, Address|Organization ); |
405 | createField( FieldImpl::BusinessAddressLocality, Address|Organization ); | 411 | 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() | |||
1871 | #endif //KAB_EMBEDDED | 1871 | #endif //KAB_EMBEDDED |
1872 | 1872 | ||
1873 | 1873 | ||
1874 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1874 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1875 | SLOT( setWhoAmI() ), actionCollection(), | 1875 | SLOT( setWhoAmI() ), actionCollection(), |
1876 | "set_personal" ); | 1876 | "set_personal" ); |
1877 | 1877 | ||
1878 | 1878 | ||
1879 | |||
1880 | |||
1881 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1879 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1882 | SLOT( setCategories() ), actionCollection(), | 1880 | SLOT( setCategories() ), actionCollection(), |
1883 | "edit_set_categories" ); | 1881 | "edit_set_categories" ); |
1884 | 1882 | ||
1885 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1883 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1886 | SLOT( removeVoice() ), actionCollection(), | 1884 | SLOT( removeVoice() ), actionCollection(), |
1887 | "remove_voice" ); | 1885 | "remove_voice" ); |
1886 | |||
1887 | mActionSetCat= new KAction( i18n( "Set categories..." ), 0, this, | ||
1888 | SLOT( setCat() ), actionCollection(), | ||
1889 | "remove_voice" ); | ||
1890 | |||
1891 | |||
1892 | mActionAddCat= new KAction( i18n( "Add categories..." ), 0, this, | ||
1893 | SLOT( addCat() ), actionCollection(), | ||
1894 | "remove_voice" ); | ||
1895 | |||
1888 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1896 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1889 | SLOT( importFromOL() ), actionCollection(), | 1897 | SLOT( importFromOL() ), actionCollection(), |
1890 | "import_OL" ); | 1898 | "import_OL" ); |
1891 | #ifdef KAB_EMBEDDED | 1899 | #ifdef KAB_EMBEDDED |
1892 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1900 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1893 | this, SLOT( showLicence() ), actionCollection(), | 1901 | this, SLOT( showLicence() ), actionCollection(), |
1894 | "licence_about_data" ); | 1902 | "licence_about_data" ); |
1895 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1903 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
@@ -2009,16 +2017,18 @@ void KABCore::addActionsManually() | |||
2009 | mActionCut->plug( editMenu ); | 2017 | mActionCut->plug( editMenu ); |
2010 | mActionCopy->plug( editMenu ); | 2018 | mActionCopy->plug( editMenu ); |
2011 | mActionPaste->plug( editMenu ); | 2019 | mActionPaste->plug( editMenu ); |
2012 | mActionDelete->plug( editMenu ); | 2020 | mActionDelete->plug( editMenu ); |
2013 | editMenu->insertSeparator(); | 2021 | editMenu->insertSeparator(); |
2014 | mActionSelectAll->plug( editMenu ); | 2022 | mActionSelectAll->plug( editMenu ); |
2015 | 2023 | ||
2016 | mActionRemoveVoice->plug( changeMenu ); | 2024 | mActionRemoveVoice->plug( changeMenu ); |
2025 | mActionSetCat->plug( changeMenu ); | ||
2026 | mActionAddCat->plug( changeMenu ); | ||
2017 | // settings menu | 2027 | // settings menu |
2018 | //US special menuentry to configure the addressbook resources. On KDE | 2028 | //US special menuentry to configure the addressbook resources. On KDE |
2019 | // you do that through the control center !!! | 2029 | // you do that through the control center !!! |
2020 | mActionConfigResources->plug( settingsMenu ); | 2030 | mActionConfigResources->plug( settingsMenu ); |
2021 | settingsMenu->insertSeparator(); | 2031 | settingsMenu->insertSeparator(); |
2022 | 2032 | ||
2023 | mActionConfigKAddressbook->plug( settingsMenu ); | 2033 | mActionConfigKAddressbook->plug( settingsMenu ); |
2024 | 2034 | ||
@@ -2091,16 +2101,56 @@ void KABCore::addActionsManually() | |||
2091 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2101 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2092 | syncManager->fillSyncMenu(); | 2102 | syncManager->fillSyncMenu(); |
2093 | 2103 | ||
2094 | } | 2104 | } |
2095 | void KABCore::showLicence() | 2105 | void KABCore::showLicence() |
2096 | { | 2106 | { |
2097 | KApplication::showLicence(); | 2107 | KApplication::showLicence(); |
2098 | } | 2108 | } |
2109 | void KABCore::setCat() | ||
2110 | { | ||
2111 | setCategories( true ); | ||
2112 | } | ||
2113 | void KABCore::addCat() | ||
2114 | { | ||
2115 | setCategories( false ); | ||
2116 | } | ||
2117 | void KABCore::setCategories( bool removeOld ) | ||
2118 | { | ||
2119 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KABPrefs::instance(), 0 ); | ||
2120 | if (! csd->exec()) { | ||
2121 | message( i18n("Setting categories cancelled") ); | ||
2122 | delete csd; | ||
2123 | return; | ||
2124 | } | ||
2125 | message( i18n("Setting categories ... please wait!") ); | ||
2126 | QStringList catList = csd->selectedCategories(); | ||
2127 | delete csd; | ||
2128 | catList.sort(); | ||
2129 | QStringList newList; | ||
2130 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | ||
2131 | KABC::Addressee::List::Iterator it; | ||
2132 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
2133 | if ( removeOld ) { | ||
2134 | (*it).setCategories( catList ); | ||
2135 | } else { | ||
2136 | newList = (*it).categories(); | ||
2137 | int i; | ||
2138 | for( i = 0; i< catList.count(); ++i ) { | ||
2139 | if ( !newList.contains (catList[i])) | ||
2140 | newList.append( catList[i] ); | ||
2141 | } | ||
2142 | newList.sort(); | ||
2143 | (*it).setCategories( newList ); | ||
2144 | } | ||
2145 | contactModified((*it) ); | ||
2146 | } | ||
2147 | message( i18n("Setting categories completed!") ); | ||
2148 | } | ||
2099 | void KABCore::removeVoice() | 2149 | void KABCore::removeVoice() |
2100 | { | 2150 | { |
2101 | 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 ) | 2151 | 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 ) |
2102 | return; | 2152 | return; |
2103 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2153 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2104 | KABC::Addressee::List::Iterator it; | 2154 | KABC::Addressee::List::Iterator it; |
2105 | for ( it = list.begin(); it != list.end(); ++it ) { | 2155 | for ( it = list.begin(); it != list.end(); ++it ) { |
2106 | 2156 | ||
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 | |||
365 | void setCaptionBack(); | 365 | void setCaptionBack(); |
366 | void importFromOL(); | 366 | void importFromOL(); |
367 | void extensionModified( const KABC::Addressee::List &list ); | 367 | void extensionModified( const KABC::Addressee::List &list ); |
368 | void extensionChanged( int id ); | 368 | void extensionChanged( int id ); |
369 | void clipboardDataChanged(); | 369 | void clipboardDataChanged(); |
370 | void updateActionMenu(); | 370 | void updateActionMenu(); |
371 | void configureKeyBindings(); | 371 | void configureKeyBindings(); |
372 | void removeVoice(); | 372 | void removeVoice(); |
373 | void setCat(); | ||
374 | void addCat(); | ||
375 | void setCategories( bool removeOld ); | ||
373 | #ifdef KAB_EMBEDDED | 376 | #ifdef KAB_EMBEDDED |
374 | void configureResources(); | 377 | void configureResources(); |
375 | #endif //KAB_EMBEDDED | 378 | #endif //KAB_EMBEDDED |
376 | 379 | ||
377 | void slotEditorDestroyed( const QString &uid ); | 380 | void slotEditorDestroyed( const QString &uid ); |
378 | void configurationChanged(); | 381 | void configurationChanged(); |
379 | void addressBookChanged(); | 382 | void addressBookChanged(); |
380 | 383 | ||
@@ -465,16 +468,18 @@ class KABCore : public QWidget, public KSyncInterface | |||
465 | QPopupMenu *filterMenu; | 468 | QPopupMenu *filterMenu; |
466 | QPopupMenu *settingsMenu; | 469 | QPopupMenu *settingsMenu; |
467 | QPopupMenu *changeMenu; | 470 | QPopupMenu *changeMenu; |
468 | //US QAction *mActionSave; | 471 | //US QAction *mActionSave; |
469 | QPopupMenu *ImportMenu; | 472 | QPopupMenu *ImportMenu; |
470 | QPopupMenu *ExportMenu; | 473 | QPopupMenu *ExportMenu; |
471 | //LR additional methods | 474 | //LR additional methods |
472 | KAction *mActionRemoveVoice; | 475 | KAction *mActionRemoveVoice; |
476 | KAction *mActionSetCat; | ||
477 | KAction *mActionAddCat; | ||
473 | KAction * mActionImportOL; | 478 | KAction * mActionImportOL; |
474 | 479 | ||
475 | #ifndef KAB_EMBEDDED | 480 | #ifndef KAB_EMBEDDED |
476 | KAddressBookService *mAddressBookService; | 481 | KAddressBookService *mAddressBookService; |
477 | #endif //KAB_EMBEDDED | 482 | #endif //KAB_EMBEDDED |
478 | 483 | ||
479 | class KABCorePrivate; | 484 | class KABCorePrivate; |
480 | KABCorePrivate *d; | 485 | KABCorePrivate *d; |