• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • kdecore
  • config
Classes | Macros | Typedefs
kconfiggroup.h File Reference
#include "kconfigbase.h"
#include <kdecore_export.h>
#include <QtCore/QExplicitlySharedDataPointer>
#include <QtCore/QVariant>
#include <QtCore/QStringList>
#include "conversion_check.h"
Include dependency graph for kconfiggroup.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  KConfigGroup
 
class  KSharedPtr< T >
 

Macros

#define KCONFIGGROUP_DECLARE_ENUM_QOBJECT(Class, Enum)
 
#define KCONFIGGROUP_DECLARE_FLAGS_QOBJECT(Class, Flags)
 
#define KCONFIGGROUP_ENUMERATOR_ERROR(ENUM)
 

Typedefs

typedef KSharedPtr< KSharedConfig > KSharedConfigPtr
 

Macro Definition Documentation

#define KCONFIGGROUP_DECLARE_ENUM_QOBJECT (   Class,
  Enum 
)
Value:
inline Class::Enum readEntry(const KConfigGroup& group, const char* key, const Class::Enum& def) \
{ \
const QMetaObject* M_obj = &Class::staticMetaObject; \
const int M_index = M_obj->indexOfEnumerator(#Enum); \
kFatal(M_index == -1) << KCONFIGGROUP_ENUMERATOR_ERROR(#Enum) << endl; \
const QMetaEnum M_enum = M_obj->enumerator(M_index); \
const QByteArray M_data = group.readEntry(key, QByteArray(M_enum.valueToKey(def)));\
return static_cast<Class::Enum>(M_enum.keyToValue(M_data.constData())); \
} \
inline void writeEntry(KConfigGroup& group, const char* key, const Class::Enum& value, KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)\
{ \
const QMetaObject* M_obj = &Class::staticMetaObject; \
const int M_index = M_obj->indexOfEnumerator(#Enum); \
kFatal(M_index == -1) << KCONFIGGROUP_ENUMERATOR_ERROR(#Enum) << endl; \
const QMetaEnum M_enum = M_obj->enumerator(M_index); \
group.writeEntry(key, QByteArray(M_enum.valueToKey(value)), flags); \
}
readEntry
KAutostart::StartPhase readEntry(const KConfigGroup &group, const char *key, const KAutostart::StartPhase &aDefault)
Definition: kautostart.cpp:227
QMetaObject::indexOfEnumerator
int indexOfEnumerator(const char *name) const
QByteArray
KMacroExpander::group
Definition: kmacroexpander_unix.cpp:34
KConfigBase::Normal
Save the entry to the application specific config file without a locale tag.
Definition: kconfigbase.h:59
QMetaObject
QMetaEnum
KConfigGroup
A class for one specific group in a KConfig object.
Definition: kconfiggroup.h:53
kFatal
static QDebug kFatal(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
Definition: kdebug.h:198
KCONFIGGROUP_ENUMERATOR_ERROR
#define KCONFIGGROUP_ENUMERATOR_ERROR(ENUM)
Definition: kconfiggroup.h:661

To add support for your own enums in KConfig, you can declare them with Q_ENUMS() in a QObject subclass (which will make moc generate the code to turn the enum into a string and vice-versa), and then (in the cpp code) use the macro KCONFIGGROUP_DECLARE_ENUM_QOBJECT(MyClass, MyEnum)

After that, you can use readEntry(group, key, value) and writeEntry(group, key, value[, flags]). Note that those are global functions, NOT member functions of KConfigGroup.

Definition at line 676 of file kconfiggroup.h.

#define KCONFIGGROUP_DECLARE_FLAGS_QOBJECT (   Class,
  Flags 
)
Value:
inline Class::Flags readEntry(const KConfigGroup& group, const char* key, const Class::Flags& def) \
{ \
const QMetaObject* M_obj = &Class::staticMetaObject; \
const int M_index = M_obj->indexOfEnumerator(#Flags); \
kFatal(M_index == -1) << KCONFIGGROUP_ENUMERATOR_ERROR(#Flags) << endl; \
const QMetaEnum M_enum = M_obj->enumerator(M_index); \
const QByteArray M_data = group.readEntry(key, QByteArray(M_enum.valueToKeys(def)));\
return static_cast<Class::Flags>(M_enum.keysToValue(M_data.constData())); \
} \
inline void writeEntry(KConfigGroup& group, const char* key, const Class::Flags& value, KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)\
{ \
const QMetaObject* M_obj = &Class::staticMetaObject; \
const int M_index = M_obj->indexOfEnumerator(#Flags); \
kFatal(M_index == -1) << KCONFIGGROUP_ENUMERATOR_ERROR(#Flags) << endl; \
const QMetaEnum M_enum = M_obj->enumerator(M_index); \
group.writeEntry(key, QByteArray(M_enum.valueToKeys(value)), flags); \
}
readEntry
KAutostart::StartPhase readEntry(const KConfigGroup &group, const char *key, const KAutostart::StartPhase &aDefault)
Definition: kautostart.cpp:227
QMetaObject::indexOfEnumerator
int indexOfEnumerator(const char *name) const
QByteArray
KMacroExpander::group
Definition: kmacroexpander_unix.cpp:34
KConfigBase::Normal
Save the entry to the application specific config file without a locale tag.
Definition: kconfigbase.h:59
QMetaObject
QMetaEnum
KConfigGroup
A class for one specific group in a KConfig object.
Definition: kconfiggroup.h:53
kFatal
static QDebug kFatal(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
Definition: kdebug.h:198
KCONFIGGROUP_ENUMERATOR_ERROR
#define KCONFIGGROUP_ENUMERATOR_ERROR(ENUM)
Definition: kconfiggroup.h:661

Similar to KCONFIGGROUP_DECLARE_ENUM_QOBJECT but for flags declared with Q_FLAGS() (where multiple values can be set at the same time)

Definition at line 699 of file kconfiggroup.h.

#define KCONFIGGROUP_ENUMERATOR_ERROR (   ENUM)
Value:
"The Qt MetaObject system does not seem to know about \"" ENUM \
"\" please use Q_ENUMS or Q_FLAGS to register it."

Definition at line 661 of file kconfiggroup.h.

Typedef Documentation

typedef KSharedPtr<KSharedConfig> KSharedConfigPtr

Definition at line 38 of file kconfiggroup.h.

This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:12 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



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