From 4617d8b63620de9729a07c5d17e8b3113fbb58a3 Mon Sep 17 00:00:00 2001 From: Raquel Medina Date: Mon, 22 Jul 2019 15:04:17 +0200 Subject: network: use roles to signal model changes This commit provides: - use of specific roles to signal model changes for wired and wifi network models. - fix to correctly broadcast wifi strength on initial connection to previously unknown wifi service. Bug-AGL: SPEC-2339 Signed-off-by: Raquel Medina Change-Id: I35922d6c96b8b89fd4d376cddd8f4113cf18dbca --- network/wifinetworkmodel.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'network/wifinetworkmodel.cpp') diff --git a/network/wifinetworkmodel.cpp b/network/wifinetworkmodel.cpp index 71e5298..7c32779 100644 --- a/network/wifinetworkmodel.cpp +++ b/network/wifinetworkmodel.cpp @@ -1,5 +1,6 @@ #include "wifinetworkmodel.h" #include "connectionprofile.h" +#include #include WifiNetworkModel::WifiNetworkModel(QObject *parent) @@ -47,24 +48,33 @@ QHash WifiNetworkModel::roleNames() const { void WifiNetworkModel::updateProperties(QString service, QJsonObject properties) { ConnectionProfile *network; + QVector vroles; + bool sbcast = false; - // FIXME: add role parameter to emits if ((network = getNetwork(service))) { if (properties.contains("ipv4")) { QString address = properties.value("ipv4").toObject().value("address").toString(); network->setAddress(address); - emit dataChanged(indexOf(network), indexOf(network)); + vroles.push_back(AddressRole); } if (properties.contains("state")) { network->setState(properties.value("state").toString()); - emit dataChanged(indexOf(network), indexOf(network)); + vroles.push_back(StateRole); + if ((network->state() == "ready") || + (network->state() == "online")) + sbcast = true; } if (properties.contains("strength")) { network->setStrength(properties.value("strength").toInt()); - emit dataChanged(indexOf(network), indexOf(network)); + vroles.push_back(StrengthRole); if ((network->state() == "ready") || (network->state() == "online")) - emit strengthChanged(network->strength()); + sbcast = true; + } + if (!vroles.isEmpty()) { + emit dataChanged(indexOf(network), indexOf(network), vroles); + if (sbcast) + emit strengthChanged(network->strength()); } } } -- cgit 1.2.3-korg