diff options
Diffstat (limited to 'src/declarative/fx/qfxitem.cpp')
-rw-r--r-- | src/declarative/fx/qfxitem.cpp | 318 |
1 files changed, 287 insertions, 31 deletions
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index c2e35b9..644e812 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -228,6 +228,11 @@ void QFxContents::setItem(QFxItem *item) */ /*! + \property QFxItem::activeFocus + This property indicates whether the item has the active focus. + */ + +/*! \fn void QFxItem::activeFocusChanged() This signal is emitted when this item gains active focus. @@ -430,17 +435,25 @@ QFxItem::~QFxItem() The default transform origin is \c TopLeft. */ + /*! \qmlproperty Item Item::parent This property holds the parent of the item. */ + +/*! + \property QFxItem::parent + This property holds the parent of the item. +*/ void QFxItem::setItemParent(QFxItem *parent) { setParent(parent); } /*! - XXX Playing around with view2view transitions. + \internal + \property QFxItem::moveToParent + Playing around with view2view transitions. */ void QFxItem::moveToParent(QFxItem *parent) { @@ -532,6 +545,19 @@ QFxItem *QFxItem::itemParent() const */ /*! + \property QFxItem::children + + This property contains the list of visual children of this item. +*/ + +/*! + \property QFxItem::resources + + This property contains non-visual resources that you want to + reference by name. +*/ + +/*! Returns true if all of the attributes set via QML have been set; otherwise returns false. @@ -704,6 +730,18 @@ void QFxItemPrivate::children_clear() data is a behind-the-scenes property: you should never need to explicitly specify it. */ + +/*! + \property QFxItem::data + + The data property is allows you to freely mix the visual children + and the non-visual resources of an item. If you assign a visual + item to the data list it becomes a child and if you assign any + other object type, it is added as a resource. + + data is a behind-the-scenes property: you should never need to + explicitly specify it. + */ QmlList<QObject *> *QFxItem::data() { Q_D(QFxItem); @@ -728,6 +766,11 @@ QFxContents *QFxItem::contents() return d->_contents; } +/*! + \internal + \property QFxItem::qmlItem +*/ + QFxItem *QFxItem::qmlItem() const { Q_D(const QFxItem); @@ -742,6 +785,15 @@ QFxItem *QFxItem::qmlItem() const item. Querying for the QML only has meaning if the QML has been dynamically set; otherwise an empty string is returned. */ + +/*! + \property QFxItem::qml + This property holds the dynamic QML for the item. + + This property is used for dynamically loading QML into the + item. Querying for the QML only has meaning if the QML has been + dynamically set; otherwise an empty string is returned. +*/ QString QFxItem::qml() const { Q_D(const QFxItem); @@ -761,7 +813,7 @@ void QFxItem::setQml(const QString &qml) } d->_qml = qml; - d->_qmlurl = itemContext()->resolvedUri(qml); + d->_qmlurl = qmlContext(this)->resolvedUri(qml); d->qmlItem = 0; if(d->_qml.isEmpty()) { @@ -776,7 +828,7 @@ void QFxItem::setQml(const QString &qml) emit qmlChanged(); } else { d->_qmlcomp = - new QmlComponent(itemContext()->engine(), d->_qmlurl, this); + new QmlComponent(qmlEngine(this), d->_qmlurl, this); if(!d->_qmlcomp->isLoading()) qmlLoaded(); else @@ -797,12 +849,12 @@ void QFxItem::qmlLoaded() if(c->isLoading()) continue; - QmlContext *ctxt = new QmlContext(itemContext()); + QmlContext *ctxt = new QmlContext(qmlContext(this)); QObject* o = c ? c->create(ctxt):0; QFxItem* ret = qobject_cast<QFxItem*>(o); if (ret) { ret->setItemParent(this); - QScriptValue v = itemContext()->engine()->scriptEngine()->newQObject(ret); + QScriptValue v = qmlEngine(this)->scriptEngine()->newQObject(ret); emit newChildCreated(d->_qmlnewloading.at(i).toString(),v); } @@ -815,7 +867,7 @@ void QFxItem::qmlLoaded() // setQml... if (d->_qmlcomp) { - QmlContext *ctxt = new QmlContext(itemContext()); + QmlContext *ctxt = new QmlContext(qmlContext(this)); ctxt->addDefaultObject(this); QObject *obj = d->_qmlcomp->create(ctxt); @@ -848,6 +900,39 @@ void QFxItem::qmlLoaded() */ /*! + \property QFxItem::width + + Defines the item's width relative to its parent. + */ + +/*! + \property QFxItem::height + + Defines the item's height relative to its parent. + */ + +/*! + \property QFxItem::x + + The x coordinate of the item relative to its parent. +*/ + +/*! + \property QFxItem::y + + The y coordinate of the item relative to its parent. +*/ + +/*! + \property QFxItem::z + + The z coordinate of the item relative to its parent. + + A negative z coordinate means the item will be painted below its parent. +*/ + + +/*! \qmlproperty real Item::z Sets the stacking order of the item. By default the stacking order is 0. @@ -900,12 +985,6 @@ void QFxItem::qmlLoaded() \endqml \endtable */ -/*! - \property QFxItem::z - \brief The z coordinate of the item relative to its parent. - - A negative z coordinate means the item will be painted below its parent. -*/ void QFxItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) @@ -999,6 +1078,13 @@ void QFxItemPrivate::handleHeightChange(int yoffset) When set, the item will be displayed flipped horizontally or vertically about its center. */ + +/*! + \property QFxItem::flipVertically + + When set, the item will be displayed flipped horizontally or vertically + about its center. + */ bool QFxItem::flipVertically() const { return flip() & VerticalFlip; @@ -1012,6 +1098,12 @@ void QFxItem::setFlipVertically(bool v) setFlip((QSimpleCanvasItem::Flip)(flip() & ~VerticalFlip)); } +/*! + \property QFxItem::flipHorizontally + + When set, the item will be displayed flipped horizontally or vertically + about its center. + */ bool QFxItem::flipHorizontally() const { return flip() & HorizontalFlip; @@ -1071,8 +1163,23 @@ QRectF QFxItem::sceneBoundingRect() const \endqml The identifier is available throughout to the \l {components}{component} - where it is declared. Two items in the same component - with the same identifier is invalid. + where it is declared. The identifier must be unique in thecomponent. +*/ + +/*! + \property QFxItem::id + This property holds the identifier for the item. + + The identifier can be used in bindings and other expressions to + refer to the item. For example: + + \qml + <Text id="myText" .../> + <Text text="{myText.text}"/> + \endqml + + The identifier is available throughout the \l {components}{component} + where it is declared. The identifier must be unique in thecomponent. */ QString QFxItem::id() const { @@ -1142,6 +1249,54 @@ QFxAnchorLine QFxItem::verticalCenter() const } /*! + \property QFxItem::top + + One of the anchor lines of the item. + + For more information see \l {anchor-layout}{Anchor Layouts}. +*/ + +/*! + \property QFxItem::bottom + + One of the anchor lines of the item. + + For more information see \l {anchor-layout}{Anchor Layouts}. +*/ + +/*! + \property QFxItem::left + + One of the anchor lines of the item. + + For more information see \l {anchor-layout}{Anchor Layouts}. +*/ + +/*! + \property QFxItem::right + + One of the anchor lines of the item. + + For more information see \l {anchor-layout}{Anchor Layouts}. +*/ + +/*! + \property QFxItem::horizontalCenter + + One of the anchor lines of the item. + + For more information see \l {anchor-layout}{Anchor Layouts}. +*/ + +/*! + \property QFxItem::verticalCenter + + One of the anchor lines of the item. + + For more information see \l {anchor-layout}{Anchor Layouts}. +*/ + +/*! \qmlproperty AnchorLine Item::top \qmlproperty AnchorLine Item::bottom \qmlproperty AnchorLine Item::left @@ -1211,7 +1366,15 @@ QFxAnchorLine QFxItem::verticalCenter() const */ /*! - \internal + \property QFxItem::baselineOffset + \brief The position of the item's baseline in global (scene) coordinates. + + The baseline of a Text item is the imaginary line on which the text + sits. Controls containing text usually set their baseline to the + baseline of their text. + + For non-text items, a default baseline offset of two-thirds of the + item's height is used to determine the baseline. */ int QFxItem::baselineOffset() const { @@ -1255,6 +1418,14 @@ void QFxItem::setBaselineOffset(int offset) \endqml \endtable */ + +/*! + \property QFxItem::rotation + This property holds the rotation of the item in degrees. + + This specifies how many degrees to rotate the item around its origin (0,0). + The default rotation is 0 degrees (i.e. not rotated at all). +*/ qreal QFxItem::rotation() const { Q_D(const QFxItem); @@ -1310,6 +1481,21 @@ void QFxItem::setRotation(qreal rotation) \endqml \endtable */ + +/*! + \property QFxItem::scale + This property holds the scale of the item. + + A scale of less than 1 means the item will be displayed smaller than + normal, and a scale of greater than 1 means the item will be + displayed larger than normal. A negative scale means the item will + be mirrored. + + By default, items are displayed at a scale of 1 (i.e. at their + normal size). + + Scaling is from the item's origin (0,0). +*/ qreal QFxItem::scale() const { return QSimpleCanvasItem::scale(); @@ -1358,6 +1544,16 @@ void QFxItem::setScale(qreal s) \endtable */ +/*! + \property QFxItem::opacity + + The opacity of the item. Opacity is specified as a number between 0 + (fully transparent) and 1 (fully opaque). The default is 1. + + Opacity is an \e inherited attribute. That is, the opacity is + also applied individually to child items. +*/ + qreal QFxItem::opacity() const { return QSimpleCanvasItem::visible(); @@ -1425,6 +1621,13 @@ QmlList<QObject *> *QFxItem::resources() \sa {states-transitions}{States and Transitions} */ + +/*! + \property QFxItem::states + This property holds a list of states defined by the item. + + \sa {states-transitions}{States and Transitions} +*/ QmlList<QmlState *>* QFxItem::states() { Q_D(QFxItem); @@ -1447,6 +1650,13 @@ QmlList<QmlState *>* QFxItem::states() \sa {states-transitions}{States and Transitions} */ + +/*! + \property QFxItem::transitions + This property holds a list of transitions defined by the item. + + \sa {states-transitions}{States and Transitions} +*/ QmlList<QmlTransition *>* QFxItem::transitions() { Q_D(QFxItem); @@ -1454,6 +1664,11 @@ QmlList<QmlTransition *>* QFxItem::transitions() } /*! + \internal + \property QFxItem::filter +*/ + +/*! \qmlproperty list<Filter> Item::filter This property holds a list of graphical filters to be applied to the item. @@ -1485,6 +1700,16 @@ QmlList<QmlTransition *>* QFxItem::transitions() */ /*! + \property QFxItem::clip + This property holds whether clipping is enabled. + + if clipping is enabled, an item will clip its own painting, as well + as the painting of its children, to its bounding rectangle. + + Non-rectangular clipping regions are not supported for performance reasons. +*/ + +/*! Returns the state with \a name. Returns 0 if no matching state is found. */ QmlState *QFxItem::findState(const QString &name) const @@ -1523,10 +1748,29 @@ QmlState *QFxItem::findState(const QString &name) const */ /*! - \property QFxItem::state - \brief the current state of the item. + \property QFxItem::state + + This property holds the name of the current state of the item. + + This property is often used in scripts to change between states. For + example: - \sa {states-transitions}{States and Transitions} + \qml + <Script> + function toggle() { + if (button.state == 'On') + button.state = 'Off'; + else + button.state = 'On'; + } + </Script> + \endqml + + If the item is in its base state (i.e. no explicit state has been + set), \c state will be a blank string. Likewise, you can return an + item to its base state by setting its current state to \c ''. + + \sa {states-transitions}{States and Transitions} */ QString QFxItem::state() const { @@ -1549,6 +1793,13 @@ void QFxItem::setState(const QString &state) For more information see \l Transform. */ + +/*! + \property QFxItem::transform + This property holds the list of transformations to apply. + + For more information see \l Transform. +*/ QList<QFxTransform *> *QFxItem::transform() { Q_D(QFxItem); @@ -1556,6 +1807,16 @@ QList<QFxTransform *> *QFxItem::transform() } /*! + \property QFxItem::focus + This property holds the item's focus state. +*/ + +/*! + \property QFxItem::focusable + This property holds whether the item has focus state. +*/ + +/*! Returns true if the item is visible; otherwise returns false. An item is considered visible if its opacity is not 0. @@ -1566,11 +1827,15 @@ bool QFxItem::isVisible() const return d->visible; } -/*! - Sets the visibility of the item to \a visible. +/*! + \property QFxItem::visible + + This property specifies whether the item is visible or invisible. Setting visibility to false sets opacity to 0. Setting the visibility to true restores the opacity to its previous value. + + \sa isVisible() */ void QFxItem::setVisible(bool visible) { @@ -1615,12 +1880,12 @@ void QFxItem::newChild(const QString &type) { Q_D(QFxItem); - QUrl url = itemContext()->resolvedUri(type); + QUrl url = qmlContext(this)->resolvedUri(type); if (url.isEmpty()) return; d->_qmlnewloading.append(url); - d->_qmlnewcomp.append(new QmlComponent(itemContext()->engine(), url, this)); + d->_qmlnewcomp.append(new QmlComponent(qmlEngine(this), url, this)); if(!d->_qmlnewcomp.last()->isLoading()) qmlLoaded(); @@ -1718,15 +1983,6 @@ void QFxItem::transformChanged(const QSimpleCanvas::Matrix &) { } -/*! - Returns the current QML context for this item. -*/ -QmlContext *QFxItem::itemContext() const -{ - Q_D(const QFxItem); - return d->_ctxt; -} - QmlStateGroup *QFxItemPrivate::states() { Q_Q(QFxItem); |