summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKimmo Ollila <kimmo.ollila@theqtcompany.com>2016-06-14 14:15:08 +0300
committerKimmo Ollila <kimmo.ollila@theqtcompany.com>2016-06-14 11:40:14 +0000
commitd0d70c3311b3dc3f0e4c11147a4b31e4da0ff56c (patch)
tree5ac6434fb1114c31d80fb4a39b20a81ed31b2dc7 /src
parent05eed5820a5f7778c49ff0f51f0782c4373c6127 (diff)
Fixes to networkSettingsService model handling
Change-Id: Ifcea4b0111ad16f4c41692af4db04c044da8359b Reviewed-by: Teemu Holappa <teemu.holappa@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/networksettings/connman/qnetworksettingsmanager_p.cpp7
-rw-r--r--src/networksettings/qnetworksettingsservicemodel.cpp17
-rw-r--r--src/networksettings/qnetworksettingsservicemodel.h1
-rw-r--r--src/settingsui/network/ComboBoxEntry.qml1
-rw-r--r--src/settingsui/network/WifiSettings.qml54
5 files changed, 69 insertions, 11 deletions
diff --git a/src/networksettings/connman/qnetworksettingsmanager_p.cpp b/src/networksettings/connman/qnetworksettingsmanager_p.cpp
index 125d242..875be9b 100644
--- a/src/networksettings/connman/qnetworksettingsmanager_p.cpp
+++ b/src/networksettings/connman/qnetworksettingsmanager_p.cpp
@@ -141,12 +141,7 @@ void QNetworkSettingsManagerPrivate::getTechnologiesFinished(QDBusPendingCallWat
void QNetworkSettingsManagerPrivate::onServicesChanged(ConnmanMapStructList changed, const QList<QDBusObjectPath> &removed)
{
foreach (QDBusObjectPath path, removed) {
- QList<QNetworkSettingsService*> serviceList = m_serviceModel->getModel();
- QMutableListIterator<QNetworkSettingsService*> i(serviceList);
- while (i.hasNext()) {
- if (i.next()->id() == path.path())
- i.remove();
- }
+ m_serviceModel->removeService(path.path());
}
QStringList newServices;
diff --git a/src/networksettings/qnetworksettingsservicemodel.cpp b/src/networksettings/qnetworksettingsservicemodel.cpp
index 4b8d87c..868cfa3 100644
--- a/src/networksettings/qnetworksettingsservicemodel.cpp
+++ b/src/networksettings/qnetworksettingsservicemodel.cpp
@@ -79,9 +79,9 @@ void QNetworkSettingsServiceModel::append(QNetworkSettingsService* item)
{
item->setParent(this);
- beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ beginResetModel();
m_items.append(item);
- endInsertRows();
+ endResetModel();
}
void QNetworkSettingsServiceModel::insert(int row, QNetworkSettingsService* item)
@@ -100,6 +100,19 @@ void QNetworkSettingsServiceModel::remove(int row)
endRemoveRows();
}
+bool QNetworkSettingsServiceModel::removeService(const QString &id)
+{
+ bool ret = false;
+ for (int i=0; i < m_items.count(); i++) {
+ if (m_items.at(i)->id() == id) {
+ remove(i);
+ ret = true;
+ break;
+ }
+ }
+ return ret;
+}
+
void QNetworkSettingsServiceModel::updated(int row)
{
dataChanged(createIndex(row, 0), createIndex(row, 0));
diff --git a/src/networksettings/qnetworksettingsservicemodel.h b/src/networksettings/qnetworksettingsservicemodel.h
index 811c127..0cf1601 100644
--- a/src/networksettings/qnetworksettingsservicemodel.h
+++ b/src/networksettings/qnetworksettingsservicemodel.h
@@ -47,6 +47,7 @@ public:
void append(QNetworkSettingsService* networkService);
void insert(int row, QNetworkSettingsService* networkInterface);
void remove(int row);
+ bool removeService(const QString &id);
void updated(int row);
QList<QNetworkSettingsService*> getModel();
diff --git a/src/settingsui/network/ComboBoxEntry.qml b/src/settingsui/network/ComboBoxEntry.qml
index f7fac3e..71b997c 100644
--- a/src/settingsui/network/ComboBoxEntry.qml
+++ b/src/settingsui/network/ComboBoxEntry.qml
@@ -40,6 +40,7 @@ RowLayout {
property alias delegate: cb.delegate
property alias textRole: cb.textRole
property alias model: cb.model
+ property alias count: cb.count
property int titleWidth: -1
Label {
diff --git a/src/settingsui/network/WifiSettings.qml b/src/settingsui/network/WifiSettings.qml
index 5514ece..7a0735c 100644
--- a/src/settingsui/network/WifiSettings.qml
+++ b/src/settingsui/network/WifiSettings.qml
@@ -35,6 +35,7 @@ Item {
id: root
anchors.fill: parent
Component.onCompleted: NetworkSettingsManager.services.type = NetworkSettingsType.Wifi;
+ property bool connecting: false
GroupBox {
id: content
@@ -58,13 +59,18 @@ Item {
}
Switch {
checked: selectedInterface.powered
- onCheckedChanged: selectedInterface.powered = checked
+ onCheckedChanged: {
+ selectedInterface.powered = checked
+ root.connecting = false
+ connectView.visible = false
+ }
}
}
RowLayout {
spacing: 10
width: parent.width
+ visible: selectedInterface.powered && networkSelection.count > 0
Label {
Layout.preferredWidth: root.width * 0.382
text: qsTr("Current network")
@@ -75,9 +81,27 @@ Item {
ComboBoxEntry {
id: networkSelection
model: NetworkSettingsManager.services
+
textRole: "name"
Layout.fillWidth: true
- onCurrentIndexChanged: if (currentIndex >= 0) model.itemFromRow(currentIndex).connectService();
+ onCurrentIndexChanged: {
+ if (currentIndex >= 0) {
+ connectView.visible = false
+
+ var service = model.itemFromRow(currentIndex)
+ if (service) {
+ root.connecting = true
+ service.connectService();
+ }
+ }
+ }
+
+ onCountChanged: {
+ if (count === 0) {
+ root.connecting = false
+ connectView.visible = false
+ }
+ }
delegate: WifiSelectorDelegate {
width: networkSelection.width
@@ -85,6 +109,25 @@ Item {
}
}
}
+
+ Row {
+ id: infoRow
+ spacing: 10
+ width: parent.width
+ visible: selectedInterface.powered && selectedInterface.state !== NetworkSettingsState.Online && (networkSelection.count == 0 || root.connecting)
+ Label {
+ id: scanningText
+ text: root.connecting ? qsTr("Connecting to the network...") : qsTr("Searching for Wi-Fi networks...")
+ horizontalAlignment: Text.AlignLeft
+ }
+ WifiSignalMonitor {
+ id: scanningIcon
+ scanning: true
+ height: scanningText.height
+ width: height
+ }
+ }
+
GroupBox {
id: connectView
title: qsTr("Enter a password")
@@ -159,7 +202,10 @@ Item {
}
Button {
text: qsTr("Cancel")
- onClicked:connectView.visible = false
+ onClicked: {
+ networkSelection.currentIndex = -1
+ connectView.visible = false
+ }
}
}
}
@@ -180,10 +226,12 @@ Item {
target: NetworkSettingsManager.userAgent
onShowUserCredentialsInput : {
connectView.visible = true
+ root.connecting = false
}
onError: {
errorView.visible = true
connectView.visible = true
+ root.connecting = false
}
}
}