#include <tdeconfigskeleton.h>
Classes | |
class | ItemBool |
class | ItemColor |
class | ItemDateTime |
class | ItemDouble |
class | ItemEnum |
class | ItemFont |
class | ItemInt |
class | ItemInt64 |
class | ItemIntList |
class | ItemLong |
class | ItemPassword |
class | ItemPath |
class | ItemPathList |
class | ItemPoint |
class | ItemProperty |
class | ItemRect |
class | ItemSize |
class | ItemString |
class | ItemStringList |
class | ItemUInt |
class | ItemUInt64 |
class | ItemULong |
Public Member Functions | |
TDEConfigSkeleton (const TQString &configname=TQString::null) | |
TDEConfigSkeleton (TDESharedConfig::Ptr config) | |
virtual | ~ TDEConfigSkeleton () |
void | setDefaults () |
void | readConfig () |
void | writeConfig () |
void | setCurrentGroup (const TQString &group) |
TQString | currentGroup () |
void | addItem (TDEConfigSkeletonItem *, const TQString &name=TQString::null) |
ItemString * | addItemString (const TQString &name, TQString &reference, const TQString &defaultValue=TQString::fromLatin1(""), const TQString &key=TQString::null) |
ItemPassword * | addItemPassword (const TQString &name, TQString &reference, const TQString &defaultValue=TQString::fromLatin1(""), const TQString &key=TQString::null) |
ItemPath * | addItemPath (const TQString &name, TQString &reference, const TQString &defaultValue=TQString::fromLatin1(""), const TQString &key=TQString::null) |
ItemProperty * | addItemProperty (const TQString &name, TQVariant &reference, const TQVariant &defaultValue=TQVariant(), const TQString &key=TQString::null) |
ItemBool * | addItemBool (const TQString &name, bool &reference, bool defaultValue=false, const TQString &key=TQString::null) |
ItemInt * | addItemInt (const TQString &name, int &reference, int defaultValue=0, const TQString &key=TQString::null) |
ItemUInt * | addItemUInt (const TQString &name, unsigned int &reference, unsigned int defaultValue=0, const TQString &key=TQString::null) |
ItemLong * | addItemLong (const TQString &name, long &reference, long defaultValue=0, const TQString &key=TQString::null) |
ItemULong * | addItemULong (const TQString &name, unsigned long &reference, unsigned long defaultValue=0, const TQString &key=TQString::null) |
ItemInt64 * | addItemInt64 (const TQString &name, TQ_INT64 &reference, TQ_INT64 defaultValue=0, const TQString &key=TQString::null) |
ItemUInt64 * | addItemUInt64 (const TQString &name, TQ_UINT64 &reference, TQ_UINT64 defaultValue=0, const TQString &key=TQString::null) |
ItemDouble * | addItemDouble (const TQString &name, double &reference, double defaultValue=0.0, const TQString &key=TQString::null) |
ItemColor * | addItemColor (const TQString &name, TQColor &reference, const TQColor &defaultValue=TQColor(128, 128, 128), const TQString &key=TQString::null) |
ItemFont * | addItemFont (const TQString &name, TQFont &reference, const TQFont &defaultValue=TDEGlobalSettings::generalFont(), const TQString &key=TQString::null) |
ItemRect * | addItemRect (const TQString &name, TQRect &reference, const TQRect &defaultValue=TQRect(), const TQString &key=TQString::null) |
ItemPoint * | addItemPoint (const TQString &name, TQPoint &reference, const TQPoint &defaultValue=TQPoint(), const TQString &key=TQString::null) |
ItemSize * | addItemSize (const TQString &name, TQSize &reference, const TQSize &defaultValue=TQSize(), const TQString &key=TQString::null) |
ItemDateTime * | addItemDateTime (const TQString &name, TQDateTime &reference, const TQDateTime &defaultValue=TQDateTime(), const TQString &key=TQString::null) |
ItemStringList * | addItemStringList (const TQString &name, TQStringList &reference, const TQStringList &defaultValue=TQStringList(), const TQString &key=TQString::null) |
ItemIntList * | addItemIntList (const TQString &name, TQValueList< int > &reference, const TQValueList< int > &defaultValue=TQValueList< int >(), const TQString &key=TQString::null) |
TDEConfig * | config () const |
TDEConfigSkeletonItem::List | items () const |
bool | isImmutable (const TQString &name) |
TDEConfigSkeletonItem * | findItem (const TQString &name) |
bool | useDefaults (bool b) |
Protected Member Functions | |
virtual void | usrUseDefaults (bool) |
virtual void | usrSetDefaults () |
virtual void | usrReadConfig () |
virtual void | usrWriteConfig () |
Detailed Description
Class for handling preferences settings for an application.
- See also
- TDEConfigSkeletonItem
This class provides an interface to preferences settings. Preferences items can be registered by the addItem() function corresponding to the data type of the seetting. TDEConfigSkeleton then handles reading and writing of config files and setting of default values.
Normally you will subclass TDEConfigSkeleton, add data members for the preferences settings and register the members in the constructor of the subclass.
Example:
It might be convenient in many cases to make this subclass of TDEConfigSkeleton a singleton for global access from all over the application without passing references to the TDEConfigSkeleton object around.
You can write the data to the configuration file by calling writeConfig() and read the data from the configuration file by calling readConfig().
If you have items, which are not covered by the existing addItem() functions you can add customized code for reading, writing and default setting by implementing the functions usrUseDefaults(), usrReadConfig() and usrWriteConfig().
Internally preferences settings are stored in instances of subclasses of TDEConfigSkeletonItem. You can also add TDEConfigSkeletonItem subclasses for your own types and call the generic addItem() to register them.
In many cases you don't have to write the specific TDEConfigSkeleton subclasses yourself, but you can use The KDE Configuration Compiler to automatically generate the C++ code from an XML description of the configuration options.
Definition at line 365 of file tdeconfigskeleton.h.
Constructor & Destructor Documentation
◆ TDEConfigSkeleton() [1/2]
TDEConfigSkeleton::TDEConfigSkeleton | ( | const TQString & | configname = TQString::null | ) |
Constructor.
- Parameters
-
configname name of config file. If no name is given, the default config file as returned by kapp()->config() is used.
Definition at line 881 of file tdeconfigskeleton.cpp.
◆ TDEConfigSkeleton() [2/2]
TDEConfigSkeleton::TDEConfigSkeleton | ( | TDESharedConfig::Ptr | config | ) |
Constructor.
- Parameters
-
config configuration object to use.
Definition at line 896 of file tdeconfigskeleton.cpp.
◆ ~ TDEConfigSkeleton()
|
virtual |
Destructor.
Member Function Documentation
◆ addItem()
void TDEConfigSkeleton::addItem | ( | TDEConfigSkeletonItem * | item, |
const TQString & | name = TQString::null |
||
) |
Register a custom TDEConfigSkeletonItem with a given name.
If the name parameter is null, take the name from TDEConfigSkeletonItem::key(). Note that all names must be unique but that multiple entries can have the same key if they reside in different groups.
Definition at line 988 of file tdeconfigskeleton.cpp.
◆ addItemBool()
TDEConfigSkeleton::ItemBool * TDEConfigSkeleton::addItemBool | ( | const TQString & | name, |
bool & | reference, | ||
bool | defaultValue = false , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type bool.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1038 of file tdeconfigskeleton.cpp.
◆ addItemColor()
TDEConfigSkeleton::ItemColor * TDEConfigSkeleton::addItemColor | ( | const TQString & | name, |
TQColor & | reference, | ||
const TQColor & | defaultValue = TQColor(128, 128, 128) , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type TQColor.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1118 of file tdeconfigskeleton.cpp.
◆ addItemDateTime()
TDEConfigSkeleton::ItemDateTime * TDEConfigSkeleton::addItemDateTime | ( | const TQString & | name, |
TQDateTime & | reference, | ||
const TQDateTime & | defaultValue = TQDateTime() , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type TQDateTime.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1168 of file tdeconfigskeleton.cpp.
◆ addItemDouble()
TDEConfigSkeleton::ItemDouble * TDEConfigSkeleton::addItemDouble | ( | const TQString & | name, |
double & | reference, | ||
double | defaultValue = 0.0 , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type double.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1108 of file tdeconfigskeleton.cpp.
◆ addItemFont()
TDEConfigSkeleton::ItemFont * TDEConfigSkeleton::addItemFont | ( | const TQString & | name, |
TQFont & | reference, | ||
const TQFont & | defaultValue = TDEGlobalSettings::generalFont() , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type TQFont.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1128 of file tdeconfigskeleton.cpp.
◆ addItemInt()
TDEConfigSkeleton::ItemInt * TDEConfigSkeleton::addItemInt | ( | const TQString & | name, |
int & | reference, | ||
int | defaultValue = 0 , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type int.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1048 of file tdeconfigskeleton.cpp.
◆ addItemInt64()
TDEConfigSkeleton::ItemInt64 * TDEConfigSkeleton::addItemInt64 | ( | const TQString & | name, |
TQ_INT64 & | reference, | ||
TQ_INT64 | defaultValue = 0 , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type TQ_INT64.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1068 of file tdeconfigskeleton.cpp.
◆ addItemIntList()
TDEConfigSkeleton::ItemIntList * TDEConfigSkeleton::addItemIntList | ( | const TQString & | name, |
TQValueList< int > & | reference, | ||
const TQValueList< int > & | defaultValue = TQValueList < int >() , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type TQValueList<int>.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1188 of file tdeconfigskeleton.cpp.
◆ addItemLong()
TDEConfigSkeleton::ItemLong * TDEConfigSkeleton::addItemLong | ( | const TQString & | name, |
long & | reference, | ||
long | defaultValue = 0 , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type long.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1088 of file tdeconfigskeleton.cpp.
◆ addItemPassword()
TDEConfigSkeleton::ItemPassword * TDEConfigSkeleton::addItemPassword | ( | const TQString & | name, |
TQString & | reference, | ||
const TQString & | defaultValue = TQString::fromLatin1("") , |
||
const TQString & | key = TQString::null |
||
) |
Register a password item of type TQString.
The string value is written encrypted to the config file. Note that the current encryption scheme is very weak.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1008 of file tdeconfigskeleton.cpp.
◆ addItemPath()
TDEConfigSkeleton::ItemPath * TDEConfigSkeleton::addItemPath | ( | const TQString & | name, |
TQString & | reference, | ||
const TQString & | defaultValue = TQString::fromLatin1("") , |
||
const TQString & | key = TQString::null |
||
) |
Register a path item of type TQString.
The string value is interpreted as a path. This means, dollar expension is activated for this value, so that e.g. $HOME gets expanded.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1018 of file tdeconfigskeleton.cpp.
◆ addItemPoint()
TDEConfigSkeleton::ItemPoint * TDEConfigSkeleton::addItemPoint | ( | const TQString & | name, |
TQPoint & | reference, | ||
const TQPoint & | defaultValue = TQPoint() , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type TQPoint.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1148 of file tdeconfigskeleton.cpp.
◆ addItemProperty()
TDEConfigSkeleton::ItemProperty * TDEConfigSkeleton::addItemProperty | ( | const TQString & | name, |
TQVariant & | reference, | ||
const TQVariant & | defaultValue = TQVariant() , |
||
const TQString & | key = TQString::null |
||
) |
Register a property item of type TQVariant.
Note that only the following TQVariant types are allowed: String, StringList, Font, Point, Rect, Size, Color, Int, UInt, Bool, Double, DateTime and Date.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1028 of file tdeconfigskeleton.cpp.
◆ addItemRect()
TDEConfigSkeleton::ItemRect * TDEConfigSkeleton::addItemRect | ( | const TQString & | name, |
TQRect & | reference, | ||
const TQRect & | defaultValue = TQRect() , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type TQRect.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1138 of file tdeconfigskeleton.cpp.
◆ addItemSize()
TDEConfigSkeleton::ItemSize * TDEConfigSkeleton::addItemSize | ( | const TQString & | name, |
TQSize & | reference, | ||
const TQSize & | defaultValue = TQSize() , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type TQSize.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1158 of file tdeconfigskeleton.cpp.
◆ addItemString()
TDEConfigSkeleton::ItemString * TDEConfigSkeleton::addItemString | ( | const TQString & | name, |
TQString & | reference, | ||
const TQString & | defaultValue = TQString::fromLatin1("") , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type TQString.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 997 of file tdeconfigskeleton.cpp.
◆ addItemStringList()
TDEConfigSkeleton::ItemStringList * TDEConfigSkeleton::addItemStringList | ( | const TQString & | name, |
TQStringList & | reference, | ||
const TQStringList & | defaultValue = TQStringList() , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type TQStringList.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1178 of file tdeconfigskeleton.cpp.
◆ addItemUInt()
TDEConfigSkeleton::ItemUInt * TDEConfigSkeleton::addItemUInt | ( | const TQString & | name, |
unsigned int & | reference, | ||
unsigned int | defaultValue = 0 , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type unsigned int.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1058 of file tdeconfigskeleton.cpp.
◆ addItemUInt64()
TDEConfigSkeleton::ItemUInt64 * TDEConfigSkeleton::addItemUInt64 | ( | const TQString & | name, |
TQ_UINT64 & | reference, | ||
TQ_UINT64 | defaultValue = 0 , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type TQ_UINT64.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1078 of file tdeconfigskeleton.cpp.
◆ addItemULong()
TDEConfigSkeleton::ItemULong * TDEConfigSkeleton::addItemULong | ( | const TQString & | name, |
unsigned long & | reference, | ||
unsigned long | defaultValue = 0 , |
||
const TQString & | key = TQString::null |
||
) |
Register an item of type unsigned long.
- Parameters
-
name Name used to indentify this setting. Names must be unique. reference Pointer to the variable, which is set by readConfig() calls and read by writeConfig() calls. defaultValue Default value, which is used when the config file does not yet contain the key of this item. key Key used in config file. If key is null, name is used as key.
- Returns
- The created item
Definition at line 1098 of file tdeconfigskeleton.cpp.
◆ config()
TDEConfig * TDEConfigSkeleton::config | ( | ) | const |
Return the TDEConfig object used for reading and writing the settings.
Definition at line 918 of file tdeconfigskeleton.cpp.
◆ currentGroup()
|
inline |
Returns the current group used for addItem() calls.
Definition at line 837 of file tdeconfigskeleton.h.
◆ findItem()
TDEConfigSkeletonItem * TDEConfigSkeleton::findItem | ( | const TQString & | name | ) |
Lookup item by name.
Definition at line 1204 of file tdeconfigskeleton.cpp.
◆ isImmutable()
bool TDEConfigSkeleton::isImmutable | ( | const TQString & | name | ) |
Return whether a certain item is immutable.
Definition at line 1198 of file tdeconfigskeleton.cpp.
◆ items()
|
inline |
Return list of items managed by this TDEConfigSkeleton object.
Definition at line 1164 of file tdeconfigskeleton.h.
◆ readConfig()
void TDEConfigSkeleton::readConfig | ( | ) |
Read preferences from config file.
All registered items are set to the values read from disk.
Definition at line 949 of file tdeconfigskeleton.cpp.
◆ setCurrentGroup()
void TDEConfigSkeleton::setCurrentGroup | ( | const TQString & | group | ) |
Set the config file group for subsequent addItem() calls.
It is valid until setCurrentGroup() is called with a new argument. Call this before you add any items. The default value is "No Group".
Definition at line 913 of file tdeconfigskeleton.cpp.
◆ setDefaults()
void TDEConfigSkeleton::setDefaults | ( | ) |
Set all registered items to their default values.
Definition at line 939 of file tdeconfigskeleton.cpp.
◆ useDefaults()
bool TDEConfigSkeleton::useDefaults | ( | bool | b | ) |
Indicate whether this object should reflect the actual values or the default values.
- Parameters
-
b If true this object reflects the default values.
- Returns
- The state prior to this call
Definition at line 923 of file tdeconfigskeleton.cpp.
◆ usrReadConfig()
|
inlineprotectedvirtual |
Implemented by subclasses that read special config values.
Definition at line 1204 of file tdeconfigskeleton.h.
◆ usrUseDefaults()
|
inlineprotectedvirtual |
Implemented by subclasses that use special defaults.
It should replace the default values with the actual values and vice versa.
Definition at line 1193 of file tdeconfigskeleton.h.
◆ usrWriteConfig()
|
inlineprotectedvirtual |
Implemented by subclasses that write special config values.
Definition at line 1211 of file tdeconfigskeleton.h.
◆ writeConfig()
void TDEConfigSkeleton::writeConfig | ( | ) |
Write preferences to config file.
The values of all registered items are written to disk.
Definition at line 967 of file tdeconfigskeleton.cpp.
The documentation for this class was generated from the following files: