-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.cpp | 36 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.h | 1 |
2 files changed, 26 insertions, 11 deletions
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp index 31ab7b5..3a2ccbb 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp +++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp | |||
@@ -1,383 +1,397 @@ | |||
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 | 35 | ||
35 | #include <kconfig.h> | 36 | #include <kconfig.h> |
36 | #include <kdebug.h> | 37 | #include <kdebug.h> |
37 | #include <kdialog.h> | 38 | #include <kdialog.h> |
38 | #include <klistview.h> | 39 | #include <klistview.h> |
39 | #include <klocale.h> | 40 | #include <klocale.h> |
40 | #include <kglobal.h> | 41 | #include <kglobal.h> |
41 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
42 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
43 | 44 | ||
44 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
45 | #include <ktrader.h> | 46 | #include <ktrader.h> |
46 | #else // KAB_EMBEDDED | 47 | #else // KAB_EMBEDDED |
47 | #include <mergewidget.h> | 48 | #include <mergewidget.h> |
48 | #include <distributionlistwidget.h> | 49 | #include <distributionlistwidget.h> |
49 | #endif // KAB_EMBEDDED | 50 | #endif // KAB_EMBEDDED |
50 | 51 | ||
51 | #include "addresseewidget.h" | 52 | #include "addresseewidget.h" |
52 | #include "extensionconfigdialog.h" | 53 | #include "extensionconfigdialog.h" |
53 | #include "extensionwidget.h" | 54 | #include "extensionwidget.h" |
54 | #include "kabprefs.h" | 55 | #include "kabprefs.h" |
55 | 56 | ||
56 | #include "kabconfigwidget.h" | 57 | #include "kabconfigwidget.h" |
57 | 58 | ||
58 | class ExtensionItem : public QCheckListItem | 59 | class ExtensionItem : public QCheckListItem |
59 | { | 60 | { |
60 | public: | 61 | public: |
61 | 62 | ||
62 | #ifndef KAB_EMBEDDED | 63 | #ifndef KAB_EMBEDDED |
63 | ExtensionItem( QListView *parent, const QString &text ); | 64 | ExtensionItem( QListView *parent, const QString &text ); |
64 | void setService( const KService::Ptr &ptr ); | 65 | void setService( const KService::Ptr &ptr ); |
65 | #else //KAB_EMBEDDED | 66 | #else //KAB_EMBEDDED |
66 | 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 ); |
67 | void setFactory( ExtensionFactory* fac ); | 68 | void setFactory( ExtensionFactory* fac ); |
68 | #endif //KAB_EMBEDDED | 69 | #endif //KAB_EMBEDDED |
69 | 70 | ||
70 | bool configWidgetAvailable() const; | 71 | bool configWidgetAvailable() const; |
71 | ExtensionFactory *factory() const; | 72 | ExtensionFactory *factory() const; |
72 | 73 | ||
73 | virtual QString text( int column ) const; | 74 | virtual QString text( int column ) const; |
74 | 75 | ||
75 | private: | 76 | private: |
76 | #ifndef KAB_EMBEDDED | 77 | #ifndef KAB_EMBEDDED |
77 | KService::Ptr mPtr; | 78 | KService::Ptr mPtr; |
78 | #else //KAB_EMBEDDED | 79 | #else //KAB_EMBEDDED |
79 | ExtensionFactory* mFactory; | 80 | ExtensionFactory* mFactory; |
80 | QString mName; | 81 | QString mName; |
81 | QString mComment; | 82 | QString mComment; |
82 | 83 | ||
83 | #endif //KAB_EMBEDDED | 84 | #endif //KAB_EMBEDDED |
84 | 85 | ||
85 | }; | 86 | }; |
86 | 87 | ||
87 | KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) | 88 | KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) |
88 | : QWidget( parent, name ) | 89 | : QWidget( parent, name ) |
89 | { | 90 | { |
90 | QVBoxLayout *topLayout = new QVBoxLayout( this, 0, | 91 | QVBoxLayout *topLayout = new QVBoxLayout( this, 0, |
91 | KDialog::spacingHint() ); | 92 | KDialog::spacingHint() ); |
92 | 93 | ||
93 | QTabWidget *tabWidget = new QTabWidget( this ); | 94 | QTabWidget *tabWidget = new QTabWidget( this ); |
94 | topLayout->addWidget( tabWidget ); | 95 | topLayout->addWidget( tabWidget ); |
95 | 96 | ||
96 | // General page | 97 | // General page |
97 | QWidget *generalPage = new QWidget( this ); | 98 | QWidget *generalPage = new QWidget( this ); |
98 | QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), | 99 | QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), |
99 | KDialog::spacingHintSmall() ); | 100 | KDialog::spacingHintSmall() ); |
100 | //general groupbox | 101 | //general groupbox |
101 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage ); | 102 | QVBox *vBox = new QVBox( generalPage, "qvbox" ); |
102 | QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() ); | 103 | QVBoxLayout *boxLayout = new QVBoxLayout( vBox->layout(), -1, "qvboxlayout" ); |
103 | boxLayout->setAlignment( Qt::AlignTop ); | 104 | boxLayout->setAlignment( Qt::AlignTop ); |
104 | boxLayout->setMargin(KDialog::marginHintSmall() ); | 105 | boxLayout->setMargin(KDialog::marginHintSmall() ); |
105 | groupBox->layout()->setMargin(KDialog::marginHintSmall()) ; | 106 | vBox->layout()->setMargin(KDialog::marginHintSmall()) ; |
106 | groupBox->layout()->setSpacing(KDialog::spacingHintSmall()); | 107 | vBox->layout()->setSpacing(KDialog::spacingHintSmall()); |
107 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); | 108 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); |
108 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" ); | 109 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); |
109 | boxLayout->addWidget( mViewsSingleClickBox ); | 110 | boxLayout->addWidget( mViewsSingleClickBox ); |
110 | 111 | ||
111 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" ); | 112 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); |
112 | boxLayout->addWidget( mNameParsing ); | 113 | boxLayout->addWidget( mNameParsing ); |
113 | 114 | ||
114 | mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), groupBox, "mdisplay" ); | 115 | mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); |
115 | boxLayout->addWidget( mMultipleViewsAtOnce ); | 116 | boxLayout->addWidget( mMultipleViewsAtOnce ); |
116 | 117 | ||
117 | layout->addWidget( groupBox ); | 118 | mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); |
119 | boxLayout->addWidget( mAskForQuit ); | ||
118 | 120 | ||
121 | layout->addWidget( vBox ); | ||
122 | |||
123 | tabWidget->addTab( generalPage, i18n( "General" ) ); | ||
124 | |||
125 | // Extension page | ||
126 | QWidget *extensionPage = new QWidget( this ); | ||
127 | QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), | ||
128 | KDialog::spacingHintSmall() ); | ||
119 | 129 | ||
120 | //extensions groupbox | 130 | //extensions groupbox |
121 | 131 | ||
122 | groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), generalPage ); | 132 | QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); |
123 | boxLayout = new QVBoxLayout( groupBox->layout() ); | 133 | boxLayout = new QVBoxLayout( groupBox->layout() ); |
124 | boxLayout->setAlignment( Qt::AlignTop ); | 134 | boxLayout->setAlignment( Qt::AlignTop ); |
125 | boxLayout->setMargin(KDialog::marginHintSmall()); | 135 | boxLayout->setMargin(KDialog::marginHintSmall()); |
126 | boxLayout->setSpacing(KDialog::spacingHintSmall()); | 136 | boxLayout->setSpacing(KDialog::spacingHintSmall()); |
127 | groupBox->layout()->setMargin(1) ; | 137 | groupBox->layout()->setMargin(1) ; |
128 | groupBox->layout()->setSpacing(0); | 138 | groupBox->layout()->setSpacing(0); |
129 | mExtensionView = new KListView( groupBox ); | 139 | mExtensionView = new KListView( groupBox ); |
130 | mExtensionView->setAllColumnsShowFocus( true ); | 140 | mExtensionView->setAllColumnsShowFocus( true ); |
131 | mExtensionView->addColumn( i18n( "Name" ) ); | 141 | mExtensionView->addColumn( i18n( "Name" ) ); |
132 | mExtensionView->addColumn( i18n( "Description" ) ); | 142 | mExtensionView->addColumn( i18n( "Description" ) ); |
133 | mExtensionView->setMaximumHeight(80); | 143 | mExtensionView->setMaximumHeight(80); |
134 | 144 | ||
135 | boxLayout->addWidget( mExtensionView ); | 145 | boxLayout->addWidget( mExtensionView ); |
136 | 146 | ||
137 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); | 147 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); |
138 | mConfigureButton->setEnabled( false ); | 148 | mConfigureButton->setEnabled( false ); |
139 | boxLayout->addWidget( mConfigureButton ); | 149 | boxLayout->addWidget( mConfigureButton ); |
140 | 150 | ||
141 | layout->addWidget( groupBox ); | 151 | extensionLayout->addWidget( groupBox ); |
142 | 152 | ||
143 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 153 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
144 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 154 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
145 | connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 155 | connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
156 | connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | ||
146 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), | 157 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), |
147 | SLOT( selectionChanged( QListViewItem* ) ) ); | 158 | SLOT( selectionChanged( QListViewItem* ) ) ); |
148 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), | 159 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), |
149 | SLOT( itemClicked( QListViewItem* ) ) ); | 160 | SLOT( itemClicked( QListViewItem* ) ) ); |
150 | connect( mConfigureButton, SIGNAL( clicked() ), | 161 | connect( mConfigureButton, SIGNAL( clicked() ), |
151 | SLOT( configureExtension() ) ); | 162 | SLOT( configureExtension() ) ); |
152 | 163 | ||
153 | tabWidget->addTab( generalPage, i18n( "General" ) ); | 164 | tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); |
154 | 165 | ||
155 | // Addressee page | 166 | // Addressee page |
156 | mAddresseeWidget = new AddresseeWidget( this ); | 167 | mAddresseeWidget = new AddresseeWidget( this ); |
157 | tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); | 168 | tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); |
158 | connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); | 169 | connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); |
159 | 170 | ||
160 | } | 171 | } |
161 | 172 | ||
162 | 173 | ||
163 | void KABConfigWidget::restoreSettings(KABPrefs* prefs) | 174 | void KABConfigWidget::restoreSettings(KABPrefs* prefs) |
164 | { | 175 | { |
165 | //US prefs was KABPrefs::instance() before | 176 | //US prefs was KABPrefs::instance() before |
166 | 177 | ||
167 | bool blocked = signalsBlocked(); | 178 | bool blocked = signalsBlocked(); |
168 | blockSignals( true ); | 179 | blockSignals( true ); |
169 | 180 | ||
170 | mNameParsing->setChecked( prefs->mAutomaticNameParsing ); | 181 | mNameParsing->setChecked( prefs->mAutomaticNameParsing ); |
171 | mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); | 182 | mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); |
172 | mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); | 183 | mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); |
184 | mAskForQuit->setChecked( prefs->mAskForQuit ); | ||
173 | 185 | ||
174 | mAddresseeWidget->restoreSettings(); | 186 | mAddresseeWidget->restoreSettings(); |
175 | 187 | ||
176 | restoreExtensionSettings(); | 188 | restoreExtensionSettings(); |
177 | 189 | ||
178 | blockSignals( blocked ); | 190 | blockSignals( blocked ); |
179 | 191 | ||
180 | emit changed( false ); | 192 | emit changed( false ); |
181 | } | 193 | } |
182 | 194 | ||
183 | void KABConfigWidget::saveSettings(KABPrefs* prefs) | 195 | void KABConfigWidget::saveSettings(KABPrefs* prefs) |
184 | { | 196 | { |
185 | prefs->mAutomaticNameParsing = mNameParsing->isChecked(); | 197 | prefs->mAutomaticNameParsing = mNameParsing->isChecked(); |
186 | prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); | 198 | prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); |
187 | prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); | 199 | prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); |
200 | prefs->mAskForQuit = mAskForQuit->isChecked(); | ||
188 | 201 | ||
189 | mAddresseeWidget->saveSettings(); | 202 | mAddresseeWidget->saveSettings(); |
190 | 203 | ||
191 | saveExtensionSettings(); | 204 | saveExtensionSettings(); |
192 | KABPrefs::instance()->writeConfig(); | 205 | KABPrefs::instance()->writeConfig(); |
193 | 206 | ||
194 | emit changed( false ); | 207 | emit changed( false ); |
195 | } | 208 | } |
196 | 209 | ||
197 | void KABConfigWidget::defaults(KABPrefs* prefs) | 210 | void KABConfigWidget::defaults(KABPrefs* prefs) |
198 | { | 211 | { |
199 | mNameParsing->setChecked( true ); | 212 | mNameParsing->setChecked( true ); |
200 | mViewsSingleClickBox->setChecked( false ); | 213 | mViewsSingleClickBox->setChecked( false ); |
201 | mMultipleViewsAtOnce->setChecked( true ); | 214 | mMultipleViewsAtOnce->setChecked( true ); |
215 | mAskForQuit->setChecked (true); | ||
202 | 216 | ||
203 | emit changed( true ); | 217 | emit changed( true ); |
204 | } | 218 | } |
205 | 219 | ||
206 | void KABConfigWidget::modified() | 220 | void KABConfigWidget::modified() |
207 | { | 221 | { |
208 | emit changed( true ); | 222 | emit changed( true ); |
209 | } | 223 | } |
210 | 224 | ||
211 | void KABConfigWidget::restoreExtensionSettings() | 225 | void KABConfigWidget::restoreExtensionSettings() |
212 | { | 226 | { |
213 | QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; | 227 | QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; |
214 | 228 | ||
215 | mExtensionView->clear(); | 229 | mExtensionView->clear(); |
216 | 230 | ||
217 | #ifndef KAB_EMBEDDED | 231 | #ifndef KAB_EMBEDDED |
218 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); | 232 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); |
219 | KTrader::OfferList::ConstIterator it; | 233 | KTrader::OfferList::ConstIterator it; |
220 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 234 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
221 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) | 235 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) |
222 | continue; | 236 | continue; |
223 | 237 | ||
224 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); | 238 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); |
225 | item->setService( *it ); | 239 | item->setService( *it ); |
226 | if ( activeExtensions.contains( item->factory()->identifier() ) ) | 240 | if ( activeExtensions.contains( item->factory()->identifier() ) ) |
227 | item->setOn( true ); | 241 | item->setOn( true ); |
228 | } | 242 | } |
229 | #else //KAB_EMBEDDED | 243 | #else //KAB_EMBEDDED |
230 | ExtensionFactory *extensionFactory = new MergeFactory(); | 244 | ExtensionFactory *extensionFactory = new MergeFactory(); |
231 | 245 | ||
232 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); | 246 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); |
233 | 247 | ||
234 | item->setFactory( extensionFactory ); | 248 | item->setFactory( extensionFactory ); |
235 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 249 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
236 | item->setOn( true ); | 250 | item->setOn( true ); |
237 | 251 | ||
238 | 252 | ||
239 | 253 | ||
240 | extensionFactory = new DistributionListFactory(); | 254 | extensionFactory = new DistributionListFactory(); |
241 | 255 | ||
242 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); | 256 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); |
243 | 257 | ||
244 | item->setFactory( extensionFactory ); | 258 | item->setFactory( extensionFactory ); |
245 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 259 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
246 | item->setOn( true ); | 260 | item->setOn( true ); |
247 | 261 | ||
248 | 262 | ||
249 | #endif //KAB_EMBEDDED | 263 | #endif //KAB_EMBEDDED |
250 | 264 | ||
251 | } | 265 | } |
252 | 266 | ||
253 | void KABConfigWidget::saveExtensionSettings() | 267 | void KABConfigWidget::saveExtensionSettings() |
254 | { | 268 | { |
255 | QStringList activeExtensions; | 269 | QStringList activeExtensions; |
256 | 270 | ||
257 | QPtrList<QListViewItem> list; | 271 | QPtrList<QListViewItem> list; |
258 | QListViewItemIterator it( mExtensionView ); | 272 | QListViewItemIterator it( mExtensionView ); |
259 | while ( it.current() ) { | 273 | while ( it.current() ) { |
260 | ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); | 274 | ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); |
261 | if ( item ) { | 275 | if ( item ) { |
262 | if ( item->isOn() ) | 276 | if ( item->isOn() ) |
263 | activeExtensions.append( item->factory()->identifier() ); | 277 | activeExtensions.append( item->factory()->identifier() ); |
264 | } | 278 | } |
265 | ++it; | 279 | ++it; |
266 | } | 280 | } |
267 | 281 | ||
268 | KABPrefs::instance()->mActiveExtensions = activeExtensions; | 282 | KABPrefs::instance()->mActiveExtensions = activeExtensions; |
269 | } | 283 | } |
270 | 284 | ||
271 | void KABConfigWidget::configureExtension() | 285 | void KABConfigWidget::configureExtension() |
272 | { | 286 | { |
273 | ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); | 287 | ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); |
274 | if ( !item ) | 288 | if ( !item ) |
275 | return; | 289 | return; |
276 | 290 | ||
277 | #ifndef KAB_EMBEDDED | 291 | #ifndef KAB_EMBEDDED |
278 | KConfig config( "kaddressbookrc" ); | 292 | KConfig config( "kaddressbookrc" ); |
279 | #else //KAB_EMBEDDED | 293 | #else //KAB_EMBEDDED |
280 | KConfig config( locateLocal("config", "kaddressbookrc") ); | 294 | KConfig config( locateLocal("config", "kaddressbookrc") ); |
281 | #endif //KAB_EMBEDDED | 295 | #endif //KAB_EMBEDDED |
282 | config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); | 296 | config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); |
283 | 297 | ||
284 | ExtensionConfigDialog dlg( item->factory(), &config, this ); | 298 | ExtensionConfigDialog dlg( item->factory(), &config, this ); |
285 | dlg.exec(); | 299 | dlg.exec(); |
286 | 300 | ||
287 | config.sync(); | 301 | config.sync(); |
288 | } | 302 | } |
289 | 303 | ||
290 | void KABConfigWidget::selectionChanged( QListViewItem *i ) | 304 | void KABConfigWidget::selectionChanged( QListViewItem *i ) |
291 | { | 305 | { |
292 | ExtensionItem *item = static_cast<ExtensionItem*>( i ); | 306 | ExtensionItem *item = static_cast<ExtensionItem*>( i ); |
293 | if ( !item ) | 307 | if ( !item ) |
294 | return; | 308 | return; |
295 | 309 | ||
296 | mConfigureButton->setEnabled( item->configWidgetAvailable() ); | 310 | mConfigureButton->setEnabled( item->configWidgetAvailable() ); |
297 | } | 311 | } |
298 | 312 | ||
299 | void KABConfigWidget::itemClicked( QListViewItem *item ) | 313 | void KABConfigWidget::itemClicked( QListViewItem *item ) |
300 | { | 314 | { |
301 | if ( item != 0 ) | 315 | if ( item != 0 ) |
302 | modified(); | 316 | modified(); |
303 | } | 317 | } |
304 | 318 | ||
305 | #ifndef KAB_EMBEDDED | 319 | #ifndef KAB_EMBEDDED |
306 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) | 320 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) |
307 | : QCheckListItem( parent, text, CheckBox ) | 321 | : QCheckListItem( parent, text, CheckBox ) |
308 | { | 322 | { |
309 | } | 323 | } |
310 | 324 | ||
311 | void ExtensionItem::setService( const KService::Ptr &ptr ) | 325 | void ExtensionItem::setService( const KService::Ptr &ptr ) |
312 | { | 326 | { |
313 | mPtr = ptr; | 327 | mPtr = ptr; |
314 | } | 328 | } |
315 | #else //KAB_EMBEDDED | 329 | #else //KAB_EMBEDDED |
316 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) | 330 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) |
317 | : QCheckListItem( parent, text, CheckBox ) | 331 | : QCheckListItem( parent, text, CheckBox ) |
318 | { | 332 | { |
319 | mName = name; | 333 | mName = name; |
320 | mComment = comment; | 334 | mComment = comment; |
321 | } | 335 | } |
322 | 336 | ||
323 | 337 | ||
324 | void ExtensionItem::setFactory( ExtensionFactory* fac ) | 338 | void ExtensionItem::setFactory( ExtensionFactory* fac ) |
325 | { | 339 | { |
326 | mFactory = fac; | 340 | mFactory = fac; |
327 | } | 341 | } |
328 | #endif //KAB_EMBEDDED | 342 | #endif //KAB_EMBEDDED |
329 | 343 | ||
330 | bool ExtensionItem::configWidgetAvailable() const | 344 | bool ExtensionItem::configWidgetAvailable() const |
331 | { | 345 | { |
332 | #ifndef KAB_EMBEDDED | 346 | #ifndef KAB_EMBEDDED |
333 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); | 347 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); |
334 | if ( !factory ) | 348 | if ( !factory ) |
335 | return false; | 349 | return false; |
336 | 350 | ||
337 | ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); | 351 | ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); |
338 | if ( !extensionFactory ) | 352 | if ( !extensionFactory ) |
339 | return false; | 353 | return false; |
340 | 354 | ||
341 | return extensionFactory->configureWidgetAvailable(); | 355 | return extensionFactory->configureWidgetAvailable(); |
342 | #else //KAB_EMBEDDED | 356 | #else //KAB_EMBEDDED |
343 | return mFactory->configureWidgetAvailable(); | 357 | return mFactory->configureWidgetAvailable(); |
344 | #endif //KAB_EMBEDDED | 358 | #endif //KAB_EMBEDDED |
345 | 359 | ||
346 | } | 360 | } |
347 | 361 | ||
348 | ExtensionFactory *ExtensionItem::factory() const | 362 | ExtensionFactory *ExtensionItem::factory() const |
349 | { | 363 | { |
350 | #ifndef KAB_EMBEDDED | 364 | #ifndef KAB_EMBEDDED |
351 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); | 365 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); |
352 | if ( !factory ) | 366 | if ( !factory ) |
353 | return 0; | 367 | return 0; |
354 | 368 | ||
355 | return static_cast<ExtensionFactory*>( factory ); | 369 | return static_cast<ExtensionFactory*>( factory ); |
356 | #else //KAB_EMBEDDED | 370 | #else //KAB_EMBEDDED |
357 | return mFactory; | 371 | return mFactory; |
358 | #endif //KAB_EMBEDDED | 372 | #endif //KAB_EMBEDDED |
359 | } | 373 | } |
360 | 374 | ||
361 | QString ExtensionItem::text( int column ) const | 375 | QString ExtensionItem::text( int column ) const |
362 | { | 376 | { |
363 | #ifndef KAB_EMBEDDED | 377 | #ifndef KAB_EMBEDDED |
364 | if ( column == 0 ) | 378 | if ( column == 0 ) |
365 | return mPtr->name(); | 379 | return mPtr->name(); |
366 | else if ( column == 1 ) | 380 | else if ( column == 1 ) |
367 | return mPtr->comment(); | 381 | return mPtr->comment(); |
368 | else | 382 | else |
369 | return QString::null; | 383 | return QString::null; |
370 | #else //KAB_EMBEDDED | 384 | #else //KAB_EMBEDDED |
371 | if ( column == 0 ) | 385 | if ( column == 0 ) |
372 | return mName; | 386 | return mName; |
373 | else if ( column == 1 ) | 387 | else if ( column == 1 ) |
374 | return mComment; | 388 | return mComment; |
375 | else | 389 | else |
376 | return QString::null; | 390 | return QString::null; |
377 | #endif //KAB_EMBEDDED | 391 | #endif //KAB_EMBEDDED |
378 | } | 392 | } |
379 | 393 | ||
380 | #ifndef KAB_EMBEDDED | 394 | #ifndef KAB_EMBEDDED |
381 | #include "kabconfigwidget.moc" | 395 | #include "kabconfigwidget.moc" |
382 | #endif //KAB_EMBEDDED | 396 | #endif //KAB_EMBEDDED |
383 | 397 | ||
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h index 2928495..831efc1 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.h +++ b/kaddressbook/kcmconfigs/kabconfigwidget.h | |||
@@ -1,78 +1,79 @@ | |||
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 <qwidget.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 QWidget |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
44 | KABConfigWidget( QWidget *parent, const char *name = 0 ); | 44 | KABConfigWidget( QWidget *parent, const char *name = 0 ); |
45 | 45 | ||
46 | void restoreSettings(KABPrefs* prefs); | 46 | void restoreSettings(KABPrefs* prefs); |
47 | void saveSettings(KABPrefs* prefs); | 47 | void saveSettings(KABPrefs* prefs); |
48 | void defaults(KABPrefs* prefs); | 48 | void defaults(KABPrefs* prefs); |
49 | 49 | ||
50 | signals: | 50 | signals: |
51 | void changed( bool ); | 51 | void changed( bool ); |
52 | 52 | ||
53 | public slots: | 53 | public slots: |
54 | void modified(); | 54 | void modified(); |
55 | 55 | ||
56 | 56 | ||
57 | 57 | ||
58 | private slots: | 58 | private slots: |
59 | void configureExtension(); | 59 | void configureExtension(); |
60 | void selectionChanged( QListViewItem* ); | 60 | void selectionChanged( QListViewItem* ); |
61 | void itemClicked( QListViewItem* ); | 61 | void itemClicked( QListViewItem* ); |
62 | 62 | ||
63 | private: | 63 | private: |
64 | void restoreExtensionSettings(); | 64 | void restoreExtensionSettings(); |
65 | void saveExtensionSettings(); | 65 | void saveExtensionSettings(); |
66 | 66 | ||
67 | KListView *mExtensionView; | 67 | KListView *mExtensionView; |
68 | 68 | ||
69 | QCheckBox *mNameParsing; | 69 | QCheckBox *mNameParsing; |
70 | QCheckBox *mViewsSingleClickBox; | 70 | QCheckBox *mViewsSingleClickBox; |
71 | QCheckBox *mMultipleViewsAtOnce; | 71 | QCheckBox *mMultipleViewsAtOnce; |
72 | QCheckBox *mAskForQuit; | ||
72 | 73 | ||
73 | QPushButton *mConfigureButton; | 74 | QPushButton *mConfigureButton; |
74 | 75 | ||
75 | AddresseeWidget *mAddresseeWidget; | 76 | AddresseeWidget *mAddresseeWidget; |
76 | }; | 77 | }; |
77 | 78 | ||
78 | #endif | 79 | #endif |