author | ulf69 <ulf69> | 2004-09-21 19:54:39 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-21 19:54:39 (UTC) |
commit | 618dec7bf4371c2085048cc1f95a93220bc8a233 (patch) (side-by-side diff) | |
tree | df5e3e47a417400fa9f6871912eda6558294d9b4 | |
parent | 186ee062d9169860fbab1613ca21b956c69296a6 (diff) | |
download | kdepimpi-618dec7bf4371c2085048cc1f95a93220bc8a233.zip kdepimpi-618dec7bf4371c2085048cc1f95a93220bc8a233.tar.gz kdepimpi-618dec7bf4371c2085048cc1f95a93220bc8a233.tar.bz2 |
modified configdialog to work properly with global configwidget from (libkdepim)
-rw-r--r-- | kaddressbook/kabcore.cpp | 9 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.cpp | 32 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.h | 20 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kcmkabconfig.cpp | 16 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kcmkabconfig.h | 2 |
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 @@ -1262,59 +1262,54 @@ QString KABCore::getNameByPhone( const QString &phone ) KABC::PhoneNumber::List::Iterator phoneIter; KABC::PhoneNumber::List phoneList; for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { phoneList = (*iter).phoneNumbers(); for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); ++phoneIter) { // Get rid of separator chars so just the numbers are compared. if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { ownerName = (*iter).formattedName(); found = true; } } } return ownerName; #else //KAB_EMBEDDED qDebug("KABCore::getNameByPhone finsih method"); return ""; #endif //KAB_EMBEDDED } void KABCore::openConfigDialog() { - KABPrefs* kab_prefs = KABPrefs::instance(); - KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); - KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); - KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); + KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); ConfigureDialog->addModule(kabcfg ); - KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); + KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); ConfigureDialog->addModule(kdelibcfg ); - - connect( ConfigureDialog, SIGNAL( applyClicked() ), this, SLOT( configurationChanged() ) ); connect( ConfigureDialog, SIGNAL( okClicked() ), this, SLOT( configurationChanged() ) ); saveSettings(); #ifndef DESKTOP_VERSION ConfigureDialog->showMaximized(); #endif if ( ConfigureDialog->exec() ) KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); delete ConfigureDialog; } void KABCore::openLDAPDialog() { #ifndef KAB_EMBEDDED if ( !mLdapSearchDialog ) { mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, SLOT( refreshView() ) ); connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, SLOT( setModified() ) ); } else mLdapSearchDialog->restoreSettings(); 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 @@ -64,50 +64,50 @@ class ExtensionItem : public QCheckListItem ExtensionItem( QListView *parent, const QString &text ); void setService( const KService::Ptr &ptr ); #else //KAB_EMBEDDED ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); void setFactory( ExtensionFactory* fac ); #endif //KAB_EMBEDDED bool configWidgetAvailable() const; ExtensionFactory *factory() const; virtual QString text( int column ) const; private: #ifndef KAB_EMBEDDED KService::Ptr mPtr; #else //KAB_EMBEDDED ExtensionFactory* mFactory; QString mName; QString mComment; #endif //KAB_EMBEDDED }; -KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) - : QWidget( parent, name ) +KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name ) + : KPrefsWidget( prefs, parent, name ) { QVBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() ); QTabWidget *tabWidget = new QTabWidget( this ); topLayout->addWidget( tabWidget ); // General page QWidget *generalPage = new QWidget( this ); QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), KDialog::spacingHintSmall() ); //general groupbox QVBox *vBox = new QVBox( generalPage, "qvbox" ); QVBoxLayout *boxLayout = new QVBoxLayout( vBox->layout(), -1, "qvboxlayout" ); boxLayout->setAlignment( Qt::AlignTop ); boxLayout->setMargin(KDialog::marginHintSmall() ); vBox->layout()->setMargin(KDialog::marginHintSmall()) ; vBox->layout()->setSpacing(KDialog::spacingHintSmall()); boxLayout->setSpacing( KDialog::spacingHintSmall() ); mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); boxLayout->addWidget( mSearchReturnBox ); mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); boxLayout->addWidget( mViewsSingleClickBox ); @@ -152,101 +152,83 @@ KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) extensionLayout->addWidget( groupBox ); connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), SLOT( selectionChanged( QListViewItem* ) ) ); connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), SLOT( itemClicked( QListViewItem* ) ) ); connect( mConfigureButton, SIGNAL( clicked() ), SLOT( configureExtension() ) ); tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); // Addressee page mAddresseeWidget = new AddresseeWidget( this ); tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); } - -void KABConfigWidget::restoreSettings(KABPrefs* prefs) +void KABConfigWidget::usrReadConfig() { -//US prefs was KABPrefs::instance() before + KABPrefs* prefs = KABPrefs::instance(); bool blocked = signalsBlocked(); blockSignals( true ); mNameParsing->setChecked( prefs->mAutomaticNameParsing ); mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); mAskForQuit->setChecked( prefs->mAskForQuit ); mAddresseeWidget->restoreSettings(); restoreExtensionSettings(); blockSignals( blocked ); - emit changed( false ); } -void KABConfigWidget::saveSettings(KABPrefs* prefs) +void KABConfigWidget::usrWriteConfig() { + KABPrefs* prefs = KABPrefs::instance(); + prefs->mAutomaticNameParsing = mNameParsing->isChecked(); prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); prefs->mAskForQuit = mAskForQuit->isChecked(); mAddresseeWidget->saveSettings(); saveExtensionSettings(); - KABPrefs::instance()->writeConfig(); - emit changed( false ); -} - -void KABConfigWidget::defaults(KABPrefs* prefs) -{ - mNameParsing->setChecked( true ); - mViewsSingleClickBox->setChecked( false ); - mMultipleViewsAtOnce->setChecked( true ); - mSearchReturnBox->setChecked( true ); - mAskForQuit->setChecked (true); - - emit changed( true ); -} - -void KABConfigWidget::modified() -{ - emit changed( true ); } void KABConfigWidget::restoreExtensionSettings() { QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; mExtensionView->clear(); #ifndef KAB_EMBEDDED KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); KTrader::OfferList::ConstIterator it; for ( it = plugins.begin(); it != plugins.end(); ++it ) { if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) continue; ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); item->setService( *it ); if ( activeExtensions.contains( item->factory()->identifier() ) ) item->setOn( true ); } #else //KAB_EMBEDDED ExtensionFactory *extensionFactory = new MergeFactory(); ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); 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 @@ -3,76 +3,72 @@ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef KABCONFIGWIDGET_H #define KABCONFIGWIDGET_H -#include <qwidget.h> +#include <kprefswidget.h> class QCheckBox; class QListViewItem; class QPushButton; class QComboBox; class QLineEdit; class KListView; class KABPrefs; class AddresseeWidget; -class KABConfigWidget : public QWidget +class KABConfigWidget : public KPrefsWidget { Q_OBJECT public: - KABConfigWidget( QWidget *parent, const char *name = 0 ); + KABConfigWidget(KABPrefs *prefs, QWidget *parent, const char *name = 0 ); - void restoreSettings(KABPrefs* prefs); - void saveSettings(KABPrefs* prefs); - void defaults(KABPrefs* prefs); - - signals: - void changed( bool ); - - public slots: - void modified(); + protected: + /** Implement this to read custom configuration widgets. */ + virtual void usrReadConfig(); + /** Implement this to write custom configuration widgets. */ + virtual void usrWriteConfig(); private slots: void configureExtension(); void selectionChanged( QListViewItem* ); void itemClicked( QListViewItem* ); private: void restoreExtensionSettings(); void saveExtensionSettings(); KListView *mExtensionView; QCheckBox *mSearchReturnBox; QCheckBox *mNameParsing; QCheckBox *mViewsSingleClickBox; QCheckBox *mMultipleViewsAtOnce; QCheckBox *mAskForQuit; QPushButton *mConfigureButton; AddresseeWidget *mAddresseeWidget; }; 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 @@ -18,75 +18,75 @@ As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qlayout.h> #ifndef KAB_EMBEDDED #include <kaboutdata.h> #endif //KAB_EMBEDDED #include <kdebug.h> //#include <klocale.h> //#include <stdlib.h> #include "kabconfigwidget.h" #include "kcmkabconfig.h" #include "kabprefs.h" #include "kprefs.h" extern "C" { - KCModule *create_kabconfig( KABPrefs* prefs, QWidget *parent, const char * ) { - return new KCMKabConfig( prefs, parent, "kcmkabconfig" ); + KCModule *create_kabconfig( QWidget *parent, const char * ) { + return new KCMKabConfig( parent, "kcmkabconfig" ); } } -KCMKabConfig::KCMKabConfig( KABPrefs* prefs, QWidget *parent, const char *name ) - : KCModule( prefs, parent, name ) +KCMKabConfig::KCMKabConfig( QWidget *parent, const char *name ) + : KCModule( KABPrefs::instance(), parent, name ) { //abort(); QVBoxLayout *layout = new QVBoxLayout( this ); - mConfigWidget = new KABConfigWidget( this, "mConfigWidget" ); + mConfigWidget = new KABConfigWidget( (KABPrefs*)getPreferences(), this, "KABConfigWidget" ); layout->addWidget( mConfigWidget ); layout->setSpacing( 0 ); layout->setMargin( 0 ); connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) ); } void KCMKabConfig::load() { - mConfigWidget->restoreSettings((KABPrefs*)getPreferences()); + mConfigWidget->readConfig(); } void KCMKabConfig::save() { - mConfigWidget->saveSettings((KABPrefs*)getPreferences()); + mConfigWidget->writeConfig(); } void KCMKabConfig::defaults() { - mConfigWidget->defaults((KABPrefs*)getPreferences()); + mConfigWidget->setDefaults(); } #ifndef KAB_EMBEDDED const KAboutData* KCMKabConfig::aboutData() const { KAboutData *about = new KAboutData( I18N_NOOP( "kcmkabconfig" ), I18N_NOOP( "KAddressBook Configure Dialog" ), 0, 0, KAboutData::License_GPL, I18N_NOOP( "(c), 2003 Tobias Koenig" ) ); about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); return about; } #endif //KAB_EMBEDDED #ifndef KAB_EMBEDDED #include "kcmkabconfig.moc" #endif //KAB_EMBEDDED 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 @@ -13,35 +13,35 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef KCMKABCONFIG_H #define KCMKABCONFIG_H #include <kcmodule.h> class KABConfigWidget; class KABPrefs; class KCMKabConfig : public KCModule { Q_OBJECT public: - KCMKabConfig( KABPrefs* prefs, QWidget *parent = 0, const char *name = 0 ); + KCMKabConfig( QWidget *parent = 0, const char *name = 0 ); virtual void load(); virtual void save(); virtual void defaults(); private: KABConfigWidget *mConfigWidget; }; #endif |