swift
navdatareference.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
7 
8 #include <QtGlobal>
9 
10 SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc::simulation::xplane, CNavDataReference)
11 SWIFT_DEFINE_SEQUENCE_MIXINS(swift::misc::simulation::xplane, CNavDataReference, CNavDataReferenceList)
12 
13 namespace swift::misc::simulation::xplane
14 {
16 
17  CNavDataReference::CNavDataReference(int id, const geo::CLatitude &latitude, const geo::CLongitude &longitude)
18  : m_id(id), m_position(latitude, longitude, {})
19  {}
20 
21  CNavDataReference::CNavDataReference(int id, float latitudeDegrees, float longitudeDegrees)
22  : m_id(id), m_position(latitudeDegrees, longitudeDegrees, 0)
23  {}
24 
26  {
27  if (index.isMyself()) { return QVariant::fromValue(*this); }
28  return ICoordinateGeodetic::canHandleIndex(index) ? ICoordinateGeodetic::propertyByIndex(index) :
30  }
31 
32  void CNavDataReference::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
33  {
34  if (index.isMyself())
35  {
36  (*this) = variant.value<CNavDataReference>();
37  return;
38  }
39  CValueObject::setPropertyByIndex(index, variant);
40  }
41 
42  QString CNavDataReference::convertToQString(bool i18n) const
43  {
44  return QString::number(id()) + ":" + m_position.convertToQString(i18n);
45  }
46 
48 
51  {}
52 } // namespace swift::misc::simulation::xplane
Non-owning reference to a CPropertyIndex with a subset of its features.
bool isMyself() const
Myself index, used with nesting.
QString convertToQString(bool i18n=false) const
Cast as QString.
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
Reference to an entry in X-Plane's navigation data (airport, navaid, fix, etc.) with its position.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QString convertToQString(bool i18n=false) const
Cast as QString.
#define SWIFT_DEFINE_SEQUENCE_MIXINS(Namespace, T, List)
Explicit template definition of mixins for a CSequence subclass.
Definition: sequence.h:63
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.
Definition: valueobject.h:67