Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Opie::Core::OConfigGroupSaver Class Reference

Helper class for easier use of OConfig groups. More...

#include </home/clem/local/src/opie/libopie2/opiecore/oconfig.h>

Collaboration diagram for Opie::Core::OConfigGroupSaver:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 OConfigGroupSaver (OConfig *config, QString group)
 OConfigGroupSaver (OConfig *config, const char *group)
 OConfigGroupSaver (OConfig *config, const QCString &group)
 ~OConfigGroupSaver ()
OConfigconfig ()

Private Member Functions

 OConfigGroupSaver (const OConfigGroupSaver &)
OConfigGroupSaveroperator= (const OConfigGroupSaver &)

Private Attributes

OConfig_config
QString _oldgroup
Private * d

Detailed Description

Helper class for easier use of OConfig groups.

Careful programmers always set the group of a OConfig object to the group they want to read from and set it back to the old one of afterwards. This is usually written as:

 QString oldgroup config()->group();
 config()->setGroup( "TheGroupThatIWant" );
 ...
 config()->writeEntry( "Blah", "Blubb" );

 config()->setGroup( oldgroup );
 

In order to facilitate this task, you can use OConfigGroupSaver. Simply construct such an object ON THE STACK when you want to switch to a new group. Then, when the object goes out of scope, the group will automatically be restored. If you want to use several different groups within a function or method, you can still use OConfigGroupSaver: Simply enclose all work with one group (including the creation of the OConfigGroupSaver object) in one block.

 OConfigGroupSaver saver(cfg,"TheGroupThatInWhat");

Note that OConfigGroupSaver (cfg,"TheGroupThatInWhat"); would get imediately destructed after created and that you would save in the old group which is unwished.

Author:
Matthias Kalle Dalheimer <Kalle@kde.org>
Version:
Id
oconfig.h,v 1.10 2004/10/07 19:36:30 clem Exp
See also:
OConfig

Definition at line 125 of file oconfig.h.


Constructor & Destructor Documentation

Opie::Core::OConfigGroupSaver::OConfigGroupSaver OConfig config,
QString  group
[inline]
 

Constructor. Create the object giving a OConfig object and a group to become the current group.

Definition at line 133 of file oconfig.h.

References _config, and Config::setGroup().

Opie::Core::OConfigGroupSaver::OConfigGroupSaver OConfig config,
const char *  group
[inline]
 

Definition at line 136 of file oconfig.h.

References _config, and Config::setGroup().

Opie::Core::OConfigGroupSaver::OConfigGroupSaver OConfig config,
const QCString group
[inline]
 

Definition at line 139 of file oconfig.h.

References _config, and Config::setGroup().

Opie::Core::OConfigGroupSaver::~OConfigGroupSaver  )  [inline]
 

Destructor. Restores the last current group.

Todo:
make it not inline for bc reasons. See KDE BC guide

Definition at line 146 of file oconfig.h.

References _config, _oldgroup, and Config::setGroup().

Opie::Core::OConfigGroupSaver::OConfigGroupSaver const OConfigGroupSaver  )  [private]
 


Member Function Documentation

OConfig* Opie::Core::OConfigGroupSaver::config  )  [inline]
 

Definition at line 148 of file oconfig.h.

References _config.

Referenced by CameraMainWindow::init(), main(), Opie::Core::OGlobalSettings::showContextMenusOnPress(), and CameraMainWindow::~CameraMainWindow().

OConfigGroupSaver& Opie::Core::OConfigGroupSaver::operator= const OConfigGroupSaver  )  [private]
 


Member Data Documentation

OConfig* Opie::Core::OConfigGroupSaver::_config [private]
 

Definition at line 148 of file oconfig.h.

Referenced by config(), OConfigGroupSaver(), and ~OConfigGroupSaver().

QString Opie::Core::OConfigGroupSaver::_oldgroup [private]
 

Definition at line 152 of file oconfig.h.

Referenced by ~OConfigGroupSaver().

Private* Opie::Core::OConfigGroupSaver::d [private]
 

Definition at line 157 of file oconfig.h.


The documentation for this class was generated from the following file:
Generated on Sat Nov 5 18:00:38 2005 for OPIE by  doxygen 1.4.2