KConfig 5.109.0
Public Member Functions | Protected Attributes | List of all members
KConfigSkeletonGenericItem< T >

Base class for storing a preferences setting of type T. More...

#include <KCoreConfigSkeleton>

Public Member Functions

 KConfigSkeletonGenericItem (const QString &_group, const QString &_key, T &reference, T defaultValue)
 Constructor.
 
void readDefault (KConfig *config) override
 Read global default value.
 
void setDefault () override
 Set the value for this item to the default value.
 
virtual void setDefaultValue (const T &v)
 Set default value for this item.
 
void setValue (const T &v)
 Set value of this KConfigSkeletonItem.
 
void swapDefault () override
 Exchanges the current value with the default value Used by KCoreConfigSkeleton::useDefaults(bool);.
 
T & value ()
 Return value of this KConfigSkeletonItem.
 
const T & value () const
 Return const value of this KConfigSkeletonItem.
 
void writeConfig (KConfig *config) override
 This function is called by KCoreConfigSkeleton to write the value of this setting to a config file.
 
- Public Member Functions inherited from KConfigSkeletonItem
 KConfigSkeletonItem (const QString &_group, const QString &_key)
 Constructor.
 
virtual ~KConfigSkeletonItem ()
 Destructor.
 
KConfigGroup configGroup (KConfig *config) const
 Return a KConfigGroup, the one provided by setGroup(const KConfigGroup&) if it's valid, or make one from config and item's group.
 
QVariant getDefault () const
 Returns the default value.
 
QString group () const
 Return name of config file group.
 
bool isDefault () const
 Indicates if the item is set to its default value.
 
virtual bool isEqual (const QVariant &p) const =0
 Check whether the item is equal to p.
 
bool isImmutable () const
 Return if the entry can be modified.
 
bool isSaveNeeded () const
 Indicates if the item has a different value than the previously loaded value.
 
QString key () const
 Return config file key.
 
QString label () const
 Return the label of the item.
 
virtual QVariant maxValue () const
 Return maximum value of item or invalid if not specified.
 
virtual QVariant minValue () const
 Return minimum value of item or invalid if not specified.
 
QString name () const
 Return internal name of entry.
 
virtual QVariant property () const =0
 Return item as property.
 
virtual void readConfig (KConfig *)=0
 This function is called by KCoreConfigSkeleton to read the value for this setting from a config file.
 
virtual void readDefault (KConfig *)=0
 Read global default value.
 
virtual void setDefault ()=0
 Sets the current value to the default value.
 
void setGroup (const KConfigGroup &cg)
 Set config file group but giving the KConfigGroup.
 
void setGroup (const QString &_group)
 Set config file group.
 
void setKey (const QString &_key)
 Set config file key.
 
void setLabel (const QString &l)
 Set label providing a translated one-line description of the item.
 
void setName (const QString &_name)
 Set internal name of entry.
 
virtual void setProperty (const QVariant &p)=0
 Set item to p.
 
void setToolTip (const QString &t)
 Set ToolTip description of item.
 
void setWhatsThis (const QString &w)
 Set WhatsThis description of item.
 
void setWriteFlags (KConfigBase::WriteConfigFlags flags)
 The write flags to be used when writing configuration.
 
virtual void swapDefault ()=0
 Exchanges the current value with the default value Used by KCoreConfigSkeleton::useDefaults(bool);.
 
QString toolTip () const
 Return ToolTip description of item.
 
QString whatsThis () const
 Return WhatsThis description of item.
 
virtual void writeConfig (KConfig *)=0
 This function is called by KCoreConfigSkeleton to write the value of this setting to a config file.
 
KConfigBase::WriteConfigFlags writeFlags () const
 Return write flags to be used when writing configuration.
 

Protected Attributes

mDefault
 The default value for this item.
 
mLoadedValue
 
T & mReference
 Stores the value for this item.
 
- Protected Attributes inherited from KConfigSkeletonItem
const QString & _group
 
const QString const QString & _key
 
KConfigSkeletonItemPrivate *const d_ptr
 
QString mGroup
 The group name for this item.
 
QString mKey
 The config key for this item.
 
QString mName
 The name of this item.
 

Additional Inherited Members

- Public Types inherited from KConfigSkeletonItem
typedef QHash< QString, KConfigSkeletonItem * > Dict
 
typedef QHash< QString, KConfigSkeletonItem * >::Iterator DictIterator
 
typedef QList< KConfigSkeletonItem * > List
 
- Protected Member Functions inherited from KConfigSkeletonItem
 __attribute__ ((visibility("hidden"))) explicit KConfigSkeletonItem(KConfigSkeletonItemPrivate &dd
 
void readImmutability (const KConfigGroup &group)
 Sets mIsImmutable to true if mKey in config is immutable.
 
void setGetDefaultImpl (const std::function< QVariant()> &impl)
 
void setIsDefaultImpl (const std::function< bool()> &impl)
 
void setIsSaveNeededImpl (const std::function< bool()> &impl)
 

Detailed Description

template<typename T>
class KConfigSkeletonGenericItem< T >

Base class for storing a preferences setting of type T.

Constructor & Destructor Documentation

◆ KConfigSkeletonGenericItem()

template<typename T >
KConfigSkeletonGenericItem< T >::KConfigSkeletonGenericItem ( const QString &  _group,
const QString &  _key,
T &  reference,
defaultValue 
)
inline

Constructor.

Parameters
_groupConfig file group.
_keyConfig file key.
referenceThe initial value to hold in the item
defaultValueThe default value for the item

Member Function Documentation

◆ readDefault()

template<typename T >
void KConfigSkeletonGenericItem< T >::readDefault ( KConfig config)
inlineoverridevirtual

Read global default value.

Implements KConfigSkeletonItem.

◆ setDefault()

template<typename T >
void KConfigSkeletonGenericItem< T >::setDefault ( )
inlineoverridevirtual

Set the value for this item to the default value.

Implements KConfigSkeletonItem.

◆ setDefaultValue()

template<typename T >
virtual void KConfigSkeletonGenericItem< T >::setDefaultValue ( const T &  v)
inlinevirtual

Set default value for this item.

◆ setValue()

template<typename T >
void KConfigSkeletonGenericItem< T >::setValue ( const T &  v)
inline

Set value of this KConfigSkeletonItem.

◆ swapDefault()

template<typename T >
void KConfigSkeletonGenericItem< T >::swapDefault ( )
inlineoverridevirtual

Exchanges the current value with the default value Used by KCoreConfigSkeleton::useDefaults(bool);.

Implements KConfigSkeletonItem.

◆ value() [1/2]

template<typename T >
T & KConfigSkeletonGenericItem< T >::value ( )
inline

Return value of this KConfigSkeletonItem.

◆ value() [2/2]

template<typename T >
const T & KConfigSkeletonGenericItem< T >::value ( ) const
inline

Return const value of this KConfigSkeletonItem.

◆ writeConfig()

template<typename T >
void KConfigSkeletonGenericItem< T >::writeConfig ( KConfig config)
inlineoverridevirtual

This function is called by KCoreConfigSkeleton to write the value of this setting to a config file.

Make sure to pass writeFlags() to every call of KConfigGroup::writeEntry() and KConfigGroup::revertToDefault().

Implements KConfigSkeletonItem.

Member Data Documentation

◆ mDefault

template<typename T >
T KConfigSkeletonGenericItem< T >::mDefault
protected

The default value for this item.

◆ mReference

template<typename T >
T& KConfigSkeletonGenericItem< T >::mReference
protected

Stores the value for this item.