LibrePCB Developers Documentation
WorkspaceSettingsItem Class Referenceabstract

Base class for all workspace settings items. More...

#include <workspacesettingsitem.h>

+ Inheritance diagram for WorkspaceSettingsItem:
+ Collaboration diagram for WorkspaceSettingsItem:

Signals

void edited ()
 Signal to notify about changes of the settings value. More...
 

Public Member Functions

 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
 

Protected Member Functions

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...
 

Private Attributes

QString mKey
 Key used for serialization. More...
 
bool mIsDefault
 Setting is at default value. More...
 
bool mEdited
 Edited since last load or save. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ WorkspaceSettingsItem() [1/3]

◆ WorkspaceSettingsItem() [2/3]

WorkspaceSettingsItem ( const QString &  key,
QObject *  parent = nullptr 
)
explicitnoexcept

◆ WorkspaceSettingsItem() [3/3]

WorkspaceSettingsItem ( const WorkspaceSettingsItem other)
delete

◆ ~WorkspaceSettingsItem()

~WorkspaceSettingsItem ( )
virtualnoexcept

Member Function Documentation

◆ getKey()

const QString & getKey ( ) const
inlinenoexcept

Get the setting key used for serialization.

Returns
Serialization key.
+ Here is the caller graph for this function:

◆ isDefaultValue()

bool isDefaultValue ( ) const
inlinenoexcept

Check whether this setting is at its default value (not modified)

Return values
trueDefault is active, value is not stored in settings file.
falseValue has been modified and is stored in settings file.
+ Here is the caller graph for this function:

◆ isEdited()

bool isEdited ( ) const
inlinenoexcept

Check whether this setting was edited sinc the last load or save.

Return values
trueValue has been modified.
falseValue not modified, settings file content is still valid.
+ Here is the caller graph for this function:

◆ restoreDefault()

void restoreDefault ( )
noexcept

Restore default value.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load()

void load ( const SExpression root)

Load value from S-Expression file.

Parameters
rootLoaded librepcb::SExpression node.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

void serialize ( SExpression root) const

Serialize the value into S-Expression nodes.

Parameters
rootS-Expression node to be updated.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

WorkspaceSettingsItem & operator= ( const WorkspaceSettingsItem rhs)
delete

◆ edited

void edited ( )
signal

Signal to notify about changes of the settings value.

+ Here is the caller graph for this function:

◆ valueModified()

void valueModified ( )
protectednoexcept
+ Here is the caller graph for this function:

◆ restoreDefaultImpl()

virtual void restoreDefaultImpl ( )
protectedpure virtualnoexcept

◆ loadImpl()

virtual void loadImpl ( const SExpression root)
protectedpure virtual

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).

Implemented in WorkspaceSettingsItem_GenericValue< T >, WorkspaceSettingsItem_GenericValue< QString >, WorkspaceSettingsItem_GenericValue< librepcb::LengthUnit >, WorkspaceSettingsItem_GenericValue< uint >, WorkspaceSettingsItem_GenericValue< bool >, WorkspaceSettingsItem_GenericValueList< T >, WorkspaceSettingsItem_GenericValueList< QStringList >, WorkspaceSettingsItem_GenericValueList< QList< QUrl > >, WorkspaceSettingsItem_GenericValueList< QSet< QString > >, WorkspaceSettingsItem_KeyboardShortcuts, and WorkspaceSettingsItem_Themes.

+ Here is the caller graph for this function:

◆ serializeImpl()

virtual void serializeImpl ( SExpression root) const
protectedpure virtual

Member Data Documentation

◆ mKey

QString mKey
private

Key used for serialization.

◆ mIsDefault

bool mIsDefault
private

Setting is at default value.

◆ mEdited

bool mEdited
mutableprivate

Edited since last load or save.


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