swift
fgswiftbussettings.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2023 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc::simulation::settings, CFGSwiftBusSettings)
7 
8 namespace swift::misc::simulation::settings
9 {
11  {
12  if (index.isMyself()) { return QVariant::fromValue(*this); }
13  const ColumnIndex i = index.frontCasted<ColumnIndex>();
14  switch (i)
15  {
16  case IndexDBusServerAddress: return QVariant::fromValue(m_dBusServerAddress);
17  default: break;
18  }
19  return CValueObject::propertyByIndex(index);
20  }
21 
22  void CFGSwiftBusSettings::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
23  {
24  if (index.isMyself())
25  {
26  (*this) = variant.value<CFGSwiftBusSettings>();
27  return;
28  }
29 
30  const ColumnIndex i = index.frontCasted<ColumnIndex>();
31  switch (i)
32  {
33  case IndexDBusServerAddress: m_dBusServerAddress = variant.toString(); break;
34  default: CValueObject::setPropertyByIndex(index, variant); break;
35  }
36  }
37 
38  QString CFGSwiftBusSettings::convertToQString(bool i18n) const
39  {
40  Q_UNUSED(i18n);
41  return "DBusServer: " + m_dBusServerAddress;
42  }
43 
44 } // 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.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.
Definition: valueobject.h:67