mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +08:00
194 lines
6.1 KiB
C++
194 lines
6.1 KiB
C++
/* Copyright (C) 2013
|
|
* swift project Community / Contributors
|
|
*
|
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
* contained in the LICENSE file.
|
|
*/
|
|
|
|
#include "aircraftcfgentries.h"
|
|
#include "blackmisc/blackmiscfreefunctions.h"
|
|
|
|
using namespace BlackMisc;
|
|
|
|
namespace BlackSim
|
|
{
|
|
namespace FsCommon
|
|
{
|
|
|
|
/*
|
|
* Constructor
|
|
*/
|
|
CAircraftCfgEntries::CAircraftCfgEntries(const QString &filePath, qint32 index, const QString &title, const QString &atcType, const QString &atcModel, const QString &atcParkingCode) :
|
|
m_index(index), m_filePath(filePath), m_title(title), m_atcType(atcType),
|
|
m_atcModel(atcModel), m_atcParkingCode(atcParkingCode)
|
|
{
|
|
// void
|
|
}
|
|
|
|
/*
|
|
* Operator ==
|
|
*/
|
|
bool CAircraftCfgEntries::operator ==(const CAircraftCfgEntries &other) const
|
|
{
|
|
if (this == &other) return true;
|
|
return TupleConverter<CAircraftCfgEntries>::toTuple(*this) == TupleConverter<CAircraftCfgEntries>::toTuple(other);
|
|
}
|
|
|
|
/*
|
|
* Operator !=
|
|
*/
|
|
bool CAircraftCfgEntries::operator !=(const CAircraftCfgEntries &other) const
|
|
{
|
|
if (this == &other) return false;
|
|
return !((*this) == other);
|
|
}
|
|
|
|
/*
|
|
* String representation
|
|
*/
|
|
QString CAircraftCfgEntries::convertToQString(bool) const
|
|
{
|
|
QString s = "{%1, %2, %3, %4, %5, %6}";
|
|
s = s.arg(this->m_filePath).arg(this->m_index).arg(this->m_title)
|
|
.arg(this->m_atcModel).arg(this->m_atcType).arg(this->m_atcParkingCode);
|
|
return s;
|
|
}
|
|
|
|
/*
|
|
* Get particular column
|
|
*/
|
|
QVariant CAircraftCfgEntries::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
|
{
|
|
if (index.isMyself()) { return this->toQVariant(); }
|
|
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
|
switch (i)
|
|
{
|
|
case IndexFilePath:
|
|
return QVariant(this->m_filePath);
|
|
case IndexTitle:
|
|
return QVariant(this->m_title);
|
|
case IndexAtcType:
|
|
return QVariant(this->m_atcType);
|
|
case IndexAtcModel:
|
|
return QVariant(this->m_atcModel);
|
|
case IndexParkingCode:
|
|
return QVariant(this->m_atcParkingCode);
|
|
case IndexEntryIndex:
|
|
return QVariant(this->m_index);
|
|
default:
|
|
return CValueObject::propertyByIndex(index);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Set property as index
|
|
*/
|
|
void CAircraftCfgEntries::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
|
{
|
|
if (index.isMyself()) { this->fromQVariant(variant); return; }
|
|
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
|
switch (i)
|
|
{
|
|
case IndexAtcModel:
|
|
this->setAtcModel(variant.toString());
|
|
break;
|
|
case IndexAtcType:
|
|
this->setAtcType(variant.toString());
|
|
break;
|
|
case IndexEntryIndex:
|
|
this->setIndex(variant.toInt());
|
|
break;
|
|
case IndexFilePath:
|
|
this->setFilePath(variant.toString());
|
|
break;
|
|
case IndexParkingCode:
|
|
this->setAtcParkingCode(variant.toString());
|
|
break;
|
|
case IndexTitle:
|
|
this->setTitle(variant.toString());
|
|
break;
|
|
default:
|
|
CValueObject::setPropertyByIndex(variant, index);
|
|
break;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Hash
|
|
*/
|
|
uint CAircraftCfgEntries::getValueHash() const
|
|
{
|
|
return qHash(TupleConverter<CAircraftCfgEntries>::toTuple(*this));
|
|
}
|
|
|
|
/*
|
|
* Register metadata
|
|
*/
|
|
void CAircraftCfgEntries::registerMetadata()
|
|
{
|
|
qRegisterMetaType<CAircraftCfgEntries>();
|
|
qDBusRegisterMetaType<CAircraftCfgEntries>();
|
|
}
|
|
|
|
/*
|
|
* Compare
|
|
*/
|
|
int CAircraftCfgEntries::compareImpl(const CValueObject &otherBase) const
|
|
{
|
|
const auto &other = static_cast<const CAircraftCfgEntries &>(otherBase);
|
|
return compare(TupleConverter<CAircraftCfgEntries>::toTuple(*this), TupleConverter<CAircraftCfgEntries>::toTuple(other));
|
|
}
|
|
|
|
/*
|
|
* Metatype
|
|
*/
|
|
int CAircraftCfgEntries::getMetaTypeId() const
|
|
{
|
|
return qMetaTypeId<CAircraftCfgEntries>();
|
|
}
|
|
|
|
/*
|
|
* Marshall to DBus
|
|
*/
|
|
void CAircraftCfgEntries::marshallToDbus(QDBusArgument &argument) const
|
|
{
|
|
argument << TupleConverter<CAircraftCfgEntries>::toTuple(*this);
|
|
}
|
|
|
|
/*
|
|
* Unmarshall from DBus
|
|
*/
|
|
void CAircraftCfgEntries::unmarshallFromDbus(const QDBusArgument &argument)
|
|
{
|
|
argument >> TupleConverter<CAircraftCfgEntries>::toTuple(*this);
|
|
}
|
|
|
|
/*
|
|
* To JSON
|
|
*/
|
|
QJsonObject CAircraftCfgEntries::toJson() const
|
|
{
|
|
return BlackMisc::serializeJson(CAircraftCfgEntries::jsonMembers(), TupleConverter<CAircraftCfgEntries>::toTuple(*this));
|
|
}
|
|
|
|
/*
|
|
* To JSON
|
|
*/
|
|
void CAircraftCfgEntries::fromJson(const QJsonObject &json)
|
|
{
|
|
BlackMisc::deserializeJson(json, CAircraftCfgEntries::jsonMembers(), TupleConverter<CAircraftCfgEntries>::toTuple(*this));
|
|
}
|
|
|
|
/*
|
|
* Members
|
|
*/
|
|
const QStringList &CAircraftCfgEntries::jsonMembers()
|
|
{
|
|
return TupleConverter<CAircraftCfgEntries>::jsonMembers();
|
|
}
|
|
|
|
}
|
|
} // namespace
|