From 162dd1adb3e6369e85af09f34dc56b70eeb43f4c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 22 Jun 2009 10:13:48 +1000 Subject: Only objects or lists of objects can be default properties. --- src/declarative/extra/qmlsqlconnection.cpp | 1 - src/declarative/extra/qmlsqlconnection.h | 1 - src/declarative/extra/qmlsqlquery.cpp | 1 - src/declarative/extra/qmlsqlquery.h | 2 -- src/declarative/fx/qfxtext.cpp | 1 - src/declarative/fx/qfxtext.h | 1 - src/declarative/fx/qfxtextedit.cpp | 1 - src/declarative/util/qmlconnection.h | 1 - 8 files changed, 9 deletions(-) diff --git a/src/declarative/extra/qmlsqlconnection.cpp b/src/declarative/extra/qmlsqlconnection.cpp index a329f3c..5cf572b 100644 --- a/src/declarative/extra/qmlsqlconnection.cpp +++ b/src/declarative/extra/qmlsqlconnection.cpp @@ -92,7 +92,6 @@ public: /*! \qmlproperty QString SqlConnection::name - \default Defines the connection's name. The name allows the connection to be retrieved using the connection property of SqlQuery or when diff --git a/src/declarative/extra/qmlsqlconnection.h b/src/declarative/extra/qmlsqlconnection.h index 306db8d..ede8bcb 100644 --- a/src/declarative/extra/qmlsqlconnection.h +++ b/src/declarative/extra/qmlsqlconnection.h @@ -67,7 +67,6 @@ class Q_DECLARATIVE_EXPORT QmlSqlConnection : public QObject, public QmlParserSt Q_PROPERTY(QString userName READ userName WRITE setUserName) Q_PROPERTY(QString password READ password WRITE setPassword) Q_PROPERTY(QString lastError READ lastError) - Q_CLASSINFO("DefaultProperty", "name") public: QmlSqlConnection(QObject *parent = 0); ~QmlSqlConnection(); diff --git a/src/declarative/extra/qmlsqlquery.cpp b/src/declarative/extra/qmlsqlquery.cpp index 82ac50062..2b11774 100644 --- a/src/declarative/extra/qmlsqlquery.cpp +++ b/src/declarative/extra/qmlsqlquery.cpp @@ -290,7 +290,6 @@ public: /*! \qmlproperty QString SqlQuery::query - \default Defines the query text. */ diff --git a/src/declarative/extra/qmlsqlquery.h b/src/declarative/extra/qmlsqlquery.h index 7aa0709..06ade08 100644 --- a/src/declarative/extra/qmlsqlquery.h +++ b/src/declarative/extra/qmlsqlquery.h @@ -96,8 +96,6 @@ class Q_DECLARATIVE_EXPORT QmlSqlQuery : public QListModelInterface, public QmlP Q_PROPERTY(QString lastError READ lastError) Q_PROPERTY(QmlList *bindings READ bindings) - - Q_CLASSINFO("DefaultProperty", "query") public: QmlSqlQuery(QObject *parent = 0); ~QmlSqlQuery(); diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index 031c0f8..9550af9 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -183,7 +183,6 @@ void QFxText::setText(const QString &n) /*! \qmlproperty string Text::text - \default The text to display. Text supports both plain and rich text strings. diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h index 99ab2be..b929a6f 100644 --- a/src/declarative/fx/qfxtext.h +++ b/src/declarative/fx/qfxtext.h @@ -69,7 +69,6 @@ class Q_DECLARATIVE_EXPORT QFxText : public QFxItem Q_PROPERTY(bool wrap READ wrap WRITE setWrap) Q_PROPERTY(Qt::TextElideMode elide READ elideMode WRITE setElideMode) Q_PROPERTY(QString activeLink READ activeLink) - Q_CLASSINFO("DefaultProperty", "text") public: QFxText(QFxItem *parent=0); diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index 5f2f36c..03dd63f 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -138,7 +138,6 @@ QString QFxTextEdit::text() const /*! \qmlproperty string TextEdit::text - \default The text to display. If the text format is AutoText the text edit will automatically determine whether the text should be treated as diff --git a/src/declarative/util/qmlconnection.h b/src/declarative/util/qmlconnection.h index 4350123..d61659f 100644 --- a/src/declarative/util/qmlconnection.h +++ b/src/declarative/util/qmlconnection.h @@ -61,7 +61,6 @@ class Q_DECLARATIVE_EXPORT QmlConnection : public QObject, public QmlParserStatu Q_DECLARE_PRIVATE(QmlConnection) Q_INTERFACES(QmlParserStatus) - Q_CLASSINFO("DefaultProperty", "script") Q_PROPERTY(QObject *sender READ signalSender WRITE setSignalSender) Q_PROPERTY(QString script READ script WRITE setScript) Q_PROPERTY(QString signal READ signal WRITE setSignal) -- cgit v0.12 From 30b9cf0ff65bca3dbfddbd74cb21ec3eb68cbd88 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 22 Jun 2009 11:27:16 +1000 Subject: Fix anchor resetting and prevent illegal anchors. --- src/declarative/fx/qfxanchors.cpp | 124 ++++++++++++++++--------- src/declarative/fx/qfxanchors.h | 3 +- tests/auto/declarative/anchors/tst_anchors.cpp | 26 ++++++ 3 files changed, 107 insertions(+), 46 deletions(-) diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index 09d6178..3da58a2 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -533,12 +533,12 @@ void QFxAnchors::setTop(const QFxAnchorLine &edge) if (!d->checkVAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasTopAnchor; - else - d->usedAnchors &= ~HasTopAnchor; + d->usedAnchors |= HasTopAnchor; - d->checkVValid(); + if (!d->checkVValid()) { + d->usedAnchors &= ~HasTopAnchor; + return; + } d->remDepend(d->top.item); d->top = edge; @@ -548,7 +548,11 @@ void QFxAnchors::setTop(const QFxAnchorLine &edge) void QFxAnchors::resetTop() { - setTop(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasTopAnchor; + d->remDepend(d->top.item); + d->top = QFxAnchorLine(); + d->updateVerticalAnchors(); } QFxAnchorLine QFxAnchors::bottom() const @@ -563,12 +567,12 @@ void QFxAnchors::setBottom(const QFxAnchorLine &edge) if (!d->checkVAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasBottomAnchor; - else - d->usedAnchors &= ~HasBottomAnchor; + d->usedAnchors |= HasBottomAnchor; - d->checkVValid(); + if (!d->checkVValid()) { + d->usedAnchors &= ~HasBottomAnchor; + return; + } d->remDepend(d->bottom.item); d->bottom = edge; @@ -578,7 +582,11 @@ void QFxAnchors::setBottom(const QFxAnchorLine &edge) void QFxAnchors::resetBottom() { - setBottom(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasBottomAnchor; + d->remDepend(d->bottom.item); + d->bottom = QFxAnchorLine(); + d->updateVerticalAnchors(); } QFxAnchorLine QFxAnchors::verticalCenter() const @@ -593,12 +601,12 @@ void QFxAnchors::setVerticalCenter(const QFxAnchorLine &edge) if (!d->checkVAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasVCenterAnchor; - else - d->usedAnchors &= ~HasVCenterAnchor; + d->usedAnchors |= HasVCenterAnchor; - d->checkVValid(); + if (!d->checkVValid()) { + d->usedAnchors &= ~HasVCenterAnchor; + return; + } d->remDepend(d->vCenter.item); d->vCenter = edge; @@ -608,7 +616,11 @@ void QFxAnchors::setVerticalCenter(const QFxAnchorLine &edge) void QFxAnchors::resetVerticalCenter() { - setVerticalCenter(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasVCenterAnchor; + d->remDepend(d->vCenter.item); + d->vCenter = QFxAnchorLine(); + d->updateVerticalAnchors(); } QFxAnchorLine QFxAnchors::baseline() const @@ -623,12 +635,12 @@ void QFxAnchors::setBaseline(const QFxAnchorLine &edge) if (!d->checkVAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasBaselineAnchor; - else - d->usedAnchors &= ~HasBaselineAnchor; + d->usedAnchors |= HasBaselineAnchor; - d->checkVValid(); + if (!d->checkVValid()) { + d->usedAnchors &= ~HasBaselineAnchor; + return; + } d->remDepend(d->baseline.item); d->baseline = edge; @@ -638,7 +650,11 @@ void QFxAnchors::setBaseline(const QFxAnchorLine &edge) void QFxAnchors::resetBaseline() { - setBaseline(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasBaselineAnchor; + d->remDepend(d->baseline.item); + d->baseline = QFxAnchorLine(); + d->updateVerticalAnchors(); } QFxAnchorLine QFxAnchors::left() const @@ -653,12 +669,12 @@ void QFxAnchors::setLeft(const QFxAnchorLine &edge) if (!d->checkHAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasLeftAnchor; - else - d->usedAnchors &= ~HasLeftAnchor; + d->usedAnchors |= HasLeftAnchor; - d->checkHValid(); + if (!d->checkHValid()) { + d->usedAnchors &= ~HasLeftAnchor; + return; + } d->remDepend(d->left.item); d->left = edge; @@ -668,7 +684,11 @@ void QFxAnchors::setLeft(const QFxAnchorLine &edge) void QFxAnchors::resetLeft() { - setLeft(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasLeftAnchor; + d->remDepend(d->left.item); + d->left = QFxAnchorLine(); + d->updateHorizontalAnchors(); } QFxAnchorLine QFxAnchors::right() const @@ -683,12 +703,12 @@ void QFxAnchors::setRight(const QFxAnchorLine &edge) if (!d->checkHAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasRightAnchor; - else - d->usedAnchors &= ~HasRightAnchor; + d->usedAnchors |= HasRightAnchor; - d->checkHValid(); + if (!d->checkHValid()) { + d->usedAnchors &= ~HasRightAnchor; + return; + } d->remDepend(d->right.item); d->right = edge; @@ -699,7 +719,11 @@ void QFxAnchors::setRight(const QFxAnchorLine &edge) void QFxAnchors::resetRight() { - setRight(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasRightAnchor; + d->remDepend(d->right.item); + d->right = QFxAnchorLine(); + d->updateHorizontalAnchors(); } QFxAnchorLine QFxAnchors::horizontalCenter() const @@ -714,12 +738,12 @@ void QFxAnchors::setHorizontalCenter(const QFxAnchorLine &edge) if (!d->checkHAnchorValid(edge)) return; - if (edge.item) - d->usedAnchors |= HasHCenterAnchor; - else - d->usedAnchors &= ~HasHCenterAnchor; + d->usedAnchors |= HasHCenterAnchor; - d->checkHValid(); + if (!d->checkHValid()) { + d->usedAnchors &= ~HasHCenterAnchor; + return; + } d->remDepend(d->hCenter.item); d->hCenter = edge; @@ -729,7 +753,11 @@ void QFxAnchors::setHorizontalCenter(const QFxAnchorLine &edge) void QFxAnchors::resetHorizontalCenter() { - setHorizontalCenter(QFxAnchorLine()); + Q_D(QFxAnchors); + d->usedAnchors &= ~HasHCenterAnchor; + d->remDepend(d->hCenter.item); + d->hCenter = QFxAnchorLine(); + d->updateHorizontalAnchors(); } int QFxAnchors::leftMargin() const @@ -848,13 +876,16 @@ bool QFxAnchorsPrivate::checkHValid() const bool QFxAnchorsPrivate::checkHAnchorValid(QFxAnchorLine anchor) const { - if (anchor.anchorLine & QFxAnchorLine::Vertical_Mask) { + if (!anchor.item) { + qmlInfo(item) << "Can't anchor to a null item."; + return false; + } else if (anchor.anchorLine & QFxAnchorLine::Vertical_Mask) { qmlInfo(item) << "Can't anchor a horizontal edge to a vertical edge."; return false; } else if (anchor.item != item->itemParent() && anchor.item->itemParent() != item->itemParent()){ qmlInfo(item) << "Can't anchor to an item that isn't a parent or sibling."; return false; - } else if (anchor.item == item){ + } else if (anchor.item == item) { qmlInfo(item) << "Can't anchor item to self."; return false; } @@ -882,7 +913,10 @@ bool QFxAnchorsPrivate::checkVValid() const bool QFxAnchorsPrivate::checkVAnchorValid(QFxAnchorLine anchor) const { - if (anchor.anchorLine & QFxAnchorLine::Horizontal_Mask) { + if (!anchor.item) { + qmlInfo(item) << "Can't anchor to a null item."; + return false; + } else if (anchor.anchorLine & QFxAnchorLine::Horizontal_Mask) { qmlInfo(item) << "Can't anchor a vertical edge to a horizontal edge."; return false; } else if (anchor.item != item->itemParent() && anchor.item->itemParent() != item->itemParent()){ diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h index 0e44223..206a05c 100644 --- a/src/declarative/fx/qfxanchors.h +++ b/src/declarative/fx/qfxanchors.h @@ -58,11 +58,12 @@ class QFxAnchorsPrivate; class QFxAnchorLine { public: - QFxAnchorLine() : item(0), anchorLine(Left) + QFxAnchorLine() : item(0), anchorLine(Invalid) { } enum AnchorLine { + Invalid = 0x0, Left = 0x01, Right = 0x02, Top = 0x04, diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp index abe6d96..4830169 100644 --- a/tests/auto/declarative/anchors/tst_anchors.cpp +++ b/tests/auto/declarative/anchors/tst_anchors.cpp @@ -17,6 +17,8 @@ private slots: void basicAnchors(); void loops(); void illegalSets(); + void reset(); + void nullItem(); }; /* @@ -154,6 +156,30 @@ void tst_anchors::illegalSets() } } +void tst_anchors::reset() +{ + QFxItem *aItem = new QFxItem; + QFxAnchorLine anchor; + anchor.item = aItem; + anchor.anchorLine = QFxAnchorLine::Top; + + QFxItem *item = new QFxItem; + item->anchors()->setBottom(anchor); + QCOMPARE(item->anchors()->usedAnchors().testFlag(QFxAnchors::HasBottomAnchor), true); + + item->anchors()->resetBottom(); + QCOMPARE(item->anchors()->usedAnchors().testFlag(QFxAnchors::HasBottomAnchor), false); +} + +void tst_anchors::nullItem() +{ + QFxAnchorLine anchor; + + QTest::ignoreMessage(QtWarningMsg, "QML QFxItem (unknown location): Can't anchor to a null item. "); + QFxItem *item = new QFxItem; + item->anchors()->setBottom(anchor); +} + QTEST_MAIN(tst_anchors) #include "tst_anchors.moc" -- cgit v0.12 From 329897ea89f0cc01e95873cc0f7722588ab3e817 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 22 Jun 2009 12:49:54 +1000 Subject: Fix Item scale + rotation on GraphicsView. --- src/declarative/canvas/qsimplecanvasitem.cpp | 11 ++++++++++- src/declarative/canvas/qsimplecanvasitem_p.h | 6 +++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/declarative/canvas/qsimplecanvasitem.cpp b/src/declarative/canvas/qsimplecanvasitem.cpp index cbdc324..0ceb7b7 100644 --- a/src/declarative/canvas/qsimplecanvasitem.cpp +++ b/src/declarative/canvas/qsimplecanvasitem.cpp @@ -1027,7 +1027,16 @@ void QSimpleCanvasItem::setTransform(const QSimpleCanvas::Matrix &m) Q_D(QSimpleCanvasItem); if (d->graphicsItem) { d->graphicsItem->transform = QSimpleCanvasConfig::matrixToTransform(m); - d->graphicsItem->setTransform(QTransform::fromScale(d->scale, d->scale) * d->graphicsItem->transform); + QTransform t; + if (d->scale != 1) { + QPointF to = transformOriginPoint(); + if (to.x() != 0. || to.y() != 0.) + t.translate(to.x(), to.y()); + t.scale(d->scale, d->scale); + if (to.x() != 0. || to.y() != 0.) + t.translate(-to.x(), -to.y()); + } + d->graphicsItem->setTransform(t * d->graphicsItem->transform); } else { if (!d->data()->transformUser) d->data()->transformUser = new QSimpleCanvas::Matrix; diff --git a/src/declarative/canvas/qsimplecanvasitem_p.h b/src/declarative/canvas/qsimplecanvasitem_p.h index 6c21d9f..7a8f40a 100644 --- a/src/declarative/canvas/qsimplecanvasitem_p.h +++ b/src/declarative/canvas/qsimplecanvasitem_p.h @@ -53,8 +53,8 @@ #include "qgraphicsitem.h" - QT_BEGIN_NAMESPACE + class QSimpleGraphicsItem : public QGraphicsItem { public: @@ -265,6 +265,6 @@ public: Q_DECLARE_OPERATORS_FOR_FLAGS(QSimpleCanvasItemPrivate::FocusStateCheckDatas) Q_DECLARE_OPERATORS_FOR_FLAGS(QSimpleCanvasItemPrivate::FocusStateCheckRDatas) -#endif // QSIMPLECANVASITEM_P_H - QT_END_NAMESPACE + +#endif // QSIMPLECANVASITEM_P_H -- cgit v0.12 From 93116be19628239b82ba19f814374b2fcabd7c96 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 22 Jun 2009 13:10:30 +1000 Subject: Doc fixes. --- doc/src/declarative/elements.qdoc | 2 +- src/declarative/fx/qfxitem.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 3298699..35d746b 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -35,7 +35,7 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \l SetPropertyAction \o \l ParentChangeAction \o \l Transition -\o \l Behaviour +\o \l Behavior \o \l Follow \endlist diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 079d691..0c4d97b 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1433,7 +1433,7 @@ void QFxItem::setBaselineOffset(int offset) \qmlproperty real Item::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). + This specifies how many degrees to rotate the item around its transformOrigin. The default rotation is 0 degrees (i.e. not rotated at all). \table @@ -1468,7 +1468,7 @@ void QFxItem::setBaselineOffset(int offset) \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). + This specifies how many degrees to rotate the item around its transformOrigin. The default rotation is 0 degrees (i.e. not rotated at all). */ qreal QFxItem::rotation() const @@ -1511,7 +1511,7 @@ void QFxItem::setRotation(qreal rotation) 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). + Scaling is from the item's transformOrigin. \table \row @@ -1547,7 +1547,7 @@ void QFxItem::setRotation(qreal rotation) 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). + Scaling is from the item's transformOrigin. */ qreal QFxItem::scale() const { -- cgit v0.12