From dac26313fcfc3862a7f2aeaa58bb2afe0d494ec9 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 1 May 2009 16:39:43 +1000 Subject: doc --- src/declarative/qml/qmlcomponent.cpp | 24 ++-- src/declarative/qml/qmldom.cpp | 214 +++++++++++++++++++-------------- src/declarative/util/qmlconnection.cpp | 56 +++++---- 3 files changed, 174 insertions(+), 120 deletions(-) diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index 2c3ebd6..c316f03 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -89,16 +89,20 @@ bool QmlComponentPrivate::isXml(const QByteArray &ba) file, or for defining a component that logically belongs with the file containing it. - \code - - - - - - - - - \endcode + \qml +Item { + Component { + id: RedSquare + Rect { + color: "red" + width: 10 + height: 10 + } + } + ComponentInstance { component: RedSquare } + ComponentInstance { component: RedSquare; x: 20 } +} + \endqml */ QML_DEFINE_TYPE(QmlComponent,Component); diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index 937c244..cf0a2fb 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -220,11 +220,13 @@ QByteArray QmlDomDocument::save() const document has no root. In the sample QML below, the root object will be the QFxItem type. - \code - - - - \endcode + \qml +Item { + Text { + text: "Hello World" + } +} + \endqml */ QmlDomObject QmlDomDocument::rootObject() const { @@ -296,9 +298,13 @@ QmlDomProperty &QmlDomProperty::operator=(const QmlDomProperty &other) /*! Return the name of this property. - \code - - \endcode + \qml +Text { + x: 10 + y: 10 + font.bold: true +} + \endqml As illustrated above, a property name can be a simple string, such as "x" or "y", or a more complex "dot property", such as "font.bold". In both cases @@ -318,9 +324,13 @@ QByteArray QmlDomProperty::propertyName() const Return the name of this property, split into multiple parts in the case of dot properties. - \code - - \endcode + \qml +Text { + x: 10 + y: 10 + font.bold: true +} + \endqml For each of the properties shown above, this method would return ("x"), ("y") and ("font", "bold"). @@ -337,10 +347,10 @@ QList QmlDomProperty::propertyNameParts() const Return true if this property is used as a default property in the QML document. - \code - - hello - \endcode + \qml + +hello + \endqml The above two examples return the same DOM tree, except that the second has the default property flag set on the text property. Observe that whether @@ -456,9 +466,12 @@ QmlDomObjectPrivate::properties(QmlParser::Property *property) const Each QmlDomProperty represents a QML property assignment on the instantiated object. For example, - \code - - \endcode + \qml +QGraphicsWidget { + opacity: 0.5 + size: "100x100" +} + \endqml describes a single QmlDomObject - "QGraphicsWidget" - with two properties, "opacity" and "size". Obviously QGraphicsWidget has many more properties than just @@ -525,9 +538,9 @@ bool QmlDomObject::isValid() const Returns the type name of this object. For example, the type of this object would be "QGraphicsWidget". - \code - - \endcode + \qml +QGraphicsWidget { } + \endqml */ QByteArray QmlDomObject::objectType() const { @@ -540,9 +553,9 @@ QByteArray QmlDomObject::objectType() const has been assigned. For example, the object id of this object would be "MyText". - \code - - \endcode + \qml +Text { id: MyText } + \endqml */ QByteArray QmlDomObject::objectId() const { @@ -565,9 +578,12 @@ void QmlDomObject::setObjectId(const QByteArray &id) Returns the list of assigned properties on this object. In the following example, "text" and "x" properties would be returned. - \code - - \endcode + \qml +Text { + text: "Hello world!" + x: 100 +} + \endqml */ QList QmlDomObject::properties() const { @@ -605,9 +621,9 @@ QList QmlDomObject::properties() const In the example below, \c {object.property("src")} would return a valid QmlDomProperty, and \c {object.property("tile")} an invalid QmlDomProperty. - \code - - \endcode + \qml +Image { src: "sample.jpg" } + \endqml */ QmlDomProperty QmlDomObject::property(const QByteArray &name) const { @@ -730,9 +746,13 @@ QmlDomBasicValuePrivate::~QmlDomBasicValuePrivate() example below, the "x", "y" and "color" properties are being assigned literal values. - \code - - \endcode + \qml +Rect { + x: 10 + y: 10 + color: "red" +} + \endqml */ /*! @@ -771,9 +791,9 @@ QmlDomValueLiteral &QmlDomValueLiteral::operator=(const QmlDomValueLiteral &othe Return the literal value. In the example below, the literal value will be the string "10". - \code - - \endcode + \qml +Rect { x: 10 } + \endqml */ QString QmlDomValueLiteral::literal() const { @@ -797,9 +817,9 @@ void QmlDomValueLiteral::setLiteral(const QString &value) A property binding is an ECMAScript expression assigned to a property. In the example below, the "x" property is being assigned a property binding. - \code - - \endcode + \qml +Rect { x: Other.x } + \endqml */ /*! @@ -837,9 +857,9 @@ QmlDomValueBinding &QmlDomValueBinding::operator=(const QmlDomValueBinding &othe Return the binding expression. In the example below, the string "Other.x" will be returned. - \code - - \endcode + \qml +Rect { x: Other.x } + \endqml */ QString QmlDomValueBinding::binding() const { @@ -867,13 +887,16 @@ void QmlDomValueBinding::setBinding(const QString &expression) class. In the example below, the "x" property is being assigned the NumericAnimation value source. - \code - - - - - - \endcode + \qml +Rect { + x: NumericAnimation { + from: 0 + to: 100 + repeat: true + running: true + } +} + \endqml */ /*! @@ -912,13 +935,16 @@ QmlDomValueValueSource &QmlDomValueValueSource::operator=(const QmlDomValueValue In the example below, an object representing the NumericAnimation will be returned. - \code - - - - - - \endcode + \qml +Rect { + x: NumericAnimation { + from: 0 + to: 100 + repeat: true + running: true + } +} + \endqml */ QmlDomObject QmlDomValueValueSource::object() const { @@ -972,9 +998,12 @@ QmlDomValuePrivate::~QmlDomValuePrivate() For example, in the following example, - \code - - \endcode + \qml +Text { + text: "Hello World!" + y: Other.y +} + \endqml The text property is being assigned a literal, and the y property a property binding. To output the values assigned to the text and y properties in the @@ -1213,24 +1242,27 @@ QmlDomList QmlDomValue::toList() const Lists of values can be assigned to properties. For example, the following example assigns multiple objects to Item's "children" property - \code - - - - - - - \endcode + \qml +Item { + children: [ + Text { }, + Rect { } + ] +} + \endqml Lists can also be implicitly created by assigning multiple \l {QmlDomValueValueSource}{value sources} or constants to a property. - \code - - - - - - \endcode + \qml +Item { + x: 10 + x: NumericAnimation { + running: false + from: 0 + to: 100 + } +} + \endqml */ /*! @@ -1301,13 +1333,16 @@ void QmlDomList::setValues(const QList &values) following example shows the definition of a sub-component with the id "ListDelegate". - \code - - - - - - \endcode + \qml +Item { + Component { + id: ListDelegate + Text { + text: modelData.text + } + } +} + \endqml Like QmlDomDocument's, components contain a single root object. */ @@ -1347,13 +1382,16 @@ QmlDomComponent &QmlDomComponent::operator=(const QmlDomComponent &other) Returns the component's root object. In the example below, the root object is the "Text" object. - \code - - - - - - \endcode + \qml +Item { + Component { + id: ListDelegate + Text { + text: modelData.text + } + } +} + \endqml */ QmlDomObject QmlDomComponent::componentRoot() const { diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp index 5cd4371..8f6c908 100644 --- a/src/declarative/util/qmlconnection.cpp +++ b/src/declarative/util/qmlconnection.cpp @@ -62,7 +62,7 @@ public: /*! \qmlclass Connection QmlConnection - \brief The Connection element describes generalized connections to signals. + \brief A Connection object describes generalized connections to signals. JavaScript-in-HTML style signal properties do not allow: \list @@ -73,31 +73,40 @@ public: \i signals in classes with coincidentally-named on properties \endlist - When any of these is needed, the Connection element can be used instead. + When any of these is needed, the Connection object can be used instead. Where a signal could be connected like this: - \code - - \endcode + \qml +MouseRegion { + onClicked: { foo(x+123,y+456) } +} + \endqml - An equivalent binding can be made with a Connection element: + An equivalent binding can be made with a Connection object: - \code - - - - \endcode + \qml +MouseRegion { + Connection { + signal: "clicked(x,y)" + script: { foo(x+123,y+456) } + } +} + \endqml - More generally, the Connection element can be a child of some other element than + More generally, the Connection object can be a child of some other object than the sender of the signal, and the script is the default attribute: - \code - - ... - - foo(x+123,y+456) - - \endcode + \qml +MouseRegion { + id: mr +} +... +Connection { + sender: mr + signal: "clicked(x,y)" + script: { foo(x+123,y+456) } +} + \endqml */ /*! @@ -257,9 +266,12 @@ void QmlConnection::setScript(const QString& script) The signal must have its formal parameter names given in parentheses: - \code - - \endcode + \qml +Connection { + signal: "clicked(x,y)" + script: { ... } +} + \endqml */ /*! -- cgit v0.12