mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
refs #247 Using CVariant in property index system.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "aircraftcfgentries.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
@@ -41,24 +42,24 @@ namespace BlackSim
|
||||
/*
|
||||
* Get particular column
|
||||
*/
|
||||
QVariant CAircraftCfgEntries::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CAircraftCfgEntries::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toQVariant(); }
|
||||
if (index.isMyself()) { return this->toCVariant(); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexFilePath:
|
||||
return QVariant(this->m_filePath);
|
||||
return CVariant::from(this->m_filePath);
|
||||
case IndexTitle:
|
||||
return QVariant(this->m_title);
|
||||
return CVariant::from(this->m_title);
|
||||
case IndexAtcType:
|
||||
return QVariant(this->m_atcType);
|
||||
return CVariant::from(this->m_atcType);
|
||||
case IndexAtcModel:
|
||||
return QVariant(this->m_atcModel);
|
||||
return CVariant::from(this->m_atcModel);
|
||||
case IndexParkingCode:
|
||||
return QVariant(this->m_atcParkingCode);
|
||||
return CVariant::from(this->m_atcParkingCode);
|
||||
case IndexEntryIndex:
|
||||
return QVariant(this->m_index);
|
||||
return CVariant::from(this->m_index);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -67,29 +68,29 @@ namespace BlackSim
|
||||
/*
|
||||
* Set property as index
|
||||
*/
|
||||
void CAircraftCfgEntries::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CAircraftCfgEntries::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself()) { this->convertFromQVariant(variant); return; }
|
||||
if (index.isMyself()) { this->convertFromCVariant(variant); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAtcModel:
|
||||
this->setAtcModel(variant.toString());
|
||||
this->setAtcModel(variant.toQString());
|
||||
break;
|
||||
case IndexAtcType:
|
||||
this->setAtcType(variant.toString());
|
||||
this->setAtcType(variant.toQString());
|
||||
break;
|
||||
case IndexEntryIndex:
|
||||
this->setIndex(variant.toInt());
|
||||
break;
|
||||
case IndexFilePath:
|
||||
this->setFilePath(variant.toString());
|
||||
this->setFilePath(variant.toQString());
|
||||
break;
|
||||
case IndexParkingCode:
|
||||
this->setAtcParkingCode(variant.toString());
|
||||
this->setAtcParkingCode(variant.toQString());
|
||||
break;
|
||||
case IndexTitle:
|
||||
this->setTitle(variant.toString());
|
||||
this->setTitle(variant.toQString());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#define BLACKSIM_FSCOMMON_AIRCRAFTCFGENTRY_H
|
||||
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include <QVariant>
|
||||
|
||||
namespace BlackSim
|
||||
{
|
||||
@@ -89,10 +88,10 @@ namespace BlackSim
|
||||
void setAtcParkingCode(const QString &parkingCode) { this->m_atcParkingCode = parkingCode; }
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
virtual void setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
virtual void setPropertyByIndex(const BlackMisc::CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
|
||||
@@ -104,30 +104,30 @@ namespace BlackSim
|
||||
/*
|
||||
* Get column
|
||||
*/
|
||||
QVariant CAircraftMapping::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CAircraftMapping::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toQVariant(); }
|
||||
if (index.isMyself()) { return this->toCVariant(); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexMappingId:
|
||||
return QVariant(this->m_mappingId);
|
||||
return CVariant::from(this->m_mappingId);
|
||||
case IndexProposalId:
|
||||
return QVariant(m_proposalId);
|
||||
return CVariant::from(m_proposalId);
|
||||
case IndexAircraftKey:
|
||||
return QVariant(m_fsAircraftKey);
|
||||
return CVariant::from(m_fsAircraftKey);
|
||||
case IndexAircraftDesignator:
|
||||
return QVariant(m_aircraftDesignator);
|
||||
return CVariant::from(m_aircraftDesignator);
|
||||
case IndexAirlineDesignator:
|
||||
return QVariant(m_airlineDesignator);
|
||||
return CVariant::from(m_airlineDesignator);
|
||||
case IndexAircraftCombinedType:
|
||||
return QVariant(m_aircraftCombinedType);
|
||||
return CVariant::from(m_aircraftCombinedType);
|
||||
case IndexWakeTurbulenceCategory:
|
||||
return QVariant(m_wakeTurbulenceCategory);
|
||||
return CVariant::from(m_wakeTurbulenceCategory);
|
||||
case IndexAirlineColor:
|
||||
return QVariant(this->m_aircraftColor);
|
||||
return CVariant::from(this->m_aircraftColor);
|
||||
case IndexLastChanged:
|
||||
return QVariant(this->getLastChangedFormatted());
|
||||
return CVariant::from(this->getLastChangedFormatted());
|
||||
case IndexSimulatorInfo:
|
||||
return this->m_simulatorInfo.propertyByIndex(index.copyFrontRemoved());
|
||||
default:
|
||||
@@ -138,47 +138,39 @@ namespace BlackSim
|
||||
/*
|
||||
* Set column's value
|
||||
*/
|
||||
void CAircraftMapping::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CAircraftMapping::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexMappingId:
|
||||
{
|
||||
bool ok = false;
|
||||
qint32 id = variant.toInt(&ok);
|
||||
this->m_mappingId = ok ? id : CAircraftMapping::InvalidId;
|
||||
}
|
||||
this->m_mappingId = variant.valueOrDefault<qint32>(CAircraftMapping::InvalidId);
|
||||
break;
|
||||
case IndexProposalId:
|
||||
{
|
||||
bool ok = false;
|
||||
qint32 id = variant.toInt(&ok);
|
||||
this->m_proposalId = ok ? id : CAircraftMapping::InvalidId;
|
||||
}
|
||||
this->m_proposalId = variant.valueOrDefault<qint32>(CAircraftMapping::InvalidId);
|
||||
break;
|
||||
case IndexAircraftKey:
|
||||
m_fsAircraftKey = variant.toString();
|
||||
m_fsAircraftKey = variant.toQString();
|
||||
break;
|
||||
case IndexAircraftDesignator:
|
||||
this->setAircraftDesignator(variant.toString());
|
||||
this->setAircraftDesignator(variant.toQString());
|
||||
break;
|
||||
case IndexAirlineDesignator:
|
||||
this->setAirlineDesignator(variant.toString());
|
||||
this->setAirlineDesignator(variant.toQString());
|
||||
break;
|
||||
case IndexAircraftCombinedType:
|
||||
this->setAircraftCombinedType(variant.toString());
|
||||
this->setAircraftCombinedType(variant.toQString());
|
||||
break;
|
||||
case IndexWakeTurbulenceCategory:
|
||||
this->setWakeTurbulenceCategory(variant.toString());
|
||||
this->setWakeTurbulenceCategory(variant.toQString());
|
||||
break;
|
||||
case IndexAirlineColor:
|
||||
this->m_aircraftColor = variant.toString();
|
||||
this->m_aircraftColor = variant.toQString();
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "aircraftcfgentries.h"
|
||||
#include "blacksim/simulatorinfo.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include <QVariant>
|
||||
#include <QDateTime>
|
||||
|
||||
namespace BlackSim
|
||||
@@ -141,10 +140,10 @@ namespace BlackSim
|
||||
void setSimulatorText(const QString &simulator);
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex()
|
||||
void setPropertyByIndex(const QVariant &value, const BlackMisc::CPropertyIndex &index) override;
|
||||
void setPropertyByIndex(const BlackMisc::CVariant &value, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! \copydoc CValueObject::getValueHash()
|
||||
virtual uint getValueHash() const override;
|
||||
|
||||
Reference in New Issue
Block a user