summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp2
-rw-r--r--src/gui/widgets/qcheckbox.cpp9
-rw-r--r--src/gui/widgets/qcheckbox.h1
-rw-r--r--tests/auto/qcheckbox/tst_qcheckbox.cpp7
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp38
5 files changed, 56 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index d1c5fd2..6db583a 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -7015,7 +7015,7 @@ void QGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
setSelected(true);
}
}
- } else if (!(flags() & ItemIsMovable)) {
+ } else if (!(flags() & ItemIsMovable) && !isSelected()) {
event->ignore();
}
if (d_ptr->isWidget) {
diff --git a/src/gui/widgets/qcheckbox.cpp b/src/gui/widgets/qcheckbox.cpp
index bc0900e..64b47b4 100644
--- a/src/gui/widgets/qcheckbox.cpp
+++ b/src/gui/widgets/qcheckbox.cpp
@@ -300,6 +300,15 @@ QSize QCheckBox::sizeHint() const
return d->sizeHint;
}
+
+/*!
+ \reimp
+*/
+QSize QCheckBox::minimumSizeHint() const
+{
+ return sizeHint();
+}
+
/*!
\reimp
*/
diff --git a/src/gui/widgets/qcheckbox.h b/src/gui/widgets/qcheckbox.h
index 7b6292d..95da261 100644
--- a/src/gui/widgets/qcheckbox.h
+++ b/src/gui/widgets/qcheckbox.h
@@ -65,6 +65,7 @@ public:
QSize sizeHint() const;
+ QSize minimumSizeHint() const;
void setTristate(bool y = true);
bool isTristate() const;
diff --git a/tests/auto/qcheckbox/tst_qcheckbox.cpp b/tests/auto/qcheckbox/tst_qcheckbox.cpp
index d16370c..24d78fe 100644
--- a/tests/auto/qcheckbox/tst_qcheckbox.cpp
+++ b/tests/auto/qcheckbox/tst_qcheckbox.cpp
@@ -92,6 +92,7 @@ private slots:
void setAccel();
void group();
void foregroundRole();
+ void minimumSizeHint();
protected slots:
void onClicked();
@@ -425,5 +426,11 @@ void tst_QCheckBox::foregroundRole()
QVERIFY(testWidget->foregroundRole() == QPalette::WindowText);
}
+void tst_QCheckBox::minimumSizeHint()
+{
+ QCheckBox box(tr("CheckBox's sizeHint is the same as it's minimumSizeHint"));
+ QCOMPARE(box.sizeHint(), box.minimumSizeHint());
+}
+
QTEST_MAIN(tst_QCheckBox)
#include "tst_qcheckbox.moc"
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 03ce45a..6e7c83c 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -294,6 +294,7 @@ private slots:
void explicitlyEnabled();
void selected();
void selected2();
+ void selected3();
void selected_group();
void selected_textItem();
void selected_multi();
@@ -1453,6 +1454,43 @@ void tst_QGraphicsItem::selected2()
}
}
+void tst_QGraphicsItem::selected3()
+{
+ QGraphicsScene scene;
+ QGraphicsItem *item1 = scene.addRect(QRectF(0, 0, 100, 100));
+ item1->setFlag(QGraphicsItem::ItemIsSelectable);
+
+ QGraphicsItem *item2 = scene.addRect(QRectF(100, 100, 100, 100));
+ item2->setFlag(QGraphicsItem::ItemIsSelectable);
+
+ item1->setSelected(true);
+ QGraphicsView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QVERIFY(item1->isSelected());
+ QVERIFY(!item2->isSelected());
+
+ // Right click on a selected item should not clear the selection
+ QTest::mouseClick(view.viewport(), Qt::RightButton, 0, view.mapFromScene(item1->boundingRect().center()));
+ QVERIFY(item1->isSelected());
+ QCOMPARE(scene.selectedItems().count(), 1);
+
+ // Right click on an unselected item should clear the selection
+ QTest::mouseClick(view.viewport(), Qt::RightButton, 0, view.mapFromScene(item2->boundingRect().center()));
+ QVERIFY(!item1->isSelected());
+ QCOMPARE(scene.selectedItems().count(), 0);
+
+ item2->setSelected(true);
+ QVERIFY(item2->isSelected());
+ QCOMPARE(scene.selectedItems().count(), 1);
+
+ // Right click on the scene background should clear the selection
+ QTest::mouseClick(view.viewport(), Qt::RightButton, 0, view.mapFromScene(QPointF(0, 110)));
+ QVERIFY(!item2->isSelected());
+ QCOMPARE(scene.selectedItems().count(), 0);
+}
+
void tst_QGraphicsItem::selected_group()
{
QGraphicsScene scene;