summaryrefslogtreecommitdiffstats
path: root/doc/src
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-05-19 06:51:37 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-05-19 06:51:37 (GMT)
commit8238ef5d6648ca8fde2c709d6125772cac6a11a5 (patch)
treed711561c6ff8ad5b2e91f9a376d28eff4fdd5c78 /doc/src
parent71114e0c0af7418f61c0bf5d9ec881619946e128 (diff)
downloadQt-8238ef5d6648ca8fde2c709d6125772cac6a11a5.zip
Qt-8238ef5d6648ca8fde2c709d6125772cac6a11a5.tar.gz
Qt-8238ef5d6648ca8fde2c709d6125772cac6a11a5.tar.bz2
Doc improvements
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/declarative/focus.qdoc7
-rw-r--r--doc/src/declarative/pics/listview-highlight.png (renamed from doc/src/declarative/pics/trivialListView.png)bin5918 -> 5918 bytes
-rw-r--r--doc/src/declarative/pics/listview-simple.pngbin0 -> 5351 bytes
-rw-r--r--doc/src/snippets/declarative/listview/ContactModel.qml (renamed from doc/src/snippets/declarative/listview/dummydata/ContactModel.qml)3
-rw-r--r--doc/src/snippets/declarative/listview/highlight.qml63
-rw-r--r--doc/src/snippets/declarative/listview/listview.qml116
6 files changed, 92 insertions, 97 deletions
diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc
index e2b8bb6..4c4a317 100644
--- a/doc/src/declarative/focus.qdoc
+++ b/doc/src/declarative/focus.qdoc
@@ -67,7 +67,12 @@ item and thus subsequently be \l {QEvent::ignore()}{ignored}.
\code
Item {
Item {
- Keys.onPressed: if (event.key == Qt.Key_A) { console.log('Key A was pressed'); event.accepted = true }
+ Keys.onPressed: {
+ if (event.key == Qt.Key_A) {
+ console.log('Key A was pressed');
+ event.accepted = true;
+ }
+ }
Rectangle {}
}
}
diff --git a/doc/src/declarative/pics/trivialListView.png b/doc/src/declarative/pics/listview-highlight.png
index dc5c6b3..dc5c6b3 100644
--- a/doc/src/declarative/pics/trivialListView.png
+++ b/doc/src/declarative/pics/listview-highlight.png
Binary files differ
diff --git a/doc/src/declarative/pics/listview-simple.png b/doc/src/declarative/pics/listview-simple.png
new file mode 100644
index 0000000..71a1c51
--- /dev/null
+++ b/doc/src/declarative/pics/listview-simple.png
Binary files differ
diff --git a/doc/src/snippets/declarative/listview/dummydata/ContactModel.qml b/doc/src/snippets/declarative/listview/ContactModel.qml
index 20687cf..b930c06 100644
--- a/doc/src/snippets/declarative/listview/dummydata/ContactModel.qml
+++ b/doc/src/snippets/declarative/listview/ContactModel.qml
@@ -1,7 +1,7 @@
+//![0]
import Qt 4.7
ListModel {
- id: contactModel
ListElement {
name: "Bill Smith"
number: "555 3264"
@@ -15,3 +15,4 @@ ListModel {
number: "555 0473"
}
}
+//![0]
diff --git a/doc/src/snippets/declarative/listview/highlight.qml b/doc/src/snippets/declarative/listview/highlight.qml
deleted file mode 100644
index 1282f8d..0000000
--- a/doc/src/snippets/declarative/listview/highlight.qml
+++ /dev/null
@@ -1,63 +0,0 @@
-import Qt 4.7
-
-Rectangle {
- width: 180; height: 200; color: "white"
-
- // ContactModel model is defined in dummydata/ContactModel.qml
- // The launcher automatically loads files in dummydata/* to assist
- // development without a real data source.
-
- // Define a delegate component. A component will be
- // instantiated for each visible item in the list.
-//! [0]
- Component {
- id: delegate
- Item {
- id: wrapper
- width: 180; height: 40
- Column {
- x: 5; y: 5
- Text { text: '<b>Name:</b> ' + name }
- Text { text: '<b>Number:</b> ' + number }
- }
- // Use the ListView.isCurrentItem attached property to
- // indent the item if it is the current item.
- states: [
- State {
- name: "Current"
- when: wrapper.ListView.isCurrentItem
- PropertyChanges { target: wrapper; x: 10 }
- }
- ]
- transitions: [
- Transition { NumberAnimation { properties: "x"; duration: 200 } }
- ]
- }
- }
-//! [0]
- // Specify a highlight with custom movement. Note that autoHighlight
- // is set to false in the ListView so that we can control how the
- // highlight moves to the current item.
-//! [1]
- Component {
- id: highlight
- Rectangle {
- width: 180; height: 40
- color: "lightsteelblue"; radius: 5
- SpringFollow on y {
- to: list.currentItem.y
- spring: 3
- damping: 0.2
- }
- }
- }
- ListView {
- id: list
- width: parent.height; height: parent.height
- model: ContactModel; delegate: delegate
- highlight: highlight
- highlightFollowsCurrentItem: false
- focus: true
- }
-//! [1]
-}
diff --git a/doc/src/snippets/declarative/listview/listview.qml b/doc/src/snippets/declarative/listview/listview.qml
index 44f0540..1e9ccd9 100644
--- a/doc/src/snippets/declarative/listview/listview.qml
+++ b/doc/src/snippets/declarative/listview/listview.qml
@@ -1,49 +1,101 @@
+//![import]
import Qt 4.7
+//![import]
-//! [3]
-Rectangle {
- width: 180; height: 200; color: "white"
+Item {
+
+//![classdocs simple]
+ListView {
+ width: 180; height: 200
+
+ model: ContactModel {}
+ delegate: Text {
+ text: name + ": " + number
+ }
+}
+//![classdocs simple]
- // ContactModel model is defined in dummydata/ContactModel.qml
- // The launcher automatically loads files in dummydata/* to assist
- // development without a real data source.
+//![classdocs advanced]
+Rectangle {
+ width: 180; height: 200
- // Define a delegate component. A component will be
- // instantiated for each visible item in the list.
-//! [0]
Component {
- id: delegate
+ id: contactDelegate
Item {
- id: wrapper
width: 180; height: 40
Column {
- x: 5; y: 5
Text { text: '<b>Name:</b> ' + name }
Text { text: '<b>Number:</b> ' + number }
}
}
}
-//! [0]
- // Define a highlight component. Just one of these will be instantiated
- // by each ListView and placed behind the current item.
-//! [1]
- Component {
- id: highlight
- Rectangle {
- color: "lightsteelblue"
- radius: 5
- }
- }
-//! [1]
- // The actual list
-//! [2]
+
ListView {
- width: parent.width; height: parent.height
- model: ContactModel
- delegate: delegate
- highlight: highlight
+ anchors.fill: parent
+ model: ContactModel {}
+ delegate: contactDelegate
+ highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
focus: true
}
-//! [2]
}
-//! [3]
+//![classdocs advanced]
+
+//![delayRemove]
+Component {
+ id: delegate
+ Item {
+ ListView.onRemove: SequentialAnimation {
+ PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true }
+ NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad }
+ PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
+ }
+ }
+}
+//![delayRemove]
+
+//![highlightFollowsCurrentItem]
+Component {
+ id: highlight
+ Rectangle {
+ width: 180; height: 40
+ color: "lightsteelblue"; radius: 5
+ SpringFollow on y {
+ to: list.currentItem.y
+ spring: 3
+ damping: 0.2
+ }
+ }
+}
+
+ListView {
+ id: list
+ width: 180; height: 200
+ model: ContactModel {}
+ delegate: Text { text: name }
+
+ highlight: highlight
+ highlightFollowsCurrentItem: false
+ focus: true
+}
+//![highlightFollowsCurrentItem]
+
+//![isCurrentItem]
+ListView {
+ width: 180; height: 200
+
+ Component {
+ id: contactsDelegate
+ Text {
+ id: contactInfo
+ text: name + ": " + number
+ color: contactInfo.ListView.isCurrentItem ? "red" : "black"
+ }
+ }
+
+ model: ContactModel {}
+ delegate: contactsDelegate
+ focus: true
+}
+//![isCurrentItem]
+
+}