author | zautrix <zautrix> | 2005-02-03 02:19:50 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-03 02:19:50 (UTC) |
commit | e0fce8c0f108e054cb6e4e4767affd04b398da45 (patch) (unidiff) | |
tree | 17414f89b5042809bab5b738dfcc37b4375b3b6d | |
parent | 7e3c508b7ee613c534c2bf0cacf38f96efaef613 (diff) | |
download | kdepimpi-e0fce8c0f108e054cb6e4e4767affd04b398da45.zip kdepimpi-e0fce8c0f108e054cb6e4e4767affd04b398da45.tar.gz kdepimpi-e0fce8c0f108e054cb6e4e4767affd04b398da45.tar.bz2 |
fixxx
-rw-r--r-- | libkdepim/kpimprefs.cpp | 6 | ||||
-rw-r--r-- | microkde/kdecore/kprefs.cpp | 1 |
2 files changed, 3 insertions, 4 deletions
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp index a05e65f..d68ccb6 100644 --- a/libkdepim/kpimprefs.cpp +++ b/libkdepim/kpimprefs.cpp | |||
@@ -1,84 +1,82 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@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 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | 35 | ||
36 | #include "kpimprefs.h" | 36 | #include "kpimprefs.h" |
37 | 37 | ||
38 | KPimPrefs::KPimPrefs( const QString &name ) : | 38 | KPimPrefs::KPimPrefs( const QString &name ) : |
39 | KPrefs( name ) | 39 | KPrefs( name ) |
40 | { | 40 | { |
41 | #ifdef _WIN32_ | 41 | #ifdef _WIN32_ |
42 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 42 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
43 | #else | 43 | #else |
44 | QString hdp= locateLocal("data","korganizer")+"/"; | 44 | QString hdp= locateLocal("data","korganizer")+"/"; |
45 | #endif | 45 | #endif |
46 | config()->setGroup("SyncOptions"); | 46 | setCurrentGroup("SyncOptions"); |
47 | addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); | 47 | addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); |
48 | addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); | 48 | addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); |
49 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); | 49 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); |
50 | addItemBool("PassiveSyncWithDesktop",&mPassiveSyncWithDesktop,false ); | 50 | addItemBool("PassiveSyncWithDesktop",&mPassiveSyncWithDesktop,false ); |
51 | addItemBool("PassiveSyncAutoStart",&mPassiveSyncAutoStart,false ); | 51 | addItemBool("PassiveSyncAutoStart",&mPassiveSyncAutoStart,false ); |
52 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); | 52 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); |
53 | } | 53 | } |
54 | 54 | ||
55 | KPimPrefs::~KPimPrefs() | 55 | KPimPrefs::~KPimPrefs() |
56 | { | 56 | { |
57 | } | 57 | } |
58 | 58 | ||
59 | void KPimPrefs::usrSetDefaults() | 59 | void KPimPrefs::usrSetDefaults() |
60 | { | 60 | { |
61 | setCategoryDefaults(); | 61 | setCategoryDefaults(); |
62 | } | 62 | } |
63 | 63 | ||
64 | void KPimPrefs::usrReadConfig() | 64 | void KPimPrefs::usrReadConfig() |
65 | { | 65 | { |
66 | kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl; | 66 | config()->setGroup("General"); |
67 | |||
68 | config()->setGroup("General"); | ||
69 | mCustomCategories = config()->readListEntry("Custom Categories"); | 67 | mCustomCategories = config()->readListEntry("Custom Categories"); |
70 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 68 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
71 | } | 69 | } |
72 | 70 | ||
73 | 71 | ||
74 | void KPimPrefs::usrWriteConfig() | 72 | void KPimPrefs::usrWriteConfig() |
75 | { | 73 | { |
76 | config()->setGroup("General"); | 74 | config()->setGroup("General"); |
77 | config()->writeEntry("Custom Categories",mCustomCategories); | 75 | config()->writeEntry("Custom Categories",mCustomCategories); |
78 | } | 76 | } |
79 | 77 | ||
80 | void KPimPrefs::setCategoryDefaults() | 78 | void KPimPrefs::setCategoryDefaults() |
81 | { | 79 | { |
82 | // empty implementation | 80 | // empty implementation |
83 | } | 81 | } |
84 | 82 | ||
diff --git a/microkde/kdecore/kprefs.cpp b/microkde/kdecore/kprefs.cpp index 71050e7..0220a34 100644 --- a/microkde/kdecore/kprefs.cpp +++ b/microkde/kdecore/kprefs.cpp | |||
@@ -144,368 +144,369 @@ class KPrefsItemIntList : public KPrefsItem { | |||
144 | const QValueList<int> &defaultValue=QValueList<int>()); | 144 | const QValueList<int> &defaultValue=QValueList<int>()); |
145 | virtual ~KPrefsItemIntList() {} | 145 | virtual ~KPrefsItemIntList() {} |
146 | 146 | ||
147 | void setDefault(); | 147 | void setDefault(); |
148 | void readConfig(KConfig *); | 148 | void readConfig(KConfig *); |
149 | void writeConfig(KConfig *); | 149 | void writeConfig(KConfig *); |
150 | 150 | ||
151 | private: | 151 | private: |
152 | QValueList<int> *mReference; | 152 | QValueList<int> *mReference; |
153 | QValueList<int> mDefault; | 153 | QValueList<int> mDefault; |
154 | }; | 154 | }; |
155 | 155 | ||
156 | 156 | ||
157 | KPrefsItemBool::KPrefsItemBool(const QString &group,const QString &name, | 157 | KPrefsItemBool::KPrefsItemBool(const QString &group,const QString &name, |
158 | bool *reference,bool defaultValue) : | 158 | bool *reference,bool defaultValue) : |
159 | KPrefsItem(group,name) | 159 | KPrefsItem(group,name) |
160 | { | 160 | { |
161 | mReference = reference; | 161 | mReference = reference; |
162 | mDefault = defaultValue; | 162 | mDefault = defaultValue; |
163 | } | 163 | } |
164 | 164 | ||
165 | void KPrefsItemBool::setDefault() | 165 | void KPrefsItemBool::setDefault() |
166 | { | 166 | { |
167 | *mReference = mDefault; | 167 | *mReference = mDefault; |
168 | } | 168 | } |
169 | 169 | ||
170 | void KPrefsItemBool::writeConfig(KConfig *config) | 170 | void KPrefsItemBool::writeConfig(KConfig *config) |
171 | { | 171 | { |
172 | config->setGroup(mGroup); | 172 | config->setGroup(mGroup); |
173 | config->writeEntry(mName,*mReference); | 173 | config->writeEntry(mName,*mReference); |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
177 | void KPrefsItemBool::readConfig(KConfig *config) | 177 | void KPrefsItemBool::readConfig(KConfig *config) |
178 | { | 178 | { |
179 | config->setGroup(mGroup); | 179 | config->setGroup(mGroup); |
180 | *mReference = config->readBoolEntry(mName,mDefault); | 180 | *mReference = config->readBoolEntry(mName,mDefault); |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | KPrefsItemInt::KPrefsItemInt(const QString &group,const QString &name, | 184 | KPrefsItemInt::KPrefsItemInt(const QString &group,const QString &name, |
185 | int *reference,int defaultValue) : | 185 | int *reference,int defaultValue) : |
186 | KPrefsItem(group,name) | 186 | KPrefsItem(group,name) |
187 | { | 187 | { |
188 | mReference = reference; | 188 | mReference = reference; |
189 | mDefault = defaultValue; | 189 | mDefault = defaultValue; |
190 | } | 190 | } |
191 | 191 | ||
192 | void KPrefsItemInt::setDefault() | 192 | void KPrefsItemInt::setDefault() |
193 | { | 193 | { |
194 | *mReference = mDefault; | 194 | *mReference = mDefault; |
195 | } | 195 | } |
196 | 196 | ||
197 | void KPrefsItemInt::writeConfig(KConfig *config) | 197 | void KPrefsItemInt::writeConfig(KConfig *config) |
198 | { | 198 | { |
199 | config->setGroup(mGroup); | 199 | config->setGroup(mGroup); |
200 | config->writeEntry(mName,*mReference); | 200 | config->writeEntry(mName,*mReference); |
201 | } | 201 | } |
202 | 202 | ||
203 | void KPrefsItemInt::readConfig(KConfig *config) | 203 | void KPrefsItemInt::readConfig(KConfig *config) |
204 | { | 204 | { |
205 | config->setGroup(mGroup); | 205 | config->setGroup(mGroup); |
206 | *mReference = config->readNumEntry(mName,mDefault); | 206 | *mReference = config->readNumEntry(mName,mDefault); |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | KPrefsItemColor::KPrefsItemColor(const QString &group,const QString &name, | 210 | KPrefsItemColor::KPrefsItemColor(const QString &group,const QString &name, |
211 | QColor *reference,const QColor &defaultValue) : | 211 | QColor *reference,const QColor &defaultValue) : |
212 | KPrefsItem(group,name) | 212 | KPrefsItem(group,name) |
213 | { | 213 | { |
214 | mReference = reference; | 214 | mReference = reference; |
215 | mDefault = defaultValue; | 215 | mDefault = defaultValue; |
216 | } | 216 | } |
217 | 217 | ||
218 | void KPrefsItemColor::setDefault() | 218 | void KPrefsItemColor::setDefault() |
219 | { | 219 | { |
220 | *mReference = mDefault; | 220 | *mReference = mDefault; |
221 | } | 221 | } |
222 | 222 | ||
223 | void KPrefsItemColor::writeConfig(KConfig *config) | 223 | void KPrefsItemColor::writeConfig(KConfig *config) |
224 | { | 224 | { |
225 | config->setGroup(mGroup); | 225 | config->setGroup(mGroup); |
226 | config->writeEntry(mName,*mReference); | 226 | config->writeEntry(mName,*mReference); |
227 | } | 227 | } |
228 | 228 | ||
229 | void KPrefsItemColor::readConfig(KConfig *config) | 229 | void KPrefsItemColor::readConfig(KConfig *config) |
230 | { | 230 | { |
231 | config->setGroup(mGroup); | 231 | config->setGroup(mGroup); |
232 | *mReference = config->readColorEntry(mName,&mDefault); | 232 | *mReference = config->readColorEntry(mName,&mDefault); |
233 | 233 | ||
234 | } | 234 | } |
235 | 235 | ||
236 | 236 | ||
237 | KPrefsItemSize::KPrefsItemSize(const QString &group,const QString &name, | 237 | KPrefsItemSize::KPrefsItemSize(const QString &group,const QString &name, |
238 | QSize *reference,const QSize &defaultValue) : | 238 | QSize *reference,const QSize &defaultValue) : |
239 | KPrefsItem(group,name) | 239 | KPrefsItem(group,name) |
240 | { | 240 | { |
241 | mReference = reference; | 241 | mReference = reference; |
242 | mDefault = defaultValue; | 242 | mDefault = defaultValue; |
243 | } | 243 | } |
244 | 244 | ||
245 | void KPrefsItemSize::setDefault() | 245 | void KPrefsItemSize::setDefault() |
246 | { | 246 | { |
247 | *mReference = mDefault; | 247 | *mReference = mDefault; |
248 | } | 248 | } |
249 | 249 | ||
250 | void KPrefsItemSize::writeConfig(KConfig *config) | 250 | void KPrefsItemSize::writeConfig(KConfig *config) |
251 | { | 251 | { |
252 | config->setGroup(mGroup); | 252 | config->setGroup(mGroup); |
253 | config->writeEntry(mName,*mReference); | 253 | config->writeEntry(mName,*mReference); |
254 | } | 254 | } |
255 | 255 | ||
256 | void KPrefsItemSize::readConfig(KConfig *config) | 256 | void KPrefsItemSize::readConfig(KConfig *config) |
257 | { | 257 | { |
258 | config->setGroup(mGroup); | 258 | config->setGroup(mGroup); |
259 | *mReference = config->readSizeEntry(mName,&mDefault); | 259 | *mReference = config->readSizeEntry(mName,&mDefault); |
260 | 260 | ||
261 | } | 261 | } |
262 | 262 | ||
263 | 263 | ||
264 | KPrefsItemFont::KPrefsItemFont(const QString &group,const QString &name, | 264 | KPrefsItemFont::KPrefsItemFont(const QString &group,const QString &name, |
265 | QFont *reference,const QFont &defaultValue) : | 265 | QFont *reference,const QFont &defaultValue) : |
266 | KPrefsItem(group,name) | 266 | KPrefsItem(group,name) |
267 | { | 267 | { |
268 | mReference = reference; | 268 | mReference = reference; |
269 | mDefault = defaultValue; | 269 | mDefault = defaultValue; |
270 | } | 270 | } |
271 | 271 | ||
272 | void KPrefsItemFont::setDefault() | 272 | void KPrefsItemFont::setDefault() |
273 | { | 273 | { |
274 | *mReference = mDefault; | 274 | *mReference = mDefault; |
275 | } | 275 | } |
276 | 276 | ||
277 | void KPrefsItemFont::writeConfig(KConfig *config) | 277 | void KPrefsItemFont::writeConfig(KConfig *config) |
278 | { | 278 | { |
279 | config->setGroup(mGroup); | 279 | config->setGroup(mGroup); |
280 | config->writeEntry(mName,*mReference); | 280 | config->writeEntry(mName,*mReference); |
281 | } | 281 | } |
282 | 282 | ||
283 | void KPrefsItemFont::readConfig(KConfig *config) | 283 | void KPrefsItemFont::readConfig(KConfig *config) |
284 | { | 284 | { |
285 | config->setGroup(mGroup); | 285 | config->setGroup(mGroup); |
286 | *mReference = config->readFontEntry(mName,&mDefault); | 286 | *mReference = config->readFontEntry(mName,&mDefault); |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | QString endecryptStr( const QString &aStr ) | 290 | QString endecryptStr( const QString &aStr ) |
291 | { | 291 | { |
292 | QString result; | 292 | QString result; |
293 | uint i; | 293 | uint i; |
294 | for ( i = 0; i < aStr.length(); i++) | 294 | for ( i = 0; i < aStr.length(); i++) |
295 | result += (aStr.at(i).unicode() < 0x20) ? | 295 | result += (aStr.at(i).unicode() < 0x20) ? |
296 | aStr.at(i) : | 296 | aStr.at(i) : |
297 | QChar(0x1001F - aStr.at(i).unicode()); | 297 | QChar(0x1001F - aStr.at(i).unicode()); |
298 | return result; | 298 | return result; |
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | KPrefsItemString::KPrefsItemString(const QString &group,const QString &name, | 302 | KPrefsItemString::KPrefsItemString(const QString &group,const QString &name, |
303 | QString *reference,const QString &defaultValue, | 303 | QString *reference,const QString &defaultValue, |
304 | bool isPassword) : | 304 | bool isPassword) : |
305 | KPrefsItem(group,name) | 305 | KPrefsItem(group,name) |
306 | { | 306 | { |
307 | mReference = reference; | 307 | mReference = reference; |
308 | mDefault = defaultValue; | 308 | mDefault = defaultValue; |
309 | mPassword = isPassword; | 309 | mPassword = isPassword; |
310 | } | 310 | } |
311 | 311 | ||
312 | void KPrefsItemString::setDefault() | 312 | void KPrefsItemString::setDefault() |
313 | { | 313 | { |
314 | *mReference = mDefault; | 314 | *mReference = mDefault; |
315 | } | 315 | } |
316 | 316 | ||
317 | void KPrefsItemString::writeConfig(KConfig *config) | 317 | void KPrefsItemString::writeConfig(KConfig *config) |
318 | { | 318 | { |
319 | config->setGroup(mGroup); | 319 | config->setGroup(mGroup); |
320 | if ( mPassword ) | 320 | if ( mPassword ) |
321 | config->writeEntry(mName, endecryptStr( *mReference ) ); | 321 | config->writeEntry(mName, endecryptStr( *mReference ) ); |
322 | else | 322 | else |
323 | config->writeEntry(mName,*mReference); | 323 | config->writeEntry(mName,*mReference); |
324 | } | 324 | } |
325 | 325 | ||
326 | void KPrefsItemString::readConfig(KConfig *config) | 326 | void KPrefsItemString::readConfig(KConfig *config) |
327 | { | 327 | { |
328 | config->setGroup(mGroup); | 328 | config->setGroup(mGroup); |
329 | 329 | ||
330 | QString value; | 330 | QString value; |
331 | if ( mPassword ) { | 331 | if ( mPassword ) { |
332 | value = config->readEntry( mName, endecryptStr( mDefault ) ); | 332 | value = config->readEntry( mName, endecryptStr( mDefault ) ); |
333 | *mReference = endecryptStr( value ); | 333 | *mReference = endecryptStr( value ); |
334 | } else { | 334 | } else { |
335 | *mReference = config->readEntry( mName, mDefault ); | 335 | *mReference = config->readEntry( mName, mDefault ); |
336 | } | 336 | } |
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | KPrefsItemStringList::KPrefsItemStringList(const QString &group,const QString &name, | 340 | KPrefsItemStringList::KPrefsItemStringList(const QString &group,const QString &name, |
341 | QStringList *reference,const QStringList &defaultValue) : | 341 | QStringList *reference,const QStringList &defaultValue) : |
342 | KPrefsItem(group,name) | 342 | KPrefsItem(group,name) |
343 | { | 343 | { |
344 | mReference = reference; | 344 | mReference = reference; |
345 | mDefault = defaultValue; | 345 | mDefault = defaultValue; |
346 | } | 346 | } |
347 | 347 | ||
348 | void KPrefsItemStringList::setDefault() | 348 | void KPrefsItemStringList::setDefault() |
349 | { | 349 | { |
350 | *mReference = mDefault; | 350 | *mReference = mDefault; |
351 | } | 351 | } |
352 | 352 | ||
353 | void KPrefsItemStringList::writeConfig(KConfig *config) | 353 | void KPrefsItemStringList::writeConfig(KConfig *config) |
354 | { | 354 | { |
355 | config->setGroup(mGroup); | 355 | config->setGroup(mGroup); |
356 | config->writeEntry(mName,*mReference); | 356 | config->writeEntry(mName,*mReference); |
357 | } | 357 | } |
358 | 358 | ||
359 | void KPrefsItemStringList::readConfig(KConfig *config) | 359 | void KPrefsItemStringList::readConfig(KConfig *config) |
360 | { | 360 | { |
361 | config->setGroup(mGroup); | 361 | config->setGroup(mGroup); |
362 | *mReference = config->readListEntry(mName); | 362 | *mReference = config->readListEntry(mName); |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | KPrefsItemIntList::KPrefsItemIntList(const QString &group,const QString &name, | 366 | KPrefsItemIntList::KPrefsItemIntList(const QString &group,const QString &name, |
367 | QValueList<int> *reference,const QValueList<int> &defaultValue) : | 367 | QValueList<int> *reference,const QValueList<int> &defaultValue) : |
368 | KPrefsItem(group,name) | 368 | KPrefsItem(group,name) |
369 | { | 369 | { |
370 | mReference = reference; | 370 | mReference = reference; |
371 | mDefault = defaultValue; | 371 | mDefault = defaultValue; |
372 | } | 372 | } |
373 | 373 | ||
374 | void KPrefsItemIntList::setDefault() | 374 | void KPrefsItemIntList::setDefault() |
375 | { | 375 | { |
376 | *mReference = mDefault; | 376 | *mReference = mDefault; |
377 | } | 377 | } |
378 | 378 | ||
379 | void KPrefsItemIntList::writeConfig(KConfig *config) | 379 | void KPrefsItemIntList::writeConfig(KConfig *config) |
380 | { | 380 | { |
381 | config->setGroup(mGroup); | 381 | config->setGroup(mGroup); |
382 | config->writeEntry(mName,*mReference); | 382 | config->writeEntry(mName,*mReference); |
383 | } | 383 | } |
384 | 384 | ||
385 | void KPrefsItemIntList::readConfig(KConfig *config) | 385 | void KPrefsItemIntList::readConfig(KConfig *config) |
386 | { | 386 | { |
387 | config->setGroup(mGroup); | 387 | config->setGroup(mGroup); |
388 | *mReference = config->readIntListEntry(mName); | 388 | *mReference = config->readIntListEntry(mName); |
389 | } | 389 | } |
390 | 390 | ||
391 | 391 | ||
392 | QString *KPrefs::mCurrentGroup = 0; | 392 | QString *KPrefs::mCurrentGroup = 0; |
393 | 393 | ||
394 | KPrefs::KPrefs(const QString &configname) | 394 | KPrefs::KPrefs(const QString &configname) |
395 | { | 395 | { |
396 | if (!configname.isEmpty()) { | 396 | if (!configname.isEmpty()) { |
397 | //qDebug("KPrefs::KPrefs %s",configname.latin1() ); | 397 | //qDebug("KPrefs::KPrefs %s",configname.latin1() ); |
398 | mConfig = new KConfig(locateLocal("config",configname)); | 398 | mConfig = new KConfig(locateLocal("config",configname)); |
399 | } else { | 399 | } else { |
400 | qDebug("KPrefs::Global config "); | ||
400 | mConfig = KGlobal::config(); | 401 | mConfig = KGlobal::config(); |
401 | } | 402 | } |
402 | 403 | ||
403 | mItems.setAutoDelete(true); | 404 | mItems.setAutoDelete(true); |
404 | 405 | ||
405 | // Set default group | 406 | // Set default group |
406 | if (mCurrentGroup == 0) mCurrentGroup = new QString("No Group"); | 407 | if (mCurrentGroup == 0) mCurrentGroup = new QString("No Group"); |
407 | } | 408 | } |
408 | 409 | ||
409 | KPrefs::~KPrefs() | 410 | KPrefs::~KPrefs() |
410 | { | 411 | { |
411 | if (mConfig != KGlobal::config()) { | 412 | if (mConfig != KGlobal::config()) { |
412 | delete mConfig; | 413 | delete mConfig; |
413 | } | 414 | } |
414 | } | 415 | } |
415 | 416 | ||
416 | void KPrefs::setCurrentGroup(const QString &group) | 417 | void KPrefs::setCurrentGroup(const QString &group) |
417 | { | 418 | { |
418 | if (mCurrentGroup) delete mCurrentGroup; | 419 | if (mCurrentGroup) delete mCurrentGroup; |
419 | mCurrentGroup = new QString(group); | 420 | mCurrentGroup = new QString(group); |
420 | } | 421 | } |
421 | 422 | ||
422 | KConfig *KPrefs::config() const | 423 | KConfig *KPrefs::config() const |
423 | { | 424 | { |
424 | return mConfig; | 425 | return mConfig; |
425 | } | 426 | } |
426 | 427 | ||
427 | void KPrefs::setDefaults() | 428 | void KPrefs::setDefaults() |
428 | { | 429 | { |
429 | KPrefsItem *item; | 430 | KPrefsItem *item; |
430 | for(item = mItems.first();item;item = mItems.next()) { | 431 | for(item = mItems.first();item;item = mItems.next()) { |
431 | item->setDefault(); | 432 | item->setDefault(); |
432 | } | 433 | } |
433 | 434 | ||
434 | usrSetDefaults(); | 435 | usrSetDefaults(); |
435 | } | 436 | } |
436 | 437 | ||
437 | void KPrefs::readConfig() | 438 | void KPrefs::readConfig() |
438 | { | 439 | { |
439 | KPrefsItem *item; | 440 | KPrefsItem *item; |
440 | for(item = mItems.first();item;item = mItems.next()) { | 441 | for(item = mItems.first();item;item = mItems.next()) { |
441 | item->readConfig(mConfig); | 442 | item->readConfig(mConfig); |
442 | } | 443 | } |
443 | 444 | ||
444 | usrReadConfig(); | 445 | usrReadConfig(); |
445 | //qDebug("KPrefs::readConfig: %s", mConfig->getFileName().latin1()); | 446 | //qDebug("KPrefs::readConfig: %s", mConfig->getFileName().latin1()); |
446 | } | 447 | } |
447 | 448 | ||
448 | void KPrefs::writeConfig() | 449 | void KPrefs::writeConfig() |
449 | { | 450 | { |
450 | KPrefsItem *item; | 451 | KPrefsItem *item; |
451 | for(item = mItems.first();item;item = mItems.next()) { | 452 | for(item = mItems.first();item;item = mItems.next()) { |
452 | item->writeConfig(mConfig); | 453 | item->writeConfig(mConfig); |
453 | } | 454 | } |
454 | 455 | ||
455 | usrWriteConfig(); | 456 | usrWriteConfig(); |
456 | //qDebug("KPrefs::WriteConfig: %s", mConfig->getFileName().latin1()); | 457 | //qDebug("KPrefs::WriteConfig: %s", mConfig->getFileName().latin1()); |
457 | mConfig->sync(); | 458 | mConfig->sync(); |
458 | } | 459 | } |
459 | 460 | ||
460 | 461 | ||
461 | void KPrefs::addItem(KPrefsItem *item) | 462 | void KPrefs::addItem(KPrefsItem *item) |
462 | { | 463 | { |
463 | mItems.append(item); | 464 | mItems.append(item); |
464 | } | 465 | } |
465 | 466 | ||
466 | void KPrefs::addItemBool(const QString &key,bool *reference,bool defaultValue) | 467 | void KPrefs::addItemBool(const QString &key,bool *reference,bool defaultValue) |
467 | { | 468 | { |
468 | addItem(new KPrefsItemBool(*mCurrentGroup,key,reference,defaultValue)); | 469 | addItem(new KPrefsItemBool(*mCurrentGroup,key,reference,defaultValue)); |
469 | } | 470 | } |
470 | 471 | ||
471 | void KPrefs::addItemInt(const QString &key,int *reference,int defaultValue) | 472 | void KPrefs::addItemInt(const QString &key,int *reference,int defaultValue) |
472 | { | 473 | { |
473 | addItem(new KPrefsItemInt(*mCurrentGroup,key,reference,defaultValue)); | 474 | addItem(new KPrefsItemInt(*mCurrentGroup,key,reference,defaultValue)); |
474 | } | 475 | } |
475 | 476 | ||
476 | void KPrefs::addItemColor(const QString &key,QColor *reference,const QColor &defaultValue) | 477 | void KPrefs::addItemColor(const QString &key,QColor *reference,const QColor &defaultValue) |
477 | { | 478 | { |
478 | addItem(new KPrefsItemColor(*mCurrentGroup,key,reference,defaultValue)); | 479 | addItem(new KPrefsItemColor(*mCurrentGroup,key,reference,defaultValue)); |
479 | } | 480 | } |
480 | 481 | ||
481 | void KPrefs::addItemFont(const QString &key,QFont *reference,const QFont &defaultValue) | 482 | void KPrefs::addItemFont(const QString &key,QFont *reference,const QFont &defaultValue) |
482 | { | 483 | { |
483 | addItem(new KPrefsItemFont(*mCurrentGroup,key,reference,defaultValue)); | 484 | addItem(new KPrefsItemFont(*mCurrentGroup,key,reference,defaultValue)); |
484 | } | 485 | } |
485 | 486 | ||
486 | void KPrefs::addItemSize(const QString &key,QSize *reference,const QSize &defaultValue) | 487 | void KPrefs::addItemSize(const QString &key,QSize *reference,const QSize &defaultValue) |
487 | { | 488 | { |
488 | addItem(new KPrefsItemSize(*mCurrentGroup,key,reference,defaultValue)); | 489 | addItem(new KPrefsItemSize(*mCurrentGroup,key,reference,defaultValue)); |
489 | } | 490 | } |
490 | 491 | ||
491 | void KPrefs::addItemString(const QString &key,QString *reference,const QString &defaultValue) | 492 | void KPrefs::addItemString(const QString &key,QString *reference,const QString &defaultValue) |
492 | { | 493 | { |
493 | addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,false)); | 494 | addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,false)); |
494 | } | 495 | } |
495 | 496 | ||
496 | void KPrefs::addItemPassword(const QString &key,QString *reference,const QString &defaultValue) | 497 | void KPrefs::addItemPassword(const QString &key,QString *reference,const QString &defaultValue) |
497 | { | 498 | { |
498 | addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,true)); | 499 | addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,true)); |
499 | } | 500 | } |
500 | 501 | ||
501 | void KPrefs::addItemStringList(const QString &key,QStringList *reference, | 502 | void KPrefs::addItemStringList(const QString &key,QStringList *reference, |
502 | const QStringList &defaultValue) | 503 | const QStringList &defaultValue) |
503 | { | 504 | { |
504 | addItem(new KPrefsItemStringList(*mCurrentGroup,key,reference,defaultValue)); | 505 | addItem(new KPrefsItemStringList(*mCurrentGroup,key,reference,defaultValue)); |
505 | } | 506 | } |
506 | 507 | ||
507 | void KPrefs::addItemIntList(const QString &key,QValueList<int> *reference, | 508 | void KPrefs::addItemIntList(const QString &key,QValueList<int> *reference, |
508 | const QValueList<int> &defaultValue) | 509 | const QValueList<int> &defaultValue) |
509 | { | 510 | { |
510 | addItem(new KPrefsItemIntList(*mCurrentGroup,key,reference,defaultValue)); | 511 | addItem(new KPrefsItemIntList(*mCurrentGroup,key,reference,defaultValue)); |
511 | } | 512 | } |