Commit 76c95a21 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Add an enabled property to ProcessDataModel

Allows disabling updates for ProcessDataModel, when it is not visible or
otherwise shouldn't be updating.
parent 9c73bad0
......@@ -205,6 +205,26 @@ void ProcessDataModel::setEnabledAttributes(const QStringList &enabledAttributes
emit enabledAttributesChanged();
}
bool ProcessDataModel::enabled() const
{
return d->m_timer->isActive();
}
void ProcessDataModel::setEnabled(bool newEnabled)
{
if (newEnabled == d->m_timer->isActive()) {
return;
}
if (newEnabled) {
d->m_timer->start();
} else {
d->m_timer->stop();
}
Q_EMIT enabledChanged();
}
QModelIndex ProcessDataModel::index(int row, int column, const QModelIndex &parent) const
{
if (row < 0) {
......
......@@ -45,6 +45,7 @@ class Q_DECL_EXPORT ProcessDataModel : public QAbstractItemModel
Q_PROPERTY(QStringList availableAttributes READ availableAttributes CONSTANT)
Q_PROPERTY(QStringList enabledAttributes READ enabledAttributes WRITE setEnabledAttributes NOTIFY enabledAttributesChanged)
Q_PROPERTY(QAbstractItemModel *attributesModel READ attributesModel CONSTANT)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
public:
enum AdditionalRoles {
......@@ -88,6 +89,10 @@ public:
*/
void setEnabledAttributes(const QStringList &enabledAttributes);
bool enabled() const;
void setEnabled(bool newEnabled);
Q_SIGNAL void enabledChanged();
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
......
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