summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-08-16 05:17:27 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-08-16 05:17:27 (GMT)
commit7fcc1daf1762d345ca39f9599a8de2567bb8e788 (patch)
tree7d1fee938d2466c2f0776eb6ab7ecb160d64d7d7
parent8ae7f9508a94e37ceddd4c2b1b94dc43ff039cf3 (diff)
downloadQt-7fcc1daf1762d345ca39f9599a8de2567bb8e788.zip
Qt-7fcc1daf1762d345ca39f9599a8de2567bb8e788.tar.gz
Qt-7fcc1daf1762d345ca39f9599a8de2567bb8e788.tar.bz2
More positioners with QGraphicsWidgets fixes.
Task-number: QTBUG-12416 Reviewed-by: Michael Brasser
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp8
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp44
2 files changed, 50 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
index f32c532..1a5c42d 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -70,6 +70,8 @@ void QDeclarativeBasePositionerPrivate::watchChanges(QGraphicsObject *other)
Q_Q(QDeclarativeBasePositioner);
QObject::connect(other, SIGNAL(widthChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
QObject::connect(other, SIGNAL(heightChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
+ QObject::connect(other, SIGNAL(opacityChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
+ QObject::connect(other, SIGNAL(visibleChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
}
}
@@ -82,6 +84,8 @@ void QDeclarativeBasePositionerPrivate::unwatchChanges(QGraphicsObject* other)
Q_Q(QDeclarativeBasePositioner);
QObject::disconnect(other, SIGNAL(widthChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
QObject::disconnect(other, SIGNAL(heightChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
+ QObject::disconnect(other, SIGNAL(opacityChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
+ QObject::disconnect(other, SIGNAL(visibleChanged()), q, SLOT(graphicsWidgetGeometryChanged()));
}
}
@@ -235,7 +239,7 @@ void QDeclarativeBasePositioner::prePositioning()
QGraphicsObject *child = children.at(ii)->toGraphicsObject();
if (!child)
continue;
- QDeclarativeItemPrivate *childPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(child));
+ QGraphicsItemPrivate *childPrivate = static_cast<QGraphicsItemPrivate*>(QGraphicsItemPrivate::get(child));
PositionedItem *item = 0;
PositionedItem posItem(child);
int wIdx = oldItems.find(posItem);
@@ -320,7 +324,7 @@ void QDeclarativeBasePositioner::finishApplyTransitions()
static inline bool isInvisible(QGraphicsObject *child)
{
- QDeclarativeItemPrivate *childPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(child));
+ QGraphicsItemPrivate *childPrivate = static_cast<QGraphicsItemPrivate*>(QGraphicsItemPrivate::get(child));
return child->opacity() == 0.0 || childPrivate->explicitlyHidden || !childPrivate->width() || !childPrivate->height();
}
diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
index 0663991..887be50 100644
--- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
+++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp
@@ -46,6 +46,7 @@
#include <private/qdeclarativepositioners_p.h>
#include <private/qdeclarativetransition_p.h>
#include <qdeclarativeexpression.h>
+#include <QtGui/qgraphicswidget.h>
#include "../../../shared/util.h"
#ifdef Q_OS_SYMBIAN
@@ -77,6 +78,7 @@ private slots:
void test_flow_resize();
void test_flow_implicit_resize();
void test_conflictinganchors();
+ void test_vertical_qgraphicswidget();
private:
QDeclarativeView *createView(const QString &filename);
};
@@ -771,6 +773,48 @@ void tst_QDeclarativePositioners::test_conflictinganchors()
QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow"));
}
+void tst_QDeclarativePositioners::test_vertical_qgraphicswidget()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/verticalqgraphicswidget.qml");
+
+ QGraphicsWidget *one = canvas->rootObject()->findChild<QGraphicsWidget*>("one");
+ QVERIFY(one != 0);
+
+ QGraphicsWidget *two = canvas->rootObject()->findChild<QGraphicsWidget*>("two");
+ QVERIFY(two != 0);
+
+ QGraphicsWidget *three = canvas->rootObject()->findChild<QGraphicsWidget*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), 50.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 60.0);
+
+ QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column");
+ QVERIFY(column);
+ QCOMPARE(column->height(), 80.0);
+ QCOMPARE(column->width(), 50.0);
+
+ two->resize(QSizeF(two->size().width(), 20.0));
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 70.0);
+
+ two->setOpacity(0.0);
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 50.0);
+
+ one->setVisible(false);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+
+ delete canvas;
+}
+
QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename)
{
QDeclarativeView *canvas = new QDeclarativeView(0);