diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-04-28 03:08:21 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-04-28 03:08:21 (GMT) |
commit | a74086946666378f07505f1cd2d873e85fa5791b (patch) | |
tree | d630ebcebddef2c48b78c223111cae3d13979604 | |
parent | 7ecfd4393149ce9b49e5da4e254fcecd6b8af420 (diff) | |
parent | f96710f689c8237fabbfb65f56279e2a4d1aca30 (diff) | |
download | Qt-a74086946666378f07505f1cd2d873e85fa5791b.zip Qt-a74086946666378f07505f1cd2d873e85fa5791b.tar.gz Qt-a74086946666378f07505f1cd2d873e85fa5791b.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
10 files changed, 264 insertions, 56 deletions
diff --git a/doc/src/snippets/declarative/mouseregion.qml b/doc/src/snippets/declarative/mouseregion.qml index a464069..683770b 100644 --- a/doc/src/snippets/declarative/mouseregion.qml +++ b/doc/src/snippets/declarative/mouseregion.qml @@ -3,13 +3,21 @@ import Qt 4.7 Rectangle { width: 200; height: 100 Row { //! [0] -Rectangle { width: 100; height: 100; color: "green" - MouseArea { anchors.fill: parent; onClicked: { parent.color = 'red' } } +Rectangle { + width: 100; height: 100 + color: "green" + + MouseArea { + anchors.fill: parent + onClicked: { parent.color = 'red' } + } } //! [0] //! [1] Rectangle { - width: 100; height: 100; color: "green" + width: 100; height: 100 + color: "green" + MouseArea { anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 247e348..1031493 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE \brief The Image element allows you to add bitmaps to a scene. \inherits Item - The Image element supports untransformed, stretched and tiled. + The Image element supports untransformed, stretched and tiled images. For an explanation of stretching and tiling, see the fillMode property description. diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index 21c33e2..32a512b 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -46,6 +46,7 @@ #include <qdeclarativestate_p.h> #include <qdeclarativestategroup_p.h> #include <qdeclarativestateoperations_p.h> +#include <qdeclarativeinfo.h> #include <QtCore/qmath.h> #include <QDebug> @@ -165,6 +166,7 @@ void QDeclarativeBasePositioner::componentComplete() QDeclarativeItem::componentComplete(); positionedItems.reserve(d->QGraphicsItemPrivate::children.count()); prePositioning(); + reportConflictingAnchors(); } QVariant QDeclarativeBasePositioner::itemChange(GraphicsItemChange change, @@ -436,6 +438,26 @@ void QDeclarativeColumn::doPositioning(QSizeF *contentSize) contentSize->setHeight(voffset - spacing()); } +void QDeclarativeColumn::reportConflictingAnchors() +{ + bool childsWithConflictingAnchors(false); + for (int ii = 0; ii < positionedItems.count(); ++ii) { + const PositionedItem &child = positionedItems.at(ii); + if (child.item) { + QDeclarativeAnchors::Anchors usedAnchors = child.item->anchors()->usedAnchors(); + if (usedAnchors & QDeclarativeAnchors::TopAnchor || + usedAnchors & QDeclarativeAnchors::BottomAnchor || + usedAnchors & QDeclarativeAnchors::VCenterAnchor) { + childsWithConflictingAnchors = true; + break; + } + } + } + if (childsWithConflictingAnchors) { + qmlInfo(this) << "Cannot specify top, bottom or verticalCenter anchors for items inside Column"; + } +} + /*! \qmlclass Row QDeclarativeRow \since 4.7 @@ -551,6 +573,25 @@ void QDeclarativeRow::doPositioning(QSizeF *contentSize) contentSize->setWidth(hoffset - spacing()); } +void QDeclarativeRow::reportConflictingAnchors() +{ + bool childsWithConflictingAnchors(false); + for (int ii = 0; ii < positionedItems.count(); ++ii) { + const PositionedItem &child = positionedItems.at(ii); + if (child.item) { + QDeclarativeAnchors::Anchors usedAnchors = child.item->anchors()->usedAnchors(); + if (usedAnchors & QDeclarativeAnchors::LeftAnchor || + usedAnchors & QDeclarativeAnchors::RightAnchor || + usedAnchors & QDeclarativeAnchors::HCenterAnchor) { + childsWithConflictingAnchors = true; + break; + } + } + } + if (childsWithConflictingAnchors) { + qmlInfo(this) << "Cannot specify left, right or horizontalCenter anchors for items inside Row"; + } +} /*! \qmlclass Grid QDeclarativeGrid @@ -823,6 +864,20 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize) } } +void QDeclarativeGrid::reportConflictingAnchors() +{ + bool childsWithConflictingAnchors(false); + for (int ii = 0; ii < positionedItems.count(); ++ii) { + const PositionedItem &child = positionedItems.at(ii); + if (child.item && child.item->anchors()->usedAnchors()) { + childsWithConflictingAnchors = true; + break; + } + } + if (childsWithConflictingAnchors) { + qmlInfo(this) << "Cannot specify anchors for items inside Grid"; + } +} /*! \qmlclass Flow QDeclarativeFlow @@ -966,5 +1021,19 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize) } } +void QDeclarativeFlow::reportConflictingAnchors() +{ + bool childsWithConflictingAnchors(false); + for (int ii = 0; ii < positionedItems.count(); ++ii) { + const PositionedItem &child = positionedItems.at(ii); + if (child.item && child.item->anchors()->usedAnchors()) { + childsWithConflictingAnchors = true; + break; + } + } + if (childsWithConflictingAnchors) { + qmlInfo(this) << "Cannot specify anchors for items inside Flow"; + } +} QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h index b5fc979..787dcd3 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h +++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h @@ -94,6 +94,7 @@ protected Q_SLOTS: protected: virtual void doPositioning(QSizeF *contentSize)=0; + virtual void reportConflictingAnchors()=0; struct PositionedItem { PositionedItem(QDeclarativeItem *i) : item(i), isNew(false), isVisible(true) {} bool operator==(const PositionedItem &other) const { return other.item == item; } @@ -118,6 +119,7 @@ public: QDeclarativeColumn(QDeclarativeItem *parent=0); protected: virtual void doPositioning(QSizeF *contentSize); + virtual void reportConflictingAnchors(); private: Q_DISABLE_COPY(QDeclarativeColumn) }; @@ -129,6 +131,7 @@ public: QDeclarativeRow(QDeclarativeItem *parent=0); protected: virtual void doPositioning(QSizeF *contentSize); + virtual void reportConflictingAnchors(); private: Q_DISABLE_COPY(QDeclarativeRow) }; @@ -161,6 +164,7 @@ Q_SIGNALS: protected: virtual void doPositioning(QSizeF *contentSize); + virtual void reportConflictingAnchors(); private: int m_rows; @@ -187,7 +191,7 @@ Q_SIGNALS: protected: virtual void doPositioning(QSizeF *contentSize); - + virtual void reportConflictingAnchors(); protected: QDeclarativeFlow(QDeclarativeFlowPrivate &dd, QDeclarativeItem *parent); private: diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp index 0328f91..fe656fa 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp +++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp @@ -155,8 +155,8 @@ void QDeclarativeGradient::doUpdate() \brief The Rectangle item allows you to add rectangles to a scene. \inherits Item - A Rectangle is painted having a solid fill (color) and an optional border. - You can also create rounded rectangles using the radius property. + A Rectangle is painted using a solid fill (color) and an optional border. + You can also create rounded rectangles using the \l radius property. \qml Rectangle { @@ -223,14 +223,22 @@ QDeclarativePen *QDeclarativeRectangle::border() \o \image declarative-rect_gradient.png \o \qml - Rectangle { y: 0; width: 80; height: 80; color: "lightsteelblue" } - Rectangle { y: 100; width: 80; height: 80 + Rectangle { + y: 0; width: 80; height: 80 + color: "lightsteelblue" + } + + Rectangle { + y: 100; width: 80; height: 80 gradient: Gradient { GradientStop { position: 0.0; color: "lightsteelblue" } GradientStop { position: 1.0; color: "blue" } } } - Rectangle { rotation: 90; y: 200; width: 80; height: 80 + + Rectangle { + y: 200; width: 80; height: 80 + rotation: 90 gradient: Gradient { GradientStop { position: 0.0; color: "lightsteelblue" } GradientStop { position: 1.0; color: "blue" } diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index d49bb02..ca0b8c6 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -67,7 +67,7 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() \brief The Repeater item allows you to repeat an Item-based component using a model. - The Repeater item is used when you want to create a large number of + The Repeater item is used to create a large number of similar items. For each entry in the model, an item is instantiated in a context seeded with data from the model. If the repeater will be instantiating a large number of instances, it may be more efficient to diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 2b8da8e..37a63eb 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -116,7 +116,7 @@ QSet<QUrl> QTextDocumentWithImageResources::errors; \brief The Text item allows you to add formatted text to a scene. \inherits Item - It can display both plain and rich text. For example: + A Text item can display both plain and rich text. For example: \qml Text { text: "Hello World!"; font.family: "Helvetica"; font.pointSize: 24; color: "red" } @@ -132,8 +132,8 @@ QSet<QUrl> QTextDocumentWithImageResources::errors; The \c elide property can alternatively be used to fit a single line of plain text to a set width. - Note that the \l{Supported HTML Subset} is limited, and that if IMG tags - load remote images, the text reloads (see resourcesLoading). + Note that the \l{Supported HTML Subset} is limited. Also, if the text contains + HTML img tags that load remote images, the text is reloaded. Text provides read-only text. For editable text, see \l TextEdit. */ @@ -191,7 +191,7 @@ QDeclarativeTextPrivate::~QDeclarativeTextPrivate() /*! \qmlproperty bool Text::font.bold - Sets the font's weight to bold. + Sets whether the font weight is bold. */ /*! @@ -216,25 +216,25 @@ QDeclarativeTextPrivate::~QDeclarativeTextPrivate() /*! \qmlproperty bool Text::font.italic - Sets the style of the text to italic. + Sets whether the font has an italic style. */ /*! \qmlproperty bool Text::font.underline - Set the style of the text to underline. + Sets whether the text is underlined. */ /*! \qmlproperty bool Text::font.outline - Set the style of the text to outline. + Sets whether the font has an outline style. */ /*! \qmlproperty bool Text::font.strikeout - Set the style of the text to strikeout. + Sets whether the font has a strikeout style. */ /*! @@ -531,7 +531,14 @@ void QDeclarativeText::setWrapMode(WrapMode mode) The way the text property should be displayed. - Supported text formats are \c AutoText, \c PlainText, \c RichText and \c StyledText + Supported text formats are: + + \list + \o AutoText + \o PlainText + \o RichText + \o StyledText + \endlist The default is AutoText. If the text format is AutoText the text element will automatically determine whether the text should be treated as @@ -1069,8 +1076,9 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid /*! \qmlproperty bool Text::smooth - Set this property if you want the text to be smoothly scaled or - transformed. Smooth filtering gives better visual quality, but is slower. If + This property holds whether the text is smoothly scaled or transformed. + + Smooth filtering gives better visual quality, but is slower. If the item is displayed at its natural size, this property has no visual or performance effect. diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 25eaef6..31ed418 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -129,7 +129,7 @@ QString QDeclarativeTextEdit::text() const /*! \qmlproperty bool TextEdit::font.bold - Sets the font's weight to bold. + Sets whether the font weight is bold. */ /*! @@ -154,25 +154,25 @@ QString QDeclarativeTextEdit::text() const /*! \qmlproperty bool TextEdit::font.italic - Sets the style of the text to italic. + Sets whether the font has an italic style. */ /*! \qmlproperty bool TextEdit::font.underline - Set the style of the text to underline. + Sets whether the text is underlined. */ /*! \qmlproperty bool TextEdit::font.outline - Set the style of the text to outline. + Sets whether the font has an outline style. */ /*! \qmlproperty bool TextEdit::font.strikeout - Set the style of the text to strikeout. + Sets whether the font has a strikeout style. */ /*! @@ -255,7 +255,12 @@ void QDeclarativeTextEdit::setText(const QString &text) The way the text property should be displayed. - Supported text formats are \c AutoText, \c PlainText and \c RichText. + \list + \o AutoText + \o PlainText + \o RichText + \o StyledText + \endlist The default is AutoText. If the text format is AutoText the text edit will automatically determine whether the text should be treated as @@ -991,8 +996,9 @@ void QDeclarativeTextEdit::updateImgCache(const QRectF &r) /*! \qmlproperty bool TextEdit::smooth - Set this property if you want the text to be smoothly scaled or - transformed. Smooth filtering gives better visual quality, but is slower. If + This property holds whether the text is smoothly scaled or transformed. + + Smooth filtering gives better visual quality, but is slower. If the item is displayed at its natural size, this property has no visual or performance effect. diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index b618183..43812b6 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -108,7 +108,7 @@ void QDeclarativeTextInput::setText(const QString &s) /*! \qmlproperty bool TextInput::font.bold - Sets the font's weight to bold. + Sets whether the font weight is bold. */ /*! @@ -133,25 +133,25 @@ void QDeclarativeTextInput::setText(const QString &s) /*! \qmlproperty bool TextInput::font.italic - Sets the style of the text to italic. + Sets whether the font has an italic style. */ /*! \qmlproperty bool TextInput::font.underline - Set the style of the text to underline. + Sets whether the text is underlined. */ /*! \qmlproperty bool TextInput::font.outline - Set the style of the text to outline. + Sets whether the font has an outline style. */ /*! \qmlproperty bool TextInput::font.strikeout - Set the style of the text to strikeout. + Sets whether the font has a strikeout style. */ /*! @@ -827,7 +827,7 @@ void QDeclarativeTextInput::moveCursor() d->cursorItem->setX(d->control->cursorToX() - d->hscroll); } -/* +/*! \qmlmethod int xToPosition(int x) This function returns the character position at @@ -1044,8 +1044,9 @@ void QDeclarativeTextInput::selectAll() /*! \qmlproperty bool TextInput::smooth - Set this property if you want the text to be smoothly scaled or - transformed. Smooth filtering gives better visual quality, but is slower. If + This property holds whether the text is smoothly scaled or transformed. + + Smooth filtering gives better visual quality, but is slower. If the item is displayed at its natural size, this property has no visual or performance effect. @@ -1054,15 +1055,15 @@ void QDeclarativeTextInput::selectAll() filtering at the beginning of the animation and reenable it at the conclusion. */ -/* +/*! \qmlproperty string TextInput::passwordCharacter This is the character displayed when echoMode is set to Password or PasswordEchoOnEdit. By default it is an asterisk. - Attempting to set this to more than one character will set it to - the first character in the string. Attempting to set this to less - than one character will fail. + If this property is set to a string with more than one character, + the first character is used. If the string is empty, the value + is ignored and the property is not set. */ QString QDeclarativeTextInput::passwordCharacter() const { @@ -1079,15 +1080,15 @@ void QDeclarativeTextInput::setPasswordCharacter(const QString &str) d->control->setPasswordCharacter(str.constData()[0]); } -/* +/*! \qmlproperty string TextInput::displayText - This is the actual text displayed in the TextInput. When - echoMode is set to TextInput::Normal this will be exactly - the same as the TextInput::text property. When echoMode - is set to something else, this property will contain the text - the user sees, while the text property will contain the - entered text. + This is the text displayed in the TextInput. + + If \l echoMode is set to TextInput::Normal, this holds the + same value as the TextInput::text property. Otherwise, + this property holds the text visible to the user, while + the \l text property holds the actual entered text. */ QString QDeclarativeTextInput::displayText() const { @@ -1095,26 +1096,30 @@ QString QDeclarativeTextInput::displayText() const return d->control->displayText(); } -/* - \qmlmethod void moveCursorSelection(int pos) +/*! + \qmlmethod void moveCursorSelection(int position) - This method allows you to move the cursor while modifying the selection accordingly. - To simply move the cursor, set the cursorPosition property. + Moves the cursor to \a position and updates the selection accordingly. + (To only move the cursor, set the \l cursorPosition property.) When this method is called it additionally sets either the selectionStart or the selectionEnd (whichever was at the previous cursor position) to the specified position. This allows you to easily extend and contract the selected text range. - Example: The sequence of calls + For example, take this sequence of calls: + + \code cursorPosition = 5 moveCursorSelection(9) moveCursorSelection(7) - would move the cursor to position 5, extend the selection end from 5 to 9 + \endcode + + This moves the cursor to position 5, extend the selection end from 5 to 9 and then retract the selection end from 9 to 7, leaving the text from position 5 to 7 selected (the 6th and 7th characters). */ -void QDeclarativeTextInput::moveCursorSelection(int pos) +void QDeclarativeTextInput::moveCursorSelection(int position) { Q_D(QDeclarativeTextInput); d->control->moveCursor(pos, true); diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index b4ac0e1..7a23773 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -41,6 +41,7 @@ #include <QtTest/QtTest> #include <private/qlistmodelinterface_p.h> #include <qdeclarativeview.h> +#include <qdeclarativeengine.h> #include <private/qdeclarativerectangle_p.h> #include <private/qdeclarativepositioners_p.h> #include <private/qdeclarativetransition_p.h> @@ -69,6 +70,7 @@ private slots: void test_repeater(); void test_flow(); void test_flow_resize(); + void test_conflictinganchors(); private: QDeclarativeView *createView(const QString &filename); }; @@ -100,6 +102,8 @@ void tst_QDeclarativePositioners::test_horizontal() QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row"); QCOMPARE(row->width(), 110.0); QCOMPARE(row->height(), 50.0); + + delete canvas; } void tst_QDeclarativePositioners::test_horizontal_spacing() @@ -125,6 +129,8 @@ void tst_QDeclarativePositioners::test_horizontal_spacing() QDeclarativeItem *row = canvas->rootObject()->findChild<QDeclarativeItem*>("row"); QCOMPARE(row->width(), 130.0); QCOMPARE(row->height(), 50.0); + + delete canvas; } void tst_QDeclarativePositioners::test_horizontal_animated() @@ -175,6 +181,8 @@ void tst_QDeclarativePositioners::test_horizontal_animated() QTRY_COMPARE(two->x(), 50.0); QTRY_COMPARE(three->x(), 100.0); + + delete canvas; } void tst_QDeclarativePositioners::test_vertical() @@ -201,6 +209,8 @@ void tst_QDeclarativePositioners::test_vertical() QVERIFY(column); QCOMPARE(column->height(), 80.0); QCOMPARE(column->width(), 50.0); + + delete canvas; } void tst_QDeclarativePositioners::test_vertical_spacing() @@ -226,6 +236,8 @@ void tst_QDeclarativePositioners::test_vertical_spacing() QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column"); QCOMPARE(column->height(), 100.0); QCOMPARE(column->width(), 50.0); + + delete canvas; } void tst_QDeclarativePositioners::test_vertical_animated() @@ -273,6 +285,7 @@ void tst_QDeclarativePositioners::test_vertical_animated() QTRY_COMPARE(two->y(), 50.0); QTRY_COMPARE(three->y(), 100.0); + delete canvas; } void tst_QDeclarativePositioners::test_grid() @@ -304,6 +317,8 @@ void tst_QDeclarativePositioners::test_grid() QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); QCOMPARE(grid->width(), 120.0); QCOMPARE(grid->height(), 100.0); + + delete canvas; } void tst_QDeclarativePositioners::test_grid_topToBottom() @@ -335,6 +350,8 @@ void tst_QDeclarativePositioners::test_grid_topToBottom() QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); QCOMPARE(grid->width(), 100.0); QCOMPARE(grid->height(), 120.0); + + delete canvas; } void tst_QDeclarativePositioners::test_grid_spacing() @@ -366,6 +383,8 @@ void tst_QDeclarativePositioners::test_grid_spacing() QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); QCOMPARE(grid->width(), 128.0); QCOMPARE(grid->height(), 104.0); + + delete canvas; } void tst_QDeclarativePositioners::test_grid_animated() @@ -446,6 +465,7 @@ void tst_QDeclarativePositioners::test_grid_animated() QTRY_COMPARE(five->x(), 50.0); QTRY_COMPARE(five->y(), 50.0); + delete canvas; } void tst_QDeclarativePositioners::test_grid_zero_columns() @@ -477,6 +497,8 @@ void tst_QDeclarativePositioners::test_grid_zero_columns() QDeclarativeItem *grid = canvas->rootObject()->findChild<QDeclarativeItem*>("grid"); QCOMPARE(grid->width(), 170.0); QCOMPARE(grid->height(), 60.0); + + delete canvas; } void tst_QDeclarativePositioners::test_propertychanges() @@ -534,6 +556,8 @@ void tst_QDeclarativePositioners::test_propertychanges() grid->setRows(2); QCOMPARE(columnsSpy.count(),2); QCOMPARE(rowsSpy.count(),2); + + delete canvas; } void tst_QDeclarativePositioners::test_repeater() @@ -555,6 +579,8 @@ void tst_QDeclarativePositioners::test_repeater() QCOMPARE(two->y(), 0.0); QCOMPARE(three->x(), 100.0); QCOMPARE(three->y(), 0.0); + + delete canvas; } void tst_QDeclarativePositioners::test_flow() @@ -587,6 +613,8 @@ void tst_QDeclarativePositioners::test_flow() QVERIFY(flow); QCOMPARE(flow->width(), 90.0); QCOMPARE(flow->height(), 120.0); + + delete canvas; } void tst_QDeclarativePositioners::test_flow_resize() @@ -618,6 +646,78 @@ void tst_QDeclarativePositioners::test_flow_resize() QCOMPARE(four->y(), 50.0); QCOMPARE(five->x(), 50.0); QCOMPARE(five->y(), 50.0); + + delete canvas; +} + +QString warningMessage; + +void interceptWarnings(QtMsgType type, const char *msg) +{ + Q_UNUSED( type ); + warningMessage = msg; +} + +void tst_QDeclarativePositioners::test_conflictinganchors() +{ + qInstallMsgHandler(interceptWarnings); + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + + component.setData("import Qt 4.7\nColumn { Item {} }", QUrl::fromLocalFile("")); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + + component.setData("import Qt 4.7\nRow { Item {} }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + + component.setData("import Qt 4.7\nGrid { Item {} }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + + component.setData("import Qt 4.7\nFlow { Item {} }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + + component.setData("import Qt 4.7\nColumn { Item { anchors.top: parent.top } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom or verticalCenter anchors for items inside Column")); + warningMessage.clear(); + + component.setData("import Qt 4.7\nColumn { Item { anchors.left: parent.left } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + warningMessage.clear(); + + component.setData("import Qt 4.7\nRow { Item { anchors.left: parent.left } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right or horizontalCenter anchors for items inside Row")); + warningMessage.clear(); + + component.setData("import Qt 4.7\nRow { Item { anchors.top: parent.top } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + warningMessage.clear(); + + component.setData("import Qt 4.7\nGrid { Item { anchors.horizontalCenter: parent.horizontalCenter } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid")); + warningMessage.clear(); + + component.setData("import Qt 4.7\nFlow { Item { anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile("")); + item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow")); } QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename) |