LibrePCB Developers Documentation
WorkspaceSettingsItem_GenericValueList< T > Class Template Referencefinal

Generic implementation of librepcb::WorkspaceSettingsItem for simple, value-in-list-type settings. More...

#include <workspacesettingsitem_genericvaluelist.h>

+ Inheritance diagram for WorkspaceSettingsItem_GenericValueList< T >:
+ Collaboration diagram for WorkspaceSettingsItem_GenericValueList< T >:

Public Member Functions

 WorkspaceSettingsItem_GenericValueList ()=delete
 
 WorkspaceSettingsItem_GenericValueList (const WorkspaceSettingsItem_GenericValueList &other)=delete
 
 WorkspaceSettingsItem_GenericValueList (const QString &listKey, const QString &itemKey, const T &defaultValue, QObject *parent=nullptr) noexcept
 
 ~WorkspaceSettingsItem_GenericValueList () noexcept
 
const T & get () const noexcept
 Get the current value. More...
 
bool contains (const typename T::value_type &item) const noexcept
 Check if the current value contains a praticular item. More...
 
void set (const T &value) noexcept
 Set the value. More...
 
void add (const typename T::value_type &item) noexcept
 Add a single item to the value list. More...
 
const T & getDefault () const noexcept
 Get the default value. More...
 
WorkspaceSettingsItem_GenericValueListoperator= (const WorkspaceSettingsItem_GenericValueList &rhs)=delete
 
- Public Member Functions inherited from WorkspaceSettingsItem
 WorkspaceSettingsItem ()=delete
 
 WorkspaceSettingsItem (const QString &key, QObject *parent=nullptr) noexcept
 
 WorkspaceSettingsItem (const WorkspaceSettingsItem &other)=delete
 
virtual ~WorkspaceSettingsItem () noexcept
 
const QString & getKey () const noexcept
 Get the setting key used for serialization. More...
 
bool isDefaultValue () const noexcept
 Check whether this setting is at its default value (not modified) More...
 
bool isEdited () const noexcept
 Check whether this setting was edited sinc the last load or save. More...
 
void restoreDefault () noexcept
 Restore default value. More...
 
void load (const SExpression &root)
 Load value from S-Expression file. More...
 
void serialize (SExpression &root) const
 Serialize the value into S-Expression nodes. More...
 
WorkspaceSettingsItemoperator= (const WorkspaceSettingsItem &rhs)=delete
 

Private Member Functions

virtual void restoreDefaultImpl () noexcept override
 Restore default value. More...
 
void loadImpl (const SExpression &root) override
 Load value from S-Expression node. More...
 
makeCanonical (const QList< typename T::value_type > &value) const noexcept
 Helper for serialization of QList. More...
 
QList< typename T::value_type > makeCanonical (const QSet< typename T::value_type > &value) const noexcept
 Helper for serialization of QSet. More...
 
void serializeImpl (SExpression &root) const override
 Serialize the value into S-Expression node. More...
 

Private Attributes

QString mItemKey
 Inner key used for serialization. More...
 
mDefaultValue
 Initial, default value. More...
 
mCurrentValue
 Current value. More...
 

Additional Inherited Members

- Signals inherited from WorkspaceSettingsItem
void edited ()
 Signal to notify about changes of the settings value. More...
 
- Protected Member Functions inherited from WorkspaceSettingsItem
void valueModified () noexcept
 
virtual void restoreDefaultImpl () noexcept=0
 Restore default value. More...
 
virtual void loadImpl (const SExpression &root)=0
 Load value from S-Expression node. More...
 
virtual void serializeImpl (SExpression &root) const =0
 Serialize the value into S-Expression node. More...
 

Detailed Description

template<typename T>
class librepcb::WorkspaceSettingsItem_GenericValueList< T >

Generic implementation of librepcb::WorkspaceSettingsItem for simple, value-in-list-type settings.

Constructor & Destructor Documentation

◆ WorkspaceSettingsItem_GenericValueList() [1/3]

◆ WorkspaceSettingsItem_GenericValueList() [2/3]

◆ WorkspaceSettingsItem_GenericValueList() [3/3]

WorkspaceSettingsItem_GenericValueList ( const QString &  listKey,
const QString &  itemKey,
const T &  defaultValue,
QObject *  parent = nullptr 
)
inlineexplicitnoexcept

◆ ~WorkspaceSettingsItem_GenericValueList()

Member Function Documentation

◆ get()

const T & get ( ) const
inlinenoexcept

Get the current value.

Returns
Current value
+ Here is the caller graph for this function:

◆ contains()

bool contains ( const typename T::value_type &  item) const
inlinenoexcept

Check if the current value contains a praticular item.

Parameters
itemItem to check.
Returns
Whether the item is contained in the current value or not.

◆ set()

void set ( const T &  value)
inlinenoexcept

Set the value.

Parameters
valueThe new value
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add()

void add ( const typename T::value_type &  item)
inlinenoexcept

Add a single item to the value list.

Parameters
itemThe item to append (list) or insert (unordered set)
+ Here is the call graph for this function:

◆ getDefault()

const T & getDefault ( ) const
inlinenoexcept

Get the default value.

Returns
Default value

◆ operator=()

◆ restoreDefaultImpl()

virtual void restoreDefaultImpl ( )
inlineoverrideprivatevirtualnoexcept

Restore default value.

Note
Implementation must emit the edited() signal if the value has changed.

Implements WorkspaceSettingsItem.

+ Here is the call graph for this function:

◆ loadImpl()

void loadImpl ( const SExpression root)
inlineoverrideprivatevirtual

Load value from S-Expression node.

Parameters
rootS-Expression node of the settings element.
Note
Implementation must emit the edited() signal if the value has changed.
Implementation must be atomic, i.e. either the value must be loaded completely from file, or left at the old value (in case of errors).

Implements WorkspaceSettingsItem.

+ Here is the call graph for this function:

◆ makeCanonical() [1/2]

T makeCanonical ( const QList< typename T::value_type > &  value) const
inlineprivatenoexcept

Helper for serialization of QList.

Parameters
valueQList to serialize.
Returns
Unmodified value.
+ Here is the caller graph for this function:

◆ makeCanonical() [2/2]

QList< typename T::value_type > makeCanonical ( const QSet< typename T::value_type > &  value) const
inlineprivatenoexcept

Helper for serialization of QSet.

Parameters
valueQSet to serialize.
Returns
QSet as a sorted QList.
+ Here is the call graph for this function:

◆ serializeImpl()

void serializeImpl ( SExpression root) const
inlineoverrideprivatevirtual

Serialize the value into S-Expression node.

Parameters
rootS-Expression node to be updated.

Implements WorkspaceSettingsItem.

+ Here is the call graph for this function:

Member Data Documentation

◆ mItemKey

QString mItemKey
private

Inner key used for serialization.

◆ mDefaultValue

T mDefaultValue
private

Initial, default value.

◆ mCurrentValue

T mCurrentValue
private

Current value.


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