Commit f50b717e authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Add a "prefix" property to SensorProperty

The final name consists of "prefix" + " " + "name" so that we can easily
change the prefix without needing to change the name. This helps when
dealing with sensors that should have a device name prefixed so they are
unambiguous.
parent 2a4dd9fb
......@@ -63,11 +63,12 @@ QString SensorProperty::path() const
void SensorProperty::setName(const QString &name)
{
if (m_info.name == name) {
if (m_name == name) {
return;
}
m_info.name = name;
m_name = name;
m_info.name = m_prefix % QLatin1Char(' ') % m_name;
emit sensorInfoChanged();
}
......@@ -81,6 +82,17 @@ void SensorProperty::setShortName(const QString &name)
emit sensorInfoChanged();
}
void SensorProperty::setPrefix(const QString &prefix)
{
if (m_prefix == prefix) {
return;
}
m_prefix = prefix;
m_info.name = prefix % QLatin1Char(' ') % m_name;
emit sensorInfoChanged();
}
void SensorProperty::setDescription(const QString &description)
{
if (m_info.description == description) {
......
......@@ -54,6 +54,7 @@ public:
*/
void setName(const QString &name);
void setShortName(const QString &name);
void setPrefix(const QString &name);
void setDescription(const QString &description);
/**
......@@ -115,7 +116,8 @@ private:
SensorObject *m_parent = nullptr;
SensorInfo m_info;
QString m_id;
QString m_path;
QString m_name;
QString m_prefix;
QVariant m_value;
int m_subscribers = 0;
};
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