Commit f59359af authored by Arjen Hiemstra's avatar Arjen Hiemstra

Add a "ready" property to SensorDataModel

This indicates the model has loaded the metadata for the current sensors
and thus querying metadata properties for these sensors will not return
invalid results.
parent 8a5fb2ce
......@@ -238,6 +238,7 @@ void SensorDataModel::setSensors(const QStringList &sensorIds)
if (!d->usedByQml || d->componentComplete) {
d->sensorsChanged();
}
Q_EMIT readyChanged();
Q_EMIT sensorsChanged();
}
......@@ -277,6 +278,11 @@ void SensorDataModel::setSensorColors(const QVariantMap &sensorColors)
Q_EMIT sensorColorsChanged();
}
bool KSysGuard::SensorDataModel::isReady() const
{
return d->sensors.size() == d->requestedSensors.size();
}
void SensorDataModel::addSensor(const QString &sensorId)
{
d->addSensor(sensorId);
......@@ -382,6 +388,7 @@ void SensorDataModel::onMetaDataChanged(const QString &sensorId, const SensorInf
SensorDaemonInterface::instance()->requestValue(sensorId);
emit sensorMetaDataChanged();
Q_EMIT readyChanged();
}
void SensorDataModel::onValueChanged(const QString &sensorId, const QVariant &value)
......
......@@ -58,6 +58,13 @@ class SENSORS_EXPORT SensorDataModel : public QAbstractTableModel, public QQmlPa
* Should this model be updated or not. Defaults to true.
*/
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
/**
* Is this model ready?
*
* Ready means it has retrieved the metadata for the sensors specified in
* \ref sensors.
*/
Q_PROPERTY(bool ready READ isReady NOTIFY readyChanged)
/**
* Used by the model to provide data for the Color role if set.
......@@ -112,6 +119,9 @@ public:
void setSensorColors(const QVariantMap &sensorColors);
Q_SIGNAL void sensorColorsChanged();
bool isReady() const;
Q_SIGNAL void readyChanged();
Q_INVOKABLE void addSensor(const QString &sensorId);
Q_INVOKABLE void removeSensor(const QString &sensorId);
Q_INVOKABLE int column(const QString &sensorId) const;
......
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