-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.cpp | 15 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.h | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp index 3ad2f74..986c9b8 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp +++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp | |||
@@ -1,401 +1,416 @@ | |||
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 | ||
103 | QWidget *hBox = new QWidget( generalPage, "qhbox" ); | 103 | QWidget *hBox = new QWidget( generalPage, "qhbox" ); |
104 | QHBoxLayout *hboxLayout = new QHBoxLayout( hBox); | 104 | QHBoxLayout *hboxLayout = new QHBoxLayout( hBox); |
105 | KPrefsWidFont *detailsFont = | 105 | KPrefsWidFont *detailsFont = |
106 | addWidFont(i18n("phone:123"),i18n("Details view font"), | 106 | addWidFont(i18n("phone:123"),i18n("Details view font"), |
107 | &(KABPrefs::instance()->mDetailsFont),hBox); | 107 | &(KABPrefs::instance()->mDetailsFont),hBox); |
108 | hboxLayout->addWidget(detailsFont->label()); | 108 | hboxLayout->addWidget(detailsFont->label()); |
109 | hboxLayout->addWidget(detailsFont->preview()); | 109 | hboxLayout->addWidget(detailsFont->preview()); |
110 | hboxLayout->addWidget(detailsFont->button()); | 110 | hboxLayout->addWidget(detailsFont->button()); |
111 | hboxLayout->setMargin(KDialog::marginHintSmall() ); | 111 | hboxLayout->setMargin(KDialog::marginHintSmall() ); |
112 | hboxLayout->setSpacing(KDialog::spacingHintSmall()); | 112 | hboxLayout->setSpacing(KDialog::spacingHintSmall()); |
113 | //hBox->setBackgroundColor( black); | 113 | //hBox->setBackgroundColor( black); |
114 | layout->addWidget( hBox ); | 114 | layout->addWidget( hBox ); |
115 | 115 | ||
116 | //general groupbox | 116 | //general groupbox |
117 | QWidget *vBox = new QWidget( generalPage, "qvbox" ); | 117 | QWidget *vBox = new QWidget( generalPage, "qvbox" ); |
118 | QVBoxLayout *boxLayout = new QVBoxLayout( vBox ); | 118 | QVBoxLayout *boxLayout = new QVBoxLayout( vBox ); |
119 | boxLayout->setAlignment( Qt::AlignTop ); | 119 | boxLayout->setAlignment( Qt::AlignTop ); |
120 | boxLayout->setMargin(KDialog::marginHintSmall() ); | 120 | boxLayout->setMargin(KDialog::marginHintSmall() ); |
121 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); | 121 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); |
122 | mMenuBarBox = new QCheckBox( i18n( "Full Menu bar (restart)" ), vBox, "mremenuturn" ); | 122 | mMenuBarBox = new QCheckBox( i18n( "Full Menu bar (restart)" ), vBox, "mremenuturn" ); |
123 | boxLayout->addWidget( mMenuBarBox ); | 123 | boxLayout->addWidget( mMenuBarBox ); |
124 | mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); | 124 | mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); |
125 | boxLayout->addWidget( mSearchReturnBox ); | 125 | boxLayout->addWidget( mSearchReturnBox ); |
126 | mAutoSearchWithWildcardBox = new QCheckBox( i18n( "Search with '*' prefix (wildcard)" ), vBox, "mwildcard" ); | ||
127 | boxLayout->addWidget( mAutoSearchWithWildcardBox); | ||
128 | mHideSearchOnSwitchBox = new QCheckBox( i18n( "Shrink searchfield in portrait view" ), vBox, "mswitch" ); | ||
129 | boxLayout->addWidget( mHideSearchOnSwitchBox ); | ||
130 | |||
131 | #ifdef DESKTOP_VERSION | ||
132 | mHideSearchOnSwitchBox->hide(); | ||
133 | #endif | ||
126 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); | 134 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); |
127 | boxLayout->addWidget( mViewsSingleClickBox ); | 135 | boxLayout->addWidget( mViewsSingleClickBox ); |
128 | 136 | ||
129 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); | 137 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); |
130 | boxLayout->addWidget( mNameParsing ); | 138 | boxLayout->addWidget( mNameParsing ); |
131 | 139 | ||
132 | mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); | 140 | mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); |
133 | boxLayout->addWidget( mMultipleViewsAtOnce ); | 141 | boxLayout->addWidget( mMultipleViewsAtOnce ); |
134 | 142 | ||
135 | mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); | 143 | mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); |
136 | boxLayout->addWidget( mAskForQuit ); | 144 | boxLayout->addWidget( mAskForQuit ); |
137 | 145 | ||
138 | layout->addWidget( vBox ); | 146 | layout->addWidget( vBox ); |
139 | 147 | ||
140 | tabWidget->addTab( generalPage, i18n( "General" ) ); | 148 | tabWidget->addTab( generalPage, i18n( "General" ) ); |
141 | 149 | ||
142 | // Extension page | 150 | // Extension page |
143 | QWidget *extensionPage = new QWidget( this ); | 151 | QWidget *extensionPage = new QWidget( this ); |
144 | QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), | 152 | QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), |
145 | KDialog::spacingHintSmall() ); | 153 | KDialog::spacingHintSmall() ); |
146 | 154 | ||
147 | //extensions groupbox | 155 | //extensions groupbox |
148 | 156 | ||
149 | QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); | 157 | QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); |
150 | boxLayout = new QVBoxLayout( groupBox->layout() ); | 158 | boxLayout = new QVBoxLayout( groupBox->layout() ); |
151 | boxLayout->setAlignment( Qt::AlignTop ); | 159 | boxLayout->setAlignment( Qt::AlignTop ); |
152 | boxLayout->setMargin(KDialog::marginHintSmall()); | 160 | boxLayout->setMargin(KDialog::marginHintSmall()); |
153 | boxLayout->setSpacing(KDialog::spacingHintSmall()); | 161 | boxLayout->setSpacing(KDialog::spacingHintSmall()); |
154 | groupBox->layout()->setMargin(1) ; | 162 | groupBox->layout()->setMargin(1) ; |
155 | groupBox->layout()->setSpacing(0); | 163 | groupBox->layout()->setSpacing(0); |
156 | mExtensionView = new KListView( groupBox ); | 164 | mExtensionView = new KListView( groupBox ); |
157 | mExtensionView->setAllColumnsShowFocus( true ); | 165 | mExtensionView->setAllColumnsShowFocus( true ); |
158 | mExtensionView->addColumn( i18n( "Name" ) ); | 166 | mExtensionView->addColumn( i18n( "Name" ) ); |
159 | mExtensionView->addColumn( i18n( "Description" ) ); | 167 | mExtensionView->addColumn( i18n( "Description" ) ); |
160 | //mExtensionView->setMaximumHeight(80); | 168 | //mExtensionView->setMaximumHeight(80); |
161 | 169 | ||
162 | boxLayout->addWidget( mExtensionView ); | 170 | boxLayout->addWidget( mExtensionView ); |
163 | 171 | ||
164 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); | 172 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); |
165 | mConfigureButton->setEnabled( false ); | 173 | mConfigureButton->setEnabled( false ); |
166 | boxLayout->addWidget( mConfigureButton ); | 174 | boxLayout->addWidget( mConfigureButton ); |
167 | 175 | ||
168 | extensionLayout->addWidget( groupBox ); | 176 | extensionLayout->addWidget( groupBox ); |
169 | 177 | ||
170 | connect( mMenuBarBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 178 | connect( mMenuBarBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
171 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 179 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
172 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 180 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
173 | connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 181 | connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
182 | connect( mAutoSearchWithWildcardBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | ||
183 | connect( mHideSearchOnSwitchBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | ||
174 | connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 184 | connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
175 | connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 185 | connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
176 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), | 186 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), |
177 | SLOT( selectionChanged( QListViewItem* ) ) ); | 187 | SLOT( selectionChanged( QListViewItem* ) ) ); |
178 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), | 188 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), |
179 | SLOT( itemClicked( QListViewItem* ) ) ); | 189 | SLOT( itemClicked( QListViewItem* ) ) ); |
180 | connect( mConfigureButton, SIGNAL( clicked() ), | 190 | connect( mConfigureButton, SIGNAL( clicked() ), |
181 | SLOT( configureExtension() ) ); | 191 | SLOT( configureExtension() ) ); |
182 | 192 | ||
183 | tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); | 193 | tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); |
184 | 194 | ||
185 | // Addressee page | 195 | // Addressee page |
186 | mAddresseeWidget = new AddresseeWidget( this ); | 196 | mAddresseeWidget = new AddresseeWidget( this ); |
187 | tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); | 197 | tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); |
188 | connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); | 198 | connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); |
189 | 199 | ||
190 | } | 200 | } |
191 | 201 | ||
192 | void KABConfigWidget::usrReadConfig() | 202 | void KABConfigWidget::usrReadConfig() |
193 | { | 203 | { |
194 | KABPrefs* prefs = KABPrefs::instance(); | 204 | KABPrefs* prefs = KABPrefs::instance(); |
195 | 205 | ||
196 | bool blocked = signalsBlocked(); | 206 | bool blocked = signalsBlocked(); |
197 | blockSignals( true ); | 207 | blockSignals( true ); |
198 | mMenuBarBox->setChecked( prefs->mFullMenuBarVisible); | 208 | mMenuBarBox->setChecked( prefs->mFullMenuBarVisible); |
199 | mNameParsing->setChecked( prefs->mAutomaticNameParsing ); | 209 | mNameParsing->setChecked( prefs->mAutomaticNameParsing ); |
200 | mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); | 210 | mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); |
201 | mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); | 211 | mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); |
212 | mAutoSearchWithWildcardBox->setChecked( prefs->mAutoSearchWithWildcard ); | ||
213 | mHideSearchOnSwitchBox->setChecked( prefs->mHideSearchOnSwitch ); | ||
202 | mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); | 214 | mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); |
203 | mAskForQuit->setChecked( prefs->mAskForQuit ); | 215 | mAskForQuit->setChecked( prefs->mAskForQuit ); |
204 | 216 | ||
205 | mAddresseeWidget->restoreSettings(); | 217 | mAddresseeWidget->restoreSettings(); |
206 | 218 | ||
207 | restoreExtensionSettings(); | 219 | restoreExtensionSettings(); |
208 | 220 | ||
209 | blockSignals( blocked ); | 221 | blockSignals( blocked ); |
210 | 222 | ||
211 | } | 223 | } |
212 | 224 | ||
213 | void KABConfigWidget::usrWriteConfig() | 225 | void KABConfigWidget::usrWriteConfig() |
214 | { | 226 | { |
215 | KABPrefs* prefs = KABPrefs::instance(); | 227 | KABPrefs* prefs = KABPrefs::instance(); |
216 | prefs->mFullMenuBarVisible = mMenuBarBox->isChecked(); | 228 | prefs->mFullMenuBarVisible = mMenuBarBox->isChecked(); |
217 | prefs->mAutomaticNameParsing = mNameParsing->isChecked(); | 229 | prefs->mAutomaticNameParsing = mNameParsing->isChecked(); |
218 | prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); | 230 | prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); |
219 | prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); | 231 | prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); |
232 | prefs->mAutoSearchWithWildcard = mAutoSearchWithWildcardBox->isChecked(); | ||
233 | prefs->mHideSearchOnSwitch = mHideSearchOnSwitchBox->isChecked(); | ||
234 | |||
220 | prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); | 235 | prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); |
221 | prefs->mAskForQuit = mAskForQuit->isChecked(); | 236 | prefs->mAskForQuit = mAskForQuit->isChecked(); |
222 | 237 | ||
223 | mAddresseeWidget->saveSettings(); | 238 | mAddresseeWidget->saveSettings(); |
224 | 239 | ||
225 | saveExtensionSettings(); | 240 | saveExtensionSettings(); |
226 | 241 | ||
227 | } | 242 | } |
228 | 243 | ||
229 | void KABConfigWidget::restoreExtensionSettings() | 244 | void KABConfigWidget::restoreExtensionSettings() |
230 | { | 245 | { |
231 | QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; | 246 | QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; |
232 | 247 | ||
233 | mExtensionView->clear(); | 248 | mExtensionView->clear(); |
234 | 249 | ||
235 | #ifndef KAB_EMBEDDED | 250 | #ifndef KAB_EMBEDDED |
236 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); | 251 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); |
237 | KTrader::OfferList::ConstIterator it; | 252 | KTrader::OfferList::ConstIterator it; |
238 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 253 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
239 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) | 254 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) |
240 | continue; | 255 | continue; |
241 | 256 | ||
242 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); | 257 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); |
243 | item->setService( *it ); | 258 | item->setService( *it ); |
244 | if ( activeExtensions.contains( item->factory()->identifier() ) ) | 259 | if ( activeExtensions.contains( item->factory()->identifier() ) ) |
245 | item->setOn( true ); | 260 | item->setOn( true ); |
246 | } | 261 | } |
247 | #else //KAB_EMBEDDED | 262 | #else //KAB_EMBEDDED |
248 | ExtensionFactory *extensionFactory = new MergeFactory(); | 263 | ExtensionFactory *extensionFactory = new MergeFactory(); |
249 | 264 | ||
250 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); | 265 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); |
251 | 266 | ||
252 | item->setFactory( extensionFactory ); | 267 | item->setFactory( extensionFactory ); |
253 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 268 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
254 | item->setOn( true ); | 269 | item->setOn( true ); |
255 | 270 | ||
256 | 271 | ||
257 | 272 | ||
258 | extensionFactory = new DistributionListFactory(); | 273 | extensionFactory = new DistributionListFactory(); |
259 | 274 | ||
260 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); | 275 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); |
261 | 276 | ||
262 | item->setFactory( extensionFactory ); | 277 | item->setFactory( extensionFactory ); |
263 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 278 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
264 | item->setOn( true ); | 279 | item->setOn( true ); |
265 | 280 | ||
266 | 281 | ||
267 | #endif //KAB_EMBEDDED | 282 | #endif //KAB_EMBEDDED |
268 | 283 | ||
269 | } | 284 | } |
270 | 285 | ||
271 | void KABConfigWidget::saveExtensionSettings() | 286 | void KABConfigWidget::saveExtensionSettings() |
272 | { | 287 | { |
273 | QStringList activeExtensions; | 288 | QStringList activeExtensions; |
274 | 289 | ||
275 | QPtrList<QListViewItem> list; | 290 | QPtrList<QListViewItem> list; |
276 | QListViewItemIterator it( mExtensionView ); | 291 | QListViewItemIterator it( mExtensionView ); |
277 | while ( it.current() ) { | 292 | while ( it.current() ) { |
278 | ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); | 293 | ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); |
279 | if ( item ) { | 294 | if ( item ) { |
280 | if ( item->isOn() ) | 295 | if ( item->isOn() ) |
281 | activeExtensions.append( item->factory()->identifier() ); | 296 | activeExtensions.append( item->factory()->identifier() ); |
282 | } | 297 | } |
283 | ++it; | 298 | ++it; |
284 | } | 299 | } |
285 | 300 | ||
286 | KABPrefs::instance()->mActiveExtensions = activeExtensions; | 301 | KABPrefs::instance()->mActiveExtensions = activeExtensions; |
287 | } | 302 | } |
288 | 303 | ||
289 | void KABConfigWidget::configureExtension() | 304 | void KABConfigWidget::configureExtension() |
290 | { | 305 | { |
291 | ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); | 306 | ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); |
292 | if ( !item ) | 307 | if ( !item ) |
293 | return; | 308 | return; |
294 | 309 | ||
295 | #ifndef KAB_EMBEDDED | 310 | #ifndef KAB_EMBEDDED |
296 | KConfig config( "kaddressbookrc" ); | 311 | KConfig config( "kaddressbookrc" ); |
297 | #else //KAB_EMBEDDED | 312 | #else //KAB_EMBEDDED |
298 | KConfig config( locateLocal("config", "kaddressbookrc") ); | 313 | KConfig config( locateLocal("config", "kaddressbookrc") ); |
299 | #endif //KAB_EMBEDDED | 314 | #endif //KAB_EMBEDDED |
300 | config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); | 315 | config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); |
301 | 316 | ||
302 | ExtensionConfigDialog dlg( item->factory(), &config, this ); | 317 | ExtensionConfigDialog dlg( item->factory(), &config, this ); |
303 | dlg.exec(); | 318 | dlg.exec(); |
304 | 319 | ||
305 | config.sync(); | 320 | config.sync(); |
306 | } | 321 | } |
307 | 322 | ||
308 | void KABConfigWidget::selectionChanged( QListViewItem *i ) | 323 | void KABConfigWidget::selectionChanged( QListViewItem *i ) |
309 | { | 324 | { |
310 | ExtensionItem *item = static_cast<ExtensionItem*>( i ); | 325 | ExtensionItem *item = static_cast<ExtensionItem*>( i ); |
311 | if ( !item ) | 326 | if ( !item ) |
312 | return; | 327 | return; |
313 | 328 | ||
314 | mConfigureButton->setEnabled( item->configWidgetAvailable() ); | 329 | mConfigureButton->setEnabled( item->configWidgetAvailable() ); |
315 | } | 330 | } |
316 | 331 | ||
317 | void KABConfigWidget::itemClicked( QListViewItem *item ) | 332 | void KABConfigWidget::itemClicked( QListViewItem *item ) |
318 | { | 333 | { |
319 | if ( item != 0 ) | 334 | if ( item != 0 ) |
320 | modified(); | 335 | modified(); |
321 | } | 336 | } |
322 | 337 | ||
323 | #ifndef KAB_EMBEDDED | 338 | #ifndef KAB_EMBEDDED |
324 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) | 339 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) |
325 | : QCheckListItem( parent, text, CheckBox ) | 340 | : QCheckListItem( parent, text, CheckBox ) |
326 | { | 341 | { |
327 | } | 342 | } |
328 | 343 | ||
329 | void ExtensionItem::setService( const KService::Ptr &ptr ) | 344 | void ExtensionItem::setService( const KService::Ptr &ptr ) |
330 | { | 345 | { |
331 | mPtr = ptr; | 346 | mPtr = ptr; |
332 | } | 347 | } |
333 | #else //KAB_EMBEDDED | 348 | #else //KAB_EMBEDDED |
334 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) | 349 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) |
335 | : QCheckListItem( parent, text, CheckBox ) | 350 | : QCheckListItem( parent, text, CheckBox ) |
336 | { | 351 | { |
337 | mName = name; | 352 | mName = name; |
338 | mComment = comment; | 353 | mComment = comment; |
339 | } | 354 | } |
340 | 355 | ||
341 | 356 | ||
342 | void ExtensionItem::setFactory( ExtensionFactory* fac ) | 357 | void ExtensionItem::setFactory( ExtensionFactory* fac ) |
343 | { | 358 | { |
344 | mFactory = fac; | 359 | mFactory = fac; |
345 | } | 360 | } |
346 | #endif //KAB_EMBEDDED | 361 | #endif //KAB_EMBEDDED |
347 | 362 | ||
348 | bool ExtensionItem::configWidgetAvailable() const | 363 | bool ExtensionItem::configWidgetAvailable() const |
349 | { | 364 | { |
350 | #ifndef KAB_EMBEDDED | 365 | #ifndef KAB_EMBEDDED |
351 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); | 366 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); |
352 | if ( !factory ) | 367 | if ( !factory ) |
353 | return false; | 368 | return false; |
354 | 369 | ||
355 | ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); | 370 | ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); |
356 | if ( !extensionFactory ) | 371 | if ( !extensionFactory ) |
357 | return false; | 372 | return false; |
358 | 373 | ||
359 | return extensionFactory->configureWidgetAvailable(); | 374 | return extensionFactory->configureWidgetAvailable(); |
360 | #else //KAB_EMBEDDED | 375 | #else //KAB_EMBEDDED |
361 | return mFactory->configureWidgetAvailable(); | 376 | return mFactory->configureWidgetAvailable(); |
362 | #endif //KAB_EMBEDDED | 377 | #endif //KAB_EMBEDDED |
363 | 378 | ||
364 | } | 379 | } |
365 | 380 | ||
366 | ExtensionFactory *ExtensionItem::factory() const | 381 | ExtensionFactory *ExtensionItem::factory() const |
367 | { | 382 | { |
368 | #ifndef KAB_EMBEDDED | 383 | #ifndef KAB_EMBEDDED |
369 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); | 384 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); |
370 | if ( !factory ) | 385 | if ( !factory ) |
371 | return 0; | 386 | return 0; |
372 | 387 | ||
373 | return static_cast<ExtensionFactory*>( factory ); | 388 | return static_cast<ExtensionFactory*>( factory ); |
374 | #else //KAB_EMBEDDED | 389 | #else //KAB_EMBEDDED |
375 | return mFactory; | 390 | return mFactory; |
376 | #endif //KAB_EMBEDDED | 391 | #endif //KAB_EMBEDDED |
377 | } | 392 | } |
378 | 393 | ||
379 | QString ExtensionItem::text( int column ) const | 394 | QString ExtensionItem::text( int column ) const |
380 | { | 395 | { |
381 | #ifndef KAB_EMBEDDED | 396 | #ifndef KAB_EMBEDDED |
382 | if ( column == 0 ) | 397 | if ( column == 0 ) |
383 | return mPtr->name(); | 398 | return mPtr->name(); |
384 | else if ( column == 1 ) | 399 | else if ( column == 1 ) |
385 | return mPtr->comment(); | 400 | return mPtr->comment(); |
386 | else | 401 | else |
387 | return QString::null; | 402 | return QString::null; |
388 | #else //KAB_EMBEDDED | 403 | #else //KAB_EMBEDDED |
389 | if ( column == 0 ) | 404 | if ( column == 0 ) |
390 | return mName; | 405 | return mName; |
391 | else if ( column == 1 ) | 406 | else if ( column == 1 ) |
392 | return mComment; | 407 | return mComment; |
393 | else | 408 | else |
394 | return QString::null; | 409 | return QString::null; |
395 | #endif //KAB_EMBEDDED | 410 | #endif //KAB_EMBEDDED |
396 | } | 411 | } |
397 | 412 | ||
398 | #ifndef KAB_EMBEDDED | 413 | #ifndef KAB_EMBEDDED |
399 | #include "kabconfigwidget.moc" | 414 | #include "kabconfigwidget.moc" |
400 | #endif //KAB_EMBEDDED | 415 | #endif //KAB_EMBEDDED |
401 | 416 | ||
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h index 08d71b4..a172e97 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.h +++ b/kaddressbook/kcmconfigs/kabconfigwidget.h | |||
@@ -1,75 +1,77 @@ | |||
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 <kprefswidget.h> | 27 | #include <kprefswidget.h> |
28 | 28 | ||
29 | class QCheckBox; | 29 | class QCheckBox; |
30 | class QListViewItem; | 30 | class QListViewItem; |
31 | class QPushButton; | 31 | class QPushButton; |
32 | class QComboBox; | 32 | class QComboBox; |
33 | class QLineEdit; | 33 | class QLineEdit; |
34 | class KListView; | 34 | class KListView; |
35 | class KABPrefs; | 35 | class KABPrefs; |
36 | 36 | ||
37 | class AddresseeWidget; | 37 | class AddresseeWidget; |
38 | 38 | ||
39 | class KABConfigWidget : public KPrefsWidget | 39 | class KABConfigWidget : public KPrefsWidget |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
44 | KABConfigWidget(KABPrefs *prefs, QWidget *parent, const char *name = 0 ); | 44 | KABConfigWidget(KABPrefs *prefs, QWidget *parent, const char *name = 0 ); |
45 | 45 | ||
46 | protected: | 46 | protected: |
47 | /** Implement this to read custom configuration widgets. */ | 47 | /** Implement this to read custom configuration widgets. */ |
48 | virtual void usrReadConfig(); | 48 | virtual void usrReadConfig(); |
49 | /** Implement this to write custom configuration widgets. */ | 49 | /** Implement this to write custom configuration widgets. */ |
50 | virtual void usrWriteConfig(); | 50 | virtual void usrWriteConfig(); |
51 | 51 | ||
52 | 52 | ||
53 | 53 | ||
54 | private slots: | 54 | private slots: |
55 | void configureExtension(); | 55 | void configureExtension(); |
56 | void selectionChanged( QListViewItem* ); | 56 | void selectionChanged( QListViewItem* ); |
57 | void itemClicked( QListViewItem* ); | 57 | void itemClicked( QListViewItem* ); |
58 | 58 | ||
59 | private: | 59 | private: |
60 | void restoreExtensionSettings(); | 60 | void restoreExtensionSettings(); |
61 | void saveExtensionSettings(); | 61 | void saveExtensionSettings(); |
62 | 62 | ||
63 | KListView *mExtensionView; | 63 | KListView *mExtensionView; |
64 | QCheckBox *mSearchReturnBox; | 64 | QCheckBox *mSearchReturnBox; |
65 | QCheckBox *mNameParsing; | 65 | QCheckBox *mNameParsing; |
66 | QCheckBox *mViewsSingleClickBox; | 66 | QCheckBox *mViewsSingleClickBox; |
67 | QCheckBox *mAutoSearchWithWildcardBox; | ||
68 | QCheckBox *mHideSearchOnSwitchBox; | ||
67 | QCheckBox *mMultipleViewsAtOnce; | 69 | QCheckBox *mMultipleViewsAtOnce; |
68 | QCheckBox *mAskForQuit; | 70 | QCheckBox *mAskForQuit; |
69 | QCheckBox *mMenuBarBox; | 71 | QCheckBox *mMenuBarBox; |
70 | QPushButton *mConfigureButton; | 72 | QPushButton *mConfigureButton; |
71 | 73 | ||
72 | AddresseeWidget *mAddresseeWidget; | 74 | AddresseeWidget *mAddresseeWidget; |
73 | }; | 75 | }; |
74 | 76 | ||
75 | #endif | 77 | #endif |