refs #472 Removed static_cast<int> for enums in blackmisc, no longer needed.

This commit is contained in:
Mathew Sutcliffe
2015-09-27 01:41:42 +01:00
parent 9b1e42d71a
commit d13e863218
23 changed files with 104 additions and 35 deletions

View File

@@ -18,6 +18,13 @@ namespace BlackMisc
namespace Aviation namespace Aviation
{ {
void CComSystem::registerMetadata()
{
Mixin::MetaType<CComSystem>::registerMetadata();
qDBusRegisterMetaType<ChannelSpacing>();
qDBusRegisterMetaType<ComUnit>();
}
bool CComSystem::validValues() const bool CComSystem::validValues() const
{ {
if (this->isDefaultValue()) return true; // special case if (this->isDefaultValue()) return true; // special case

View File

@@ -49,6 +49,9 @@ namespace BlackMisc
Com2 Com2
}; };
//! \copydoc BlackMisc::CValueObject::registerMetadata
static void registerMetadata();
//! Default constructor //! Default constructor
CComSystem() {} CComSystem() {}
@@ -171,5 +174,7 @@ namespace BlackMisc
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CComSystem, (o.m_channelSpacing)) BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CComSystem, (o.m_channelSpacing))
Q_DECLARE_METATYPE(BlackMisc::Aviation::CComSystem) Q_DECLARE_METATYPE(BlackMisc::Aviation::CComSystem)
Q_DECLARE_METATYPE(BlackMisc::Aviation::CComSystem::ChannelSpacing)
Q_DECLARE_METATYPE(BlackMisc::Aviation::CComSystem::ComUnit)
#endif // guard #endif // guard

View File

@@ -17,6 +17,12 @@ namespace BlackMisc
namespace Aviation namespace Aviation
{ {
void CTransponder::registerMetadata()
{
CValueObject<CTransponder>::registerMetadata();
qRegisterMetaType<TransponderMode>();
}
bool CTransponder::validValues() const bool CTransponder::validValues() const
{ {
if (this->isDefaultValue()) return true; // special case if (this->isDefaultValue()) return true; // special case
@@ -151,7 +157,7 @@ namespace BlackMisc
switch (i) switch (i)
{ {
case IndexMode: case IndexMode:
return CVariant::from(static_cast<int>(this->getTransponderMode())); return CVariant::from(this->getTransponderMode());
case IndexModeAsString: case IndexModeAsString:
return CVariant::from(this->getModeAsString()); return CVariant::from(this->getModeAsString());
case IndexTransponderCode: case IndexTransponderCode:
@@ -176,7 +182,7 @@ namespace BlackMisc
switch (i) switch (i)
{ {
case IndexMode: case IndexMode:
this->setTransponderMode(static_cast<TransponderMode>(variant.toInt())); this->setTransponderMode(variant.value<TransponderMode>());
break; break;
case IndexModeAsString: case IndexModeAsString:
this->setTransponderMode(modeFromString(variant.toQString())); this->setTransponderMode(modeFromString(variant.toQString()));

View File

@@ -45,6 +45,9 @@ namespace BlackMisc
IndexTransponderCodeAndModeFormatted IndexTransponderCodeAndModeFormatted
}; };
//! \copydoc BlackMisc::CValueObject::registerMetadata
static void registerMetadata();
//! Default constructor //! Default constructor
CTransponder() : m_transponderCode(0), m_transponderMode(StateStandby) {} CTransponder() : m_transponderCode(0), m_transponderMode(StateStandby) {}
@@ -184,5 +187,6 @@ BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CTransponder, (
)) ))
Q_DECLARE_METATYPE(BlackMisc::Aviation::CTransponder) Q_DECLARE_METATYPE(BlackMisc::Aviation::CTransponder)
Q_DECLARE_METATYPE(BlackMisc::Aviation::CTransponder::TransponderMode)
#endif // guard #endif // guard

View File

@@ -54,6 +54,8 @@ void BlackMisc::Audio::registerMetadata()
CAudioDeviceInfoList::registerMetadata(); CAudioDeviceInfoList::registerMetadata();
CVoiceRoom::registerMetadata(); CVoiceRoom::registerMetadata();
CVoiceRoomList::registerMetadata(); CVoiceRoomList::registerMetadata();
qDBusRegisterMetaType<BlackSound::CNotificationSounds::PlayMode>();
qDBusRegisterMetaType<BlackSound::CNotificationSounds::Notification>();
} }
void BlackMisc::Input::registerMetadata() void BlackMisc::Input::registerMetadata()
@@ -65,6 +67,7 @@ void BlackMisc::Input::registerMetadata()
CActionHotkey::registerMetadata(); CActionHotkey::registerMetadata();
CActionHotkeyList::registerMetadata(); CActionHotkeyList::registerMetadata();
CHotkeyCombination::registerMetadata(); CHotkeyCombination::registerMetadata();
qDBusRegisterMetaType<KeyCode>();
} }
void BlackMisc::registerMetadata() void BlackMisc::registerMetadata()

View File

@@ -14,24 +14,24 @@
namespace BlackMisc namespace BlackMisc
{ {
CIcon::CIcon(CIcons::IconIndex index, const QString &descriptiveText) : CIcon::CIcon(CIcons::IconIndex index, const QString &descriptiveText) :
m_index(static_cast<int>(index)), m_descriptiveText(descriptiveText) {} m_index(index), m_descriptiveText(descriptiveText) {}
CIcon::CIcon(const QPixmap &pixmap, const QString &descriptiveText) : CIcon::CIcon(const QPixmap &pixmap, const QString &descriptiveText) :
m_index(static_cast<int>(CIcons::IconIsGenerated)), m_descriptiveText(descriptiveText), m_pixmap(pixmap) m_index(CIcons::IconIsGenerated), m_descriptiveText(descriptiveText), m_pixmap(pixmap)
{ } { }
CIcon::CIcon(const QString &resourceFilePath, const QString &descriptiveText) : CIcon::CIcon(const QString &resourceFilePath, const QString &descriptiveText) :
m_index(static_cast<int>(CIcons::IconIsFile)), m_descriptiveText(descriptiveText), m_pixmap(CIcons::pixmapByResourceFileName(resourceFilePath)) m_index(CIcons::IconIsFile), m_descriptiveText(descriptiveText), m_pixmap(CIcons::pixmapByResourceFileName(resourceFilePath))
{} {}
CIcons::IconIndex CIcon::getIndex() const CIcons::IconIndex CIcon::getIndex() const
{ {
return static_cast<CIcons::IconIndex>(this->m_index); return this->m_index;
} }
bool CIcon::isIndexBased() const bool CIcon::isIndexBased() const
{ {
return m_index >= 0 && m_index < static_cast<int>(CIcons::IconIsGenerated); return m_index >= 0 && m_index < CIcons::IconIsGenerated;
} }
bool CIcon::isGenerated() const bool CIcon::isGenerated() const
@@ -46,7 +46,7 @@ namespace BlackMisc
bool CIcon::isSet() const bool CIcon::isSet() const
{ {
return (this->m_index != static_cast<int>(CIcons::NotSet)); return (this->m_index != CIcons::NotSet);
} }
QPixmap CIcon::toPixmap() const QPixmap CIcon::toPixmap() const

View File

@@ -130,7 +130,7 @@ namespace BlackMisc
private: private:
BLACK_ENABLE_TUPLE_CONVERSION(CIcon) BLACK_ENABLE_TUPLE_CONVERSION(CIcon)
int m_index = static_cast<int>(CIcons::NotSet); CIcons::IconIndex m_index = CIcons::NotSet;
int m_rotateDegrees = 0; //!< Rotation int m_rotateDegrees = 0; //!< Rotation
QString m_descriptiveText; //!< what does it represent? QString m_descriptiveText; //!< what does it represent?
QPixmap m_pixmap; //!< Used with generated pixmaps, when not used with index QPixmap m_pixmap; //!< Used with generated pixmaps, when not used with index

View File

@@ -642,4 +642,7 @@ namespace BlackMisc
static QMap<QString, QPixmap> &getResourceFileCache(); static QMap<QString, QPixmap> &getResourceFileCache();
}; };
} }
Q_DECLARE_METATYPE(BlackMisc::CIcons::IconIndex)
#endif // guard #endif // guard

View File

@@ -75,7 +75,7 @@ namespace BlackMisc
switch (i) switch (i)
{ {
case IndexKey: case IndexKey:
return CVariant::from(static_cast<int>(this->m_keyCode)); return CVariant::from(this->m_keyCode);
case IndexKeyAsString: case IndexKeyAsString:
return CVariant::from(getKeyAsString()); return CVariant::from(getKeyAsString());
default: default:

View File

@@ -12,6 +12,8 @@
#ifndef BLACKMISC_INPUT_KEYCODES_H #ifndef BLACKMISC_INPUT_KEYCODES_H
#define BLACKMISC_INPUT_KEYCODES_H #define BLACKMISC_INPUT_KEYCODES_H
#include <QMetaType>
namespace BlackMisc namespace BlackMisc
{ {
namespace Input namespace Input
@@ -70,4 +72,6 @@ namespace BlackMisc
} //namespace } //namespace
} // namespace } // namespace
Q_DECLARE_METATYPE(BlackMisc::Input::KeyCode)
#endif //guard #endif //guard

View File

@@ -54,11 +54,11 @@ namespace BlackMisc
// special case, handle icon and allow to set it // special case, handle icon and allow to set it
// doing this in the switch gives gcc warning as IndexIcon is no member of ColumnIndex // doing this in the switch gives gcc warning as IndexIcon is no member of ColumnIndex
if (i == static_cast<int>(IndexIcon)) if (static_cast<int>(i) == static_cast<int>(IndexIcon))
{ {
if (static_cast<QMetaType::Type>(variant.type()) == QMetaType::Int) if (static_cast<QMetaType::Type>(variant.type()) == QMetaType::Int)
{ {
CIcons::IconIndex index = static_cast<CIcons::IconIndex>(variant.toInt()); CIcons::IconIndex index = variant.value<CIcons::IconIndex>();
this->m_icon = CIconList::iconByIndex(index); this->m_icon = CIconList::iconByIndex(index);
} }
else else

View File

@@ -37,16 +37,16 @@ namespace BlackMisc
CVoiceCapabilities() = default; CVoiceCapabilities() = default;
//! Constructor by callsign //! Constructor by callsign
CVoiceCapabilities(VoiceCapabilities capabilities) : m_voiceCapabilities(static_cast<int>(capabilities)) {} CVoiceCapabilities(VoiceCapabilities capabilities) : m_voiceCapabilities(capabilities) {}
//! Constructor. //! Constructor.
CVoiceCapabilities(const QString &flightPlanRemarks); CVoiceCapabilities(const QString &flightPlanRemarks);
//! Get capabilities //! Get capabilities
VoiceCapabilities getCapabilities() const { return static_cast<VoiceCapabilities>(m_voiceCapabilities); } VoiceCapabilities getCapabilities() const { return m_voiceCapabilities; }
//! Set capabilites //! Set capabilites
void setCapabilities(VoiceCapabilities capabilites) { m_voiceCapabilities = static_cast<int>(capabilites); } void setCapabilities(VoiceCapabilities capabilites) { m_voiceCapabilities = capabilites; }
//! Is capability known //! Is capability known
bool isUnknown() const { return m_voiceCapabilities == Unknown; } bool isUnknown() const { return m_voiceCapabilities == Unknown; }
@@ -71,7 +71,7 @@ namespace BlackMisc
private: private:
BLACK_ENABLE_TUPLE_CONVERSION(CVoiceCapabilities) BLACK_ENABLE_TUPLE_CONVERSION(CVoiceCapabilities)
int m_voiceCapabilities = Unknown; VoiceCapabilities m_voiceCapabilities = Unknown;
//! Capabilites from flight plans remarks such as "/V/" //! Capabilites from flight plans remarks such as "/V/"
void setFromFlightPlanRemarks(const QString &flightPlanRemarks); void setFromFlightPlanRemarks(const QString &flightPlanRemarks);

View File

@@ -12,6 +12,8 @@
#ifndef BLACKMISC_NOTIFICATIONSOUNDS_H #ifndef BLACKMISC_NOTIFICATIONSOUNDS_H
#define BLACKMISC_NOTIFICATIONSOUNDS_H #define BLACKMISC_NOTIFICATIONSOUNDS_H
#include <QMetaType>
namespace BlackSound namespace BlackSound
{ {
@@ -44,4 +46,7 @@ namespace BlackSound
}; };
} // ns } // ns
Q_DECLARE_METATYPE(BlackSound::CNotificationSounds::PlayMode)
Q_DECLARE_METATYPE(BlackSound::CNotificationSounds::Notification)
#endif // guard #endif // guard

View File

@@ -20,6 +20,12 @@ namespace BlackMisc
{ {
namespace Simulation namespace Simulation
{ {
void CAircraftModel::registerMetadata()
{
CValueObject<CAircraftModel>::registerMetadata();
qRegisterMetaType<ModelType>();
}
CAircraftModel::CAircraftModel(const QString &model, CAircraftModel::ModelType type) : CAircraftModel::CAircraftModel(const QString &model, CAircraftModel::ModelType type) :
m_modelString(model.trimmed().toUpper()), m_modelType(type) m_modelString(model.trimmed().toUpper()), m_modelType(type)
{} {}
@@ -59,11 +65,11 @@ namespace BlackMisc
case IndexHasQueriedModelString: case IndexHasQueriedModelString:
return CVariant::fromValue(this->hasQueriedModelString()); return CVariant::fromValue(this->hasQueriedModelString());
case IndexModelType: case IndexModelType:
return CVariant::fromValue(static_cast<int>(this->m_modelType)); return CVariant::fromValue(this->m_modelType);
case IndexModelTypeAsString: case IndexModelTypeAsString:
return CVariant(this->getModelTypeAsString()); return CVariant(this->getModelTypeAsString());
case IndexModelMode: case IndexModelMode:
return CVariant::fromValue(static_cast<int>(this->m_modelMode)); return CVariant::fromValue(this->m_modelMode);
case IndexModelModeAsString: case IndexModelModeAsString:
return CVariant(this->getModelModeAsString()); return CVariant(this->getModelModeAsString());
case IndexDistributor: case IndexDistributor:
@@ -123,10 +129,10 @@ namespace BlackMisc
this->m_fileName = variant.toQString(); this->m_fileName = variant.toQString();
break; break;
case IndexModelType: case IndexModelType:
this->m_modelType = static_cast<ModelType>(variant.toInt()); this->m_modelType = variant.value<ModelType>();
break; break;
case IndexModelMode: case IndexModelMode:
this->m_modelMode = static_cast<ModelMode>(variant.toInt()); this->m_modelMode = variant.value<ModelMode>();
break; break;
default: default:
CValueObject::setPropertyByIndex(variant, index); CValueObject::setPropertyByIndex(variant, index);
@@ -173,7 +179,7 @@ namespace BlackMisc
if (this->m_description.isEmpty()) { this->setDescription(model.getDescription()); } if (this->m_description.isEmpty()) { this->setDescription(model.getDescription()); }
if (this->m_fileName.isEmpty()) { this->setFileName(model.getFileName()); } if (this->m_fileName.isEmpty()) { this->setFileName(model.getFileName()); }
if (this->m_callsign.isEmpty()) { this->setCallsign(model.getCallsign()); } if (this->m_callsign.isEmpty()) { this->setCallsign(model.getCallsign()); }
if (this->m_modelType == static_cast<int>(TypeUnknown)) { this->m_modelType = model.getModelType(); } if (this->m_modelType == TypeUnknown) { this->m_modelType = model.getModelType(); }
if (this->m_simulator.isUnspecified()) if (this->m_simulator.isUnspecified())
{ {
this->setSimulatorInfo(model.getSimulatorInfo()); this->setSimulatorInfo(model.getSimulatorInfo());

View File

@@ -73,6 +73,9 @@ namespace BlackMisc
IndexHasQueriedModelString IndexHasQueriedModelString
}; };
//! \copydoc BlackMisc::CValueObject::registerMetadata
static void registerMetadata();
//! Default constructor. //! Default constructor.
CAircraftModel() {} CAircraftModel() {}
@@ -272,5 +275,7 @@ BLACK_DECLARE_TUPLE_CONVERSION(
attr(o.m_modelMode) attr(o.m_modelMode)
)) ))
Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftModel) Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftModel)
Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftModel::ModelType)
Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftModel::ModelMode)
#endif // guard #endif // guard

View File

@@ -54,7 +54,7 @@ namespace BlackMisc
return this->m_ownAircraftProvider->updateCockpit(com1, com2, transponder, originator); return this->m_ownAircraftProvider->updateCockpit(com1, com2, transponder, originator);
} }
bool COwnAircraftAware::updateActiveComFrequency(const CFrequency &frequency, int comUnit, const CIdentifier &originator) bool COwnAircraftAware::updateActiveComFrequency(const CFrequency &frequency, CComSystem::ComUnit comUnit, const CIdentifier &originator)
{ {
Q_ASSERT_X(this->m_ownAircraftProvider, Q_FUNC_INFO, "No object available"); Q_ASSERT_X(this->m_ownAircraftProvider, Q_FUNC_INFO, "No object available");
return this->m_ownAircraftProvider->updateActiveComFrequency(frequency, comUnit, originator); return this->m_ownAircraftProvider->updateActiveComFrequency(frequency, comUnit, originator);

View File

@@ -74,7 +74,7 @@ namespace BlackMisc
//! Update cockpit, but send signals when applicable //! Update cockpit, but send signals when applicable
//! \threadsafe //! \threadsafe
virtual bool updateActiveComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, int comUnit, const BlackMisc::CIdentifier &originator) = 0; virtual bool updateActiveComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit comUnit, const BlackMisc::CIdentifier &originator) = 0;
//! Update cockpit, but send signals when applicable //! Update cockpit, but send signals when applicable
//! \threadsafe //! \threadsafe
@@ -105,7 +105,7 @@ namespace BlackMisc
virtual bool updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const BlackMisc::CIdentifier &originator); virtual bool updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const BlackMisc::CIdentifier &originator);
//! \copydoc IOwnAircraftProvider::updateComFrequency //! \copydoc IOwnAircraftProvider::updateComFrequency
virtual bool updateActiveComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, int comUnit, const BlackMisc::CIdentifier &originator); virtual bool updateActiveComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit comUnit, const BlackMisc::CIdentifier &originator);
//! \copydoc IOwnAircraftProvider::updateSelcal //! \copydoc IOwnAircraftProvider::updateSelcal
virtual bool updateSelcal(const BlackMisc::Aviation::CSelcal &selcal, const BlackMisc::CIdentifier &originator); virtual bool updateSelcal(const BlackMisc::Aviation::CSelcal &selcal, const BlackMisc::CIdentifier &originator);

View File

@@ -46,13 +46,12 @@ namespace BlackMisc
return true; return true;
} }
bool COwnAircraftProviderDummy::updateActiveComFrequency(const PhysicalQuantities::CFrequency &frequency, int comUnit, const BlackMisc::CIdentifier &originator) bool COwnAircraftProviderDummy::updateActiveComFrequency(const PhysicalQuantities::CFrequency &frequency, CComSystem::ComUnit comUnit, const BlackMisc::CIdentifier &originator)
{ {
if (!CComSystem::isValidComFrequency(frequency)) { return false; } if (!CComSystem::isValidComFrequency(frequency)) { return false; }
CComSystem::ComUnit comUnitEnum = static_cast<CComSystem::ComUnit>(comUnit); CComSystem com = m_ownAircraft.getComSystem(comUnit);
CComSystem com = m_ownAircraft.getComSystem(comUnitEnum);
com.setFrequencyActive(frequency); com.setFrequencyActive(frequency);
m_ownAircraft.setComSystem(com, comUnitEnum); m_ownAircraft.setComSystem(com, comUnit);
Q_UNUSED(originator); Q_UNUSED(originator);
return true; return true;
} }

View File

@@ -53,7 +53,7 @@ namespace BlackMisc
virtual bool updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const BlackMisc::CIdentifier &originator) override; virtual bool updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const BlackMisc::CIdentifier &originator) override;
//! \copydoc IOwnAircraftProvider::updateComFrequency //! \copydoc IOwnAircraftProvider::updateComFrequency
virtual bool updateActiveComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, int comUnit, const BlackMisc::CIdentifier &originator) override; virtual bool updateActiveComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit comUnit, const BlackMisc::CIdentifier &originator) override;
//! \copydoc IOwnAircraftProvider::updateSelcal //! \copydoc IOwnAircraftProvider::updateSelcal
virtual bool updateSelcal(const BlackMisc::Aviation::CSelcal &selcal, const BlackMisc::CIdentifier &originator) override; virtual bool updateSelcal(const BlackMisc::Aviation::CSelcal &selcal, const BlackMisc::CIdentifier &originator) override;

View File

@@ -18,6 +18,12 @@
namespace BlackMisc namespace BlackMisc
{ {
void CStatusMessage::registerMetadata()
{
CValueObject<CStatusMessage>::registerMetadata();
qRegisterMetaType<StatusSeverity>();
}
CStatusMessage::CStatusMessage(const QString &message) CStatusMessage::CStatusMessage(const QString &message)
: m_message(message) : m_message(message)
{} {}
@@ -281,7 +287,7 @@ namespace BlackMisc
case IndexMessage: case IndexMessage:
return CVariant::from(this->m_message); return CVariant::from(this->m_message);
case IndexSeverity: case IndexSeverity:
return CVariant::from(static_cast<uint>(this->m_severity)); return CVariant::from(this->m_severity);
case IndexSeverityAsString: case IndexSeverityAsString:
return CVariant::from(this->getSeverityAsString()); return CVariant::from(this->getSeverityAsString());
case IndexCategories: case IndexCategories:
@@ -304,7 +310,7 @@ namespace BlackMisc
this->m_message = variant.value<QString>(); this->m_message = variant.value<QString>();
break; break;
case IndexSeverity: case IndexSeverity:
this->m_severity = static_cast<StatusSeverity>(variant.value<uint>()); this->m_severity = variant.value<StatusSeverity>();
break; break;
case IndexCategories: case IndexCategories:
this->m_categories = variant.value<CLogCategoryList>(); this->m_categories = variant.value<CLogCategoryList>();

View File

@@ -50,6 +50,9 @@ namespace BlackMisc
IndexMessage IndexMessage
}; };
//! \copydoc BlackMisc::CValueObject::registerMetadata
static void registerMetadata();
//! Constructor //! Constructor
CStatusMessage() = default; CStatusMessage() = default;
@@ -184,5 +187,6 @@ BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::CStatusMessage, (
attr(o.m_handledByObjects, flags < DisabledForHashing | DisabledForJson | DisabledForComparison | DisabledForMarshalling > ()) attr(o.m_handledByObjects, flags < DisabledForHashing | DisabledForJson | DisabledForComparison | DisabledForMarshalling > ())
)) ))
Q_DECLARE_METATYPE(BlackMisc::CStatusMessage) Q_DECLARE_METATYPE(BlackMisc::CStatusMessage)
Q_DECLARE_METATYPE(BlackMisc::CStatusMessage::StatusSeverity)
#endif // guard #endif // guard

View File

@@ -17,6 +17,13 @@ namespace BlackMisc
namespace Weather namespace Weather
{ {
void CPresentWeather::registerMetadata()
{
CValueObject<CPresentWeather>::registerMetadata();
qRegisterMetaType<Intensity>();
qRegisterMetaType<Descriptor>();
}
CPresentWeather::CPresentWeather(Intensity intensity, Descriptor descriptor, int weatherPhenomena) : CPresentWeather::CPresentWeather(Intensity intensity, Descriptor descriptor, int weatherPhenomena) :
m_intensity(intensity), m_descriptor(descriptor), m_weatherPhenomena(weatherPhenomena) m_intensity(intensity), m_descriptor(descriptor), m_weatherPhenomena(weatherPhenomena)
{ } { }
@@ -28,9 +35,9 @@ namespace BlackMisc
switch (i) switch (i)
{ {
case IndexIntensity: case IndexIntensity:
return CVariant::fromValue<int>(static_cast<int>(m_intensity)); return CVariant::fromValue(m_intensity);
case IndexDescriptor: case IndexDescriptor:
return CVariant::fromValue<int>(static_cast<int>(m_descriptor)); return CVariant::fromValue(m_descriptor);
case IndexWeatherPhenomena: case IndexWeatherPhenomena:
return CVariant::fromValue(m_weatherPhenomena); return CVariant::fromValue(m_weatherPhenomena);
default: default:
@@ -45,10 +52,10 @@ namespace BlackMisc
switch (i) switch (i)
{ {
case IndexIntensity: case IndexIntensity:
setIntensity(static_cast<Intensity>(variant.toInt())); setIntensity(variant.value<Intensity>());
break; break;
case IndexDescriptor: case IndexDescriptor:
setDescriptor(static_cast<Descriptor>(variant.toInt())); setDescriptor(variant.value<Descriptor>());
break; break;
case IndexWeatherPhenomena: case IndexWeatherPhenomena:
setWeatherPhenomena(variant.toInt()); setWeatherPhenomena(variant.toInt());

View File

@@ -88,6 +88,9 @@ namespace BlackMisc
IndexWeatherPhenomena IndexWeatherPhenomena
}; };
//! \copydoc BlackMisc::CValueObject::registerMetadata
static void registerMetadata();
//! Default constructor. //! Default constructor.
CPresentWeather() = default; CPresentWeather() = default;
@@ -132,6 +135,8 @@ namespace BlackMisc
} // namespace } // namespace
Q_DECLARE_METATYPE(BlackMisc::Weather::CPresentWeather) Q_DECLARE_METATYPE(BlackMisc::Weather::CPresentWeather)
Q_DECLARE_METATYPE(BlackMisc::Weather::CPresentWeather::Intensity)
Q_DECLARE_METATYPE(BlackMisc::Weather::CPresentWeather::Descriptor)
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Weather::CPresentWeather, ( BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Weather::CPresentWeather, (
attr(o.m_intensity), attr(o.m_intensity),
attr(o.m_descriptor), attr(o.m_descriptor),