summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp15
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h2
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp50
3 files changed, 52 insertions, 15 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index b7e88f4..bd764b5 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -2607,7 +2607,6 @@ QTransform QGraphicsItem::transform() const
QVariant v(x);
d_ptr->setExtra(QGraphicsItemPrivate::ExtraTransform, v);
d_ptr->dirtyTransform = 0;
- d_ptr->dirtyTransformComponents = 1;
const_cast<QGraphicsItem *>(this)->itemChange(ItemTransformHasChanged, v);
return x;
}
@@ -3200,9 +3199,9 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)
prepareGeometryChange();
d_ptr->hasTransform = !newTransform.isIdentity();
d_ptr->setExtra(QGraphicsItemPrivate::ExtraTransform, newTransform);
+ d_ptr->dirtyTransformComponents = 1;
+ d_ptr->dirtyTransform = 0;
d_ptr->invalidateSceneTransformCache();
- if (d_ptr->hasDecomposedTransform)
- d_ptr->dirtyTransform = 1;
// Send post-notification.
// NB! We have to change the value from QMatrix to QTransform.
@@ -3253,9 +3252,9 @@ void QGraphicsItem::setTransform(const QTransform &matrix, bool combine)
prepareGeometryChange();
d_ptr->hasTransform = !newTransform.isIdentity();
d_ptr->setExtra(QGraphicsItemPrivate::ExtraTransform, newTransform);
+ d_ptr->dirtyTransformComponents = 1;
+ d_ptr->dirtyTransform = 0;
d_ptr->invalidateSceneTransformCache();
- if (d_ptr->hasDecomposedTransform)
- d_ptr->dirtyTransform = 1;
// Send post-notification.
itemChange(ItemTransformHasChanged, newTransformVariant);
@@ -8838,9 +8837,9 @@ bool QGraphicsTextItemPrivate::_q_mouseOnEdge(QGraphicsSceneMouseEvent *event)
Sets the flags \a flags to specify how the text item should react to user
input.
- The default for a QGraphicsTextItem is Qt::NoTextInteraction. Setting a
- value different to Qt::NoTextInteraction will also set the ItemIsFocusable
- QGraphicsItem flag.
+ The default for a QGraphicsTextItem is Qt::NoTextInteraction. This function
+ also affects the ItemIsFocusable QGraphicsItem flag by setting it if \a flags
+ is different from Qt::NoTextInteraction and clearing it otherwise.
By default, the text is read-only. To transform the item into an editor,
set the Qt::TextEditable flag.
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 1070e5f..62e0411 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -356,7 +356,7 @@ public:
int globalStackingOrder;
int sceneTransformIndex;
- struct DecomposedTransform;
+ struct DecomposedTransform;
DecomposedTransform *decomposedTransform() const
{
QGraphicsItemPrivate *that = const_cast<QGraphicsItemPrivate *>(this);
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index d41b3b4..c03c420 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -6404,26 +6404,26 @@ void tst_QGraphicsItem::setTransformProperties_data()
QTest::addColumn<qreal>("shearY");
QTest::newRow("nothing") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(0.0)
- << qreal(0.0) << qreal(0.0) << qreal(0.0) << qreal(0.0);
+ << qreal(1) << qreal(1) << qreal(0.0) << qreal(0.0);
QTest::newRow("rotationZ") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(42.2)
- << qreal(0.0) << qreal(0.0) << qreal(0.0) << qreal(0.0);
+ << qreal(1) << qreal(1) << qreal(0.0) << qreal(0.0);
QTest::newRow("rotationXY") << QPointF() << qreal(12.5) << qreal(53.6) << qreal(0.0)
- << qreal(0.0) << qreal(0.0) << qreal(0.0) << qreal(0.0);
+ << qreal(1) << qreal(1) << qreal(0.0) << qreal(0.0);
QTest::newRow("rotationXYZ") << QPointF() << qreal(-25) << qreal(12) << qreal(556)
- << qreal(0.0) << qreal(0.0) << qreal(0.0) << qreal(0.0);
+ << qreal(1) << qreal(1) << qreal(0.0) << qreal(0.0);
QTest::newRow("rotationXYZ dicentred") << QPointF(-53, 25.2)
<< qreal(-2578.2) << qreal(4565.2) << qreal(56)
- << qreal(0.0) << qreal(0.0) << qreal(0.0) << qreal(0.0);
+ << qreal(1) << qreal(1) << qreal(0.0) << qreal(0.0);
QTest::newRow("Scale") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(0.0)
<< qreal(6) << qreal(0.5) << qreal(0.0) << qreal(0.0);
QTest::newRow("Shear") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(0.0)
- << qreal(0.0) << qreal(0.0) << qreal(2.2) << qreal(0.5);
+ << qreal(1) << qreal(1) << qreal(2.2) << qreal(0.5);
QTest::newRow("Scale and Shear") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(0.0)
<< qreal(5.2) << qreal(2.1) << qreal(5.2) << qreal(5.5);
@@ -6475,6 +6475,44 @@ void tst_QGraphicsItem::setTransformProperties()
QCOMPARE(item->transformOrigin(), origin);
QCOMPARE(result, item->transform());
+
+ //-----------------------------------------------------------------
+ //Change the rotation Z
+ item->setZRotation(45);
+ QTransform result2;
+ result2.translate(origin.x(), origin.y());
+ result2.rotate(rotationX, Qt::XAxis);
+ result2.rotate(rotationY, Qt::YAxis);
+ result2.rotate(45, Qt::ZAxis);
+ result2.shear(shearX, shearY);
+ result2.scale(scaleX, scaleY);
+ result2.translate(-origin.x(), -origin.y());
+
+ QCOMPARE(item->xRotation(), rotationX);
+ QCOMPARE(item->yRotation(), rotationY);
+ QCOMPARE(item->zRotation(), 45.0);
+ QCOMPARE(item->xScale(), scaleX);
+ QCOMPARE(item->yScale(), scaleY);
+ QCOMPARE(item->horizontalShear(), shearX);
+ QCOMPARE(item->verticalShear(), shearY);
+ QCOMPARE(item->transformOrigin(), origin);
+
+ QCOMPARE(result2, item->transform());
+
+ //-----------------------------------------------------------------
+ // calling setTransform() should reset the properties to their default
+ item->setTransform(result);
+
+ QCOMPARE(item->xRotation(), 0.0);
+ QCOMPARE(item->yRotation(), 0.0);
+ QCOMPARE(item->zRotation(), 0.0);
+ QCOMPARE(item->xScale(), 1.0);
+ QCOMPARE(item->yScale(), 1.0);
+ QCOMPARE(item->horizontalShear(), 0.0);
+ QCOMPARE(item->verticalShear(), 0.0);
+ QCOMPARE(item->transformOrigin(), QPointF(0,0));
+
+ QCOMPARE(result, item->transform());
}