aboutsummaryrefslogtreecommitdiffstats
path: root/examples/declarative/modelviews
diff options
context:
space:
mode:
authorDamian Jansen <damian.jansen@nokia.com>2011-08-26 15:38:56 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-02 07:56:38 +0200
commit44dabd02d63ecdb776b6a102888af06cac5987c0 (patch)
tree0088cde4de22dafc5a53f009cba780abeb1ee6d4 /examples/declarative/modelviews
parent04f75faee3f7aedd10748a00d83ff87a97c223e6 (diff)
Update more examples to QtQuick 2.0
Minehunt and abstractitemmodel examples use QSGview Snake now using Particles 2.0 Minor examples and twitter have updated imports Removed duplicate delegate example Change-Id: I04f8f8aeb8ef34ab2a8678ccc1d6d594b9db166e Reviewed-on: http://codereview.qt.nokia.com/3630 Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'examples/declarative/modelviews')
-rw-r--r--examples/declarative/modelviews/Delegate/Delegate.qml88
-rw-r--r--examples/declarative/modelviews/Delegate/view.qml76
-rw-r--r--examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro12
-rw-r--r--examples/declarative/modelviews/abstractitemmodel/main.cpp10
-rw-r--r--examples/declarative/modelviews/abstractitemmodel/view.qml3
-rw-r--r--examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro5
6 files changed, 15 insertions, 179 deletions
diff --git a/examples/declarative/modelviews/Delegate/Delegate.qml b/examples/declarative/modelviews/Delegate/Delegate.qml
deleted file mode 100644
index ef575f567f..0000000000
--- a/examples/declarative/modelviews/Delegate/Delegate.qml
+++ /dev/null
@@ -1,88 +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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-//![0]
-Package {
- Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' }
- Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' }
-
- Rectangle {
- id: wrapper
- width: 200; height: 25
- color: 'lightsteelblue'
-
- Text { text: display; anchors.centerIn: parent }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (wrapper.state == 'inList')
- wrapper.state = 'inGrid';
- else
- wrapper.state = 'inList';
- }
- }
-
- state: 'inList'
- states: [
- State {
- name: 'inList'
- ParentChange { target: wrapper; parent: listDelegate }
- },
- State {
- name: 'inGrid'
- ParentChange {
- target: wrapper; parent: gridDelegate
- x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height
- }
- }
- ]
-
- transitions: [
- Transition {
- ParentAnimation {
- NumberAnimation { properties: 'x,y,width,height'; duration: 300 }
- }
- }
- ]
- }
-}
-//![0]
diff --git a/examples/declarative/modelviews/Delegate/view.qml b/examples/declarative/modelviews/Delegate/view.qml
deleted file mode 100644
index 89fed86aa6..0000000000
--- a/examples/declarative/modelviews/Delegate/view.qml
+++ /dev/null
@@ -1,76 +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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- color: "white"
- width: 400
- height: 200
-
- ListModel {
- id: myModel
- ListElement { display: "One" }
- ListElement { display: "Two" }
- ListElement { display: "Three" }
- ListElement { display: "Four" }
- ListElement { display: "Five" }
- ListElement { display: "Six" }
- ListElement { display: "Seven" }
- ListElement { display: "Eight" }
- }
- //![0]
- VisualDataModel {
- id: visualModel
- delegate: Delegate {}
- model: myModel
- }
-
- ListView {
- width: 200; height:200
- model: visualModel.parts.list
- }
- GridView {
- x: 200; width: 200; height:200
- cellHeight: 50
- model: visualModel.parts.grid
- }
- //![0]
-}
diff --git a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro b/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro
index 760a8dca55..6c51eed9d2 100644
--- a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro
+++ b/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro
@@ -1,8 +1,10 @@
TEMPLATE = app
-
-QT += declarative qtquick1
-
-RESOURCES += abstractitemmodel.qrc
+TARGET = abstractitemmodel
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
HEADERS = model.h
-SOURCES = main.cpp model.cpp
+SOURCES = main.cpp \
+ model.cpp
+RESOURCES += abstractitemmodel.qrc \ No newline at end of file
diff --git a/examples/declarative/modelviews/abstractitemmodel/main.cpp b/examples/declarative/modelviews/abstractitemmodel/main.cpp
index 7f3c574178..3c78608295 100644
--- a/examples/declarative/modelviews/abstractitemmodel/main.cpp
+++ b/examples/declarative/modelviews/abstractitemmodel/main.cpp
@@ -38,10 +38,13 @@
**
****************************************************************************/
#include "model.h"
-#include <QtQuick1/QDeclarativeView>
-#include <QtDeclarative/QDeclarativeContext>
#include <QApplication>
+#include <qdeclarativeengine.h>
+#include <qdeclarativecontext.h>
+#include <qdeclarative.h>
+#include <qsgitem.h>
+#include <qsgview.h>
//![0]
int main(int argc, char ** argv)
@@ -53,7 +56,8 @@ int main(int argc, char ** argv)
model.addAnimal(Animal("Polar bear", "Large"));
model.addAnimal(Animal("Quoll", "Small"));
- QDeclarativeView view;
+ QSGView view;
+ view.setResizeMode(QSGView::SizeRootObjectToView);
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", &model);
//![0]
diff --git a/examples/declarative/modelviews/abstractitemmodel/view.qml b/examples/declarative/modelviews/abstractitemmodel/view.qml
index 0363e9a4eb..6a02f5e750 100644
--- a/examples/declarative/modelviews/abstractitemmodel/view.qml
+++ b/examples/declarative/modelviews/abstractitemmodel/view.qml
@@ -37,12 +37,11 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
//![0]
ListView {
width: 200; height: 250
- anchors.fill: parent
model: myModel
delegate: Text { text: "Animal: " + type + ", " + size }
diff --git a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro
index de3e16f948..8cc293dbfa 100644
--- a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro
+++ b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro
@@ -10,9 +10,4 @@ SOURCES += main.cpp \
HEADERS += dataobject.h
RESOURCES += objectlistmodel.qrc
-sources.files = $$SOURCES $$HEADERS $$RESOURCES objectlistmodel.pro view.qml
-sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/objectlistmodel
-target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/objectlistmodel
-
-INSTALLS += sources target