swift
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 
8 SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc::simulation::settings, CModelSettings)
9 
10 namespace 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()) { return QVariant::fromValue(*this); }
21  const auto i = index.frontCasted<ColumnIndex>();
22  switch (i)
23  {
24  case IndexAllowExclude: return QVariant::fromValue(this->m_allowExcludeModels);
25  default: return CValueObject::propertyByIndex(index);
26  }
27  }
28 
30  {
31  if (index.isMyself())
32  {
33  (*this) = variant.value<CModelSettings>();
34  return;
35  }
36  const auto i = index.frontCasted<ColumnIndex>();
37  switch (i)
38  {
39  case IndexAllowExclude: this->setAllowExcludedModels(variant.toBool()); break;
40  default: CValueObject::setPropertyByIndex(index, variant); break;
41  }
42  }
43 } // 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.
ColumnIndex
Base class enums.
Definition: mixinindex.h:44
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
Definition: mixinindex.h:158
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Definition: mixinindex.h:165
QString convertToQString(bool i18n=false) const
Cast as QString.
void setAllowExcludedModels(bool allow)
Allow excluded models?
Definition: modelsettings.h:35
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