mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 07:35:53 +08:00
refs #247 Using CVariant in property index system.
This commit is contained in:
@@ -129,9 +129,9 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant CAircraft::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CAircraft::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)
|
||||
{
|
||||
@@ -161,11 +161,11 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index (setter)
|
||||
*/
|
||||
void CAircraft::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CAircraft::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
|
||||
@@ -224,10 +224,10 @@ namespace BlackMisc
|
||||
void initTransponder();
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString()
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "avaircrafticao.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <tuple>
|
||||
#include <QRegularExpression>
|
||||
@@ -65,22 +66,22 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant CAircraftIcao::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CAircraftIcao::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 IndexAircraftDesignator:
|
||||
return QVariant::fromValue(this->m_aircraftDesignator);
|
||||
return CVariant::fromValue(this->m_aircraftDesignator);
|
||||
case IndexAirlineDesignator:
|
||||
return QVariant::fromValue(this->m_airlineDesignator);
|
||||
return CVariant::fromValue(this->m_airlineDesignator);
|
||||
case IndexCombinedAircraftType:
|
||||
return QVariant::fromValue(this->m_aircraftCombinedType);
|
||||
return CVariant::fromValue(this->m_aircraftCombinedType);
|
||||
case IndexAircraftColor:
|
||||
return QVariant::fromValue(this->m_aircraftColor);
|
||||
return CVariant::fromValue(this->m_aircraftColor);
|
||||
case IndexAsString:
|
||||
return QVariant::fromValue(this->asString());
|
||||
return CVariant::fromValue(this->asString());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -89,11 +90,11 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
void CAircraftIcao::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CAircraftIcao::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -130,10 +130,10 @@ namespace BlackMisc
|
||||
bool matchesWildcardIcao(const CAircraftIcao &otherIcao) const;
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! Valid designator?
|
||||
static bool isValidDesignator(const QString &designator);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "avaircraftsituation.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
@@ -37,9 +38,9 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant CAircraftSituation::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CAircraftSituation::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)
|
||||
{
|
||||
@@ -60,26 +61,26 @@ namespace BlackMisc
|
||||
case IndexGroundspeed:
|
||||
return this->m_groundspeed.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexTimeStamp:
|
||||
return QVariant::fromValue(this->m_timestamp);
|
||||
return CVariant::fromValue(this->m_timestamp);
|
||||
case IndexTimeStampFormatted:
|
||||
return QVariant::fromValue(this->m_groundspeed.toQString("dd hh:mm:ss"));
|
||||
return CVariant::fromValue(this->m_groundspeed.toQString("dd hh:mm:ss"));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Q_ASSERT_X(false, "CAircraftSituation", "index unknown");
|
||||
QString m = QString("no property, index ").append(index.toQString());
|
||||
return QVariant::fromValue(m);
|
||||
return CVariant::fromValue(m);
|
||||
}
|
||||
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
void CAircraftSituation::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CAircraftSituation::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,10 +57,10 @@ namespace BlackMisc
|
||||
m_bank(bank), m_groundspeed(gs), m_timestamp(QDateTime::currentDateTimeUtc()) {}
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! Get position
|
||||
const BlackMisc::Geo::CCoordinateGeodetic &getPosition() const { return this->m_position; }
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "avairport.h"
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include "propertyindex.h"
|
||||
#include "variant.h"
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Geo;
|
||||
@@ -79,16 +80,16 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant CAirport::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CAirport::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 IndexIcao:
|
||||
return this->m_icao.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexDescriptiveName:
|
||||
return QVariant(this->m_descriptiveName);
|
||||
return CVariant(this->m_descriptiveName);
|
||||
case IndexPosition:
|
||||
return this->m_position.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexElevation:
|
||||
@@ -105,17 +106,17 @@ namespace BlackMisc
|
||||
|
||||
Q_ASSERT_X(false, "CAirport", "index unknown");
|
||||
QString m = QString("no property, index ").append(index.toQString());
|
||||
return QVariant::fromValue(m);
|
||||
return CVariant::fromValue(m);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set property as index
|
||||
*/
|
||||
void CAirport::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CAirport::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
@@ -125,7 +126,7 @@ namespace BlackMisc
|
||||
this->m_icao.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexDescriptiveName:
|
||||
this->setDescriptiveName(variant.toString());
|
||||
this->setDescriptiveName(variant.toQString());
|
||||
break;
|
||||
case IndexPosition:
|
||||
this->m_position.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
|
||||
@@ -110,10 +110,10 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "icon.h"
|
||||
#include "propertyindex.h"
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include "variant.h"
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Geo;
|
||||
@@ -233,16 +234,16 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant CAtcStation::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CAtcStation::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 IndexBookedFrom:
|
||||
return QVariant(this->m_bookedFromUtc);
|
||||
return CVariant::from(this->m_bookedFromUtc);
|
||||
case IndexBookedUntil:
|
||||
return QVariant(this->m_bookedUntilUtc);
|
||||
return CVariant::from(this->m_bookedUntilUtc);
|
||||
case IndexCallsign:
|
||||
return this->m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexController:
|
||||
@@ -250,7 +251,7 @@ namespace BlackMisc
|
||||
case IndexFrequency:
|
||||
return this->m_frequency.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexIsOnline:
|
||||
return QVariant(this->m_isOnline);
|
||||
return CVariant::from(this->m_isOnline);
|
||||
case IndexLatitude:
|
||||
return this->latitude().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexDistance:
|
||||
@@ -266,7 +267,7 @@ namespace BlackMisc
|
||||
case IndexMetar:
|
||||
return this->m_metar.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexVoiceRoom:
|
||||
return QVariant(this->m_voiceRoom.propertyByIndex(index.copyFrontRemoved()));
|
||||
return this->m_voiceRoom.propertyByIndex(index.copyFrontRemoved());
|
||||
default:
|
||||
if (ICoordinateGeodetic::canHandleIndex(index)) { return ICoordinateGeodetic::propertyByIndex(index); }
|
||||
return CValueObject::propertyByIndex(index);
|
||||
@@ -276,9 +277,9 @@ namespace BlackMisc
|
||||
/*
|
||||
* Set property as index
|
||||
*/
|
||||
void CAtcStation::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CAtcStation::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)
|
||||
{
|
||||
|
||||
@@ -255,10 +255,10 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
virtual void setPropertyByIndex(const QVariant &variant, const CPropertyIndex &index) override;
|
||||
virtual void setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index) override;
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
|
||||
@@ -82,18 +82,18 @@ namespace BlackMisc
|
||||
/*
|
||||
* Index
|
||||
*/
|
||||
QVariant CCallsign::propertyByIndex(const CPropertyIndex &index) const
|
||||
CVariant CCallsign::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toQVariant(); }
|
||||
if (index.isMyself()) { return this->toCVariant(); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCallsignString:
|
||||
return QVariant(this->asString());
|
||||
return CVariant(this->asString());
|
||||
case IndexCallsignStringAsSet:
|
||||
return QVariant(this->getStringAsSet());
|
||||
return CVariant(this->getStringAsSet());
|
||||
case IndexTelephonyDesignator:
|
||||
return QVariant(this->getTelephonyDesignator());
|
||||
return CVariant(this->getTelephonyDesignator());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -102,24 +102,24 @@ namespace BlackMisc
|
||||
/*
|
||||
* Index
|
||||
*/
|
||||
void CCallsign::setPropertyByIndex(const QVariant &variant, const CPropertyIndex &index)
|
||||
void CCallsign::setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCallsignString:
|
||||
this->m_callsign = variant.toString();
|
||||
this->m_callsign = variant.toQString();
|
||||
break;
|
||||
case IndexCallsignStringAsSet:
|
||||
this->m_callsignAsSet = variant.toString();
|
||||
this->m_callsignAsSet = variant.toQString();
|
||||
break;
|
||||
case IndexTelephonyDesignator:
|
||||
this->m_telephonyDesignator = variant.toString();
|
||||
this->m_telephonyDesignator = variant.toQString();
|
||||
break;
|
||||
default:
|
||||
return CValueObject::setPropertyByIndex(variant, index);
|
||||
|
||||
@@ -70,10 +70,10 @@ namespace BlackMisc
|
||||
virtual BlackMisc::CIcon toIcon() const override { return convertToIcon(*this); }
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! Valid callsign?
|
||||
static bool isValidCallsign(const QString &callsign);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "blackmisc/avioadfsystem.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
using BlackMisc::PhysicalQuantities::CFrequency;
|
||||
using BlackMisc::PhysicalQuantities::CFrequencyUnit;
|
||||
@@ -34,9 +35,9 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
template <class AVIO> QVariant CModulator<AVIO>::propertyByIndex(const CPropertyIndex &index) const
|
||||
template <class AVIO> CVariant CModulator<AVIO>::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toQVariant(); }
|
||||
if (index.isMyself()) { return this->toCVariant(); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
@@ -45,11 +46,11 @@ namespace BlackMisc
|
||||
case IndexStandbyFrequency:
|
||||
return this->getFrequencyStandby().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexEnabled:
|
||||
return QVariant(this->isEnabled());
|
||||
return CVariant::from(this->isEnabled());
|
||||
case IndexInputVolume:
|
||||
return QVariant(this->getVolumeInput());
|
||||
return CVariant::from(this->getVolumeInput());
|
||||
case IndexOutputVolume:
|
||||
return QVariant(this->getVolumeOutput());
|
||||
return CVariant::from(this->getVolumeOutput());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -58,11 +59,11 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
template <class AVIO> void CModulator<AVIO>::setPropertyByIndex(const QVariant &variant, const CPropertyIndex &index)
|
||||
template <class AVIO> void CModulator<AVIO>::setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
|
||||
@@ -90,10 +90,10 @@ namespace BlackMisc
|
||||
void setEnabled(bool enable) { this->m_enabled = enable;}
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
protected:
|
||||
//! Default constructor
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "blackmisc/aviotransponder.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -156,36 +157,36 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property
|
||||
*/
|
||||
QVariant CTransponder::propertyByIndex(const CPropertyIndex &index) const
|
||||
CVariant CTransponder::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toQVariant(); }
|
||||
if (index.isMyself()) { return this->toCVariant(); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexMode:
|
||||
return QVariant(this->getTransponderMode());
|
||||
return CVariant::from(static_cast<int>(this->getTransponderMode()));
|
||||
case IndexModeAsString:
|
||||
return QVariant(this->getModeAsString());
|
||||
return CVariant::from(this->getModeAsString());
|
||||
case IndexTransponderCode:
|
||||
return QVariant(this->getTransponderCode());
|
||||
return CVariant::from(this->getTransponderCode());
|
||||
case IndexTransponderCodeFormatted:
|
||||
return QVariant(this->getTransponderCodeFormatted());
|
||||
return CVariant::from(this->getTransponderCodeFormatted());
|
||||
case IndexTransponderCodeAndModeFormatted:
|
||||
return QVariant(this->getTransponderCodeAndModeFormatted());
|
||||
return CVariant::from(this->getTransponderCodeAndModeFormatted());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Q_ASSERT_X(false, "CTransponder", "index unknown");
|
||||
QString m = QString("no property, index ").append(index.toQString());
|
||||
return QVariant::fromValue(m);
|
||||
return CVariant::fromValue(m);
|
||||
}
|
||||
|
||||
void CTransponder::setPropertyByIndex(const QVariant &variant, const CPropertyIndex &index)
|
||||
void CTransponder::setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
@@ -195,7 +196,7 @@ namespace BlackMisc
|
||||
this->setTransponderMode(static_cast<TransponderMode>(variant.toInt()));
|
||||
break;
|
||||
case IndexModeAsString:
|
||||
this->setTransponderMode(modeFromString(variant.toString()));
|
||||
this->setTransponderMode(modeFromString(variant.toQString()));
|
||||
break;
|
||||
case IndexTransponderCode:
|
||||
case IndexTransponderCodeFormatted:
|
||||
@@ -205,7 +206,7 @@ namespace BlackMisc
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setTransponderCode(variant.toString());
|
||||
this->setTransponderCode(variant.toQString());
|
||||
}
|
||||
break;
|
||||
case IndexTransponderCodeAndModeFormatted:
|
||||
|
||||
@@ -143,10 +143,10 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! Is valid transponder code?
|
||||
static bool isValidTransponderCode(const QString &transponderCode);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "mathematics.h"
|
||||
#include "variant.h"
|
||||
#include <QtCore/qmath.h>
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
@@ -111,7 +112,7 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant ICoordinateGeodetic::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant ICoordinateGeodetic::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (!index.isMyself())
|
||||
{
|
||||
@@ -123,9 +124,9 @@ namespace BlackMisc
|
||||
case IndexLongitude:
|
||||
return this->longitude().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexLatitudeAsString:
|
||||
return QVariant(this->latitudeAsString());
|
||||
return CVariant(this->latitudeAsString());
|
||||
case IndexLongitudeAsString:
|
||||
return QVariant(this->longitudeAsString());
|
||||
return CVariant(this->longitudeAsString());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -133,30 +134,30 @@ namespace BlackMisc
|
||||
|
||||
Q_ASSERT_X(false, "ICoordinateGeodetic", "index unknown");
|
||||
QString m = QString("no property, index ").append(index.toQString());
|
||||
return QVariant::fromValue(m);
|
||||
return CVariant::fromValue(m);
|
||||
}
|
||||
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant CCoordinateGeodetic::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CCoordinateGeodetic::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 IndexLatitude:
|
||||
return this->m_latitude.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexLatitudeAsString:
|
||||
return QVariant(this->m_latitude.toQString());
|
||||
return CVariant(this->m_latitude.toQString());
|
||||
case IndexLongitude:
|
||||
return this->m_longitude.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexLongitudeAsString:
|
||||
return QVariant(this->m_longitude.toQString());
|
||||
return CVariant(this->m_longitude.toQString());
|
||||
case IndexGeodeticHeight:
|
||||
return this->m_geodeticHeight.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexGeodeticHeightAsString:
|
||||
return QVariant(this->m_geodeticHeight.toQString());
|
||||
return CVariant(this->m_geodeticHeight.toQString());
|
||||
default:
|
||||
if (ICoordinateGeodetic::canHandleIndex(index))
|
||||
{
|
||||
@@ -169,11 +170,11 @@ namespace BlackMisc
|
||||
/*
|
||||
* Set property as index
|
||||
*/
|
||||
void CCoordinateGeodetic::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CCoordinateGeodetic::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
@@ -189,13 +190,13 @@ namespace BlackMisc
|
||||
this->setLongitude(variant.value<CLongitude>());
|
||||
break;
|
||||
case IndexLatitudeAsString:
|
||||
this->setLatitude(CLatitude::fromWgs84(variant.toString()));
|
||||
this->setLatitude(CLatitude::fromWgs84(variant.toQString()));
|
||||
break;
|
||||
case IndexLongitudeAsString:
|
||||
this->setLongitude(CLongitude::fromWgs84(variant.toString()));
|
||||
this->setLongitude(CLongitude::fromWgs84(variant.toQString()));
|
||||
break;
|
||||
case IndexGeodeticHeightAsString:
|
||||
this->m_geodeticHeight.parseFromString(variant.toString());
|
||||
this->m_geodeticHeight.parseFromString(variant.toQString());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace BlackMisc
|
||||
virtual const CLongitude &longitude() const = 0;
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
virtual CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! Latitude as string
|
||||
QString latitudeAsString() const { return this->latitude().toQString(true); }
|
||||
@@ -124,10 +124,10 @@ namespace BlackMisc
|
||||
const BlackMisc::PhysicalQuantities::CLength &geodeticHeight() const { return this->m_geodeticHeight; }
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! Switch unit of latitude / longitude
|
||||
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CAngleUnit &unit)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "hwjoystickbutton.h"
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include "variant.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -29,11 +30,11 @@ namespace BlackMisc
|
||||
this->m_buttonIndex = button.m_buttonIndex;
|
||||
}
|
||||
|
||||
void CJoystickButton::setPropertyByIndex(const QVariant &variant, const CPropertyIndex &index)
|
||||
void CJoystickButton::setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
@@ -53,23 +54,23 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
QVariant CJoystickButton::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CJoystickButton::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 IndexButton:
|
||||
return QVariant(this->getButtonIndex());
|
||||
return CVariant::from(this->getButtonIndex());
|
||||
case IndexButtonAsString:
|
||||
return QVariant(this->getButtonAsString());
|
||||
return CVariant::from(this->getButtonAsString());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Q_ASSERT_X(false, "CJoystickButton", "index unknown");
|
||||
QString m = QString("no property, index ").append(index.toQString());
|
||||
return QVariant::fromValue(m);
|
||||
return CVariant::fromValue(m);
|
||||
}
|
||||
|
||||
QString CJoystickButton::buttonIndexToString(qint32 buttonIndex)
|
||||
|
||||
@@ -54,10 +54,10 @@ namespace BlackMisc
|
||||
void setButtonObject(const BlackMisc::Hardware::CJoystickButton &button);
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
virtual void setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
virtual void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
virtual CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! Button index to string
|
||||
static QString buttonIndexToString(qint32 buttonIndex);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "hwkeyboardkey.h"
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include "propertyindex.h"
|
||||
#include "variant.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -245,40 +246,40 @@ namespace BlackMisc
|
||||
return ks;
|
||||
}
|
||||
|
||||
QVariant CKeyboardKey::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CKeyboardKey::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 IndexModifier1:
|
||||
return QVariant(static_cast<uint>(this->m_modifier1));
|
||||
return CVariant::from(static_cast<uint>(this->m_modifier1));
|
||||
case IndexModifier2:
|
||||
return QVariant(static_cast<uint>(this->m_modifier2));
|
||||
return CVariant::from(static_cast<uint>(this->m_modifier2));
|
||||
case IndexModifier1AsString:
|
||||
return QVariant(this->getModifier1AsString());
|
||||
return CVariant::from(this->getModifier1AsString());
|
||||
case IndexModifier2AsString:
|
||||
return QVariant(this->getModifier2AsString());
|
||||
return CVariant::from(this->getModifier2AsString());
|
||||
case IndexKey:
|
||||
return QVariant(this->m_qtKey);
|
||||
return CVariant::from(static_cast<int>(this->m_qtKey));
|
||||
case IndexKeyAsString:
|
||||
return QVariant(QString(QChar(this->m_qtKey)));
|
||||
return CVariant::from(QString(QChar(this->m_qtKey)));
|
||||
case IndexKeyAsStringRepresentation:
|
||||
return QVariant(this->getKeyAsStringRepresentation());
|
||||
return CVariant::from(this->getKeyAsStringRepresentation());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Q_ASSERT_X(false, "CKeyboardKey", "index unknown");
|
||||
QString m = QString("no property, index ").append(index.toQString());
|
||||
return QVariant::fromValue(m);
|
||||
return CVariant::fromValue(m);
|
||||
}
|
||||
|
||||
void CKeyboardKey::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CKeyboardKey::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
|
||||
@@ -180,10 +180,10 @@ namespace BlackMisc
|
||||
bool equalsWithRelaxedModifiers(const CKeyboardKey &key) const;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
virtual void setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
virtual void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
|
||||
//! Modifier to string
|
||||
static QString modifierToString(Modifier modifier);
|
||||
|
||||
@@ -50,20 +50,20 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant CNameVariantPair::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CNameVariantPair::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 IndexName:
|
||||
return QVariant(this->m_name);
|
||||
return CVariant(this->m_name);
|
||||
case IndexVariant:
|
||||
return this->m_variant.toQVariant();
|
||||
return this->m_variant;
|
||||
case IndexIcon:
|
||||
return this->m_icon.toQVariant();
|
||||
return this->m_icon.toCVariant();
|
||||
case IndexPixmap:
|
||||
return this->m_icon.toPixmap();
|
||||
return CVariant(this->m_icon.toPixmap());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -72,11 +72,11 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index (setter)
|
||||
*/
|
||||
void CNameVariantPair::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CNameVariantPair::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
|
||||
@@ -58,10 +58,10 @@ namespace BlackMisc
|
||||
bool hasIcon() const;
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString()
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "nwaircraftmapping.h"
|
||||
#include "propertyindex.h"
|
||||
#include "variant.h"
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Network;
|
||||
@@ -45,9 +46,9 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
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)
|
||||
{
|
||||
@@ -62,17 +63,17 @@ namespace BlackMisc
|
||||
}
|
||||
Q_ASSERT_X(false, "CAircraftMapping", "index unknown");
|
||||
QString m = QString("no property, index ").append(index.toQString());
|
||||
return QVariant::fromValue(m);
|
||||
return CVariant::fromValue(m);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set property as index
|
||||
*/
|
||||
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>();
|
||||
|
||||
@@ -49,10 +49,10 @@ namespace BlackMisc
|
||||
CAircraftMapping(const QString &aircraftDesignator, const QString &airlineDesignator, const QString &model);
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! ICAO
|
||||
void setIcao(const BlackMisc::Aviation::CAircraftIcao &icao) { this->m_icao = icao; }
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "nwaircraftmodel.h"
|
||||
#include "variant.h"
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -28,17 +29,17 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant CAircraftModel::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CAircraftModel::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 IndexModelString:
|
||||
return QVariant(this->m_modelString);
|
||||
return CVariant::from(this->m_modelString);
|
||||
break;
|
||||
case IndexIsQueriedModelString:
|
||||
return QVariant(this->m_queriedModelStringFlag);
|
||||
return CVariant::from(this->m_queriedModelStringFlag);
|
||||
break;
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
@@ -49,18 +50,18 @@ namespace BlackMisc
|
||||
/*
|
||||
* Set property as index
|
||||
*/
|
||||
void CAircraftModel::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CAircraftModel::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 IndexModelString:
|
||||
this->m_modelString = variant.toString();
|
||||
this->m_modelString = variant.toQString();
|
||||
break;
|
||||
case IndexIsQueriedModelString:
|
||||
this->m_queriedModelStringFlag = variant.toBool();
|
||||
|
||||
@@ -39,10 +39,10 @@ namespace BlackMisc
|
||||
CAircraftModel(const QString &model, bool isQueriedString) : m_modelString(model), m_queriedModelStringFlag(isQueriedString) {}
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! Queried model string
|
||||
const QString &getModelString() const { return this->m_modelString; }
|
||||
|
||||
@@ -75,16 +75,16 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant CClient::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CClient::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 IndexCapabilities:
|
||||
return this->m_capabilities.toQVariant();
|
||||
return this->m_capabilities.toCVariant();
|
||||
case IndexCapabilitiesString:
|
||||
return QVariant(this->getCapabilitiesAsString());
|
||||
return CVariant(this->getCapabilitiesAsString());
|
||||
case IndexCallsign:
|
||||
return this->getCallsign().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexUser:
|
||||
@@ -92,15 +92,15 @@ namespace BlackMisc
|
||||
case IndexModel:
|
||||
return this->m_model.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexServer:
|
||||
return QVariant(this->m_server);
|
||||
return CVariant(this->m_server);
|
||||
case IndexVoiceCapabilities:
|
||||
return this->m_voiceCapabilities.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexVoiceCapabilitiesPixmap:
|
||||
return QVariant(this->m_voiceCapabilities.toPixmap());
|
||||
return CVariant::from(this->m_voiceCapabilities.toPixmap());
|
||||
case IndexVoiceCapabilitiesIcon:
|
||||
return QVariant(this->m_voiceCapabilities.toIcon().toQVariant());
|
||||
return this->m_voiceCapabilities.toIcon().toCVariant();
|
||||
case IndexVoiceCapabilitiesString:
|
||||
return QVariant(this->m_voiceCapabilities.toQString(true));
|
||||
return CVariant(this->m_voiceCapabilities.toQString(true));
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -109,11 +109,11 @@ namespace BlackMisc
|
||||
/*
|
||||
* Set property as index
|
||||
*/
|
||||
void CClient::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CClient::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
@@ -126,7 +126,7 @@ namespace BlackMisc
|
||||
this->m_model.setPropertyByIndex(variant, index.copyFrontRemoved());;
|
||||
break;
|
||||
case IndexServer:
|
||||
this->m_server = variant.toString();
|
||||
this->m_server = variant.toQString();
|
||||
break;
|
||||
case IndexUser:
|
||||
this->m_user.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
|
||||
@@ -112,10 +112,10 @@ namespace BlackMisc
|
||||
virtual CIcon toIcon() const override { return this->m_user.toIcon(); }
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
@@ -133,7 +133,13 @@ namespace BlackMisc
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Network::CClient, (o.m_user, o.m_model, o.m_capabilities, o.m_server, o.m_voiceCapabilities))
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Network::CClient, (
|
||||
o.m_user,
|
||||
o.m_model,
|
||||
attr(o.m_capabilities, flags<DisabledForComparison>()),
|
||||
o.m_server,
|
||||
o.m_voiceCapabilities
|
||||
))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Network::CClient)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "nwserver.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include <tuple>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -52,41 +53,41 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant CServer::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CServer::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 IndexAddress:
|
||||
return QVariant::fromValue(this->m_address);
|
||||
return CVariant::fromValue(this->m_address);
|
||||
case IndexDescription:
|
||||
return QVariant::fromValue(this->m_description);
|
||||
return CVariant::fromValue(this->m_description);
|
||||
case IndexName:
|
||||
return QVariant::fromValue(this->m_name);
|
||||
return CVariant::fromValue(this->m_name);
|
||||
case IndexPort:
|
||||
return QVariant::fromValue(this->m_port);
|
||||
return CVariant::fromValue(this->m_port);
|
||||
case IndexUser:
|
||||
return this->m_user.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexIsAcceptingConnections:
|
||||
return QVariant::fromValue(this->m_isAcceptingConnections);
|
||||
return CVariant::fromValue(this->m_isAcceptingConnections);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Q_ASSERT_X(false, "CServer", "index unknown");
|
||||
QString m = QString("no property, index ").append(index.toQString());
|
||||
return QVariant::fromValue(m);
|
||||
return CVariant::fromValue(m);
|
||||
}
|
||||
|
||||
/*
|
||||
* Property by index (setter)
|
||||
*/
|
||||
void CServer::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CServer::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,10 +87,10 @@ namespace BlackMisc
|
||||
BlackMisc::CStatusMessageList validate() const;
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString()
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "blackmisc/icon.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include <tuple>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -82,20 +83,20 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant CUser::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CUser::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 IndexEmail:
|
||||
return QVariant(this->m_email);
|
||||
return CVariant(this->m_email);
|
||||
case IndexId:
|
||||
return QVariant(this->m_id);
|
||||
return CVariant(this->m_id);
|
||||
case IndexPassword:
|
||||
return QVariant(this->m_password);
|
||||
return CVariant(this->m_password);
|
||||
case IndexRealName:
|
||||
return QVariant(this->m_realname);
|
||||
return CVariant(this->m_realname);
|
||||
case IndexCallsign:
|
||||
return this->m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
default:
|
||||
@@ -106,11 +107,11 @@ namespace BlackMisc
|
||||
/*
|
||||
* Set property as index
|
||||
*/
|
||||
void CUser::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CUser::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
|
||||
@@ -118,10 +118,10 @@ namespace BlackMisc
|
||||
virtual BlackMisc::CIcon toIcon() const override { return this->getCallsign().toIcon(); }
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
/*!
|
||||
* This and another user exchange missing data.
|
||||
|
||||
@@ -290,26 +290,26 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property
|
||||
*/
|
||||
template <class MU, class PQ> QVariant CPhysicalQuantity<MU, PQ>::propertyByIndex(const CPropertyIndex &index) const
|
||||
template <class MU, class PQ> CVariant CPhysicalQuantity<MU, PQ>::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toQVariant(); }
|
||||
if (index.isMyself()) { return this->toCVariant(); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexValue:
|
||||
return QVariant(this->m_value);
|
||||
return CVariant::from(this->m_value);
|
||||
case IndexUnit:
|
||||
return this->m_unit.toQVariant();
|
||||
return this->m_unit.toCVariant();
|
||||
case IndexValueRounded0DigitsWithUnit:
|
||||
return QVariant(this->valueRoundedWithUnit(0));
|
||||
return CVariant::from(this->valueRoundedWithUnit(0));
|
||||
case IndexValueRounded1DigitsWithUnit:
|
||||
return QVariant(this->valueRoundedWithUnit(1));
|
||||
return CVariant::from(this->valueRoundedWithUnit(1));
|
||||
case IndexValueRounded2DigitsWithUnit:
|
||||
return QVariant(this->valueRoundedWithUnit(2));
|
||||
return CVariant::from(this->valueRoundedWithUnit(2));
|
||||
case IndexValueRounded3DigitsWithUnit:
|
||||
return QVariant(this->valueRoundedWithUnit(3));
|
||||
return CVariant::from(this->valueRoundedWithUnit(3));
|
||||
case IndexValueRounded6DigitsWithUnit:
|
||||
return QVariant(this->valueRoundedWithUnit(6));
|
||||
return CVariant::from(this->valueRoundedWithUnit(6));
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -318,11 +318,11 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property
|
||||
*/
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::setPropertyByIndex(const QVariant &variant, const CPropertyIndex &index)
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
@@ -332,14 +332,14 @@ namespace BlackMisc
|
||||
this->m_value = variant.toDouble();
|
||||
break;
|
||||
case IndexUnit:
|
||||
this->m_unit.convertFromQVariant(variant);
|
||||
this->m_unit.convertFromCVariant(variant);
|
||||
break;
|
||||
case IndexValueRounded0DigitsWithUnit:
|
||||
case IndexValueRounded1DigitsWithUnit:
|
||||
case IndexValueRounded2DigitsWithUnit:
|
||||
case IndexValueRounded3DigitsWithUnit:
|
||||
case IndexValueRounded6DigitsWithUnit:
|
||||
this->parseFromString(variant.toString());
|
||||
this->parseFromString(variant.toQString());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
|
||||
@@ -236,10 +236,10 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
protected:
|
||||
//! Constructor with double
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace BlackMisc
|
||||
/*
|
||||
* Constructor single value
|
||||
*/
|
||||
CPropertyIndexVariantMap::CPropertyIndexVariantMap(const CPropertyIndex &index, const QVariant &value)
|
||||
CPropertyIndexVariantMap::CPropertyIndexVariantMap(const CPropertyIndex &index, const CVariant &value)
|
||||
: m_wildcard(false)
|
||||
{
|
||||
this->addValue(index, value);
|
||||
@@ -125,7 +125,7 @@ namespace BlackMisc
|
||||
/*
|
||||
* Add value
|
||||
*/
|
||||
void CPropertyIndexVariantMap::addValue(const CPropertyIndex &index, const QVariant &value)
|
||||
void CPropertyIndexVariantMap::addValue(const CPropertyIndex &index, const CVariant &value)
|
||||
{
|
||||
this->m_values.insert(index, value);
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ namespace BlackMisc
|
||||
CPropertyIndexVariantMap(bool wildcard = false);
|
||||
|
||||
//! Single value constructor
|
||||
CPropertyIndexVariantMap(const CPropertyIndex &index, const QVariant &value);
|
||||
CPropertyIndexVariantMap(const CPropertyIndex &index, const CVariant &value);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CPropertyIndexVariantMap() {}
|
||||
|
||||
//! Add a value
|
||||
void addValue(const CPropertyIndex &index, const QVariant &value);
|
||||
void addValue(const CPropertyIndex &index, const CVariant &value);
|
||||
|
||||
//! Add a value
|
||||
void addValue(const CPropertyIndex &index, const QVariant &value) { this->addValue(index, CVariant(value)); }
|
||||
@@ -58,17 +58,17 @@ namespace BlackMisc
|
||||
//! Add QString as literal, disambiguate as I want to add QString
|
||||
void addValue(const CPropertyIndex &index, const char *str);
|
||||
|
||||
//! Add a value as non QVariant
|
||||
//! Add a value as non CVariant
|
||||
template<class T> void addValue(const CPropertyIndex &index, const T &value) { this->m_values.insert(index, CVariant::fromValue(value)); }
|
||||
|
||||
//! Is empty?
|
||||
bool isEmpty() const { return this->m_values.isEmpty(); }
|
||||
|
||||
//! Value
|
||||
QVariant value(const CPropertyIndex &index) const { return this->m_values.value(index).toQVariant(); }
|
||||
CVariant value(const CPropertyIndex &index) const { return this->m_values.value(index).toCVariant(); }
|
||||
|
||||
//! Set value
|
||||
void value(const CPropertyIndex &index, const QVariant &value) { this->m_values.value(index, value); }
|
||||
void value(const CPropertyIndex &index, const CVariant &value) { this->m_values.value(index, value); }
|
||||
|
||||
//! Indexes
|
||||
CPropertyIndexList indexes() const;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "setkeyboardhotkey.h"
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include "variant.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -39,40 +40,40 @@ namespace BlackMisc
|
||||
m_key = obj.m_key;
|
||||
}
|
||||
|
||||
QVariant CSettingKeyboardHotkey::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CSettingKeyboardHotkey::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 IndexFunction:
|
||||
return QVariant(m_hotkeyFunction.getFunction());
|
||||
return CVariant::from(static_cast<uint>(m_hotkeyFunction.getFunction()));
|
||||
case IndexFunctionAsString:
|
||||
return QVariant(m_hotkeyFunction.getFunctionAsString());
|
||||
return CVariant::from(m_hotkeyFunction.getFunctionAsString());
|
||||
case IndexModifier1:
|
||||
return QVariant(static_cast<uint>(m_key.getModifier1()));
|
||||
return CVariant::from(static_cast<uint>(m_key.getModifier1()));
|
||||
case IndexModifier2:
|
||||
return QVariant(static_cast<uint>(m_key.getModifier2()));
|
||||
return CVariant::from(static_cast<uint>(m_key.getModifier2()));
|
||||
case IndexModifier1AsString:
|
||||
return QVariant(m_key.getModifier1AsString());
|
||||
return CVariant::from(m_key.getModifier1AsString());
|
||||
case IndexModifier2AsString:
|
||||
return QVariant(m_key.getModifier2AsString());
|
||||
return CVariant::from(m_key.getModifier2AsString());
|
||||
case IndexKey:
|
||||
return QVariant(m_key.getKeyAsQtKey());
|
||||
return CVariant::from(static_cast<int>(m_key.getKeyAsQtKey()));
|
||||
case IndexKeyAsString:
|
||||
return QVariant(QString(QChar(m_key.getKeyAsQtKey())));
|
||||
return CVariant::from(QString(QChar(m_key.getKeyAsQtKey())));
|
||||
case IndexKeyAsStringRepresentation:
|
||||
return QVariant(m_key.getKeyAsStringRepresentation());
|
||||
return CVariant::from(m_key.getKeyAsStringRepresentation());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CSettingKeyboardHotkey::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CSettingKeyboardHotkey::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
|
||||
@@ -82,10 +82,10 @@ namespace BlackMisc
|
||||
static QString toStringRepresentation(int key) { return Hardware::CKeyboardKey::toStringRepresentation(key); }
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
virtual void setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
virtual void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
|
||||
@@ -241,29 +241,29 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant CStatusMessage::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CStatusMessage::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 IndexMessage:
|
||||
return QVariant(this->m_message);
|
||||
return CVariant::from(this->m_message);
|
||||
case IndexSeverity:
|
||||
return QVariant(static_cast<uint>(this->m_severity));
|
||||
return CVariant::from(static_cast<uint>(this->m_severity));
|
||||
case IndexSeverityAsString:
|
||||
return QVariant(this->getSeverityAsString());
|
||||
return CVariant::from(this->getSeverityAsString());
|
||||
case IndexTimestamp:
|
||||
return QVariant(this->m_timestamp);
|
||||
return CVariant::from(this->m_timestamp);
|
||||
case IndexTimestampFormatted:
|
||||
{
|
||||
if (this->m_timestamp.isNull() || !this->m_timestamp.isValid()) return "";
|
||||
return this->m_timestamp.toString("HH:mm::ss.zzz");
|
||||
}
|
||||
case IndexCategories:
|
||||
return QVariant(this->m_categories.toQString());
|
||||
return CVariant::from(this->m_categories.toQString());
|
||||
case IndexCategoryHumanReadable:
|
||||
return QVariant(this->getHumanReadableCategory());
|
||||
return CVariant::from(this->getHumanReadableCategory());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -272,11 +272,11 @@ namespace BlackMisc
|
||||
/*
|
||||
* Set property as index
|
||||
*/
|
||||
void CStatusMessage::setPropertyByIndex(const QVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CStatusMessage::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
|
||||
@@ -121,10 +121,10 @@ namespace BlackMisc
|
||||
static const QStringList &allSeverityStrings();
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! To HTML
|
||||
QString toHtml() const;
|
||||
|
||||
@@ -47,15 +47,15 @@ namespace BlackMisc
|
||||
if (byPropertyIndex)
|
||||
{
|
||||
CAtcStation station;
|
||||
station.setPropertyByIndex(CCallsign(cs).toQVariant(), CAtcStation::IndexCallsign);
|
||||
station.setPropertyByIndex(user.toQVariant(), CAtcStation::IndexController);
|
||||
station.setPropertyByIndex(CFrequency(f, CFrequencyUnit::MHz()).toQVariant(), CAtcStation::IndexFrequency);
|
||||
station.setPropertyByIndex(CLength(50, CLengthUnit::km()).toQVariant(), CAtcStation::IndexRange);
|
||||
station.setPropertyByIndex(geoPos.toQVariant(), CAtcStation::IndexPosition);
|
||||
station.setPropertyByIndex(false, CAtcStation::IndexIsOnline);
|
||||
station.setPropertyByIndex(dtFrom, CAtcStation::IndexBookedFrom);
|
||||
station.setPropertyByIndex(dtUntil, CAtcStation::IndexBookedUntil);
|
||||
station.setPropertyByIndex(CLength(index + 1, CLengthUnit::NM()).toQVariant(), CAtcStation::IndexDistance);
|
||||
station.setPropertyByIndex(CCallsign(cs).toCVariant(), CAtcStation::IndexCallsign);
|
||||
station.setPropertyByIndex(user.toCVariant(), CAtcStation::IndexController);
|
||||
station.setPropertyByIndex(CFrequency(f, CFrequencyUnit::MHz()).toCVariant(), CAtcStation::IndexFrequency);
|
||||
station.setPropertyByIndex(CLength(50, CLengthUnit::km()).toCVariant(), CAtcStation::IndexRange);
|
||||
station.setPropertyByIndex(geoPos.toCVariant(), CAtcStation::IndexPosition);
|
||||
station.setPropertyByIndex(CVariant::from(false), CAtcStation::IndexIsOnline);
|
||||
station.setPropertyByIndex(CVariant::from(dtFrom), CAtcStation::IndexBookedFrom);
|
||||
station.setPropertyByIndex(CVariant::from(dtUntil), CAtcStation::IndexBookedUntil);
|
||||
station.setPropertyByIndex(CLength(index + 1, CLengthUnit::NM()).toCVariant(), CAtcStation::IndexDistance);
|
||||
return station;
|
||||
}
|
||||
else
|
||||
@@ -81,11 +81,11 @@ namespace BlackMisc
|
||||
QString r;
|
||||
if (byPropertyIndex)
|
||||
{
|
||||
r.append(station.propertyByIndex({ CAtcStation::IndexCallsign, CCallsign::IndexString}).toString());
|
||||
r.append(station.propertyByIndex({ CAtcStation::IndexController, CUser::IndexRealName}).toString());
|
||||
r.append(station.propertyByIndex({ CAtcStation::IndexPosition, CCoordinateGeodetic::IndexLatitudeAsString}).toString());
|
||||
r.append(station.propertyByIndex({ CAtcStation::IndexPosition, CCoordinateGeodetic::IndexLongitudeAsString}).toString());
|
||||
r.append(station.propertyByIndex({ CAtcStation::IndexDistance, CLength::IndexValueRounded2DigitsWithUnit}).toString());
|
||||
r.append(station.propertyByIndex({ CAtcStation::IndexCallsign, CCallsign::IndexString}).toQString());
|
||||
r.append(station.propertyByIndex({ CAtcStation::IndexController, CUser::IndexRealName}).toQString());
|
||||
r.append(station.propertyByIndex({ CAtcStation::IndexPosition, CCoordinateGeodetic::IndexLatitudeAsString}).toQString());
|
||||
r.append(station.propertyByIndex({ CAtcStation::IndexPosition, CCoordinateGeodetic::IndexLongitudeAsString}).toQString());
|
||||
r.append(station.propertyByIndex({ CAtcStation::IndexDistance, CLength::IndexValueRounded2DigitsWithUnit}).toQString());
|
||||
r.append(station.propertyByIndex({ CAtcStation::IndexBookedFrom}).toDateTime().toString("YYYY-mm-dd hh:mm"));
|
||||
r.append(station.propertyByIndex({ CAtcStation::IndexBookedUntil}).toDateTime().toString("YYYY-mm-dd hh:mm"));
|
||||
}
|
||||
|
||||
@@ -54,11 +54,11 @@ namespace BlackMisc
|
||||
/*
|
||||
* Setter for property by index
|
||||
*/
|
||||
void CValueObject::setPropertyByIndex(const QVariant &variant, const CPropertyIndex &index)
|
||||
void CValueObject::setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,18 +70,18 @@ namespace BlackMisc
|
||||
/*
|
||||
* By index
|
||||
*/
|
||||
QVariant CValueObject::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CValueObject::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 IndexIcon:
|
||||
return this->toIcon().toQVariant();
|
||||
return this->toIcon().toCVariant();
|
||||
case IndexPixmap:
|
||||
return QVariant(this->toPixmap());
|
||||
return CVariant::from(this->toPixmap());
|
||||
case IndexString:
|
||||
return QVariant(this->toQString());
|
||||
return CVariant(this->toQString());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ namespace BlackMisc
|
||||
// not all classes have implemented nesting
|
||||
const QString m = QString("Property by index not found, index: ").append(index.toQString());
|
||||
qFatal("%s", qPrintable(m));
|
||||
return QVariant(m); // avoid compiler warning
|
||||
return CVariant(m); // avoid compiler warning
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -98,17 +98,15 @@ namespace BlackMisc
|
||||
QString CValueObject::propertyByIndexAsString(const CPropertyIndex &index, bool i18n) const
|
||||
{
|
||||
// default implementation, requires propertyByIndex
|
||||
QVariant qv = this->propertyByIndex(index);
|
||||
return BlackMisc::qVariantToString(qv, i18n);
|
||||
return this->propertyByIndex(index).toQString(i18n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Variant equal property index?
|
||||
*/
|
||||
bool CValueObject::equalsPropertyByIndex(const QVariant &compareValue, const CPropertyIndex &index) const
|
||||
bool CValueObject::equalsPropertyByIndex(const CVariant &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
const QVariant myValue = this->propertyByIndex(index);
|
||||
return BlackMisc::equalQVariants(myValue, compareValue);
|
||||
return this->propertyByIndex(index) == compareValue;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -159,7 +157,7 @@ namespace BlackMisc
|
||||
const auto &map = indexMap.map();
|
||||
for (auto it = map.begin(); it != map.end(); ++it)
|
||||
{
|
||||
const QVariant value = it.value().toQVariant();
|
||||
const CVariant value = it.value().toCVariant();
|
||||
const CPropertyIndex index = it.key();
|
||||
if (skipEqualValues)
|
||||
{
|
||||
@@ -206,9 +204,9 @@ namespace BlackMisc
|
||||
for (auto it = map.begin(); it != map.end(); ++it)
|
||||
{
|
||||
// QVariant cannot be compared directly
|
||||
QVariant p = valueObject.propertyByIndex(it.key()); // from value object
|
||||
QVariant v = it.value().toQVariant(); // from map
|
||||
if (!BlackMisc::equalQVariants(p, v)) return false;
|
||||
CVariant p = valueObject.propertyByIndex(it.key()); // from value object
|
||||
CVariant v = it.value().toCVariant(); // from map
|
||||
if (p != v) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -200,17 +200,17 @@ namespace BlackMisc
|
||||
virtual QPixmap toPixmap() const;
|
||||
|
||||
//! Set property by index
|
||||
virtual void setPropertyByIndex(const QVariant &variant, const CPropertyIndex &index);
|
||||
virtual void setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index);
|
||||
|
||||
//! Property by index
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
virtual CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! Property by index as String
|
||||
//! \details Intentionally not abstract, avoiding all classes need to implement this method
|
||||
virtual QString propertyByIndexAsString(const CPropertyIndex &index, bool i18n = false) const;
|
||||
|
||||
//! Is given variant equal to value of property index?
|
||||
virtual bool equalsPropertyByIndex(const QVariant &compareValue, const CPropertyIndex &index) const;
|
||||
virtual bool equalsPropertyByIndex(const CVariant &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! The stored object as CValueObject
|
||||
static const CValueObject *fromQVariant(const QVariant &variant);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "voiceroom.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include <QChar>
|
||||
#include <QStringList>
|
||||
#include <tuple>
|
||||
@@ -30,22 +31,22 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
QVariant CVoiceRoom::propertyByIndex(const CPropertyIndex &index) const
|
||||
CVariant CVoiceRoom::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toQVariant(); }
|
||||
if (index.isMyself()) { return this->toCVariant(); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAudioPlaying:
|
||||
return QVariant(this->isAudioPlaying());
|
||||
return CVariant::from(this->isAudioPlaying());
|
||||
case IndexConnected:
|
||||
return QVariant(this->isConnected());
|
||||
return CVariant::from(this->isConnected());
|
||||
case IndexChannel:
|
||||
return QVariant(this->getChannel());
|
||||
return CVariant::from(this->getChannel());
|
||||
case IndexHostname:
|
||||
return QVariant(this->getHostname());
|
||||
return CVariant::from(this->getHostname());
|
||||
case IndexUrl:
|
||||
return QVariant(this->getVoiceRoomUrl());
|
||||
return CVariant::from(this->getVoiceRoomUrl());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -54,11 +55,11 @@ namespace BlackMisc
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
void CVoiceRoom::setPropertyByIndex(const QVariant &variant, const CPropertyIndex &index)
|
||||
void CVoiceRoom::setPropertyByIndex(const CVariant &variant, const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
this->convertFromQVariant(variant);
|
||||
this->convertFromCVariant(variant);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,10 +87,10 @@ namespace BlackMisc
|
||||
bool isAtis() const;
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
virtual 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 CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! Protocol prefix "vvl"
|
||||
static const QString &protocol() { static QString p("vvl"); return p; }
|
||||
|
||||
Reference in New Issue
Block a user