summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsitem
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@trolltech.com>2009-04-15 12:14:27 (GMT)
committerAlexis Menard <alexis.menard@trolltech.com>2009-04-15 12:19:12 (GMT)
commit36b16a126e24cb8d8e5c34cfd807bc7c51ea49cf (patch)
treef911a31464dd0de8a0ee8bd7af48ec075c493317 /tests/auto/qgraphicsitem
parent4cb80de7ade662deb5542f77cd3a36517fa9cd9b (diff)
downloadQt-36b16a126e24cb8d8e5c34cfd807bc7c51ea49cf.zip
Qt-36b16a126e24cb8d8e5c34cfd807bc7c51ea49cf.tar.gz
Qt-36b16a126e24cb8d8e5c34cfd807bc7c51ea49cf.tar.bz2
Update the item if the text has changed but the boundingRect is the
same. updateBoudingRect update the item only if the boundingRect change but if we have 123 as an initial text and then we set 321 as the new text, then nothing happen because the rect is the same. In case the boundingRect change then we call update 2 times but the item is already dirty so the second call will just return. BT:yes Reviewed-by: Andreas
Diffstat (limited to 'tests/auto/qgraphicsitem')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 2d1be37..d500182 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -222,6 +222,7 @@ private slots:
// task specific tests below me
void task141694_textItemEnsureVisible();
void task128696_textItemEnsureMovable();
+ void ensureUpdateOnTextItem();
void task177918_lineItemUndetected();
void task240400_clickOnTextItem_data();
void task240400_clickOnTextItem();
@@ -5272,6 +5273,39 @@ void tst_QGraphicsItem::task240400_clickOnTextItem()
QCOMPARE(item->textCursor().columnNumber(), 0);
}
+class TextItem : public QGraphicsSimpleTextItem
+{
+public:
+ TextItem(const QString& text) : QGraphicsSimpleTextItem(text)
+ {
+ updates = 0;
+ }
+
+ void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
+ {
+ updates++;
+ QGraphicsSimpleTextItem::paint(painter, option, widget);
+ }
+
+ int updates;
+};
+
+void tst_QGraphicsItem::ensureUpdateOnTextItem()
+{
+ QGraphicsScene scene;
+ TextItem *text1 = new TextItem(QLatin1String("123"));
+ scene.addItem(text1);
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWait(250);
+ QCOMPARE(text1->updates,1);
+
+ //same bouding rect but we have to update
+ text1->setText(QLatin1String("321"));
+ QTest::qWait(250);
+ QCOMPARE(text1->updates,2);
+}
+
void tst_QGraphicsItem::task243707_addChildBeforeParent()
{
// Task reports that adding the child before the parent leads to an