swift
launchersetup.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2017 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 using namespace swift::misc;
9 
11 
12 namespace swift::core::data
13 {
14  QString CLauncherSetup::convertToQString(bool i18n) const
15  {
16  Q_UNUSED(i18n)
17  return QStringLiteral("DBus: %1 frameless: %2 mode: %3")
18  .arg(m_dBusAddress, boolToYesNo(m_windowFrameless))
19  .arg(m_coreMode);
20  }
21 
22  QVariant CLauncherSetup::propertyByIndex(swift::misc::CPropertyIndexRef index) const
23  {
24  if (index.isMyself()) { return QVariant::fromValue(*this); }
25  const ColumnIndex i = index.frontCasted<ColumnIndex>();
26  switch (i)
27  {
28  case IndexDBusAddress: return QVariant::fromValue(m_dBusAddress);
29  case IndexFramelessWindow: return QVariant::fromValue(m_windowFrameless);
30  case IndexCoreMode: return QVariant::fromValue(m_coreMode);
31  case IndexAudioMode: return QVariant::fromValue(m_audioMode);
32  default: return CValueObject::propertyByIndex(index);
33  }
34  }
35 
36  void CLauncherSetup::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
37  {
38  if (index.isMyself())
39  {
40  (*this) = variant.value<CLauncherSetup>();
41  return;
42  }
43  const ColumnIndex i = index.frontCasted<ColumnIndex>();
44  switch (i)
45  {
46  case IndexDBusAddress: this->setDBusAddress(variant.toString()); break;
47  case IndexFramelessWindow: m_windowFrameless = variant.toBool(); break;
48  case IndexCoreMode: m_coreMode = variant.toInt(); break;
49  case IndexAudioMode: m_audioMode = variant.toInt(); break;
50  default: CValueObject::setPropertyByIndex(index, variant); break;
51  }
52  }
53 } // namespace swift::core::data
ColumnIndex
Properties by index.
Definition: launchersetup.h:25
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:160
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Definition: mixinindex.h:167
Core data traits (aka cached values) and classes.
Free functions in swift::misc.
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