Qt 4.8
qgraphicsview_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QGRAPHICSVIEW_P_H
43 #define QGRAPHICSVIEW_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists for the convenience
50 // of other Qt classes. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include "qgraphicsview.h"
57 
58 #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
59 
60 #include <QtGui/qevent.h>
61 #include <QtCore/qcoreapplication.h>
62 #include "qgraphicssceneevent.h"
63 #include <QtGui/qstyleoption.h>
64 #include <private/qabstractscrollarea_p.h>
65 #include <private/qapplication_p.h>
66 
68 
70 {
72 public:
74 
75  void recalculateContentSize();
76  void centerView(QGraphicsView::ViewportAnchor anchor);
77 
78  QPainter::RenderHints renderHints;
79 
81 
97 
99  void updateLastCenterPoint();
100 
101  qint64 horizontalScroll() const;
102  qint64 verticalScroll() const;
103 
104  QRectF mapRectToScene(const QRect &rect) const;
105  QRectF mapRectFromScene(const QRectF &rect) const;
106 
117  qint64 scrollX, scrollY;
118  void updateScroll();
119 
122 
123  // Replaying mouse events
125  void replayLastMouseEvent();
126  void storeMouseEvent(QMouseEvent *event);
127  void mouseMoveEventHandler(QMouseEvent *event);
128 
130  Qt::Alignment alignment;
131 
135  QGraphicsView::OptimizationFlags optimizationFlags;
136 
138 #ifndef QT_NO_RUBBERBAND
140  QRegion rubberBandRegion(const QWidget *widget, const QRect &rect) const;
143 #endif
145 
146  QGraphicsView::CacheMode cacheMode;
147 
149  QStyleOptionGraphicsItem *allocStyleOptionsArray(int numItems);
150  void freeStyleOptionsArray(QStyleOptionGraphicsItem *array);
151 
156 
157 #ifndef QT_NO_CURSOR
160  void _q_setViewportCursor(const QCursor &cursor);
161  void _q_unsetViewportCursor();
162 #endif
163 
165  void storeDragDropEvent(const QGraphicsSceneDragDropEvent *event);
166  void populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
167  QDropEvent *source);
168 
169  QRect mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const;
170  QRegion mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const;
173  void processPendingUpdates();
174  inline void updateAll()
175  {
176  viewport->update();
177  fullUpdatePending = true;
178  dirtyBoundingRect = QRect();
179  dirtyRegion = QRegion();
180  }
181 
183  {
184 #ifdef Q_WS_MAC
185  // QWidget::update() works slightly different on the Mac without the raster engine;
186  // it's not part of our backing store so it needs special threatment.
188  // At this point either HIViewSetNeedsDisplay (Carbon) or setNeedsDisplay: YES (Cocoa)
189  // is called, which means there's a pending update request. We want to dispatch it
190  // now because otherwise graphics view updates would require two
191  // round-trips in the event loop before the item is painted.
193  qt_mac_dispatchPendingUpdateRequests(viewport->window());
194  } else
195 #endif // !Q_WS_MAC
196  {
197  if (qt_widget_private(viewport)->paintOnScreen())
199  else
201  }
202  }
203 
204  void setUpdateClip(QGraphicsItem *);
205 
206  inline bool updateRectF(const QRectF &rect)
207  {
208  if (rect.isEmpty())
209  return false;
210  if (optimizationFlags & QGraphicsView::DontAdjustForAntialiasing)
211  return updateRect(rect.toAlignedRect().adjusted(-1, -1, 1, 1));
212  return updateRect(rect.toAlignedRect().adjusted(-2, -2, 2, 2));
213  }
214 
215  bool updateRect(const QRect &rect);
216  bool updateRegion(const QRectF &rect, const QTransform &xform);
219 
220  QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems,
221  const QTransform &viewTransform) const;
222 
223  QPointF mapToScene(const QPointF &point) const;
224  QRectF mapToScene(const QRectF &rect) const;
225  static void translateTouchEvent(QGraphicsViewPrivate *d, QTouchEvent *touchEvent);
226  void updateInputMethodSensitivity();
227 };
228 
230 
231 #endif // QT_NO_GRAPHICSVIEW
232 
233 #endif
double d
Definition: qnumeric_p.h:62
QRect toAlignedRect() const
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle...
Definition: qrect.cpp:2817
bool updateRectF(const QRectF &rect)
DragMode
This enum describes the default action for the view when pressing and dragging the mouse over the vie...
Definition: qgraphicsview.h:98
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
double qreal
Definition: qglobal.h:1193
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QGraphicsView::CacheMode cacheMode
EventRef event
QPointer< QWidget > widget
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
bool paintOnScreen() const
Definition: qwidget.cpp:2255
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QMouseEvent lastMouseEvent
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void qt_mac_dispatchPendingUpdateRequests(QWidget *widget)
ItemSelectionMode
Definition: qnamespace.h:1503
bool updateSceneSlotReimplementedChecked
QVector< QStyleOptionGraphicsItem > styleOptions
QPainter::RenderHints renderHints
QGraphicsView::ViewportAnchor transformationAnchor
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QGraphicsView::ViewportUpdateMode viewportUpdateMode
static void sendPostedEvents()
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
__int64 qint64
Definition: qglobal.h:942
static QString graphics_system_name
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
Definition: qevent.h:476
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framewor...
Qt::Alignment alignment
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void dispatchPendingUpdateRequests()
unsigned int quint32
Definition: qglobal.h:938
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Qt::MouseButton mousePressButton
QGraphicsView::DragMode dragMode
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
QGraphicsView::OptimizationFlags optimizationFlags
The QTouchEvent class contains parameters that describe a touch event.
Definition: qevent.h:741
quint32 mustResizeBackgroundPixmap
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
QGraphicsSceneDragDropEvent * lastDragDropEvent
QTouchEventSequence touchEvent(QWidget *widget=0, QTouchEvent::DeviceType deviceType=QTouchEvent::TouchScreen)
Creates and returns a QTouchEventSequence for the device deviceType to simulate events for widget...
Definition: qtesttouch.h:141
quint32 mustAllocateStyleOptions
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:658
QPointer< QGraphicsScene > scene
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem...
Definition: qstyleoption.h:867
Qt::ItemSelectionMode rubberBandSelectionMode
QGraphicsView::ViewportAnchor resizeAnchor
ViewportUpdateMode
This enum describes how QGraphicsView updates its viewport when the scene contents change or are expo...
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
ViewportAnchor
This enums describe the possible anchors that QGraphicsView can use when the user resizes the view or...
Definition: qgraphicsview.h:86
MouseButton
Definition: qnamespace.h:150