Commit f8b51f99 authored by Grégory JANISZEWSKI's avatar Grégory JANISZEWSKI

Add metaData property in QmlCanOpenValueModifier

* Fix const ref on QVariantMap
parent dd771e2c
......@@ -19,6 +19,9 @@ void QmlCanOpenValueModifier::prepareOBD (CanOpenObjDict * obd) {
CanOpenSubEntry * subEntry = entry->getSubEntry (m_subIndex);
subEntry->writeFromQtVariant (m_data);
subEntry->resetWrittenFlag ();
for (QVariantMap::const_iterator it = m_metaData.constBegin (); it != m_metaData.constEnd (); ++it) {
obd->setMetaDataForObdPos (m_index, subIndex, it.key (), it.value ());
}
}
else {
emit diag (Warning, QStringLiteral ("OBD entry %1 has no such subentry %2 !").arg (QString::fromLatin1 (QtCAN::hexNumberStr (m_index, 2))).arg (QString::fromLatin1 (QtCAN::hexNumberStr (m_subIndex, 1))));
......@@ -38,10 +41,14 @@ int QmlCanOpenValueModifier::getSubIndex (void) const {
return m_subIndex;
}
QVariant QmlCanOpenValueModifier::getData (void) const {
const QVariant & QmlCanOpenValueModifier::getData (void) const {
return m_data;
}
const QVariantMap & QmlCanOpenValueModifier::getMetaData (void) const {
return m_metaData;
}
void QmlCanOpenValueModifier::setIndex (const int index) {
if (index >= 0x0001 && index <= 0xFFFF) {
const CanOpenIndex tmp = CanOpenIndex (index);
......@@ -74,3 +81,10 @@ void QmlCanOpenValueModifier::setData (const QVariant & data) {
emit dataChanged ();
}
}
void QmlCanOpenValueModifier::setMetaData (const QVariantMap & metaData) {
if (m_metaData != metaData) {
m_metaData = metaData;
emit metaDataChanged ();
}
}
......@@ -8,33 +8,38 @@
class QTCAN_CANOPEN_EXPORT QmlCanOpenValueModifier : public AbstractObdPreparator {
Q_OBJECT
Q_PROPERTY (int index READ getIndex WRITE setIndex NOTIFY indexChanged)
Q_PROPERTY (int subIndex READ getSubIndex WRITE setSubIndex NOTIFY subIndexChanged)
Q_PROPERTY (QVariant data READ getData WRITE setData NOTIFY dataChanged)
Q_PROPERTY (int index READ getIndex WRITE setIndex NOTIFY indexChanged)
Q_PROPERTY (int subIndex READ getSubIndex WRITE setSubIndex NOTIFY subIndexChanged)
Q_PROPERTY (QVariant data READ getData WRITE setData NOTIFY dataChanged)
Q_PROPERTY (QVariantMap metaData READ getMetaData WRITE setMetaData NOTIFY metaDataChanged)
public:
explicit QmlCanOpenValueModifier (QObject * parent = Q_NULLPTR);
void prepareOBD (CanOpenObjDict * obd);
int getIndex (void) const;
int getSubIndex (void) const;
QVariant getData (void) const;
int getIndex (void) const;
int getSubIndex (void) const;
const QVariant & getData (void) const;
const QVariantMap & getMetaData (void) const;
public slots:
void setIndex (const int index);
void setSubIndex (const int subIndex);
void setData (const QVariant & data);
void setMetaData (const QVariantMap & metaData);
signals:
void indexChanged (void);
void subIndexChanged (void);
void dataChanged (void);
void metaDataChanged (void);
private:
CanOpenIndex m_index;
CanOpenSubIndex m_subIndex;
QVariant m_data;
QVariantMap m_metaData;
};
#endif // QMLCANOPENVALUEMODIFIER_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment