-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.cpp | 9 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.h | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp index b5309c0..31ab7b5 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp +++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp | |||
@@ -66,177 +66,184 @@ class ExtensionItem : public QCheckListItem | |||
66 | ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); | 66 | ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); |
67 | void setFactory( ExtensionFactory* fac ); | 67 | void setFactory( ExtensionFactory* fac ); |
68 | #endif //KAB_EMBEDDED | 68 | #endif //KAB_EMBEDDED |
69 | 69 | ||
70 | bool configWidgetAvailable() const; | 70 | bool configWidgetAvailable() const; |
71 | ExtensionFactory *factory() const; | 71 | ExtensionFactory *factory() const; |
72 | 72 | ||
73 | virtual QString text( int column ) const; | 73 | virtual QString text( int column ) const; |
74 | 74 | ||
75 | private: | 75 | private: |
76 | #ifndef KAB_EMBEDDED | 76 | #ifndef KAB_EMBEDDED |
77 | KService::Ptr mPtr; | 77 | KService::Ptr mPtr; |
78 | #else //KAB_EMBEDDED | 78 | #else //KAB_EMBEDDED |
79 | ExtensionFactory* mFactory; | 79 | ExtensionFactory* mFactory; |
80 | QString mName; | 80 | QString mName; |
81 | QString mComment; | 81 | QString mComment; |
82 | 82 | ||
83 | #endif //KAB_EMBEDDED | 83 | #endif //KAB_EMBEDDED |
84 | 84 | ||
85 | }; | 85 | }; |
86 | 86 | ||
87 | KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) | 87 | KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) |
88 | : QWidget( parent, name ) | 88 | : QWidget( parent, name ) |
89 | { | 89 | { |
90 | QVBoxLayout *topLayout = new QVBoxLayout( this, 0, | 90 | QVBoxLayout *topLayout = new QVBoxLayout( this, 0, |
91 | KDialog::spacingHint() ); | 91 | KDialog::spacingHint() ); |
92 | 92 | ||
93 | QTabWidget *tabWidget = new QTabWidget( this ); | 93 | QTabWidget *tabWidget = new QTabWidget( this ); |
94 | topLayout->addWidget( tabWidget ); | 94 | topLayout->addWidget( tabWidget ); |
95 | 95 | ||
96 | // General page | 96 | // General page |
97 | QWidget *generalPage = new QWidget( this ); | 97 | QWidget *generalPage = new QWidget( this ); |
98 | QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), | 98 | QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), |
99 | KDialog::spacingHintSmall() ); | 99 | KDialog::spacingHintSmall() ); |
100 | //general groupbox | 100 | //general groupbox |
101 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage ); | 101 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage ); |
102 | QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() ); | 102 | QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() ); |
103 | boxLayout->setAlignment( Qt::AlignTop ); | 103 | boxLayout->setAlignment( Qt::AlignTop ); |
104 | boxLayout->setMargin(KDialog::marginHintSmall() ); | 104 | boxLayout->setMargin(KDialog::marginHintSmall() ); |
105 | groupBox->layout()->setMargin(KDialog::marginHintSmall()) ; | 105 | groupBox->layout()->setMargin(KDialog::marginHintSmall()) ; |
106 | groupBox->layout()->setSpacing(KDialog::spacingHintSmall()); | 106 | groupBox->layout()->setSpacing(KDialog::spacingHintSmall()); |
107 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); | 107 | boxLayout->setSpacing( KDialog::spacingHintSmall() ); |
108 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" ); | 108 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" ); |
109 | boxLayout->addWidget( mViewsSingleClickBox ); | 109 | boxLayout->addWidget( mViewsSingleClickBox ); |
110 | 110 | ||
111 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" ); | 111 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" ); |
112 | boxLayout->addWidget( mNameParsing ); | 112 | boxLayout->addWidget( mNameParsing ); |
113 | 113 | ||
114 | mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), groupBox, "mdisplay" ); | ||
115 | boxLayout->addWidget( mMultipleViewsAtOnce ); | ||
116 | |||
114 | layout->addWidget( groupBox ); | 117 | layout->addWidget( groupBox ); |
115 | 118 | ||
116 | 119 | ||
117 | //extensions groupbox | 120 | //extensions groupbox |
118 | 121 | ||
119 | groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions" ), generalPage ); | 122 | groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), generalPage ); |
120 | boxLayout = new QVBoxLayout( groupBox->layout() ); | 123 | boxLayout = new QVBoxLayout( groupBox->layout() ); |
121 | boxLayout->setAlignment( Qt::AlignTop ); | 124 | boxLayout->setAlignment( Qt::AlignTop ); |
122 | boxLayout->setMargin(KDialog::marginHintSmall()); | 125 | boxLayout->setMargin(KDialog::marginHintSmall()); |
123 | boxLayout->setSpacing(KDialog::spacingHintSmall()); | 126 | boxLayout->setSpacing(KDialog::spacingHintSmall()); |
124 | groupBox->layout()->setMargin(1) ; | 127 | groupBox->layout()->setMargin(1) ; |
125 | groupBox->layout()->setSpacing(0); | 128 | groupBox->layout()->setSpacing(0); |
126 | mExtensionView = new KListView( groupBox ); | 129 | mExtensionView = new KListView( groupBox ); |
127 | mExtensionView->setAllColumnsShowFocus( true ); | 130 | mExtensionView->setAllColumnsShowFocus( true ); |
128 | mExtensionView->addColumn( i18n( "Name" ) ); | 131 | mExtensionView->addColumn( i18n( "Name" ) ); |
129 | mExtensionView->addColumn( i18n( "Description" ) ); | 132 | mExtensionView->addColumn( i18n( "Description" ) ); |
130 | mExtensionView->setMaximumHeight(80); | 133 | mExtensionView->setMaximumHeight(80); |
131 | 134 | ||
132 | boxLayout->addWidget( mExtensionView ); | 135 | boxLayout->addWidget( mExtensionView ); |
133 | 136 | ||
134 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); | 137 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); |
135 | mConfigureButton->setEnabled( false ); | 138 | mConfigureButton->setEnabled( false ); |
136 | boxLayout->addWidget( mConfigureButton ); | 139 | boxLayout->addWidget( mConfigureButton ); |
137 | 140 | ||
138 | layout->addWidget( groupBox ); | 141 | layout->addWidget( groupBox ); |
139 | 142 | ||
140 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 143 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
141 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | 144 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); |
145 | connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | ||
142 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), | 146 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), |
143 | SLOT( selectionChanged( QListViewItem* ) ) ); | 147 | SLOT( selectionChanged( QListViewItem* ) ) ); |
144 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), | 148 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), |
145 | SLOT( itemClicked( QListViewItem* ) ) ); | 149 | SLOT( itemClicked( QListViewItem* ) ) ); |
146 | connect( mConfigureButton, SIGNAL( clicked() ), | 150 | connect( mConfigureButton, SIGNAL( clicked() ), |
147 | SLOT( configureExtension() ) ); | 151 | SLOT( configureExtension() ) ); |
148 | 152 | ||
149 | tabWidget->addTab( generalPage, i18n( "General" ) ); | 153 | tabWidget->addTab( generalPage, i18n( "General" ) ); |
150 | 154 | ||
151 | // Addressee page | 155 | // Addressee page |
152 | mAddresseeWidget = new AddresseeWidget( this ); | 156 | mAddresseeWidget = new AddresseeWidget( this ); |
153 | tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); | 157 | tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); |
154 | connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); | 158 | connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); |
155 | 159 | ||
156 | } | 160 | } |
157 | 161 | ||
158 | 162 | ||
159 | void KABConfigWidget::restoreSettings(KABPrefs* prefs) | 163 | void KABConfigWidget::restoreSettings(KABPrefs* prefs) |
160 | { | 164 | { |
161 | //US prefs was KABPrefs::instance() before | 165 | //US prefs was KABPrefs::instance() before |
162 | 166 | ||
163 | bool blocked = signalsBlocked(); | 167 | bool blocked = signalsBlocked(); |
164 | blockSignals( true ); | 168 | blockSignals( true ); |
165 | 169 | ||
166 | mNameParsing->setChecked( prefs->mAutomaticNameParsing ); | 170 | mNameParsing->setChecked( prefs->mAutomaticNameParsing ); |
167 | mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); | 171 | mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); |
172 | mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); | ||
168 | 173 | ||
169 | mAddresseeWidget->restoreSettings(); | 174 | mAddresseeWidget->restoreSettings(); |
170 | 175 | ||
171 | restoreExtensionSettings(); | 176 | restoreExtensionSettings(); |
172 | 177 | ||
173 | blockSignals( blocked ); | 178 | blockSignals( blocked ); |
174 | 179 | ||
175 | emit changed( false ); | 180 | emit changed( false ); |
176 | } | 181 | } |
177 | 182 | ||
178 | void KABConfigWidget::saveSettings(KABPrefs* prefs) | 183 | void KABConfigWidget::saveSettings(KABPrefs* prefs) |
179 | { | 184 | { |
180 | prefs->mAutomaticNameParsing = mNameParsing->isChecked(); | 185 | prefs->mAutomaticNameParsing = mNameParsing->isChecked(); |
181 | prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); | 186 | prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); |
187 | prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); | ||
182 | 188 | ||
183 | mAddresseeWidget->saveSettings(); | 189 | mAddresseeWidget->saveSettings(); |
184 | 190 | ||
185 | saveExtensionSettings(); | 191 | saveExtensionSettings(); |
186 | KABPrefs::instance()->writeConfig(); | 192 | KABPrefs::instance()->writeConfig(); |
187 | 193 | ||
188 | emit changed( false ); | 194 | emit changed( false ); |
189 | } | 195 | } |
190 | 196 | ||
191 | void KABConfigWidget::defaults(KABPrefs* prefs) | 197 | void KABConfigWidget::defaults(KABPrefs* prefs) |
192 | { | 198 | { |
193 | mNameParsing->setChecked( true ); | 199 | mNameParsing->setChecked( true ); |
194 | mViewsSingleClickBox->setChecked( false ); | 200 | mViewsSingleClickBox->setChecked( false ); |
201 | mMultipleViewsAtOnce->setChecked( true ); | ||
195 | 202 | ||
196 | emit changed( true ); | 203 | emit changed( true ); |
197 | } | 204 | } |
198 | 205 | ||
199 | void KABConfigWidget::modified() | 206 | void KABConfigWidget::modified() |
200 | { | 207 | { |
201 | emit changed( true ); | 208 | emit changed( true ); |
202 | } | 209 | } |
203 | 210 | ||
204 | void KABConfigWidget::restoreExtensionSettings() | 211 | void KABConfigWidget::restoreExtensionSettings() |
205 | { | 212 | { |
206 | QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; | 213 | QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; |
207 | 214 | ||
208 | mExtensionView->clear(); | 215 | mExtensionView->clear(); |
209 | 216 | ||
210 | #ifndef KAB_EMBEDDED | 217 | #ifndef KAB_EMBEDDED |
211 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); | 218 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); |
212 | KTrader::OfferList::ConstIterator it; | 219 | KTrader::OfferList::ConstIterator it; |
213 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 220 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
214 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) | 221 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) |
215 | continue; | 222 | continue; |
216 | 223 | ||
217 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); | 224 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); |
218 | item->setService( *it ); | 225 | item->setService( *it ); |
219 | if ( activeExtensions.contains( item->factory()->identifier() ) ) | 226 | if ( activeExtensions.contains( item->factory()->identifier() ) ) |
220 | item->setOn( true ); | 227 | item->setOn( true ); |
221 | } | 228 | } |
222 | #else //KAB_EMBEDDED | 229 | #else //KAB_EMBEDDED |
223 | ExtensionFactory *extensionFactory = new MergeFactory(); | 230 | ExtensionFactory *extensionFactory = new MergeFactory(); |
224 | 231 | ||
225 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); | 232 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); |
226 | 233 | ||
227 | item->setFactory( extensionFactory ); | 234 | item->setFactory( extensionFactory ); |
228 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 235 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
229 | item->setOn( true ); | 236 | item->setOn( true ); |
230 | 237 | ||
231 | 238 | ||
232 | 239 | ||
233 | extensionFactory = new DistributionListFactory(); | 240 | extensionFactory = new DistributionListFactory(); |
234 | 241 | ||
235 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); | 242 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); |
236 | 243 | ||
237 | item->setFactory( extensionFactory ); | 244 | item->setFactory( extensionFactory ); |
238 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | 245 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) |
239 | item->setOn( true ); | 246 | item->setOn( true ); |
240 | 247 | ||
241 | 248 | ||
242 | #endif //KAB_EMBEDDED | 249 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h index 8c0c436..2928495 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.h +++ b/kaddressbook/kcmconfigs/kabconfigwidget.h | |||
@@ -23,54 +23,56 @@ | |||
23 | 23 | ||
24 | #ifndef KABCONFIGWIDGET_H | 24 | #ifndef KABCONFIGWIDGET_H |
25 | #define KABCONFIGWIDGET_H | 25 | #define KABCONFIGWIDGET_H |
26 | 26 | ||
27 | #include <qwidget.h> | 27 | #include <qwidget.h> |
28 | 28 | ||
29 | class QCheckBox; | 29 | class QCheckBox; |
30 | class QListViewItem; | 30 | class QListViewItem; |
31 | class QPushButton; | 31 | class QPushButton; |
32 | class QComboBox; | 32 | class QComboBox; |
33 | class QLineEdit; | 33 | class QLineEdit; |
34 | class KListView; | 34 | class KListView; |
35 | class KABPrefs; | 35 | class KABPrefs; |
36 | 36 | ||
37 | class AddresseeWidget; | 37 | class AddresseeWidget; |
38 | 38 | ||
39 | class KABConfigWidget : public QWidget | 39 | class KABConfigWidget : public QWidget |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
44 | KABConfigWidget( QWidget *parent, const char *name = 0 ); | 44 | KABConfigWidget( QWidget *parent, const char *name = 0 ); |
45 | 45 | ||
46 | void restoreSettings(KABPrefs* prefs); | 46 | void restoreSettings(KABPrefs* prefs); |
47 | void saveSettings(KABPrefs* prefs); | 47 | void saveSettings(KABPrefs* prefs); |
48 | void defaults(KABPrefs* prefs); | 48 | void defaults(KABPrefs* prefs); |
49 | 49 | ||
50 | signals: | 50 | signals: |
51 | void changed( bool ); | 51 | void changed( bool ); |
52 | 52 | ||
53 | public slots: | 53 | public slots: |
54 | void modified(); | 54 | void modified(); |
55 | 55 | ||
56 | 56 | ||
57 | 57 | ||
58 | private slots: | 58 | private slots: |
59 | void configureExtension(); | 59 | void configureExtension(); |
60 | void selectionChanged( QListViewItem* ); | 60 | void selectionChanged( QListViewItem* ); |
61 | void itemClicked( QListViewItem* ); | 61 | void itemClicked( QListViewItem* ); |
62 | 62 | ||
63 | private: | 63 | private: |
64 | void restoreExtensionSettings(); | 64 | void restoreExtensionSettings(); |
65 | void saveExtensionSettings(); | 65 | void saveExtensionSettings(); |
66 | 66 | ||
67 | KListView *mExtensionView; | 67 | KListView *mExtensionView; |
68 | 68 | ||
69 | QCheckBox *mNameParsing; | 69 | QCheckBox *mNameParsing; |
70 | QCheckBox *mViewsSingleClickBox; | 70 | QCheckBox *mViewsSingleClickBox; |
71 | QCheckBox *mMultipleViewsAtOnce; | ||
72 | |||
71 | QPushButton *mConfigureButton; | 73 | QPushButton *mConfigureButton; |
72 | 74 | ||
73 | AddresseeWidget *mAddresseeWidget; | 75 | AddresseeWidget *mAddresseeWidget; |
74 | }; | 76 | }; |
75 | 77 | ||
76 | #endif | 78 | #endif |