summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-07-29 06:39:05 (GMT)
committerToby Tomkins <toby.tomkins@nokia.com>2010-08-05 00:15:30 (GMT)
commit803f92115a349798aaaf304221c841a7ff6c9e93 (patch)
treeb8beaf180020a712a439b8b29ce987f769c52920 /examples
parent5b142f20b2b20250f0fd8687e55ee4feb280113b (diff)
downloadQt-803f92115a349798aaaf304221c841a7ff6c9e93.zip
Qt-803f92115a349798aaaf304221c841a7ff6c9e93.tar.gz
Qt-803f92115a349798aaaf304221c841a7ff6c9e93.tar.bz2
Use an enum to return the bearer type of a network configuration.
Task-number: QTBUG-12378 Reviewed-by: Alex
Diffstat (limited to 'examples')
-rw-r--r--examples/network/bearercloud/cloud.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/examples/network/bearercloud/cloud.cpp b/examples/network/bearercloud/cloud.cpp
index f45ae0d..8deaab3 100644
--- a/examples/network/bearercloud/cloud.cpp
+++ b/examples/network/bearercloud/cloud.cpp
@@ -53,7 +53,7 @@
#include <math.h>
-static QMap<QString, QSvgRenderer *> svgCache;
+static QMap<QNetworkConfiguration::BearerType, QSvgRenderer *> svgCache;
//! [0]
Cloud::Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent)
@@ -313,17 +313,25 @@ void Cloud::stateChanged(QNetworkSession::State state)
//! [1]
void Cloud::newConfigurationActivated()
{
- const QString bearerTypeName = configuration.bearerTypeName();
- if (!svgCache.contains(bearerTypeName)) {
- if (bearerTypeName == QLatin1String("WLAN"))
- svgCache.insert(bearerTypeName, new QSvgRenderer(QLatin1String(":wlan.svg")));
- else if (bearerTypeName == QLatin1String("Ethernet"))
- svgCache.insert(bearerTypeName, new QSvgRenderer(QLatin1String(":lan.svg")));
- else
- svgCache.insert(bearerTypeName, new QSvgRenderer(QLatin1String(":unknown.svg")));
+ QNetworkConfiguration::BearerType bearerType = configuration.bearerType();
+ if (!svgCache.contains(bearerType)) {
+ QSvgRenderer *renderer = 0;
+ switch (bearerType) {
+ case QNetworkConfiguration::BearerWLAN:
+ renderer = new QSvgRenderer(QLatin1String(":wlan.svg"));
+ break;
+ case QNetworkConfiguration::BearerEthernet:
+ renderer = new QSvgRenderer(QLatin1String(":lan.svg"));
+ break;
+ default:
+ renderer = new QSvgRenderer(QLatin1String(":unknown.svg"));
+ }
+
+ if (renderer)
+ svgCache.insert(bearerType, renderer);
}
- icon->setSharedRenderer(svgCache[bearerTypeName]);
+ icon->setSharedRenderer(svgCache[bearerType]);
if (configuration.name().isEmpty()) {
text->setPlainText(tr("HIDDEN NETWORK"));