KConfig

kconfig.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton <[email protected]>
4  SPDX-FileCopyrightText: 2001 Waldo Bastian <[email protected]>
5  SPDX-FileCopyrightText: 1999 Preston Brown <[email protected]>
6  SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer <[email protected]>
7 
8  SPDX-License-Identifier: LGPL-2.0-or-later
9 */
10 
11 #ifndef KCONFIG_H
12 #define KCONFIG_H
13 
14 #include "kconfigbase.h"
15 
16 #include <kconfigcore_export.h>
17 
18 #include <QString>
19 #include <QVariant>
20 #include <QByteArray>
21 #include <QList>
22 #include <QStandardPaths>
23 
24 class KConfigGroup;
25 class KEntryMap;
26 class KConfigPrivate;
27 
56 class KCONFIGCORE_EXPORT KConfig : public KConfigBase
57 {
58 public:
82  enum OpenFlag {
83  IncludeGlobals = 0x01,
84  CascadeConfig = 0x02,
85 
86  SimpleConfig = 0x00,
87  NoCascade = IncludeGlobals,
88  NoGlobals = CascadeConfig,
89  FullConfig = IncludeGlobals | CascadeConfig
90  };
94  Q_DECLARE_FLAGS(OpenFlags, OpenFlag)
95 
96 
124  explicit KConfig(const QString &file = QString(), OpenFlags mode = FullConfig,
125  QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation);
126 
139  KConfig(const QString &file, const QString &backend, QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation);
140 
141  virtual ~KConfig();
142 
148  QStandardPaths::StandardLocation locationType() const;
149 
153  QString name() const;
154 
159  OpenFlags openFlags() const;
160 
162  bool sync() override;
163 
166  bool isDirty() const;
167 
169  void markAsClean() override;
170 
173  AccessMode accessMode() const override;
174 
193  bool isConfigWritable(bool warnUser);
195 
213  KConfig *copyTo(const QString &file, KConfig *config = nullptr) const;
214 
231  void checkUpdate(const QString &id, const QString &updateFile);
232 
236  void reparseConfiguration();
237 
239 
266  void addConfigSources(const QStringList &sources);
267 
271  QStringList additionalConfigSources() const;
272 
275 
278  QString locale() const;
291  bool setLocale(const QString &aLocale);
293 
295 
304  void setReadDefaults(bool b);
309  bool readDefaults() const;
311 
314  bool isImmutable() const override;
316 
318 #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(4, 0)
319 
327  KCONFIGCORE_DEPRECATED_VERSION(4, 0, "Not recommended")
328  void setForceGlobal(bool force);
329 #endif
330 
331 #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(4, 0)
332 
339  KCONFIGCORE_DEPRECATED_VERSION(4, 0, "Not recommended")
340  bool forceGlobal() const;
341 #endif
342 
345  QStringList groupList() const override;
346 
358  QMap<QString, QString> entryMap(const QString &aGroup = QString()) const;
359 
364  static void setMainConfigName(const QString &str);
365 
366 protected:
367  bool hasGroupImpl(const QByteArray &group) const override;
368  KConfigGroup groupImpl(const QByteArray &b) override;
369  const KConfigGroup groupImpl(const QByteArray &b) const override;
370  void deleteGroupImpl(const QByteArray &group, WriteConfigFlags flags = Normal) override;
371  bool isGroupImmutableImpl(const QByteArray &aGroup) const override;
372 
373  friend class KConfigGroup;
374  friend class KConfigGroupPrivate;
375  friend class KSharedConfig;
376 
380  void virtual_hook(int id, void *data) override;
381 
382  KConfigPrivate *const d_ptr;
383 
384  KConfig(KConfigPrivate &d);
385 
386 private:
387  friend class KConfigTest;
388 
389  QStringList keyList(const QString &aGroup = QString()) const;
390 
394  static QString mainConfigName();
395 
396  Q_DISABLE_COPY(KConfig)
397 
398  Q_DECLARE_PRIVATE(KConfig)
399 };
400 Q_DECLARE_OPERATORS_FOR_FLAGS(KConfig::OpenFlags)
401 
402 #endif // KCONFIG_H
virtual void virtual_hook(int id, void *data)
Virtual hook, used to add new "virtual" functions while maintaining binary compatibility.
Definition: kconfigbase.cpp:97
KConfig variant using shared memory.
Definition: ksharedconfig.h:31
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.
Definition: kconfig.cpp:238
virtual QStringList groupList() const =0
Returns a list of groups that are known about.
OpenFlag
Determines how the system-wide and user&#39;s global settings will affect the reading of the configuratio...
Definition: kconfig.h:82
virtual bool hasGroupImpl(const QByteArray &group) const =0
Interface to interact with configuration.
Definition: kconfigbase.h:30
virtual void deleteGroupImpl(const QByteArray &group, WriteConfigFlags flags=Normal)=0
A class for one specific group in a KConfig object.
Definition: kconfiggroup.h:38
The central class of the KDE configuration data system.
Definition: kconfig.h:56
AccessMode
Possible return values for accessMode().
Definition: kconfigbase.h:175
virtual KConfigGroup groupImpl(const QByteArray &group)=0
virtual bool isGroupImmutableImpl(const QByteArray &group) const =0
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 13 2020 22:48:14 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.