summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabprefs.cpp2
-rw-r--r--kaddressbook/kaddressbookmain.cpp86
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp36
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.h1
4 files changed, 52 insertions, 73 deletions
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index 03c5e76..2425158 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -1,130 +1,130 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
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//US#ifdef KAB_EMBEDDED 24//US#ifdef KAB_EMBEDDED
25//#include <qstring.h> 25//#include <qstring.h>
26//#endif //KAB_EMBEDDED 26//#endif //KAB_EMBEDDED
27 27
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30#include <klocale.h> 30#include <klocale.h>
31#include <kstaticdeleter.h> 31#include <kstaticdeleter.h>
32//US#include <kdebug.h> // defines kdDebug() 32//US#include <kdebug.h> // defines kdDebug()
33 33
34#include "kabprefs.h" 34#include "kabprefs.h"
35 35
36KABPrefs *KABPrefs::sInstance = 0; 36KABPrefs *KABPrefs::sInstance = 0;
37static KStaticDeleter<KABPrefs> staticDeleter; 37static KStaticDeleter<KABPrefs> staticDeleter;
38 38
39KABPrefs::KABPrefs() 39KABPrefs::KABPrefs()
40 : KPimPrefs("kaddressbookrc") 40 : KPimPrefs("kaddressbookrc")
41{ 41{
42 KPrefs::setCurrentGroup( "Views" ); 42 KPrefs::setCurrentGroup( "Views" );
43 addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); 43 addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
44 44
45 KPrefs::setCurrentGroup( "General" ); 45 KPrefs::setCurrentGroup( "General" );
46 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); 46 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true );
47 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); 47 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 );
48 48
49#ifdef KAB_EMBEDDED 49#ifdef KAB_EMBEDDED
50 addItemBool("AskForQuit",&mAskForQuit,false); 50 addItemBool("AskForQuit",&mAskForQuit,true);
51 addItemBool("ToolBarHor",&mToolBarHor, true ); 51 addItemBool("ToolBarHor",&mToolBarHor, true );
52 addItemBool("ToolBarUp",&mToolBarUp, false ); 52 addItemBool("ToolBarUp",&mToolBarUp, false );
53 53
54#endif //KAB_EMBEDDED 54#endif //KAB_EMBEDDED
55 55
56 KPrefs::setCurrentGroup( "MainWindow" ); 56 KPrefs::setCurrentGroup( "MainWindow" );
57 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); 57 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false );
58 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); 58 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true );
59 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); 59 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter );
60 addItemIntList( "DetailsSplitter", &mDetailsSplitter ); 60 addItemIntList( "DetailsSplitter", &mDetailsSplitter );
61 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); 61 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true );
62 62
63 63
64 KPrefs::setCurrentGroup( "Extensions_General" ); 64 KPrefs::setCurrentGroup( "Extensions_General" );
65 QStringList defaultExtensions; 65 QStringList defaultExtensions;
66 defaultExtensions << "merge"; 66 defaultExtensions << "merge";
67 defaultExtensions << "distribution_list_editor"; 67 defaultExtensions << "distribution_list_editor";
68 addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); 68 addItemInt( "CurrentExtension", &mCurrentExtension, 0 );
69 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); 69 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions );
70 70
71 KPrefs::setCurrentGroup( "Views" ); 71 KPrefs::setCurrentGroup( "Views" );
72 QString defaultView = i18n( "Default Table View" ); 72 QString defaultView = i18n( "Default Table View" );
73 addItemString( "CurrentView", &mCurrentView, defaultView ); 73 addItemString( "CurrentView", &mCurrentView, defaultView );
74 addItemStringList( "ViewNames", &mViewNames, defaultView ); 74 addItemStringList( "ViewNames", &mViewNames, defaultView );
75 75
76 KPrefs::setCurrentGroup( "Filters" ); 76 KPrefs::setCurrentGroup( "Filters" );
77 addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); 77 addItemInt( "CurrentFilter", &mCurrentFilter, 0 );
78 78
79} 79}
80 80
81KABPrefs::~KABPrefs() 81KABPrefs::~KABPrefs()
82{ 82{
83} 83}
84 84
85KABPrefs *KABPrefs::instance() 85KABPrefs *KABPrefs::instance()
86{ 86{
87 if ( !sInstance ) { 87 if ( !sInstance ) {
88#ifdef KAB_EMBEDDED 88#ifdef KAB_EMBEDDED
89 sInstance = staticDeleter.setObject( new KABPrefs() ); 89 sInstance = staticDeleter.setObject( new KABPrefs() );
90#else //KAB_EMBEDDED 90#else //KAB_EMBEDDED
91 //US the following line has changed ???. Why 91 //US the following line has changed ???. Why
92 staticDeleter.setObject( sInstance, new KABPrefs() ); 92 staticDeleter.setObject( sInstance, new KABPrefs() );
93#endif //KAB_EMBEDDED 93#endif //KAB_EMBEDDED
94 sInstance->readConfig(); 94 sInstance->readConfig();
95 } 95 }
96 96
97 return sInstance; 97 return sInstance;
98} 98}
99 99
100void KABPrefs::setCategoryDefaults() 100void KABPrefs::setCategoryDefaults()
101{ 101{
102 mCustomCategories.clear(); 102 mCustomCategories.clear();
103 103
104 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) 104 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
105 << i18n( "Customer" ) << i18n( "Friend" ); 105 << i18n( "Customer" ) << i18n( "Friend" );
106} 106}
107 107
108 // US introduce a nonconst way to return the config object. 108 // US introduce a nonconst way to return the config object.
109KConfig* KABPrefs::getConfig() 109KConfig* KABPrefs::getConfig()
110{ 110{
111 return config(); 111 return config();
112} 112}
113 113
114 114
115/*US 115/*US
116void KABPrefs::usrSetDefaults() 116void KABPrefs::usrSetDefaults()
117{ 117{
118 KPimPrefs::usrSetDefaults(); 118 KPimPrefs::usrSetDefaults();
119} 119}
120 120
121void KABPrefs::usrReadConfig() 121void KABPrefs::usrReadConfig()
122{ 122{
123 KPimPrefs::usrReadConfig(); 123 KPimPrefs::usrReadConfig();
124} 124}
125 125
126void KABPrefs::usrWriteConfig() 126void KABPrefs::usrWriteConfig()
127{ 127{
128 KPimPrefs::usrWriteConfig(); 128 KPimPrefs::usrWriteConfig();
129} 129}
130*/ 130*/
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp
index 8ebb93a..f48f214 100644
--- a/kaddressbook/kaddressbookmain.cpp
+++ b/kaddressbook/kaddressbookmain.cpp
@@ -10,267 +10,231 @@
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#ifdef KAB_EMBEDDED 24#ifdef KAB_EMBEDDED
25#include "kabprefs.h" 25#include "kabprefs.h"
26#include <kglobal.h> 26#include <kglobal.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qtoolbar.h> 28#include <qtoolbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30#else //KAB_EMBEDDED 30#else //KAB_EMBEDDED
31#include <kedittoolbar.h> 31#include <kedittoolbar.h>
32#include <kkeydialog.h> 32#include <kkeydialog.h>
33#include <kmessagebox.h> 33#include <kmessagebox.h>
34#include <kstatusbar.h> 34#include <kstatusbar.h>
35#endif //KAB_EMBEDDED 35#endif //KAB_EMBEDDED
36#include <klocale.h> 36#include <klocale.h>
37 37
38#include "kabcore.h" 38#include "kabcore.h"
39#include "kaddressbookmain.h" 39#include "kaddressbookmain.h"
40#include "kactioncollection.h" 40#include "kactioncollection.h"
41 41
42#ifdef KAB_EMBEDDED 42#ifdef KAB_EMBEDDED
43KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) 43KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" )
44#else //KAB_EMBEDDED 44#else //KAB_EMBEDDED
45//MOC_SKIP_BEGIN 45//MOC_SKIP_BEGIN
46KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) 46KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 )
47//MOC_SKIP_END 47//MOC_SKIP_END
48#endif //KAB_EMBEDDED 48#endif //KAB_EMBEDDED
49{ 49{
50 50
51 setIcon(SmallIcon( "ka24" ) ); 51 setIcon(SmallIcon( "ka24" ) );
52#if 0 52#if 0
53 //US for embedded systems, create the toolbar before we initiate KABCore. 53 //US for embedded systems, create the toolbar before we initiate KABCore.
54 // KABCore will fill the toolbar with menues and icons 54 // KABCore will fill the toolbar with menues and icons
55 QMainWindow::ToolBarDock tbd; 55 QMainWindow::ToolBarDock tbd;
56 tbd = Top; 56 tbd = Top;
57 iconToolBar = new QToolBar( this ); 57 iconToolBar = new QToolBar( this );
58 addToolBar (iconToolBar , tbd ); 58 addToolBar (iconToolBar , tbd );
59 iconToolBar->setHorizontalStretchable(true); 59 iconToolBar->setHorizontalStretchable(true);
60//US iconToolBar->setWidth(300); 60//US iconToolBar->setWidth(300);
61#endif // 0 61#endif // 0
62 62
63 mCore = new KABCore( this, true, this ); 63 mCore = new KABCore( this, true, this );
64 64
65#ifdef KAB_EMBEDDED 65#ifdef KAB_EMBEDDED
66 setCaption( i18n( "KAddressbook/Pi" ) ); 66 setCaption( i18n( "KAddressbook/Pi" ) );
67#else //KAB_EMBEDDED 67#else //KAB_EMBEDDED
68 setCaption( i18n( "Address Book Browser" ) ); 68 setCaption( i18n( "Address Book Browser" ) );
69#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
70 70
71 //mCore->restoreSettings(); 71 //mCore->restoreSettings();
72 72
73 initActions(); 73 initActions();
74 74
75 setCentralWidget( mCore ); 75 setCentralWidget( mCore );
76 76
77//US statusBar()->show(); 77//US statusBar()->show();
78 78
79#ifndef KAB_EMBEDDED 79#ifndef KAB_EMBEDDED
80 setStandardToolBarMenuEnabled(true); 80 setStandardToolBarMenuEnabled(true);
81 81
82 createGUI( "kaddressbookui.rc", false ); 82 createGUI( "kaddressbookui.rc", false );
83 83
84 84
85#endif //KAB_EMBEDDED 85#endif //KAB_EMBEDDED
86 setAutoSaveSettings(); 86 setAutoSaveSettings();
87 qApp->processEvents(); 87 qApp->processEvents();
88 mCore->restoreSettings(); 88 mCore->restoreSettings();
89} 89}
90 90
91KAddressBookMain::~KAddressBookMain() 91KAddressBookMain::~KAddressBookMain()
92{ 92{
93 // mCore->saveSettings(); 93 // mCore->saveSettings();
94} 94}
95 95
96void KAddressBookMain::showMinimized () 96void KAddressBookMain::showMinimized ()
97{ 97{
98 QWidget::showMinimized () ; 98 QWidget::showMinimized () ;
99} 99}
100void KAddressBookMain::addEmail( QString addr ) 100void KAddressBookMain::addEmail( QString addr )
101{ 101{
102 mCore->addEmail( addr ); 102 mCore->addEmail( addr );
103} 103}
104 104
105#ifndef KAB_EMBEDDED 105#ifndef KAB_EMBEDDED
106ASYNC KAddressBookMain::showContactEditor( QString uid ) 106ASYNC KAddressBookMain::showContactEditor( QString uid )
107{ 107{
108 mCore->editContact( uid ); 108 mCore->editContact( uid );
109} 109}
110#endif //KAB_EMBEDDED 110#endif //KAB_EMBEDDED
111void KAddressBookMain::newContact() 111void KAddressBookMain::newContact()
112{ 112{
113 mCore->newContact(); 113 mCore->newContact();
114} 114}
115 115
116QString KAddressBookMain::getNameByPhone( QString phone ) 116QString KAddressBookMain::getNameByPhone( QString phone )
117{ 117{
118 return mCore->getNameByPhone( phone ); 118 return mCore->getNameByPhone( phone );
119} 119}
120 120
121void KAddressBookMain::save() 121void KAddressBookMain::save()
122{ 122{
123 mCore->save(); 123 mCore->save();
124} 124}
125 125
126void KAddressBookMain::exit() 126void KAddressBookMain::exit()
127{ 127{
128 close( ); 128 close( );
129} 129}
130 130
131void KAddressBookMain::saveProperties( KConfig* ) 131void KAddressBookMain::saveProperties( KConfig* )
132{ 132{
133} 133}
134 134
135void KAddressBookMain::readProperties( KConfig* ) 135void KAddressBookMain::readProperties( KConfig* )
136{ 136{
137} 137}
138 138
139void KAddressBookMain::initActions() 139void KAddressBookMain::initActions()
140{ 140{
141#ifndef KAB_EMBEDDED 141#ifndef KAB_EMBEDDED
142 KStdAction::quit( this, SLOT( close() ), actionCollection() ); 142 KStdAction::quit( this, SLOT( close() ), actionCollection() );
143 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); 143 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() );
144#else //KAB_EMBEDDED 144#else //KAB_EMBEDDED
145 //US: transfered the setup of the actions into KABCore 145 //US: transfered the setup of the actions into KABCore
146#endif //KAB_EMBEDDED 146#endif //KAB_EMBEDDED
147 147
148 148
149} 149}
150 150
151//US new method to setup menues and toolbars on embedded systems 151//US new method to setup menues and toolbars on embedded systems
152#ifdef KAB_EMBEDDED 152#ifdef KAB_EMBEDDED
153/* 153/*
154QToolBar * KAddressBookMain::getIconToolBar() 154QToolBar * KAddressBookMain::getIconToolBar()
155{ 155{
156 return iconToolBar; 156 return iconToolBar;
157} 157}
158*/ 158*/
159 159
160void KAddressBookMain::createGUI() 160void KAddressBookMain::createGUI()
161{ 161{
162 162
163 163
164 164
165} 165}
166#endif //KAB_EMBEDDED 166#endif //KAB_EMBEDDED
167 167
168void KAddressBookMain::configureToolbars() 168void KAddressBookMain::configureToolbars()
169{ 169{
170#ifndef KAB_EMBEDDED 170#ifndef KAB_EMBEDDED
171 saveMainWindowSettings( KGlobal::config(), "MainWindow" ); 171 saveMainWindowSettings( KGlobal::config(), "MainWindow" );
172 172
173 KEditToolbar dlg( factory() ); 173 KEditToolbar dlg( factory() );
174 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); 174 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) );
175 175
176 dlg.exec(); 176 dlg.exec();
177#else //KAB_EMBEDDED 177#else //KAB_EMBEDDED
178 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); 178 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" );
179#endif //KAB_EMBEDDED 179#endif //KAB_EMBEDDED
180} 180}
181 181
182void KAddressBookMain::slotNewToolbarConfig() 182void KAddressBookMain::slotNewToolbarConfig()
183{ 183{
184#ifndef KAB_EMBEDDED 184#ifndef KAB_EMBEDDED
185 applyMainWindowSettings( KGlobal::config(), "MainWindow" ); 185 applyMainWindowSettings( KGlobal::config(), "MainWindow" );
186#else //KAB_EMBEDDED 186#else //KAB_EMBEDDED
187 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); 187 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" );
188#endif //KAB_EMBEDDED 188#endif //KAB_EMBEDDED
189} 189}
190 190
191void KAddressBookMain::configureKeys() 191void KAddressBookMain::configureKeys()
192{ 192{
193#ifndef KAB_EMBEDDED 193#ifndef KAB_EMBEDDED
194 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); 194 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this );
195#else //KAB_EMBEDDED 195#else //KAB_EMBEDDED
196 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); 196 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" );
197#endif //KAB_EMBEDDED 197#endif //KAB_EMBEDDED
198} 198}
199 199
200void KAddressBookMain::closeEvent( QCloseEvent* ce ) 200void KAddressBookMain::closeEvent( QCloseEvent* ce )
201{ 201{
202 QString mess = i18n( "Close KA/Pi?"); 202 bool mModified = mCore->modified();
203 if ( mCore->modified() ) 203 bool mAskForQuit = KABPrefs::instance()->mAskForQuit;
204 mess += i18n( "\n\nChanges will be saved!");
205 else
206 mess += i18n( "\n\nNo unsaved changes detected!\nNothing will be saved!");
207
208 switch( QMessageBox::information( this, "KA/Pi", mess ,
209 i18n("Yes!"), i18n("No"), 0, 0 ) ) {
210 case 0:
211
212 break;
213 case 1:
214 return;
215 break;
216 case 2:
217 return;
218 break;
219
220 default:
221 return;
222 break;
223 }
224 204
225#if 0 205 QString mess = i18n( "Close KA/Pi?");
206 if ( mModified == true )
207 mess += i18n( "\nChanges will be saved!");
208 else
209 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!");
226 210
227 if ( mCore->modified() ) { 211 bool mQuit = true;
228 QString text = i18n( "The address book has been modified.\nDo you want to save your changes?" );
229 212
230#ifndef KAB_EMBEDDED
231 int ret = KMessageBox::warningYesNoCancel( this, text, "",
232 KStdGuiItem::yes(),
233 KStdGuiItem::no(), "AskForSave" );
234 switch ( ret ) {
235 case KMessageBox::Yes:
236 save();
237 break;
238 case KMessageBox::No:
239 return true;
240 break;
241 default: //cancel
242 return ;
243 break;
244 }
245 213
246#else //KAB_EMBEDDED 214 if (mAskForQuit)
247 switch( QMessageBox::information( this, "KA/Pi", 215 {
248 text, 216
249 i18n("Yes!"), i18n("No"), 0, 0 ) ) { 217 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 );
250 case 0: 218 if (res == 0)
251 save(); 219 mQuit = true;
252 break; 220 else
253 case 1: 221 mQuit = false;
254 break;
255 case 2:
256 return;
257 default:
258 return;
259 break;
260 }
261#endif //KAB_EMBEDDED
262 } 222 }
263 223
264#endif 224 if (mQuit == false)
225 return;
226
227 if (mModified == true)
228 {
229 save();
230 mCore->saveSettings();
231 KABPrefs::instance()->writeConfig();
232 }
265 233
266 save();
267 mCore->saveSettings();
268 KABPrefs::instance()->writeConfig();
269 ce->accept(); 234 ce->accept();
270
271} 235}
272 236
273#ifndef KAB_EMBEDDED 237#ifndef KAB_EMBEDDED
274#include "kaddressbookmain.moc" 238#include "kaddressbookmain.moc"
275#endif //KAB_EMBEDDED 239#endif //KAB_EMBEDDED
276 240
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
58class ExtensionItem : public QCheckListItem 59class 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
87KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) 88KABConfigWidget::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
163void KABConfigWidget::restoreSettings(KABPrefs* prefs) 174void 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
183void KABConfigWidget::saveSettings(KABPrefs* prefs) 195void 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
197void KABConfigWidget::defaults(KABPrefs* prefs) 210void 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
206void KABConfigWidget::modified() 220void KABConfigWidget::modified()
207{ 221{
208 emit changed( true ); 222 emit changed( true );
209} 223}
210 224
211void KABConfigWidget::restoreExtensionSettings() 225void 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
253void KABConfigWidget::saveExtensionSettings() 267void 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
271void KABConfigWidget::configureExtension() 285void 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
290void KABConfigWidget::selectionChanged( QListViewItem *i ) 304void 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
299void KABConfigWidget::itemClicked( QListViewItem *item ) 313void 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
306ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) 320ExtensionItem::ExtensionItem( QListView *parent, const QString &text )
307 : QCheckListItem( parent, text, CheckBox ) 321 : QCheckListItem( parent, text, CheckBox )
308{ 322{
309} 323}
310 324
311void ExtensionItem::setService( const KService::Ptr &ptr ) 325void ExtensionItem::setService( const KService::Ptr &ptr )
312{ 326{
313 mPtr = ptr; 327 mPtr = ptr;
314} 328}
315#else //KAB_EMBEDDED 329#else //KAB_EMBEDDED
316ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) 330ExtensionItem::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
324void ExtensionItem::setFactory( ExtensionFactory* fac ) 338void ExtensionItem::setFactory( ExtensionFactory* fac )
325{ 339{
326 mFactory = fac; 340 mFactory = fac;
327} 341}
328#endif //KAB_EMBEDDED 342#endif //KAB_EMBEDDED
329 343
330bool ExtensionItem::configWidgetAvailable() const 344bool 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
348ExtensionFactory *ExtensionItem::factory() const 362ExtensionFactory *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
361QString ExtensionItem::text( int column ) const 375QString 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
29class QCheckBox; 29class QCheckBox;
30class QListViewItem; 30class QListViewItem;
31class QPushButton; 31class QPushButton;
32class QComboBox; 32class QComboBox;
33class QLineEdit; 33class QLineEdit;
34class KListView; 34class KListView;
35class KABPrefs; 35class KABPrefs;
36 36
37class AddresseeWidget; 37class AddresseeWidget;
38 38
39class KABConfigWidget : public QWidget 39class KABConfigWidget : public 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