KConfigBase Class
Interface to interact with configuration. More...
| Header: | #include <KConfigBase> |
| CMake: | find_package(KF6 REQUIRED COMPONENTS Config)target_link_libraries(mytarget PRIVATE KF6::ConfigCore) |
| Inherited By: | KConfig and KConfigGroup |
Public Types
| enum | AccessMode { NoAccess, ReadOnly, ReadWrite } |
| enum | WriteConfigFlag { Persistent, Global, Localized, Notify, Normal } |
| flags | WriteConfigFlags |
Public Functions
| virtual KConfigBase::AccessMode | accessMode() const = 0 |
| void | deleteGroup(const QString &group, KConfigBase::WriteConfigFlags flags = Normal) |
| KConfigGroup | group(const QString &group) |
| const KConfigGroup | group(const QString &group) const |
| virtual QStringList | groupList() const = 0 |
| bool | hasGroup(const QString &group) const |
| bool | isGroupImmutable(const QString &group) const |
| virtual bool | isImmutable() const = 0 |
| virtual void | markAsClean() = 0 |
(since 6.33) void | syncLater() |
(since 6.33) bool | syncNow() |
Detailed Description
KConfigBase allows a component of an application to persists its configuration without the component knowing if it is storing the configuration into a top level KConfig or a KConfigGroup inside a KConfig instance.
Member Type Documentation
enum KConfigBase::AccessMode
Possible return values for accessMode().
| Constant | Value |
|---|---|
KConfigBase::NoAccess | 0 |
KConfigBase::ReadOnly | 1 |
KConfigBase::ReadWrite | 2 |
enum KConfigBase::WriteConfigFlag
flags KConfigBase::WriteConfigFlags
Flags to control write entry
| Constant | Value | Description |
|---|---|---|
KConfigBase::Persistent | 0x01 | Save this entry when saving the config object. |
KConfigBase::Global | 0x02 | Save the entry to the global KDE config file instead of the application specific config file. |
KConfigBase::Localized | 0x04 | Add the locale tag to the key when writing it. |
KConfigBase::Notify (since 5.51) | 0x08 | Persistent | Notifies remote KConfigWatchers of changes (requires DBus support). Implies Persistent. |
KConfigBase::Normal | Persistent | Save the entry to the application specific config file without a locale tag. This is the default. |
The WriteConfigFlags type is a typedef for QFlags<WriteConfigFlag>. It stores an OR combination of WriteConfigFlag values.
See also KConfigGroup, KConfigWatcher, and KConfigSkeletonItem::setWriteFlags().
Member Function Documentation
[pure virtual] KConfigBase::AccessMode KConfigBase::accessMode() const
Returns the access mode of the app-config object.
Possible return values are NoAccess (the application-specific config file could not be opened neither read-write nor read-only), ReadOnly (the application-specific config file is opened read-only, but not read-write) and ReadWrite (the application-specific config file is opened read-write).
void KConfigBase::deleteGroup(const QString &group, KConfigBase::WriteConfigFlags flags = Normal)
Delete group.
This marks group as deleted in the config object. This effectively removes any cascaded values from config files earlier in the stack.
KConfigGroup KConfigBase::group(const QString &group)
Returns an object for the named subgroup.
group the group to open. Pass an empty string here to the KConfig object to obtain a handle on the root group. Returns config group object for the given group name.
const KConfigGroup KConfigBase::group(const QString &group) const
Const overload for group(const QString&)
This is an overloaded function.
[pure virtual] QStringList KConfigBase::groupList() const
Returns a list of groups that are known about.
bool KConfigBase::hasGroup(const QString &group) const
Returns true if the specified group is known about.
group name of group to search for
bool KConfigBase::isGroupImmutable(const QString &group) const
Can changes be made to the entries in group?
group The group to check for immutability.
Returns false if the entries in group can be modified, otherwise true
[pure virtual] bool KConfigBase::isImmutable() const
Checks whether this configuration object can be modified.
[pure virtual] void KConfigBase::markAsClean()
Reset the dirty flags of all entries in the entry map, so the values will not be written to disk on a later call to syncNow() or syncLater().
[since 6.33] void KConfigBase::syncLater()
Writes all pending changes to disk on a background thread and returns immediately.
See KConfig::syncLater() for details.
This function was introduced in 6.33.
[since 6.33] bool KConfigBase::syncNow()
Writes all pending config changes to disk synchronously and returns whether it succeeded.
This function was introduced in 6.33.