source: trunk/src/gui/graphicsview/qgraphicsview_p.h@ 769

Last change on this file since 769 was 769, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

File size: 7.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
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
66QT_BEGIN_NAMESPACE
67
68class Q_AUTOTEST_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
69{
70 Q_DECLARE_PUBLIC(QGraphicsView)
71public:
72 QGraphicsViewPrivate();
73
74 void recalculateContentSize();
75 void centerView(QGraphicsView::ViewportAnchor anchor);
76
77 QPainter::RenderHints renderHints;
78
79 QGraphicsView::DragMode dragMode;
80 bool sceneInteractionAllowed;
81 QRectF sceneRect;
82 bool hasSceneRect;
83 void updateLastCenterPoint();
84 bool connectedToScene;
85
86 qint64 horizontalScroll() const;
87 qint64 verticalScroll() const;
88
89 QRectF mapRectToScene(const QRect &rect) const;
90 QRectF mapRectFromScene(const QRectF &rect) const;
91
92 QPointF mousePressItemPoint;
93 QPointF mousePressScenePoint;
94 QPoint mousePressViewPoint;
95 QPoint mousePressScreenPoint;
96 QPointF lastMouseMoveScenePoint;
97 QPoint lastMouseMoveScreenPoint;
98 QPoint dirtyScrollOffset;
99 Qt::MouseButton mousePressButton;
100 QTransform matrix;
101 bool identityMatrix;
102 qint64 scrollX, scrollY;
103 bool dirtyScroll;
104 void updateScroll();
105
106 bool accelerateScrolling;
107 qreal leftIndent;
108 qreal topIndent;
109
110 // Replaying mouse events
111 QMouseEvent lastMouseEvent;
112 bool useLastMouseEvent;
113 void replayLastMouseEvent();
114 void storeMouseEvent(QMouseEvent *event);
115 void mouseMoveEventHandler(QMouseEvent *event);
116
117 QPointF lastCenterPoint;
118 bool keepLastCenterPoint;
119 Qt::Alignment alignment;
120 bool transforming;
121
122 QGraphicsView::ViewportAnchor transformationAnchor;
123 QGraphicsView::ViewportAnchor resizeAnchor;
124 QGraphicsView::ViewportUpdateMode viewportUpdateMode;
125 QGraphicsView::OptimizationFlags optimizationFlags;
126
127 QPointer<QGraphicsScene> scene;
128#ifndef QT_NO_RUBBERBAND
129 QRect rubberBandRect;
130 QRegion rubberBandRegion(const QWidget *widget, const QRect &rect) const;
131 bool rubberBanding;
132 Qt::ItemSelectionMode rubberBandSelectionMode;
133#endif
134 bool handScrolling;
135 int handScrollMotions;
136
137 QGraphicsView::CacheMode cacheMode;
138
139 QVector<QStyleOptionGraphicsItem> styleOptions;
140 bool mustAllocateStyleOptions;
141 QStyleOptionGraphicsItem *allocStyleOptionsArray(int numItems);
142 void freeStyleOptionsArray(QStyleOptionGraphicsItem *array);
143
144 QBrush backgroundBrush;
145 QBrush foregroundBrush;
146 QPixmap backgroundPixmap;
147 bool mustResizeBackgroundPixmap;
148 QRegion backgroundPixmapExposed;
149
150#ifndef QT_NO_CURSOR
151 QCursor originalCursor;
152 bool hasStoredOriginalCursor;
153 void _q_setViewportCursor(const QCursor &cursor);
154 void _q_unsetViewportCursor();
155#endif
156
157 QGraphicsSceneDragDropEvent *lastDragDropEvent;
158 void storeDragDropEvent(const QGraphicsSceneDragDropEvent *event);
159 void populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
160 QDropEvent *source);
161
162 QRect mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const;
163 QRegion mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const;
164 bool fullUpdatePending;
165 QRegion dirtyRegion;
166 QRect dirtyBoundingRect;
167 void processPendingUpdates();
168 inline void updateAll()
169 {
170 viewport->update();
171 fullUpdatePending = true;
172 dirtyBoundingRect = QRect();
173 dirtyRegion = QRegion();
174 }
175
176 inline void dispatchPendingUpdateRequests()
177 {
178#ifndef Q_WS_MAC
179 // QWidget::update() works slightly different on the Mac; it's not part of
180 // our backing store so it needs special threatment.
181 if (qt_widget_private(viewport)->paintOnScreen())
182 QCoreApplication::sendPostedEvents(viewport, QEvent::UpdateRequest);
183 else
184 QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest);
185#else
186 // At this point either HIViewSetNeedsDisplay (Carbon) or setNeedsDisplay: YES (Cocoa)
187 // is called, which means there's a pending update request. We want to dispatch it
188 // now because otherwise graphics view updates would require two
189 // round-trips in the event loop before the item is painted.
190 extern void qt_mac_dispatchPendingUpdateRequests(QWidget *);
191 qt_mac_dispatchPendingUpdateRequests(viewport->window());
192#endif
193 }
194
195 bool updateRect(const QRect &rect);
196 bool updateRegion(const QRegion &region);
197 bool updateSceneSlotReimplementedChecked;
198 QRegion exposedRegion;
199
200 QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems,
201 const QTransform &viewTransform) const;
202
203 QPointF mapToScene(const QPointF &point) const;
204 QRectF mapToScene(const QRectF &rect) const;
205 static void translateTouchEvent(QGraphicsViewPrivate *d, QTouchEvent *touchEvent);
206 void updateInputMethodSensitivity();
207};
208
209QT_END_NAMESPACE
210
211#endif // QT_NO_GRAPHICSVIEW
212
213#endif
Note: See TracBrowser for help on using the repository browser.