summaryrefslogtreecommitdiffstats
path: root/src/widgets/graphicsview/qgraphicsscene.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsscene.cpp')
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index 988152da9d..aa42445b2a 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -1468,6 +1468,8 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
QGraphicsView *view = mouseEvent->widget() ? qobject_cast<QGraphicsView *>(mouseEvent->widget()->parentWidget()) : 0;
bool dontClearSelection = view && view->dragMode() == QGraphicsView::ScrollHandDrag;
+ bool extendSelection = (mouseEvent->modifiers() & Qt::ControlModifier) != 0;
+ dontClearSelection |= extendSelection;
if (!dontClearSelection) {
// Clear the selection if the originating view isn't in scroll
// hand drag mode. The view will clear the selection if no drag
@@ -2263,6 +2265,28 @@ void QGraphicsScene::setSelectionArea(const QPainterPath &path, const QTransform
void QGraphicsScene::setSelectionArea(const QPainterPath &path, Qt::ItemSelectionMode mode,
const QTransform &deviceTransform)
{
+ setSelectionArea(path, Qt::ReplaceSelection, mode, deviceTransform);
+}
+
+/*!
+ \overload
+ \since 5.5
+
+ Sets the selection area to \a path using \a mode to determine if items are
+ included in the selection area.
+
+ \a deviceTransform is the transformation that applies to the view, and needs to
+ be provided if the scene contains items that ignore transformations.
+
+ \a selectionOperation determines what to do with the currently selected items.
+
+ \sa clearSelection(), selectionArea()
+*/
+void QGraphicsScene::setSelectionArea(const QPainterPath &path,
+ Qt::ItemSelectionOperation selectionOperation,
+ Qt::ItemSelectionMode mode,
+ const QTransform &deviceTransform)
+{
Q_D(QGraphicsScene);
// Note: with boolean path operations, we can improve performance here
@@ -2287,10 +2311,16 @@ void QGraphicsScene::setSelectionArea(const QPainterPath &path, Qt::ItemSelectio
}
}
- // Unselect all items outside path.
- foreach (QGraphicsItem *item, unselectItems) {
- item->setSelected(false);
- changed = true;
+ switch (selectionOperation) {
+ case Qt::ReplaceSelection:
+ // Deselect all items outside path.
+ foreach (QGraphicsItem *item, unselectItems) {
+ item->setSelected(false);
+ changed = true;
+ }
+ break;
+ default:
+ break;
}
// Reenable emitting selectionChanged() for individual items.
@@ -4910,7 +4940,7 @@ void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const Q
if (painterStateProtection || restorePainterClip)
painter->restore();
- static int drawRect = qgetenv("QT_DRAW_SCENE_ITEM_RECTS").toInt();
+ static int drawRect = qEnvironmentVariableIntValue("QT_DRAW_SCENE_ITEM_RECTS");
if (drawRect) {
QPen oldPen = painter->pen();
QBrush oldBrush = painter->brush();