summaryrefslogtreecommitdiffstats
path: root/demos/embedded/qmlphotoviewer
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-07-07 06:28:45 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-07-19 00:32:33 (GMT)
commit75db37022a9fd479e2a446b57e774eaf8e3e73ea (patch)
treec00dffdb4fe9f38aba2385ff686c2d16b2cae2e3 /demos/embedded/qmlphotoviewer
parent192a3c6d69b42f02aa9033c30502a6930cceb8f7 (diff)
downloadQt-75db37022a9fd479e2a446b57e774eaf8e3e73ea.zip
Qt-75db37022a9fd479e2a446b57e774eaf8e3e73ea.tar.gz
Qt-75db37022a9fd479e2a446b57e774eaf8e3e73ea.tar.bz2
Convert examples and demos to use Bearer Management.
Task-number: QTBUG-10439
Diffstat (limited to 'demos/embedded/qmlphotoviewer')
-rw-r--r--demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp63
-rw-r--r--demos/embedded/qmlphotoviewer/qmlphotoviewer.pro2
2 files changed, 39 insertions, 26 deletions
diff --git a/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp b/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp
index 7889842..2b9db5e 100644
--- a/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp
+++ b/demos/embedded/qmlphotoviewer/qmlphotoviewer.cpp
@@ -40,41 +40,59 @@
****************************************************************************/
#include <QtCore/QFileInfo>
+#include <QtCore/QSettings>
#include <QtGui/QApplication>
#include <QtDeclarative/QDeclarativeView>
#include <QtDeclarative/QDeclarativeEngine>
+#include <QtDeclarative/QDeclarativeNetworkAccessManagerFactory>
+#include <QtNetwork/QNetworkConfiguration>
+#include <QtNetwork/QNetworkConfigurationManager>
+#include <QtNetwork/QNetworkAccessManager>
-#if defined(Q_OS_SYMBIAN)
-#include <QtCore/QTextCodec>
-#include <QtCore/QTimer>
-#include "sym_iap_util.h"
-
-class QmlAppView : public QDeclarativeView
+// Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise
+// the system default.
+class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory
{
-Q_OBJECT
public:
- QmlAppView(QWidget *parent = 0)
- : QDeclarativeView(parent)
- {
- QTimer::singleShot(0, this, SLOT(setDefaultIap()));
- }
+ ~NetworkAccessManagerFactory() { }
-private slots:
- void setDefaultIap()
- {
- qt_SetDefaultIap();
- }
+ QNetworkAccessManager *create(QObject *parent);
};
-#else // Q_OS_SYMBIAN
-typedef QDeclarativeView QmlAppView;
-#endif // Q_OS_SYMBIAN
+
+QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent)
+{
+ QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent);
+
+ QNetworkConfigurationManager manager;
+ if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
+ // Get saved network configuration
+ QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
+ settings.beginGroup(QLatin1String("QtNetwork"));
+ const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
+ settings.endGroup();
+
+ // If the saved network configuration is not currently discovered use the system default
+ QNetworkConfiguration config = manager.configurationFromIdentifier(id);
+ if ((config.state() & QNetworkConfiguration::Discovered) !=
+ QNetworkConfiguration::Discovered) {
+ config = manager.defaultConfiguration();
+ }
+
+ accessManager->setConfiguration(config);
+ }
+
+ return accessManager;
+}
int main(int argc, char *argv[])
{
QApplication application(argc, argv);
+ NetworkAccessManagerFactory networkAccessManagerFactory;
+
const QString mainQmlApp = QLatin1String("photoviewer.qml");
- QmlAppView view;
+ QDeclarativeView view;
+ view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory);
view.setSource(QUrl(mainQmlApp));
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
@@ -87,6 +105,3 @@ int main(int argc, char *argv[])
return application.exec();
}
-#if defined(Q_OS_SYMBIAN)
-#include "qmlphotoviewer.moc"
-#endif // Q_OS_SYMBIAN
diff --git a/demos/embedded/qmlphotoviewer/qmlphotoviewer.pro b/demos/embedded/qmlphotoviewer/qmlphotoviewer.pro
index ead5e67..a4234cf 100644
--- a/demos/embedded/qmlphotoviewer/qmlphotoviewer.pro
+++ b/demos/embedded/qmlphotoviewer/qmlphotoviewer.pro
@@ -7,8 +7,6 @@ include($$PWD/deployment.pri)
symbian {
TARGET.UID3 = 0x$$qmlphotoviewer_uid3 # defined in deployment.pri
include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
- INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/
- LIBS += -lesock -lcommdb -linsock # For IAP selection
TARGET.CAPABILITY = NetworkServices
TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
}