• Skip to content
  • Skip to link menu
Brand

API Documentation

  1. KDE API Reference
  2. The KDE Frameworks
  3. KConfig
  • KDE Home
  • Contact Us

Quick Links

Skip menu "KConfig"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List
  • Dependencies
  • Related Pages

Class Picker

About

Configuration system

Maintainer
Matthew Dawson
Supported platforms
Android, FreeBSD, Linux, MacOSX, Windows
Community
IRC: #kde-devel on Freenode
Mailing list: kde-frameworks-devel
Use with CMake
find_package(KF5Config)
target_link_libraries(yourapp KF5::ConfigCore KF5::ConfigGui)
Use with QMake
QT += KConfigCore KConfigGui 
Clone
git clone git://anongit.kde.org/kconfig.git
Browse source
KConfig on cgit.kde.org

KConfig

  • frameworks
  • frameworks
  • kconfig
  • src
  • core
kconfig.h
1 /*
2  This file is part of the KDE libraries
3  Copyright (c) 2006, 2007 Thomas Braxton <[email protected]>
4  Copyright (c) 2001 Waldo Bastian <[email protected]>
5  Copyright (c) 1999 Preston Brown <[email protected]>
6  Copyright (c) 1997 Matthias Kalle Dalheimer <[email protected]>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 */
23 
24 #ifndef KCONFIG_H
25 #define KCONFIG_H
26 
27 #include "kconfigbase.h"
28 
29 #include <kconfigcore_export.h>
30 
31 #include <QString>
32 #include <QVariant>
33 #include <QByteArray>
34 #include <QList>
35 #include <qstandardpaths.h>
36 
37 class KConfigGroup;
38 class KEntryMap;
39 class KConfigPrivate;
40 
69 class KCONFIGCORE_EXPORT KConfig : public KConfigBase
70 {
71 public:
94  enum OpenFlag {
95  IncludeGlobals = 0x01,
96  CascadeConfig = 0x02,
97 
98  SimpleConfig = 0x00,
99  NoCascade = IncludeGlobals,
100  NoGlobals = CascadeConfig,
101  FullConfig = IncludeGlobals | CascadeConfig
102  };
103  Q_DECLARE_FLAGS(OpenFlags, OpenFlag)
104 
105 
133  explicit KConfig(const QString &file = QString(), OpenFlags mode = FullConfig,
134  QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation);
135 
148  KConfig(const QString &file, const QString &backend, QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation);
149 
150  virtual ~KConfig();
151 
157  QStandardPaths::StandardLocation locationType() const;
158 
162  QString name() const;
163 
168  OpenFlags openFlags() const;
169 
171  bool sync() override;
172 
175  bool isDirty() const;
176 
178  void markAsClean() override;
179 
182  AccessMode accessMode() const override;
183 
202  bool isConfigWritable(bool warnUser);
204 
222  KConfig *copyTo(const QString &file, KConfig *config = nullptr) const;
223 
240  void checkUpdate(const QString &id, const QString &updateFile);
241 
245  void reparseConfiguration();
246 
248 
275  void addConfigSources(const QStringList &sources);
276 
280  QStringList additionalConfigSources() const;
281 
284 
287  QString locale() const;
300  bool setLocale(const QString &aLocale);
302 
304 
313  void setReadDefaults(bool b);
318  bool readDefaults() const;
320 
323  bool isImmutable() const override;
325 
327 #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(4, 0)
328 
336  KCONFIGCORE_DEPRECATED_VERSION(4, 0, "Not recommended")
337  void setForceGlobal(bool force);
338 #endif
339 
340 #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(4, 0)
341 
348  KCONFIGCORE_DEPRECATED_VERSION(4, 0, "Not recommended")
349  bool forceGlobal() const;
350 #endif
351 
354  QStringList groupList() const override;
355 
367  QMap<QString, QString> entryMap(const QString &aGroup = QString()) const;
368 
373  static void setMainConfigName(const QString &str);
374 
375 protected:
376  bool hasGroupImpl(const QByteArray &group) const override;
377  KConfigGroup groupImpl(const QByteArray &b) override;
378  const KConfigGroup groupImpl(const QByteArray &b) const override;
379  void deleteGroupImpl(const QByteArray &group, WriteConfigFlags flags = Normal) override;
380  bool isGroupImmutableImpl(const QByteArray &aGroup) const override;
381 
382  friend class KConfigGroup;
383  friend class KConfigGroupPrivate;
384  friend class KSharedConfig;
385 
389  void virtual_hook(int id, void *data) override;
390 
391  KConfigPrivate *const d_ptr;
392 
393  KConfig(KConfigPrivate &d);
394 
395 private:
396  friend class KConfigTest;
397 
398  QStringList keyList(const QString &aGroup = QString()) const;
399 
403  static QString mainConfigName();
404 
405  Q_DISABLE_COPY(KConfig)
406 
407  Q_DECLARE_PRIVATE(KConfig)
408 };
409 Q_DECLARE_OPERATORS_FOR_FLAGS(KConfig::OpenFlags)
410 
411 #endif // KCONFIG_H
KConfigBase::virtual_hook
virtual void virtual_hook(int id, void *data)
Virtual hook, used to add new "virtual" functions while maintaining binary compatibility.
Definition: kconfigbase.cpp:110
KSharedConfig
KConfig variant using shared memory.
Definition: ksharedconfig.h:44
KEntryMap
Definition: kconfigdata.h:160
QByteArray
QMap< QString, QString >
KConfig::KConfig
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:240
KConfigBase::groupList
virtual QStringList groupList() const =0
Returns a list of groups that are known about.
KConfig::OpenFlag
OpenFlag
Determines how the system-wide and user&#39;s global settings will affect the reading of the configuratio...
Definition: kconfig.h:94
QString
KConfigBase
Interface to interact with configuration.
Definition: kconfigbase.h:43
QStringList
QStandardPaths
KConfigGroup
A class for one specific group in a KConfig object.
Definition: kconfiggroup.h:51
KConfig
The central class of the KDE configuration data system.
Definition: kconfig.h:69
KConfigBase::AccessMode
AccessMode
Possible return values for accessMode().
Definition: kconfigbase.h:143
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Fri Dec 13 2019 02:39:23 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal