Commit 1d3b6e8f authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[System Tray] Update effective status on model insertion

Differential Revision: https://phabricator.kde.org/D28435
parent a05dc73c
......@@ -33,6 +33,7 @@ BaseModel::BaseModel(QObject *parent)
: QStandardItemModel(parent),
m_showAllItems(false)
{
connect(this, &BaseModel::rowsInserted, this, &BaseModel::onRowsInserted);
connect(this, &BaseModel::dataChanged, this, &BaseModel::onDataChanged);
}
......@@ -68,6 +69,18 @@ void BaseModel::onConfigurationChanged(const KConfigGroup &config)
}
}
void BaseModel::onRowsInserted(const QModelIndex &parent, int first, int last)
{
if (parent.isValid()) {
return;
}
for (int i = first; i <= last; ++i) {
QStandardItem *dataItem = item(i);
updateEffectiveStatus(dataItem);
}
}
void BaseModel::onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
{
if (roles.contains(static_cast<int>(BaseRole::Status)) || roles.contains(static_cast<int>(BaseRole::CanRender))) {
......
......@@ -52,6 +52,7 @@ public slots:
void onConfigurationChanged(const KConfigGroup &config);
private slots:
void onRowsInserted(const QModelIndex &parent, int first, int last);
void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
private:
......
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