KConfigGroup Class Reference
from PyKDE4.kdecore import *
Inherits: KConfigBase
Detailed Description
\class KConfigGroup kconfiggroup.h <KConfigGroup>
A class for one specific group in a KConfig object.
If you want to access the top-level entries of a KConfig object, which are not associated with any group, use an empty group name. A KConfigGroup can be read-only if it is constructed from a const config object or from another read-only group.
Methods | |
__init__ (self) | |
__init__ (self, KConfigBase master, QString group) | |
__init__ (self, KConfigBase master, QString group) | |
__init__ (self, KConfigBase master, QString group) | |
__init__ (self, KConfigBase master, QString group) | |
__init__ (self, KSharedConfigPtr master, QString group) | |
__init__ (self, KSharedConfigPtr master, QString group) | |
__init__ (self, KConfigGroup a0) | |
KConfigBase.AccessMode | accessMode (self) |
changeGroup (self, QString group) | |
changeGroup (self, QString group) | |
KConfig | config (self) |
KConfig | config (self) |
copyTo (self, KConfigBase other, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
deleteEntry (self, QString pKey, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
deleteEntry (self, QString pKey, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
deleteGroup (self, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
deleteGroupImpl (self, QByteArray group, KConfigBase.WriteConfigFlags flags) | |
QMap | entryMap (self) |
bool | exists (self) |
KConfigGroup | groupImpl (self, QByteArray b) |
KConfigGroup | groupImpl (self, QByteArray b) |
QStringList | groupList (self) |
bool | hasDefault (self, QString key) |
bool | hasDefault (self, QString key) |
bool | hasGroupImpl (self, QByteArray group) |
bool | hasKey (self, QString key) |
bool | hasKey (self, QString key) |
bool | isEntryImmutable (self, QString key) |
bool | isEntryImmutable (self, QString key) |
bool | isGroupImmutableImpl (self, QByteArray aGroup) |
bool | isImmutable (self) |
bool | isValid (self) |
QStringList | keyList (self) |
markAsClean (self) | |
QString | name (self) |
KConfigGroup | parent (self) |
QVariant | readEntry (self, QString key, QVariant aDefault) |
QVariant | readEntry (self, QString key, QVariant aDefault) |
QString | readEntry (self, QString key, QString aDefault) |
QString | readEntry (self, QString key, QString aDefault) |
QString | readEntry (self, QString key, QString aDefault=0) |
QString | readEntry (self, QString key, QString aDefault=0) |
QVariantList | readEntry (self, QString key, QVariantList aDefault) |
QVariantList | readEntry (self, QString key, QVariantList aDefault) |
QStringList | readEntry (self, QString key, QStringList aDefault) |
QStringList | readEntry (self, QString key, QStringList aDefault) |
QString | readEntryUntranslated (self, QString pKey, QString aDefault=QString()) |
QString | readEntryUntranslated (self, QString key, QString aDefault=QString()) |
QString | readPathEntry (self, QString pKey, QString aDefault) |
QString | readPathEntry (self, QString key, QString aDefault) |
QStringList | readPathEntry (self, QString pKey, QStringList aDefault) |
QStringList | readPathEntry (self, QString key, QStringList aDefault) |
QStringList | readXdgListEntry (self, QString pKey, QStringList aDefault=QStringList()) |
QStringList | readXdgListEntry (self, QString pKey, QStringList aDefault=QStringList()) |
reparent (self, KConfigBase parent, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
revertToDefault (self, QString key) | |
revertToDefault (self, QString key) | |
sync (self) | |
writeEntry (self, QString key, QVariant value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writeEntry (self, QString key, QVariant value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writeEntry (self, QString key, QString value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writeEntry (self, QString key, QString value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writeEntry (self, QString key, QByteArray value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writeEntry (self, QString key, QByteArray value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writeEntry (self, QString key, QString value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writeEntry (self, QString key, QString value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writeEntry (self, QString key, QStringList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writeEntry (self, QString key, QStringList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writeEntry (self, QString key, QVariantList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writeEntry (self, QString key, QVariantList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writePathEntry (self, QString pKey, QString path, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writePathEntry (self, QString pKey, QString path, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writePathEntry (self, QString pKey, QStringList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writePathEntry (self, QString pKey, QStringList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writeXdgListEntry (self, QString pKey, QStringList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) | |
writeXdgListEntry (self, QString pKey, QStringList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal) |
Method Documentation
__init__ | ( | self ) |
Constructs a null group. A null group is invalid.
- See also:
- isValid
__init__ | ( | self, | ||
KConfigBase | master, | |||
QString | group | |||
) |
Construct a config group corresponding to group in master.
This allows to create subgroups, by passing an existing group as master.
group is the group name encoded in UTF-8.
__init__ | ( | self, | ||
KConfigBase | master, | |||
QString | group | |||
) |
__init__ | ( | self, | ||
KConfigBase | master, | |||
QString | group | |||
) |
Construct a read-only config group. A read-only group will silently ignore any attempts to write to it.
This allows to create subgroups, by passing an existing group as master.
__init__ | ( | self, | ||
KConfigBase | master, | |||
QString | group | |||
) |
__init__ | ( | self, | ||
KSharedConfigPtr | master, | |||
QString | group | |||
) |
__init__ | ( | self, | ||
KSharedConfigPtr | master, | |||
QString | group | |||
) |
__init__ | ( | self, | ||
KConfigGroup | a0 | |||
) |
KConfigBase.AccessMode accessMode | ( | self ) |
changeGroup | ( | self, | ||
QString | group | |||
) |
Changes the group of the object. This is a convenience function and should not be overused. Prefer another object for another group to avoid mixture of groups. A subgroup can only change to another subgroup of the parent.
changeGroup | ( | self, | ||
QString | group | |||
) |
KConfig config | ( | self ) |
Return the config object that this group belongs to.
KConfig config | ( | self ) |
copyTo | ( | self, | ||
KConfigBase | other, | |||
KConfigBase.WriteConfigFlags | pFlags=KConfigBase.Normal | |||
) |
Copies the entries in this group to another config object.
- Parameters:
-
other The other config object to copy this group's entries to. - Note:
- other
- Since:
- 4.1
deleteEntry ( self, QString pKey, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) Deletes the entry specified by pKey in the current group. This also hides system wide defaults.
- Parameters:
-
pKey The key to delete. pFlags The flags to use when deleting this entry.
deleteEntry ( self, QString pKey, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) deleteGroup ( self, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) Delete all entries in the entire group
- Parameters:
-
pFlags flags passed to KConfig.deleteGroup
deleteGroupImpl ( self, QByteArray group, KConfigBase.WriteConfigFlags flags ) QMap entryMap ( self ) Returns a map (tree) of entries for all entries in this group.
Only the actual entry string is returned, none of the other internal data should be included.
- Returns:
- A map of entries in this group, indexed by key.
bool exists ( self ) Check whether the containing KConfig object acutally contains a group with this name.
KConfigGroup groupImpl ( self, QByteArray b ) KConfigGroup groupImpl ( self, QByteArray b ) QStringList groupList ( self ) bool hasDefault ( self, QString key ) Returns whether a default is specified for an entry in either the system wide configuration file or the global KDE config file.
If an application computes a default value at runtime for a certain entry, e.g. like:
QColor computedDefault = qApp->palette().color(QPalette.Active, QPalette.Text) QColor color = config->readEntry(key, computedDefault);
Then it may wish to make the following check before writing back changes:
if ( (value == computedDefault) && !config->hasDefault(key) ) config->revertToDefault(key) else config->writeEntry(key, value)
This ensures that as long as the entry is not modified to differ from the computed default, the application will keep using the computed default and will follow changes the computed default makes over time.
- Parameters:
-
key The key of the entry to check.
bool hasDefault ( self, QString key ) bool hasGroupImpl ( self, QByteArray group ) bool hasKey ( self, QString key ) Checks whether the key has an entry in the currently active group. Use this to determine whether a key is not specified for the current group (hasKey() returns false).
- Parameters:
-
key The key to search for.
- Returns:
- If true, the key is available.
bool hasKey ( self, QString key ) bool isEntryImmutable ( self, QString key ) Checks whether it is possible to change the given entry.
- Parameters:
-
key the key to check
- Returns:
- whether the entry key may be changed in the current group in this configuration file.
bool isEntryImmutable ( self, QString key ) bool isGroupImmutableImpl ( self, QByteArray aGroup ) bool isImmutable ( self ) Checks whether it is possible to change the given group.
- Returns:
- whether changes may be made to this group.
bool isValid ( self ) Returns true if the group is valid; otherwise returns false. A group is invalid if it was constructed without arguments.
You should not call any functions on an invalid group.
QStringList keyList ( self ) Returns a list of keys this group contains.
markAsClean ( self ) QString name ( self ) The name of this group. The root group is named "<default>".
KConfigGroup parent ( self ) Returns the group that this group belongs to, can be invalid if this is a top-level group.
- Since:
- 4.1
Reads the value of an entry specified by key in the current group.
- Parameters:
-
key The key to search for. aDefault A default value returned if the key was not found.
- Returns:
- The value for this key. Can be QVariant() if aDefault is null.
Reads the value of an entry specified by key in the current group. If you want to read a path, please use readPathEntry().
- Parameters:
-
key The key to search for. aDefault A default value returned if the key was not found.
- Returns:
- The value for this key. Can be QString() if aDefault is null.
Reads the value of an entry specified by key in the current group.
- Parameters:
-
key The key to search for. aDefault A default value returned if the key was not found.
- Returns:
- The value for this key. Can be QString() if aDefault is null.
QVariantList readEntry ( self, QString key, QVariantList aDefault ) Reads a list from the config object.
readEntry(const char*, const QList<T>&) const
- Warning:
- This function doesn't convert the items returned to any type. It's actually a list of QVariant.String's. If you want the items converted to a specific type use readEntry(const char*, const QList<T>&) const
QVariantList readEntry ( self, QString key, QVariantList aDefault ) QStringList readEntry ( self, QString key, QStringList aDefault ) Reads a list of strings from the config object.
- Parameters:
-
key The key to search for. aDefault The default value to use if the key does not exist.
- Returns:
- The list. Contains aDefault if key does not exist.
QStringList readEntry ( self, QString key, QStringList aDefault ) Reads the value of an entry specified by pKey in the current group. The untranslated entry is returned, you normally do not need this.
- Parameters:
-
pKey The key to search for. aDefault A default value returned if the key was not found.
- Returns:
- The value for this key.
Reads a path.
Read the value of an entry specified by pKey in the current group and interpret it as a path. This means, dollar expansion is activated for this value, so that e.g. $HOME gets expanded.
- Parameters:
-
pKey The key to search for. aDefault A default value returned if the key was not found.
- Returns:
- The value for this key. Can be QString() if aDefault is null.
QStringList readPathEntry ( self, QString pKey, QStringList aDefault ) Reads a list of string paths.
Read the value of an entry specified by pKey in the current group and interpret it as a list of paths. This means, dollar expansion is activated for this value, so that e.g. $HOME gets expanded.
- Parameters:
-
pKey The key to search for. aDefault A default value returned if the key was not found.
- Returns:
- The list. Empty if the entry does not exist.
QStringList readPathEntry ( self, QString key, QStringList aDefault ) QStringList readXdgListEntry ( self, QString pKey, QStringList aDefault=QStringList() ) Reads a list of strings from the config object, following XDG desktop entry spec separator semantics.
- Parameters:
-
pKey The key to search for. aDefault The default value to use if the key does not exist.
- Returns:
- The list. Contains aDefault if pKey does not exist.
QStringList readXdgListEntry ( self, QString pKey, QStringList aDefault=QStringList() ) reparent ( self, KConfigBase parent, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) Changes the group that this group belongs to.
- Parameters:
-
parent the config object to place this group under. If parent is a KConfig it will be promoted to a top-level group.
- Since:
- 4.1
revertToDefault ( self, QString key ) Reverts the entry with key key in the current group in the application specific config file to either the system wide (default) value or the value specified in the global KDE config file.
To revert entries in the global KDE config file, the global KDE config file should be opened explicitly in a separate config object.
- Parameters:
-
key The key of the entry to revert.
revertToDefault ( self, QString key ) sync ( self ) writeEntry ( self, QString key, QVariant value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) Writes a value to the config object.
- Parameters:
-
key The key to write value The value to write pFlags The flags to use when writing this entry.
writeEntry ( self, QString key, QString value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) Writes a value to the config object.
- Parameters:
-
key The key to write value The value to write pFlags The flags to use when writing this entry.
writeEntry ( self, QString key, QByteArray value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) Writes a value to the config object.
- Parameters:
-
key The key to write value The value to write pFlags The flags to use when writing this entry.
writeEntry ( self, QString key, QByteArray value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) writeEntry ( self, QString key, QString value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) Writes a value to the config object.
- Parameters:
-
key The key to write value The value to write pFlags The flags to use when writing this entry.
writeEntry ( self, QString key, QStringList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) writeEntry() overridden to accept a list of strings.
- Parameters:
-
key The key to write value The list to write pFlags The flags to use when writing this entry.
- See also:
- writeEntry()
writeEntry ( self, QString key, QStringList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) writeEntry ( self, QString key, QVariantList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) writeEntry() overridden to accept a list of QVariant values.
- Parameters:
-
key The key to write value The list to write pFlags The flags to use when writing this entry.
- See also:
- writeEntry()
writeEntry ( self, QString key, QVariantList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) writePathEntry ( self, QString pKey, QString path, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) Writes a file path.
It is checked whether the path is located under $HOME. If so the path is written out with the user's home-directory replaced with $HOME. The path should be read back with readPathEntry()
- Parameters:
-
pKey The key to write. path The path to write. pFlags The flags to use when writing this entry.
writePathEntry ( self, QString pKey, QStringList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) writePathEntry() overridden to accept a list of paths (strings).
It is checked whether the paths are located under $HOME. If so each of the paths are written out with the user's home-directory replaced with $HOME. The paths should be read back with readPathEntry()
- Parameters:
-
pKey The key to write value The list to write pFlags The flags to use when writing this entry.
- See also:
- readPathEntry()
writePathEntry ( self, QString pKey, QStringList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) writeXdgListEntry ( self, QString pKey, QStringList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal ) Writes a list of strings to the config object, following XDG desktop entry spec separator semantics.
- Parameters:
-
pKey The key to write value The list to write pFlags The flags to use when writing this entry.
- See also:
- writeEntry()
writeXdgListEntry ( self, QString pKey, QStringList value, KConfigBase.WriteConfigFlags pFlags=KConfigBase.Normal )