BibleTime
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
BtConfigCore Class Reference

#include <btconfigcore.h>

Inheritance diagram for BtConfigCore:

Public Member Functions

 BtConfigCore (BtConfigCore &&)=default
 
 BtConfigCore (BtConfigCore const &)=default
 
QStringList childGroups () const
 
QStringList childKeys () const
 
template<typename Prefix >
BtConfigCore group (Prefix &&prefix) &&
 
template<typename Prefix >
BtConfigCore group (Prefix &&prefix) const &
 
BtConfigCoreoperator= (BtConfigCore &&)=default
 
BtConfigCoreoperator= (BtConfigCore const &)=default
 
QVariant qVariantValue (QString const &key, QVariant const &defaultValue=QVariant()) const
 Returns the settings value for the given global key as a QVariant. More...
 
void remove (QString const &key)
 removes a key (and its children) from the current group. More...
 
template<typename T >
void setValue (QString const &key, T const &value)
 Sets a value for a key. More...
 
void sync ()
 Synchronizes the configuration to disk. More...
 
template<typename T >
T value (QString const &key, T const &defaultValue=T()) const
 Returns the settings value for the given global key. More...
 
 ~BtConfigCore ()
 

Private Member Functions

 BtConfigCore (std::shared_ptr< QSettings > state, QString groupPrefix=QString())
 
void setValue_ (QString const &key, QVariant value)
 

Private Attributes

QString m_groupPrefix
 Empty or absolute path with trailing slash. More...
 
std::shared_ptr< QSettings > m_state
 

Friends

class BtConfig
 

Detailed Description

Note
Session keys are QStrings because we even want to handle cases where the configuration file is manually changed. When creating new sessions, they are still generated from unsigned integers.

Definition at line 29 of file btconfigcore.h.

Constructor & Destructor Documentation

◆ BtConfigCore() [1/3]

BtConfigCore::BtConfigCore ( BtConfigCore &&  )
default

◆ BtConfigCore() [2/3]

BtConfigCore::BtConfigCore ( BtConfigCore const &  )
default

◆ ~BtConfigCore()

BtConfigCore::~BtConfigCore ( )
default

◆ BtConfigCore() [3/3]

BtConfigCore::BtConfigCore ( std::shared_ptr< QSettings >  state,
QString  groupPrefix = QString() 
)
private

Definition at line 33 of file btconfigcore.cpp.

References BT_ASSERT, BT_DEBUG_ONLY, and m_groupPrefix.

Member Function Documentation

◆ childGroups()

QStringList BtConfigCore::childGroups ( ) const
Returns
a list of first-level groups in the current group.

Definition at line 57 of file btconfigcore.cpp.

References anonymous_namespace{btconfigcore.cpp}::groupGuard(), m_groupPrefix, and m_state.

◆ childKeys()

QStringList BtConfigCore::childKeys ( ) const
Returns
a list of first-level keys in the current group.

Definition at line 50 of file btconfigcore.cpp.

References anonymous_namespace{btconfigcore.cpp}::groupGuard(), m_groupPrefix, and m_state.

◆ group() [1/2]

template<typename Prefix >
BtConfigCore BtConfigCore::group ( Prefix &&  prefix) &&
inline
Parameters
[in]prefixthe prefix to append
Returns
a BtConfigCore object for a subgroup.

Definition at line 101 of file btconfigcore.h.

References m_groupPrefix.

◆ group() [2/2]

template<typename Prefix >
BtConfigCore BtConfigCore::group ( Prefix &&  prefix) const &
inline

◆ operator=() [1/2]

BtConfigCore& BtConfigCore::operator= ( BtConfigCore &&  )
default

◆ operator=() [2/2]

BtConfigCore& BtConfigCore::operator= ( BtConfigCore const &  )
default

◆ qVariantValue()

QVariant BtConfigCore::qVariantValue ( QString const &  key,
QVariant const &  defaultValue = QVariant() 
) const

Returns the settings value for the given global key as a QVariant.

Parameters
[in]keyKey to get the value for.
[in]defaultValueThe value to return if no saved value is found.
Returns
the value.

Definition at line 46 of file btconfigcore.cpp.

References m_groupPrefix, and m_state.

Referenced by BtConfig::getFontForLanguage(), BtBookshelfTreeModel::Grouping::loadFrom(), and value().

◆ remove()

void BtConfigCore::remove ( QString const &  key)

removes a key (and its children) from the current group.

Parameters
[in]keythe key to remove

Definition at line 64 of file btconfigcore.cpp.

References m_groupPrefix, and m_state.

Referenced by BtConfig::deleteSearchScopesWithCurrentLocale(), and BtConfig::deleteSession().

◆ setValue()

template<typename T >
void BtConfigCore::setValue ( QString const &  key,
T const &  value 
)
inline

◆ setValue_()

void BtConfigCore::setValue_ ( QString const &  key,
QVariant  value 
)
private

Definition at line 69 of file btconfigcore.cpp.

References m_groupPrefix, m_state, and value().

Referenced by setValue().

◆ sync()

void BtConfigCore::sync ( )

Synchronizes the configuration to disk.

Definition at line 67 of file btconfigcore.cpp.

References m_state.

Referenced by BibleTime::processCommandline().

◆ value()

template<typename T >
T BtConfigCore::value ( QString const &  key,
T const &  defaultValue = T() 
) const
inline

Friends And Related Function Documentation

◆ BtConfig

friend class BtConfig
friend

Definition at line 31 of file btconfigcore.h.

Referenced by BtConfig::initBtConfig().

Member Data Documentation

◆ m_groupPrefix

QString BtConfigCore::m_groupPrefix
private

Empty or absolute path with trailing slash.

Definition at line 119 of file btconfigcore.h.

Referenced by BtConfigCore(), childGroups(), childKeys(), group(), qVariantValue(), remove(), and setValue_().

◆ m_state

std::shared_ptr<QSettings> BtConfigCore::m_state
private

Definition at line 118 of file btconfigcore.h.

Referenced by childGroups(), childKeys(), group(), qVariantValue(), remove(), setValue_(), and sync().


The documentation for this class was generated from the following files: