summaryrefslogtreecommitdiffstats
path: root/network
diff options
context:
space:
mode:
Diffstat (limited to 'network')
-rw-r--r--network/wifinetworkmodel.cpp20
-rw-r--r--network/wirednetworkmodel.cpp10
2 files changed, 22 insertions, 8 deletions
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 <QVector>
#include <QDebug>
WifiNetworkModel::WifiNetworkModel(QObject *parent)
@@ -47,24 +48,33 @@ QHash<int, QByteArray> WifiNetworkModel::roleNames() const {
void WifiNetworkModel::updateProperties(QString service, QJsonObject properties)
{
ConnectionProfile *network;
+ QVector<int> 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());
}
}
}
diff --git a/network/wirednetworkmodel.cpp b/network/wirednetworkmodel.cpp
index eb8988b..01a50fb 100644
--- a/network/wirednetworkmodel.cpp
+++ b/network/wirednetworkmodel.cpp
@@ -1,5 +1,6 @@
#include "wirednetworkmodel.h"
#include "connectionprofile.h"
+#include <QVector>
#include <QDebug>
WiredNetworkModel::WiredNetworkModel(QObject *parent)
@@ -46,17 +47,20 @@ QHash<int, QByteArray> WiredNetworkModel::roleNames() const {
void WiredNetworkModel::updateProperties(QString service, QJsonObject properties)
{
ConnectionProfile *network;
+ QVector<int> vroles;
- // 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 (!vroles.isEmpty())
+ emit dataChanged(indexOf(network), indexOf(network), vroles);
+
}
}