summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-09-21 19:54:39 (UTC)
committer ulf69 <ulf69>2004-09-21 19:54:39 (UTC)
commit618dec7bf4371c2085048cc1f95a93220bc8a233 (patch) (unidiff)
treedf5e3e47a417400fa9f6871912eda6558294d9b4
parent186ee062d9169860fbab1613ca21b956c69296a6 (diff)
downloadkdepimpi-618dec7bf4371c2085048cc1f95a93220bc8a233.zip
kdepimpi-618dec7bf4371c2085048cc1f95a93220bc8a233.tar.gz
kdepimpi-618dec7bf4371c2085048cc1f95a93220bc8a233.tar.bz2
modified configdialog to work properly with global configwidget from (libkdepim)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp9
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp32
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.h20
-rw-r--r--kaddressbook/kcmconfigs/kcmkabconfig.cpp16
-rw-r--r--kaddressbook/kcmconfigs/kcmkabconfig.h2
5 files changed, 26 insertions, 53 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 4ebd6a8..1b40d71 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1274,35 +1274,30 @@ QString KABCore::getNameByPhone( const QString &phone )
1274 } 1274 }
1275 1275
1276 return ownerName; 1276 return ownerName;
1277#else //KAB_EMBEDDED 1277#else //KAB_EMBEDDED
1278 qDebug("KABCore::getNameByPhone finsih method"); 1278 qDebug("KABCore::getNameByPhone finsih method");
1279 return ""; 1279 return "";
1280#endif //KAB_EMBEDDED 1280#endif //KAB_EMBEDDED
1281 1281
1282} 1282}
1283 1283
1284void KABCore::openConfigDialog() 1284void KABCore::openConfigDialog()
1285{ 1285{
1286 KABPrefs* kab_prefs = KABPrefs::instance();
1287 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance();
1288
1289 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1286 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1290 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1287 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1291 ConfigureDialog->addModule(kabcfg ); 1288 ConfigureDialog->addModule(kabcfg );
1292 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1289 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1293 ConfigureDialog->addModule(kdelibcfg ); 1290 ConfigureDialog->addModule(kdelibcfg );
1294 1291
1295
1296
1297 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1292 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1298 this, SLOT( configurationChanged() ) ); 1293 this, SLOT( configurationChanged() ) );
1299 connect( ConfigureDialog, SIGNAL( okClicked() ), 1294 connect( ConfigureDialog, SIGNAL( okClicked() ),
1300 this, SLOT( configurationChanged() ) ); 1295 this, SLOT( configurationChanged() ) );
1301 saveSettings(); 1296 saveSettings();
1302#ifndef DESKTOP_VERSION 1297#ifndef DESKTOP_VERSION
1303 ConfigureDialog->showMaximized(); 1298 ConfigureDialog->showMaximized();
1304#endif 1299#endif
1305 if ( ConfigureDialog->exec() ) 1300 if ( ConfigureDialog->exec() )
1306 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1301 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1307 delete ConfigureDialog; 1302 delete ConfigureDialog;
1308} 1303}
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
index 0c3a199..e970c3d 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
@@ -76,26 +76,26 @@ class ExtensionItem : public QCheckListItem
76 private: 76 private:
77#ifndef KAB_EMBEDDED 77#ifndef KAB_EMBEDDED
78 KService::Ptr mPtr; 78 KService::Ptr mPtr;
79#else //KAB_EMBEDDED 79#else //KAB_EMBEDDED
80 ExtensionFactory* mFactory; 80 ExtensionFactory* mFactory;
81 QString mName; 81 QString mName;
82 QString mComment; 82 QString mComment;
83 83
84#endif //KAB_EMBEDDED 84#endif //KAB_EMBEDDED
85 85
86}; 86};
87 87
88KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) 88KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name )
89 : QWidget( parent, name ) 89 : KPrefsWidget( prefs, parent, name )
90{ 90{
91 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 91 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
92 KDialog::spacingHint() ); 92 KDialog::spacingHint() );
93 93
94 QTabWidget *tabWidget = new QTabWidget( this ); 94 QTabWidget *tabWidget = new QTabWidget( this );
95 topLayout->addWidget( tabWidget ); 95 topLayout->addWidget( tabWidget );
96 96
97 // General page 97 // General page
98 QWidget *generalPage = new QWidget( this ); 98 QWidget *generalPage = new QWidget( this );
99 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), 99 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(),
100 KDialog::spacingHintSmall() ); 100 KDialog::spacingHintSmall() );
101 //general groupbox 101 //general groupbox
@@ -164,77 +164,59 @@ KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name )
164 connect( mConfigureButton, SIGNAL( clicked() ), 164 connect( mConfigureButton, SIGNAL( clicked() ),
165 SLOT( configureExtension() ) ); 165 SLOT( configureExtension() ) );
166 166
167 tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); 167 tabWidget->addTab( extensionPage, i18n( "Extensions" ) );
168 168
169 // Addressee page 169 // Addressee page
170 mAddresseeWidget = new AddresseeWidget( this ); 170 mAddresseeWidget = new AddresseeWidget( this );
171 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); 171 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
172 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); 172 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
173 173
174} 174}
175 175
176 176void KABConfigWidget::usrReadConfig()
177void KABConfigWidget::restoreSettings(KABPrefs* prefs)
178{ 177{
179//US prefs was KABPrefs::instance() before 178 KABPrefs* prefs = KABPrefs::instance();
180 179
181 bool blocked = signalsBlocked(); 180 bool blocked = signalsBlocked();
182 blockSignals( true ); 181 blockSignals( true );
183 182
184 mNameParsing->setChecked( prefs->mAutomaticNameParsing ); 183 mNameParsing->setChecked( prefs->mAutomaticNameParsing );
185 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); 184 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick );
186 mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); 185 mSearchReturnBox->setChecked( prefs->mSearchWithReturn );
187 mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); 186 mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce );
188 mAskForQuit->setChecked( prefs->mAskForQuit ); 187 mAskForQuit->setChecked( prefs->mAskForQuit );
189 188
190 mAddresseeWidget->restoreSettings(); 189 mAddresseeWidget->restoreSettings();
191 190
192 restoreExtensionSettings(); 191 restoreExtensionSettings();
193 192
194 blockSignals( blocked ); 193 blockSignals( blocked );
195 194
196 emit changed( false );
197} 195}
198 196
199void KABConfigWidget::saveSettings(KABPrefs* prefs) 197void KABConfigWidget::usrWriteConfig()
200{ 198{
199 KABPrefs* prefs = KABPrefs::instance();
200
201 prefs->mAutomaticNameParsing = mNameParsing->isChecked(); 201 prefs->mAutomaticNameParsing = mNameParsing->isChecked();
202 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); 202 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked();
203 prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); 203 prefs->mSearchWithReturn = mSearchReturnBox->isChecked();
204 prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); 204 prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked();
205 prefs->mAskForQuit = mAskForQuit->isChecked(); 205 prefs->mAskForQuit = mAskForQuit->isChecked();
206 206
207 mAddresseeWidget->saveSettings(); 207 mAddresseeWidget->saveSettings();
208 208
209 saveExtensionSettings(); 209 saveExtensionSettings();
210 KABPrefs::instance()->writeConfig();
211 210
212 emit changed( false );
213}
214
215void KABConfigWidget::defaults(KABPrefs* prefs)
216{
217 mNameParsing->setChecked( true );
218 mViewsSingleClickBox->setChecked( false );
219 mMultipleViewsAtOnce->setChecked( true );
220 mSearchReturnBox->setChecked( true );
221 mAskForQuit->setChecked (true);
222
223 emit changed( true );
224}
225
226void KABConfigWidget::modified()
227{
228 emit changed( true );
229} 211}
230 212
231void KABConfigWidget::restoreExtensionSettings() 213void KABConfigWidget::restoreExtensionSettings()
232{ 214{
233 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; 215 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions;
234 216
235 mExtensionView->clear(); 217 mExtensionView->clear();
236 218
237#ifndef KAB_EMBEDDED 219#ifndef KAB_EMBEDDED
238 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); 220 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" );
239 KTrader::OfferList::ConstIterator it; 221 KTrader::OfferList::ConstIterator it;
240 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 222 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h
index 6cd4223..1e71fd1 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.h
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.h
@@ -15,52 +15,48 @@
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCONFIGWIDGET_H 24#ifndef KABCONFIGWIDGET_H
25#define KABCONFIGWIDGET_H 25#define KABCONFIGWIDGET_H
26 26
27#include <qwidget.h> 27#include <kprefswidget.h>
28 28
29class QCheckBox; 29class QCheckBox;
30class QListViewItem; 30class QListViewItem;
31class QPushButton; 31class QPushButton;
32class QComboBox; 32class QComboBox;
33class QLineEdit; 33class QLineEdit;
34class KListView; 34class KListView;
35class KABPrefs; 35class KABPrefs;
36 36
37class AddresseeWidget; 37class AddresseeWidget;
38 38
39class KABConfigWidget : public QWidget 39class KABConfigWidget : public KPrefsWidget
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43 public: 43 public:
44 KABConfigWidget( QWidget *parent, const char *name = 0 ); 44 KABConfigWidget(KABPrefs *prefs, QWidget *parent, const char *name = 0 );
45 45
46 void restoreSettings(KABPrefs* prefs); 46 protected:
47 void saveSettings(KABPrefs* prefs); 47 /** Implement this to read custom configuration widgets. */
48 void defaults(KABPrefs* prefs); 48 virtual void usrReadConfig();
49 49 /** Implement this to write custom configuration widgets. */
50 signals: 50 virtual void usrWriteConfig();
51 void changed( bool );
52
53 public slots:
54 void modified();
55 51
56 52
57 53
58 private slots: 54 private slots:
59 void configureExtension(); 55 void configureExtension();
60 void selectionChanged( QListViewItem* ); 56 void selectionChanged( QListViewItem* );
61 void itemClicked( QListViewItem* ); 57 void itemClicked( QListViewItem* );
62 58
63 private: 59 private:
64 void restoreExtensionSettings(); 60 void restoreExtensionSettings();
65 void saveExtensionSettings(); 61 void saveExtensionSettings();
66 62
diff --git a/kaddressbook/kcmconfigs/kcmkabconfig.cpp b/kaddressbook/kcmconfigs/kcmkabconfig.cpp
index b460a81..cbfedbd 100644
--- a/kaddressbook/kcmconfigs/kcmkabconfig.cpp
+++ b/kaddressbook/kcmconfigs/kcmkabconfig.cpp
@@ -30,55 +30,55 @@
30//#include <klocale.h> 30//#include <klocale.h>
31//#include <stdlib.h> 31//#include <stdlib.h>
32 32
33#include "kabconfigwidget.h" 33#include "kabconfigwidget.h"
34 34
35#include "kcmkabconfig.h" 35#include "kcmkabconfig.h"
36 36
37#include "kabprefs.h" 37#include "kabprefs.h"
38#include "kprefs.h" 38#include "kprefs.h"
39 39
40extern "C" 40extern "C"
41{ 41{
42 KCModule *create_kabconfig( KABPrefs* prefs, QWidget *parent, const char * ) { 42 KCModule *create_kabconfig( QWidget *parent, const char * ) {
43 return new KCMKabConfig( prefs, parent, "kcmkabconfig" ); 43 return new KCMKabConfig( parent, "kcmkabconfig" );
44 } 44 }
45} 45}
46 46
47KCMKabConfig::KCMKabConfig( KABPrefs* prefs, QWidget *parent, const char *name ) 47KCMKabConfig::KCMKabConfig( QWidget *parent, const char *name )
48 : KCModule( prefs, parent, name ) 48 : KCModule( KABPrefs::instance(), parent, name )
49{ 49{
50 //abort(); 50 //abort();
51 QVBoxLayout *layout = new QVBoxLayout( this ); 51 QVBoxLayout *layout = new QVBoxLayout( this );
52 mConfigWidget = new KABConfigWidget( this, "mConfigWidget" ); 52 mConfigWidget = new KABConfigWidget( (KABPrefs*)getPreferences(), this, "KABConfigWidget" );
53 layout->addWidget( mConfigWidget ); 53 layout->addWidget( mConfigWidget );
54 layout->setSpacing( 0 ); 54 layout->setSpacing( 0 );
55 layout->setMargin( 0 ); 55 layout->setMargin( 0 );
56 56
57 connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) ); 57 connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) );
58} 58}
59 59
60void KCMKabConfig::load() 60void KCMKabConfig::load()
61{ 61{
62 mConfigWidget->restoreSettings((KABPrefs*)getPreferences()); 62 mConfigWidget->readConfig();
63} 63}
64 64
65void KCMKabConfig::save() 65void KCMKabConfig::save()
66{ 66{
67 mConfigWidget->saveSettings((KABPrefs*)getPreferences()); 67 mConfigWidget->writeConfig();
68} 68}
69 69
70void KCMKabConfig::defaults() 70void KCMKabConfig::defaults()
71{ 71{
72 mConfigWidget->defaults((KABPrefs*)getPreferences()); 72 mConfigWidget->setDefaults();
73} 73}
74 74
75#ifndef KAB_EMBEDDED 75#ifndef KAB_EMBEDDED
76const KAboutData* KCMKabConfig::aboutData() const 76const KAboutData* KCMKabConfig::aboutData() const
77{ 77{
78 KAboutData *about = new KAboutData( I18N_NOOP( "kcmkabconfig" ), 78 KAboutData *about = new KAboutData( I18N_NOOP( "kcmkabconfig" ),
79 I18N_NOOP( "KAddressBook Configure Dialog" ), 79 I18N_NOOP( "KAddressBook Configure Dialog" ),
80 0, 0, KAboutData::License_GPL, 80 0, 0, KAboutData::License_GPL,
81 I18N_NOOP( "(c), 2003 Tobias Koenig" ) ); 81 I18N_NOOP( "(c), 2003 Tobias Koenig" ) );
82 82
83 about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); 83 about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" );
84 84
diff --git a/kaddressbook/kcmconfigs/kcmkabconfig.h b/kaddressbook/kcmconfigs/kcmkabconfig.h
index 1cb6ad3..2ecbfef 100644
--- a/kaddressbook/kcmconfigs/kcmkabconfig.h
+++ b/kaddressbook/kcmconfigs/kcmkabconfig.h
@@ -25,23 +25,23 @@
25#define KCMKABCONFIG_H 25#define KCMKABCONFIG_H
26 26
27#include <kcmodule.h> 27#include <kcmodule.h>
28 28
29class KABConfigWidget; 29class KABConfigWidget;
30class KABPrefs; 30class KABPrefs;
31 31
32class KCMKabConfig : public KCModule 32class KCMKabConfig : public KCModule
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35 35
36 public: 36 public:
37 KCMKabConfig( KABPrefs* prefs, QWidget *parent = 0, const char *name = 0 ); 37 KCMKabConfig( QWidget *parent = 0, const char *name = 0 );
38 38
39 virtual void load(); 39 virtual void load();
40 virtual void save(); 40 virtual void save();
41 virtual void defaults(); 41 virtual void defaults();
42 42
43 private: 43 private:
44 KABConfigWidget *mConfigWidget; 44 KABConfigWidget *mConfigWidget;
45}; 45};
46 46
47#endif 47#endif