summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-07-23 05:17:08 (GMT)
committerToby Tomkins <toby.tomkins@nokia.com>2010-07-29 03:37:59 (GMT)
commit8bc698aaad002286270639fe15f80815bc4df878 (patch)
tree0e21f3e9ddc2eef7f4598041094c215dd0208ba6
parent09ff0fb02378fa3aca92e9141d746880e11d7938 (diff)
downloadQt-8bc698aaad002286270639fe15f80815bc4df878.zip
Qt-8bc698aaad002286270639fe15f80815bc4df878.tar.gz
Qt-8bc698aaad002286270639fe15f80815bc4df878.tar.bz2
Show Service Network members in priority order.
The configurations returned from QNetworkConfiguration::children() are guaranteed to be in priority order. Ensure that this order is reflected in the tree view. Task-number: QTBUG-11678 RevBy: juhvu <qt-info@nokia.com> (cherry picked from commit 88d721fa8d28519e98207ca0249ff057faef8af0)
-rw-r--r--examples/network/bearermonitor/bearermonitor.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp
index 98869ea..1959919 100644
--- a/examples/network/bearermonitor/bearermonitor.cpp
+++ b/examples/network/bearermonitor/bearermonitor.cpp
@@ -180,10 +180,8 @@ void BearerMonitor::configurationChanged(const QNetworkConfiguration &config)
void BearerMonitor::updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap)
{
QMap<QString, QTreeWidgetItem *> itemMap;
- for (int i = 0; i < parent->childCount(); ++i) {
- QTreeWidgetItem *item = parent->child(i);
+ foreach (QTreeWidgetItem *item, parent->takeChildren())
itemMap.insert(item->data(0, Qt::UserRole).toString(), item);
- }
QList<QNetworkConfiguration> allConfigurations = snap.children();
@@ -194,6 +192,8 @@ void BearerMonitor::updateSnapConfiguration(QTreeWidgetItem *parent, const QNetw
if (item) {
updateItem(item, config);
+ parent->addChild(item);
+
if (config.type() == QNetworkConfiguration::ServiceNetwork)
updateSnapConfiguration(item, config);
} else {
@@ -201,10 +201,7 @@ void BearerMonitor::updateSnapConfiguration(QTreeWidgetItem *parent, const QNetw
}
}
- foreach (const QString &id, itemMap.keys())
- delete itemMap.value(id);
-
- itemMap.clear();
+ qDeleteAll(itemMap);
}
void BearerMonitor::updateConfigurations()
@@ -239,8 +236,7 @@ void BearerMonitor::updateConfigurations()
}
}
- foreach (const QString &id, itemMap.keys())
- delete itemMap.value(id);
+ qDeleteAll(itemMap);
}
void BearerMonitor::onlineStateChanged(bool isOnline)