Update ZigbeeNodesProxy filter when a device changes reachable state

pull/774/head
Michael Zanetti 2022-02-20 23:23:20 +01:00
parent e8f9e83abd
commit 3882f367ff
2 changed files with 8 additions and 3 deletions

View File

@ -65,6 +65,12 @@ void ZigbeeNodesProxy::setZigbeeNodes(ZigbeeNodes *zigbeeNodes)
m_newNodes.insert(m_zigbeeNodes->get(i), QDateTime::currentDateTime());
}
});
connect(m_zigbeeNodes, &ZigbeeNodes::dataChanged, this, [this](const QModelIndex &/*topLeft*/, const QModelIndex &/*bottomRight*/, const QVector<int> &roles = QVector<int>()){
if (roles.contains(ZigbeeNodes::RoleReachable) && (!m_showOffline || !m_showOnline)) {
invalidateFilter();
emit countChanged();
}
});
setSourceModel(m_zigbeeNodes);

View File

@ -173,8 +173,8 @@ SettingsPageBase {
Label {
Layout.fillWidth: true
text: offlineNodes.count == 0
? qsTr("%n device(s)", "", networkDelegate.network.nodes.count)
: qsTr("%n device(s) (%1 disconnected)", "", networkDelegate.network.nodes.count).arg(offlineNodes.count)
? qsTr("%n device(s)", "", Math.max(0, networkDelegate.network.nodes.count - 1)) // -1 for coordinator node
: qsTr("%n device(s) (%1 disconnected)", "", Math.max(networkDelegate.network.nodes.count - 1)).arg(offlineNodes.count)
ZigbeeNodesProxy {
id: offlineNodes
@ -183,7 +183,6 @@ SettingsPageBase {
showOnline: false
}
}
}
}
}