| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** 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 are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com.
|
|---|
| 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 qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
|
|---|
| 51 | // file may change from version to 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 "qgraphicssceneevent.h"
|
|---|
| 62 | #include <private/qabstractscrollarea_p.h>
|
|---|
| 63 |
|
|---|
| 64 | QT_BEGIN_NAMESPACE
|
|---|
| 65 |
|
|---|
| 66 | class Q_GUI_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
|
|---|
| 67 | {
|
|---|
| 68 | Q_DECLARE_PUBLIC(QGraphicsView)
|
|---|
| 69 | public:
|
|---|
| 70 | QGraphicsViewPrivate();
|
|---|
| 71 |
|
|---|
| 72 | void recalculateContentSize();
|
|---|
| 73 | void centerView(QGraphicsView::ViewportAnchor anchor);
|
|---|
| 74 |
|
|---|
| 75 | QPainter::RenderHints renderHints;
|
|---|
| 76 |
|
|---|
| 77 | QGraphicsView::DragMode dragMode;
|
|---|
| 78 | bool sceneInteractionAllowed;
|
|---|
| 79 | QRectF sceneRect;
|
|---|
| 80 | bool hasSceneRect;
|
|---|
| 81 | void updateLastCenterPoint();
|
|---|
| 82 | bool connectedToScene;
|
|---|
| 83 |
|
|---|
| 84 | qint64 horizontalScroll() const;
|
|---|
| 85 | qint64 verticalScroll() const;
|
|---|
| 86 |
|
|---|
| 87 | QList<QGraphicsItem *> itemsInArea(const QPainterPath &path,
|
|---|
| 88 | Qt::ItemSelectionMode mode = Qt::IntersectsItemShape,
|
|---|
| 89 | Qt::SortOrder = Qt::AscendingOrder) const;
|
|---|
| 90 |
|
|---|
| 91 | QPointF mousePressItemPoint;
|
|---|
| 92 | QPointF mousePressScenePoint;
|
|---|
| 93 | QPoint mousePressViewPoint;
|
|---|
| 94 | QPoint mousePressScreenPoint;
|
|---|
| 95 | QPointF lastMouseMoveScenePoint;
|
|---|
| 96 | QPoint lastMouseMoveScreenPoint;
|
|---|
| 97 | Qt::MouseButton mousePressButton;
|
|---|
| 98 | QTransform matrix;
|
|---|
| 99 | bool identityMatrix;
|
|---|
| 100 | qint64 scrollX, scrollY;
|
|---|
| 101 | bool dirtyScroll;
|
|---|
| 102 | void updateScroll();
|
|---|
| 103 |
|
|---|
| 104 | bool accelerateScrolling;
|
|---|
| 105 | qreal leftIndent;
|
|---|
| 106 | qreal topIndent;
|
|---|
| 107 |
|
|---|
| 108 | // Replaying mouse events
|
|---|
| 109 | QMouseEvent lastMouseEvent;
|
|---|
| 110 | bool useLastMouseEvent;
|
|---|
| 111 | void replayLastMouseEvent();
|
|---|
| 112 | void storeMouseEvent(QMouseEvent *event);
|
|---|
| 113 | void mouseMoveEventHandler(QMouseEvent *event);
|
|---|
| 114 |
|
|---|
| 115 | QPointF lastCenterPoint;
|
|---|
| 116 | bool keepLastCenterPoint;
|
|---|
| 117 | Qt::Alignment alignment;
|
|---|
| 118 | bool transforming;
|
|---|
| 119 |
|
|---|
| 120 | QGraphicsView::ViewportAnchor transformationAnchor;
|
|---|
| 121 | QGraphicsView::ViewportAnchor resizeAnchor;
|
|---|
| 122 | QGraphicsView::ViewportUpdateMode viewportUpdateMode;
|
|---|
| 123 | QGraphicsView::OptimizationFlags optimizationFlags;
|
|---|
| 124 |
|
|---|
| 125 | QPointer<QGraphicsScene> scene;
|
|---|
| 126 | #ifndef QT_NO_RUBBERBAND
|
|---|
| 127 | QRect rubberBandRect;
|
|---|
| 128 | QRegion rubberBandRegion(const QWidget *widget, const QRect &rect) const;
|
|---|
| 129 | bool rubberBanding;
|
|---|
| 130 | Qt::ItemSelectionMode rubberBandSelectionMode;
|
|---|
| 131 | #endif
|
|---|
| 132 | bool handScrolling;
|
|---|
| 133 | int handScrollMotions;
|
|---|
| 134 |
|
|---|
| 135 | QGraphicsView::CacheMode cacheMode;
|
|---|
| 136 |
|
|---|
| 137 | QVector<QStyleOptionGraphicsItem> styleOptions;
|
|---|
| 138 | bool mustAllocateStyleOptions;
|
|---|
| 139 | QStyleOptionGraphicsItem *allocStyleOptionsArray(int numItems);
|
|---|
| 140 | void freeStyleOptionsArray(QStyleOptionGraphicsItem *array);
|
|---|
| 141 |
|
|---|
| 142 | QBrush backgroundBrush;
|
|---|
| 143 | QBrush foregroundBrush;
|
|---|
| 144 | QPixmap backgroundPixmap;
|
|---|
| 145 | bool mustResizeBackgroundPixmap;
|
|---|
| 146 | QRegion backgroundPixmapExposed;
|
|---|
| 147 |
|
|---|
| 148 | #ifndef QT_NO_CURSOR
|
|---|
| 149 | QCursor originalCursor;
|
|---|
| 150 | bool hasStoredOriginalCursor;
|
|---|
| 151 | void _q_setViewportCursor(const QCursor &cursor);
|
|---|
| 152 | void _q_unsetViewportCursor();
|
|---|
| 153 | #endif
|
|---|
| 154 |
|
|---|
| 155 | QGraphicsSceneDragDropEvent *lastDragDropEvent;
|
|---|
| 156 | void storeDragDropEvent(const QGraphicsSceneDragDropEvent *event);
|
|---|
| 157 | void populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
|
|---|
| 158 | QDropEvent *source);
|
|---|
| 159 |
|
|---|
| 160 | QRect mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const;
|
|---|
| 161 | QRegion mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const;
|
|---|
| 162 | void itemUpdated(QGraphicsItem *item, const QRectF &rect);
|
|---|
| 163 | bool fullUpdatePending;
|
|---|
| 164 | QList<QRect> dirtyRects;
|
|---|
| 165 | QList<QRegion> dirtyRegions;
|
|---|
| 166 | int dirtyRectCount;
|
|---|
| 167 | QRect dirtyBoundingRect;
|
|---|
| 168 | void updateLater();
|
|---|
| 169 | bool updatingLater;
|
|---|
| 170 | void _q_updateLaterSlot();
|
|---|
| 171 | void updateAll();
|
|---|
| 172 | void updateRect(const QRect &rect);
|
|---|
| 173 | void updateRegion(const QRegion ®ion);
|
|---|
| 174 | bool updateSceneSlotReimplementedChecked;
|
|---|
| 175 |
|
|---|
| 176 | QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems) const;
|
|---|
| 177 |
|
|---|
| 178 | void generateStyleOptions(const QList<QGraphicsItem *> &itemList,
|
|---|
| 179 | QGraphicsItem **itemArray,
|
|---|
| 180 | QStyleOptionGraphicsItem *styleOptionArray,
|
|---|
| 181 | const QTransform &worldTransform,
|
|---|
| 182 | bool allItems,
|
|---|
| 183 | const QRegion &exposedRegion) const;
|
|---|
| 184 | };
|
|---|
| 185 |
|
|---|
| 186 | QT_END_NAMESPACE
|
|---|
| 187 |
|
|---|
| 188 | #endif // QT_NO_GRAPHICSVIEW
|
|---|
| 189 |
|
|---|
| 190 | #endif
|
|---|