summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-30 01:46:35 (UTC)
committer zautrix <zautrix>2004-10-30 01:46:35 (UTC)
commit6c755a7a8a1e9d9a747267eadf914a6030c9b711 (patch) (unidiff)
tree14b1b8ed39f50683f095ca5fb7656abd3326854e
parentc477fa8ba7eacfaba3d154a72153acc7bc46abdc (diff)
downloadkdepimpi-6c755a7a8a1e9d9a747267eadf914a6030c9b711.zip
kdepimpi-6c755a7a8a1e9d9a747267eadf914a6030c9b711.tar.gz
kdepimpi-6c755a7a8a1e9d9a747267eadf914a6030c9b711.tar.bz2
better cat management in kapi
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
@@ -130,10 +130,13 @@ $Id$
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134#include <qradiobutton.h>
135#include <qbuttongroup.h>
134 136
135#include <libkdepim/categoryselectdialog.h> 137#include <libkdepim/categoryselectdialog.h>
138#include <libkdepim/categoryeditdialog.h>
136#include <kabc/vcardconverter.h> 139#include <kabc/vcardconverter.h>
137 140
138 141
139#include "addresseeutil.h" 142#include "addresseeutil.h"
@@ -158,8 +161,43 @@ $Id$
158// sync includes 161// sync includes
159#include <libkdepim/ksyncprofile.h> 162#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 163#include <libkdepim/ksyncprefsdialog.h>
161 164
165
166class KABCatPrefs : public QDialog
167{
168 public:
169 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
170 QDialog( parent, name, true )
171 {
172 setCaption( i18n("Manage new Categories") );
173 QVBoxLayout* lay = new QVBoxLayout( this );
174 lay->setSpacing( 3 );
175 lay->setMargin( 3 );
176 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 );
177 lay->addWidget( lab );
178 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
179 lay->addWidget( format );
180 format->setExclusive ( true ) ;
181 addCatBut = new QRadioButton(i18n("Add to category list"), format );
182 new QRadioButton(i18n("Remove from addressees"), format );
183 addCatBut->setChecked( true );
184 QPushButton * ok = new QPushButton( i18n("OK"), this );
185 lay->addWidget( ok );
186 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
187 lay->addWidget( cancel );
188 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
189 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
190 resize( 200, 200 );
191 }
192
193 bool addCat() { return addCatBut->isChecked(); }
194private:
195 QRadioButton* addCatBut;
196};
197
198
199
162class KAex2phonePrefs : public QDialog 200class KAex2phonePrefs : public QDialog
163{ 201{
164 public: 202 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 203 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
@@ -955,9 +993,13 @@ void KABCore::setWhoAmI()
955 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 993 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
956 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 994 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
957 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 995 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
958} 996}
959 997void KABCore::editCategories()
998{
999 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1000 dlg.exec();
1001}
960void KABCore::setCategories() 1002void KABCore::setCategories()
961{ 1003{
962 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1004 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
963 if ( !dlg.exec() ) { 1005 if ( !dlg.exec() ) {
@@ -987,9 +1029,8 @@ void KABCore::setCategories()
987 addrCategories.append( *catIt ); 1029 addrCategories.append( *catIt );
988 } 1030 }
989 addr.setCategories( addrCategories ); 1031 addr.setCategories( addrCategories );
990 } 1032 }
991
992 mAddressBook->insertAddressee( addr ); 1033 mAddressBook->insertAddressee( addr );
993 } 1034 }
994 } 1035 }
995 1036
@@ -1881,8 +1922,11 @@ void KABCore::initActions()
1881 1922
1882 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1923 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1883 SLOT( setCategories() ), actionCollection(), 1924 SLOT( setCategories() ), actionCollection(),
1884 "edit_set_categories" ); 1925 "edit_set_categories" );
1926 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
1927 SLOT( editCategories() ), actionCollection(),
1928 "edit__categories" );
1885 1929
1886 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1930 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1887 SLOT( removeVoice() ), actionCollection(), 1931 SLOT( removeVoice() ), actionCollection(),
1888 "remove_voice" ); 1932 "remove_voice" );
@@ -2049,8 +2093,9 @@ void KABCore::addActionsManually()
2049 mActionBR->plug(settingsMenu ); 2093 mActionBR->plug(settingsMenu );
2050 settingsMenu->insertSeparator(); 2094 settingsMenu->insertSeparator();
2051 2095
2052 mActionWhoAmI->plug( settingsMenu ); 2096 mActionWhoAmI->plug( settingsMenu );
2097 mActionEditCategories->plug( settingsMenu );
2053 mActionCategories->plug( settingsMenu ); 2098 mActionCategories->plug( settingsMenu );
2054 mActionManageCategories->plug( settingsMenu ); 2099 mActionManageCategories->plug( settingsMenu );
2055 2100
2056 2101
@@ -2106,9 +2151,65 @@ void KABCore::showLicence()
2106} 2151}
2107 2152
2108void KABCore::manageCategories( ) 2153void KABCore::manageCategories( )
2109{ 2154{
2110 2155 KABCatPrefs* cp = new KABCatPrefs();
2156 cp->show();
2157 int w =cp->sizeHint().width() ;
2158 int h = cp->sizeHint().height() ;
2159 int dw = QApplication::desktop()->width();
2160 int dh = QApplication::desktop()->height();
2161 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2162 if ( !cp->exec() ) {
2163 delete cp;
2164 return;
2165 }
2166 int count = 0;
2167 message( i18n("Please wait, processing categories..."));
2168 if ( cp->addCat() ) {
2169 KABC::AddressBook::Iterator it;
2170 QStringList catList = KABPrefs::instance()->mCustomCategories;
2171 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2172 QStringList catIncList = (*it).categories();
2173 int i;
2174 for( i = 0; i< catIncList.count(); ++i ) {
2175 if ( !catList.contains (catIncList[i])) {
2176 catList.append( catIncList[i] );
2177 //qDebug("add cat %s ", catIncList[i].latin1());
2178 ++count;
2179 }
2180 }
2181 }
2182 catList.sort();
2183 KABPrefs::instance()->mCustomCategories = catList;
2184 KABPrefs::instance()->writeConfig();
2185 message(QString::number( count )+ i18n(" categories added to list! "));
2186 } else {
2187 QStringList catList = KABPrefs::instance()->mCustomCategories;
2188 QStringList catIncList;
2189 QStringList newCatList;
2190 KABC::AddressBook::Iterator it;
2191 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2192 QStringList catIncList = (*it).categories();
2193 int i;
2194 if ( catIncList.count() ) {
2195 newCatList.clear();
2196 for( i = 0; i< catIncList.count(); ++i ) {
2197 if ( catList.contains (catIncList[i])) {
2198 newCatList.append( catIncList[i] );
2199 }
2200 }
2201 newCatList.sort();
2202 (*it).setCategories( newCatList );
2203 mAddressBook->insertAddressee( (*it) );
2204 }
2205 }
2206 setModified( true );
2207 mViewManager->refreshView();
2208 mDetails->refreshView();
2209 message( i18n("Removing categories done!"));
2210 }
2211 delete cp;
2111} 2212}
2112void KABCore::removeVoice() 2213void KABCore::removeVoice()
2113{ 2214{
2114 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 ) 2215 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 bf5398b..d2ee45d 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -243,8 +243,9 @@ class KABCore : public QWidget, public KSyncInterface
243 selected contacts. 243 selected contacts.
244 */ 244 */
245 void setCategories(); 245 void setCategories();
246 void manageCategories(); 246 void manageCategories();
247 void editCategories();
247 248
248 /** 249 /**
249 Sets the field list of the Incremental Search Widget. 250 Sets the field list of the Incremental Search Widget.
250 */ 251 */
@@ -451,8 +452,9 @@ class KABCore : public QWidget, public KSyncInterface
451 KToggleAction *mActionJumpBar; 452 KToggleAction *mActionJumpBar;
452 KToggleAction *mActionDetails; 453 KToggleAction *mActionDetails;
453 KAction *mActionWhoAmI; 454 KAction *mActionWhoAmI;
454 KAction *mActionCategories; 455 KAction *mActionCategories;
456 KAction *mActionEditCategories;
455 KAction *mActionManageCategories; 457 KAction *mActionManageCategories;
456 KAction *mActionAboutKAddressbook; 458 KAction *mActionAboutKAddressbook;
457 KAction *mActionLicence; 459 KAction *mActionLicence;
458 KAction *mActionFaq; 460 KAction *mActionFaq;