summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/oconfig.h
Unidiff
Diffstat (limited to 'libopie2/opiecore/oconfig.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/oconfig.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/libopie2/opiecore/oconfig.h b/libopie2/opiecore/oconfig.h
index becf70d..29c1f86 100644
--- a/libopie2/opiecore/oconfig.h
+++ b/libopie2/opiecore/oconfig.h
@@ -19,80 +19,88 @@
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
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//FIXME: Or rather use QSettings also for libqpe?
37 37
38#include <qpe/config.h> 38#include <qpe/config.h>
39 39
40class QColor; 40class QColor;
41class QFont; 41class QFont;
42 42
43namespace Opie {
44namespace Core {
45
43/** 46/**
44 * A Configuration class based on the Qtopia @ref Config class 47 * A Configuration class based on the Qtopia @ref Config class
45 * featuring additional handling of color and font entries 48 * featuring additional handling of color and font entries
46 */ 49 */
47 50
48class OConfig : public Config 51class OConfig : public Config
49{ 52{
50 public: 53 public:
51 /** 54 /**
52 * Constructs a OConfig object with a @a name. 55 * Constructs a OConfig object with a @a name.
53 */ 56 */
54 OConfig( const QString &name, Domain domain = User ); 57 OConfig( const QString &name, Domain domain = User );
55 /** 58 /**
56 * Destructs the OConfig object. 59 * Destructs the OConfig object.
57 * 60 *
58 * Writes back any dirty configuration entries, and destroys 61 * Writes back any dirty configuration entries, and destroys
59 * dynamically created objects. 62 * dynamically created objects.
60 */ 63 */
61 virtual ~OConfig(); 64 virtual ~OConfig();
62 /** 65 /**
63 * @returns the name of the current group. 66 * @returns the name of the current group.
64 * The current group is used for searching keys and accessing entries. 67 * The current group is used for searching keys and accessing entries.
68 * @todo make const
65 */ 69 */
66 const QString& group() { return git.key(); }; 70 const QString& group() { return git.key(); };
67 /** 71 /**
68 * @returns a @ref QColor entry or a @a default value if the key is not found. 72 * @returns a @ref QColor entry or a @a default value if the key is not found.
69 */ 73 */
70 QColor readColorEntry( const QString& key, const QColor* pDefault ) const; 74 QColor readColorEntry( const QString& key, const QColor* pDefault ) const;
71 /** 75 /**
72 * @returns a @ref QFont value or a @a default value if the key is not found. 76 * @returns a @ref QFont value or a @a default value if the key is not found.
73 */ 77 */
74 QFont readFontEntry( const QString& key, const QFont* pDefault ) const; 78 QFont readFontEntry( const QString& key, const QFont* pDefault ) const;
79
80private:
81 class Private;
82 Private *d;
75}; 83};
76 84
77/** 85/**
78 * @brief Helper class for easier use of OConfig groups. 86 * @brief Helper class for easier use of OConfig groups.
79 * 87 *
80 * Careful programmers always set the group of a 88 * Careful programmers always set the group of a
81 * @ref OConfig object to the group they want to read from 89 * @ref OConfig object to the group they want to read from
82 * and set it back to the old one of afterwards. This is usually 90 * and set it back to the old one of afterwards. This is usually
83 * written as: 91 * written as:
84 * <pre> 92 * <pre>
85 * 93 *
86 * QString oldgroup config()->group(); 94 * QString oldgroup config()->group();
87 * config()->setGroup( "TheGroupThatIWant" ); 95 * config()->setGroup( "TheGroupThatIWant" );
88 * ... 96 * ...
89 * config()->writeEntry( "Blah", "Blubb" ); 97 * config()->writeEntry( "Blah", "Blubb" );
90 * 98 *
91 * config()->setGroup( oldgroup ); 99 * config()->setGroup( oldgroup );
92 * </pre> 100 * </pre>
93 * 101 *
94 * In order to facilitate this task, you can use 102 * In order to facilitate this task, you can use
95 * OConfigGroupSaver. Simply construct such an object ON THE STACK 103 * OConfigGroupSaver. Simply construct such an object ON THE STACK
96 * when you want to switch to a new group. Then, when the object goes 104 * when you want to switch to a new group. Then, when the object goes
97 * out of scope, the group will automatically be restored. If you 105 * out of scope, the group will automatically be restored. If you
98 * want to use several different groups within a function or method, 106 * want to use several different groups within a function or method,
@@ -115,27 +123,32 @@ class OConfigGroupSaver
115 */ 123 */
116 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() ) 124 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() )
117 { _config->setGroup( group ); } 125 { _config->setGroup( group ); }
118 126
119 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group()) 127 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group())
120 { _config->setGroup( group ); } 128 { _config->setGroup( group ); }
121 129
122 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group()) 130 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group())
123 { _config->setGroup( group ); } 131 { _config->setGroup( group ); }
124 /** 132 /**
125 * Destructor. 133 * Destructor.
126 * Restores the last current group. 134 * Restores the last current group.
127 * @todo make it not inline for bc reasons. See KDE BC guide 135 * @todo make it not inline for bc reasons. See KDE BC guide
128 */ 136 */
129 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); } 137 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); }
130 138
131 OConfig* config() { return _config; }; 139 OConfig* config() { return _config; };
132 140
133 private: 141 private:
134 OConfig* _config; 142 OConfig* _config;
135 QString _oldgroup; 143 QString _oldgroup;
136 144
137 OConfigGroupSaver( const OConfigGroupSaver& ); 145 OConfigGroupSaver( const OConfigGroupSaver& );
138 OConfigGroupSaver& operator=( const OConfigGroupSaver& ); 146 OConfigGroupSaver& operator=( const OConfigGroupSaver& );
147
148 class Private;
149 Private *d;
139}; 150};
151}
152}
140 153
141#endif // OCONFIG_H 154#endif // OCONFIG_H