KConfigGroup

Search for usage in LXR

#include <KConfigGroup>

Inheritance diagram for KConfigGroup:

Public Member Functions

 KConfigGroup ()
 
 KConfigGroup (const KConfigBase *master, const char *group)
 
 KConfigGroup (const KConfigBase *master, const QString &group)
 
 KConfigGroup (const KConfigGroup &)
 
 KConfigGroup (const QExplicitlySharedDataPointer< KSharedConfig > &master, const char *group)
 
 KConfigGroup (const QExplicitlySharedDataPointer< KSharedConfig > &master, const QString &group)
 
 KConfigGroup (KConfigBase *master, const char *group)
 
 KConfigGroup (KConfigBase *master, const QString &group)
 
AccessMode accessMode () const override
 
void changeGroup (const char *group)
 
void changeGroup (const QString &group)
 
KConfigconfig ()
 
const KConfigconfig () const
 
void copyTo (KConfigBase *other, WriteConfigFlags pFlags=Normal) const
 
void deleteEntry (const char *key, WriteConfigFlags pFlags=Normal)
 
void deleteEntry (const QString &pKey, WriteConfigFlags pFlags=Normal)
 
void deleteGroup (const char *group, WriteConfigFlags flags=Normal)
 
void deleteGroup (const QByteArray &group, WriteConfigFlags flags=Normal)
 
void deleteGroup (const QString &group, WriteConfigFlags flags=Normal)
 
void deleteGroup (WriteConfigFlags pFlags=Normal)
 
QMap< QString, QStringentryMap () const
 
bool exists () const
 
QStringList groupList () const override
 
bool hasDefault (const char *key) const
 
bool hasDefault (const QString &key) const
 
bool hasKey (const char *key) const
 
bool hasKey (const QString &key) const
 
bool isEntryImmutable (const char *key) const
 
bool isEntryImmutable (const QString &key) const
 
bool isImmutable () const override
 
bool isValid () const
 
QStringList keyList () const
 
void markAsClean () override
 
void moveValuesTo (const QList< const char * > &keys, KConfigGroup &other, WriteConfigFlags pFlags=Normal)
 
QString name () const
 
KConfigGroupoperator= (const KConfigGroup &)
 
KConfigGroup parent () const
 
QString readEntry (const char *key, const char *aDefault=nullptr) const
 
template<typename T >
QList< T > readEntry (const char *key, const QList< T > &aDefault) const
 
QString readEntry (const char *key, const QString &aDefault) const
 
QStringList readEntry (const char *key, const QStringList &aDefault) const
 
QVariant readEntry (const char *key, const QVariant &aDefault) const
 
QVariantList readEntry (const char *key, const QVariantList &aDefault) const
 
template<typename T >
readEntry (const char *key, const T &aDefault) const
 
QString readEntry (const QString &key, const char *aDefault=nullptr) const
 
template<typename T >
QList< T > readEntry (const QString &key, const QList< T > &aDefault) const
 
QString readEntry (const QString &key, const QString &aDefault) const
 
QStringList readEntry (const QString &key, const QStringList &aDefault) const
 
QVariant readEntry (const QString &key, const QVariant &aDefault) const
 
QVariantList readEntry (const QString &key, const QVariantList &aDefault) const
 
template<typename T >
readEntry (const QString &key, const T &aDefault) const
 
QString readEntryUntranslated (const char *key, const QString &aDefault=QString()) const
 
QString readEntryUntranslated (const QString &pKey, const QString &aDefault=QString()) const
 
QString readPathEntry (const char *key, const QString &aDefault) const
 
QStringList readPathEntry (const char *key, const QStringList &aDefault) const
 
QString readPathEntry (const QString &pKey, const QString &aDefault) const
 
QStringList readPathEntry (const QString &pKey, const QStringList &aDefault) const
 
QStringList readXdgListEntry (const char *key, const QStringList &aDefault=QStringList()) const
 
QStringList readXdgListEntry (const QString &pKey, const QStringList &aDefault=QStringList()) const
 
void reparent (KConfigBase *parent, WriteConfigFlags pFlags=Normal)
 
void revertToDefault (const char *key)
 
void revertToDefault (const char *key, WriteConfigFlags pFlag)
 
void revertToDefault (const QString &key)
 
void revertToDefault (const QString &key, WriteConfigFlags pFlag)
 
bool sync () override
 
void writeEntry (const char *key, const char *value, WriteConfigFlags pFlags=Normal)
 
void writeEntry (const char *key, const QByteArray &value, WriteConfigFlags pFlags=Normal)
 
template<typename T >
void writeEntry (const char *key, const QList< T > &value, WriteConfigFlags pFlags=Normal)
 
void writeEntry (const char *key, const QString &value, WriteConfigFlags pFlags=Normal)
 
void writeEntry (const char *key, const QStringList &value, WriteConfigFlags pFlags=Normal)
 
void writeEntry (const char *key, const QVariant &value, WriteConfigFlags pFlags=Normal)
 
void writeEntry (const char *key, const QVariantList &value, WriteConfigFlags pFlags=Normal)
 
template<typename T >
void writeEntry (const char *key, const T &value, WriteConfigFlags pFlags=Normal)
 
void writeEntry (const QString &key, const char *value, WriteConfigFlags pFlags=Normal)
 
void writeEntry (const QString &key, const QByteArray &value, WriteConfigFlags pFlags=Normal)
 
template<typename T >
void writeEntry (const QString &key, const QList< T > &value, WriteConfigFlags pFlags=Normal)
 
void writeEntry (const QString &key, const QString &value, WriteConfigFlags pFlags=Normal)
 
void writeEntry (const QString &key, const QStringList &value, WriteConfigFlags pFlags=Normal)
 
void writeEntry (const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
 
void writeEntry (const QString &key, const QVariantList &value, WriteConfigFlags pFlags=Normal)
 
template<typename T >
void writeEntry (const QString &key, const T &value, WriteConfigFlags pFlags=Normal)
 
void writePathEntry (const char *Key, const QString &path, WriteConfigFlags pFlags=Normal)
 
void writePathEntry (const char *key, const QStringList &value, WriteConfigFlags pFlags=Normal)
 
void writePathEntry (const QString &pKey, const QString &path, WriteConfigFlags pFlags=Normal)
 
void writePathEntry (const QString &pKey, const QStringList &value, WriteConfigFlags pFlags=Normal)
 
void writeXdgListEntry (const char *key, const QStringList &value, WriteConfigFlags pFlags=Normal)
 
void writeXdgListEntry (const QString &pKey, const QStringList &value, WriteConfigFlags pFlags=Normal)
 
- Public Member Functions inherited from KConfigBase
virtual ~KConfigBase ()
 
void deleteGroup (const char *group, WriteConfigFlags flags=Normal)
 
void deleteGroup (const QByteArray &group, WriteConfigFlags flags=Normal)
 
void deleteGroup (const QString &group, WriteConfigFlags flags=Normal)
 
KConfigGroup group (const char *group)
 
const KConfigGroup group (const char *group) const
 
KConfigGroup group (const QByteArray &group)
 
const KConfigGroup group (const QByteArray &group) const
 
KConfigGroup group (const QString &group)
 
const KConfigGroup group (const QString &group) const
 
bool hasGroup (const char *group) const
 
bool hasGroup (const QByteArray &group) const
 
bool hasGroup (const QString &group) const
 
bool isGroupImmutable (const char *group) const
 
bool isGroupImmutable (const QByteArray &group) const
 
bool isGroupImmutable (const QString &group) const
 

Protected Member Functions

void deleteGroupImpl (const QByteArray &group, WriteConfigFlags flags) override
 
const KConfigGroup groupImpl (const QByteArray &b) const override
 
KConfigGroup groupImpl (const QByteArray &b) override
 
bool hasGroupImpl (const QByteArray &group) const override
 
bool isGroupImmutableImpl (const QByteArray &aGroup) const override
 
- Protected Member Functions inherited from KConfigBase
virtual void virtual_hook (int id, void *data)
 

Additional Inherited Members

- Public Types inherited from KConfigBase
enum  AccessMode { NoAccess, ReadOnly, ReadWrite }
 
enum  WriteConfigFlag {
  Persistent = 0x01, Global = 0x02, Localized = 0x04, Notify = 0x08 | Persistent,
  Normal = Persistent
}
 
typedef QFlags< WriteConfigFlagWriteConfigFlags
 

Detailed Description

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 will be read-only if it is constructed from a const config object or from another read-only group.

Definition at line 38 of file kconfiggroup.h.

Constructor & Destructor Documentation

◆ KConfigGroup() [1/8]

KConfigGroup::KConfigGroup ( )

Constructs an invalid group.

See also
isValid

Definition at line 449 of file kconfiggroup.cpp.

◆ KConfigGroup() [2/8]

KConfigGroup::KConfigGroup ( KConfigBase master,
const QString group 
)

Construct a config group corresponding to group in master.

This allows the creation of subgroups by passing another group as master.

Parameters
groupname of group

Definition at line 476 of file kconfiggroup.cpp.

◆ KConfigGroup() [3/8]

KConfigGroup::KConfigGroup ( KConfigBase master,
const char *  group 
)

Overload for KConfigGroup(KConfigBase*,const QString&)

Parameters
groupname of group, encoded in UTF-8

Definition at line 481 of file kconfiggroup.cpp.

◆ KConfigGroup() [4/8]

KConfigGroup::KConfigGroup ( const KConfigBase master,
const QString group 
)

Construct a read-only config group.

A read-only group will silently ignore any attempts to write to it.

This allows the creation of subgroups by passing an existing group as master.

Definition at line 486 of file kconfiggroup.cpp.

◆ KConfigGroup() [5/8]

KConfigGroup::KConfigGroup ( const KConfigBase master,
const char *  group 
)

Overload for KConfigGroup(const KConfigBase*,const QString&)

Parameters
groupname of group, encoded in UTF-8

Definition at line 491 of file kconfiggroup.cpp.

◆ KConfigGroup() [6/8]

KConfigGroup::KConfigGroup ( const QExplicitlySharedDataPointer< KSharedConfig > &  master,
const QString group 
)

Overload for KConfigGroup(const KConfigBase*,const QString&)

Definition at line 496 of file kconfiggroup.cpp.

◆ KConfigGroup() [7/8]

KConfigGroup::KConfigGroup ( const QExplicitlySharedDataPointer< KSharedConfig > &  master,
const char *  group 
)

Overload for KConfigGroup(const KConfigBase*,const QString&)

Parameters
groupname of group, encoded in UTF-8

Definition at line 501 of file kconfiggroup.cpp.

◆ KConfigGroup() [8/8]

KConfigGroup::KConfigGroup ( const KConfigGroup rhs)

Creates a copy of a group.

Definition at line 512 of file kconfiggroup.cpp.

Member Function Documentation

◆ accessMode()

KConfigGroup::AccessMode KConfigGroup::accessMode ( ) const
overridevirtual
Reimplemented from superclass.

Implements KConfigBase.

Definition at line 1211 of file kconfiggroup.cpp.

◆ changeGroup() [1/2]

void KConfigGroup::changeGroup ( const char *  group)

Overload for changeGroup(const QString&)

Parameters
groupname of group, encoded in UTF-8
Deprecated:
Since 5.0. Create another KConfigGroup from the parent of this group instead.

Definition at line 581 of file kconfiggroup.cpp.

◆ changeGroup() [2/2]

void KConfigGroup::changeGroup ( const QString group)

Changes the group of the object.

Deprecated:
Since 5.0 Create another KConfigGroup from the parent of this group instead.

Definition at line 572 of file kconfiggroup.cpp.

◆ config() [1/2]

const KConfig * KConfigGroup::config ( )

Return the config object that this group belongs to.

Definition at line 621 of file kconfiggroup.cpp.

◆ config() [2/2]

const KConfig* KConfigGroup::config ( ) const

Return the config object that this group belongs to.

◆ copyTo()

void KConfigGroup::copyTo ( KConfigBase other,
WriteConfigFlags  pFlags = Normal 
) const

Copies the entries in this group to another configuration object.

Note
other can be either another group or a different file.
Parameters
otherthe configuration object to copy this group's entries to
pFlagsthe flags to use when writing the entries to the other configuration object
Since
4.1

Definition at line 1244 of file kconfiggroup.cpp.

◆ deleteEntry() [1/2]

void KConfigGroup::deleteEntry ( const char *  key,
WriteConfigFlags  pFlags = Normal 
)

Overload for deleteEntry(const QString&, WriteConfigFlags)

Parameters
keyname of key, encoded in UTF-8

Definition at line 1116 of file kconfiggroup.cpp.

◆ deleteEntry() [2/2]

void KConfigGroup::deleteEntry ( const QString pKey,
WriteConfigFlags  pFlags = Normal 
)

Deletes the entry specified by pKey in the current group.

This also hides system wide defaults.

Parameters
pKeythe key to delete
pFlagsthe flags to use when deleting this entry
See also
deleteGroup(), readEntry(), writeEntry()

Definition at line 1124 of file kconfiggroup.cpp.

◆ deleteGroup() [1/4]

void KConfigBase::deleteGroup

Overload for deleteGroup(const QString&, WriteConfigFlags)

Parameters
groupname of group to delete, encoded in UTF-8

Definition at line 71 of file kconfigbase.cpp.

◆ deleteGroup() [2/4]

void KConfigBase::deleteGroup

Overload for deleteGroup(const QString&, WriteConfigFlags)

Parameters
groupname of group to delete, encoded in UTF-8

Definition at line 61 of file kconfigbase.cpp.

◆ deleteGroup() [3/4]

void KConfigBase::deleteGroup

Delete group.

This marks group as deleted in the config object. This effectively removes any cascaded values from config files earlier in the stack.

Definition at line 66 of file kconfigbase.cpp.

◆ deleteGroup() [4/4]

void KConfigGroup::deleteGroup ( WriteConfigFlags  pFlags = Normal)

Delete all entries in the entire group.

Parameters
pFlagsflags passed to KConfig::deleteGroup
See also
deleteEntry()

Definition at line 563 of file kconfiggroup.cpp.

◆ deleteGroupImpl()

void KConfigGroup::deleteGroupImpl ( const QByteArray group,
WriteConfigFlags  flags 
)
overrideprotectedvirtual
Parameters
groupname of group, encoded in UTF-8

Implements KConfigBase.

Definition at line 1225 of file kconfiggroup.cpp.

◆ entryMap()

QMap< QString, QString > KConfigGroup::entryMap ( ) const

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

Definition at line 614 of file kconfiggroup.cpp.

◆ exists()

bool KConfigGroup::exists ( ) const

Check whether the containing KConfig object actually contains a group with this name.

Definition at line 596 of file kconfiggroup.cpp.

◆ groupImpl() [1/2]

const KConfigGroup KConfigGroup::groupImpl ( const QByteArray group) const
overrideprotectedvirtual
Parameters
groupname of group, encoded in UTF-8

Implements KConfigBase.

Definition at line 534 of file kconfiggroup.cpp.

◆ groupImpl() [2/2]

KConfigGroup KConfigGroup::groupImpl ( const QByteArray group)
overrideprotectedvirtual
Parameters
groupname of group, encoded in UTF-8

Implements KConfigBase.

Definition at line 522 of file kconfiggroup.cpp.

◆ groupList()

QStringList KConfigGroup::groupList ( ) const
overridevirtual
Reimplemented from superclass.

Implements KConfigBase.

Definition at line 1190 of file kconfiggroup.cpp.

◆ hasDefault() [1/2]

bool KConfigGroup::hasDefault ( const char *  key) const

Overload for hasDefault(const QString&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 1152 of file kconfiggroup.cpp.

◆ hasDefault() [2/2]

bool KConfigGroup::hasDefault ( const QString key) const

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 = group.readEntry(key, computedDefault);

then it may wish to make the following check before writing back changes:

if ( (value == computedDefault) && !group.hasDefault(key) )
else
group.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
keythe key of the entry to check
Returns
true if the global or system settings files specify a default for key in this group, false otherwise

Definition at line 1161 of file kconfiggroup.cpp.

◆ hasGroupImpl()

bool KConfigGroup::hasGroupImpl ( const QByteArray group) const
overrideprotectedvirtual
Parameters
groupname of group, encoded in UTF-8

Implements KConfigBase.

Definition at line 1218 of file kconfiggroup.cpp.

◆ hasKey() [1/2]

bool KConfigGroup::hasKey ( const char *  key) const

Overload for hasKey(const QString&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 1166 of file kconfiggroup.cpp.

◆ hasKey() [2/2]

bool KConfigGroup::hasKey ( const QString key) const

Checks whether the key has an entry in this group.

Use this to determine if a key is not specified for the current group (hasKey() returns false).

If this returns false for a key, readEntry() (and its variants) will return the default value passed to them.

Parameters
keythe key to search for
Returns
true if the key is defined in this group by any of the configuration sources, false otherwise
See also
readEntry()

Definition at line 1178 of file kconfiggroup.cpp.

◆ isEntryImmutable() [1/2]

bool KConfigGroup::isEntryImmutable ( const char *  key) const

Overload for isEntryImmutable(const QString&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 635 of file kconfiggroup.cpp.

◆ isEntryImmutable() [2/2]

bool KConfigGroup::isEntryImmutable ( const QString key) const

Checks if it is possible to change the given entry.

If isImmutable() returns true, then this method will return true for all inputs.

Parameters
keythe key to check
Returns
false if the key may be changed using this configuration group object, true otherwise

Definition at line 642 of file kconfiggroup.cpp.

◆ isGroupImmutableImpl()

bool KConfigGroup::isGroupImmutableImpl ( const QByteArray group) const
overrideprotectedvirtual
Parameters
groupname of group, encoded in UTF-8

Implements KConfigBase.

Definition at line 1233 of file kconfiggroup.cpp.

◆ isImmutable()

bool KConfigGroup::isImmutable ( ) const
overridevirtual

Whether this group may be changed.

Returns
false if the group may be changed, true otherwise

Implements KConfigBase.

Definition at line 1183 of file kconfiggroup.cpp.

◆ isValid()

bool KConfigGroup::isValid ( ) const

Whether the group is valid.

A group is invalid if it was constructed without arguments.

You should not call any functions on an invalid group.

Returns
true if the group is valid, false if it is invalid.

Definition at line 454 of file kconfiggroup.cpp.

◆ keyList()

QStringList KConfigGroup::keyList ( ) const

Returns a list of keys this group contains.

Definition at line 1197 of file kconfiggroup.cpp.

◆ markAsClean()

void KConfigGroup::markAsClean ( )
overridevirtual
Reimplemented from superclass.

Implements KConfigBase.

Definition at line 1204 of file kconfiggroup.cpp.

◆ moveValuesTo()

void KConfigGroup::moveValuesTo ( const QList< const char * > &  keys,
KConfigGroup other,
WriteConfigFlags  pFlags = Normal 
)

Moves the key-value pairs from one config group to the other.

In case the entries do not exist the key is ignored.

Since
5.88

Definition at line 1273 of file kconfiggroup.cpp.

◆ name()

QString KConfigGroup::name ( ) const

The name of this group.

The root group is named "<default>".

Definition at line 589 of file kconfiggroup.cpp.

◆ parent()

KConfigGroup KConfigGroup::parent ( ) const

Returns the group that this group belongs to.

Returns
the parent group, or an invalid group if this is a top-level group
Since
4.1

Definition at line 546 of file kconfiggroup.cpp.

◆ readEntry() [1/14]

QString KConfigGroup::readEntry ( const char *  key,
const char *  aDefault = nullptr 
) const

Overload for readEntry(const QString&, const QString&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 663 of file kconfiggroup.cpp.

◆ readEntry() [2/14]

template<typename T >
QList< T > KConfigGroup::readEntry ( const char *  key,
const QList< T > &  aDefault 
) const

Overload for readEntry<T>(const QString&, const QList<T>&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 829 of file kconfiggroup.h.

◆ readEntry() [3/14]

QString KConfigGroup::readEntry ( const char *  key,
const QString aDefault 
) const

Overload for readEntry(const QString&, const QString&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 673 of file kconfiggroup.cpp.

◆ readEntry() [4/14]

QStringList KConfigGroup::readEntry ( const char *  key,
const QStringList aDefault 
) const

Overload for readEntry(const QString&, const QStringList&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 697 of file kconfiggroup.cpp.

◆ readEntry() [5/14]

QVariant KConfigGroup::readEntry ( const char *  key,
const QVariant aDefault 
) const

Overload for readEntry(const QString&, const QVariant&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 714 of file kconfiggroup.cpp.

◆ readEntry() [6/14]

QVariantList KConfigGroup::readEntry ( const char *  key,
const QVariantList &  aDefault 
) const

Overload for readEntry(const QString&, const QVariantList&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 736 of file kconfiggroup.cpp.

◆ readEntry() [7/14]

template<typename T >
T KConfigGroup::readEntry ( const char *  key,
const T &  aDefault 
) const

Overload for readEntry<T>(const QString&, const T&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 822 of file kconfiggroup.h.

◆ readEntry() [8/14]

QString KConfigGroup::readEntry ( const QString key,
const char *  aDefault = nullptr 
) const

Overload for readEntry(const QString&, const QString&) const.

Definition at line 668 of file kconfiggroup.cpp.

◆ readEntry() [9/14]

template<typename T >
QList<T> KConfigGroup::readEntry ( const QString key,
const QList< T > &  aDefault 
) const
inline

Reads a list of values from the config object.

Parameters
keythe key to search for
aDefaultthe default value to use if the key does not exist
Returns
the list, or aDefault if key does not exist
See also
readXdgListEntry(), writeEntry(), deleteEntry(), hasKey()

Definition at line 352 of file kconfiggroup.h.

◆ readEntry() [10/14]

QString KConfigGroup::readEntry ( const QString key,
const QString aDefault 
) const

Reads the string value of an entry specified by key in the current group.

If you want to read a path, please use readPathEntry().

Parameters
keythe key to search for
aDefaulta default value returned if the key was not found
Returns
the value for this key, or aDefault if the key was not found
See also
readPathEntry(), writeEntry(), deleteEntry(), hasKey()

Definition at line 692 of file kconfiggroup.cpp.

◆ readEntry() [11/14]

QStringList KConfigGroup::readEntry ( const QString key,
const QStringList aDefault 
) const

Reads a list of strings from the config object.

Parameters
keyThe key to search for
aDefaultThe default value to use if the key does not exist
Returns
The list, or aDefault if key does not exist
See also
readXdgListEntry(), writeEntry(), deleteEntry(), hasKey()

Definition at line 709 of file kconfiggroup.cpp.

◆ readEntry() [12/14]

QVariant KConfigGroup::readEntry ( const QString key,
const QVariant aDefault 
) const

Reads the value of an entry specified by key in the current group.

Parameters
keythe key to search for
aDefaulta default value returned if the key was not found
Returns
the value for this key, or aDefault if the key was not found
See also
writeEntry(), deleteEntry(), hasKey()

Definition at line 731 of file kconfiggroup.cpp.

◆ readEntry() [13/14]

QVariantList KConfigGroup::readEntry ( const QString key,
const QVariantList &  aDefault 
) const

Overload for readEntry(const QString&, const QStringList&) const.

Parameters
keyname of key, encoded in UTF-8
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

Definition at line 756 of file kconfiggroup.cpp.

◆ readEntry() [14/14]

template<typename T >
T KConfigGroup::readEntry ( const QString key,
const T &  aDefault 
) const
inline

Reads the value of an entry specified by pKey in the current group.

This template method makes it possible to write QString foo = readEntry("...", QString("default")); and the same with all other types supported by QVariant.

The return type of the method is simply the same as the type of the default value.

Note
readEntry("...", Qt::white) will not compile because Qt::white is an enum. You must turn it into readEntry("...", QColor(Qt::white)).
Only the following QVariant types are allowed : String, StringList, List, Font, Point, Rect, Size, Color, Int, UInt, Bool, Double, LongLong, ULongLong, DateTime and Date.
Parameters
keyThe key to search for
aDefaultA default value returned if the key was not found
Returns
The value for this key, or aDefault.
See also
writeEntry(), deleteEntry(), hasKey()

Definition at line 258 of file kconfiggroup.h.

◆ readEntryUntranslated() [1/2]

QString KConfigGroup::readEntryUntranslated ( const char *  key,
const QString aDefault = QString() 
) const

Overload for readEntryUntranslated(const QString&, const QString&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 652 of file kconfiggroup.cpp.

◆ readEntryUntranslated() [2/2]

QString KConfigGroup::readEntryUntranslated ( const QString pKey,
const QString aDefault = QString() 
) const

Reads an untranslated string entry.

You should not normally need to use this.

Parameters
pKeythe key to search for
aDefaulta default value returned if the key was not found
Returns
the value for this key, or aDefault if the key does not exist

Definition at line 647 of file kconfiggroup.cpp.

◆ readPathEntry() [1/4]

QString KConfigGroup::readPathEntry ( const char *  key,
const QString aDefault 
) const

Overload for readPathEntry(const QString&, const QString&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 806 of file kconfiggroup.cpp.

◆ readPathEntry() [2/4]

QStringList KConfigGroup::readPathEntry ( const char *  key,
const QStringList aDefault 
) const

Overload for readPathEntry(const QString&, const QStringList&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 825 of file kconfiggroup.cpp.

◆ readPathEntry() [3/4]

QString KConfigGroup::readPathEntry ( const QString pKey,
const QString aDefault 
) const

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
pKeyThe key to search for.
aDefaultA default value returned if the key was not found.
Returns
The value for this key. Can be QString() if aDefault is null.

Definition at line 801 of file kconfiggroup.cpp.

◆ readPathEntry() [4/4]

QStringList KConfigGroup::readPathEntry ( const QString pKey,
const QStringList aDefault 
) const

Reads a list of 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
pKeythe key to search for
aDefaulta default value returned if the key was not found
Returns
the list, or aDefault if the key does not exist

Definition at line 820 of file kconfiggroup.cpp.

◆ readXdgListEntry() [1/2]

QStringList KConfigGroup::readXdgListEntry ( const char *  key,
const QStringList aDefault = QStringList() 
) const

Overload for readXdgListEntry(const QString&, const QStringList&) const.

Parameters
keyname of key, encoded in UTF-8

Definition at line 766 of file kconfiggroup.cpp.

◆ readXdgListEntry() [2/2]

QStringList KConfigGroup::readXdgListEntry ( const QString pKey,
const QStringList aDefault = QStringList() 
) const

Reads a list of strings from the config object, following XDG desktop entry spec separator semantics.

Parameters
pKeythe key to search for
aDefaultthe default value to use if the key does not exist
Returns
the list, or aDefault if pKey does not exist
See also
readEntry(const QString&, const QStringList&) const

Definition at line 761 of file kconfiggroup.cpp.

◆ reparent()

void KConfigGroup::reparent ( KConfigBase parent,
WriteConfigFlags  pFlags = Normal 
)

Changes the configuration object that this group belongs to.

Note
other can be another group, the top-level KConfig object or a different KConfig object entirely.

If parent is already the parent of this group, this method will have no effect.

Parameters
parentthe config object to place this group under
pFlagsthe flags to use in determining which storage source to write the data to
Since
4.1

Definition at line 1259 of file kconfiggroup.cpp.

◆ revertToDefault() [1/3]

void KConfigGroup::revertToDefault ( const char *  key)

Overload for revertToDefault(const QString&)

Parameters
keyname of key, encoded in UTF-8

Definition at line 1129 of file kconfiggroup.cpp.

◆ revertToDefault() [2/3]

void KConfigGroup::revertToDefault ( const char *  key,
WriteConfigFlags  pFlag 
)

Overload for revertToDefault(const QString&, WriteConfigFlags)

Parameters
keyname of key, encoded in UTF-8

Definition at line 1134 of file kconfiggroup.cpp.

◆ revertToDefault() [3/3]

void KConfigGroup::revertToDefault ( const QString key)

Reverts an entry to the default settings.

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.

Note
This is not the same as deleting the key, as instead the global setting will be copied to the configuration file that this object manipulates.
Parameters
keyThe key of the entry to revert.

Definition at line 1142 of file kconfiggroup.cpp.

◆ sync()

bool KConfigGroup::sync ( )
overridevirtual
Reimplemented from superclass.

Syncs the parent config.

Implements KConfigBase.

Definition at line 603 of file kconfiggroup.cpp.

◆ writeEntry() [1/16]

void KConfigGroup::writeEntry ( const char *  key,
const char *  value,
WriteConfigFlags  pFlags = Normal 
)

Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)

Parameters
keyname of key, encoded in UTF-8

Definition at line 858 of file kconfiggroup.cpp.

◆ writeEntry() [2/16]

void KConfigGroup::writeEntry ( const char *  key,
const QByteArray value,
WriteConfigFlags  pFlags = Normal 
)

Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)

Parameters
keyname of key, encoded in UTF-8

Definition at line 863 of file kconfiggroup.cpp.

◆ writeEntry() [3/16]

template<typename T >
void KConfigGroup::writeEntry ( const char *  key,
const QList< T > &  value,
WriteConfigFlags  pFlags = Normal 
)

Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)

Parameters
keyname of key, encoded in UTF-8

Definition at line 858 of file kconfiggroup.h.

◆ writeEntry() [4/16]

void KConfigGroup::writeEntry ( const char *  key,
const QString value,
WriteConfigFlags  pFlags = Normal 
)

Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)

Parameters
keyname of key, encoded in UTF-8

Definition at line 837 of file kconfiggroup.cpp.

◆ writeEntry() [5/16]

void KConfigGroup::writeEntry ( const char *  key,
const QStringList value,
WriteConfigFlags  pFlags = Normal 
)

Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)

Parameters
keyname of key, encoded in UTF-8

Definition at line 876 of file kconfiggroup.cpp.

◆ writeEntry() [6/16]

void KConfigGroup::writeEntry ( const char *  key,
const QVariant value,
WriteConfigFlags  pFlags = Normal 
)

Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)

Parameters
keyname of key, encoded in UTF-8

Definition at line 915 of file kconfiggroup.cpp.

◆ writeEntry() [7/16]

void KConfigGroup::writeEntry ( const char *  key,
const QVariantList &  value,
WriteConfigFlags  pFlags = Normal 
)

Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)

Parameters
keyname of key, encoded in UTF-8

Definition at line 896 of file kconfiggroup.cpp.

◆ writeEntry() [8/16]

template<typename T >
void KConfigGroup::writeEntry ( const char *  key,
const T &  value,
WriteConfigFlags  pFlags = Normal 
)

Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)

Parameters
keyname of key, encoded in UTF-8

Definition at line 851 of file kconfiggroup.h.

◆ writeEntry() [9/16]

void KConfigGroup::writeEntry ( const QString key,
const char *  value,
WriteConfigFlags  pFlags = Normal 
)

◆ writeEntry() [10/16]

void KConfigGroup::writeEntry ( const QString key,
const QByteArray value,
WriteConfigFlags  pFlags = Normal 
)

◆ writeEntry() [11/16]

template<typename T >
void KConfigGroup::writeEntry ( const QString key,
const QList< T > &  value,
WriteConfigFlags  pFlags = Normal 
)
inline

◆ writeEntry() [12/16]

void KConfigGroup::writeEntry ( const QString key,
const QString value,
WriteConfigFlags  pFlags = Normal 
)

◆ writeEntry() [13/16]

void KConfigGroup::writeEntry ( const QString key,
const QStringList value,
WriteConfigFlags  pFlags = Normal 
)

◆ writeEntry() [14/16]

void KConfigGroup::writeEntry ( const QString key,
const QVariant value,
WriteConfigFlags  pFlags = Normal 
)

Writes a value to the configuration object.

Parameters
keythe key to write to
valuethe value to write
pFlagsthe flags to use when writing this entry
See also
readEntry(), writeXdgListEntry(), deleteEntry()

Definition at line 1051 of file kconfiggroup.cpp.

◆ writeEntry() [15/16]

void KConfigGroup::writeEntry ( const QString key,
const QVariantList &  value,
WriteConfigFlags  pFlags = Normal 
)

◆ writeEntry() [16/16]

template<typename T >
void KConfigGroup::writeEntry ( const QString key,
const T &  value,
WriteConfigFlags  pFlags = Normal 
)
inline

◆ writePathEntry() [1/4]

void KConfigGroup::writePathEntry ( const char *  Key,
const QString path,
WriteConfigFlags  pFlags = Normal 
)

Overload for writePathEntry(const QString&, const QString&, WriteConfigFlags)

Parameters
keyname of key, encoded in UTF-8

Definition at line 1089 of file kconfiggroup.cpp.

◆ writePathEntry() [2/4]

void KConfigGroup::writePathEntry ( const char *  key,
const QStringList value,
WriteConfigFlags  pFlags = Normal 
)

Overload for writePathEntry(const QString&, const QStringList&, WriteConfigFlags)

Parameters
keyname of key, encoded in UTF-8

Definition at line 1102 of file kconfiggroup.cpp.

◆ writePathEntry() [3/4]

void KConfigGroup::writePathEntry ( const QString pKey,
const QString path,
WriteConfigFlags  pFlags = Normal 
)

Writes a file path to the configuration.

If the path is located under $HOME, the user's home directory is replaced with $HOME in the persistent storage. The path should therefore be read back with readPathEntry()

Parameters
pKeythe key to write to
paththe path to write
pFlagsthe flags to use when writing this entry
See also
writeEntry(), readPathEntry()

Definition at line 1084 of file kconfiggroup.cpp.

◆ writePathEntry() [4/4]

void KConfigGroup::writePathEntry ( const QString pKey,
const QStringList value,
WriteConfigFlags  pFlags = Normal 
)

Writes a list of paths to the configuration.

If any of the paths are located under $HOME, the user's home directory is replaced with $HOME in the persistent storage. The paths should therefore be read back with readPathEntry()

Parameters
pKeythe key to write to
valuethe list to write
pFlagsthe flags to use when writing this entry
See also
writeEntry(), readPathEntry()

Definition at line 1097 of file kconfiggroup.cpp.

◆ writeXdgListEntry() [1/2]

void KConfigGroup::writeXdgListEntry ( const char *  key,
const QStringList value,
WriteConfigFlags  pFlags = Normal 
)

Overload for writeXdgListEntry(const QString&, const QStringList&, WriteConfigFlags)

Parameters
keyname of key, encoded in UTF-8

Definition at line 1066 of file kconfiggroup.cpp.

◆ writeXdgListEntry() [2/2]

void KConfigGroup::writeXdgListEntry ( const QString pKey,
const QStringList value,
WriteConfigFlags  pFlags = Normal 
)

Writes a list of strings to the config object, following XDG desktop entry spec separator semantics.

Parameters
pKeythe key to write to
valuethe list to write
pFlagsthe flags to use when writing this entry
See also
writeEntry(), readXdgListEntry()

Definition at line 1061 of file kconfiggroup.cpp.


The documentation for this class was generated from the following files:
void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
Writes a value to the configuration object.
bool hasDefault(const QString &key) const
Whether a default is specified for an entry in either the system wide configuration file or the globa...
T readEntry(const QString &key, const T &aDefault) const
Reads the value of an entry specified by pKey in the current group.
Definition: kconfiggroup.h:258
void revertToDefault(const QString &key)
Reverts an entry to the default settings.
KConfigGroup group(const QString &group)
Returns an object for the named subgroup.
Definition: kconfigbase.cpp:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Dec 5 2023 04:08:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.