Add string based identifier to CGridPoint

refs #612
This commit is contained in:
Roland Winklmeier
2016-03-28 17:06:24 +02:00
parent 28292e3af7
commit 779191e66b
3 changed files with 37 additions and 5 deletions

View File

@@ -19,13 +19,23 @@ namespace BlackMisc
{
namespace Weather
{
CGridPoint::CGridPoint(const Geo::CCoordinateGeodetic &position,
CGridPoint::CGridPoint(const QString &identifier,
const Geo::CCoordinateGeodetic &position) :
m_identifier(identifier),
m_position(position)
{ }
CGridPoint::CGridPoint(const QString &identifier,
const Geo::CCoordinateGeodetic &position,
const CCloudLayerList &cloudLayers,
const CTemperatureLayerList &temperatureLayers,
const CVisibilityLayerList &visibilityLayers,
const CWindLayerList &windLayers) :
m_position(position), m_cloudLayers(cloudLayers),
m_temperatureLayers(temperatureLayers), m_visibilityLayers(visibilityLayers),
m_identifier(identifier),
m_position(position),
m_cloudLayers(cloudLayers),
m_temperatureLayers(temperatureLayers),
m_visibilityLayers(visibilityLayers),
m_windLayers(windLayers)
{ }
@@ -43,6 +53,8 @@ namespace BlackMisc
ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexIdentifier:
return CVariant::fromValue(m_identifier);
case IndexPosition:
return CVariant::fromValue(m_position);
case IndexCloudLayers:
@@ -62,6 +74,9 @@ namespace BlackMisc
ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexIdentifier:
setIdentifier(variant.value<QString>());
break;
case IndexPosition:
setPosition(variant.value<CCoordinateGeodetic>());
break;

View File

@@ -34,7 +34,8 @@ namespace BlackMisc
//! Properties by index
enum ColumnIndex
{
IndexPosition = BlackMisc::CPropertyIndex::GlobalIndexCGridPoint,
IndexIdentifier = BlackMisc::CPropertyIndex::GlobalIndexCGridPoint,
IndexPosition,
IndexCloudLayers,
IndexTemperatureLayers,
IndexWindLayers
@@ -44,12 +45,23 @@ namespace BlackMisc
CGridPoint() = default;
//! Constructor
CGridPoint(const Geo::CCoordinateGeodetic &position,
CGridPoint(const QString &identifier,
const Geo::CCoordinateGeodetic &position);
//! Constructor
CGridPoint(const QString &identifier,
const Geo::CCoordinateGeodetic &position,
const CCloudLayerList &cloudLayers,
const CTemperatureLayerList &temperatureLayers,
const CVisibilityLayerList &visibilityLayers,
const CWindLayerList &windLayers);
//! Set identifier
void setIdentifier(const QString &identifier) { m_identifier = identifier; }
//! Get identifier
QString getIdentifier() const { return m_identifier; }
//! Set position
void setPosition(const BlackMisc::Geo::CCoordinateGeodetic &position) { m_position = position; }
@@ -93,6 +105,8 @@ namespace BlackMisc
QString convertToQString(bool i18n = false) const;
private:
// Identifier is intentionally string based. MSFS uses ICAO but others don't.
QString m_identifier;
BlackMisc::Geo::CCoordinateGeodetic m_position;
CCloudLayerList m_cloudLayers;
CTemperatureLayerList m_temperatureLayers;
@@ -101,6 +115,7 @@ namespace BlackMisc
BLACK_METACLASS(
CGridPoint,
BLACK_METAMEMBER(identifier),
BLACK_METAMEMBER(position),
BLACK_METAMEMBER(cloudLayers),
BLACK_METAMEMBER(temperatureLayers),

View File

@@ -47,6 +47,7 @@ namespace BlackMisc
static const CGridPoint gridPointGLOB =
{
"GLOB",
{},
CCloudLayerList { cloudLayer },
CTemperatureLayerList { temperatureLayer },
@@ -97,6 +98,7 @@ namespace BlackMisc
static const CGridPoint gridPointGLOB
{
"GLOB",
{},
CCloudLayerList { cloudLayer1, cloudLayer2 },
CTemperatureLayerList { temperatureLayer },