src/gui/graphicsview/qgraphicsview_p.h
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    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 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    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 
       
    66 QT_BEGIN_NAMESPACE
       
    67 
       
    68 class Q_AUTOTEST_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
       
    69 {
       
    70     Q_DECLARE_PUBLIC(QGraphicsView)
       
    71 public:
       
    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     QPointF mousePressItemPoint;
       
    90     QPointF mousePressScenePoint;
       
    91     QPoint mousePressViewPoint;
       
    92     QPoint mousePressScreenPoint;
       
    93     QPointF lastMouseMoveScenePoint;
       
    94     QPoint lastMouseMoveScreenPoint;
       
    95     QPoint dirtyScrollOffset;
       
    96     Qt::MouseButton mousePressButton;
       
    97     QTransform matrix;
       
    98     bool identityMatrix;
       
    99     qint64 scrollX, scrollY;
       
   100     bool dirtyScroll;
       
   101     void updateScroll();
       
   102 
       
   103     bool accelerateScrolling;
       
   104     qreal leftIndent;
       
   105     qreal topIndent;
       
   106 
       
   107     // Replaying mouse events
       
   108     QMouseEvent lastMouseEvent;
       
   109     bool useLastMouseEvent;
       
   110     void replayLastMouseEvent();
       
   111     void storeMouseEvent(QMouseEvent *event);
       
   112     void mouseMoveEventHandler(QMouseEvent *event);
       
   113 
       
   114     QPointF lastCenterPoint;
       
   115     bool keepLastCenterPoint;
       
   116     Qt::Alignment alignment;
       
   117     bool transforming;
       
   118 
       
   119     QGraphicsView::ViewportAnchor transformationAnchor;
       
   120     QGraphicsView::ViewportAnchor resizeAnchor;
       
   121     QGraphicsView::ViewportUpdateMode viewportUpdateMode;
       
   122     QGraphicsView::OptimizationFlags optimizationFlags;
       
   123 
       
   124     QPointer<QGraphicsScene> scene;
       
   125 #ifndef QT_NO_RUBBERBAND
       
   126     QRect rubberBandRect;
       
   127     QRegion rubberBandRegion(const QWidget *widget, const QRect &rect) const;
       
   128     bool rubberBanding;
       
   129     Qt::ItemSelectionMode rubberBandSelectionMode;
       
   130 #endif
       
   131     bool handScrolling;
       
   132     int handScrollMotions;
       
   133 
       
   134     QGraphicsView::CacheMode cacheMode;
       
   135 
       
   136     QVector<QStyleOptionGraphicsItem> styleOptions;
       
   137     bool mustAllocateStyleOptions;
       
   138     QStyleOptionGraphicsItem *allocStyleOptionsArray(int numItems);
       
   139     void freeStyleOptionsArray(QStyleOptionGraphicsItem *array);
       
   140 
       
   141     QBrush backgroundBrush;
       
   142     QBrush foregroundBrush;
       
   143     QPixmap backgroundPixmap;
       
   144     bool mustResizeBackgroundPixmap;
       
   145     QRegion backgroundPixmapExposed;
       
   146 
       
   147 #ifndef QT_NO_CURSOR
       
   148     QCursor originalCursor;
       
   149     bool hasStoredOriginalCursor;
       
   150     void _q_setViewportCursor(const QCursor &cursor);
       
   151     void _q_unsetViewportCursor();
       
   152 #endif
       
   153 
       
   154     QGraphicsSceneDragDropEvent *lastDragDropEvent;
       
   155     void storeDragDropEvent(const QGraphicsSceneDragDropEvent *event);
       
   156     void populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
       
   157                                     QDropEvent *source);
       
   158 
       
   159     QRect mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const;
       
   160     QRegion mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const;
       
   161     bool fullUpdatePending;
       
   162     QRegion dirtyRegion;
       
   163     QRect dirtyBoundingRect;
       
   164     void processPendingUpdates();
       
   165     inline void updateAll()
       
   166     {
       
   167         viewport->update();
       
   168         fullUpdatePending = true;
       
   169         dirtyBoundingRect = QRect();
       
   170         dirtyRegion = QRegion();
       
   171     }
       
   172 
       
   173     inline void dispatchPendingUpdateRequests()
       
   174     {
       
   175         if (qt_widget_private(viewport)->paintOnScreen())
       
   176             QCoreApplication::sendPostedEvents(viewport, QEvent::UpdateRequest);
       
   177         else
       
   178             QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest);
       
   179     }
       
   180 
       
   181     bool updateRect(const QRect &rect);
       
   182     bool updateRegion(const QRegion &region);
       
   183     bool updateSceneSlotReimplementedChecked;
       
   184     QRegion exposedRegion;
       
   185 
       
   186     QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems,
       
   187                                      const QTransform &viewTransform) const;
       
   188 
       
   189     QPointF mapToScene(const QPointF &point) const;
       
   190     QRectF mapToScene(const QRectF &rect) const;
       
   191     static void translateTouchEvent(QGraphicsViewPrivate *d, QTouchEvent *touchEvent);
       
   192     void updateInputMethodSensitivity();
       
   193 };
       
   194 
       
   195 QT_END_NAMESPACE
       
   196 
       
   197 #endif // QT_NO_GRAPHICSVIEW
       
   198 
       
   199 #endif