Commit 2a4dd9fb authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Allow setting SensorObject's name after construction

It's just a user visible string so there seems no harm in this. It is
not yet properly signalled to the client that it changed however.
parent 06caa120
...@@ -61,6 +61,16 @@ QString SensorObject::path() const ...@@ -61,6 +61,16 @@ QString SensorObject::path() const
return m_parent->id() % QLatin1Char('/') % m_id; return m_parent->id() % QLatin1Char('/') % m_id;
} }
void SensorObject::setName(const QString& newName)
{
if (newName == m_name) {
return;
}
m_name = newName;
Q_EMIT nameChanged();
}
void SensorObject::setParentContainer(SensorContainer* parent) void SensorObject::setParentContainer(SensorContainer* parent)
{ {
m_parent = parent; m_parent = parent;
......
...@@ -40,8 +40,10 @@ public: ...@@ -40,8 +40,10 @@ public:
~SensorObject(); ~SensorObject();
QString id() const; QString id() const;
QString name() const;
QString path() const; QString path() const;
QString name() const;
void setName(const QString &newName);
void setParentContainer(SensorContainer *parent); void setParentContainer(SensorContainer *parent);
QList<SensorProperty *> sensors() const; QList<SensorProperty *> sensors() const;
...@@ -50,6 +52,7 @@ public: ...@@ -50,6 +52,7 @@ public:
void addProperty(SensorProperty *property); void addProperty(SensorProperty *property);
bool isSubscribed() const; bool isSubscribed() const;
Q_SIGNALS: Q_SIGNALS:
/** /**
* Emitted when a client subscribes to one or more of the underlying properties of this object * Emitted when a client subscribes to one or more of the underlying properties of this object
...@@ -62,6 +65,11 @@ Q_SIGNALS: ...@@ -62,6 +65,11 @@ Q_SIGNALS:
*/ */
void aboutToBeRemoved(); void aboutToBeRemoved();
/**
* Emitted whenever the object's name changes.
*/
void nameChanged();
private: private:
SensorContainer *m_parent = nullptr; SensorContainer *m_parent = nullptr;
QString m_id; QString m_id;
......
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