src/gui/graphicsview/qgraphicsview_p.h
changeset 30 5dc02b23752f
parent 23 89e065397ea6
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
    63 #include <QtGui/qstyleoption.h>
    63 #include <QtGui/qstyleoption.h>
    64 #include <private/qabstractscrollarea_p.h>
    64 #include <private/qabstractscrollarea_p.h>
    65 
    65 
    66 QT_BEGIN_NAMESPACE
    66 QT_BEGIN_NAMESPACE
    67 
    67 
    68 class Q_AUTOTEST_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
    68 class Q_GUI_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
    69 {
    69 {
    70     Q_DECLARE_PUBLIC(QGraphicsView)
    70     Q_DECLARE_PUBLIC(QGraphicsView)
    71 public:
    71 public:
    72     QGraphicsViewPrivate();
    72     QGraphicsViewPrivate();
    73 
    73 
    75     void centerView(QGraphicsView::ViewportAnchor anchor);
    75     void centerView(QGraphicsView::ViewportAnchor anchor);
    76 
    76 
    77     QPainter::RenderHints renderHints;
    77     QPainter::RenderHints renderHints;
    78 
    78 
    79     QGraphicsView::DragMode dragMode;
    79     QGraphicsView::DragMode dragMode;
    80     bool sceneInteractionAllowed;
    80 
       
    81     quint32 sceneInteractionAllowed : 1;
       
    82     quint32 hasSceneRect : 1;
       
    83     quint32 connectedToScene : 1;
       
    84     quint32 useLastMouseEvent : 1;
       
    85     quint32 identityMatrix : 1;
       
    86     quint32 dirtyScroll : 1;
       
    87     quint32 accelerateScrolling : 1;
       
    88     quint32 keepLastCenterPoint : 1;
       
    89     quint32 transforming : 1;
       
    90     quint32 handScrolling : 1;
       
    91     quint32 mustAllocateStyleOptions : 1;
       
    92     quint32 mustResizeBackgroundPixmap : 1;
       
    93     quint32 fullUpdatePending : 1;
       
    94     quint32 hasUpdateClip : 1;
       
    95     quint32 padding : 18;
       
    96 
    81     QRectF sceneRect;
    97     QRectF sceneRect;
    82     bool hasSceneRect;
       
    83     void updateLastCenterPoint();
    98     void updateLastCenterPoint();
    84     bool connectedToScene;
       
    85 
    99 
    86     qint64 horizontalScroll() const;
   100     qint64 horizontalScroll() const;
    87     qint64 verticalScroll() const;
   101     qint64 verticalScroll() const;
    88 
   102 
    89     QRectF mapRectToScene(const QRect &rect) const;
   103     QRectF mapRectToScene(const QRect &rect) const;
    90     QRectF mapRectFromScene(const QRectF &rect) const;
   104     QRectF mapRectFromScene(const QRectF &rect) const;
    91 
   105 
       
   106     QRect updateClip;
    92     QPointF mousePressItemPoint;
   107     QPointF mousePressItemPoint;
    93     QPointF mousePressScenePoint;
   108     QPointF mousePressScenePoint;
    94     QPoint mousePressViewPoint;
   109     QPoint mousePressViewPoint;
    95     QPoint mousePressScreenPoint;
   110     QPoint mousePressScreenPoint;
    96     QPointF lastMouseMoveScenePoint;
   111     QPointF lastMouseMoveScenePoint;
    97     QPoint lastMouseMoveScreenPoint;
   112     QPoint lastMouseMoveScreenPoint;
    98     QPoint dirtyScrollOffset;
   113     QPoint dirtyScrollOffset;
    99     Qt::MouseButton mousePressButton;
   114     Qt::MouseButton mousePressButton;
   100     QTransform matrix;
   115     QTransform matrix;
   101     bool identityMatrix;
       
   102     qint64 scrollX, scrollY;
   116     qint64 scrollX, scrollY;
   103     bool dirtyScroll;
       
   104     void updateScroll();
   117     void updateScroll();
   105 
   118 
   106     bool accelerateScrolling;
       
   107     qreal leftIndent;
   119     qreal leftIndent;
   108     qreal topIndent;
   120     qreal topIndent;
   109 
   121 
   110     // Replaying mouse events
   122     // Replaying mouse events
   111     QMouseEvent lastMouseEvent;
   123     QMouseEvent lastMouseEvent;
   112     bool useLastMouseEvent;
       
   113     void replayLastMouseEvent();
   124     void replayLastMouseEvent();
   114     void storeMouseEvent(QMouseEvent *event);
   125     void storeMouseEvent(QMouseEvent *event);
   115     void mouseMoveEventHandler(QMouseEvent *event);
   126     void mouseMoveEventHandler(QMouseEvent *event);
   116 
   127 
   117     QPointF lastCenterPoint;
   128     QPointF lastCenterPoint;
   118     bool keepLastCenterPoint;
       
   119     Qt::Alignment alignment;
   129     Qt::Alignment alignment;
   120     bool transforming;
       
   121 
   130 
   122     QGraphicsView::ViewportAnchor transformationAnchor;
   131     QGraphicsView::ViewportAnchor transformationAnchor;
   123     QGraphicsView::ViewportAnchor resizeAnchor;
   132     QGraphicsView::ViewportAnchor resizeAnchor;
   124     QGraphicsView::ViewportUpdateMode viewportUpdateMode;
   133     QGraphicsView::ViewportUpdateMode viewportUpdateMode;
   125     QGraphicsView::OptimizationFlags optimizationFlags;
   134     QGraphicsView::OptimizationFlags optimizationFlags;
   129     QRect rubberBandRect;
   138     QRect rubberBandRect;
   130     QRegion rubberBandRegion(const QWidget *widget, const QRect &rect) const;
   139     QRegion rubberBandRegion(const QWidget *widget, const QRect &rect) const;
   131     bool rubberBanding;
   140     bool rubberBanding;
   132     Qt::ItemSelectionMode rubberBandSelectionMode;
   141     Qt::ItemSelectionMode rubberBandSelectionMode;
   133 #endif
   142 #endif
   134     bool handScrolling;
       
   135     int handScrollMotions;
   143     int handScrollMotions;
   136 
   144 
   137     QGraphicsView::CacheMode cacheMode;
   145     QGraphicsView::CacheMode cacheMode;
   138 
   146 
   139     QVector<QStyleOptionGraphicsItem> styleOptions;
   147     QVector<QStyleOptionGraphicsItem> styleOptions;
   140     bool mustAllocateStyleOptions;
       
   141     QStyleOptionGraphicsItem *allocStyleOptionsArray(int numItems);
   148     QStyleOptionGraphicsItem *allocStyleOptionsArray(int numItems);
   142     void freeStyleOptionsArray(QStyleOptionGraphicsItem *array);
   149     void freeStyleOptionsArray(QStyleOptionGraphicsItem *array);
   143 
   150 
   144     QBrush backgroundBrush;
   151     QBrush backgroundBrush;
   145     QBrush foregroundBrush;
   152     QBrush foregroundBrush;
   146     QPixmap backgroundPixmap;
   153     QPixmap backgroundPixmap;
   147     bool mustResizeBackgroundPixmap;
       
   148     QRegion backgroundPixmapExposed;
   154     QRegion backgroundPixmapExposed;
   149 
   155 
   150 #ifndef QT_NO_CURSOR
   156 #ifndef QT_NO_CURSOR
   151     QCursor originalCursor;
   157     QCursor originalCursor;
   152     bool hasStoredOriginalCursor;
   158     bool hasStoredOriginalCursor;
   159     void populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
   165     void populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
   160                                     QDropEvent *source);
   166                                     QDropEvent *source);
   161 
   167 
   162     QRect mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const;
   168     QRect mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const;
   163     QRegion mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const;
   169     QRegion mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const;
   164     bool fullUpdatePending;
       
   165     QRegion dirtyRegion;
   170     QRegion dirtyRegion;
   166     QRect dirtyBoundingRect;
   171     QRect dirtyBoundingRect;
   167     void processPendingUpdates();
   172     void processPendingUpdates();
   168     inline void updateAll()
   173     inline void updateAll()
   169     {
   174     {
   190         extern void qt_mac_dispatchPendingUpdateRequests(QWidget *);
   195         extern void qt_mac_dispatchPendingUpdateRequests(QWidget *);
   191         qt_mac_dispatchPendingUpdateRequests(viewport->window());
   196         qt_mac_dispatchPendingUpdateRequests(viewport->window());
   192 #endif
   197 #endif
   193     }
   198     }
   194 
   199 
       
   200     void setUpdateClip(QGraphicsItem *);
       
   201 
       
   202     inline bool updateRectF(const QRectF &rect)
       
   203     {
       
   204         if (rect.isEmpty())
       
   205             return false;
       
   206         if (optimizationFlags & QGraphicsView::DontAdjustForAntialiasing)
       
   207             return updateRect(rect.toAlignedRect().adjusted(-1, -1, 1, 1));
       
   208         return updateRect(rect.toAlignedRect().adjusted(-2, -2, 2, 2));
       
   209     }
       
   210 
   195     bool updateRect(const QRect &rect);
   211     bool updateRect(const QRect &rect);
   196     bool updateRegion(const QRegion &region);
   212     bool updateRegion(const QRectF &rect, const QTransform &xform);
   197     bool updateSceneSlotReimplementedChecked;
   213     bool updateSceneSlotReimplementedChecked;
   198     QRegion exposedRegion;
   214     QRegion exposedRegion;
   199 
   215 
   200     QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems,
   216     QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems,
   201                                      const QTransform &viewTransform) const;
   217                                      const QTransform &viewTransform) const;