From 923f679cb1096d1cb56fbb735a268b5249913480 Mon Sep 17 00:00:00 2001 From: artoka Date: Thu, 17 Nov 2011 15:49:46 +0100 Subject: modelviews/abstractitemmodel example modifications Modified the project to use centralized qmlapplicationviewer, deleted duplicate files and modified the project files according to the changes. Merge-request: 2719 Reviewed-by: Casper van Donderen --- .../abstractitemmodel/abstractitemmodel.pro | 39 +++++++++++++++-- .../modelviews/abstractitemmodel/main.cpp | 12 ++--- .../qml/abstractitemmodel/view.qml | 51 ++++++++++++++++++++++ .../modelviews/abstractitemmodel/view.qml | 51 ---------------------- 4 files changed, 92 insertions(+), 61 deletions(-) create mode 100644 examples/declarative/modelviews/abstractitemmodel/qml/abstractitemmodel/view.qml delete mode 100644 examples/declarative/modelviews/abstractitemmodel/view.qml diff --git a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro b/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro index 55e67f3..98490b2 100644 --- a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro +++ b/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro @@ -1,8 +1,39 @@ -TEMPLATE = app +# Add more folders to ship with the application, here +folder_01.source = qml/abstractitemmodel +folder_01.target = qml +DEPLOYMENTFOLDERS = folder_01 -QT += declarative +# Additional import path used to resolve QML modules in Creator's code model +QML_IMPORT_PATH = -RESOURCES += abstractitemmodel.qrc +symbian:TARGET.UID3 = 0xE1CB8EBB -HEADERS = model.h +# Smart Installer package's UID +# This UID is from the protected range and therefore the package will +# fail to install if self-signed. By default qmake uses the unprotected +# range value if unprotected UID is defined for the application and +# 0x2002CCCF value if protected UID is given to the application +#symbian:DEPLOYMENT.installer_header = 0x2002CCCF + +# Allow network access on Symbian +symbian:TARGET.CAPABILITY += NetworkServices + +# If your application uses the Qt Mobility libraries, uncomment the following +# lines and add the respective components to the MOBILITY variable. +# CONFIG += mobility +# MOBILITY += + +# Speed up launching on MeeGo/Harmattan when using applauncherd daemon +# CONFIG += qdeclarative-boostable + +# Add dependency to Symbian components +# CONFIG += qt-components + +# The .cpp file which was generated for your project. Feel free to hack it. SOURCES = main.cpp model.cpp +HEADERS = model.h +RESOURCES += abstractitemmodel.qrc + +# Please do not modify the following two lines. Required for deployment. +include(../../../tools/qmlapplicationviewer/qmlapplicationviewer.pri) +qtcAddDeployment() diff --git a/examples/declarative/modelviews/abstractitemmodel/main.cpp b/examples/declarative/modelviews/abstractitemmodel/main.cpp index f60c9b8..4a3e84e 100644 --- a/examples/declarative/modelviews/abstractitemmodel/main.cpp +++ b/examples/declarative/modelviews/abstractitemmodel/main.cpp @@ -38,28 +38,28 @@ ** ****************************************************************************/ #include "model.h" +#include "qmlapplicationviewer.h" #include -#include - #include //![0] int main(int argc, char ** argv) { QApplication app(argc, argv); + QmlApplicationViewer viewer; AnimalModel model; model.addAnimal(Animal("Wolf", "Medium")); model.addAnimal(Animal("Polar bear", "Large")); model.addAnimal(Animal("Quoll", "Small")); - QDeclarativeView view; - QDeclarativeContext *ctxt = view.rootContext(); + QDeclarativeContext *ctxt = viewer.rootContext(); ctxt->setContextProperty("myModel", &model); //![0] - view.setSource(QUrl("qrc:view.qml")); - view.show(); + viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape); + viewer.setMainQmlFile(QLatin1String("qml/abstractitemmodel/view.qml")); + viewer.showExpanded(); return app.exec(); } diff --git a/examples/declarative/modelviews/abstractitemmodel/qml/abstractitemmodel/view.qml b/examples/declarative/modelviews/abstractitemmodel/qml/abstractitemmodel/view.qml new file mode 100644 index 0000000..0363e9a --- /dev/null +++ b/examples/declarative/modelviews/abstractitemmodel/qml/abstractitemmodel/view.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ +import QtQuick 1.0 + +//![0] +ListView { + width: 200; height: 250 + anchors.fill: parent + + model: myModel + delegate: Text { text: "Animal: " + type + ", " + size } +} +//![0] + diff --git a/examples/declarative/modelviews/abstractitemmodel/view.qml b/examples/declarative/modelviews/abstractitemmodel/view.qml deleted file mode 100644 index 0363e9a..0000000 --- a/examples/declarative/modelviews/abstractitemmodel/view.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** -****************************************************************************/ -import QtQuick 1.0 - -//![0] -ListView { - width: 200; height: 250 - anchors.fill: parent - - model: myModel - delegate: Text { text: "Animal: " + type + ", " + size } -} -//![0] - -- cgit v0.12