refs #369, smaller changes

* rendered attribute in CSimulatedAircraft
* Formatting
* contains in CPropertyIndex
* CAircraftModel, new type
This commit is contained in:
Klaus Basan
2015-02-05 23:50:44 +01:00
parent 366721d9ad
commit 89424647aa
7 changed files with 45 additions and 6 deletions

View File

@@ -65,11 +65,9 @@ namespace BlackCore
signals:
//! Aircraft cockpit update
//! \remarks DBus and local
void changedAircraftCockpit(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const QString &originator);
//! Changed SELCAL code
//! \remarks DBus and local
void changedSelcal(const BlackMisc::Aviation::CSelcal &selcal, const QString &originator);
public slots:

View File

@@ -121,4 +121,9 @@ namespace BlackMisc
this->setIndexStringByList(newList);
}
bool CPropertyIndex::contains(int index) const
{
return this->indexList().contains(index);
}
} // namespace

View File

@@ -93,6 +93,16 @@ namespace BlackMisc
//! Shif existing indexes to right and insert given index at front
void prepend(int newLeftIndex);
//! Contains index?
bool contains(int index) const;
//! Compare with index given by enum
template<class EnumType> bool contains(EnumType ev) const
{
static_assert(std::is_enum<EnumType>::value, "Argument must be an enum");
return contains(static_cast<int>(ev));
}
//! First element casted to given type, usually then PropertIndex enum
template<class CastType> CastType frontCasted() const
{

View File

@@ -134,6 +134,7 @@ namespace BlackMisc
case TypeQueriedFromNetwork: return "queried";
case TypeModelMatching: return "matching";
case TypeModelMapping: return "mapping";
case TypeModelMatchingDefaultModel: return "map. default";
case TypeOwnSimulatorModel: return "own simulator";
case TypeManuallySet: return "set";
case TypeUnknown:

View File

@@ -32,6 +32,7 @@ namespace BlackMisc
TypeUnknown,
TypeQueriedFromNetwork, //!< model was queried by network protocol
TypeModelMatching, //!< model is result of model matching
TypeModelMatchingDefaultModel, //!< a default model assigned by model matching
TypeModelMapping, //!< used along with mapping definition
TypeManuallySet, //!< manually set, e.g. from GUI
TypeOwnSimulatorModel //!< represents own simulator model
@@ -56,6 +57,10 @@ namespace BlackMisc
//! Constructor.
CAircraftModel(const QString &model, ModelType type) : m_modelString(model), m_modelType(type) {}
//! Constructor.
CAircraftModel(const QString &model, ModelType type, const QString &description, const BlackMisc::Aviation::CAircraftIcao &icao) :
m_icao(icao), m_modelString(model), m_description(description), m_modelType(type) {}
//! Constructor
CAircraftModel(const BlackMisc::Aviation::CAircraft &aircraft);

View File

@@ -51,6 +51,8 @@ namespace BlackMisc
return this->m_client.propertyByIndex(index.copyFrontRemoved());
case IndexEnabled:
return CVariant::fromValue(this->isEnabled());
case IndexRendered:
return CVariant::fromValue(this->isRendered());
default:
return CAircraft::propertyByIndex(index);
}
@@ -75,6 +77,9 @@ namespace BlackMisc
case IndexEnabled:
this->m_enabled = variant.toBool();
break;
case IndexRendered:
this->m_rendered = variant.toBool();
break;
default:
CAircraft::setPropertyByIndex(variant, index);
break;
@@ -141,6 +146,9 @@ namespace BlackMisc
s += " enabled: ";
s += this->isEnabled() ? "yes" : "no";
s += " ";
s += " rendered: ";
s += this->isRendered() ? "yes" : "no";
s += " ";
s += this->m_model.toQString(i18n);
s += " ";
s += this->m_client.toQString(i18n);

View File

@@ -30,7 +30,8 @@ namespace BlackMisc
{
IndexModel = BlackMisc::CPropertyIndex::GlobalIndexCSimulatedAircraft,
IndexClient,
IndexEnabled
IndexEnabled,
IndexRendered
};
//! Default constructor.
@@ -50,6 +51,9 @@ namespace BlackMisc
//! Get model
const BlackMisc::Simulation::CAircraftModel &getModel() const { return m_model; }
//! Get model string
QString getModelString() const { return m_model.getModelString(); }
//! Set model
void setModel(const BlackMisc::Simulation::CAircraftModel &model);
@@ -74,9 +78,15 @@ namespace BlackMisc
//! Enabled?
bool isEnabled() const { return m_enabled; }
//! Enabled
//! Enabled / disabled
void setEnabled(bool enabled) { m_enabled = enabled; }
//! Rendered?
bool isRendered() const { return m_rendered; }
//! Rendered?
void setRendered(bool rendered) { m_rendered = rendered; }
//! Update from aviation aircraft
void setAircraft(const BlackMisc::Aviation::CAircraft &aircraft);
@@ -88,7 +98,8 @@ namespace BlackMisc
BLACK_ENABLE_TUPLE_CONVERSION(CSimulatedAircraft)
BlackMisc::Simulation::CAircraftModel m_model;
BlackMisc::Network::CClient m_client;
bool m_enabled = true;
bool m_enabled = true; // to be displayed in sim
bool m_rendered = false; // really shown in sim
void init();
};
@@ -98,7 +109,8 @@ namespace BlackMisc
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::CSimulatedAircraft, (
attr(o.m_model),
attr(o.m_client),
attr(o.m_enabled)
attr(o.m_enabled),
attr(o.m_rendered)
))
Q_DECLARE_METATYPE(BlackMisc::Simulation::CSimulatedAircraft)