author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdecore/kconfigbase.h | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kdecore/kconfigbase.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdecore/kconfigbase.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/microkde/kdecore/kconfigbase.h b/microkde/kdecore/kconfigbase.h index 7e56d11..1ef6a04 100644 --- a/microkde/kdecore/kconfigbase.h +++ b/microkde/kdecore/kconfigbase.h | |||
@@ -1,102 +1,104 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the KDE libraries | 2 | This file is part of the KDE libraries |
3 | Copyright (c) 1999 Preston Brown <pbrown@kde.org> | 3 | Copyright (c) 1999 Preston Brown <pbrown@kde.org> |
4 | Copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org> | 4 | Copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org> |
5 | Copyright (c) 2001 Waldo Bastian <bastian@kde.org> | 5 | Copyright (c) 2001 Waldo Bastian <bastian@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | // $Id$ | 23 | // $Id$ |
24 | 24 | ||
25 | #ifndef _KCONFIGBASE_H | 25 | #ifndef _KCONFIGBASE_H |
26 | #define _KCONFIGBASE_H | 26 | #define _KCONFIGBASE_H |
27 | 27 | ||
28 | #include "kconfig.h" | 28 | #include "kconfig.h" |
29 | //Added by qt3to4: | ||
30 | #include <Q3CString> | ||
29 | 31 | ||
30 | /** | 32 | /** |
31 | * Helper class to facilitate working with @ref KConfig / @ref KSimpleConfig | 33 | * Helper class to facilitate working with @ref KConfig / @ref KSimpleConfig |
32 | * groups. | 34 | * groups. |
33 | * | 35 | * |
34 | * Careful programmers always set the group of a | 36 | * Careful programmers always set the group of a |
35 | * @ref KConfig @ref KSimpleConfig object to the group they want to read from | 37 | * @ref KConfig @ref KSimpleConfig object to the group they want to read from |
36 | * and set it back to the old one of afterwards. This is usually | 38 | * and set it back to the old one of afterwards. This is usually |
37 | * written as: | 39 | * written as: |
38 | * <pre> | 40 | * <pre> |
39 | * | 41 | * |
40 | * QString oldgroup config->group(); | 42 | * QString oldgroup config->group(); |
41 | * config->setGroup( "TheGroupThatIWant" ); | 43 | * config->setGroup( "TheGroupThatIWant" ); |
42 | * ... | 44 | * ... |
43 | * config->writeEntry( "Blah", "Blubb" ); | 45 | * config->writeEntry( "Blah", "Blubb" ); |
44 | * | 46 | * |
45 | * config->setGroup( oldgroup ); | 47 | * config->setGroup( oldgroup ); |
46 | * </pre> | 48 | * </pre> |
47 | * | 49 | * |
48 | * In order to facilitate this task, you can use | 50 | * In order to facilitate this task, you can use |
49 | * KConfigGroupSaver. Simply construct such an object ON THE STACK | 51 | * KConfigGroupSaver. Simply construct such an object ON THE STACK |
50 | * when you want to switch to a new group. Then, when the object goes | 52 | * when you want to switch to a new group. Then, when the object goes |
51 | * out of scope, the group will automatically be restored. If you | 53 | * out of scope, the group will automatically be restored. If you |
52 | * want to use several different groups within a function or method, | 54 | * want to use several different groups within a function or method, |
53 | * you can still use KConfigGroupSaver: Simply enclose all work with | 55 | * you can still use KConfigGroupSaver: Simply enclose all work with |
54 | * one group (including the creation of the KConfigGroupSaver object) | 56 | * one group (including the creation of the KConfigGroupSaver object) |
55 | * in one block. | 57 | * in one block. |
56 | * | 58 | * |
57 | * @author Matthias Kalle Dalheimer <kalle@kde.org> | 59 | * @author Matthias Kalle Dalheimer <kalle@kde.org> |
58 | * @version $Id$ | 60 | * @version $Id$ |
59 | * @see KConfigBase, KConfig, KSimpleConfig | 61 | * @see KConfigBase, KConfig, KSimpleConfig |
60 | * @short Helper class for easier use of KConfig/KSimpleConfig groups | 62 | * @short Helper class for easier use of KConfig/KSimpleConfig groups |
61 | */ | 63 | */ |
62 | //US I converted the class in a way that it can be used with KConfig objects of microkde | 64 | //US I converted the class in a way that it can be used with KConfig objects of microkde |
63 | 65 | ||
64 | class KConfigGroupSaver | 66 | class KConfigGroupSaver |
65 | { | 67 | { |
66 | public: | 68 | public: |
67 | /** | 69 | /** |
68 | * Constructor. You pass a pointer to the KConfigBase-derived | 70 | * Constructor. You pass a pointer to the KConfigBase-derived |
69 | * object you want to work with and a string indicating the _new_ | 71 | * object you want to work with and a string indicating the _new_ |
70 | * group. | 72 | * group. |
71 | * | 73 | * |
72 | * @param config The KConfigBase-derived object this | 74 | * @param config The KConfigBase-derived object this |
73 | * KConfigGroupSaver works on. | 75 | * KConfigGroupSaver works on. |
74 | * @param group The new group that the config object should switch to. | 76 | * @param group The new group that the config object should switch to. |
75 | */ | 77 | */ |
76 | KConfigGroupSaver( KConfig* config, QString group ) | 78 | KConfigGroupSaver( KConfig* config, QString group ) |
77 | /* KDE 4 : make the second parameter const QString & */ | 79 | /* KDE 4 : make the second parameter const QString & */ |
78 | : _config(config), _oldgroup(config->group()) | 80 | : _config(config), _oldgroup(config->group()) |
79 | { _config->setGroup( group ); } | 81 | { _config->setGroup( group ); } |
80 | 82 | ||
81 | KConfigGroupSaver( KConfig* config, const char *group ) | 83 | KConfigGroupSaver( KConfig* config, const char *group ) |
82 | : _config(config), _oldgroup(config->group()) | 84 | : _config(config), _oldgroup(config->group()) |
83 | { _config->setGroup( group ); } | 85 | { _config->setGroup( group ); } |
84 | 86 | ||
85 | KConfigGroupSaver( KConfig* config, const QCString &group ) | 87 | KConfigGroupSaver( KConfig* config, const Q3CString &group ) |
86 | : _config(config), _oldgroup(config->group()) | 88 | : _config(config), _oldgroup(config->group()) |
87 | { _config->setGroup( group ); } | 89 | { _config->setGroup( group ); } |
88 | 90 | ||
89 | ~KConfigGroupSaver() { _config->setGroup( _oldgroup ); } | 91 | ~KConfigGroupSaver() { _config->setGroup( _oldgroup ); } |
90 | 92 | ||
91 | KConfig* config() { return _config; }; | 93 | KConfig* config() { return _config; }; |
92 | 94 | ||
93 | private: | 95 | private: |
94 | KConfig* _config; | 96 | KConfig* _config; |
95 | QString _oldgroup; | 97 | QString _oldgroup; |
96 | 98 | ||
97 | KConfigGroupSaver(const KConfigGroupSaver&); | 99 | KConfigGroupSaver(const KConfigGroupSaver&); |
98 | KConfigGroupSaver& operator=(const KConfigGroupSaver&); | 100 | KConfigGroupSaver& operator=(const KConfigGroupSaver&); |
99 | 101 | ||
100 | }; | 102 | }; |
101 | 103 | ||
102 | #endif | 104 | #endif |