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  QString CModelSettings::convertToQString(bool i18n) const
15  {
16  Q_UNUSED(i18n);
17  return QStringLiteral("Allow exclude: %1").arg(boolToYesNo(this->m_allowExcludeModels));
18  }
19 
21  {
22  if (index.isMyself()) { return QVariant::fromValue(*this); }
23  const ColumnIndex i = index.frontCasted<ColumnIndex>();
24  switch (i)
25  {
26  case IndexAllowExclude: return QVariant::fromValue(this->m_allowExcludeModels);
27  default: return CValueObject::propertyByIndex(index);
28  }
29  }
30 
31  void CModelSettings::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
32  {
33  if (index.isMyself())
34  {
35  (*this) = variant.value<CModelSettings>();
36  return;
37  }
38  const ColumnIndex i = index.frontCasted<ColumnIndex>();
39  switch (i)
40  {
41  case IndexAllowExclude: this->setAllowExcludedModels(variant.toBool()); break;
42  default: CValueObject::setPropertyByIndex(index, variant); break;
43  }
44  }
45 } // 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:160
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Definition: mixinindex.h:167
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.
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.
Definition: valueobject.h:67