summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-08-09 07:20:51 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-08-09 07:20:51 (GMT)
commit899c6dfcbc0d5ffd8da5676b3496ae31d2515235 (patch)
tree09221824187365e061be72270c8e32294b7a9e85
parent1d09376c4eec88ba94f00a4b045fc425c5f51346 (diff)
parent0d060e71a5a03f21df5b2edbb4f6de1e928b9ada (diff)
downloadQt-899c6dfcbc0d5ffd8da5676b3496ae31d2515235.zip
Qt-899c6dfcbc0d5ffd8da5676b3496ae31d2515235.tar.gz
Qt-899c6dfcbc0d5ffd8da5676b3496ae31d2515235.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: XmlListModel doc fixes Mention QML_IMPORT_TRACE in Modules docs Merge sections about when property and default state Explain Flipable example further PathView required some diagonal movement before a drag was initiated.
-rw-r--r--doc/src/declarative/modules.qdoc8
-rw-r--r--doc/src/declarative/qdeclarativestates.qdoc95
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflipable.cpp14
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp2
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp8
5 files changed, 85 insertions, 42 deletions
diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc
index 9e51a40..467b7d0 100644
--- a/doc/src/declarative/modules.qdoc
+++ b/doc/src/declarative/modules.qdoc
@@ -302,5 +302,13 @@ For examples of \c qmldir files for plugins, see the
\l {declarative/cppextensions/plugins}{Plugins} example and
\l {Tutorial: Writing QML extensions with C++}.
+
+\section1 Debugging
+
+The \c QML_IMPORT_TRACE environment variable can be useful for debugging
+when there are problems with finding and loading modules. See
+\l{Debugging module imports} for more information.
+
+
*/
/
diff --git a/doc/src/declarative/qdeclarativestates.qdoc b/doc/src/declarative/qdeclarativestates.qdoc
index 0b91756..274040a 100644
--- a/doc/src/declarative/qdeclarativestates.qdoc
+++ b/doc/src/declarative/qdeclarativestates.qdoc
@@ -84,18 +84,34 @@ Rectangle.
\snippet doc/src/snippets/declarative/states.qml 0
-A \l State item defines all the changes to be made in the new state. You
+The \l State item defines all the changes to be made in the new state. It
could specify additional properties to be changed, or create additional
-PropertyChanges for other objects. (Note that a \l State can modify the
-properties of other objects, not just the object that owns the state.)
+PropertyChanges for other objects. It can also modify the properties of other
+objects, not just the object that owns the state. For example:
-For example:
+\qml
+Rectangle {
+ ...
+ states: [
+ State {
+ name: "moved"
+ PropertyChanges { target: myRect; x: 50; y: 50; color: "blue" }
+ PropertyChanges { target: someOtherItem; width: 1000 }
+ }
+ ]
+}
+\endqml
+
+As a convenience, if an item only has one state, its \l {Item::}{states}
+property can be defined as a single \l State, without the square-brace list
+syntax:
\qml
-State {
- name: "moved"
- PropertyChanges { target: myRect; x: 50; y: 50; color: "blue" }
- PropertyChanges { target: someOtherItem; width: 1000 }
+Item {
+ ...
+ states: State {
+ ...
+ }
}
\endqml
@@ -118,54 +134,61 @@ transitions between them.
Of course, the \l Rectangle in the example above could have simply been moved
by setting its position to (50, 50) in the mouse area's \c onClicked handler.
-However, aside from enabling batched property changes, the use of states allows
-an item to revert to its \e {default state}, which contains all of the items'
-initial property values before they were modified in a state change.
+However, aside from enabling batched property changes, one of the features of
+QML states is the ability of an item to revert to its \e {default state}.
+The default state contains all of an item's initial property values before
+they were modified in a state change.
-The default state is specified by an empty string. If the MouseArea in the
-above example was changed to this:
+For example, suppose the \l Rectangle should move to (50,50) when the mouse is
+pressed, and then move back to its original position when the mouse is
+released. This can be achieved by using the \l {State::}{when} property,
+like this:
-\qml
-MouseArea {
- anchors.fill: parent
- onClicked: myRect.state == 'moved' ? myRect.state = "" : myRect.state = 'moved';
-}
-\endqml
-
-This would toggle the \l Rectangle's state between the \e moved and \e default
-states when clicked. The properties can be reverted to their initial
-values without requiring the definition of another \l State that defines these
-value changes.
+\qml
+Rectangle {
+ ...
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ }
+ states: State {
+ name: "moved"; when: mouseArea.pressed
+ ...
+ }
+}
+\endqml
-\section1 The "when" property
+The \l {State::}{when} property is set to an expression that evaluates to
+\c true when the item should be set to that state. When the mouse is pressed,
+the state is changed to \e moved. When it is released, the item reverts to its
+\e default state, which defines all of the item's original property values.
-The \l {State::}{when} property is useful for specifying when a state should be
-applied. This can be set to an expression that evaluates to \c true when an
-item should change to a particular state.
+Alternatively, an item can be explicitly set to its default state by setting its
+\l {Item::}{state} property to an empty string (""). For example, instead of
+using the \l {State::}{when} property, the above code could be changed to:
-If the above example was changed to this:
-
\qml
Rectangle {
...
MouseArea {
- id: mouseArea
anchors.fill: parent
+ onPressed: myRect.state = 'moved';
+ onReleased: myRect.state = '';
}
states: State {
- name: "moved"; when: mouseArea.pressed
+ name: "moved"
...
}
+}
\endqml
-The \l Rectangle would automatically change to the \e moved state when the
-mouse is pressed, and revert to the default state when it is released. This is
-simpler (and a better, more declarative method) than creating \c onPressed
-and \c onReleased handlers in the MouseArea to set the current state.
+Obviously it makes sense to use the \l {State::}{when} property when possible
+as it provides a simpler (and a better, more declarative) solution than
+assigning the state from signal handlers.
\section1 Animating state changes
diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
index 8c9d2dd..b266273 100644
--- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
@@ -83,10 +83,16 @@ public:
\image flipable.gif
- The \l Rotation element is used to specify the angle and axis of the flip,
- and the \l State defines the changes in angle which produce the flipping
- effect. Finally, the \l Transition creates the animation that changes the
- angle over one second.
+ The \l Rotation element is used to specify the angle and axis of the flip.
+ When \c flipped is \c true, the item changes to the "back" state, where
+ the angle is changed to 180 degrees to produce the flipping effect.
+ Finally, the \l Transition creates the animation that changes the
+ angle over one second: when the item changes between its "back" and
+ default states, the NumberAnimation animates the angle between
+ its old and new values.
+
+ See the \l {QML States} and \l {QML Animation} documentation for more
+ details on state changes and how animations work within transitions.
\sa {declarative/ui-components/flipable}{Flipable example}
*/
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index 06ac275..5771f84 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -1061,7 +1061,7 @@ void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (!d->stealMouse) {
QPointF delta = event->pos() - d->startPoint;
- if (qAbs(delta.x()) > QApplication::startDragDistance() && qAbs(delta.y()) > QApplication::startDragDistance())
+ if (qAbs(delta.x()) > QApplication::startDragDistance() || qAbs(delta.y()) > QApplication::startDragDistance())
d->stealMouse = true;
}
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index 7c1e1fd..8bd829e 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -560,7 +560,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
ListView {
width: 180; height: 300
model: xmlModel
- delegate: Text { text: title + " (" + pubDate + ")" }
+ delegate: Text { text: title + ": " + pubDate }
}
\endqml
@@ -855,6 +855,12 @@ qreal QDeclarativeXmlListModel::progress() const
return d->progress;
}
+/*!
+ \qmlmethod void XmlListModel::errorString()
+
+ Returns a string description of the last error that occurred
+ if \l status is XmlListModel::Error.
+*/
QString QDeclarativeXmlListModel::errorString() const
{
Q_D(const QDeclarativeXmlListModel);