KConfig 5.109.0
|
KConfig variant using shared memory. More...
#include <KSharedConfig>
Public Types | |
typedef QExplicitlySharedDataPointer< KSharedConfig > | Ptr |
![]() | |
enum | OpenFlag { IncludeGlobals = 0x01 , CascadeConfig = 0x02 , SimpleConfig = 0x00 , NoCascade = IncludeGlobals , NoGlobals = CascadeConfig , FullConfig = IncludeGlobals | CascadeConfig } |
Determines how the system-wide and user's global settings will affect the reading of the configuration. More... | |
typedef QFlags< OpenFlag > | OpenFlags |
Stores a combination of #OpenFlag values. | |
![]() | |
enum | AccessMode { NoAccess , ReadOnly , ReadWrite } |
Possible return values for accessMode(). More... | |
enum | WriteConfigFlag { Persistent = 0x01 , Global = 0x02 , Localized = 0x04 , Notify = 0x08 | Persistent , Normal = Persistent } |
Flags to control write entry. More... | |
typedef QFlags< WriteConfigFlag > | WriteConfigFlags |
Stores a combination of #WriteConfigFlag values. | |
Static Public Member Functions | |
static KSharedConfig::Ptr | openConfig (const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation) |
Creates a KSharedConfig object to manipulate a configuration file. | |
static KSharedConfig::Ptr | openStateConfig (const QString &fileName=QString()) |
Creates a KSharedConfig object to manipulate a configuration file suitable for storing state information. | |
![]() | |
static QString | mainConfigName () |
Get the name of application config file. | |
static void | setMainConfigName (const QString &str) |
Sets the name of the application config file. | |
Additional Inherited Members | |
![]() | |
KConfig (const QString &file, const QString &backend, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation) | |
KConfig (const QString &file=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation) | |
Creates a KConfig object to manipulate a configuration file for the current application. | |
void | checkUpdate (const QString &id, const QString &updateFile) |
Ensures that the configuration file contains a certain update. | |
KConfig * | copyTo (const QString &file, KConfig *config=nullptr) const |
Copies all entries from this config object to a new config object that will save itself to file . | |
QMap< QString, QString > | entryMap (const QString &aGroup=QString()) const |
Returns a map (tree) of entries in a particular group. | |
QStringList | groupList () const override |
bool | isDirty () const |
Returns true if sync has any changes to write out. | |
QStandardPaths::StandardLocation | locationType () const |
Returns the standard location enum passed to the constructor. | |
void | markAsClean () override |
QString | name () const |
Returns the filename used to store the configuration. | |
OpenFlags | openFlags () const |
void | reparseConfiguration () |
Updates the state of this object to match the persistent storage. | |
bool | sync () override |
AccessMode | accessMode () const override |
bool | isConfigWritable (bool warnUser) |
Whether the configuration can be written to. | |
void | addConfigSources (const QStringList &sources) |
extra config files | |
QStringList | additionalConfigSources () const |
Returns a list of the additional configuration sources used in this object. | |
QString | locale () const |
locales | |
bool | setLocale (const QString &aLocale) |
Sets the locale to aLocale . | |
void | setReadDefaults (bool b) |
defaults | |
bool | readDefaults () const |
bool | isImmutable () const override |
void | setForceGlobal (bool force) |
global | |
bool | forceGlobal () const |
Returns whether all entries are being written to kdeglobals . | |
![]() | |
virtual | ~KConfigBase () |
Destructs the KConfigBase object. | |
virtual AccessMode | accessMode () const =0 |
Returns the access mode of the app-config object. | |
void | deleteGroup (const char *group, WriteConfigFlags flags=Normal) |
Overload for deleteGroup(const QString&, WriteConfigFlags) | |
void | deleteGroup (const QByteArray &group, WriteConfigFlags flags=Normal) |
Overload for deleteGroup(const QString&, WriteConfigFlags) | |
void | deleteGroup (const QString &group, WriteConfigFlags flags=Normal) |
Delete group . | |
KConfigGroup | group (const char *group) |
Overload for group(const QString&) | |
const KConfigGroup | group (const char *group) const |
Const overload for group(const QString&) | |
KConfigGroup | group (const QByteArray &group) |
Overload for group(const QString&) | |
const KConfigGroup | group (const QByteArray &group) const |
Const overload for group(const QString&) | |
KConfigGroup | group (const QString &group) |
Returns an object for the named subgroup. | |
const KConfigGroup | group (const QString &group) const |
Const overload for group(const QString&) | |
virtual QStringList | groupList () const =0 |
Returns a list of groups that are known about. | |
bool | hasGroup (const char *group) const |
Overload for hasGroup(const QString&) const. | |
bool | hasGroup (const QByteArray &group) const |
Overload for hasGroup(const QString&) const. | |
bool | hasGroup (const QString &group) const |
Returns true if the specified group is known about. | |
bool | isGroupImmutable (const char *group) const |
Overload for isGroupImmutable(const QString&) const. | |
bool | isGroupImmutable (const QByteArray &group) const |
Overload for isGroupImmutable(const QString&) const. | |
bool | isGroupImmutable (const QString &group) const |
Can changes be made to the entries in group ? | |
virtual bool | isImmutable () const =0 |
Checks whether this configuration object can be modified. | |
virtual void | markAsClean ()=0 |
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 sync(). | |
virtual bool | sync ()=0 |
Syncs the configuration object that this group belongs to. | |
![]() | |
__attribute__ ((visibility("hidden"))) explicit KConfig(KConfigPrivate &d) | |
void | deleteGroupImpl (const QByteArray &group, WriteConfigFlags flags=Normal) 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 |
void | virtual_hook (int id, void *data) override |
Virtual hook, used to add new "virtual" functions while maintaining binary compatibility. | |
virtual void | deleteGroupImpl (const QByteArray &group, WriteConfigFlags flags=Normal)=0 |
virtual const KConfigGroup | groupImpl (const QByteArray &group) const =0 |
virtual KConfigGroup | groupImpl (const QByteArray &group)=0 |
virtual bool | hasGroupImpl (const QByteArray &group) const =0 |
virtual bool | isGroupImmutableImpl (const QByteArray &group) const =0 |
virtual void | virtual_hook (int id, void *data) |
Virtual hook, used to add new "virtual" functions while maintaining binary compatibility. | |
![]() | |
KConfigPrivate *const | d_ptr |
KConfig variant using shared memory.
KSharedConfig provides a shared (reference counted) variant of KConfig. This allows you to use/manipulate the same configuration files from different places in your code without worrying about accidentally overwriting changes.
The openConfig() method is threadsafe: every thread gets a separate repository of shared KConfig objects. This means, however, that you'll be responsible for synchronizing the instances of KConfig for the same filename between threads, using KConfig::reparseConfiguration() after a manual change notification, just like you have to do between processes.
|
static |
Creates a KSharedConfig object to manipulate a configuration file.
If an absolute path is specified for fileName
, that file will be used as the store for the configuration settings. If a non-absolute path is provided, the file will be looked for in the standard directory specified by type
. If no path is provided, a default configuration file will be used based on the name of the main application component.
mode
determines whether the user or global settings will be allowed to influence the values returned by this object. See KConfig::OpenFlags for more details.
fileName | the configuration file to open. If empty, it will be determined automatically (from –config on the command line, otherwise from the application name + "rc") |
mode | how global settings should affect the configuration options exposed by this KConfig object |
type | The standard directory to look for the configuration file in (see QStandardPaths) |
|
static |
Creates a KSharedConfig object to manipulate a configuration file suitable for storing state information.
Use this for storing information that is changing frequently and should not be saved by configuration backup utilities.
If an absolute path is specified for fileName
, that file will be used as the store for the configuration settings. If a non-absolute path is provided, the file will be looked for in the standard data directory (QStandardPaths::AppDataLocation). If no path is provided, a default configuration file will be used based on the name of the main application component.
fileName | the configuration file to open. If empty, it will be determined automatically from the application name + "staterc" |