summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/oconfig.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/libopie2/opiecore/oconfig.h b/libopie2/opiecore/oconfig.h
index 444d280..becf70d 100644
--- a/libopie2/opiecore/oconfig.h
+++ b/libopie2/opiecore/oconfig.h
@@ -79,62 +79,63 @@ class OConfig : public Config
79 * 79 *
80 * Careful programmers always set the group of a 80 * Careful programmers always set the group of a
81 * @ref OConfig object to the group they want to read from 81 * @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 82 * and set it back to the old one of afterwards. This is usually
83 * written as: 83 * written as:
84 * <pre> 84 * <pre>
85 * 85 *
86 * QString oldgroup config()->group(); 86 * QString oldgroup config()->group();
87 * config()->setGroup( "TheGroupThatIWant" ); 87 * config()->setGroup( "TheGroupThatIWant" );
88 * ... 88 * ...
89 * config()->writeEntry( "Blah", "Blubb" ); 89 * config()->writeEntry( "Blah", "Blubb" );
90 * 90 *
91 * config()->setGroup( oldgroup ); 91 * config()->setGroup( oldgroup );
92 * </pre> 92 * </pre>
93 * 93 *
94 * In order to facilitate this task, you can use 94 * In order to facilitate this task, you can use
95 * OConfigGroupSaver. Simply construct such an object ON THE STACK 95 * OConfigGroupSaver. Simply construct such an object ON THE STACK
96 * when you want to switch to a new group. Then, when the object goes 96 * 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 97 * out of scope, the group will automatically be restored. If you
98 * want to use several different groups within a function or method, 98 * want to use several different groups within a function or method,
99 * you can still use OConfigGroupSaver: Simply enclose all work with 99 * you can still use OConfigGroupSaver: Simply enclose all work with
100 * one group (including the creation of the OConfigGroupSaver object) 100 * one group (including the creation of the OConfigGroupSaver object)
101 * in one block. 101 * in one block.
102 * 102 *
103 * @author Matthias Kalle Dalheimer <Kalle@kde.org> 103 * @author Matthias Kalle Dalheimer <Kalle@kde.org>
104 * @version $Id$ 104 * @version $Id$
105 * @see OConfig 105 * @see OConfig
106 */ 106 */
107 107
108class OConfigGroupSaver 108class OConfigGroupSaver
109{ 109{
110 public: 110 public:
111 /** 111 /**
112 * Constructor. 112 * Constructor.
113 * Create the object giving a @config object and a @a group to become 113 * Create the object giving a @config object and a @a group to become
114 * the current group. 114 * the current group.
115 */ 115 */
116 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() ) 116 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() )
117 { _config->setGroup( group ); } 117 { _config->setGroup( group ); }
118 118
119 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group()) 119 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group())
120 { _config->setGroup( group ); } 120 { _config->setGroup( group ); }
121 121
122 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group()) 122 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group())
123 { _config->setGroup( group ); } 123 { _config->setGroup( group ); }
124 /** 124 /**
125 * Destructor. 125 * Destructor.
126 * Restores the last current group. 126 * Restores the last current group.
127 * @todo make it not inline for bc reasons. See KDE BC guide
127 */ 128 */
128 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); } 129 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); }
129 130
130 OConfig* config() { return _config; }; 131 OConfig* config() { return _config; };
131 132
132 private: 133 private:
133 OConfig* _config; 134 OConfig* _config;
134 QString _oldgroup; 135 QString _oldgroup;
135 136
136 OConfigGroupSaver( const OConfigGroupSaver& ); 137 OConfigGroupSaver( const OConfigGroupSaver& );
137 OConfigGroupSaver& operator=( const OConfigGroupSaver& ); 138 OConfigGroupSaver& operator=( const OConfigGroupSaver& );
138}; 139};
139 140
140#endif // OCONFIG_H 141#endif // OCONFIG_H