mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
refs #314, new propertyBy methods (nested indexes)
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "blackmisc/aviocomsystem.h"
|
||||
#include "blackmisc/avionavsystem.h"
|
||||
#include "blackmisc/avioadfsystem.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
|
||||
using BlackMisc::PhysicalQuantities::CFrequency;
|
||||
@@ -55,6 +56,64 @@ namespace BlackMisc
|
||||
BlackMisc::deserializeJson(json, CModulator::jsonMembers(), TupleConverter<CModulator>::toTuple(*this));
|
||||
}
|
||||
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
template <class AVIO> QVariant CModulator<AVIO>::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toQVariant(); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexActiveFrequency:
|
||||
return this->getFrequencyActive().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexStandbyFrequency:
|
||||
return this->getFrequencyStandby().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexEnabled:
|
||||
return QVariant(this->isEnabled());
|
||||
case IndexInputVolume:
|
||||
return QVariant(this->getVolumeInput());
|
||||
case IndexOutputVolume:
|
||||
return QVariant(this->getVolumeOutput());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
template <class AVIO> void CModulator<AVIO>::setPropertyByIndex(const QVariant &variant, const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->fromQVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexActiveFrequency:
|
||||
this->m_frequencyActive.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexStandbyFrequency:
|
||||
this->m_frequencyStandby.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexEnabled:
|
||||
this->setEnabled(variant.toBool());
|
||||
break;
|
||||
case IndexInputVolume:
|
||||
this->setVolumeInput(variant.toInt());
|
||||
break;
|
||||
case IndexOutputVolume:
|
||||
this->setVolumeOutput(variant.toInt());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Members
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user