-rw-r--r-- | libopie2/opiecore/oconfig.h | 55 |
1 files changed, 14 insertions, 41 deletions
diff --git a/libopie2/opiecore/oconfig.h b/libopie2/opiecore/oconfig.h index afe14b1..444d280 100644 --- a/libopie2/opiecore/oconfig.h +++ b/libopie2/opiecore/oconfig.h | |||
@@ -30,12 +30,13 @@ | |||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef OCONFIG_H | 32 | #ifndef OCONFIG_H |
33 | #define OCONFIG_H | 33 | #define OCONFIG_H |
34 | 34 | ||
35 | //FIXME: Implement for X11 or reuse libqpe/Config there also? | 35 | //FIXME: Implement for X11 or reuse libqpe/Config there also? |
36 | //FIXME: Or rather use QSettings also for libqpe? | ||
36 | 37 | ||
37 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
38 | 39 | ||
39 | class QColor; | 40 | class QColor; |
40 | class QFont; | 41 | class QFont; |
41 | 42 | ||
@@ -44,67 +45,40 @@ class QFont; | |||
44 | * featuring additional handling of color and font entries | 45 | * featuring additional handling of color and font entries |
45 | */ | 46 | */ |
46 | 47 | ||
47 | class OConfig : public Config | 48 | class OConfig : public Config |
48 | { | 49 | { |
49 | public: | 50 | public: |
50 | |||
51 | /** | 51 | /** |
52 | * Constructs a OConfig object. | 52 | * Constructs a OConfig object with a @a name. |
53 | * | ||
54 | * @param name A file to parse. | ||
55 | */ | 53 | */ |
56 | OConfig( const QString &name, Domain domain = User ); | 54 | OConfig( const QString &name, Domain domain = User ); |
57 | |||
58 | /** | 55 | /** |
59 | * Destructs the OConfig object. | 56 | * Destructs the OConfig object. |
60 | * | 57 | * |
61 | * Writes back any dirty configuration entries, and destroys | 58 | * Writes back any dirty configuration entries, and destroys |
62 | * dynamically created objects. | 59 | * dynamically created objects. |
63 | */ | 60 | */ |
64 | virtual ~OConfig(); | 61 | virtual ~OConfig(); |
65 | |||
66 | /** | 62 | /** |
67 | * Returns the name of the group in which we are | 63 | * @returns the name of the current group. |
68 | * searching for keys and from which we are retrieving entries. | 64 | * The current group is used for searching keys and accessing entries. |
69 | * | ||
70 | * @return The current group. | ||
71 | */ | 65 | */ |
72 | const QString& group() { return git.key(); }; | 66 | const QString& group() { return git.key(); }; |
73 | |||
74 | /** | 67 | /** |
75 | * Reads a @ref QColor entry. | 68 | * @returns a @ref QColor entry or a @a default value if the key is not found. |
76 | * | ||
77 | * Read the value of an entry specified by @p pKey in the current group | ||
78 | * and interpret it as a color. | ||
79 | * | ||
80 | * @param pKey The key to search for. | ||
81 | * @param pDefault A default value (null QColor by default) returned if the | ||
82 | * key was not found or if the value cannot be interpreted. | ||
83 | * @return The value for this key. | ||
84 | */ | 69 | */ |
85 | QColor readColorEntry( const QString& key, const QColor* pDefault ) const; | 70 | QColor readColorEntry( const QString& key, const QColor* pDefault ) const; |
86 | |||
87 | /** | 71 | /** |
88 | * Reads a @ref QFont value. | 72 | * @returns a @ref QFont value or a @a default value if the key is not found. |
89 | * | ||
90 | * Read the value of an entry specified by @p pKey in the current group | ||
91 | * and interpret it as a font object. | ||
92 | * | ||
93 | * @param pKey The key to search for. | ||
94 | * @param pDefault A default value (null QFont by default) returned if the | ||
95 | * key was not found or if the read value cannot be interpreted. | ||
96 | * @return The value for this key. | ||
97 | */ | 73 | */ |
98 | QFont readFontEntry( const QString& key, const QFont* pDefault ) const; | 74 | QFont readFontEntry( const QString& key, const QFont* pDefault ) const; |
99 | |||
100 | }; | 75 | }; |
101 | 76 | ||
102 | /** | 77 | /** |
103 | * Helper class to facilitate working with @ref OConfig / @ref OSimpleConfig | 78 | * @brief Helper class for easier use of OConfig groups. |
104 | * groups. | ||
105 | * | 79 | * |
106 | * Careful programmers always set the group of a | 80 | * Careful programmers always set the group of a |
107 | * @ref OConfig object to the group they want to read from | 81 | * @ref OConfig object to the group they want to read from |
108 | * and set it back to the old one of afterwards. This is usually | 82 | * and set it back to the old one of afterwards. This is usually |
109 | * written as: | 83 | * written as: |
110 | * <pre> | 84 | * <pre> |
@@ -126,35 +100,34 @@ class OConfig : public Config | |||
126 | * one group (including the creation of the OConfigGroupSaver object) | 100 | * one group (including the creation of the OConfigGroupSaver object) |
127 | * in one block. | 101 | * in one block. |
128 | * | 102 | * |
129 | * @author Matthias Kalle Dalheimer <Kalle@kde.org> | 103 | * @author Matthias Kalle Dalheimer <Kalle@kde.org> |
130 | * @version $Id$ | 104 | * @version $Id$ |
131 | * @see OConfig | 105 | * @see OConfig |
132 | * @short Helper class for easier use of OConfig groups | ||
133 | */ | 106 | */ |
134 | 107 | ||
135 | class OConfigGroupSaver | 108 | class OConfigGroupSaver |
136 | { | 109 | { |
137 | public: | 110 | public: |
138 | /** | 111 | /** |
139 | * Constructor. You pass a pointer to the OConfigBase-derived | 112 | * Constructor. |
140 | * object you want to work with and a string indicating the _new_ | 113 | * Create the object giving a @config object and a @a group to become |
141 | * group. | 114 | * the current group. |
142 | * @param config The OConfig-derived object this | ||
143 | * OConfigGroupSaver works on. | ||
144 | * @param group The new group that the config object should switch to. | ||
145 | */ | 115 | */ |
146 | OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() ) | 116 | OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() ) |
147 | { _config->setGroup( group ); } | 117 | { _config->setGroup( group ); } |
148 | 118 | ||
149 | OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group()) | 119 | OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group()) |
150 | { _config->setGroup( group ); } | 120 | { _config->setGroup( group ); } |
151 | 121 | ||
152 | OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group()) | 122 | OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group()) |
153 | { _config->setGroup( group ); } | 123 | { _config->setGroup( group ); } |
154 | 124 | /** | |
125 | * Destructor. | ||
126 | * Restores the last current group. | ||
127 | */ | ||
155 | ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); } | 128 | ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); } |
156 | 129 | ||
157 | OConfig* config() { return _config; }; | 130 | OConfig* config() { return _config; }; |
158 | 131 | ||
159 | private: | 132 | private: |
160 | OConfig* _config; | 133 | OConfig* _config; |