From 94dff487709583068bdc002a955cf5b423cae614 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 1 May 2009 11:07:52 +1000 Subject: More format conversion. --- doc/src/declarative/pics/repeater.png | Bin 0 -> 800 bytes doc/src/snippets/declarative/repeater.qml | 12 ++++++++++++ src/declarative/fx/qfxflickable.cpp | 29 ++++++++++++++++------------ src/declarative/fx/qfxrepeater.cpp | 31 +++++++++++++++--------------- 4 files changed, 44 insertions(+), 28 deletions(-) create mode 100644 doc/src/declarative/pics/repeater.png create mode 100644 doc/src/snippets/declarative/repeater.qml diff --git a/doc/src/declarative/pics/repeater.png b/doc/src/declarative/pics/repeater.png new file mode 100644 index 0000000..973df27 Binary files /dev/null and b/doc/src/declarative/pics/repeater.png differ diff --git a/doc/src/snippets/declarative/repeater.qml b/doc/src/snippets/declarative/repeater.qml new file mode 100644 index 0000000..c8f9f18 --- /dev/null +++ b/doc/src/snippets/declarative/repeater.qml @@ -0,0 +1,12 @@ +//! [0] +Rect { width: 220; height: 20; color: "white" + Component { id: Dot + Rect { width: 20; height: 20; radius: 10; color: "green" } + } + HorizontalLayout { + Rect { width: 10; height: 20; color: "red" } + Repeater { component: Dot; dataSource: 10 } + Rect { width: 10; height: 20; color: "blue" } + } +} +//! [0] diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index 671d65d..17e44e1 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -232,9 +232,10 @@ QML_DEFINE_TYPE(QFxFlickable,Flickable); Flickable places its children on a surface that can be dragged and flicked. \code - - - + Flickable { + width: 200; height: 200; viewportWidth: image.width; viewportHeight: image.height + Image { id: image; source: "bigimage.png" } + } \endcode \image flickable.gif @@ -257,9 +258,10 @@ QML_DEFINE_TYPE(QFxFlickable,Flickable); QFxFlickable allows its children to be dragged and flicked. \code - - - +Flickable { + width: 320; height: 480; viewportWidth: image.width; viewportHeight: image.height + Image { id: image; source: "bigimage.png" } +} \endcode Note that QFxFlickable does not automatically clip its contents. If @@ -475,9 +477,11 @@ bool QFxFlickable::isAtYBeginning() const These properties are typically used to draw a scrollbar, for example: \code - + Rect { + opacity: 0.5; anchors.right: MyListView.right-2; width: 6 + y: MyListView.pageYPosition * MyListView.height + height: MyListView.pageHeight * MyListView.height + } \endcode */ qreal QFxFlickable::pageWidth() const @@ -879,9 +883,10 @@ void QFxFlickable::setOverShoot(bool o) should be set to the combined size of the items placed in the Flickable. \code - - - + Flickable { + width: 320; height: 480; viewportWidth: image.width; viewportHeight: image.height + Image { id: image; source: "bigimage.png" } + } \endcode */ diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp index 7ee949d..f9fc878 100644 --- a/src/declarative/fx/qfxrepeater.cpp +++ b/src/declarative/fx/qfxrepeater.cpp @@ -99,14 +99,9 @@ QML_DEFINE_TYPE(QFxRepeater,Repeater); the instantiated items would visually appear stacked between the red and blue rectangles. - \code - - - - - - - \endcode + \snippet doc/src/snippets/declarative/repeater.qml 0 + + \image repeater.png The repeater instance continues to own all items it instantiates, even if they are otherwise manipulated. It is illegal to manually remove an item @@ -144,14 +139,7 @@ QML_DEFINE_TYPE(QFxRepeater,Repeater); the instantiated items would visually appear stacked between the red and blue rectangles. - \code - - - - - - - \endcode + \snippet doc/src/snippets/declarative/repeater.qml 0 The QFxRepeater instance continues to own all items it instantiates, even if they are otherwise manipulated. It is illegal to manually delete an item @@ -191,6 +179,17 @@ QFxRepeater::~QFxRepeater() \qmlproperty any Repeater::dataSource The Repeater's data source. + + The data source may be either an object list, a string list or a Qt model. + In each case, the data element and the index is exposed to each instantiated + component. The index is always exposed as an accessible \c index property. + In the case of an object or string list, the data element (of type string + or object) is available as the \c modelData property. In the case of a Qt model, + all roles are available as named properties just like in the view classes. + + As a special case the data source can also be merely a number. In this case it will + create that many instances of the component. They will also be assigned an index + based on the order they are created. */ /*! -- cgit v0.12