swift
Loading...
Searching...
No Matches
modelsettings.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#include "misc/stringutils.h"
7
8SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc::simulation::settings, CModelSettings)
9
10namespace swift::misc::simulation::settings
11{
13 {
14 Q_UNUSED(i18n);
15 return QStringLiteral("Allow exclude: %1").arg(boolToYesNo(this->m_allowExcludeModels));
16 }
17
19 {
20 if (index.isMyself())
21 {
22 return QVariant::fromValue(*this);
23 }
24 const auto i = index.frontCasted<ColumnIndex>();
25 switch (i)
26 {
27 case IndexAllowExclude: return QVariant::fromValue(this->m_allowExcludeModels);
28 default: return CValueObject::propertyByIndex(index);
29 }
30 }
31
33 {
34 if (index.isMyself())
35 {
36 (*this) = variant.value<CModelSettings>();
37 return;
38 }
39 const auto i = index.frontCasted<ColumnIndex>();
40 switch (i)
41 {
42 case IndexAllowExclude: this->setAllowExcludedModels(variant.toBool()); break;
43 default: CValueObject::setPropertyByIndex(index, variant); break;
44 }
45 }
46} // namespace swift::misc::simulation::settings
Non-owning reference to a CPropertyIndex with a subset of its features.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
Definition mixinindex.h:167
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Definition mixinindex.h:180
QString convertToQString(bool i18n=false) const
Cast as QString.
CModelSettings()=default
Default constructor.
void setAllowExcludedModels(bool allow)
Allow excluded models?
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
SWIFT_MISC_EXPORT const QString & boolToYesNo(bool v)
Bool to yes/no.
QVariant fromValue(T &&value)
bool toBool() const const
T value() const &const
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.
Definition valueobject.h:67