-rw-r--r-- | microkde/kdecore/kprefs.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/microkde/kdecore/kprefs.cpp b/microkde/kdecore/kprefs.cpp index 0220a34..d4010fa 100644 --- a/microkde/kdecore/kprefs.cpp +++ b/microkde/kdecore/kprefs.cpp | |||
@@ -1,55 +1,57 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include <qcolor.h> | 23 | #include <qcolor.h> |
24 | //Added by qt3to4: | ||
25 | #include <Q3ValueList> | ||
24 | 26 | ||
25 | #include <kconfig.h> | 27 | #include <kconfig.h> |
26 | #include <kstandarddirs.h> | 28 | #include <kstandarddirs.h> |
27 | #include <kglobal.h> | 29 | #include <kglobal.h> |
28 | #include <kdebug.h> | 30 | #include <kdebug.h> |
29 | 31 | ||
30 | #include "kprefs.h" | 32 | #include "kprefs.h" |
31 | 33 | ||
32 | class KPrefsItemBool : public KPrefsItem { | 34 | class KPrefsItemBool : public KPrefsItem { |
33 | public: | 35 | public: |
34 | KPrefsItemBool(const QString &group,const QString &name,bool *,bool defaultValue=true); | 36 | KPrefsItemBool(const QString &group,const QString &name,bool *,bool defaultValue=true); |
35 | virtual ~KPrefsItemBool() {} | 37 | virtual ~KPrefsItemBool() {} |
36 | 38 | ||
37 | void setDefault(); | 39 | void setDefault(); |
38 | void readConfig(KConfig *); | 40 | void readConfig(KConfig *); |
39 | void writeConfig(KConfig *); | 41 | void writeConfig(KConfig *); |
40 | 42 | ||
41 | private: | 43 | private: |
42 | bool *mReference; | 44 | bool *mReference; |
43 | bool mDefault; | 45 | bool mDefault; |
44 | }; | 46 | }; |
45 | 47 | ||
46 | class KPrefsItemInt : public KPrefsItem { | 48 | class KPrefsItemInt : public KPrefsItem { |
47 | public: | 49 | public: |
48 | KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0); | 50 | KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0); |
49 | virtual ~KPrefsItemInt() {} | 51 | virtual ~KPrefsItemInt() {} |
50 | 52 | ||
51 | void setDefault(); | 53 | void setDefault(); |
52 | void readConfig(KConfig *); | 54 | void readConfig(KConfig *); |
53 | void writeConfig(KConfig *); | 55 | void writeConfig(KConfig *); |
54 | 56 | ||
55 | private: | 57 | private: |
@@ -111,75 +113,75 @@ class KPrefsItemString : public KPrefsItem { | |||
111 | const QString &defaultValue="", bool isPassword=false); | 113 | const QString &defaultValue="", bool isPassword=false); |
112 | virtual ~KPrefsItemString() {} | 114 | virtual ~KPrefsItemString() {} |
113 | 115 | ||
114 | void setDefault(); | 116 | void setDefault(); |
115 | void readConfig(KConfig *); | 117 | void readConfig(KConfig *); |
116 | void writeConfig(KConfig *); | 118 | void writeConfig(KConfig *); |
117 | 119 | ||
118 | private: | 120 | private: |
119 | QString *mReference; | 121 | QString *mReference; |
120 | QString mDefault; | 122 | QString mDefault; |
121 | bool mPassword; | 123 | bool mPassword; |
122 | }; | 124 | }; |
123 | 125 | ||
124 | 126 | ||
125 | class KPrefsItemStringList : public KPrefsItem { | 127 | class KPrefsItemStringList : public KPrefsItem { |
126 | public: | 128 | public: |
127 | KPrefsItemStringList(const QString &group,const QString &name,QStringList *, | 129 | KPrefsItemStringList(const QString &group,const QString &name,QStringList *, |
128 | const QStringList &defaultValue=QStringList()); | 130 | const QStringList &defaultValue=QStringList()); |
129 | virtual ~KPrefsItemStringList() {} | 131 | virtual ~KPrefsItemStringList() {} |
130 | 132 | ||
131 | void setDefault(); | 133 | void setDefault(); |
132 | void readConfig(KConfig *); | 134 | void readConfig(KConfig *); |
133 | void writeConfig(KConfig *); | 135 | void writeConfig(KConfig *); |
134 | 136 | ||
135 | private: | 137 | private: |
136 | QStringList *mReference; | 138 | QStringList *mReference; |
137 | QStringList mDefault; | 139 | QStringList mDefault; |
138 | }; | 140 | }; |
139 | 141 | ||
140 | 142 | ||
141 | class KPrefsItemIntList : public KPrefsItem { | 143 | class KPrefsItemIntList : public KPrefsItem { |
142 | public: | 144 | public: |
143 | KPrefsItemIntList(const QString &group,const QString &name,QValueList<int> *, | 145 | KPrefsItemIntList(const QString &group,const QString &name,Q3ValueList<int> *, |
144 | const QValueList<int> &defaultValue=QValueList<int>()); | 146 | const Q3ValueList<int> &defaultValue=Q3ValueList<int>()); |
145 | virtual ~KPrefsItemIntList() {} | 147 | virtual ~KPrefsItemIntList() {} |
146 | 148 | ||
147 | void setDefault(); | 149 | void setDefault(); |
148 | void readConfig(KConfig *); | 150 | void readConfig(KConfig *); |
149 | void writeConfig(KConfig *); | 151 | void writeConfig(KConfig *); |
150 | 152 | ||
151 | private: | 153 | private: |
152 | QValueList<int> *mReference; | 154 | Q3ValueList<int> *mReference; |
153 | QValueList<int> mDefault; | 155 | Q3ValueList<int> mDefault; |
154 | }; | 156 | }; |
155 | 157 | ||
156 | 158 | ||
157 | KPrefsItemBool::KPrefsItemBool(const QString &group,const QString &name, | 159 | KPrefsItemBool::KPrefsItemBool(const QString &group,const QString &name, |
158 | bool *reference,bool defaultValue) : | 160 | bool *reference,bool defaultValue) : |
159 | KPrefsItem(group,name) | 161 | KPrefsItem(group,name) |
160 | { | 162 | { |
161 | mReference = reference; | 163 | mReference = reference; |
162 | mDefault = defaultValue; | 164 | mDefault = defaultValue; |
163 | } | 165 | } |
164 | 166 | ||
165 | void KPrefsItemBool::setDefault() | 167 | void KPrefsItemBool::setDefault() |
166 | { | 168 | { |
167 | *mReference = mDefault; | 169 | *mReference = mDefault; |
168 | } | 170 | } |
169 | 171 | ||
170 | void KPrefsItemBool::writeConfig(KConfig *config) | 172 | void KPrefsItemBool::writeConfig(KConfig *config) |
171 | { | 173 | { |
172 | config->setGroup(mGroup); | 174 | config->setGroup(mGroup); |
173 | config->writeEntry(mName,*mReference); | 175 | config->writeEntry(mName,*mReference); |
174 | } | 176 | } |
175 | 177 | ||
176 | 178 | ||
177 | void KPrefsItemBool::readConfig(KConfig *config) | 179 | void KPrefsItemBool::readConfig(KConfig *config) |
178 | { | 180 | { |
179 | config->setGroup(mGroup); | 181 | config->setGroup(mGroup); |
180 | *mReference = config->readBoolEntry(mName,mDefault); | 182 | *mReference = config->readBoolEntry(mName,mDefault); |
181 | } | 183 | } |
182 | 184 | ||
183 | 185 | ||
184 | KPrefsItemInt::KPrefsItemInt(const QString &group,const QString &name, | 186 | KPrefsItemInt::KPrefsItemInt(const QString &group,const QString &name, |
185 | int *reference,int defaultValue) : | 187 | int *reference,int defaultValue) : |
@@ -335,65 +337,65 @@ void KPrefsItemString::readConfig(KConfig *config) | |||
335 | *mReference = config->readEntry( mName, mDefault ); | 337 | *mReference = config->readEntry( mName, mDefault ); |
336 | } | 338 | } |
337 | } | 339 | } |
338 | 340 | ||
339 | 341 | ||
340 | KPrefsItemStringList::KPrefsItemStringList(const QString &group,const QString &name, | 342 | KPrefsItemStringList::KPrefsItemStringList(const QString &group,const QString &name, |
341 | QStringList *reference,const QStringList &defaultValue) : | 343 | QStringList *reference,const QStringList &defaultValue) : |
342 | KPrefsItem(group,name) | 344 | KPrefsItem(group,name) |
343 | { | 345 | { |
344 | mReference = reference; | 346 | mReference = reference; |
345 | mDefault = defaultValue; | 347 | mDefault = defaultValue; |
346 | } | 348 | } |
347 | 349 | ||
348 | void KPrefsItemStringList::setDefault() | 350 | void KPrefsItemStringList::setDefault() |
349 | { | 351 | { |
350 | *mReference = mDefault; | 352 | *mReference = mDefault; |
351 | } | 353 | } |
352 | 354 | ||
353 | void KPrefsItemStringList::writeConfig(KConfig *config) | 355 | void KPrefsItemStringList::writeConfig(KConfig *config) |
354 | { | 356 | { |
355 | config->setGroup(mGroup); | 357 | config->setGroup(mGroup); |
356 | config->writeEntry(mName,*mReference); | 358 | config->writeEntry(mName,*mReference); |
357 | } | 359 | } |
358 | 360 | ||
359 | void KPrefsItemStringList::readConfig(KConfig *config) | 361 | void KPrefsItemStringList::readConfig(KConfig *config) |
360 | { | 362 | { |
361 | config->setGroup(mGroup); | 363 | config->setGroup(mGroup); |
362 | *mReference = config->readListEntry(mName); | 364 | *mReference = config->readListEntry(mName); |
363 | } | 365 | } |
364 | 366 | ||
365 | 367 | ||
366 | KPrefsItemIntList::KPrefsItemIntList(const QString &group,const QString &name, | 368 | KPrefsItemIntList::KPrefsItemIntList(const QString &group,const QString &name, |
367 | QValueList<int> *reference,const QValueList<int> &defaultValue) : | 369 | Q3ValueList<int> *reference,const Q3ValueList<int> &defaultValue) : |
368 | KPrefsItem(group,name) | 370 | KPrefsItem(group,name) |
369 | { | 371 | { |
370 | mReference = reference; | 372 | mReference = reference; |
371 | mDefault = defaultValue; | 373 | mDefault = defaultValue; |
372 | } | 374 | } |
373 | 375 | ||
374 | void KPrefsItemIntList::setDefault() | 376 | void KPrefsItemIntList::setDefault() |
375 | { | 377 | { |
376 | *mReference = mDefault; | 378 | *mReference = mDefault; |
377 | } | 379 | } |
378 | 380 | ||
379 | void KPrefsItemIntList::writeConfig(KConfig *config) | 381 | void KPrefsItemIntList::writeConfig(KConfig *config) |
380 | { | 382 | { |
381 | config->setGroup(mGroup); | 383 | config->setGroup(mGroup); |
382 | config->writeEntry(mName,*mReference); | 384 | config->writeEntry(mName,*mReference); |
383 | } | 385 | } |
384 | 386 | ||
385 | void KPrefsItemIntList::readConfig(KConfig *config) | 387 | void KPrefsItemIntList::readConfig(KConfig *config) |
386 | { | 388 | { |
387 | config->setGroup(mGroup); | 389 | config->setGroup(mGroup); |
388 | *mReference = config->readIntListEntry(mName); | 390 | *mReference = config->readIntListEntry(mName); |
389 | } | 391 | } |
390 | 392 | ||
391 | 393 | ||
392 | QString *KPrefs::mCurrentGroup = 0; | 394 | QString *KPrefs::mCurrentGroup = 0; |
393 | 395 | ||
394 | KPrefs::KPrefs(const QString &configname) | 396 | KPrefs::KPrefs(const QString &configname) |
395 | { | 397 | { |
396 | if (!configname.isEmpty()) { | 398 | if (!configname.isEmpty()) { |
397 | //qDebug("KPrefs::KPrefs %s",configname.latin1() ); | 399 | //qDebug("KPrefs::KPrefs %s",configname.latin1() ); |
398 | mConfig = new KConfig(locateLocal("config",configname)); | 400 | mConfig = new KConfig(locateLocal("config",configname)); |
399 | } else { | 401 | } else { |
@@ -476,37 +478,37 @@ void KPrefs::addItemInt(const QString &key,int *reference,int defaultValue) | |||
476 | 478 | ||
477 | void KPrefs::addItemColor(const QString &key,QColor *reference,const QColor &defaultValue) | 479 | void KPrefs::addItemColor(const QString &key,QColor *reference,const QColor &defaultValue) |
478 | { | 480 | { |
479 | addItem(new KPrefsItemColor(*mCurrentGroup,key,reference,defaultValue)); | 481 | addItem(new KPrefsItemColor(*mCurrentGroup,key,reference,defaultValue)); |
480 | } | 482 | } |
481 | 483 | ||
482 | void KPrefs::addItemFont(const QString &key,QFont *reference,const QFont &defaultValue) | 484 | void KPrefs::addItemFont(const QString &key,QFont *reference,const QFont &defaultValue) |
483 | { | 485 | { |
484 | addItem(new KPrefsItemFont(*mCurrentGroup,key,reference,defaultValue)); | 486 | addItem(new KPrefsItemFont(*mCurrentGroup,key,reference,defaultValue)); |
485 | } | 487 | } |
486 | 488 | ||
487 | void KPrefs::addItemSize(const QString &key,QSize *reference,const QSize &defaultValue) | 489 | void KPrefs::addItemSize(const QString &key,QSize *reference,const QSize &defaultValue) |
488 | { | 490 | { |
489 | addItem(new KPrefsItemSize(*mCurrentGroup,key,reference,defaultValue)); | 491 | addItem(new KPrefsItemSize(*mCurrentGroup,key,reference,defaultValue)); |
490 | } | 492 | } |
491 | 493 | ||
492 | void KPrefs::addItemString(const QString &key,QString *reference,const QString &defaultValue) | 494 | void KPrefs::addItemString(const QString &key,QString *reference,const QString &defaultValue) |
493 | { | 495 | { |
494 | addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,false)); | 496 | addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,false)); |
495 | } | 497 | } |
496 | 498 | ||
497 | void KPrefs::addItemPassword(const QString &key,QString *reference,const QString &defaultValue) | 499 | void KPrefs::addItemPassword(const QString &key,QString *reference,const QString &defaultValue) |
498 | { | 500 | { |
499 | addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,true)); | 501 | addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,true)); |
500 | } | 502 | } |
501 | 503 | ||
502 | void KPrefs::addItemStringList(const QString &key,QStringList *reference, | 504 | void KPrefs::addItemStringList(const QString &key,QStringList *reference, |
503 | const QStringList &defaultValue) | 505 | const QStringList &defaultValue) |
504 | { | 506 | { |
505 | addItem(new KPrefsItemStringList(*mCurrentGroup,key,reference,defaultValue)); | 507 | addItem(new KPrefsItemStringList(*mCurrentGroup,key,reference,defaultValue)); |
506 | } | 508 | } |
507 | 509 | ||
508 | void KPrefs::addItemIntList(const QString &key,QValueList<int> *reference, | 510 | void KPrefs::addItemIntList(const QString &key,Q3ValueList<int> *reference, |
509 | const QValueList<int> &defaultValue) | 511 | const Q3ValueList<int> &defaultValue) |
510 | { | 512 | { |
511 | addItem(new KPrefsItemIntList(*mCurrentGroup,key,reference,defaultValue)); | 513 | addItem(new KPrefsItemIntList(*mCurrentGroup,key,reference,defaultValue)); |
512 | } | 514 | } |