summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kcmconfigs
Unidiff
Diffstat (limited to 'kaddressbook/kcmconfigs') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp110
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.h10
-rw-r--r--kaddressbook/kcmconfigs/kcmkabconfig.cpp60
-rw-r--r--kaddressbook/kcmconfigs/kcmkabconfig.h50
4 files changed, 65 insertions, 165 deletions
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
index 1bac26f..b5309c0 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
@@ -1,470 +1,376 @@
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 34
35#include <kconfig.h> 35#include <kconfig.h>
36#include <kdebug.h> 36#include <kdebug.h>
37#include <kdialog.h> 37#include <kdialog.h>
38#include <klistview.h> 38#include <klistview.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kglobal.h> 40#include <kglobal.h>
41#include <kmessagebox.h> 41#include <kmessagebox.h>
42#include <kstandarddirs.h> 42#include <kstandarddirs.h>
43 43
44#ifndef KAB_EMBEDDED 44#ifndef KAB_EMBEDDED
45#include <ktrader.h> 45#include <ktrader.h>
46#else // KAB_EMBEDDED 46#else // KAB_EMBEDDED
47#include <mergewidget.h> 47#include <mergewidget.h>
48#include <distributionlistwidget.h> 48#include <distributionlistwidget.h>
49#endif // KAB_EMBEDDED 49#endif // KAB_EMBEDDED
50 50
51#include "addresseewidget.h" 51#include "addresseewidget.h"
52#include "extensionconfigdialog.h" 52#include "extensionconfigdialog.h"
53#include "extensionwidget.h" 53#include "extensionwidget.h"
54#include "kabprefs.h" 54#include "kabprefs.h"
55 55
56#include "kabconfigwidget.h" 56#include "kabconfigwidget.h"
57 57
58class ExtensionItem : public QCheckListItem 58class ExtensionItem : public QCheckListItem
59{ 59{
60 public: 60 public:
61 61
62#ifndef KAB_EMBEDDED 62#ifndef KAB_EMBEDDED
63 ExtensionItem( QListView *parent, const QString &text ); 63 ExtensionItem( QListView *parent, const QString &text );
64 void setService( const KService::Ptr &ptr ); 64 void setService( const KService::Ptr &ptr );
65#else //KAB_EMBEDDED 65#else //KAB_EMBEDDED
66 ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); 66 ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment );
67 void setFactory( ExtensionFactory* fac ); 67 void setFactory( ExtensionFactory* fac );
68#endif //KAB_EMBEDDED 68#endif //KAB_EMBEDDED
69 69
70 bool configWidgetAvailable() const; 70 bool configWidgetAvailable() const;
71 ExtensionFactory *factory() const; 71 ExtensionFactory *factory() const;
72 72
73 virtual QString text( int column ) const; 73 virtual QString text( int column ) const;
74 74
75 private: 75 private:
76#ifndef KAB_EMBEDDED 76#ifndef KAB_EMBEDDED
77 KService::Ptr mPtr; 77 KService::Ptr mPtr;
78#else //KAB_EMBEDDED 78#else //KAB_EMBEDDED
79 ExtensionFactory* mFactory; 79 ExtensionFactory* mFactory;
80 QString mName; 80 QString mName;
81 QString mComment; 81 QString mComment;
82 82
83#endif //KAB_EMBEDDED 83#endif //KAB_EMBEDDED
84 84
85}; 85};
86 86
87KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) 87KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name )
88 : QWidget( parent, name ) 88 : QWidget( parent, name )
89{ 89{
90 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 90 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
91 KDialog::spacingHint() ); 91 KDialog::spacingHint() );
92 92
93 QTabWidget *tabWidget = new QTabWidget( this ); 93 QTabWidget *tabWidget = new QTabWidget( this );
94 topLayout->addWidget( tabWidget ); 94 topLayout->addWidget( tabWidget );
95 95
96 // General page 96 // General page
97 QWidget *generalPage = new QWidget( this ); 97 QWidget *generalPage = new QWidget( this );
98 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), 98 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(),
99 KDialog::spacingHintSmall() ); 99 KDialog::spacingHintSmall() );
100 //general groupbox 100 //general groupbox
101 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage ); 101 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage );
102 QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() ); 102 QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() );
103 boxLayout->setAlignment( Qt::AlignTop ); 103 boxLayout->setAlignment( Qt::AlignTop );
104 boxLayout->setMargin(KDialog::marginHintSmall() ); 104 boxLayout->setMargin(KDialog::marginHintSmall() );
105 groupBox->layout()->setMargin(KDialog::marginHintSmall()) ; 105 groupBox->layout()->setMargin(KDialog::marginHintSmall()) ;
106 groupBox->layout()->setSpacing(KDialog::spacingHintSmall()); 106 groupBox->layout()->setSpacing(KDialog::spacingHintSmall());
107 boxLayout->setSpacing( KDialog::spacingHintSmall() ); 107 boxLayout->setSpacing( KDialog::spacingHintSmall() );
108 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" ); 108 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" );
109 boxLayout->addWidget( mViewsSingleClickBox ); 109 boxLayout->addWidget( mViewsSingleClickBox );
110 110
111 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" ); 111 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" );
112 boxLayout->addWidget( mNameParsing ); 112 boxLayout->addWidget( mNameParsing );
113 113
114 layout->addWidget( groupBox ); 114 layout->addWidget( groupBox );
115 115
116 116
117 //extensions groupbox 117 //extensions groupbox
118 118
119 groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions" ), generalPage ); 119 groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions" ), generalPage );
120 boxLayout = new QVBoxLayout( groupBox->layout() ); 120 boxLayout = new QVBoxLayout( groupBox->layout() );
121 boxLayout->setAlignment( Qt::AlignTop ); 121 boxLayout->setAlignment( Qt::AlignTop );
122 boxLayout->setMargin(KDialog::marginHintSmall()); 122 boxLayout->setMargin(KDialog::marginHintSmall());
123 boxLayout->setSpacing(KDialog::spacingHintSmall()); 123 boxLayout->setSpacing(KDialog::spacingHintSmall());
124 groupBox->layout()->setMargin(1) ; 124 groupBox->layout()->setMargin(1) ;
125 groupBox->layout()->setSpacing(0); 125 groupBox->layout()->setSpacing(0);
126 mExtensionView = new KListView( groupBox ); 126 mExtensionView = new KListView( groupBox );
127 mExtensionView->setAllColumnsShowFocus( true ); 127 mExtensionView->setAllColumnsShowFocus( true );
128 mExtensionView->addColumn( i18n( "Name" ) ); 128 mExtensionView->addColumn( i18n( "Name" ) );
129 mExtensionView->addColumn( i18n( "Description" ) ); 129 mExtensionView->addColumn( i18n( "Description" ) );
130 mExtensionView->setMaximumHeight(80); 130 mExtensionView->setMaximumHeight(80);
131 131
132 boxLayout->addWidget( mExtensionView ); 132 boxLayout->addWidget( mExtensionView );
133 133
134 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); 134 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox );
135 mConfigureButton->setEnabled( false ); 135 mConfigureButton->setEnabled( false );
136 boxLayout->addWidget( mConfigureButton ); 136 boxLayout->addWidget( mConfigureButton );
137 137
138 layout->addWidget( groupBox ); 138 layout->addWidget( groupBox );
139 139
140 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 140 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
141 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 141 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
142 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), 142 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ),
143 SLOT( selectionChanged( QListViewItem* ) ) ); 143 SLOT( selectionChanged( QListViewItem* ) ) );
144 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), 144 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ),
145 SLOT( itemClicked( QListViewItem* ) ) ); 145 SLOT( itemClicked( QListViewItem* ) ) );
146 connect( mConfigureButton, SIGNAL( clicked() ), 146 connect( mConfigureButton, SIGNAL( clicked() ),
147 SLOT( configureExtension() ) ); 147 SLOT( configureExtension() ) );
148 148
149 tabWidget->addTab( generalPage, i18n( "General" ) ); 149 tabWidget->addTab( generalPage, i18n( "General" ) );
150 150
151 // Addressee page 151 // Addressee page
152 mAddresseeWidget = new AddresseeWidget( this ); 152 mAddresseeWidget = new AddresseeWidget( this );
153 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); 153 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
154 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); 154 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
155 155
156 // mailclient page
157 QWidget *mailclientPage = new QWidget( this );
158 layout = new QVBoxLayout( mailclientPage, KDialog::marginHintSmall(),
159 KDialog::spacingHintSmall() );
160
161 groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), mailclientPage );
162 boxLayout = new QVBoxLayout( groupBox->layout() );
163 boxLayout->setAlignment( Qt::AlignTop );
164// boxLayout->setMargin(KDialog::marginHintSmall() );
165// groupBox->layout()->setMargin(KDialog::marginHintSmall()) ;
166// groupBox->layout()->setSpacing(KDialog::spacingHintSmall());
167// boxLayout->setSpacing( KDialog::spacingHintSmall() );
168
169 mEmailClient = new QComboBox( groupBox );
170 mEmailClient->insertItem( i18n("OM/Pi"), KABPrefs::OMPI );
171 mEmailClient->insertItem( i18n("Qtopia mail"), KABPrefs::QTOPIA );
172 mEmailClient->insertItem( i18n("Opie mail"), KABPrefs::OPIE );
173 mEmailClient->insertItem( i18n("Other"), KABPrefs::OTHER );
174 boxLayout->addWidget( mEmailClient );
175
176 connect( mEmailClient, SIGNAL( activated( int ) ),
177 this, SLOT (emailclient_changed( int ) ) );
178
179 QLabel* lab = new QLabel( i18n("Channel:"), groupBox);
180 boxLayout->addWidget( lab );
181 mEmailChannel = new QLineEdit(groupBox);
182 mEmailChannel->setReadOnly(true);
183 boxLayout->addWidget( mEmailChannel );
184
185 layout->addWidget( groupBox );
186 tabWidget->addTab( mailclientPage, i18n( "Mail" ) );
187
188
189
190} 156}
191 157
192 158
193 159void KABConfigWidget::restoreSettings(KABPrefs* prefs)
194void KABConfigWidget::emailclient_changed( int newClient )
195{ 160{
196 if (newClient == KABPrefs::OTHER) 161//US prefs was KABPrefs::instance() before
197 mEmailChannel->setReadOnly(false);
198 else
199 mEmailChannel->setReadOnly(true);
200
201 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
202 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
203
204 if (opiepath.isEmpty())
205 opiepath = qtopiapath;
206
207 QString text = mEmailChannel->text();
208
209 if (newClient == KABPrefs::OPIE)
210 {
211 if ( QFile::exists( opiepath + "/bin/opiemail" ))
212 text = "QPE/Application/opiemail";
213 else
214 text = "FILENOTFOUND: " + opiepath + "/bin/opiemail";
215 }
216 else if (newClient == KABPrefs::QTOPIA)
217 {
218 if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
219 text = "QPE/Application/qtmail";
220 else
221 text = "FILENOTFOUND: " + qtopiapath + "/bin/qtmail";
222 162
223 }
224 else if (newClient == KABPrefs::OMPI)
225 {
226 if ( QFile::exists( qtopiapath + "/bin/ompi" ))
227 text = "QPE/Application/ompi";
228 else if ( QFile::exists( opiepath + "/bin/ompi" ))
229 text = "QPE/Application/ompi";
230 else
231 text = "FILENOTFOUND: " + qtopiapath + "/bin/ompi";
232
233 }
234 else
235 {
236 //do nothing if we choosed other
237 }
238
239 mEmailChannel->setText( text );
240
241
242}
243
244
245void KABConfigWidget::restoreSettings()
246{
247 bool blocked = signalsBlocked(); 163 bool blocked = signalsBlocked();
248 blockSignals( true ); 164 blockSignals( true );
249 165
250 mNameParsing->setChecked( KABPrefs::instance()->mAutomaticNameParsing ); 166 mNameParsing->setChecked( prefs->mAutomaticNameParsing );
251 mViewsSingleClickBox->setChecked( KABPrefs::instance()->mHonorSingleClick ); 167 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick );
252
253 mEmailChannel->setText( KABPrefs::instance()->mEmailChannel );
254 mEmailClient->setCurrentItem(KABPrefs::instance()->mEmailClient);
255 168
256 mAddresseeWidget->restoreSettings(); 169 mAddresseeWidget->restoreSettings();
257 170
258 restoreExtensionSettings(); 171 restoreExtensionSettings();
259 172
260 blockSignals( blocked ); 173 blockSignals( blocked );
261 174
262 emit changed( false ); 175 emit changed( false );
263} 176}
264 177
265void KABConfigWidget::saveSettings() 178void KABConfigWidget::saveSettings(KABPrefs* prefs)
266{ 179{
267 KABPrefs::instance()->mAutomaticNameParsing = mNameParsing->isChecked(); 180 prefs->mAutomaticNameParsing = mNameParsing->isChecked();
268 KABPrefs::instance()->mHonorSingleClick = mViewsSingleClickBox->isChecked(); 181 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked();
269
270 KABPrefs::instance()->mEmailClient = mEmailClient->currentItem();
271 KABPrefs::instance()->mEmailChannel = mEmailChannel->text();
272 182
273 mAddresseeWidget->saveSettings(); 183 mAddresseeWidget->saveSettings();
274 184
275 saveExtensionSettings(); 185 saveExtensionSettings();
276 KABPrefs::instance()->writeConfig(); 186 KABPrefs::instance()->writeConfig();
277 187
278 emit changed( false ); 188 emit changed( false );
279} 189}
280 190
281void KABConfigWidget::defaults() 191void KABConfigWidget::defaults(KABPrefs* prefs)
282{ 192{
283 mNameParsing->setChecked( true ); 193 mNameParsing->setChecked( true );
284 mViewsSingleClickBox->setChecked( false ); 194 mViewsSingleClickBox->setChecked( false );
285 195
286 mEmailClient->setCurrentItem(KABPrefs::OMPI);
287 emailclient_changed( KABPrefs::OMPI );
288
289
290 emit changed( true ); 196 emit changed( true );
291} 197}
292 198
293void KABConfigWidget::modified() 199void KABConfigWidget::modified()
294{ 200{
295 emit changed( true ); 201 emit changed( true );
296} 202}
297 203
298void KABConfigWidget::restoreExtensionSettings() 204void KABConfigWidget::restoreExtensionSettings()
299{ 205{
300 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; 206 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions;
301 207
302 mExtensionView->clear(); 208 mExtensionView->clear();
303 209
304#ifndef KAB_EMBEDDED 210#ifndef KAB_EMBEDDED
305 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); 211 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" );
306 KTrader::OfferList::ConstIterator it; 212 KTrader::OfferList::ConstIterator it;
307 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 213 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
308 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) 214 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) )
309 continue; 215 continue;
310 216
311 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); 217 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() );
312 item->setService( *it ); 218 item->setService( *it );
313 if ( activeExtensions.contains( item->factory()->identifier() ) ) 219 if ( activeExtensions.contains( item->factory()->identifier() ) )
314 item->setOn( true ); 220 item->setOn( true );
315 } 221 }
316#else //KAB_EMBEDDED 222#else //KAB_EMBEDDED
317 ExtensionFactory *extensionFactory = new MergeFactory(); 223 ExtensionFactory *extensionFactory = new MergeFactory();
318 224
319 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); 225 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts");
320 226
321 item->setFactory( extensionFactory ); 227 item->setFactory( extensionFactory );
322 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 228 if ( activeExtensions.contains( extensionFactory->identifier() ) )
323 item->setOn( true ); 229 item->setOn( true );
324 230
325 231
326 232
327 extensionFactory = new DistributionListFactory(); 233 extensionFactory = new DistributionListFactory();
328 234
329 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); 235 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists");
330 236
331 item->setFactory( extensionFactory ); 237 item->setFactory( extensionFactory );
332 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 238 if ( activeExtensions.contains( extensionFactory->identifier() ) )
333 item->setOn( true ); 239 item->setOn( true );
334 240
335 241
336#endif //KAB_EMBEDDED 242#endif //KAB_EMBEDDED
337 243
338} 244}
339 245
340void KABConfigWidget::saveExtensionSettings() 246void KABConfigWidget::saveExtensionSettings()
341{ 247{
342 QStringList activeExtensions; 248 QStringList activeExtensions;
343 249
344 QPtrList<QListViewItem> list; 250 QPtrList<QListViewItem> list;
345 QListViewItemIterator it( mExtensionView ); 251 QListViewItemIterator it( mExtensionView );
346 while ( it.current() ) { 252 while ( it.current() ) {
347 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); 253 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() );
348 if ( item ) { 254 if ( item ) {
349 if ( item->isOn() ) 255 if ( item->isOn() )
350 activeExtensions.append( item->factory()->identifier() ); 256 activeExtensions.append( item->factory()->identifier() );
351 } 257 }
352 ++it; 258 ++it;
353 } 259 }
354 260
355 KABPrefs::instance()->mActiveExtensions = activeExtensions; 261 KABPrefs::instance()->mActiveExtensions = activeExtensions;
356} 262}
357 263
358void KABConfigWidget::configureExtension() 264void KABConfigWidget::configureExtension()
359{ 265{
360 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); 266 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() );
361 if ( !item ) 267 if ( !item )
362 return; 268 return;
363 269
364#ifndef KAB_EMBEDDED 270#ifndef KAB_EMBEDDED
365 KConfig config( "kaddressbookrc" ); 271 KConfig config( "kaddressbookrc" );
366#else //KAB_EMBEDDED 272#else //KAB_EMBEDDED
367 KConfig config( locateLocal("config", "kaddressbookrc") ); 273 KConfig config( locateLocal("config", "kaddressbookrc") );
368#endif //KAB_EMBEDDED 274#endif //KAB_EMBEDDED
369 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); 275 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) );
370 276
371 ExtensionConfigDialog dlg( item->factory(), &config, this ); 277 ExtensionConfigDialog dlg( item->factory(), &config, this );
372 dlg.exec(); 278 dlg.exec();
373 279
374 config.sync(); 280 config.sync();
375} 281}
376 282
377void KABConfigWidget::selectionChanged( QListViewItem *i ) 283void KABConfigWidget::selectionChanged( QListViewItem *i )
378{ 284{
379 ExtensionItem *item = static_cast<ExtensionItem*>( i ); 285 ExtensionItem *item = static_cast<ExtensionItem*>( i );
380 if ( !item ) 286 if ( !item )
381 return; 287 return;
382 288
383 mConfigureButton->setEnabled( item->configWidgetAvailable() ); 289 mConfigureButton->setEnabled( item->configWidgetAvailable() );
384} 290}
385 291
386void KABConfigWidget::itemClicked( QListViewItem *item ) 292void KABConfigWidget::itemClicked( QListViewItem *item )
387{ 293{
388 if ( item != 0 ) 294 if ( item != 0 )
389 modified(); 295 modified();
390} 296}
391 297
392#ifndef KAB_EMBEDDED 298#ifndef KAB_EMBEDDED
393ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) 299ExtensionItem::ExtensionItem( QListView *parent, const QString &text )
394 : QCheckListItem( parent, text, CheckBox ) 300 : QCheckListItem( parent, text, CheckBox )
395{ 301{
396} 302}
397 303
398void ExtensionItem::setService( const KService::Ptr &ptr ) 304void ExtensionItem::setService( const KService::Ptr &ptr )
399{ 305{
400 mPtr = ptr; 306 mPtr = ptr;
401} 307}
402#else //KAB_EMBEDDED 308#else //KAB_EMBEDDED
403ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) 309ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment )
404 : QCheckListItem( parent, text, CheckBox ) 310 : QCheckListItem( parent, text, CheckBox )
405{ 311{
406 mName = name; 312 mName = name;
407 mComment = comment; 313 mComment = comment;
408} 314}
409 315
410 316
411void ExtensionItem::setFactory( ExtensionFactory* fac ) 317void ExtensionItem::setFactory( ExtensionFactory* fac )
412{ 318{
413 mFactory = fac; 319 mFactory = fac;
414} 320}
415#endif //KAB_EMBEDDED 321#endif //KAB_EMBEDDED
416 322
417bool ExtensionItem::configWidgetAvailable() const 323bool ExtensionItem::configWidgetAvailable() const
418{ 324{
419#ifndef KAB_EMBEDDED 325#ifndef KAB_EMBEDDED
420 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); 326 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() );
421 if ( !factory ) 327 if ( !factory )
422 return false; 328 return false;
423 329
424 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); 330 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory );
425 if ( !extensionFactory ) 331 if ( !extensionFactory )
426 return false; 332 return false;
427 333
428 return extensionFactory->configureWidgetAvailable(); 334 return extensionFactory->configureWidgetAvailable();
429#else //KAB_EMBEDDED 335#else //KAB_EMBEDDED
430 return mFactory->configureWidgetAvailable(); 336 return mFactory->configureWidgetAvailable();
431#endif //KAB_EMBEDDED 337#endif //KAB_EMBEDDED
432 338
433} 339}
434 340
435ExtensionFactory *ExtensionItem::factory() const 341ExtensionFactory *ExtensionItem::factory() const
436{ 342{
437#ifndef KAB_EMBEDDED 343#ifndef KAB_EMBEDDED
438 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); 344 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() );
439 if ( !factory ) 345 if ( !factory )
440 return 0; 346 return 0;
441 347
442 return static_cast<ExtensionFactory*>( factory ); 348 return static_cast<ExtensionFactory*>( factory );
443#else //KAB_EMBEDDED 349#else //KAB_EMBEDDED
444 return mFactory; 350 return mFactory;
445#endif //KAB_EMBEDDED 351#endif //KAB_EMBEDDED
446} 352}
447 353
448QString ExtensionItem::text( int column ) const 354QString ExtensionItem::text( int column ) const
449{ 355{
450#ifndef KAB_EMBEDDED 356#ifndef KAB_EMBEDDED
451 if ( column == 0 ) 357 if ( column == 0 )
452 return mPtr->name(); 358 return mPtr->name();
453 else if ( column == 1 ) 359 else if ( column == 1 )
454 return mPtr->comment(); 360 return mPtr->comment();
455 else 361 else
456 return QString::null; 362 return QString::null;
457#else //KAB_EMBEDDED 363#else //KAB_EMBEDDED
458 if ( column == 0 ) 364 if ( column == 0 )
459 return mName; 365 return mName;
460 else if ( column == 1 ) 366 else if ( column == 1 )
461 return mComment; 367 return mComment;
462 else 368 else
463 return QString::null; 369 return QString::null;
464#endif //KAB_EMBEDDED 370#endif //KAB_EMBEDDED
465} 371}
466 372
467#ifndef KAB_EMBEDDED 373#ifndef KAB_EMBEDDED
468#include "kabconfigwidget.moc" 374#include "kabconfigwidget.moc"
469#endif //KAB_EMBEDDED 375#endif //KAB_EMBEDDED
470 376
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h
index 9d1363b..8c0c436 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.h
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.h
@@ -1,78 +1,76 @@
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
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;
35 36
36class AddresseeWidget; 37class AddresseeWidget;
37 38
38class KABConfigWidget : public QWidget 39class KABConfigWidget : public QWidget
39{ 40{
40 Q_OBJECT 41 Q_OBJECT
41 42
42 public: 43 public:
43 KABConfigWidget( QWidget *parent, const char *name = 0 ); 44 KABConfigWidget( QWidget *parent, const char *name = 0 );
44 45
45 void restoreSettings(); 46 void restoreSettings(KABPrefs* prefs);
46 void saveSettings(); 47 void saveSettings(KABPrefs* prefs);
47 void defaults(); 48 void defaults(KABPrefs* prefs);
48 49
49 signals: 50 signals:
50 void changed( bool ); 51 void changed( bool );
51 52
52 public slots: 53 public slots:
53 void modified(); 54 void modified();
54 55
55 56
56 57
57 private slots: 58 private slots:
58 void configureExtension(); 59 void configureExtension();
59 void selectionChanged( QListViewItem* ); 60 void selectionChanged( QListViewItem* );
60 void itemClicked( QListViewItem* ); 61 void itemClicked( QListViewItem* );
61 void emailclient_changed( int newClient );
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 QPushButton *mConfigureButton; 71 QPushButton *mConfigureButton;
72 QComboBox* mEmailClient;
73 QLineEdit* mEmailChannel;
74 72
75 AddresseeWidget *mAddresseeWidget; 73 AddresseeWidget *mAddresseeWidget;
76}; 74};
77 75
78#endif 76#endif
diff --git a/kaddressbook/kcmconfigs/kcmkabconfig.cpp b/kaddressbook/kcmconfigs/kcmkabconfig.cpp
index a278042..26398f8 100644
--- a/kaddressbook/kcmconfigs/kcmkabconfig.cpp
+++ b/kaddressbook/kcmconfigs/kcmkabconfig.cpp
@@ -1,90 +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"
38#include "kprefs.h"
39
37extern "C" 40extern "C"
38{ 41{
39 KCModule *create_kabconfig( QWidget *parent, const char * ) { 42 KCModule *create_kabconfig( QWidget *parent, const char * ) {
40 return new KCMKabConfig( parent, "kcmkabconfig" ); 43 return new KCMKabConfig( parent, "kcmkabconfig" );
41 } 44 }
42} 45}
43 46
44KCMKabConfig::KCMKabConfig( QWidget *parent, const char *name ) 47KCMKabConfig::KCMKabConfig( QWidget *parent, const char *name )
45 : KCModule( parent, name ) 48 : KCModule( parent, name )
46{ 49{
47 //abort(); 50 //abort();
48 QVBoxLayout *layout = new QVBoxLayout( this ); 51 QVBoxLayout *layout = new QVBoxLayout( this );
49 mConfigWidget = new KABConfigWidget( this, "mConfigWidget" ); 52 mConfigWidget = new KABConfigWidget( this, "mConfigWidget" );
50 layout->addWidget( mConfigWidget ); 53 layout->addWidget( mConfigWidget );
51 layout->setSpacing( 0 ); 54 layout->setSpacing( 0 );
52 layout->setMargin( 0 ); 55 layout->setMargin( 0 );
53 56
54 connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) ); 57 connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) );
55 load();
56} 58}
57 59
58void KCMKabConfig::load() 60void KCMKabConfig::load(KPrefs* prefs)
59{ 61{
60 mConfigWidget->restoreSettings(); 62 mConfigWidget->restoreSettings((KABPrefs*)prefs);
61} 63}
62 64
63void KCMKabConfig::save() 65void KCMKabConfig::save(KPrefs* prefs)
64{ 66{
65 mConfigWidget->saveSettings(); 67 mConfigWidget->saveSettings((KABPrefs*)prefs);
66} 68}
67 69
68void KCMKabConfig::defaults() 70void KCMKabConfig::defaults(KPrefs* prefs)
69{ 71{
70 mConfigWidget->defaults(); 72 mConfigWidget->defaults((KABPrefs*)prefs);
71} 73}
72 74
73#ifndef KAB_EMBEDDED 75#ifndef KAB_EMBEDDED
74const KAboutData* KCMKabConfig::aboutData() const 76const KAboutData* KCMKabConfig::aboutData() const
75{ 77{
76 KAboutData *about = new KAboutData( I18N_NOOP( "kcmkabconfig" ), 78 KAboutData *about = new KAboutData( I18N_NOOP( "kcmkabconfig" ),
77 I18N_NOOP( "KAddressBook Configure Dialog" ), 79 I18N_NOOP( "KAddressBook Configure Dialog" ),
78 0, 0, KAboutData::License_GPL, 80 0, 0, KAboutData::License_GPL,
79 I18N_NOOP( "(c), 2003 Tobias Koenig" ) ); 81 I18N_NOOP( "(c), 2003 Tobias Koenig" ) );
80 82
81 about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); 83 about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" );
82 84
83 return about; 85 return about;
84 86
85} 87}
86#endif //KAB_EMBEDDED 88#endif //KAB_EMBEDDED
87 89
88#ifndef KAB_EMBEDDED 90#ifndef KAB_EMBEDDED
89#include "kcmkabconfig.moc" 91#include "kcmkabconfig.moc"
90#endif //KAB_EMBEDDED 92#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kcmconfigs/kcmkabconfig.h b/kaddressbook/kcmconfigs/kcmkabconfig.h
index be345b8..b4858c1 100644
--- a/kaddressbook/kcmconfigs/kcmkabconfig.h
+++ b/kaddressbook/kcmconfigs/kcmkabconfig.h
@@ -1,53 +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
29class KABConfigWidget; 29class KABConfigWidget;
30 30class KPrefs;
31#ifndef KAB_EMBEDDED
32class KAboutData;
33#endif //KAB_EMBEDDED
34 31
35class KCMKabConfig : public KCModule 32class KCMKabConfig : public KCModule
36{ 33{
37 Q_OBJECT 34 Q_OBJECT
38 35
39 public: 36 public:
40 KCMKabConfig( QWidget *parent = 0, const char *name = 0 ); 37 KCMKabConfig( QWidget *parent = 0, const char *name = 0 );
41 38
42 virtual void load(); 39 virtual void load(KPrefs* prefs);
43 virtual void save(); 40 virtual void save(KPrefs* prefs);
44 virtual void defaults(); 41 virtual void defaults(KPrefs* prefs);
45#ifndef KAB_EMBEDDED
46 virtual const KAboutData* aboutData() const;
47#endif //KAB_EMBEDDED
48 42
49 private: 43 private:
50 KABConfigWidget *mConfigWidget; 44 KABConfigWidget *mConfigWidget;
51}; 45};
52 46
53#endif 47#endif