src/declarative/util/qdeclarativepropertychanges.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
--- a/src/declarative/util/qdeclarativepropertychanges.cpp	Fri Sep 17 08:34:18 2010 +0300
+++ b/src/declarative/util/qdeclarativepropertychanges.cpp	Mon Oct 04 01:19:32 2010 +0300
@@ -61,51 +61,34 @@
 
 /*!
     \qmlclass PropertyChanges QDeclarativePropertyChanges
+    \ingroup qml-state-elements
     \since 4.7
     \brief The PropertyChanges element describes new property bindings or values for a state.
 
-    PropertyChanges provides a state change that modifies the properties of an item.
+    PropertyChanges is used to define the property values or bindings in a 
+    \l State. This enables an item's property values to be changed when it
+    \l {QML States}{changes between states}.
 
-    Here is a property change that modifies the text and color of a \l Text element
-    when it is clicked:
+    To create a PropertyChanges object, specify the \l target item whose 
+    properties are to be modified, and define the new property values or
+    bindings. For example:
     
-    \qml
-    Text {
-        id: myText
-        width: 100; height: 100
-        text: "Hello"
-        color: "blue"
-
-        states: State {
-            name: "myState"
+    \snippet doc/src/snippets/declarative/propertychanges.qml import 
+    \codeline
+    \snippet doc/src/snippets/declarative/propertychanges.qml 0
 
-            PropertyChanges {
-                target: myText
-                text: "Goodbye"
-                color: "red"
-            }
-        }
-
-        MouseArea { anchors.fill: parent; onClicked: myText.state = 'myState' }
-    }
-    \endqml
-
-    By default, PropertyChanges will establish new bindings where appropriate.
-    For example, the following creates a new binding for myItem's \c height property.
+    When the mouse is pressed, the \l Rectangle changes to the \e resized
+    state. In this state, the PropertyChanges object sets the rectangle's 
+    color to blue and the \c height value to that of \c container.height.
 
-    \qml
-    PropertyChanges {
-        target: myItem
-        height: parent.height
-    }
-    \endqml
-
-    If you don't want a binding to be established (and instead just want to assign
-    the value of the binding at the time the state is entered),
-    you should set the PropertyChange's \l{PropertyChanges::explicit}{explicit}
+    Note this automatically binds \c rect.height to \c container.height 
+    in the \e resized state. If a property binding should not be
+    established, and the height should just be set to the value of
+    \c container.height at the time of the state change, set the \l explicit
     property to \c true.
-    
-    State-specific script for signal handlers can also be specified:
+   
+    A PropertyChanges object can also override the default signal handler
+    for an object to implement a signal handler specific to the new state:
 
     \qml
     PropertyChanges {
@@ -114,47 +97,36 @@
     }
     \endqml
 
-    You can reset a property in a state change by assigning \c undefined. In the following
-    example we reset \c theText's width when we enter state1. This will give the text its
-    natural width (which is the whole string on one line).
+    \note PropertyChanges can be used to change anchor margins, but not other anchor
+    values; use AnchorChanges for this instead. Similarly, to change an \l Item's
+    \l {Item::}{parent} value, use ParentChanges instead.
+
 
-    \qml
-    import Qt 4.7
+    \section2 Resetting property values
+
+    The \c undefined value can be used to reset the property value for a state.
+    In the following example, when \c theText changes to the \e widerText
+    state, its \c width property is reset, giving the text its natural width
+    and displaying the whole string on a single line.
 
-    Rectangle {
-        width: 640
-        height: 480
-        Text {
-            id: theText
-            width: 50
-            wrapMode: Text.WordWrap
-            text: "a text string that is longer than 50 pixels"
-        }
+    \snippet doc/src/snippets/declarative/propertychanges.qml reset
+
+
+    \section2 Immediate property changes in transitions
 
-        states: State {
-            name: "state1"
-            PropertyChanges {
-                target: theText
-                width: undefined
-            }
-        }
-    }
-    \endqml
+    When \l Transitions are used to animate state changes, they animate 
+    properties from their values in the current state to those defined in the
+    new state (as defined by PropertyChanges objects). However, 
+    it is sometimes desirable to set a property value \e immediately during a 
+    \l Transition, without animation; in these cases, the PropertyAction 
+    element can be used to force an immediate property change.
 
-    Anchor margins should be changed with PropertyChanges, but other anchor changes or changes to
-    an Item's parent should be done using the associated change elements
-    (ParentChange and AnchorChanges, respectively).
+    See the PropertyAction documentation for more details.
 
     \sa {declarative/animation/states}{states example}, {qmlstate}{States}, QtDeclarative
 */
 
 /*!
-    \internal
-    \class QDeclarativePropertyChanges
-    \brief The QDeclarativePropertyChanges class describes new property values for a state.
-*/
-
-/*!
     \qmlproperty Object PropertyChanges::target
     This property holds the object which contains the properties to be changed.
 */
@@ -396,12 +368,12 @@
 
 /*!
     \qmlproperty bool PropertyChanges::restoreEntryValues
-    
-    Whether or not the previous values should be restored when
-    leaving the state. By default, restoreEntryValues is true.
 
-    By setting restoreEntryValues to false, you can create a temporary state
-    that has permanent effects on property values.
+    This property holds whether the previous values should be restored when
+    leaving the state. 
+
+    The default value is \c true. Setting this value to \c false creates a
+    temporary state that has permanent effects on property values.
 */
 bool QDeclarativePropertyChanges::restoreEntryValues() const
 {