-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 |
4 files changed, 24 insertions, 46 deletions
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 | |||
@@ -1,324 +1,306 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
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 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qframe.h> | 25 | #include <qframe.h> |
26 | #include <qgroupbox.h> | 26 | #include <qgroupbox.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qtabwidget.h> | 29 | #include <qtabwidget.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qvbox.h> | 34 | #include <qvbox.h> |
35 | 35 | ||
36 | #include <kconfig.h> | 36 | #include <kconfig.h> |
37 | #include <kdebug.h> | 37 | #include <kdebug.h> |
38 | #include <kdialog.h> | 38 | #include <kdialog.h> |
39 | #include <klistview.h> | 39 | #include <klistview.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kglobal.h> | 41 | #include <kglobal.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <ktrader.h> | 46 | #include <ktrader.h> |
47 | #else // KAB_EMBEDDED | 47 | #else // KAB_EMBEDDED |
48 | #include <mergewidget.h> | 48 | #include <mergewidget.h> |
49 | #include <distributionlistwidget.h> | 49 | #include <distributionlistwidget.h> |
50 | #endif // KAB_EMBEDDED | 50 | #endif // KAB_EMBEDDED |
51 | 51 | ||
52 | #include "addresseewidget.h" | 52 | #include "addresseewidget.h" |
53 | #include "extensionconfigdialog.h" | 53 | #include "extensionconfigdialog.h" |
54 | #include "extensionwidget.h" | 54 | #include "extensionwidget.h" |
55 | #include "kabprefs.h" | 55 | #include "kabprefs.h" |
56 | 56 | ||
57 | #include "kabconfigwidget.h" | 57 | #include "kabconfigwidget.h" |
58 | 58 | ||
59 | class ExtensionItem : public QCheckListItem | 59 | class ExtensionItem : public QCheckListItem |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | 62 | ||
63 | #ifndef KAB_EMBEDDED | 63 | #ifndef KAB_EMBEDDED |
64 | ExtensionItem( QListView *parent, const QString &text ); | 64 | ExtensionItem( QListView *parent, const QString &text ); |
65 | void setService( const KService::Ptr &ptr ); | 65 | void setService( const KService::Ptr &ptr ); |
66 | #else //KAB_EMBEDDED | 66 | #else //KAB_EMBEDDED |
67 | ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); | 67 | ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); |
68 | void setFactory( ExtensionFactory* fac ); | 68 | void setFactory( ExtensionFactory* fac ); |
69 | #endif //KAB_EMBEDDED | 69 | #endif //KAB_EMBEDDED |
70 | 70 | ||
71 | bool configWidgetAvailable() const; | 71 | bool configWidgetAvailable() const; |
72 | ExtensionFactory *factory() const; | 72 | ExtensionFactory *factory() const; |
73 | 73 | ||
74 | virtual QString text( int column ) const; | 74 | virtual QString text( int column ) const; |
75 | 75 | ||
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 | ||
88 | KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) | 88 | KABConfigWidget::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 |
102 | QVBox *vBox = new QVBox( generalPage, "qvbox" ); | 102 | QVBox *vBox = new QVBox( generalPage, "qvbox" ); |
103 | QVBoxLayout *boxLayout = new QVBoxLayout( vBox->layout(), -1, "qvboxlayout" ); | 103 | QVBoxLayout *boxLayout = new QVBoxLayout( vBox->layout(), -1, "qvboxlayout" ); |
104 | boxLayout->setAlignment( Qt::AlignTop ); | 104 | boxLayout->setAlignment( Qt::AlignTop ); |
105 | boxLayout->setMargin(KDialog::marginHintSmall() ); | 105 | boxLayout->setMargin(KDialog::marginHintSmall() ); |
106 | vBox->layout()->setMargin(KDialog::marginHintSmall()) ; | 106 | vBox->layout()->setMargin(KDialog::marginHintSmall()) ; |
107 | vBox->layout()->setSpacing(KDialog::spacingHintSmall()); | 107 | vBox->layout()->setSpacing(KDialog::spacingHintSmall()); |
108 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); | 108 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); |
109 | mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); | 109 | mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); |
110 | boxLayout->addWidget( mSearchReturnBox ); | 110 | boxLayout->addWidget( mSearchReturnBox ); |
111 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); | 111 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); |
112 | boxLayout->addWidget( mViewsSingleClickBox ); | 112 | boxLayout->addWidget( mViewsSingleClickBox ); |
113 | 113 | ||
114 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); | 114 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); |
115 | boxLayout->addWidget( mNameParsing ); | 115 | boxLayout->addWidget( mNameParsing ); |
116 | 116 | ||
117 | mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); | 117 | mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); |
118 | boxLayout->addWidget( mMultipleViewsAtOnce ); | 118 | boxLayout->addWidget( mMultipleViewsAtOnce ); |
119 | 119 | ||
120 | mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); | 120 | mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); |
121 | boxLayout->addWidget( mAskForQuit ); | 121 | boxLayout->addWidget( mAskForQuit ); |
122 | 122 | ||
123 | layout->addWidget( vBox ); | 123 | layout->addWidget( vBox ); |
124 | 124 | ||
125 | tabWidget->addTab( generalPage, i18n( "General" ) ); | 125 | tabWidget->addTab( generalPage, i18n( "General" ) ); |
126 | 126 | ||
127 | // Extension page | 127 | // Extension page |
128 | QWidget *extensionPage = new QWidget( this ); | 128 | QWidget *extensionPage = new QWidget( this ); |
129 | QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), | 129 | QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), |
130 | KDialog::spacingHintSmall() ); | 130 | KDialog::spacingHintSmall() ); |
131 | 131 | ||
132 | //extensions groupbox | 132 | //extensions groupbox |
133 | 133 | ||
134 | QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); | 134 | QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); |
135 | boxLayout = new QVBoxLayout( groupBox->layout() ); | 135 | boxLayout = new QVBoxLayout( groupBox->layout() ); |
136 | boxLayout->setAlignment( Qt::AlignTop ); | 136 | boxLayout->setAlignment( Qt::AlignTop ); |
137 | boxLayout->setMargin(KDialog::marginHintSmall()); | 137 | boxLayout->setMargin(KDialog::marginHintSmall()); |
138 | boxLayout->setSpacing(KDialog::spacingHintSmall()); | 138 | boxLayout->setSpacing(KDialog::spacingHintSmall()); |
139 | groupBox->layout()->setMargin(1) ; | 139 | groupBox->layout()->setMargin(1) ; |
140 | groupBox->layout()->setSpacing(0); | 140 | groupBox->layout()->setSpacing(0); |
141 | mExtensionView = new KListView( groupBox ); | 141 | mExtensionView = new KListView( groupBox ); |
142 | mExtensionView->setAllColumnsShowFocus( true ); | 142 | mExtensionView->setAllColumnsShowFocus( true ); |
143 | mExtensionView->addColumn( i18n( "Name" ) ); | 143 | mExtensionView->addColumn( i18n( "Name" ) ); |
144 | mExtensionView->addColumn( i18n( "Description" ) ); | 144 | mExtensionView->addColumn( i18n( "Description" ) ); |
145 | mExtensionView->setMaximumHeight(80); | 145 | mExtensionView->setMaximumHeight(80); |
146 | 146 | ||
147 | boxLayout->addWidget( mExtensionView ); | 147 | boxLayout->addWidget( mExtensionView ); |
148 | 148 | ||
149 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); | 149 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); |
150 | mConfigureButton->setEnabled( false ); | 150 | mConfigureButton->setEnabled( false ); |
151 | boxLayout->addWidget( mConfigureButton ); | 151 | boxLayout->addWidget( mConfigureButton ); |
152 | 152 | ||
153 | extensionLayout->addWidget( groupBox ); | 153 | extensionLayout->addWidget( groupBox ); |
154 | 154 | ||
155 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 155 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
156 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 156 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
157 | connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 157 | connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
158 | connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 158 | connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
159 | connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 159 | connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
160 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), | 160 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), |
161 | SLOT( selectionChanged( QListViewItem* ) ) ); | 161 | SLOT( selectionChanged( QListViewItem* ) ) ); |
162 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), | 162 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), |
163 | SLOT( itemClicked( QListViewItem* ) ) ); | 163 | SLOT( itemClicked( QListViewItem* ) ) ); |
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 | 176 | void KABConfigWidget::usrReadConfig() | |
177 | void 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 | ||
199 | void KABConfigWidget::saveSettings(KABPrefs* prefs) | 197 | void 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 | |||
215 | void 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 | |||
226 | void KABConfigWidget::modified() | ||
227 | { | ||
228 | emit changed( true ); | ||
229 | } | 211 | } |
230 | 212 | ||
231 | void KABConfigWidget::restoreExtensionSettings() | 213 | void 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 ) { |
241 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) | 223 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) |
242 | continue; | 224 | continue; |
243 | 225 | ||
244 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); | 226 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); |
245 | item->setService( *it ); | 227 | item->setService( *it ); |
246 | if ( activeExtensions.contains( item->factory()->identifier() ) ) | 228 | if ( activeExtensions.contains( item->factory()->identifier() ) ) |
247 | item->setOn( true ); | 229 | item->setOn( true ); |
248 | } | 230 | } |
249 | #else //KAB_EMBEDDED | 231 | #else //KAB_EMBEDDED |
250 | ExtensionFactory *extensionFactory = new MergeFactory(); | 232 | ExtensionFactory *extensionFactory = new MergeFactory(); |
251 | 233 | ||
252 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); | 234 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); |
253 | 235 | ||
254 | item->setFactory( extensionFactory ); | 236 | item->setFactory( extensionFactory ); |
255 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 237 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
256 | item->setOn( true ); | 238 | item->setOn( true ); |
257 | 239 | ||
258 | 240 | ||
259 | 241 | ||
260 | extensionFactory = new DistributionListFactory(); | 242 | extensionFactory = new DistributionListFactory(); |
261 | 243 | ||
262 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); | 244 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); |
263 | 245 | ||
264 | item->setFactory( extensionFactory ); | 246 | item->setFactory( extensionFactory ); |
265 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 247 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
266 | item->setOn( true ); | 248 | item->setOn( true ); |
267 | 249 | ||
268 | 250 | ||
269 | #endif //KAB_EMBEDDED | 251 | #endif //KAB_EMBEDDED |
270 | 252 | ||
271 | } | 253 | } |
272 | 254 | ||
273 | void KABConfigWidget::saveExtensionSettings() | 255 | void KABConfigWidget::saveExtensionSettings() |
274 | { | 256 | { |
275 | QStringList activeExtensions; | 257 | QStringList activeExtensions; |
276 | 258 | ||
277 | QPtrList<QListViewItem> list; | 259 | QPtrList<QListViewItem> list; |
278 | QListViewItemIterator it( mExtensionView ); | 260 | QListViewItemIterator it( mExtensionView ); |
279 | while ( it.current() ) { | 261 | while ( it.current() ) { |
280 | ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); | 262 | ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); |
281 | if ( item ) { | 263 | if ( item ) { |
282 | if ( item->isOn() ) | 264 | if ( item->isOn() ) |
283 | activeExtensions.append( item->factory()->identifier() ); | 265 | activeExtensions.append( item->factory()->identifier() ); |
284 | } | 266 | } |
285 | ++it; | 267 | ++it; |
286 | } | 268 | } |
287 | 269 | ||
288 | KABPrefs::instance()->mActiveExtensions = activeExtensions; | 270 | KABPrefs::instance()->mActiveExtensions = activeExtensions; |
289 | } | 271 | } |
290 | 272 | ||
291 | void KABConfigWidget::configureExtension() | 273 | void KABConfigWidget::configureExtension() |
292 | { | 274 | { |
293 | ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); | 275 | ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); |
294 | if ( !item ) | 276 | if ( !item ) |
295 | return; | 277 | return; |
296 | 278 | ||
297 | #ifndef KAB_EMBEDDED | 279 | #ifndef KAB_EMBEDDED |
298 | KConfig config( "kaddressbookrc" ); | 280 | KConfig config( "kaddressbookrc" ); |
299 | #else //KAB_EMBEDDED | 281 | #else //KAB_EMBEDDED |
300 | KConfig config( locateLocal("config", "kaddressbookrc") ); | 282 | KConfig config( locateLocal("config", "kaddressbookrc") ); |
301 | #endif //KAB_EMBEDDED | 283 | #endif //KAB_EMBEDDED |
302 | config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); | 284 | config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); |
303 | 285 | ||
304 | ExtensionConfigDialog dlg( item->factory(), &config, this ); | 286 | ExtensionConfigDialog dlg( item->factory(), &config, this ); |
305 | dlg.exec(); | 287 | dlg.exec(); |
306 | 288 | ||
307 | config.sync(); | 289 | config.sync(); |
308 | } | 290 | } |
309 | 291 | ||
310 | void KABConfigWidget::selectionChanged( QListViewItem *i ) | 292 | void KABConfigWidget::selectionChanged( QListViewItem *i ) |
311 | { | 293 | { |
312 | ExtensionItem *item = static_cast<ExtensionItem*>( i ); | 294 | ExtensionItem *item = static_cast<ExtensionItem*>( i ); |
313 | if ( !item ) | 295 | if ( !item ) |
314 | return; | 296 | return; |
315 | 297 | ||
316 | mConfigureButton->setEnabled( item->configWidgetAvailable() ); | 298 | mConfigureButton->setEnabled( item->configWidgetAvailable() ); |
317 | } | 299 | } |
318 | 300 | ||
319 | void KABConfigWidget::itemClicked( QListViewItem *item ) | 301 | void KABConfigWidget::itemClicked( QListViewItem *item ) |
320 | { | 302 | { |
321 | if ( item != 0 ) | 303 | if ( item != 0 ) |
322 | modified(); | 304 | modified(); |
323 | } | 305 | } |
324 | 306 | ||
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 | |||
@@ -1,79 +1,75 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
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 | ||
29 | class QCheckBox; | 29 | class QCheckBox; |
30 | class QListViewItem; | 30 | class QListViewItem; |
31 | class QPushButton; | 31 | class QPushButton; |
32 | class QComboBox; | 32 | class QComboBox; |
33 | class QLineEdit; | 33 | class QLineEdit; |
34 | class KListView; | 34 | class KListView; |
35 | class KABPrefs; | 35 | class KABPrefs; |
36 | 36 | ||
37 | class AddresseeWidget; | 37 | class AddresseeWidget; |
38 | 38 | ||
39 | class KABConfigWidget : public QWidget | 39 | class 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 | ||
67 | KListView *mExtensionView; | 63 | KListView *mExtensionView; |
68 | QCheckBox *mSearchReturnBox; | 64 | QCheckBox *mSearchReturnBox; |
69 | QCheckBox *mNameParsing; | 65 | QCheckBox *mNameParsing; |
70 | QCheckBox *mViewsSingleClickBox; | 66 | QCheckBox *mViewsSingleClickBox; |
71 | QCheckBox *mMultipleViewsAtOnce; | 67 | QCheckBox *mMultipleViewsAtOnce; |
72 | QCheckBox *mAskForQuit; | 68 | QCheckBox *mAskForQuit; |
73 | 69 | ||
74 | QPushButton *mConfigureButton; | 70 | QPushButton *mConfigureButton; |
75 | 71 | ||
76 | AddresseeWidget *mAddresseeWidget; | 72 | AddresseeWidget *mAddresseeWidget; |
77 | }; | 73 | }; |
78 | 74 | ||
79 | #endif | 75 | #endif |
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 | |||
@@ -1,92 +1,92 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
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 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | 25 | ||
26 | #ifndef KAB_EMBEDDED | 26 | #ifndef KAB_EMBEDDED |
27 | #include <kaboutdata.h> | 27 | #include <kaboutdata.h> |
28 | #endif //KAB_EMBEDDED | 28 | #endif //KAB_EMBEDDED |
29 | #include <kdebug.h> | 29 | #include <kdebug.h> |
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 | ||
40 | extern "C" | 40 | extern "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 | ||
47 | KCMKabConfig::KCMKabConfig( KABPrefs* prefs, QWidget *parent, const char *name ) | 47 | KCMKabConfig::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 | ||
60 | void KCMKabConfig::load() | 60 | void KCMKabConfig::load() |
61 | { | 61 | { |
62 | mConfigWidget->restoreSettings((KABPrefs*)getPreferences()); | 62 | mConfigWidget->readConfig(); |
63 | } | 63 | } |
64 | 64 | ||
65 | void KCMKabConfig::save() | 65 | void KCMKabConfig::save() |
66 | { | 66 | { |
67 | mConfigWidget->saveSettings((KABPrefs*)getPreferences()); | 67 | mConfigWidget->writeConfig(); |
68 | } | 68 | } |
69 | 69 | ||
70 | void KCMKabConfig::defaults() | 70 | void KCMKabConfig::defaults() |
71 | { | 71 | { |
72 | mConfigWidget->defaults((KABPrefs*)getPreferences()); | 72 | mConfigWidget->setDefaults(); |
73 | } | 73 | } |
74 | 74 | ||
75 | #ifndef KAB_EMBEDDED | 75 | #ifndef KAB_EMBEDDED |
76 | const KAboutData* KCMKabConfig::aboutData() const | 76 | const 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 | ||
85 | return about; | 85 | return about; |
86 | 86 | ||
87 | } | 87 | } |
88 | #endif //KAB_EMBEDDED | 88 | #endif //KAB_EMBEDDED |
89 | 89 | ||
90 | #ifndef KAB_EMBEDDED | 90 | #ifndef KAB_EMBEDDED |
91 | #include "kcmkabconfig.moc" | 91 | #include "kcmkabconfig.moc" |
92 | #endif //KAB_EMBEDDED | 92 | #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 | |||
@@ -1,47 +1,47 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
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 KCMKABCONFIG_H | 24 | #ifndef KCMKABCONFIG_H |
25 | #define KCMKABCONFIG_H | 25 | #define KCMKABCONFIG_H |
26 | 26 | ||
27 | #include <kcmodule.h> | 27 | #include <kcmodule.h> |
28 | 28 | ||
29 | class KABConfigWidget; | 29 | class KABConfigWidget; |
30 | class KABPrefs; | 30 | class KABPrefs; |
31 | 31 | ||
32 | class KCMKabConfig : public KCModule | 32 | class 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 |