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: signals:
//! Aircraft cockpit update //! Aircraft cockpit update
//! \remarks DBus and local
void changedAircraftCockpit(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const QString &originator); void changedAircraftCockpit(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const QString &originator);
//! Changed SELCAL code //! Changed SELCAL code
//! \remarks DBus and local
void changedSelcal(const BlackMisc::Aviation::CSelcal &selcal, const QString &originator); void changedSelcal(const BlackMisc::Aviation::CSelcal &selcal, const QString &originator);
public slots: public slots:

View File

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

View File

@@ -93,6 +93,16 @@ namespace BlackMisc
//! Shif existing indexes to right and insert given index at front //! Shif existing indexes to right and insert given index at front
void prepend(int newLeftIndex); 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 //! First element casted to given type, usually then PropertIndex enum
template<class CastType> CastType frontCasted() const template<class CastType> CastType frontCasted() const
{ {

View File

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

View File

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

View File

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

View File

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