diff options
author | aavit <qt-info@nokia.com> | 2010-07-19 12:06:18 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2010-07-19 12:06:18 (GMT) |
commit | cbbdb874e0340492b80c8abcd130d1f41a8cf2b3 (patch) | |
tree | 4965dc63dcbdbbd7c0bfd8c90665e8b4a57e3ef4 | |
parent | 30341a6f9e57caac3ec19e02ffd67164d43c0453 (diff) | |
parent | 8acf3098bf5d88871d866aa87fa38e6feb3a32d0 (diff) | |
download | Qt-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
52 files changed, 490 insertions, 793 deletions
diff --git a/demos/declarative/samegame/SamegameCore/samegame.js b/demos/declarative/samegame/SamegameCore/samegame.js index 6e1b24d..aa1b359 100755 --- a/demos/declarative/samegame/SamegameCore/samegame.js +++ b/demos/declarative/samegame/SamegameCore/samegame.js @@ -110,7 +110,7 @@ function shuffleDown() }else{ if(fallDist > 0){ var obj = board[index(column,row)]; - obj.y += fallDist * gameCanvas.blockSize; + obj.y = (row+fallDist) * gameCanvas.blockSize; board[index(column,row+fallDist)] = obj; board[index(column,row)] = null; } @@ -128,7 +128,7 @@ function shuffleDown() obj = board[index(column,row)]; if(obj == null) continue; - obj.x -= fallDist * gameCanvas.blockSize; + obj.x = (column-fallDist) * gameCanvas.blockSize; board[index(column-fallDist,row)] = obj; board[index(column,row)] = null; } diff --git a/demos/embedded/anomaly/anomaly.pro b/demos/embedded/anomaly/anomaly.pro index 584e5cd..a786b46 100644 --- a/demos/embedded/anomaly/anomaly.pro +++ b/demos/embedded/anomaly/anomaly.pro @@ -26,8 +26,6 @@ RESOURCES += src/anomaly.qrc symbian { TARGET.UID3 = 0xA000CF71 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 } diff --git a/demos/embedded/anomaly/src/BrowserView.cpp b/demos/embedded/anomaly/src/BrowserView.cpp index a6e6f7a..73d0b70 100644 --- a/demos/embedded/anomaly/src/BrowserView.cpp +++ b/demos/embedded/anomaly/src/BrowserView.cpp @@ -51,10 +51,6 @@ #include "webview.h" #include "ZoomStrip.h" -#if defined (Q_OS_SYMBIAN) -#include "sym_iap_util.h" -#endif - BrowserView::BrowserView(QWidget *parent) : QWidget(parent) , m_titleBar(0) @@ -71,6 +67,26 @@ BrowserView::BrowserView(QWidget *parent) m_zoomLevels << 100; m_zoomLevels << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300; + 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(); + } + + m_webView->page()->networkAccessManager()->setConfiguration(config); + } + QTimer::singleShot(0, this, SLOT(initialize())); } @@ -100,9 +116,6 @@ void BrowserView::initialize() m_webView->setHtml("about:blank"); m_webView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_webView->setFocus(); -#ifdef Q_OS_SYMBIAN - QTimer::singleShot(0, this, SLOT(setDefaultIap())); -#endif } void BrowserView::start() @@ -173,12 +186,6 @@ void BrowserView::resizeEvent(QResizeEvent *event) int zh = m_zoomStrip->sizeHint().height(); m_zoomStrip->move(width() - zw, (height() - zh) / 2); } -#ifdef Q_OS_SYMBIAN -void BrowserView::setDefaultIap() -{ - qt_SetDefaultIap(); -} -#endif void BrowserView::navigate(const QUrl &url) { diff --git a/demos/embedded/anomaly/src/BrowserView.h b/demos/embedded/anomaly/src/BrowserView.h index 5ab1dd7..8981582 100644 --- a/demos/embedded/anomaly/src/BrowserView.h +++ b/demos/embedded/anomaly/src/BrowserView.h @@ -63,9 +63,6 @@ public slots: void navigate(const QUrl &url); void zoomIn(); void zoomOut(); -#ifdef Q_OS_SYMBIAN - void setDefaultIap(); -#endif private slots: void initialize(); diff --git a/demos/embedded/lightmaps/lightmaps.cpp b/demos/embedded/lightmaps/lightmaps.cpp index c76aed0..2eb1733 100644 --- a/demos/embedded/lightmaps/lightmaps.cpp +++ b/demos/embedded/lightmaps/lightmaps.cpp @@ -43,10 +43,6 @@ #include <QtGui> #include <QtNetwork> -#if defined (Q_OS_SYMBIAN) -#include "sym_iap_util.h" -#endif - #include <math.h> #ifndef M_PI @@ -490,6 +486,7 @@ class MapZoom : public QMainWindow private: LightMaps *map; + QNetworkSession *networkSession; public: MapZoom(): QMainWindow(0) { @@ -526,15 +523,49 @@ public: menu->addAction(osmAction); #endif - QTimer::singleShot(0, this, SLOT(delayedInit())); + 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(); + } + + networkSession = new QNetworkSession(config, this); + connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened())); + + networkSession->open(); + } else { + networkSession = 0; + } } private slots: - void delayedInit() { -#if defined(Q_OS_SYMBIAN) - qt_SetDefaultIap(); -#endif + void sessionOpened() { + // Save the used configuration + QNetworkConfiguration config = networkSession->configuration(); + QString id; + if (config.type() == QNetworkConfiguration::UserChoice) { + id = networkSession->sessionProperty( + QLatin1String("UserChoiceConfiguration")).toString(); + } else { + id = config.identifier(); + } + + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); + settings.endGroup(); } void chooseOslo() { diff --git a/demos/embedded/lightmaps/lightmaps.pro b/demos/embedded/lightmaps/lightmaps.pro index ee4cc5a..9d83721 100644 --- a/demos/embedded/lightmaps/lightmaps.pro +++ b/demos/embedded/lightmaps/lightmaps.pro @@ -5,8 +5,6 @@ QT += network symbian { TARGET.UID3 = 0xA000CF75 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 } diff --git a/demos/embedded/qmlcalculator/deployment.pri b/demos/embedded/qmlcalculator/deployment.pri index 53c6dbf..a31303d 100644 --- a/demos/embedded/qmlcalculator/deployment.pri +++ b/demos/embedded/qmlcalculator/deployment.pri @@ -1,5 +1,6 @@ qmlcalculator_src = $$PWD/../../declarative/calculator symbian { + load(data_caging_paths) qmlcalculator_uid3 = A000E3FB qmlcalculator_files.path = $$APP_PRIVATE_DIR_BASE/$$qmlcalculator_uid3 } diff --git a/demos/embedded/qmlclocks/deployment.pri b/demos/embedded/qmlclocks/deployment.pri index 03ba129..0946733 100644 --- a/demos/embedded/qmlclocks/deployment.pri +++ b/demos/embedded/qmlclocks/deployment.pri @@ -1,5 +1,6 @@ qmlclocks_src = $$PWD/../../../examples/declarative/toys/clocks symbian { + load(data_caging_paths) qmlclocks_uid3 = A000E3FC qmlclocks_files.path = $$APP_PRIVATE_DIR_BASE/$$qmlclocks_uid3 } diff --git a/demos/embedded/qmldialcontrol/deployment.pri b/demos/embedded/qmldialcontrol/deployment.pri index 097c74c..e0e72e6 100644 --- a/demos/embedded/qmldialcontrol/deployment.pri +++ b/demos/embedded/qmldialcontrol/deployment.pri @@ -1,5 +1,6 @@ qmldialcontrol_src = $$PWD/../../../examples/declarative/ui-components/dialcontrol symbian { + load(data_caging_paths) qmldialcontrol_uid3 = A000E3FD qmldialcontrol_files.path = $$APP_PRIVATE_DIR_BASE/$$qmldialcontrol_uid3 } diff --git a/demos/embedded/qmleasing/deployment.pri b/demos/embedded/qmleasing/deployment.pri index 47192e6..984f5c8 100644 --- a/demos/embedded/qmleasing/deployment.pri +++ b/demos/embedded/qmleasing/deployment.pri @@ -1,5 +1,6 @@ qmleasing_src = $$PWD/../../../examples/declarative/animation/easing symbian { + load(data_caging_paths) qmleasing_uid3 = A000E3FE qmleasing_files.path = $$APP_PRIVATE_DIR_BASE/$$qmleasing_uid3 } 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 } diff --git a/demos/embedded/qmlphotoviewer/deployment.pri b/demos/embedded/qmlphotoviewer/deployment.pri index 128a1f7..35937a8 100644 --- a/demos/embedded/qmlphotoviewer/deployment.pri +++ b/demos/embedded/qmlphotoviewer/deployment.pri @@ -1,5 +1,6 @@ qmlphotoviewer_src = $$PWD/../../declarative/photoviewer symbian { + load(data_caging_paths) qmlphotoviewer_uid3 = A000E400 qmlphotoviewer_files.path = $$APP_PRIVATE_DIR_BASE/$$qmlphotoviewer_uid3 } 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 } diff --git a/demos/embedded/qmltwitter/deployment.pri b/demos/embedded/qmltwitter/deployment.pri index 40c53ad..4404e33 100644 --- a/demos/embedded/qmltwitter/deployment.pri +++ b/demos/embedded/qmltwitter/deployment.pri @@ -1,5 +1,6 @@ qmltwitter_src = $$PWD/../../declarative/twitter symbian { + load(data_caging_paths) qmltwitter_uid3 = A000E401 qmltwitter_files.path = $$APP_PRIVATE_DIR_BASE/$$qmltwitter_uid3 } diff --git a/demos/embedded/qmltwitter/qmltwitter.cpp b/demos/embedded/qmltwitter/qmltwitter.cpp index e30ab24..c53098a4 100644 --- a/demos/embedded/qmltwitter/qmltwitter.cpp +++ b/demos/embedded/qmltwitter/qmltwitter.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("twitter.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 "qmltwitter.moc" -#endif // Q_OS_SYMBIAN diff --git a/demos/embedded/qmltwitter/qmltwitter.pro b/demos/embedded/qmltwitter/qmltwitter.pro index 7f9be57..7bd4617 100644 --- a/demos/embedded/qmltwitter/qmltwitter.pro +++ b/demos/embedded/qmltwitter/qmltwitter.pro @@ -7,8 +7,6 @@ include($$PWD/deployment.pri) symbian { TARGET.UID3 = 0x$$qmltwitter_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 } diff --git a/demos/qtdemo/colors.cpp b/demos/qtdemo/colors.cpp index b352e3d..802d77d 100644 --- a/demos/qtdemo/colors.cpp +++ b/demos/qtdemo/colors.cpp @@ -81,7 +81,6 @@ bool Colors::noRescale = false; bool Colors::noAnimations = false; bool Colors::noBlending = false; bool Colors::noScreenSync = false; -bool Colors::noBlur = true; bool Colors::fullscreen = false; bool Colors::usePixmaps = false; bool Colors::useLoop = false; @@ -233,8 +232,6 @@ void Colors::parseArgs(int argc, char *argv[]) Colors::showFps = true; else if (s == "-no-blending") Colors::noBlending = true; - else if (s == "-use-blur") - Colors::noBlur = false; else if (s == "-no-sync") Colors::noScreenSync = true; else if (s.startsWith("-menu")) @@ -270,7 +267,7 @@ void Colors::parseArgs(int argc, char *argv[]) else if (s.startsWith("-h") || s.startsWith("-help")){ QMessageBox::warning(0, "Arguments", QString("Usage: qtdemo [-verbose] [-no-adapt] [-opengl] [-software] [-fullscreen] [-ticker[0|1]] ") - + "[-animations[0|1]] [-no-blending] [-use-blur] [-no-sync] [-use-timer-update[0|1]] [-pause[0|1]] " + + "[-animations[0|1]] [-no-blending] [-no-sync] [-use-timer-update[0|1]] [-pause[0|1]] " + "[-use-window-mask] [-no-rescale] " + "[-use-pixmaps] [-show-fps] [-show-br] [-8bit[0|1]] [-menu<int>] [-use-loop] [-use-balls] " + "[-animation-speed<float>] [-fps<int>] " @@ -298,7 +295,6 @@ void Colors::setLowSettings() Colors::usePixmaps = true; Colors::noAnimations = true; Colors::noBlending = true; - Colors::noBlur = true; } void Colors::detectSystemResources() diff --git a/demos/qtdemo/colors.h b/demos/qtdemo/colors.h index 2d58058..1e0b795 100644 --- a/demos/qtdemo/colors.h +++ b/demos/qtdemo/colors.h @@ -91,7 +91,6 @@ public: static bool noAnimations; static bool noBlending; static bool noScreenSync; - static bool noBlur; static bool useLoop; static bool noWindowMask; static bool usePixmaps; diff --git a/demos/qtdemo/mainwindow.cpp b/demos/qtdemo/mainwindow.cpp index 753014a..16c5bf3 100644 --- a/demos/qtdemo/mainwindow.cpp +++ b/demos/qtdemo/mainwindow.cpp @@ -310,14 +310,6 @@ void MainWindow::checkAdapt() qDebug() << "- benchmark adaption: removed ticker (fps < 30)"; } - //Note: Because we don't adapt later in the program, if blur makes FPS plummet then we won't catch it - if (!Colors::noBlur && MenuManager::instance()->declarativeEngine && this->mainSceneRoot){ - Colors::noBlur = true; - MenuManager::instance()->declarativeEngine->rootContext()->setContextProperty("useBlur", false); - if (Colors::verbose) - qDebug() << "- benchmark adaption: removed blur (fps < 30)"; - } - if (this->fpsMedian < 20){ Colors::noAnimations = true; if (Colors::verbose) diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp index 15561ab..7168b57 100644 --- a/demos/qtdemo/menumanager.cpp +++ b/demos/qtdemo/menumanager.cpp @@ -378,17 +378,6 @@ void MenuManager::launchQmlExample(const QString &name) return; } } - if(!Colors::noBlur){ - QImage qmlBgImage(this->window->rect().size(), QImage::Format_ARGB32_Premultiplied); - QPainter painter(&qmlBgImage); - if(Colors::showFps) - this->window->fpsLabel->setOpacity(0); - this->window->render(&painter); - if(Colors::showFps) - this->window->fpsLabel->setOpacity(1.0); - Qt::ImageConversionFlags convFlags = Qt::AvoidDither | Qt::NoOpaqueDetection; - this->declarativeEngine->rootContext()->setContextProperty("bgAppPixmap", QVariant(QPixmap::fromImage(qmlBgImage, convFlags))); - } qmlRoot->setProperty("qmlFile", QVariant(""));//unload component qmlRoot->setProperty("show", QVariant(true)); @@ -439,17 +428,8 @@ void MenuManager::init(MainWindow *window) } // Create QML Loader - qmlRegisterType<QGraphicsBlurEffect>("Effects", 1, 0, "Blur"); - qmlRegisterType<QGraphicsDropShadowEffect>("Effects", 1, 0, "DropShadow"); declarativeEngine = new QDeclarativeEngine(this); - // Note that we paint the background into a static image for a theorized performance improvement when blurring - // It has not yet been determined what, if any, speed up this gives (but is left in 'cause the QML expects it now) - declarativeEngine->rootContext()->setContextProperty("useBlur", !Colors::noBlur); - QImage qmlBgImage(this->window->rect().size(), QImage::Format_ARGB32_Premultiplied); - qmlBgImage.fill(0); - this->declarativeEngine->rootContext()->setContextProperty("bgAppPixmap", QVariant(QPixmap::fromImage(qmlBgImage))); - QDeclarativeComponent component(declarativeEngine, QUrl("qrc:qml/qmlShell.qml"), this); qmlRoot = 0; if(component.isReady()) diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml index e15d33c..b5fdf39 100644 --- a/demos/qtdemo/qmlShell.qml +++ b/demos/qtdemo/qmlShell.qml @@ -40,26 +40,13 @@ ****************************************************************************/ import Qt 4.7 -import Effects 1.0 -/* Vars exposed from C++ - pixmap bgAppPixmap - bool useBlur (to turn on, pass -use-blur on the cmd line. Off by default 'cause it's too slow) -*/ Item { id: main //height and width set by program to fill window //below properties are sometimes set from C++ property url qmlFile: '' property bool show: false - Image{ - id: bg - opacity: 0 - anchors.fill: parent - z: -1 - pixmap: bgAppPixmap - effect: Blur { id: blurEffect; enabled: useBlur; blurRadius: 8;} - } Item{ id:embeddedViewer width: parent.width @@ -112,13 +99,6 @@ Item { anchors.fill:parent } - effect: DropShadow { - enabled: useBlur; - blurRadius: 9; - color: "#88000000"; - xOffset:0 - yOffset:0 - } } Text{ @@ -136,6 +116,32 @@ Item { onLinkActivated: Qt.openUrlExternally(link); } } + Rectangle{ + id: helpLabel + property bool timedOut: false + z: 9 + //Positioned in the top left corner + x: 8 + y: 8 + color: "white" + border.color: "black" + border.width: 1 + width: helpText.width + 16 + height: helpText.height + 8 + Text{ + id: helpText + color: "black" + anchors.centerIn: parent + text: "Click outside the example to exit it." + } + opacity: 0 + Behavior on opacity{ NumberAnimation{duration:500} } + Timer{ + id: helpTimer + interval: 5000 + onTriggered: {helpLabel.timedOut=true} + } + } Rectangle{ id: blackout //Maybe use a colorize effect instead? z: 8 anchors.fill: parent @@ -160,8 +166,8 @@ Item { opacity: 1 } PropertyChanges { - target: bg - opacity: 1 + target: helpLabel + opacity: helpLabel.timedOut?0:1 } PropertyChanges { target: blackout @@ -171,9 +177,9 @@ Item { ] transitions: [//Should not be too long, because the component has already started running Transition { from: ''; to: "show"; reversible: true - SequentialAnimation{ - PropertyAction { target: bg; property: useBlur?"y":"opacity";}//fade in blurred background only if blurred - NumberAnimation{ properties: "opacity"; easing.type: Easing.InQuad; duration: 500} + ParallelAnimation{ + ScriptAction{ script: {helpLabel.timedOut = false; helpTimer.restart();} } + NumberAnimation{ exclude: helpLabel; properties: "opacity"; easing.type: Easing.InQuad; duration: 500} PropertyAction { target: loader; property: "focus"; value: true}//Might be needed to ensure the focus stays with us } } diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index ce53677..3fd4ea8 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -317,6 +317,15 @@ */ /*! + \title Models and Views: PathView + \example declarative/modelviews/pathview + + This example shows how to use the PathView element. + + \image qml-pathview-example.png +*/ + +/*! \title Models and Views: Object ListModel \example declarative/modelviews/objectlistmodel diff --git a/doc/src/snippets/declarative/pathview/pathattributes.qml b/doc/src/snippets/declarative/pathview/pathattributes.qml index 8d424a8..4daee63 100644 --- a/doc/src/snippets/declarative/pathview/pathattributes.qml +++ b/doc/src/snippets/declarative/pathview/pathattributes.qml @@ -49,8 +49,8 @@ Rectangle { id: delegate Item { width: 80; height: 80 - scale: PathView.scale - opacity: PathView.opacity + scale: PathView.iconScale + opacity: PathView.iconOpacity Column { Image { anchors.horizontalCenter: name.horizontalCenter; width: 64; height: 64; source: icon } Text { text: name; font.pointSize: 16} @@ -66,11 +66,11 @@ Rectangle { delegate: delegate path: Path { startX: 120; startY: 100 - PathAttribute { name: "scale"; value: 1.0 } - PathAttribute { name: "opacity"; value: 1.0 } + PathAttribute { name: "iconScale"; value: 1.0 } + PathAttribute { name: "iconOpacity"; value: 1.0 } PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } - PathAttribute { name: "scale"; value: 0.3 } - PathAttribute { name: "opacity"; value: 0.5 } + PathAttribute { name: "iconScale"; value: 0.3 } + PathAttribute { name: "iconOpacity"; value: 0.5 } PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 } } } diff --git a/examples/declarative/modelviews/pathview/pathview-example.qml b/examples/declarative/modelviews/pathview/pathview-example.qml index 59a0acb..0a3b34c 100644 --- a/examples/declarative/modelviews/pathview/pathview-example.qml +++ b/examples/declarative/modelviews/pathview/pathview-example.qml @@ -57,10 +57,9 @@ Rectangle { Component { id: appDelegate - Item { width: 100; height: 100 - scale: PathView.scale + scale: PathView.iconScale Image { id: myIcon @@ -98,11 +97,11 @@ Rectangle { path: Path { startX: 10 startY: 50 - PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "iconScale"; value: 0.5 } PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 } - PathAttribute { name: "scale"; value: 1.0 } + PathAttribute { name: "iconScale"; value: 1.0 } PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 } - PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "iconScale"; value: 0.5 } } } } diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp index b9a85c4..fe35906 100644 --- a/examples/network/fortuneclient/client.cpp +++ b/examples/network/fortuneclient/client.cpp @@ -43,13 +43,9 @@ #include "client.h" -#ifdef Q_OS_SYMBIAN -#include "sym_iap_util.h" -#endif - //! [0] Client::Client(QWidget *parent) - : QDialog(parent) +: QDialog(parent), networkSession(0) { //! [0] hostLabel = new QLabel(tr("&Server name:")); @@ -121,9 +117,28 @@ Client::Client(QWidget *parent) setWindowTitle(tr("Fortune Client")); portLineEdit->setFocus(); -#ifdef Q_OS_SYMBIAN - isDefaultIapSet = false; -#endif + 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(); + } + + networkSession = new QNetworkSession(config, this); + connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened())); + + getFortuneButton->setEnabled(false); + statusLabel->setText(tr("Opening network session.")); + networkSession->open(); + } //! [5] } //! [5] @@ -132,12 +147,6 @@ Client::Client(QWidget *parent) void Client::requestNewFortune() { getFortuneButton->setEnabled(false); -#ifdef Q_OS_SYMBIAN - if(!isDefaultIapSet) { - qt_SetDefaultIap(); - isDefaultIapSet = true; - } -#endif blockSize = 0; tcpSocket->abort(); //! [7] @@ -214,6 +223,30 @@ void Client::displayError(QAbstractSocket::SocketError socketError) void Client::enableGetFortuneButton() { - getFortuneButton->setEnabled(!hostLineEdit->text().isEmpty() - && !portLineEdit->text().isEmpty()); + getFortuneButton->setEnabled((!networkSession || networkSession->isOpen()) && + !hostLineEdit->text().isEmpty() && + !portLineEdit->text().isEmpty()); + } + +void Client::sessionOpened() +{ + // Save the used configuration + QNetworkConfiguration config = networkSession->configuration(); + QString id; + if (config.type() == QNetworkConfiguration::UserChoice) + id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString(); + else + id = config.identifier(); + + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); + settings.endGroup(); + + statusLabel->setText(tr("This examples requires that you run the " + "Fortune Server example as well.")); + + enableGetFortuneButton(); +} + diff --git a/examples/network/fortuneclient/client.h b/examples/network/fortuneclient/client.h index 50a9037..d0c0718 100644 --- a/examples/network/fortuneclient/client.h +++ b/examples/network/fortuneclient/client.h @@ -50,6 +50,7 @@ class QLabel; class QLineEdit; class QPushButton; class QTcpSocket; +class QNetworkSession; QT_END_NAMESPACE //! [0] @@ -65,6 +66,7 @@ private slots: void readFortune(); void displayError(QAbstractSocket::SocketError socketError); void enableGetFortuneButton(); + void sessionOpened(); private: QLabel *hostLabel; @@ -79,9 +81,8 @@ private: QTcpSocket *tcpSocket; QString currentFortune; quint16 blockSize; -#ifdef Q_OS_SYMBIAN - bool isDefaultIapSet; -#endif + + QNetworkSession *networkSession; }; //! [0] diff --git a/examples/network/fortuneclient/fortuneclient.pro b/examples/network/fortuneclient/fortuneclient.pro index edbf14d..f79679d 100644 --- a/examples/network/fortuneclient/fortuneclient.pro +++ b/examples/network/fortuneclient/fortuneclient.pro @@ -11,8 +11,6 @@ INSTALLS += target sources symbian { include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ - LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = "NetworkServices ReadUserData WriteUserData" TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } diff --git a/examples/network/fortuneserver/fortuneserver.pro b/examples/network/fortuneserver/fortuneserver.pro index 474ec11..e13f309 100644 --- a/examples/network/fortuneserver/fortuneserver.pro +++ b/examples/network/fortuneserver/fortuneserver.pro @@ -12,8 +12,6 @@ INSTALLS += target sources symbian { TARGET.UID3 = 0xA000CF71 include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ - LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = "NetworkServices ReadUserData" TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } diff --git a/examples/network/fortuneserver/main.cpp b/examples/network/fortuneserver/main.cpp index 29fe777..53149c0 100644 --- a/examples/network/fortuneserver/main.cpp +++ b/examples/network/fortuneserver/main.cpp @@ -45,15 +45,8 @@ #include "server.h" -#ifdef Q_OS_SYMBIAN -#include "sym_iap_util.h" -#endif - int main(int argc, char *argv[]) { -#ifdef Q_OS_SYMBIAN - qt_SetDefaultIap(); -#endif QApplication app(argc, argv); Server server; #ifdef Q_OS_SYMBIAN diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp index 98234e0..b931b96 100644 --- a/examples/network/fortuneserver/server.cpp +++ b/examples/network/fortuneserver/server.cpp @@ -46,12 +46,79 @@ #include "server.h" Server::Server(QWidget *parent) - : QDialog(parent) +: QDialog(parent), tcpServer(0), networkSession(0) { statusLabel = new QLabel; quitButton = new QPushButton(tr("Quit")); quitButton->setAutoDefault(false); + 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(); + } + + networkSession = new QNetworkSession(config, this); + connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened())); + + statusLabel->setText(tr("Opening network session.")); + networkSession->open(); + } else { + sessionOpened(); + } + + //! [2] + fortunes << tr("You've been leading a dog's life. Stay off the furniture.") + << tr("You've got to think about tomorrow.") + << tr("You will be surprised by a loud noise.") + << tr("You will feel hungry again in another hour.") + << tr("You might have mail.") + << tr("You cannot kill time without injuring eternity.") + << tr("Computers are not intelligent. They only think they are."); + //! [2] + + connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); + //! [3] + connect(tcpServer, SIGNAL(newConnection()), this, SLOT(sendFortune())); + //! [3] + + QHBoxLayout *buttonLayout = new QHBoxLayout; + buttonLayout->addStretch(1); + buttonLayout->addWidget(quitButton); + buttonLayout->addStretch(1); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(statusLabel); + mainLayout->addLayout(buttonLayout); + setLayout(mainLayout); + + setWindowTitle(tr("Fortune Server")); +} + +void Server::sessionOpened() +{ + // Save the used configuration + QNetworkConfiguration config = networkSession->configuration(); + QString id; + if (config.type() == QNetworkConfiguration::UserChoice) + id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString(); + else + id = config.identifier(); + + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); + settings.endGroup(); + //! [0] //! [1] tcpServer = new QTcpServer(this); if (!tcpServer->listen()) { @@ -79,33 +146,6 @@ Server::Server(QWidget *parent) "Run the Fortune Client example now.") .arg(ipAddress).arg(tcpServer->serverPort())); //! [1] - -//! [2] - fortunes << tr("You've been leading a dog's life. Stay off the furniture.") - << tr("You've got to think about tomorrow.") - << tr("You will be surprised by a loud noise.") - << tr("You will feel hungry again in another hour.") - << tr("You might have mail.") - << tr("You cannot kill time without injuring eternity.") - << tr("Computers are not intelligent. They only think they are."); -//! [2] - - connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); -//! [3] - connect(tcpServer, SIGNAL(newConnection()), this, SLOT(sendFortune())); -//! [3] - - QHBoxLayout *buttonLayout = new QHBoxLayout; - buttonLayout->addStretch(1); - buttonLayout->addWidget(quitButton); - buttonLayout->addStretch(1); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(statusLabel); - mainLayout->addLayout(buttonLayout); - setLayout(mainLayout); - - setWindowTitle(tr("Fortune Server")); } //! [4] diff --git a/examples/network/fortuneserver/server.h b/examples/network/fortuneserver/server.h index 2d8d116..9d9ef62 100644 --- a/examples/network/fortuneserver/server.h +++ b/examples/network/fortuneserver/server.h @@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE class QLabel; class QPushButton; class QTcpServer; +class QNetworkSession; QT_END_NAMESPACE //! [0] @@ -58,6 +59,7 @@ public: Server(QWidget *parent = 0); private slots: + void sessionOpened(); void sendFortune(); private: @@ -65,6 +67,7 @@ private: QPushButton *quitButton; QTcpServer *tcpServer; QStringList fortunes; + QNetworkSession *networkSession; }; //! [0] diff --git a/examples/network/network-chat/chatdialog.cpp b/examples/network/network-chat/chatdialog.cpp index 14fabaa..2bab535 100644 --- a/examples/network/network-chat/chatdialog.cpp +++ b/examples/network/network-chat/chatdialog.cpp @@ -53,9 +53,6 @@ ChatDialog::ChatDialog(QWidget *parent) listWidget->setFocusPolicy(Qt::NoFocus); connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed())); -#ifdef Q_OS_SYMBIAN - connect(sendButton, SIGNAL(clicked()), this, SLOT(returnPressed())); -#endif connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed())); connect(&client, SIGNAL(newMessage(QString,QString)), this, SLOT(appendMessage(QString,QString))); diff --git a/examples/network/network-chat/main.cpp b/examples/network/network-chat/main.cpp index 7226217..e3db74b 100644 --- a/examples/network/network-chat/main.cpp +++ b/examples/network/network-chat/main.cpp @@ -41,16 +41,52 @@ #include <QApplication> #include "chatdialog.h" -#ifdef Q_OS_SYMBIAN -#include "sym_iap_util.h" -#endif + +#include <QtCore/QSettings> +#include <QtNetwork/QNetworkConfigurationManager> +#include <QtNetwork/QNetworkSession> int main(int argc, char *argv[]) { -#ifdef Q_OS_SYMBIAN - qt_SetDefaultIap(); -#endif QApplication app(argc, argv); + + 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(); + } + + QNetworkSession *networkSession = new QNetworkSession(config, &app); + networkSession->open(); + networkSession->waitForOpened(); + + if (networkSession->isOpen()) { + // Save the used configuration + QNetworkConfiguration config = networkSession->configuration(); + QString id; + if (config.type() == QNetworkConfiguration::UserChoice) { + id = networkSession->sessionProperty( + QLatin1String("UserChoiceConfiguration")).toString(); + } else { + id = config.identifier(); + } + + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); + settings.endGroup(); + } + } + ChatDialog dialog; #ifdef Q_OS_SYMBIAN // Make application better looking and more usable on small screen diff --git a/examples/network/network-chat/network-chat.pro b/examples/network/network-chat/network-chat.pro index 1215aea..b3d429e 100644 --- a/examples/network/network-chat/network-chat.pro +++ b/examples/network/network-chat/network-chat.pro @@ -20,8 +20,6 @@ INSTALLS += target sources symbian { include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ - LIBS += -lesock -lcommdb -linsock # For IAP selection LIBS += -lcharconv TARGET.CAPABILITY = "NetworkServices ReadUserData WriteUserData" TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 diff --git a/examples/network/qftp/ftpwindow.cpp b/examples/network/qftp/ftpwindow.cpp index 635b679..f39f9a0 100644 --- a/examples/network/qftp/ftpwindow.cpp +++ b/examples/network/qftp/ftpwindow.cpp @@ -43,12 +43,8 @@ #include "ftpwindow.h" -#ifdef Q_OS_SYMBIAN -#include "sym_iap_util.h" -#endif - FtpWindow::FtpWindow(QWidget *parent) - : QDialog(parent), ftp(0) + : QDialog(parent), ftp(0), networkSession(0) { ftpServerLabel = new QLabel(tr("Ftp &server:")); ftpServerLineEdit = new QLineEdit("ftp.qt.nokia.com"); @@ -118,9 +114,28 @@ FtpWindow::FtpWindow(QWidget *parent) mainLayout->addWidget(buttonBox); setLayout(mainLayout); -#ifdef Q_OS_SYMBIAN - bDefaultIapSet = false; -#endif + 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(); + } + + networkSession = new QNetworkSession(config, this); + connect(networkSession, SIGNAL(opened()), this, SLOT(enableConnectButton())); + + connectButton->setEnabled(false); + statusLabel->setText(tr("Opening network session.")); + networkSession->open(); + } setWindowTitle(tr("FTP")); } @@ -133,12 +148,6 @@ QSize FtpWindow::sizeHint() const //![0] void FtpWindow::connectOrDisconnect() { -#ifdef Q_OS_SYMBIAN - if(!bDefaultIapSet) { - qt_SetDefaultIap(); - bDefaultIapSet = true; - } -#endif if (ftp) { ftp->abort(); ftp->deleteLater(); @@ -377,3 +386,22 @@ void FtpWindow::enableDownloadButton() } //![14] +void FtpWindow::enableConnectButton() +{ + // Save the used configuration + QNetworkConfiguration config = networkSession->configuration(); + QString id; + if (config.type() == QNetworkConfiguration::UserChoice) + id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString(); + else + id = config.identifier(); + + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); + settings.endGroup(); + + connectButton->setEnabled(networkSession->isOpen()); + statusLabel->setText(tr("Please enter the name of an FTP server.")); +} + diff --git a/examples/network/qftp/ftpwindow.h b/examples/network/qftp/ftpwindow.h index 25a7a56..9f39ccd 100644 --- a/examples/network/qftp/ftpwindow.h +++ b/examples/network/qftp/ftpwindow.h @@ -55,6 +55,7 @@ class QTreeWidgetItem; class QProgressDialog; class QPushButton; class QUrlInfo; +class QNetworkSession; QT_END_NAMESPACE class FtpWindow : public QDialog @@ -78,6 +79,7 @@ private slots: void updateDataTransferProgress(qint64 readBytes, qint64 totalBytes); void enableDownloadButton(); + void enableConnectButton(); //![0] private: @@ -98,9 +100,7 @@ private: QFtp *ftp; QFile *file; -#ifdef Q_OS_SYMBIAN - bool bDefaultIapSet; -#endif + QNetworkSession *networkSession; //![1] }; diff --git a/examples/network/qftp/qftp.pro b/examples/network/qftp/qftp.pro index b3106c3..232e8eb 100644 --- a/examples/network/qftp/qftp.pro +++ b/examples/network/qftp/qftp.pro @@ -13,8 +13,6 @@ INSTALLS += target sources symbian { TARGET.UID3 = 0xA000A648 include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - HEADERS += sym_iap_util.h INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE TARGET.CAPABILITY="NetworkServices ReadUserData WriteUserData" - LIBS+=-lesock -lcommdb -linsock # For IAP selection } diff --git a/examples/network/qftp/sym_iap_util.h b/examples/network/qftp/sym_iap_util.h deleted file mode 100644 index bea447c..0000000 --- a/examples/network/qftp/sym_iap_util.h +++ /dev/null @@ -1,519 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QSYM_IAP_UTIL_H -#define QSYM_IAP_UTIL_H - -// Symbian -#include <utf.h> -#include <es_sock.h> -#include <in_sock.h> -#include <es_enum.h> -#include <in_iface.h> -#include <commdbconnpref.h> -#include <e32cmn.h> - -// OpenC -#include <sys/socket.h> -#include <net/if.h> - -//Qt -#include <QSettings> -#include <QStringList> -//#include <QTextCodec> - -_LIT(KIapNameSetting, "IAP\\Name"); // text - mandatory -_LIT(KIapTableIdField, "IAP\\Id"); -_LIT(KIapDialogPref, "IAP\\DialogPref"); // TUnit32 - optional -_LIT(KIapService, "IAP\\IAPService"); // TUnit32 - mandatory -_LIT(KIapServiceType, "IAP\\IAPServiceType"); // text - mandatory -_LIT(KIapBearer, "IAP\\IAPBearer"); // TUint32 - optional -_LIT(KIapBearerType, "IAP\\IAPBearerType"); // text - optional -_LIT(KIapNetwork, "IAP\\IAPNetwork"); // TUint32 - optional - -const QLatin1String qtOrganizationTag("Trolltech"); -const QLatin1String qtNetworkModuleTag("QtNetwork"); -const QLatin1String iapGroupTag("IAP"); -const QLatin1String iapNamesArrayTag("Names"); -const QLatin1String iapNameItemTag("Name"); - -static QTextCodec *utf16LETextCodec = 0; - -void clearIapNamesSettings(QSettings &settings) { - settings.beginGroup(qtNetworkModuleTag); - settings.beginGroup(iapGroupTag); - settings.remove(iapNamesArrayTag); - settings.endGroup(); - settings.endGroup(); -} - -void writeIapNamesSettings(QSettings &settings, const QStringList& iapNames) { - clearIapNamesSettings(settings); - settings.beginGroup(qtNetworkModuleTag); - settings.beginGroup(iapGroupTag); - settings.beginWriteArray(iapNamesArrayTag); - for (int index = 0; index < iapNames.size(); ++index) { - settings.setArrayIndex(index); - settings.setValue(iapNameItemTag, iapNames.at(index)); - } - settings.endArray(); - settings.endGroup(); - settings.endGroup(); -} - -void readIapNamesSettings(QSettings &settings, QStringList& iapNames) { - settings.beginGroup(qtNetworkModuleTag); - settings.beginGroup(iapGroupTag); - int last = settings.beginReadArray(iapNamesArrayTag); - for (int index = 0; index < last; ++index) { - settings.setArrayIndex(index); - iapNames.append(settings.value(iapNameItemTag).toString()); - } - settings.endArray(); - settings.endGroup(); - settings.endGroup(); -} - -static QString qt_TNameToQString(TName data) { - if(utf16LETextCodec == 0) - utf16LETextCodec = QTextCodec::codecForName("UTF-16LE"); - - QByteArray tmpByteArray = QByteArray::fromRawData((char*)(data.PtrZ()), data.Length() * 2); - return utf16LETextCodec->toUnicode(tmpByteArray); -} - -static QString qt_InterfaceInfoL() -{ - QString output; - - TBuf8<512> buffer; - TBuf<128> t; - TAutoClose<RSocketServ> ss; - User::LeaveIfError(ss.iObj.Connect()); - ss.PushL(); - - TAutoClose<RSocket> sock; - User::LeaveIfError(sock.iObj.Open(ss.iObj, _L("udp"))); - sock.PushL(); - - User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl)); - - TProtocolDesc in; - User::LeaveIfError(sock.iObj.Info(in)); - printf("EPOC32 IP Configuration TCPIP Version %d.%d.%d\n", in.iVersion.iMajor, in.iVersion.iMinor, in.iVersion.iBuild); - - TPckgBuf<TSoInetInterfaceInfo> info, next; - - TInt res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, info); - if(res!=KErrNone) - User::Leave(res); - TInt count = 0; - while(res==KErrNone) { - res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, next); - - if(info().iName != _L("") && info().iName != _L("loop6") && info().iName != _L("loop4")) { - printf("Interface %d\n", count++); - - printf("Name \"%s\"\n", qt_TNameToQString(info().iName).toLatin1().data()); - printf("NIF tag \"%s\"\n", qt_TNameToQString(info().iTag).toLatin1().data()); - - printf("State "); - switch (info().iState) - { - case EIfPending: - printf("pending\n"); - break; - case EIfUp: - printf("up\n"); - break; - case EIfBusy: - printf("busy\n"); - break; - default: - printf("down\n"); - break; - } - - printf("Mtu %d\n", info().iMtu); - printf("Speed Metric %d\n", info().iSpeedMetric); - - printf("Features:"); - info().iFeatures & KIfIsLoopback ? printf(" loopback") : printf(""); - info().iFeatures & KIfIsDialup ? printf(" dialup") : printf(""); - info().iFeatures & KIfIsPointToPoint ? printf(" pointtopoint") : printf(""); - info().iFeatures & KIfCanBroadcast ? printf(" canbroadcast") : printf(""); - info().iFeatures & KIfCanMulticast ? printf(" canmulticast") : printf(""); - info().iFeatures & KIfCanSetMTU ? printf(" cansetmtu") : printf(""); - info().iFeatures & KIfHasHardwareAddr ? printf(" hardwareaddr") : printf(""); - info().iFeatures & KIfCanSetHardwareAddr ? printf(" cansethardwareaddr") : printf(""); - printf("\n"); - - TName address; - info().iAddress.Output(address); - printf("Addr: %s\n", qt_TNameToQString(address).toLatin1().data()); - - if(info().iAddress.IsLinkLocal()) { - printf(" -link local\n"); - } else if(info().iAddress.IsSiteLocal()) { - printf(" -site local\n"); - } else { - printf(" -global\n"); - } - - info().iNetMask.Output(address); - printf("Netmask %s\n", qt_TNameToQString(address).toLatin1().data()); - - info().iBrdAddr.Output(address); - printf("Broadcast address %s\n", qt_TNameToQString(address).toLatin1().data()); - - info().iDefGate.Output(address); - printf("Gatew: %s\n", qt_TNameToQString(address).toLatin1().data()); - - info().iNameSer1.Output(address); - printf("DNS 1: %s\n", qt_TNameToQString(address).toLatin1().data()); - - info().iNameSer2.Output(address); - printf("DNS 2: %s\n", qt_TNameToQString(address).toLatin1().data()); - - if (info().iHwAddr.Family() != KAFUnspec) { - printf("Hardware address "); - TUint j; - for(j = sizeof(SSockAddr) ; j < sizeof(SSockAddr) + 6 ; ++j) { - if(j < (TUint)info().iHwAddr.Length()) { - printf("%02X", info().iHwAddr[j]); - } else { - printf("??"); - } - if(j < sizeof(SSockAddr) + 5) - printf("-"); - else - printf("\n"); - } - } - } - if(res == KErrNone) { - info = next; - printf("\n"); - } else { - printf("\n"); - } - } - - sock.Pop(); - ss.Pop(); - - return output; -} - -static QString qt_RouteInfoL() { - QString output; - TAutoClose<RSocketServ> ss; - User::LeaveIfError(ss.iObj.Connect()); - ss.PushL(); - - TAutoClose<RSocket> sock; - User::LeaveIfError(sock.iObj.Open(ss.iObj, _L("udp"))); - sock.PushL(); - - TSoInetRouteInfo routeInfo; - TPckg<TSoInetRouteInfo> routeInfoPkg(routeInfo); - - TName destAddr; - TName netMask; - TName gateway; - TName ifAddr; - - // Begins enumeration of routes by setting this option - User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumRoutes, KSolInetRtCtrl)); - - // The TSoInetRouteInfo contains information for a new route each time GetOpt returns KErrNone - for(TInt i = 0; sock.iObj.GetOpt(KSoInetNextRoute, KSolInetRtCtrl, routeInfoPkg) == KErrNone ; i++) - { - // Extract the destination and netmask - routeInfo.iDstAddr.Output(destAddr); - routeInfo.iNetMask.Output(netMask); - routeInfo.iGateway.Output(gateway); - routeInfo.iIfAddr.Output(ifAddr); -/* - if(destAddr.Length() <= 2) - continue; - - if(netMask.Find(_L("255.255.255.255")) != KErrNotFound - || netMask.Find(_L("0.0.0.0")) != KErrNotFound - || netMask.Find(_L("ffff:ffff:ffff:ffff")) != KErrNotFound) - continue; -*/ - printf("Route Info #[%i]\n", i); - printf("DstAddr %s\n", qt_TNameToQString(destAddr).toLatin1().data()); - printf("NetMask %s\n", qt_TNameToQString(netMask).toLatin1().data()); - printf("Gateway %s\n", qt_TNameToQString(gateway).toLatin1().data()); - printf("IfAddr %s\n", qt_TNameToQString(ifAddr).toLatin1().data()); - printf("\n"); - } - - sock.Pop(); - ss.Pop(); - - return output; -} - -QString qt_TDesC2QStringL(const TDesC& aDescriptor) -{ -#ifdef QT_NO_UNICODE - return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length()); -#else - return QString((const QChar *)aDescriptor.Ptr(), aDescriptor.Length()); -#endif -} - -static bool qt_SetDefaultIapName(const QString &iapName, int &error) { - struct ifreq ifReq; - // clear structure - memset(&ifReq, 0, sizeof(struct ifreq)); - // set IAP name value - // make sure it is in UTF8 - strcpy(ifReq.ifr_name, iapName.toUtf8().data()); - - if(setdefaultif(&ifReq) == 0) { - // OK - error = 0; - return true; - } else { - error = errno; - return false; - } - -} -static bool qt_SetDefaultSnapId(const int snapId, int &error) { - struct ifreq ifReq; - // clear structure - memset(&ifReq, 0, sizeof(struct ifreq)); - // set SNAP ID value - ifReq.ifr_ifru.snap_id = snapId; - - if(setdefaultif(&ifReq) == 0) { - // OK - error = 0; - return true; - } else { - error = errno; - return false; - } - -} - -static void qt_SaveIapName(QSettings& settings, QStringList& iapNames, QString& iapNameValue) { - if(iapNames.contains(iapNameValue) && iapNames.first() == iapNameValue) { - // no need to update - } else { - if(iapNameValue != QString("Easy WLAN")) { - // new selection alway on top - iapNames.removeAll(iapNameValue); - iapNames.prepend(iapNameValue); - writeIapNamesSettings(settings, iapNames); - } else { - // Unbeliveable ... if IAP dodn't exist before - // no matter what you choose from IAP selection list - // you will get "Easy WLAN" as IAP name value - - // somehow commsdb is not in sync - } - } -} - -static QString qt_OfferIapDialog() { - TBuf8<256> iapName; - - RSocketServ socketServ; - CleanupClosePushL(socketServ); - - RConnection connection; - CleanupClosePushL(connection); - - socketServ.Connect(); - - TCommDbConnPref prefs; - prefs.SetDialogPreference(ECommDbDialogPrefPrompt); - - connection.Open(socketServ); - connection.Start(prefs); - - connection.GetDesSetting(TPtrC(KIapNameSetting), iapName); - //connection.Stop(); - - iapName.ZeroTerminate(); - QString strIapName((char*)iapName.Ptr()); - - int error = 0; - if(!strIapName.isEmpty()) { - if(!qt_SetDefaultIapName(strIapName, error)) { - //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); - strIapName = QString(""); - } - } - - CleanupStack::PopAndDestroy(&connection); - CleanupStack::PopAndDestroy(&socketServ); - - return strIapName; -} - -static QString qt_CheckForActiveConnection() { - TUint count; - - RSocketServ serv; - CleanupClosePushL(serv); - - RConnection conn; - CleanupClosePushL(conn); - - serv.Connect(); - conn.Open(serv); - - TConnectionInfoBuf connInfo; - - TBuf8<256> iapName; - TBuf8<256> iapServiceType; - - QString strIapName; - - if (conn.EnumerateConnections(count) == KErrNone) { - if(count > 0) { - for (TUint i = 1; i <= count; i++) { - if (conn.GetConnectionInfo(i, connInfo) == KErrNone) { - RConnection tempConn; - CleanupClosePushL(tempConn); - tempConn.Open(serv); - if (tempConn.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) { - tempConn.GetDesSetting(TPtrC(KIapNameSetting), iapName); - tempConn.GetDesSetting(TPtrC(KIapServiceType), iapServiceType); - //tempConn.Stop(); - iapName.ZeroTerminate(); - iapServiceType.ZeroTerminate(); - -// if(iapServiceType.Find(_L8("LANService")) != KErrNotFound) { -// activeLanConnectionFound = ETrue; -// break; -// } - strIapName = QString((char*)iapName.Ptr()); - int error = 0; - if(!qt_SetDefaultIapName(strIapName, error)) { - //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); - strIapName = QString(""); - } - - CleanupStack::PopAndDestroy(&tempConn); - break; - } - } - } - } - } - - //conn.Stop(); - - CleanupStack::PopAndDestroy(&conn); - CleanupStack::PopAndDestroy(&serv); - - return strIapName; -} - -static QString qt_CheckSettingsForConnection(QStringList& iapNames) { - QString strIapName; - for(int index = 0; index < iapNames.size(); ++index) { - strIapName = iapNames.at(index); - int error = 0; - if(!qt_SetDefaultIapName(strIapName, error)) { - //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); - strIapName = QString(""); - } else { - return strIapName; - } - } - return strIapName; -} - -static void qt_SetDefaultIapL() -{ - // settings @ /c/data/.config/Trolltech.com - QSettings settings(QSettings::UserScope, qtOrganizationTag); - // populate iap name list - QStringList iapNames; - readIapNamesSettings(settings, iapNames); - - QString iapNameValue; - - iapNameValue = qt_CheckForActiveConnection(); - - if(!iapNameValue.isEmpty()) { - qt_SaveIapName(settings, iapNames, iapNameValue); - return; - } - - iapNameValue = qt_CheckSettingsForConnection(iapNames); - - if(!iapNameValue.isEmpty()) { - qt_SaveIapName(settings, iapNames, iapNameValue); - return; - } - - /* - * no active LAN connections yet - * no IAP in settings - * offer IAP dialog to user - */ - iapNameValue = qt_OfferIapDialog(); - qt_SaveIapName(settings, iapNames, iapNameValue); - return; - -} - -static int qt_SetDefaultIap() -{ -#ifndef __WINS__ - TRAPD(err1, qt_SetDefaultIapL()); -// TRAPD(err2, qt_InterfaceInfoL()); -// TRAPD(err3, qt_RouteInfoL()); - return err1; -#else - return 0; // IAP dialog not required for emulator -#endif -} - -#endif // QSYM_IAP_UTIL_H diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 90738c8..37736cc 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE \endqml \endtable - If the \l {Image::width}{width} and \l{Image::height}{height} properties are not specified, + If the \l {Item::width}{width} and \l{Item::height}{height} properties are not specified, the Image element is automatically sized to the loaded image. Image elements can be stretched and tiled using the \l fillMode property. diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index b9498f1..367a5d0 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2692,7 +2692,7 @@ bool QDeclarativeItem::sceneEvent(QEvent *event) } /*! - \reimp + \internal Note that unlike QGraphicsItems, QDeclarativeItem::itemChange() is \e not called during initial widget polishing. Items wishing to optimize start-up construction diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index fa422fd..38bc6f5 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -577,7 +577,7 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex) listItem->attached->m_prevSection = sectionAt(modelIndex-1); if (FxListItem *item = visibleItem(modelIndex+1)) listItem->attached->m_nextSection = item->attached->section(); - else + else if (modelIndex < model->count()-1) listItem->attached->m_nextSection = sectionAt(modelIndex+1); } } diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp index a904869..80196a1 100644 --- a/src/declarative/graphicsitems/qdeclarativepath.cpp +++ b/src/declarative/graphicsitems/qdeclarativepath.cpp @@ -533,6 +533,13 @@ void QDeclarativeCurve::setY(qreal y) /*! \qmlproperty string PathAttribute::name the name of the attribute to change. + + This attribute will be available to the delegate as PathView.<name> + + Note that using an existing Item property name such as "opacity" as an + attribute is allowed. This is because path attributes add a new + \l{qdeclarativeintroduction.html#attached-properties} {Attached Property} + which in no way clashes with existing properties. */ /*! diff --git a/src/declarative/graphicsitems/qdeclarativetranslate.cpp b/src/declarative/graphicsitems/qdeclarativetranslate.cpp index 17daac7..16a1127 100644 --- a/src/declarative/graphicsitems/qdeclarativetranslate.cpp +++ b/src/declarative/graphicsitems/qdeclarativetranslate.cpp @@ -117,7 +117,7 @@ void QDeclarativeTranslate::setY(qreal y) } /*! - \reimp + \internal */ void QDeclarativeTranslate::applyTo(QMatrix4x4 *matrix) const { diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 786d6f9..cfa1c6d 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -1089,6 +1089,11 @@ QString QDeclarativeVisualDataModel::stringValue(int index, const QString &name) if (d->m_visualItemModel) return d->m_visualItemModel->stringValue(index, name); + if ((!d->m_listModelInterface || !d->m_abstractItemModel) && d->m_listAccessor) { + if (QObject *object = d->m_listAccessor->at(index).value<QObject*>()) + return object->property(name.toUtf8()).toString(); + } + if ((!d->m_listModelInterface && !d->m_abstractItemModel) || !d->m_delegate) return QString(); diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp index 34e1e2b..6b7418e 100644 --- a/src/declarative/util/qdeclarativetransition.cpp +++ b/src/declarative/util/qdeclarativetransition.cpp @@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE Transition { ... } ] } - |endqml + \endqml \sa {declarative/animation/states}{states example}, {qmlstates}{States}, {state-transitions}{Transitions}, {QtDeclarative} */ diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 9f4df22..7c1e1fd 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -567,7 +567,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla \image qml-xmllistmodel-example.png The XmlListModel data is loaded asynchronously, and \l status - is set to \l XmlListModel::Ready when loading is complete. + is set to \c XmlListModel.Ready when loading is complete. Note this means when XmlListModel is used for a view, the view is not populated until the model is loaded. diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml b/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml index f5198c9..d030222 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml @@ -11,6 +11,9 @@ ListView { width: 100 color: model.modelData.color Text { objectName: "name"; text: name } + Text { objectName: "section"; text: parent.ListView.section } } } + section.property: "name" + section.criteria: ViewSection.FullString } diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp index 43d4d06..e0f32ea 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp @@ -179,6 +179,9 @@ void tst_qdeclarativevisualdatamodel::objectListModel() QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "name", 0); QCOMPARE(name->text(), QString("Item 1")); + QDeclarativeText *section = findItem<QDeclarativeText>(contentItem, "section", 0); + QCOMPARE(section->text(), QString("Item 1")); + dataList[0]->setProperty("name", QLatin1String("Changed")); QCOMPARE(name->text(), QString("Changed")); } diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index fe2a719..e9ef070 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -315,7 +315,24 @@ void tst_QImageReader::jpegRgbCmyk() QImage image1(prefix + QLatin1String("YCbCr_cmyk.jpg")); QImage image2(prefix + QLatin1String("YCbCr_cmyk.png")); - QCOMPARE(image1, image2); + // first, do some obvious tests + QCOMPARE(image1.height(), image2.height()); + QCOMPARE(image1.width(), image2.width()); + QCOMPARE(image1.format(), image2.format()); + QCOMPARE(image1.format(), QImage::Format_RGB32); + + // compare all the pixels with a slack of 3. This ignores rounding errors in libjpeg/libpng + for (int h = 0; h < image1.height(); ++h) { + const uchar *s1 = image1.constScanLine(h); + const uchar *s2 = image2.constScanLine(h); + for (int w = 0; w < image1.width() * 4; ++w) { + if (*s1 != *s2) { + QVERIFY2(qAbs(*s1 - *s2) <= 3, qPrintable(QString("images differ in line %1, col %2 (image1: %3, image2: %4)").arg(h).arg(w).arg(*s1, 0, 16).arg(*s2, 0, 16))); + } + s1++; + s2++; + } + } } void tst_QImageReader::setScaledSize_data() |