Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
MantidQt::MantidWidgets::QSettingsChangeAware Class Reference

A QSettings facade that applies only effective changes. More...

#include <QSettingsChangeAware.h>

Public Member Functions

bool changed () const noexcept
 
QSettingsChangeAwareoperator= (QSettingsChangeAware const &)=delete
 
 QSettingsChangeAware ()
 
 QSettingsChangeAware (QSettings &settings)
 
 QSettingsChangeAware (QSettingsChangeAware const &)=delete
 
bool remove (QString const &key)
 Remove a key or group only when it contains a value.
 
bool setValue (QString const &key, QVariant const &value)
 Set a value only when the effective stored value differs.
 

Private Member Functions

bool containsKeyOrChildren (QString const &key)
 

Static Private Member Functions

static bool valuesEqual (QVariant current, QVariant const &requested)
 

Private Attributes

bool m_changed {false}
 
std::unique_ptr< QSettings > m_ownedSettings
 
QSettings & m_settings
 

Detailed Description

A QSettings facade that applies only effective changes.

The default constructor owns a standard QSettings instance. A caller may instead inject a QSettings instance, which remains owned by the caller.

Values are compared after converting the stored value to the requested value's type. This avoids unnecessary writes caused by type information lost by INI storage. An absent key is still written, even when the requested value resembles a caller-side default.

Definition at line 26 of file QSettingsChangeAware.h.

Constructor & Destructor Documentation

◆ QSettingsChangeAware() [1/3]

MantidQt::MantidWidgets::QSettingsChangeAware::QSettingsChangeAware ( )
inline

Definition at line 28 of file QSettingsChangeAware.h.

◆ QSettingsChangeAware() [2/3]

MantidQt::MantidWidgets::QSettingsChangeAware::QSettingsChangeAware ( QSettings &  settings)
inlineexplicit

Definition at line 29 of file QSettingsChangeAware.h.

◆ QSettingsChangeAware() [3/3]

MantidQt::MantidWidgets::QSettingsChangeAware::QSettingsChangeAware ( QSettingsChangeAware const &  )
delete

Member Function Documentation

◆ changed()

bool MantidQt::MantidWidgets::QSettingsChangeAware::changed ( ) const
inlinenoexcept

Definition at line 58 of file QSettingsChangeAware.h.

References m_changed.

◆ containsKeyOrChildren()

bool MantidQt::MantidWidgets::QSettingsChangeAware::containsKeyOrChildren ( QString const &  key)
inlineprivate

Definition at line 72 of file QSettingsChangeAware.h.

References m_settings.

Referenced by remove().

◆ operator=()

QSettingsChangeAware & MantidQt::MantidWidgets::QSettingsChangeAware::operator= ( QSettingsChangeAware const &  )
delete

◆ remove()

bool MantidQt::MantidWidgets::QSettingsChangeAware::remove ( QString const &  key)
inline

Remove a key or group only when it contains a value.

Returns
true when QSettings::remove was called.

Definition at line 49 of file QSettingsChangeAware.h.

References containsKeyOrChildren(), m_changed, and m_settings.

Referenced by MantidQt::MantidWidgets::FitPropertyBrowser::executeCustomSetupRemove(), and MantidQt::API::AbstractAlgorithmInputHistory::saveSettings().

◆ setValue()

bool MantidQt::MantidWidgets::QSettingsChangeAware::setValue ( QString const &  key,
QVariant const &  value 
)
inline

◆ valuesEqual()

static bool MantidQt::MantidWidgets::QSettingsChangeAware::valuesEqual ( QVariant  current,
QVariant const &  requested 
)
inlinestaticprivate

Definition at line 61 of file QSettingsChangeAware.h.

Referenced by setValue().

Member Data Documentation

◆ m_changed

bool MantidQt::MantidWidgets::QSettingsChangeAware::m_changed {false}
private

Definition at line 86 of file QSettingsChangeAware.h.

Referenced by changed(), remove(), and setValue().

◆ m_ownedSettings

std::unique_ptr<QSettings> MantidQt::MantidWidgets::QSettingsChangeAware::m_ownedSettings
private

Definition at line 84 of file QSettingsChangeAware.h.

◆ m_settings

QSettings& MantidQt::MantidWidgets::QSettingsChangeAware::m_settings
private

Definition at line 85 of file QSettingsChangeAware.h.

Referenced by containsKeyOrChildren(), remove(), and setValue().


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