From 700910d938c75c978f765ec8438f81e70676999a Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 23 Jan 2013 14:08:58 -0800 Subject: Add QtQml.Models module The moved Model classes can now be exposed in a QtQml import. To keep the QtQml import resticted to more core functionality, they are being exposed in a plugin module. Change-Id: I0a84642a72c7c9bbf9b6ffd2a6c33549f8e61c29 Reviewed-by: Alan Alpert Reviewed-by: Lars Knoll --- .../photoviewer/PhotoViewerCore/AlbumDelegate.qml | 3 +- examples/quick/demos/photoviewer/photoviewer.qml | 3 +- examples/quick/demos/stocqt/stocqt.qml | 3 +- .../quick/draganddrop/doc/src/draganddrop.qdoc | 2 +- examples/quick/draganddrop/views/gridview.qml | 5 +- examples/quick/shadereffects/shadereffects.qml | 3 +- .../dynamicview/dynamicview3/dynamicview.qml | 7 +- .../dynamicview/dynamicview4/dynamicview.qml | 7 +- .../tutorials/gettingStartedQml/core/MenuBar.qml | 3 +- .../gettingStartedQml/parts/part2/MenuBar.qml | 3 +- .../gettingStartedQml/parts/part3/MenuBar.qml | 3 +- .../gettingStartedQml/parts/part4/MenuBar.qml | 3 +- .../gettingStartedQml/parts/part5/core/MenuBar.qml | 3 +- examples/quick/views/doc/src/views.qdoc | 4 +- examples/quick/views/objectmodel/objectmodel.qml | 118 +++++++++++++++++++++ examples/quick/views/package/view.qml | 3 +- .../quick/views/parallax/content/ParallaxView.qml | 3 +- examples/quick/views/views.qml | 37 +++---- examples/quick/views/views.qrc | 2 +- .../quick/views/visualdatamodel/dragselection.qml | 19 ++-- examples/quick/views/visualdatamodel/slideshow.qml | 11 +- .../views/visualitemmodel/visualitemmodel.qml | 117 -------------------- 22 files changed, 190 insertions(+), 172 deletions(-) create mode 100644 examples/quick/views/objectmodel/objectmodel.qml delete mode 100644 examples/quick/views/visualitemmodel/visualitemmodel.qml (limited to 'examples/quick') diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml index 4bd5e33ae3..d94231c9b5 100644 --- a/examples/quick/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml +++ b/examples/quick/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml @@ -41,6 +41,7 @@ import QtQuick 2.0 import QtQuick.XmlListModel 2.0 +import QtQml.Models 2.1 Component { id: albumDelegate @@ -69,7 +70,7 @@ Component { Package.name: 'album' id: albumWrapper; width: 210; height: 220 - VisualDataModel { + DelegateModel { id: visualModel; delegate: PhotoDelegate { } model: RssModel { id: rssModel; tags: tag } } diff --git a/examples/quick/demos/photoviewer/photoviewer.qml b/examples/quick/demos/photoviewer/photoviewer.qml index fa7c83f74e..df344accd5 100644 --- a/examples/quick/demos/photoviewer/photoviewer.qml +++ b/examples/quick/demos/photoviewer/photoviewer.qml @@ -40,6 +40,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 import "PhotoViewerCore" Rectangle { @@ -58,7 +59,7 @@ Rectangle { ListElement { tag: "Prague" } } - VisualDataModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} } + DelegateModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} } GridView { id: albumView; width: parent.width; height: parent.height; cellWidth: 210; cellHeight: 220 diff --git a/examples/quick/demos/stocqt/stocqt.qml b/examples/quick/demos/stocqt/stocqt.qml index ec353737fe..9bcffd972f 100644 --- a/examples/quick/demos/stocqt/stocqt.qml +++ b/examples/quick/demos/stocqt/stocqt.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 import "./content" ListView { @@ -66,7 +67,7 @@ ListView { } } - model: VisualItemModel { + model: ObjectModel { StockListView { id: listView width: root.width diff --git a/examples/quick/draganddrop/doc/src/draganddrop.qdoc b/examples/quick/draganddrop/doc/src/draganddrop.qdoc index 1844c3b4eb..ad32cbcfcd 100644 --- a/examples/quick/draganddrop/doc/src/draganddrop.qdoc +++ b/examples/quick/draganddrop/doc/src/draganddrop.qdoc @@ -49,7 +49,7 @@ \section2 GridView adds drag and drop to a GridView, allowing you to reorder the list. - It uses a VisualDataModel to move a delegate item to the position of another item + It uses a DelegateModel to move a delegate item to the position of another item it is dragged over. \snippet quick/draganddrop/views/gridview.qml 0 diff --git a/examples/quick/draganddrop/views/gridview.qml b/examples/quick/draganddrop/views/gridview.qml index 4df265e8af..f2c9c75e42 100644 --- a/examples/quick/draganddrop/views/gridview.qml +++ b/examples/quick/draganddrop/views/gridview.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 GridView { id: root @@ -50,7 +51,7 @@ GridView { } //! [0] - model: VisualDataModel { + model: DelegateModel { //! [0] id: visualModel model: ListModel { @@ -84,7 +85,7 @@ GridView { delegate: MouseArea { id: delegateRoot - property int visualIndex: VisualDataModel.itemsIndex + property int visualIndex: DelegateModel.itemsIndex width: 80; height: 80 drag.target: icon diff --git a/examples/quick/shadereffects/shadereffects.qml b/examples/quick/shadereffects/shadereffects.qml index 77de356eac..a8f0469b44 100644 --- a/examples/quick/shadereffects/shadereffects.qml +++ b/examples/quick/shadereffects/shadereffects.qml @@ -40,6 +40,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 import "content" Rectangle { @@ -85,7 +86,7 @@ Rectangle { height: 140 clip: true snapMode: ListView.SnapOneItem - model: VisualItemModel { + model: ObjectModel { Text { width: 160 height: 140 diff --git a/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml index 09c69df54d..7f353f075a 100644 --- a/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml +++ b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 //![0] Rectangle { id: root @@ -111,8 +112,8 @@ Rectangle { onEntered: { visualModel.items.move( - drag.source.VisualDataModel.itemsIndex, - dragArea.VisualDataModel.itemsIndex) + drag.source.DelegateModel.itemsIndex, + dragArea.DelegateModel.itemsIndex) } } //![3] @@ -120,7 +121,7 @@ Rectangle { } //![2] //![4] - VisualDataModel { + DelegateModel { id: visualModel model: PetsModel {} diff --git a/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml index 6ff3f7eb96..82639c2016 100644 --- a/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml +++ b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 Rectangle { id: root @@ -112,14 +113,14 @@ Rectangle { onEntered: { visualModel.items.move( - drag.source.VisualDataModel.itemsIndex, - dragArea.VisualDataModel.itemsIndex) + drag.source.DelegateModel.itemsIndex, + dragArea.DelegateModel.itemsIndex) } } } } //![0] - VisualDataModel { + DelegateModel { id: visualModel //![4] property var lessThan: [ diff --git a/examples/quick/tutorials/gettingStartedQml/core/MenuBar.qml b/examples/quick/tutorials/gettingStartedQml/core/MenuBar.qml index c6edcab836..b53fc1b45a 100644 --- a/examples/quick/tutorials/gettingStartedQml/core/MenuBar.qml +++ b/examples/quick/tutorials/gettingStartedQml/core/MenuBar.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 Rectangle { id: menuBar @@ -128,7 +129,7 @@ Rectangle { } } //a list of visual items already have delegates handling their display - VisualItemModel { + ObjectModel { id: menuListModel FileMenu { diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part2/MenuBar.qml b/examples/quick/tutorials/gettingStartedQml/parts/part2/MenuBar.qml index 929052f0ae..63b2a1c190 100644 --- a/examples/quick/tutorials/gettingStartedQml/parts/part2/MenuBar.qml +++ b/examples/quick/tutorials/gettingStartedQml/parts/part2/MenuBar.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 Rectangle { id: menuBar @@ -99,7 +100,7 @@ Rectangle { } //a list of visual items already have delegates handling their display - VisualItemModel{ + ObjectModel{ id: menuListModel FileMenu{ diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part3/MenuBar.qml b/examples/quick/tutorials/gettingStartedQml/parts/part3/MenuBar.qml index 929052f0ae..63b2a1c190 100644 --- a/examples/quick/tutorials/gettingStartedQml/parts/part3/MenuBar.qml +++ b/examples/quick/tutorials/gettingStartedQml/parts/part3/MenuBar.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 Rectangle { id: menuBar @@ -99,7 +100,7 @@ Rectangle { } //a list of visual items already have delegates handling their display - VisualItemModel{ + ObjectModel{ id: menuListModel FileMenu{ diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part4/MenuBar.qml b/examples/quick/tutorials/gettingStartedQml/parts/part4/MenuBar.qml index 39b74e9d49..7bb1d2d30e 100644 --- a/examples/quick/tutorials/gettingStartedQml/parts/part4/MenuBar.qml +++ b/examples/quick/tutorials/gettingStartedQml/parts/part4/MenuBar.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 Rectangle { id: menuBar @@ -105,7 +106,7 @@ Rectangle { } //a list of visual items already have delegates handling their display - VisualItemModel{ + ObjectModel{ id: menuListModel FileMenu{ diff --git a/examples/quick/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml index 7ffa90c8f4..3600be7868 100644 --- a/examples/quick/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml +++ b/examples/quick/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 Rectangle { id: menuBar @@ -129,7 +130,7 @@ Rectangle { } } //a list of visual items already have delegates handling their display - VisualItemModel{ + ObjectModel{ id: menuListModel FileMenu{ diff --git a/examples/quick/views/doc/src/views.qdoc b/examples/quick/views/doc/src/views.qdoc index e48a66514b..658e51c8fc 100644 --- a/examples/quick/views/doc/src/views.qdoc +++ b/examples/quick/views/doc/src/views.qdoc @@ -71,12 +71,12 @@ \snippet quick/views/package/Delegate.qml 0 - A VisualDataModel allows the individual views to access their specific items from + A DelegateModel allows the individual views to access their specific items from the shared package delegate. \snippet quick/views/package/view.qml 0 - \section2 VisualItemModel uses a VisualItemModel for the model instead of a ListModel. + \section2 ObjectModel uses an ObjectModel for the model instead of a ListModel. \snippet quick/views/visualitemmodel/visualitemmodel.qml 0 */ diff --git a/examples/quick/views/objectmodel/objectmodel.qml b/examples/quick/views/objectmodel/objectmodel.qml new file mode 100644 index 0000000000..b790053c82 --- /dev/null +++ b/examples/quick/views/objectmodel/objectmodel.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc 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$ +** +****************************************************************************/ + +// This example demonstrates placing items in a view using +// an ObjectModel + +import QtQuick 2.0 +import QtQml.Models 2.1 + +Rectangle { + id: root + color: "lightgray" + width: 320 + height: 480 + property bool printDestruction: false + +//! [0] + ObjectModel { + id: itemModel + + Rectangle { + width: view.width; height: view.height + color: "#FFFEF0" + Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } + + Component.onDestruction: if (printDestruction) print("destroyed 1") + } + Rectangle { + width: view.width; height: view.height + color: "#F0FFF7" + Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } + + Component.onDestruction: if (printDestruction) print("destroyed 2") + } + Rectangle { + width: view.width; height: view.height + color: "#F4F0FF" + Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } + + Component.onDestruction: if (printDestruction) print("destroyed 3") + } + } + + ListView { + id: view + anchors { fill: parent; bottomMargin: 30 } + model: itemModel + preferredHighlightBegin: 0; preferredHighlightEnd: 0 + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem; flickDeceleration: 2000 + cacheBuffer: 200 + } +//! [0] + Rectangle { + width: root.width; height: 30 + anchors { top: view.bottom; bottom: parent.bottom } + color: "gray" + + Row { + anchors.centerIn: parent + spacing: 20 + + Repeater { + model: itemModel.count + + Rectangle { + width: 5; height: 5 + radius: 3 + color: view.currentIndex == index ? "blue" : "white" + + MouseArea { + width: 20; height: 20 + anchors.centerIn: parent + onClicked: view.currentIndex = index + } + } + } + } + } +} diff --git a/examples/quick/views/package/view.qml b/examples/quick/views/package/view.qml index 58ae5a4bf8..820eb4068c 100644 --- a/examples/quick/views/package/view.qml +++ b/examples/quick/views/package/view.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 Rectangle { id: root @@ -64,7 +65,7 @@ Rectangle { ListElement { display: "Eight" } } //![0] - VisualDataModel { + DelegateModel { id: visualModel delegate: Delegate {} model: myModel diff --git a/examples/quick/views/parallax/content/ParallaxView.qml b/examples/quick/views/parallax/content/ParallaxView.qml index 5bfed1a297..e8c67c7434 100644 --- a/examples/quick/views/parallax/content/ParallaxView.qml +++ b/examples/quick/views/parallax/content/ParallaxView.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 Item { id: root @@ -63,7 +64,7 @@ Item { orientation: Qt.Horizontal boundsBehavior: Flickable.DragOverBounds - model: VisualItemModel { id: visualModel } + model: ObjectModel { id: visualModel } highlightRangeMode: ListView.StrictlyEnforceRange snapMode: ListView.SnapOneItem diff --git a/examples/quick/views/views.qml b/examples/quick/views/views.qml index d1dda2a777..0724d11456 100644 --- a/examples/quick/views/views.qml +++ b/examples/quick/views/views.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 import "../shared" as Examples /*! @@ -51,50 +52,50 @@ import "../shared" as Examples are focused on the views side, which is the visual representation of the data in the models. \section2 GridView and PathView demonstrate usage of these elements to display views. - \snippet examples/quick/modelviews/gridview/gridview-example.qml 0 + \snippet examples/quick/views/gridview/gridview-example.qml 0 \section2 Dynamic List demonstrates animation of runtime additions and removals to a ListView. The ListView.onAdd signal handler runs an animation when new items are added to the view, and the ListView.onRemove another when they are removed. - \snippet examples/quick/modelviews/listview/dynamiclist.qml 0 - \snippet examples/quick/modelviews/listview/dynamiclist.qml 1 + \snippet examples/quick/views/listview/dynamiclist.qml 0 + \snippet examples/quick/views/listview/dynamiclist.qml 1 \section2 Expanding Delegates demonstrates delegates that expand when activated. It has a complex delegate the size and appearance of which can change, displacing other items in the view. - \snippet examples/quick/modelviews/listview/expandingdelegates.qml 0 - \snippet examples/quick/modelviews/listview/expandingdelegates.qml 1 - \snippet examples/quick/modelviews/listview/expandingdelegates.qml 2 - \snippet examples/quick/modelviews/listview/expandingdelegates.qml 3 + \snippet examples/quick/views/listview/expandingdelegates.qml 0 + \snippet examples/quick/views/listview/expandingdelegates.qml 1 + \snippet examples/quick/views/listview/expandingdelegates.qml 2 + \snippet examples/quick/views/listview/expandingdelegates.qml 3 \section2 Highlight demonstrates adding a custom highlight to a ListView. - \snippet examples/quick/modelviews/listview/highlight.qml 0 + \snippet examples/quick/views/listview/highlight.qml 0 \section2 Highlight Ranges shows the three different highlight range modes of ListView. - \snippet examples/quick/modelviews/listview/highlightranges.qml 0 - \snippet examples/quick/modelviews/listview/highlightranges.qml 1 - \snippet examples/quick/modelviews/listview/highlightranges.qml 2 + \snippet examples/quick/views/listview/highlightranges.qml 0 + \snippet examples/quick/views/listview/highlightranges.qml 1 + \snippet examples/quick/views/listview/highlightranges.qml 2 \section2 Sections demonstrates the various section headers and footers available to ListView. - \snippet examples/quick/modelviews/listview/sections.qml 0 + \snippet examples/quick/views/listview/sections.qml 0 \section2 Packages demonstrates using Packages to transition delegates between two views. It has a Package which defines delegate items for each view and an item that can be transferred between delegates. - \snippet examples/quick/modelviews/package/Delegate.qml 0 + \snippet examples/quick/views/package/Delegate.qml 0 - A VisualDataModel allows the individual views to access their specific items from + A DelegateModel allows the individual views to access their specific items from the shared package delegate. - \snippet examples/quick/modelviews/package/view.qml 0 + \snippet examples/quick/views/package/view.qml 0 - \section2 VisualItemModel uses a VisualItemModel for the model instead of a ListModel. + \section2 ObjectModel uses a ObjectModel for the model instead of a ListModel. - \snippet examples/quick/modelviews/visualitemmodel/visualitemmodel.qml 0 + \snippet examples/quick/views/objectmodel/objectmodel.qml 0 */ Item { @@ -112,7 +113,7 @@ import "../shared" as Examples addExample("Sections", "ListView section headers and footers", Qt.resolvedUrl("listview/sections.qml")) addExample("Packages", "Transitions between a ListView and GridView", Qt.resolvedUrl("package/view.qml")) addExample("PathView", "A simple PathView", Qt.resolvedUrl("pathview/pathview-example.qml")) - addExample("VisualItemModel", "Using a VisualItemModel", Qt.resolvedUrl("visualitemmodel/visualitemmodel.qml")) + addExample("ObjectModel", "Using a ObjectModel", Qt.resolvedUrl("objectmodel/objectmodel.qml")) } } } diff --git a/examples/quick/views/views.qrc b/examples/quick/views/views.qrc index e35f128202..434fa788bf 100644 --- a/examples/quick/views/views.qrc +++ b/examples/quick/views/views.qrc @@ -63,7 +63,7 @@ pathview/pics/VideoPlayer_48.png visualdatamodel/slideshow.qml visualdatamodel/dragselection.qml - visualitemmodel/visualitemmodel.qml + objectmodel/objectmodel.qml views.qml diff --git a/examples/quick/views/visualdatamodel/dragselection.qml b/examples/quick/views/visualdatamodel/dragselection.qml index ec80cc7c16..5578268961 100644 --- a/examples/quick/views/visualdatamodel/dragselection.qml +++ b/examples/quick/views/visualdatamodel/dragselection.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQml.Models 2.1 Item { id: root @@ -59,7 +60,7 @@ Item { width: 64 height: 64 - enabled: packageRoot.VisualDataModel.inSelected + enabled: packageRoot.DelegateModel.inSelected drag.target: draggable @@ -83,7 +84,7 @@ Item { } DropArea { anchors.fill: parent - onEntered: selectedItems.move(0, visualModel.items.get(packageRoot.VisualDataModel.itemsIndex), selectedItems.count) + onEntered: selectedItems.move(0, visualModel.items.get(packageRoot.DelegateModel.itemsIndex), selectedItems.count) } } Item { @@ -112,7 +113,7 @@ Item { border.width: 2 border.color: "#007423" - state: root.dragging && packageRoot.VisualDataModel.inSelected ? "selected" : "visible" + state: root.dragging && packageRoot.DelegateModel.inSelected ? "selected" : "visible" Text { anchors.fill: parent @@ -126,7 +127,7 @@ Item { Rectangle { anchors { right: parent.right; top: parent.top; margins: 3 } width: 12; height: 12 - color: packageRoot.VisualDataModel.inSelected ? "black" : "white" + color: packageRoot.DelegateModel.inSelected ? "black" : "white" radius: 6 border.color: "white" @@ -134,7 +135,7 @@ Item { MouseArea { anchors.fill: parent - onClicked: packageRoot.VisualDataModel.inSelected = !packageRoot.VisualDataModel.inSelected + onClicked: packageRoot.DelegateModel.inSelected = !packageRoot.DelegateModel.inSelected } } @@ -142,19 +143,19 @@ Item { State { name: "selected" ParentChange { target: content; parent: selectionContainer; x: 3; y: 3 } - PropertyChanges { target: packageRoot; VisualDataModel.inItems: visibleContainer.drag.active } + PropertyChanges { target: packageRoot; DelegateModel.inItems: visibleContainer.drag.active } PropertyChanges { target: gradientStart; color: "#017423" } PropertyChanges { target: gradientStart; color: "#007423" } }, State { name: "visible" - PropertyChanges { target: packageRoot; VisualDataModel.inItems: true } + PropertyChanges { target: packageRoot; DelegateModel.inItems: true } ParentChange { target: content; parent: visibleContainer; x: 3; y: 3 } PropertyChanges { target: gradientStart; color: "#8AC953" } PropertyChanges { target: gradientStart; color: "#8BC953" } } ] transitions: Transition { - PropertyAction { target: packageRoot; properties: "VisualDataModel.inItems" } + PropertyAction { target: packageRoot; properties: "DelegateModel.inItems" } ParentAnimation { target: content NumberAnimation { target: content; properties: "x,y"; duration: 500 } @@ -165,7 +166,7 @@ Item { } } - VisualDataModel { + DelegateModel { id: visualModel model: 35 delegate: packageDelegate diff --git a/examples/quick/views/visualdatamodel/slideshow.qml b/examples/quick/views/visualdatamodel/slideshow.qml index 77fe9809d4..d3a4013503 100644 --- a/examples/quick/views/visualdatamodel/slideshow.qml +++ b/examples/quick/views/visualdatamodel/slideshow.qml @@ -40,6 +40,7 @@ import QtQuick 2.0 import QtQuick.XmlListModel 2.0 +import QtQml.Models 2.1 Rectangle { id: root @@ -50,7 +51,7 @@ Rectangle { color: "black" - VisualDataModel { + DelegateModel { id: visualModel model: XmlListModel { @@ -97,14 +98,14 @@ Rectangle { name: "inDisplay"; ParentChange { target: image; parent: imageContainer; x: 75; y: 75; width: 150; height: 150 } PropertyChanges { target: image; z: 2 } - PropertyChanges { target: delegateItem; VisualDataModel.inItems: false } + PropertyChanges { target: delegateItem; DelegateModel.inItems: false } }, State { when: root.displayItem !== delegateItem name: "inList"; ParentChange { target: image; parent: delegateItem; x: 2; y: 2; width: 75; height: 75 } PropertyChanges { target: image; z: 1 } - PropertyChanges { target: delegateItem; VisualDataModel.inItems: true } + PropertyChanges { target: delegateItem; DelegateModel.inItems: true } } ] @@ -112,7 +113,7 @@ Rectangle { Transition { from: "inList" SequentialAnimation { - PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: true } + PropertyAction { target: delegateItem; property: "DelegateModel.inPersistedItems"; value: true } ParentAnimation { target: image; via: root @@ -126,7 +127,7 @@ Rectangle { target: image NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 } } - PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: false } + PropertyAction { target: delegateItem; property: "DelegateModel.inPersistedItems"; value: false } } } ] diff --git a/examples/quick/views/visualitemmodel/visualitemmodel.qml b/examples/quick/views/visualitemmodel/visualitemmodel.qml deleted file mode 100644 index 90adf39b86..0000000000 --- a/examples/quick/views/visualitemmodel/visualitemmodel.qml +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia Plc 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$ -** -****************************************************************************/ - -// This example demonstrates placing items in a view using -// a VisualItemModel - -import QtQuick 2.0 - -Rectangle { - id: root - color: "lightgray" - width: 320 - height: 480 - property bool printDestruction: false - -//! [0] - VisualItemModel { - id: itemModel - - Rectangle { - width: view.width; height: view.height - color: "#FFFEF0" - Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } - - Component.onDestruction: if (printDestruction) print("destroyed 1") - } - Rectangle { - width: view.width; height: view.height - color: "#F0FFF7" - Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } - - Component.onDestruction: if (printDestruction) print("destroyed 2") - } - Rectangle { - width: view.width; height: view.height - color: "#F4F0FF" - Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } - - Component.onDestruction: if (printDestruction) print("destroyed 3") - } - } - - ListView { - id: view - anchors { fill: parent; bottomMargin: 30 } - model: itemModel - preferredHighlightBegin: 0; preferredHighlightEnd: 0 - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem; flickDeceleration: 2000 - cacheBuffer: 200 - } -//! [0] - Rectangle { - width: root.width; height: 30 - anchors { top: view.bottom; bottom: parent.bottom } - color: "gray" - - Row { - anchors.centerIn: parent - spacing: 20 - - Repeater { - model: itemModel.count - - Rectangle { - width: 5; height: 5 - radius: 3 - color: view.currentIndex == index ? "blue" : "white" - - MouseArea { - width: 20; height: 20 - anchors.centerIn: parent - onClicked: view.currentIndex = index - } - } - } - } - } -} -- cgit v1.2.3