summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-05-01 03:33:21 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-05-01 03:33:21 (GMT)
commit3dea1411dbb4fe3a570c2f5516dc6b5991c6db81 (patch)
treeb32418fcd269a65c64881bfae11cb8cfd2fc67d9 /src
parent1276c6ff207ee2d5228a6282f2a632ba0c206f25 (diff)
parentf5b007243af66abc320ee9022170c84e1a3f6da6 (diff)
downloadQt-3dea1411dbb4fe3a570c2f5516dc6b5991c6db81.zip
Qt-3dea1411dbb4fe3a570c2f5516dc6b5991c6db81.tar.gz
Qt-3dea1411dbb4fe3a570c2f5516dc6b5991c6db81.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src')
-rw-r--r--src/declarative/fx/qfxanimatedimageitem.cpp12
-rw-r--r--src/declarative/fx/qfxcomponentinstance.cpp13
-rw-r--r--src/declarative/fx/qfxflickable.cpp29
-rw-r--r--src/declarative/fx/qfxkeyactions.cpp10
-rw-r--r--src/declarative/fx/qfxmouseregion.cpp32
-rw-r--r--src/declarative/fx/qfxrect.cpp36
-rw-r--r--src/declarative/fx/qfxrepeater.cpp31
7 files changed, 77 insertions, 86 deletions
diff --git a/src/declarative/fx/qfxanimatedimageitem.cpp b/src/declarative/fx/qfxanimatedimageitem.cpp
index 8f930d5..5a495e9 100644
--- a/src/declarative/fx/qfxanimatedimageitem.cpp
+++ b/src/declarative/fx/qfxanimatedimageitem.cpp
@@ -67,11 +67,13 @@ QT_BEGIN_NAMESPACE
\o \image animatedimageitem.gif
\o
\code
-<Item width="{anim.width}" height="{anim.height+8}">
- <AnimatedImage id="anim" file="pics/games-anim.gif"/>
- <Rect color="red" width="4" height="8" y="{anim.height}"
- x="{(anim.width-width)*anim.currentFrame/(anim.frameCount-1)}"/>
-</Item>
+Item {
+ width: anim.width; height: anim.height+8
+ AnimatedImage { id: anim; source: "pics/games-anim.gif" }
+ Rect { color: "red"; width: 4; height: 8; y: anim.height
+ x: (anim.width-width)*anim.currentFrame/(anim.frameCount-1)
+ }
+}
\endcode
\endtable
*/
diff --git a/src/declarative/fx/qfxcomponentinstance.cpp b/src/declarative/fx/qfxcomponentinstance.cpp
index 5343f7d..5fb5466 100644
--- a/src/declarative/fx/qfxcomponentinstance.cpp
+++ b/src/declarative/fx/qfxcomponentinstance.cpp
@@ -61,13 +61,14 @@ QML_DEFINE_TYPE(QFxComponentInstance,ComponentInstance);
\brief The ComponentInstance element allows you to instantiate a \l{qml-component.html} {Component}.
\code
- <Item>
- <Component id="RedSquare">
- <Rect color="red" width="10" height="10"/>
- </Component>
+ Item {
+ Component {
+ id: RedSquare
+ Rect { color: "red"; width: 10; height: 10 }
+ }
- <ComponentInstance component="{RedSquare}"/>
- </Item>
+ ComponentInstance { component: RedSquare }
+ }
\endcode
*/
QFxComponentInstance::QFxComponentInstance(QFxItem *parent)
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" file="bigimage.png"/>
- </Flickable>
+ 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" file="bigimage.png"/>
-</Flickable>
+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}"/>
+ 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" file="bigimage.png"/>
- </Flickable>
+ Flickable {
+ width: 320; height: 480; viewportWidth: image.width; viewportHeight: image.height
+ Image { id: image; source: "bigimage.png" }
+ }
\endcode
*/
diff --git a/src/declarative/fx/qfxkeyactions.cpp b/src/declarative/fx/qfxkeyactions.cpp
index d2739ea..52a013a 100644
--- a/src/declarative/fx/qfxkeyactions.cpp
+++ b/src/declarative/fx/qfxkeyactions.cpp
@@ -245,7 +245,7 @@ void QFxKeyActions::setEnabled(bool e)
The following example sets actions for the 'c' and 'x' keys.
\code
- <KeyActions keyC="print('c is for cookie')" keyX="print('I like cookies')" />
+ KeyActions { keyC: "print('c is for cookie')"; keyX: "print('I like cookies')" }
\endcode
*/
QString QFxKeyActions::key_A() const
@@ -519,7 +519,7 @@ void QFxKeyActions::setKey_Z(const QString &s)
The following example sets actions for the left and right arrow keys.
\code
- <KeyActions leftArrow="print('You pressed left')" rightArrow="print('You pressed right')" />
+ KeyActions { leftArrow: "print('You pressed left')"; rightArrow: "print('You pressed right')" }
\endcode
*/
@@ -570,7 +570,7 @@ void QFxKeyActions::setKey_Down(const QString &s)
The following example sets actions for the '5' and '6' keys.
\code
- <KeyActions digit5="print('5 is a prime number')" digit6="print('6 is a composite number')" />
+ KeyActions { digit5: "print('5 is a prime number')"; digit6: "print('6 is a composite number')"; focus: true }
\endcode
*/
@@ -745,7 +745,7 @@ void QFxKeyActions::setKey_Space(const QString &s)
The following example sets an action for the space key.
\code
- <KeyActions space="print('Space pressed')" />
+ KeyActions { space: "print('Space pressed')" }
\endcode
*/
@@ -766,7 +766,7 @@ void QFxKeyActions::setKey_Space(const QString &s)
The following example sets an action for the hangup key.
\code
- <KeyActions hangup="print('Go away now')" />
+ KeyActions { hangup: "print('Go away now')" }
\endcode
*/
diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp
index d197c9a..3b318e3 100644
--- a/src/declarative/fx/qfxmouseregion.cpp
+++ b/src/declarative/fx/qfxmouseregion.cpp
@@ -148,12 +148,11 @@ void QFxDrag::setYmax(int m)
\brief The MouseRegion element enables simple mouse handling.
\inherits Item
- A MouseRegion is typically used in conjunction with a visible element, where the MouseRegion effectively 'proxies' mouse handling for that element. For example, we can put a MouseRegion in a Rect that changes the Rect color to red when clicked:
- \code
- <Rect width="100" height="100">
- <MouseRegion anchors.fill="{parent}" onClick="parent.color = 'red';"/>
- </Rect>
- \endcode
+ A MouseRegion is typically used in conjunction with a visible element,
+ where the MouseRegion effectively 'proxies' mouse handling for that
+ element. For example, we can put a MouseRegion in a Rect that changes
+ the Rect color to red when clicked:
+ \snippet doc/src/snippets/declarative/mouseregion.qml 0
Many MouseRegion signals pass a \l {MouseEvent}{mouse} parameter that contains
additional information about the mouse event, such as the position, button,
@@ -161,11 +160,7 @@ void QFxDrag::setYmax(int m)
Below we have the previous
example extended so as to give a different color when you right click.
- \code
- <Rect width="100" height="100">
- <MouseRegion anchors.fill="{parent}" onClick="if (mouse.button==Qt.RightButton) { parent.color='blue';} else { parent.color = 'red';}"/>
- </Rect>
- \endcode
+ \snippet doc/src/snippets/declarative/mouseregion.qml 1
For basic key handling, see \l KeyActions.
@@ -578,19 +573,8 @@ QFxDrag *QFxMouseRegion::drag()
\i the min and max properties limit how far the target can be dragged along the corresponding axes.
\endlist
- The following example uses drag to blur an image as it moves to the right:
- \code
- <Item id="blurtest" width="600" height="200">
- <Image id="pic" file="pic.png" anchors.verticalCenter="{parent.verticalCenter}" >
- <filter><Blur radius="{pic.x/10}"/></filter>
- <MouseRegion anchors.fill="{parent}"
- drag.target="{pic}"
- drag.axis="x"
- drag.xmin="0"
- drag.xmax="{blurtest.width-pic.width}" />
- </Image>
- </Item>
- \endcode
+ The following example uses drag to reduce the opacity of an image as it moves to the right:
+ \snippet doc/src/snippets/declarative/drag.qml 0
*/
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index 2bfc149..8aaddba 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -54,7 +54,7 @@ QML_DEFINE_TYPE(QFxPen,Pen);
Example:
\code
- <Rect pen.width="2" pen.color="red".../>
+ Rect { pen.width: 2; pen.color: "red" ... }
\endcode
*/
@@ -73,11 +73,11 @@ QML_DEFINE_TYPE(QFxPen,Pen);
or as an \l {http://www.w3.org/TR/SVG/types.html#ColorKeywords}{SVG color keyword name}
(as defined by the World Wide Web Consortium). For example:
\code
- <!-- rect with green border using hexidecimal notation -->
- <Rect pen.color="#00FF00" .../>
+ // rect with green border using hexidecimal notation
+ Rect { pen.color: "#00FF00" }
- <!-- rect with steelblue border using SVG color name-->
- <Rect pen.color="steelblue" .../>
+ // rect with steelblue border using SVG color name
+ Rect { pen.color: "steelblue" }
\endcode
For the full set of ways to specify color, see Qt's QColor::setNamedColor documentation.
@@ -102,7 +102,7 @@ QML_DEFINE_TYPE(QFxRect,Rect);
A Rect is painted having a solid fill (color) and an optional border (pen). You can also create rounded rectangles using the radius property.
\code
- <Rect width="100" height="100" color="red" pen.color="black" pen.width="5" radius="10"/>
+ Rect { width: 100; height: 100; color: "red"; pen.color: "black"; pen.width: 5; radius: 10 }
\endcode
\image declarative-rect.png
@@ -116,7 +116,7 @@ QML_DEFINE_TYPE(QFxRect,Rect);
A Rect is painted having a solid fill (color) and an optional border (pen). You can also create rounded rectangles using the radius property.
\code
- <Rect width="100" height="100" color="red" pen.color="black" pen.width="5" radius="10"/>
+ Rect { width: 100; height: 100; color: "red"; pen.color: "black"; pen.width: 5; radius: 10 }
\endcode
\image declarative-rect.png
@@ -217,11 +217,11 @@ void QFxRect::dump(int depth)
This property holds the color used to fill the rect.
\code
- <!-- green rect using hexidecimal notation -->
- <Rect color="#00FF00" .../>
+ // green rect using hexidecimal notation
+ Rect { color: "#00FF00" }
- <!-- steelblue rect using SVG color name-->
- <Rect color="steelblue" .../>
+ // steelblue rect using SVG color name
+ Rect { color: "steelblue" }
\endcode
*/
@@ -260,8 +260,8 @@ void QFxRect::setColor(const QColor &c)
This color will be drawn over the rect's color when the rect is painted. The tint color should usually be mostly transparent, or you will not be able to see the underlying color. The below example provides a slight red tint by having the tint color be pure red which is only 1/16th opaque.
\code
- <Rect x="0" width="80" height="80" color="lightsteelblue"/>
- <Rect x="100" width="80" height="80" color="lightsteelblue" tintColor="#10FF0000"/>
+ Rect { x: 0; width: 80; height: 80; color: "lightsteelblue" }
+ Rect { x: 100; width: 80; height: 80; color: "lightsteelblue"; tintColor: "#10FF0000" }
\endcode
\image declarative-rect_tint.png
@@ -321,11 +321,11 @@ QColor QFxRectPrivate::getColor()
This property allows for the easy construction of simple horizontal gradients. Other gradients may by formed by adding rotation to the rect. The gradient will blend linearly from the rect's main color to the color specified for gradient color.
\code
- <Rect y="0" width="80" height="80" color="lightsteelblue"/>
- <Rect y="100" width="80" height="80" color="lightsteelblue" gradientColor="blue"/>
- <Rect rotation="90" x="80" y="200" width="80" height="80" color="lightsteelblue"
- gradientColor="blue"/>
- <!-- The x offset is needed because the rotation is from the top left corner -->
+ Rect { y: 0; width: 80; height: 80; color: "lightsteelblue" }
+ Rect { y: 100; width: 80; height: 80; color: "lightsteelblue"; gradientColor="blue" }
+ Rect { rotation: 90; x: 80; y: 200; width: 80; height: 80; color="lightsteelblue"
+ gradientColor: "blue" }
+ // The x offset is needed because the rotation is from the top left corner
\endcode
\image declarative-rect_gradient.png
*/
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
- <Item>
- <Rect width="100" height="100" color="red" />
- <Repeater ...repeater arguments... />
- <!-- Instantiated items would appear here -->
- <Rect width="100" height="100" color="blue" />
- </Item>
- \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
- <Item>
- <Rect width="100" height="100" color="red" />
- <Repeater ...repeater arguments... />
- <!-- Instantiated items would appear here -->
- <Rect width="100" height="100" color="blue" />
- </Item>
- \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.
*/
/*!