diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-07-23 05:17:08 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-07-23 05:21:25 (GMT) |
commit | 88d721fa8d28519e98207ca0249ff057faef8af0 (patch) | |
tree | fefe8c06d483df97df528e8322366d6dceda84c5 /examples | |
parent | 959efa8daab2715d18440ed8b890b9dd2b501fc7 (diff) | |
download | Qt-88d721fa8d28519e98207ca0249ff057faef8af0.zip Qt-88d721fa8d28519e98207ca0249ff057faef8af0.tar.gz Qt-88d721fa8d28519e98207ca0249ff057faef8af0.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>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/network/bearermonitor/bearermonitor.cpp | 14 |
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) |