summaryrefslogtreecommitdiffstats
path: root/doc/src
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-10-06 05:17:43 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-10-06 05:17:43 (GMT)
commite3549cc32e4eab21b921cc66d07841eb81f52223 (patch)
tree865e1ea5542e0f93f76811bb4b823ba5c3493cdc /doc/src
parent9d2de4a1aa26b4a19a6ffb4dad7a2d8ad06163d9 (diff)
parent2d7ad6196158a6138c946a5d26eefe9ac32f0773 (diff)
downloadQt-e3549cc32e4eab21b921cc66d07841eb81f52223.zip
Qt-e3549cc32e4eab21b921cc66d07841eb81f52223.tar.gz
Qt-e3549cc32e4eab21b921cc66d07841eb81f52223.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/declarative/binding.qdoc5
-rw-r--r--doc/src/declarative/qmlmodels.qdoc61
-rw-r--r--doc/src/declarative/qtdeclarative.qdoc1
-rw-r--r--doc/src/snippets/declarative/GroupBox.qml4
-rw-r--r--doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml2
-rw-r--r--doc/src/snippets/declarative/gridview/gridview.qml12
-rw-r--r--doc/src/snippets/declarative/listview/highlight.qml14
-rw-r--r--doc/src/snippets/declarative/listview/listview.qml12
-rw-r--r--doc/src/snippets/declarative/pathview/pathattributes.qml12
-rw-r--r--doc/src/snippets/declarative/pathview/pathview.qml12
10 files changed, 100 insertions, 35 deletions
diff --git a/doc/src/declarative/binding.qdoc b/doc/src/declarative/binding.qdoc
index 37b4c97..e6835ee 100644
--- a/doc/src/declarative/binding.qdoc
+++ b/doc/src/declarative/binding.qdoc
@@ -38,7 +38,8 @@ The QML mechanisms of data binding can also be used to bind Qt C++ objects.
The data binding framework is based on Qt's property system (see the Qt documentation for more details on this system). If a binding is meant to be dynamic (where changes in one object are reflected in another object), \c NOTIFY must be specified for the property being tracked. If \c NOTIFY is not specified, any binding to that property will be an 'intialization' binding (the tracking object will be updated only once with the initial value of the tracked object).
-Relevant items can also be bound to the contents of a Qt model. For example, ListView can make use of data from a QListModelInterface-derived model. (QListModelInterface is part of the next generation Model/View architecture being developed for Qt.)
+Relevant items can also be bound to the contents of a Qt model.
+For example, ListView can make use of data from a QAbstractItemModel-derived model.
\section1 Passing Data Between C++ and QML
@@ -107,4 +108,6 @@ Binding { target: screen; property: "brightness"; value: slider.value }
The \l QBindableMap class provides a convenient way to make data visible to the bind engine.
+C++ \l {qmlmodels}{Data Models} may also be provided to QML.
+
*/
diff --git a/doc/src/declarative/qmlmodels.qdoc b/doc/src/declarative/qmlmodels.qdoc
new file mode 100644
index 0000000..4712de1
--- /dev/null
+++ b/doc/src/declarative/qmlmodels.qdoc
@@ -0,0 +1,61 @@
+/*!
+\page qmlmodels.html
+\target qmlmodels
+\title Data Models
+
+Some QML Items use Data Models to provide the data to be displayed.
+These items typically require a \e delegate component that
+creates an instance for each item in the model. Models may be static, or
+have items modified, inserted, removed or moved dynamically.
+
+Data is provided to the delegate via named data roles which the
+delegate may bind to. A special \e index role containing the
+index of the item in the model is also available. Models that do
+not have named roles will have the data provided via the \e modelData
+role. The \e modelData role is also provided for Models that have
+only one role. In this case the \e modelData role contains the same
+data as the named role.
+
+There are a number of QML elements that operate using data models:
+
+\list
+\o ListView
+\o GridView
+\o PathView
+\o \l {qml-repeater}{Repeater}
+\endlist
+
+QML supports several types of data model, which may be provided by QML
+or C++ (via QmlContext::setContextProperty(), for example).
+
+\section1 QML Data Models
+
+\list
+\o ListModel is a simple hierarchy of elements specified in QML. The
+available roles are specified by the \l ListElement properties.
+\o XmlListModel allows construction of a model from an XML data source. The roles
+are specified via the \l XmlRole element.
+\o VisualItemModel allows QML items to be provided as a model. This model contains
+both the data and delegate (its child items). This model does not provide any roles.
+\endlist
+
+
+\section1 C++ Data Models
+
+\list
+\o QAbstractItemModel provides the roles set via the QAbstractItemModel::setRoleNames() method.
+\o QStringList provides the contents of the list via the \e modelData role.
+\o QList<QObject*> provides the properties of the objects in the list as roles.
+\endlist
+
+
+\section1 Other Data Models
+
+\list
+\o An Integer specifies a model containing the integer number of elements.
+There are no data roles.
+\o An Object Instance specifies a model with a single Object element. The
+properties of the object are provided as roles.
+\endlist
+
+*/
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc
index 460819a..06cba15 100644
--- a/doc/src/declarative/qtdeclarative.qdoc
+++ b/doc/src/declarative/qtdeclarative.qdoc
@@ -71,6 +71,7 @@
Core QML Features:
\list
\o \l {binding}{Data Binding}
+ \o \l {qmlmodels}{Data Models}
\o \l {anchor-layout}{Layout Anchors}
\o \l {qmlanimation}{Animation}
\o \l {qmlmodules}{Modules}
diff --git a/doc/src/snippets/declarative/GroupBox.qml b/doc/src/snippets/declarative/GroupBox.qml
index 13e7eb6..6c5431e 100644
--- a/doc/src/snippets/declarative/GroupBox.qml
+++ b/doc/src/snippets/declarative/GroupBox.qml
@@ -1,12 +1,12 @@
import Qt 4.6
ContentWrapper {
- id: Container; width: parent.width; height: contents.height
+ id: container; width: parent.width; height: contents.height
children: [
Rectangle {
width: parent.width; height: contents.height
color: "white"; pen.width: 2; pen.color: "#adaeb0"; radius: 10
- VerticalLayout {
+ Column {
id: layout; width: parent.width; margin: 5; spacing: 2
Content { }
}
diff --git a/doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml b/doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml
index 6868385..3cf9ba7 100644
--- a/doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml
+++ b/doc/src/snippets/declarative/gridview/dummydata/ContactModel.qml
@@ -1,7 +1,7 @@
import Qt 4.6
ListModel {
- id: ContactModel
+ id: contactModel
ListElement {
name: "Bill Smith"
number: "555 3264"
diff --git a/doc/src/snippets/declarative/gridview/gridview.qml b/doc/src/snippets/declarative/gridview/gridview.qml
index d0f0623..1a2021c 100644
--- a/doc/src/snippets/declarative/gridview/gridview.qml
+++ b/doc/src/snippets/declarative/gridview/gridview.qml
@@ -11,11 +11,11 @@ Rectangle {
// instantiated for each visible item in the list.
//! [0]
Component {
- id: Delegate
+ id: delegate
Item {
- id: Wrapper
+ id: wrapper
width: 80; height: 78
- VerticalLayout {
+ Column {
Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter }
Text { text: name; anchors.horizontalCenter: parent.horizontalCenter }
}
@@ -26,7 +26,7 @@ Rectangle {
// by each ListView and placed behind the current item.
//! [1]
Component {
- id: Highlight
+ id: highlight
Rectangle {
color: "lightsteelblue"
radius: 5
@@ -37,9 +37,9 @@ Rectangle {
//! [2]
GridView {
width: parent.width; height: parent.height
- model: ContactModel; delegate: Delegate
+ model: ContactModel; delegate: delegate
cellWidth: 80; cellHeight: 80
- highlight: Highlight
+ highlight: highlight
focus: true
}
//! [2]
diff --git a/doc/src/snippets/declarative/listview/highlight.qml b/doc/src/snippets/declarative/listview/highlight.qml
index 97eac45..2234ee7 100644
--- a/doc/src/snippets/declarative/listview/highlight.qml
+++ b/doc/src/snippets/declarative/listview/highlight.qml
@@ -11,9 +11,9 @@ Rectangle {
// instantiated for each visible item in the list.
//! [0]
Component {
- id: Delegate
+ id: delegate
Item {
- id: Wrapper
+ id: wrapper
width: 180; height: 40
Column {
x: 5; y: 5
@@ -28,22 +28,22 @@ Rectangle {
// highlight moves to the current item.
//! [1]
Component {
- id: Highlight
+ id: highlight
Rectangle {
width: 180; height: 40
color: "lightsteelblue"; radius: 5
y: SpringFollow {
- source: List.currentItem.y
+ source: list.currentItem.y
spring: 3
damping: 0.2
}
}
}
ListView {
- id: List
+ id: list
width: parent.height; height: parent.height
- model: ContactModel; delegate: Delegate
- highlight: Highlight
+ model: ContactModel; delegate: delegate
+ highlight: highlight
highlightFollowsCurrentItem: false
focus: true
}
diff --git a/doc/src/snippets/declarative/listview/listview.qml b/doc/src/snippets/declarative/listview/listview.qml
index c907077..be0f3ad 100644
--- a/doc/src/snippets/declarative/listview/listview.qml
+++ b/doc/src/snippets/declarative/listview/listview.qml
@@ -12,11 +12,11 @@ Rectangle {
// instantiated for each visible item in the list.
//! [0]
Component {
- id: Delegate
+ id: delegate
Item {
- id: Wrapper
+ id: wrapper
width: 180; height: 40
- VerticalLayout {
+ Column {
x: 5; y: 5
Text { text: '<b>Name:</b> ' + name }
Text { text: '<b>Number:</b> ' + number }
@@ -28,7 +28,7 @@ Rectangle {
// by each ListView and placed behind the current item.
//! [1]
Component {
- id: Highlight
+ id: highlight
Rectangle {
color: "lightsteelblue"
radius: 5
@@ -40,8 +40,8 @@ Rectangle {
ListView {
width: parent.width; height: parent.height
model: ContactModel
- delegate: Delegate
- highlight: Highlight
+ delegate: delegate
+ highlight: highlight
focus: true
}
//! [2]
diff --git a/doc/src/snippets/declarative/pathview/pathattributes.qml b/doc/src/snippets/declarative/pathview/pathattributes.qml
index 92d6966..19a192c 100644
--- a/doc/src/snippets/declarative/pathview/pathattributes.qml
+++ b/doc/src/snippets/declarative/pathview/pathattributes.qml
@@ -5,22 +5,22 @@ Rectangle {
//! [0]
//! [1]
Component {
- id: Delegate
+ id: delegate
Item {
- id: Wrapper
+ id: wrapper
width: 80; height: 80
scale: PathView.scale
opacity: PathView.opacity
- VerticalLayout {
- Image { anchors.horizontalCenter: Name.horizontalCenter; width: 64; height: 64; source: icon }
- Text { id: Name; text: name; font.pointSize: 16}
+ Column {
+ Image { anchors.horizontalCenter: name.horizontalCenter; width: 64; height: 64; source: icon }
+ Text { id: name; text: name; font.pointSize: 16}
}
}
}
//! [1]
//! [2]
PathView {
- anchors.fill: parent; model: MenuModel; delegate: Delegate
+ anchors.fill: parent; model: MenuModel; delegate: delegate
path: Path {
startX: 120; startY: 100
PathAttribute { name: "scale"; value: 1.0 }
diff --git a/doc/src/snippets/declarative/pathview/pathview.qml b/doc/src/snippets/declarative/pathview/pathview.qml
index 004a1d2..5605139 100644
--- a/doc/src/snippets/declarative/pathview/pathview.qml
+++ b/doc/src/snippets/declarative/pathview/pathview.qml
@@ -5,20 +5,20 @@ Rectangle {
//! [0]
//! [1]
Component {
- id: Delegate
+ id: delegate
Item {
- id: Wrapper
+ id: wrapper
width: 80; height: 80
- VerticalLayout {
- Image { anchors.horizontalCenter: Name.horizontalCenter; width: 64; height: 64; source: icon }
- Text { id: Name; text: name; font.pointSize: 16}
+ Column {
+ Image { anchors.horizontalCenter: name.horizontalCenter; width: 64; height: 64; source: icon }
+ Text { id: name; text: name; font.pointSize: 16}
}
}
}
//! [1]
//! [2]
PathView {
- anchors.fill: parent; model: MenuModel; delegate: Delegate
+ anchors.fill: parent; model: MenuModel; delegate: delegate
path: Path {
startX: 120; startY: 100
PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 }