summaryrefslogtreecommitdiffstats
path: root/demos/embedded/qmlflickr
diff options
context:
space:
mode:
authoraavit <qt-info@nokia.com>2010-07-19 12:06:18 (GMT)
committeraavit <qt-info@nokia.com>2010-07-19 12:06:18 (GMT)
commitcbbdb874e0340492b80c8abcd130d1f41a8cf2b3 (patch)
tree4965dc63dcbdbbd7c0bfd8c90665e8b4a57e3ef4 /demos/embedded/qmlflickr
parent30341a6f9e57caac3ec19e02ffd67164d43c0453 (diff)
parent8acf3098bf5d88871d866aa87fa38e6feb3a32d0 (diff)
downloadQt-cbbdb874e0340492b80c8abcd130d1f41a8cf2b3.zip
Qt-cbbdb874e0340492b80c8abcd130d1f41a8cf2b3.tar.gz
Qt-cbbdb874e0340492b80c8abcd130d1f41a8cf2b3.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7
Diffstat (limited to 'demos/embedded/qmlflickr')
-rw-r--r--demos/embedded/qmlflickr/deployment.pri1
-rw-r--r--demos/embedded/qmlflickr/qmlflickr.cpp63
-rw-r--r--demos/embedded/qmlflickr/qmlflickr.pro2
3 files changed, 40 insertions, 26 deletions
diff --git a/demos/embedded/qmlflickr/deployment.pri b/demos/embedded/qmlflickr/deployment.pri
index c8fef1a..b508292 100644
--- a/demos/embedded/qmlflickr/deployment.pri
+++ b/demos/embedded/qmlflickr/deployment.pri
@@ -1,5 +1,6 @@
qmlflickr_src = $$PWD/../../declarative/flickr
symbian {
+ load(data_caging_paths)
qmlflickr_uid3 = A000E3FF
qmlflickr_files.path = $$APP_PRIVATE_DIR_BASE/$$qmlflickr_uid3
}
diff --git a/demos/embedded/qmlflickr/qmlflickr.cpp b/demos/embedded/qmlflickr/qmlflickr.cpp
index 6f0c528..7068f88 100644
--- a/demos/embedded/qmlflickr/qmlflickr.cpp
+++ b/demos/embedded/qmlflickr/qmlflickr.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("flickr.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 "qmlflickr.moc"
-#endif // Q_OS_SYMBIAN
diff --git a/demos/embedded/qmlflickr/qmlflickr.pro b/demos/embedded/qmlflickr/qmlflickr.pro
index e706134..39b316a 100644
--- a/demos/embedded/qmlflickr/qmlflickr.pro
+++ b/demos/embedded/qmlflickr/qmlflickr.pro
@@ -7,8 +7,6 @@ include($$PWD/deployment.pri)
symbian {
TARGET.UID3 = 0x$$qmlflickr_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
}