Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgraphicsview_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QGRAPHICSVIEW_P_H
6#define QGRAPHICSVIEW_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of other Qt classes. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtWidgets/private/qtwidgetsglobal_p.h>
20#include "qgraphicsview.h"
21
22#include <QtGui/private/qevent_p.h>
23#include <QtCore/qcoreapplication.h>
25#include <QtWidgets/qstyleoption.h>
26#include <private/qabstractscrollarea_p.h>
27#include <private/qapplication_p.h>
28
29#include <QtCore/qpointer.h>
30
32
34
35class Q_WIDGETS_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
36{
37 Q_DECLARE_PUBLIC(QGraphicsView)
38public:
39 QGraphicsViewPrivate();
40 ~QGraphicsViewPrivate();
41
42 void recalculateContentSize();
43 void centerView(QGraphicsView::ViewportAnchor anchor);
44
45 QPainter::RenderHints renderHints;
46
47 QGraphicsView::DragMode dragMode;
48
49 quint32 sceneInteractionAllowed : 1;
50 quint32 hasSceneRect : 1;
51 quint32 connectedToScene : 1;
52 quint32 useLastMouseEvent : 1;
53 quint32 identityMatrix : 1;
54 quint32 dirtyScroll : 1;
55 quint32 accelerateScrolling : 1;
56 quint32 keepLastCenterPoint : 1;
57 quint32 transforming : 1;
58 quint32 handScrolling : 1;
59 quint32 mustAllocateStyleOptions : 1;
60 quint32 mustResizeBackgroundPixmap : 1;
61 quint32 fullUpdatePending : 1;
62 quint32 hasUpdateClip : 1;
63 quint32 padding : 18;
64
65 QRectF sceneRect;
66 void updateLastCenterPoint();
67
68 qint64 horizontalScroll() const;
69 qint64 verticalScroll() const;
70
71 QRectF mapRectToScene(const QRect &rect) const;
72 QRectF mapRectFromScene(const QRectF &rect) const;
73
74 QRect updateClip;
75 QPointF mousePressItemPoint;
76 QPointF mousePressScenePoint;
77 QPoint mousePressViewPoint;
78 QPoint mousePressScreenPoint;
79 QPointF lastMouseMoveScenePoint;
80 QPointF lastRubberbandScenePoint;
81 QPoint lastMouseMoveScreenPoint;
82 QPoint dirtyScrollOffset;
83 Qt::MouseButton mousePressButton;
84 QTransform matrix;
85 qint64 scrollX, scrollY;
86 void updateScroll();
87 bool canStartScrollingAt(const QPoint &startPos) const override;
88
89 qreal leftIndent;
90 qreal topIndent;
91
92 // Replaying mouse events
93 QEventStorage<QMouseEvent> lastMouseEvent;
94 void replayLastMouseEvent();
95 void storeMouseEvent(QMouseEvent *event);
96 void mouseMoveEventHandler(QMouseEvent *event);
97
98 QPointF lastCenterPoint;
99 Qt::Alignment alignment;
100
101 QGraphicsView::ViewportAnchor transformationAnchor;
102 QGraphicsView::ViewportAnchor resizeAnchor;
103 QGraphicsView::ViewportUpdateMode viewportUpdateMode;
104 QGraphicsView::OptimizationFlags optimizationFlags;
105
106 bool stereoEnabled = false; // Set in setupViewport()
107
108 QPointer<QGraphicsScene> scene;
109#if QT_CONFIG(rubberband)
110 QRect rubberBandRect;
111 QRegion rubberBandRegion(const QWidget *widget, const QRect &rect) const;
112 void updateRubberBand(const QMouseEvent *event);
113 void clearRubberBand();
114 bool rubberBanding;
115 Qt::ItemSelectionMode rubberBandSelectionMode;
116 Qt::ItemSelectionOperation rubberBandSelectionOperation;
117#endif
118 int handScrollMotions;
119
120 QGraphicsView::CacheMode cacheMode;
121
122 QList<QStyleOptionGraphicsItem> styleOptions;
123 QStyleOptionGraphicsItem *allocStyleOptionsArray(int numItems);
124 void freeStyleOptionsArray(QStyleOptionGraphicsItem *array);
125
126 QBrush backgroundBrush;
127 QBrush foregroundBrush;
128 QPixmap backgroundPixmap;
129 QRegion backgroundPixmapExposed;
130
131#ifndef QT_NO_CURSOR
132 QCursor originalCursor;
133 bool hasStoredOriginalCursor;
134 void _q_setViewportCursor(const QCursor &cursor);
135 void _q_unsetViewportCursor();
136#endif
137
138 QGraphicsSceneDragDropEvent *lastDragDropEvent;
139 void storeDragDropEvent(const QGraphicsSceneDragDropEvent *event);
140 void populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
141 QDropEvent *source);
142
143 QTransform mapToViewTransform(const QGraphicsItem *item) const;
144 QRect mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const;
145 QRegion mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const;
146 QRegion dirtyRegion;
147 QRect dirtyBoundingRect;
148 void processPendingUpdates();
149 inline void updateAll()
150 {
151 viewport->update();
152 fullUpdatePending = true;
153 dirtyBoundingRect = QRect();
154 dirtyRegion = QRegion();
155 }
156
157 inline void dispatchPendingUpdateRequests()
158 {
159 if (qt_widget_private(viewport)->shouldPaintOnScreen())
160 QCoreApplication::sendPostedEvents(viewport, QEvent::UpdateRequest);
161 else
162 QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest);
163 }
164
165 void setUpdateClip(QGraphicsItem *);
166
167 inline bool updateRectF(const QRectF &rect)
168 {
169 if (rect.isEmpty())
170 return false;
171 if (optimizationFlags & QGraphicsView::DontAdjustForAntialiasing)
172 return updateRect(rect.toAlignedRect().adjusted(-1, -1, 1, 1));
173 return updateRect(rect.toAlignedRect().adjusted(-2, -2, 2, 2));
174 }
175
176 bool updateRect(const QRect &rect);
177 bool updateRegion(const QRectF &rect, const QTransform &xform);
178 bool updateSceneSlotReimplementedChecked;
179 QRegion exposedRegion;
180
181 QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems,
182 const QTransform &viewTransform) const;
183
184 QPointF mapToScene(const QPointF &point) const;
185 QRectF mapToScene(const QRectF &rect) const;
186 static void translateTouchEvent(QGraphicsViewPrivate *d, QTouchEvent *touchEvent);
187 void updateInputMethodSensitivity();
188};
189
190QT_END_NAMESPACE
191
192#endif
The QAbstractGraphicsShapeItem class provides a common base for all path items.
The QGraphicsEllipseItem class provides an ellipse item that you can add to a QGraphicsScene.
QHash< const QGraphicsItem *, QMap< int, QVariant > > data
The QGraphicsItemGroup class provides a container that treats a group of items as a single item.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
The QGraphicsLineItem class provides a line item that you can add to a QGraphicsScene.
The QGraphicsObject class provides a base class for all graphics items that require signals,...
QGraphicsPixmapItem::ShapeMode shapeMode
Qt::TransformationMode transformationMode
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.
The QGraphicsPolygonItem class provides a polygon item that you can add to a QGraphicsScene.
The QGraphicsRectItem class provides a rectangle item that you can add to a QGraphicsScene.
The QGraphicsSceneContextMenuEvent class provides context menu events in the graphics view framework.
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framewor...
The QGraphicsSceneEvent class provides a base class for all graphics view related events.
The QGraphicsSceneHelpEvent class provides events when a tooltip is requested.
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
The QGraphicsSceneMoveEvent class provides events for widget moving in the graphics view framework.
The QGraphicsSceneResizeEvent class provides events for widget resizing in the graphics view framewor...
The QGraphicsSceneWheelEvent class provides wheel events in the graphics view framework.
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
The QGraphicsSimpleTextItem class provides a simple text item that you can add to a QGraphicsScene.
void _q_updateBoundingRect(const QSizeF &)
bool _q_mouseOnEdge(QGraphicsSceneMouseEvent *)
QWidgetTextControl * control
QWidgetTextControl * textControl() const
void sendControlEvent(QEvent *e)
The QGraphicsTextItem class provides a text item that you can add to a QGraphicsScene to display form...
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
friend class QPainter
\inmodule QtGui
friend class QWidget
Definition qpainter.h:431
\inmodule QtCore\reentrant
Definition qpoint.h:231
The QPolygonF class provides a list of points using floating point precision.
Definition qpolygon.h:96
QT_REQUIRE_CONFIG(animation)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2568
static void formatGraphicsItemHelper(QDebug debug, const QGraphicsItem *item)
bool _qt_movableAncestorIsSelected(const QGraphicsItem *item)
static QRectF setupTextLayout(QTextLayout *layout)
QDebug operator<<(QDebug debug, const QGraphicsObject *item)
static QPainterPath qt_graphicsItem_shapeFromPath(const QPainterPath &path, const QPen &pen)
QDebug operator<<(QDebug debug, const QGraphicsItem *item)
static bool qt_QGraphicsItem_isObscured(const QGraphicsItem *item, const QGraphicsItem *other, const QRectF &rect)
QT_REQUIRE_CONFIG(graphicsview)
static QRectF adjustedItemBoundingRect(const QGraphicsItem *item)
static QRectF adjustedItemEffectiveBoundingRect(const QGraphicsItem *item)
static void _q_adjustRect(QRectF *rect)
QDebug operator<<(QDebug debug, QIODevice::OpenMode modes)