class KConfigSkeleton |
|
|
< Stores the value for this item < The default value for this item Class for handling preferences settings for an application. Author Cornelius Schumacher See also KConfigSkeletonItem 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. KConfigSkeleton then handles reading and writing of config files and setting of default values. Normally you will subclass KConfigSkeleton, add data members for the preferences settings and register the members in the constructor of the subclass. Example: class MyPrefs : public KConfigSkeleton { public: MyPrefs() { setCurrentGroup("MyGroup"); addItemBool("MySetting1",mMyBool,false); addItemColor("MySetting2",mMyColor,QColor(1,2,3)); It might be convenient in many cases to make this subclass of KConfigSkeleton a singleton for global access from all over the application without passing references to the KConfigSkeleton 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 want to watch for config changes, use configChanged() signal. 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 KConfigSkeletonItem. You can also add KConfigSkeletonItem subclasses for your own types and call the generic addItem() to register them. In many cases you don't have to write the specific KConfigSkeleton subclasses yourself, but you can use kconfig_compiler to automatically generate the C++ code from an XML description of the configuration options. |
|
Constructor.
configname - name of config file. If no name is given, the default config file as returned by KGlobal.config() is used. |
|
Constructor.
config - configuration object to use. |
|
Register a custom KConfigSkeletonItem with a given name. If the name parameter is null, take the name from KConfigSkeletonItem.key(). Note that all names must be unique but that multiple entries can have the same key if they reside in different groups. |
|
Register an item of type bool.
name - Name used to identify 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 |
|
Register an item of type QColor.
name - Name used to identify 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 |
|
Register an item of type QDateTime.
name - Name used to identify 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 |
|
Register an item of type double.
name - Name used to identify 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 |
|
Register an item of type QFont.
name - Name used to identify 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 |
|
Register an item of type qint32.
name - Name used to identify 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 |
|
|
Register an item of type QList
name - Name used to identify 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 |
|
Register an item of type qint64.
name - Name used to identify 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 |
|
Register a password item of type QString. The string value is written encrypted to the config file. Note that the current encryption scheme is very weak.
name - Name used to identify 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 |
|
Register a path item of type QString. The string value is interpreted as a path. This means, dollar expension is activated for this value, so that e.g. $HOME gets expanded.
name - Name used to identify 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 |
|
Register an item of type QPoint.
name - Name used to identify 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 |
|
Register a property item of type QVariant. Note that only the following QVariant types are allowed: String, StringList, Font, Point, Rect, Size, Color, Int, UInt, Bool, Double, DateTime and Date.
name - Name used to identify 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 |
|
Register an item of type QRect.
name - Name used to identify 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 |
|
Register an item of type QSize.
name - Name used to identify 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 |
|
Register an item of type QString.
name - Name used to identify 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 |
|
Register an item of type QStringList.
name - Name used to identify 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 |
|
Register an item of type quint32.
name - Name used to identify 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 |
|
|
Register an item of type quint64
name - Name used to identify 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 |
|
Return the KConfig object used for reading and writing the settings. |
|
This signal is emitted when the configuration change. |
|
Returns the current group used for addItem() calls. |
|
Lookup item by name |
|
Return whether a certain item is immutable |
|
Return list of items managed by this KConfigSkeleton object. |
|
Read preferences from config file. All registered items are set to the values read from disk. This method calls usrReadConfig() after reading the settings of the registered items from the KConfig. You can overridde usrReadConfig() in derived classes if you have special requirements. If you need more fine-grained control of storing the settings from the registered items you can override readConfig() in a derived class. |
|
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". |
|
Set all registered items to their default values. This method calls usrSetDefaults() after setting the defaults for the registered items. You can overridde usrSetDefaults() in derived classes if you have special requirements. If you need more fine-grained control of setting the default values of the registered items you can override setDefaults() in a derived class. |
|
Set the KSharedConfig object used for reading and writing the settings. |
|
Specify whether this object should reflect the actual values or the default values. This method is implemented by usrUseDefaults(), which can be overridden in derived classes if you have special requirements and can call usrUseDefaults() directly. If you don't have control wether useDefaults() or usrUseDefaults() is called override useDefaults() directly. b - true to make this object reflect the default values, false to make it reflect the actual values. Returns The state prior to this call |
|
Perform the actual reading of the configuration file. Override in derived classes to read special config values. Called from readConfig() |
|
Perform the actual setting of default values. Override in derived classes to set special default values. Called from setDefaults() |
|
Implemented by subclasses that use special defaults. It replaces the default values with the actual values and vice versa. Called from useDefaults() b - true to make this object reflect the default values, false to make it reflect the actual values. Returns The state prior to this call |
|
Perform the actual writing of the configuration file. Override in derived classes to write special config values. Called from writeConfig() |
|
Write preferences to config file. The values of all registered items are written to disk. This method calls usrWriteConfig() after writing the settings from the registered items to the KConfig. You can overridde usrWriteConfig() in derived classes if you have special requirements. If you need more fine-grained control of storing the settings from the registered items you can override writeConfig() in a derived class. |