From 8bc698aaad002286270639fe15f80815bc4df878 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Fri, 23 Jul 2010 15:17:08 +1000 Subject: 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 (cherry picked from commit 88d721fa8d28519e98207ca0249ff057faef8af0) --- examples/network/bearermonitor/bearermonitor.cpp | 14 +++++--------- 1 file 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 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 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) -- cgit v0.12