20#ifndef LIBREPCB_CORE_WORKSPACESETTINGSITEM_GENERICVALUELIST_H
21#define LIBREPCB_CORE_WORKSPACESETTINGSITEM_GENERICVALUELIST_H
45template <
typename T,
bool SerializeRaw = false>
54 const QString& listKey,
const QString& itemKey,
const T& defaultValue,
55 QObject* parent =
nullptr) noexcept
76 bool contains(
const typename T::value_type& item)
const noexcept {
85 void set(
const T& value)
noexcept {
97 void add(
const typename T::value_type& item)
noexcept {
127 values << deserialize<typename T::value_type>(*child);
129 values << deserialize<typename T::value_type>(child->
getChild(
"@0"));
142 T
makeCanonical(
const QList<typename T::value_type>& value)
const noexcept {
154 const QSet<typename T::value_type>& value)
const noexcept {
The LogicError class.
Definition exceptions.h:181
The SExpression class.
Definition sexpression.h:69
QList< SExpression * > getChildren(Type type) noexcept
Definition sexpression.cpp:94
void ensureLineBreak()
Definition sexpression.cpp:206
SExpression & getChild(int index)
Definition sexpression.cpp:86
void appendChild(std::unique_ptr< SExpression > child)
Definition sexpression.cpp:217
Generic implementation of librepcb::WorkspaceSettingsItem for simple, value-in-list-type settings.
Definition workspacesettingsitem_genericvaluelist.h:47
void loadImpl(const SExpression &root) override
Load value from S-Expression node.
Definition workspacesettingsitem_genericvaluelist.h:123
T mCurrentValue
Current value.
Definition workspacesettingsitem_genericvaluelist.h:180
QList< typename T::value_type > makeCanonical(const QSet< typename T::value_type > &value) const noexcept
Helper for serialization of QSet.
Definition workspacesettingsitem_genericvaluelist.h:153
~WorkspaceSettingsItem_GenericValueList() noexcept
Definition workspacesettingsitem_genericvaluelist.h:60
void add(const typename T::value_type &item) noexcept
Add a single item to the value list.
Definition workspacesettingsitem_genericvaluelist.h:97
WorkspaceSettingsItem_GenericValueList(const QString &listKey, const QString &itemKey, const T &defaultValue, QObject *parent=nullptr) noexcept
Definition workspacesettingsitem_genericvaluelist.h:53
void set(const T &value) noexcept
Set the value.
Definition workspacesettingsitem_genericvaluelist.h:85
T makeCanonical(const QList< typename T::value_type > &value) const noexcept
Helper for serialization of QList.
Definition workspacesettingsitem_genericvaluelist.h:142
QString mItemKey
Inner key used for serialization.
Definition workspacesettingsitem_genericvaluelist.h:178
T mDefaultValue
Initial, default value.
Definition workspacesettingsitem_genericvaluelist.h:179
WorkspaceSettingsItem_GenericValueList(const WorkspaceSettingsItem_GenericValueList &other)=delete
WorkspaceSettingsItem_GenericValueList & operator=(const WorkspaceSettingsItem_GenericValueList &rhs)=delete
bool contains(const typename T::value_type &item) const noexcept
Check if the current value contains a praticular item.
Definition workspacesettingsitem_genericvaluelist.h:76
void serializeImpl(SExpression &root) const override
Serialize the value into S-Expression node.
Definition workspacesettingsitem_genericvaluelist.h:161
const T & getDefault() const noexcept
Get the default value.
Definition workspacesettingsitem_genericvaluelist.h:108
const T & get() const noexcept
Get the current value.
Definition workspacesettingsitem_genericvaluelist.h:67
virtual void restoreDefaultImpl() noexcept override
Restore default value.
Definition workspacesettingsitem_genericvaluelist.h:118
WorkspaceSettingsItem_GenericValueList()=delete
Base class for all workspace settings items.
Definition workspacesettingsitem.h:49
void valueModified() noexcept
Definition workspacesettingsitem.cpp:48
Definition occmodel.cpp:77
std::unique_ptr< SExpression > serialize(const AttributeKey &obj)
Definition attributekey.h:94