diff options
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsscene_p.h')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsscene_p.h | 69 |
1 files changed, 24 insertions, 45 deletions
diff --git a/src/widgets/graphicsview/qgraphicsscene_p.h b/src/widgets/graphicsview/qgraphicsscene_p.h index a2d13436fc..c4b8b4e867 100644 --- a/src/widgets/graphicsview/qgraphicsscene_p.h +++ b/src/widgets/graphicsview/qgraphicsscene_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSSCENE_P_H #define QGRAPHICSSCENE_P_H @@ -69,6 +33,9 @@ #include <QtWidgets/qstyle.h> #include <QtWidgets/qstyleoption.h> +#include <set> +#include <tuple> + QT_REQUIRE_CONFIG(graphicsview); QT_BEGIN_NAMESPACE @@ -122,12 +89,24 @@ public: QRectF growingItemsBoundingRect; void _q_emitUpdated(); - QList<QRectF> updatedRects; + + struct UpdatedRectsCmp + { + bool operator() (const QRectF &a, const QRectF &b) const noexcept + { + return std::make_tuple(a.y(), a.x(), a.height(), a.width()) + < std::make_tuple(b.y(), b.x(), b.height(), b.width()); + } + }; + + // std::set was used here instead of std::unordered_set due to requiring only a comparator and + // showing equivalent performance in empirical measurements within the ranges of interest... + std::set<QRectF, UpdatedRectsCmp> updatedRects; QPainterPath selectionArea; int selectionChanging; QSet<QGraphicsItem *> selectedItems; - QVector<QGraphicsItem *> unpolishedItems; + QList<QGraphicsItem *> unpolishedItems; QList<QGraphicsItem *> topLevelItems; QHash<QGraphicsItem *, QPointF> movingItemsInitialPositions; @@ -226,7 +205,7 @@ public: void drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, const QTransform *const, QRegion *exposedRegion, QWidget *widget, qreal parentOpacity = qreal(1.0), - const QTransform *const effectTransform = 0); + const QTransform *const effectTransform = nullptr); void draw(QGraphicsItem *, QPainter *, const QTransform *const, const QTransform *const, QRegion *, QWidget *, qreal, const QTransform *const, bool, bool); @@ -294,7 +273,7 @@ public: QStyleOptionGraphicsItem styleOptionTmp; - QMap<int, QTouchEvent::TouchPoint> sceneCurrentTouchPoints; + QMap<int, QEventPoint> sceneCurrentTouchPoints; QMap<int, QGraphicsItem *> itemForTouchPointId; static void updateTouchPointsForItem(QGraphicsItem *item, QTouchEvent *touchEvent); int findClosestTouchPointId(const QPointF &scenePos); @@ -312,9 +291,9 @@ public: void gestureTargetsAtHotSpots(const QSet<QGesture *> &gestures, Qt::GestureFlag flag, QHash<QGraphicsObject *, QSet<QGesture *> > *targets, - QSet<QGraphicsObject *> *itemsSet = 0, - QSet<QGesture *> *normal = 0, - QSet<QGesture *> *conflicts = 0); + QSet<QGraphicsObject *> *itemsSet = nullptr, + QSet<QGesture *> *normal = nullptr, + QSet<QGesture *> *conflicts = nullptr); void cancelGesturesForChildren(QGesture *original); void grabGesture(QGraphicsItem *, Qt::GestureType gesture); void ungrabGesture(QGraphicsItem *, Qt::GestureType gesture); |