-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp index c8b68c7..936d052 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp +++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp | |||
@@ -1,398 +1,398 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qframe.h> | 25 | #include <qframe.h> |
26 | #include <qgroupbox.h> | 26 | #include <qgroupbox.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qtabwidget.h> | 29 | #include <qtabwidget.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qvbox.h> | 34 | #include <qvbox.h> |
35 | 35 | ||
36 | #include <kconfig.h> | 36 | #include <kconfig.h> |
37 | #include <kdebug.h> | 37 | #include <kdebug.h> |
38 | #include <kdialog.h> | 38 | #include <kdialog.h> |
39 | #include <klistview.h> | 39 | #include <klistview.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kglobal.h> | 41 | #include <kglobal.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <ktrader.h> | 46 | #include <ktrader.h> |
47 | #else // KAB_EMBEDDED | 47 | #else // KAB_EMBEDDED |
48 | #include <mergewidget.h> | 48 | #include <mergewidget.h> |
49 | #include <distributionlistwidget.h> | 49 | #include <distributionlistwidget.h> |
50 | #endif // KAB_EMBEDDED | 50 | #endif // KAB_EMBEDDED |
51 | 51 | ||
52 | #include "addresseewidget.h" | 52 | #include "addresseewidget.h" |
53 | #include "extensionconfigdialog.h" | 53 | #include "extensionconfigdialog.h" |
54 | #include "extensionwidget.h" | 54 | #include "extensionwidget.h" |
55 | #include "kabprefs.h" | 55 | #include "kabprefs.h" |
56 | 56 | ||
57 | #include "kabconfigwidget.h" | 57 | #include "kabconfigwidget.h" |
58 | 58 | ||
59 | class ExtensionItem : public QCheckListItem | 59 | class ExtensionItem : public QCheckListItem |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | 62 | ||
63 | #ifndef KAB_EMBEDDED | 63 | #ifndef KAB_EMBEDDED |
64 | ExtensionItem( QListView *parent, const QString &text ); | 64 | ExtensionItem( QListView *parent, const QString &text ); |
65 | void setService( const KService::Ptr &ptr ); | 65 | void setService( const KService::Ptr &ptr ); |
66 | #else //KAB_EMBEDDED | 66 | #else //KAB_EMBEDDED |
67 | ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); | 67 | ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); |
68 | void setFactory( ExtensionFactory* fac ); | 68 | void setFactory( ExtensionFactory* fac ); |
69 | #endif //KAB_EMBEDDED | 69 | #endif //KAB_EMBEDDED |
70 | 70 | ||
71 | bool configWidgetAvailable() const; | 71 | bool configWidgetAvailable() const; |
72 | ExtensionFactory *factory() const; | 72 | ExtensionFactory *factory() const; |
73 | 73 | ||
74 | virtual QString text( int column ) const; | 74 | virtual QString text( int column ) const; |
75 | 75 | ||
76 | private: | 76 | private: |
77 | #ifndef KAB_EMBEDDED | 77 | #ifndef KAB_EMBEDDED |
78 | KService::Ptr mPtr; | 78 | KService::Ptr mPtr; |
79 | #else //KAB_EMBEDDED | 79 | #else //KAB_EMBEDDED |
80 | ExtensionFactory* mFactory; | 80 | ExtensionFactory* mFactory; |
81 | QString mName; | 81 | QString mName; |
82 | QString mComment; | 82 | QString mComment; |
83 | 83 | ||
84 | #endif //KAB_EMBEDDED | 84 | #endif //KAB_EMBEDDED |
85 | 85 | ||
86 | }; | 86 | }; |
87 | 87 | ||
88 | KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name ) | 88 | KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name ) |
89 | : KPrefsWidget( prefs, parent, name ) | 89 | : KPrefsWidget( prefs, parent, name ) |
90 | { | 90 | { |
91 | QVBoxLayout *topLayout = new QVBoxLayout( this, 0, | 91 | QVBoxLayout *topLayout = new QVBoxLayout( this, 0, |
92 | KDialog::spacingHint() ); | 92 | KDialog::spacingHint() ); |
93 | 93 | ||
94 | QTabWidget *tabWidget = new QTabWidget( this ); | 94 | QTabWidget *tabWidget = new QTabWidget( this ); |
95 | topLayout->addWidget( tabWidget ); | 95 | topLayout->addWidget( tabWidget ); |
96 | 96 | ||
97 | // General page | 97 | // General page |
98 | QWidget *generalPage = new QWidget( this ); | 98 | QWidget *generalPage = new QWidget( this ); |
99 | QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), | 99 | QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), |
100 | KDialog::spacingHintSmall() ); | 100 | KDialog::spacingHintSmall() ); |
101 | 101 | ||
102 | |||
102 | QWidget *hBox = new QWidget( generalPage, "qhbox" ); | 103 | QWidget *hBox = new QWidget( generalPage, "qhbox" ); |
103 | QHBoxLayout *hboxLayout = new QHBoxLayout( hBox); | 104 | QHBoxLayout *hboxLayout = new QHBoxLayout( hBox); |
104 | KPrefsWidFont *detailsFont = | 105 | KPrefsWidFont *detailsFont = |
105 | addWidFont(i18n("phone:123"),i18n("Details view font"), | 106 | addWidFont(i18n("phone:123"),i18n("Details view font"), |
106 | &(KABPrefs::instance()->mDetailsFont),hBox); | 107 | &(KABPrefs::instance()->mDetailsFont),hBox); |
107 | hboxLayout->addWidget(detailsFont->label()); | 108 | hboxLayout->addWidget(detailsFont->label()); |
108 | hboxLayout->addWidget(detailsFont->preview()); | 109 | hboxLayout->addWidget(detailsFont->preview()); |
109 | hboxLayout->addWidget(detailsFont->button()); | 110 | hboxLayout->addWidget(detailsFont->button()); |
110 | hboxLayout->setMargin(KDialog::marginHintSmall() ); | 111 | hboxLayout->setMargin(KDialog::marginHintSmall() ); |
111 | hboxLayout->setSpacing(KDialog::spacingHintSmall()); | 112 | hboxLayout->setSpacing(KDialog::spacingHintSmall()); |
113 | //hBox->setBackgroundColor( black); | ||
112 | layout->addWidget( hBox ); | 114 | layout->addWidget( hBox ); |
113 | 115 | ||
114 | //general groupbox | 116 | //general groupbox |
115 | QVBox *vBox = new QVBox( generalPage, "qvbox" ); | 117 | QWidget *vBox = new QWidget( generalPage, "qvbox" ); |
116 | QVBoxLayout *boxLayout = new QVBoxLayout( vBox->layout(), -1, "qvboxlayout" ); | 118 | QVBoxLayout *boxLayout = new QVBoxLayout( vBox ); |
117 | boxLayout->setAlignment( Qt::AlignTop ); | 119 | boxLayout->setAlignment( Qt::AlignTop ); |
118 | boxLayout->setMargin(KDialog::marginHintSmall() ); | 120 | boxLayout->setMargin(KDialog::marginHintSmall() ); |
119 | vBox->layout()->setMargin(KDialog::marginHintSmall()) ; | ||
120 | vBox->layout()->setSpacing(KDialog::spacingHintSmall()); | ||
121 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); | 121 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); |
122 | mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); | 122 | mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); |
123 | boxLayout->addWidget( mSearchReturnBox ); | 123 | boxLayout->addWidget( mSearchReturnBox ); |
124 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); | 124 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); |
125 | boxLayout->addWidget( mViewsSingleClickBox ); | 125 | boxLayout->addWidget( mViewsSingleClickBox ); |
126 | 126 | ||
127 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); | 127 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); |
128 | boxLayout->addWidget( mNameParsing ); | 128 | boxLayout->addWidget( mNameParsing ); |
129 | 129 | ||
130 | mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); | 130 | mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); |
131 | boxLayout->addWidget( mMultipleViewsAtOnce ); | 131 | boxLayout->addWidget( mMultipleViewsAtOnce ); |
132 | 132 | ||
133 | mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); | 133 | mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); |
134 | boxLayout->addWidget( mAskForQuit ); | 134 | boxLayout->addWidget( mAskForQuit ); |
135 | 135 | ||
136 | layout->addWidget( vBox ); | 136 | layout->addWidget( vBox ); |
137 | 137 | ||
138 | tabWidget->addTab( generalPage, i18n( "General" ) ); | 138 | tabWidget->addTab( generalPage, i18n( "General" ) ); |
139 | 139 | ||
140 | // Extension page | 140 | // Extension page |
141 | QWidget *extensionPage = new QWidget( this ); | 141 | QWidget *extensionPage = new QWidget( this ); |
142 | QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), | 142 | QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), |
143 | KDialog::spacingHintSmall() ); | 143 | KDialog::spacingHintSmall() ); |
144 | 144 | ||
145 | //extensions groupbox | 145 | //extensions groupbox |
146 | 146 | ||
147 | QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); | 147 | QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); |
148 | boxLayout = new QVBoxLayout( groupBox->layout() ); | 148 | boxLayout = new QVBoxLayout( groupBox->layout() ); |
149 | boxLayout->setAlignment( Qt::AlignTop ); | 149 | boxLayout->setAlignment( Qt::AlignTop ); |
150 | boxLayout->setMargin(KDialog::marginHintSmall()); | 150 | boxLayout->setMargin(KDialog::marginHintSmall()); |
151 | boxLayout->setSpacing(KDialog::spacingHintSmall()); | 151 | boxLayout->setSpacing(KDialog::spacingHintSmall()); |
152 | groupBox->layout()->setMargin(1) ; | 152 | groupBox->layout()->setMargin(1) ; |
153 | groupBox->layout()->setSpacing(0); | 153 | groupBox->layout()->setSpacing(0); |
154 | mExtensionView = new KListView( groupBox ); | 154 | mExtensionView = new KListView( groupBox ); |
155 | mExtensionView->setAllColumnsShowFocus( true ); | 155 | mExtensionView->setAllColumnsShowFocus( true ); |
156 | mExtensionView->addColumn( i18n( "Name" ) ); | 156 | mExtensionView->addColumn( i18n( "Name" ) ); |
157 | mExtensionView->addColumn( i18n( "Description" ) ); | 157 | mExtensionView->addColumn( i18n( "Description" ) ); |
158 | mExtensionView->setMaximumHeight(80); | 158 | mExtensionView->setMaximumHeight(80); |
159 | 159 | ||
160 | boxLayout->addWidget( mExtensionView ); | 160 | boxLayout->addWidget( mExtensionView ); |
161 | 161 | ||
162 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); | 162 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); |
163 | mConfigureButton->setEnabled( false ); | 163 | mConfigureButton->setEnabled( false ); |
164 | boxLayout->addWidget( mConfigureButton ); | 164 | boxLayout->addWidget( mConfigureButton ); |
165 | 165 | ||
166 | extensionLayout->addWidget( groupBox ); | 166 | extensionLayout->addWidget( groupBox ); |
167 | 167 | ||
168 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 168 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
169 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 169 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
170 | connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 170 | connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
171 | connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 171 | connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
172 | connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 172 | connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
173 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), | 173 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), |
174 | SLOT( selectionChanged( QListViewItem* ) ) ); | 174 | SLOT( selectionChanged( QListViewItem* ) ) ); |
175 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), | 175 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), |
176 | SLOT( itemClicked( QListViewItem* ) ) ); | 176 | SLOT( itemClicked( QListViewItem* ) ) ); |
177 | connect( mConfigureButton, SIGNAL( clicked() ), | 177 | connect( mConfigureButton, SIGNAL( clicked() ), |
178 | SLOT( configureExtension() ) ); | 178 | SLOT( configureExtension() ) ); |
179 | 179 | ||
180 | tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); | 180 | tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); |
181 | 181 | ||
182 | // Addressee page | 182 | // Addressee page |
183 | mAddresseeWidget = new AddresseeWidget( this ); | 183 | mAddresseeWidget = new AddresseeWidget( this ); |
184 | tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); | 184 | tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); |
185 | connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); | 185 | connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); |
186 | 186 | ||
187 | } | 187 | } |
188 | 188 | ||
189 | void KABConfigWidget::usrReadConfig() | 189 | void KABConfigWidget::usrReadConfig() |
190 | { | 190 | { |
191 | KABPrefs* prefs = KABPrefs::instance(); | 191 | KABPrefs* prefs = KABPrefs::instance(); |
192 | 192 | ||
193 | bool blocked = signalsBlocked(); | 193 | bool blocked = signalsBlocked(); |
194 | blockSignals( true ); | 194 | blockSignals( true ); |
195 | 195 | ||
196 | mNameParsing->setChecked( prefs->mAutomaticNameParsing ); | 196 | mNameParsing->setChecked( prefs->mAutomaticNameParsing ); |
197 | mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); | 197 | mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); |
198 | mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); | 198 | mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); |
199 | mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); | 199 | mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); |
200 | mAskForQuit->setChecked( prefs->mAskForQuit ); | 200 | mAskForQuit->setChecked( prefs->mAskForQuit ); |
201 | 201 | ||
202 | mAddresseeWidget->restoreSettings(); | 202 | mAddresseeWidget->restoreSettings(); |
203 | 203 | ||
204 | restoreExtensionSettings(); | 204 | restoreExtensionSettings(); |
205 | 205 | ||
206 | blockSignals( blocked ); | 206 | blockSignals( blocked ); |
207 | 207 | ||
208 | } | 208 | } |
209 | 209 | ||
210 | void KABConfigWidget::usrWriteConfig() | 210 | void KABConfigWidget::usrWriteConfig() |
211 | { | 211 | { |
212 | KABPrefs* prefs = KABPrefs::instance(); | 212 | KABPrefs* prefs = KABPrefs::instance(); |
213 | 213 | ||
214 | prefs->mAutomaticNameParsing = mNameParsing->isChecked(); | 214 | prefs->mAutomaticNameParsing = mNameParsing->isChecked(); |
215 | prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); | 215 | prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); |
216 | prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); | 216 | prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); |
217 | prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); | 217 | prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); |
218 | prefs->mAskForQuit = mAskForQuit->isChecked(); | 218 | prefs->mAskForQuit = mAskForQuit->isChecked(); |
219 | 219 | ||
220 | mAddresseeWidget->saveSettings(); | 220 | mAddresseeWidget->saveSettings(); |
221 | 221 | ||
222 | saveExtensionSettings(); | 222 | saveExtensionSettings(); |
223 | 223 | ||
224 | } | 224 | } |
225 | 225 | ||
226 | void KABConfigWidget::restoreExtensionSettings() | 226 | void KABConfigWidget::restoreExtensionSettings() |
227 | { | 227 | { |
228 | QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; | 228 | QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; |
229 | 229 | ||
230 | mExtensionView->clear(); | 230 | mExtensionView->clear(); |
231 | 231 | ||
232 | #ifndef KAB_EMBEDDED | 232 | #ifndef KAB_EMBEDDED |
233 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); | 233 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); |
234 | KTrader::OfferList::ConstIterator it; | 234 | KTrader::OfferList::ConstIterator it; |
235 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 235 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
236 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) | 236 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) |
237 | continue; | 237 | continue; |
238 | 238 | ||
239 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); | 239 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); |
240 | item->setService( *it ); | 240 | item->setService( *it ); |
241 | if ( activeExtensions.contains( item->factory()->identifier() ) ) | 241 | if ( activeExtensions.contains( item->factory()->identifier() ) ) |
242 | item->setOn( true ); | 242 | item->setOn( true ); |
243 | } | 243 | } |
244 | #else //KAB_EMBEDDED | 244 | #else //KAB_EMBEDDED |
245 | ExtensionFactory *extensionFactory = new MergeFactory(); | 245 | ExtensionFactory *extensionFactory = new MergeFactory(); |
246 | 246 | ||
247 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); | 247 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); |
248 | 248 | ||
249 | item->setFactory( extensionFactory ); | 249 | item->setFactory( extensionFactory ); |
250 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 250 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
251 | item->setOn( true ); | 251 | item->setOn( true ); |
252 | 252 | ||
253 | 253 | ||
254 | 254 | ||
255 | extensionFactory = new DistributionListFactory(); | 255 | extensionFactory = new DistributionListFactory(); |
256 | 256 | ||
257 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); | 257 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); |
258 | 258 | ||
259 | item->setFactory( extensionFactory ); | 259 | item->setFactory( extensionFactory ); |
260 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 260 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
261 | item->setOn( true ); | 261 | item->setOn( true ); |
262 | 262 | ||
263 | 263 | ||
264 | #endif //KAB_EMBEDDED | 264 | #endif //KAB_EMBEDDED |
265 | 265 | ||
266 | } | 266 | } |
267 | 267 | ||
268 | void KABConfigWidget::saveExtensionSettings() | 268 | void KABConfigWidget::saveExtensionSettings() |
269 | { | 269 | { |
270 | QStringList activeExtensions; | 270 | QStringList activeExtensions; |
271 | 271 | ||
272 | QPtrList<QListViewItem> list; | 272 | QPtrList<QListViewItem> list; |
273 | QListViewItemIterator it( mExtensionView ); | 273 | QListViewItemIterator it( mExtensionView ); |
274 | while ( it.current() ) { | 274 | while ( it.current() ) { |
275 | ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); | 275 | ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); |
276 | if ( item ) { | 276 | if ( item ) { |
277 | if ( item->isOn() ) | 277 | if ( item->isOn() ) |
278 | activeExtensions.append( item->factory()->identifier() ); | 278 | activeExtensions.append( item->factory()->identifier() ); |
279 | } | 279 | } |
280 | ++it; | 280 | ++it; |
281 | } | 281 | } |
282 | 282 | ||
283 | KABPrefs::instance()->mActiveExtensions = activeExtensions; | 283 | KABPrefs::instance()->mActiveExtensions = activeExtensions; |
284 | } | 284 | } |
285 | 285 | ||
286 | void KABConfigWidget::configureExtension() | 286 | void KABConfigWidget::configureExtension() |
287 | { | 287 | { |
288 | ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); | 288 | ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); |
289 | if ( !item ) | 289 | if ( !item ) |
290 | return; | 290 | return; |
291 | 291 | ||
292 | #ifndef KAB_EMBEDDED | 292 | #ifndef KAB_EMBEDDED |
293 | KConfig config( "kaddressbookrc" ); | 293 | KConfig config( "kaddressbookrc" ); |
294 | #else //KAB_EMBEDDED | 294 | #else //KAB_EMBEDDED |
295 | KConfig config( locateLocal("config", "kaddressbookrc") ); | 295 | KConfig config( locateLocal("config", "kaddressbookrc") ); |
296 | #endif //KAB_EMBEDDED | 296 | #endif //KAB_EMBEDDED |
297 | config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); | 297 | config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); |
298 | 298 | ||
299 | ExtensionConfigDialog dlg( item->factory(), &config, this ); | 299 | ExtensionConfigDialog dlg( item->factory(), &config, this ); |
300 | dlg.exec(); | 300 | dlg.exec(); |
301 | 301 | ||
302 | config.sync(); | 302 | config.sync(); |
303 | } | 303 | } |
304 | 304 | ||
305 | void KABConfigWidget::selectionChanged( QListViewItem *i ) | 305 | void KABConfigWidget::selectionChanged( QListViewItem *i ) |
306 | { | 306 | { |
307 | ExtensionItem *item = static_cast<ExtensionItem*>( i ); | 307 | ExtensionItem *item = static_cast<ExtensionItem*>( i ); |
308 | if ( !item ) | 308 | if ( !item ) |
309 | return; | 309 | return; |
310 | 310 | ||
311 | mConfigureButton->setEnabled( item->configWidgetAvailable() ); | 311 | mConfigureButton->setEnabled( item->configWidgetAvailable() ); |
312 | } | 312 | } |
313 | 313 | ||
314 | void KABConfigWidget::itemClicked( QListViewItem *item ) | 314 | void KABConfigWidget::itemClicked( QListViewItem *item ) |
315 | { | 315 | { |
316 | if ( item != 0 ) | 316 | if ( item != 0 ) |
317 | modified(); | 317 | modified(); |
318 | } | 318 | } |
319 | 319 | ||
320 | #ifndef KAB_EMBEDDED | 320 | #ifndef KAB_EMBEDDED |
321 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) | 321 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) |
322 | : QCheckListItem( parent, text, CheckBox ) | 322 | : QCheckListItem( parent, text, CheckBox ) |
323 | { | 323 | { |
324 | } | 324 | } |
325 | 325 | ||
326 | void ExtensionItem::setService( const KService::Ptr &ptr ) | 326 | void ExtensionItem::setService( const KService::Ptr &ptr ) |
327 | { | 327 | { |
328 | mPtr = ptr; | 328 | mPtr = ptr; |
329 | } | 329 | } |
330 | #else //KAB_EMBEDDED | 330 | #else //KAB_EMBEDDED |
331 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) | 331 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) |
332 | : QCheckListItem( parent, text, CheckBox ) | 332 | : QCheckListItem( parent, text, CheckBox ) |
333 | { | 333 | { |
334 | mName = name; | 334 | mName = name; |
335 | mComment = comment; | 335 | mComment = comment; |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | void ExtensionItem::setFactory( ExtensionFactory* fac ) | 339 | void ExtensionItem::setFactory( ExtensionFactory* fac ) |
340 | { | 340 | { |
341 | mFactory = fac; | 341 | mFactory = fac; |
342 | } | 342 | } |
343 | #endif //KAB_EMBEDDED | 343 | #endif //KAB_EMBEDDED |
344 | 344 | ||
345 | bool ExtensionItem::configWidgetAvailable() const | 345 | bool ExtensionItem::configWidgetAvailable() const |
346 | { | 346 | { |
347 | #ifndef KAB_EMBEDDED | 347 | #ifndef KAB_EMBEDDED |
348 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); | 348 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); |
349 | if ( !factory ) | 349 | if ( !factory ) |
350 | return false; | 350 | return false; |
351 | 351 | ||
352 | ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); | 352 | ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); |
353 | if ( !extensionFactory ) | 353 | if ( !extensionFactory ) |
354 | return false; | 354 | return false; |
355 | 355 | ||
356 | return extensionFactory->configureWidgetAvailable(); | 356 | return extensionFactory->configureWidgetAvailable(); |
357 | #else //KAB_EMBEDDED | 357 | #else //KAB_EMBEDDED |
358 | return mFactory->configureWidgetAvailable(); | 358 | return mFactory->configureWidgetAvailable(); |
359 | #endif //KAB_EMBEDDED | 359 | #endif //KAB_EMBEDDED |
360 | 360 | ||
361 | } | 361 | } |
362 | 362 | ||
363 | ExtensionFactory *ExtensionItem::factory() const | 363 | ExtensionFactory *ExtensionItem::factory() const |
364 | { | 364 | { |
365 | #ifndef KAB_EMBEDDED | 365 | #ifndef KAB_EMBEDDED |
366 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); | 366 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); |
367 | if ( !factory ) | 367 | if ( !factory ) |
368 | return 0; | 368 | return 0; |
369 | 369 | ||
370 | return static_cast<ExtensionFactory*>( factory ); | 370 | return static_cast<ExtensionFactory*>( factory ); |
371 | #else //KAB_EMBEDDED | 371 | #else //KAB_EMBEDDED |
372 | return mFactory; | 372 | return mFactory; |
373 | #endif //KAB_EMBEDDED | 373 | #endif //KAB_EMBEDDED |
374 | } | 374 | } |
375 | 375 | ||
376 | QString ExtensionItem::text( int column ) const | 376 | QString ExtensionItem::text( int column ) const |
377 | { | 377 | { |
378 | #ifndef KAB_EMBEDDED | 378 | #ifndef KAB_EMBEDDED |
379 | if ( column == 0 ) | 379 | if ( column == 0 ) |
380 | return mPtr->name(); | 380 | return mPtr->name(); |
381 | else if ( column == 1 ) | 381 | else if ( column == 1 ) |
382 | return mPtr->comment(); | 382 | return mPtr->comment(); |
383 | else | 383 | else |
384 | return QString::null; | 384 | return QString::null; |
385 | #else //KAB_EMBEDDED | 385 | #else //KAB_EMBEDDED |
386 | if ( column == 0 ) | 386 | if ( column == 0 ) |
387 | return mName; | 387 | return mName; |
388 | else if ( column == 1 ) | 388 | else if ( column == 1 ) |
389 | return mComment; | 389 | return mComment; |
390 | else | 390 | else |
391 | return QString::null; | 391 | return QString::null; |
392 | #endif //KAB_EMBEDDED | 392 | #endif //KAB_EMBEDDED |
393 | } | 393 | } |
394 | 394 | ||
395 | #ifndef KAB_EMBEDDED | 395 | #ifndef KAB_EMBEDDED |
396 | #include "kabconfigwidget.moc" | 396 | #include "kabconfigwidget.moc" |
397 | #endif //KAB_EMBEDDED | 397 | #endif //KAB_EMBEDDED |
398 | 398 | ||