Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QGraphicsViewPrivate Class Reference

#include <qgraphicsview_p.h>

Inheritance diagram for QGraphicsViewPrivate:
QAbstractScrollAreaPrivate QFramePrivate QWidgetPrivate QObjectPrivate QObjectData QDeclarativeViewPrivate

Public Functions

void _q_setViewportCursor (const QCursor &cursor)
 
void _q_unsetViewportCursor ()
 
QStyleOptionGraphicsItemallocStyleOptionsArray (int numItems)
 
void centerView (QGraphicsView::ViewportAnchor anchor)
 
void dispatchPendingUpdateRequests ()
 
QList< QGraphicsItem * > findItems (const QRegion &exposedRegion, bool *allItems, const QTransform &viewTransform) const
 

Adjustments in findItems: mapToScene(QRect) forces us to adjust the

input rectangle by (0, 0, 1, 1), because it uses QRect::bottomRight() (etc) when mapping the rectangle to a polygon (which is wrong). More...
 
void freeStyleOptionsArray (QStyleOptionGraphicsItem *array)
 
qint64 horizontalScroll () const
 Returns the horizontal scroll value (the X value of the left edge of the viewport). More...
 
QRectF mapRectFromScene (const QRectF &rect) const
 
QRectF mapRectToScene (const QRect &rect) const
 
QPointF mapToScene (const QPointF &point) const
 
QRectF mapToScene (const QRectF &rect) const
 
QRect mapToViewRect (const QGraphicsItem *item, const QRectF &rect) const
 
QRegion mapToViewRegion (const QGraphicsItem *item, const QRectF &rect) const
 
void mouseMoveEventHandler (QMouseEvent *event)
 
void populateSceneDragDropEvent (QGraphicsSceneDragDropEvent *dest, QDropEvent *source)
 
void processPendingUpdates ()
 
 QGraphicsViewPrivate ()
 
void recalculateContentSize ()
 
void replayLastMouseEvent ()
 
QRegion rubberBandRegion (const QWidget *widget, const QRect &rect) const
 
void setUpdateClip (QGraphicsItem *)
 
void storeDragDropEvent (const QGraphicsSceneDragDropEvent *event)
 
void storeMouseEvent (QMouseEvent *event)
 
void updateAll ()
 
void updateInputMethodSensitivity ()
 Enables input methods for the view if and only if the current focus item of the scene accepts input methods. More...
 
void updateLastCenterPoint ()
 
bool updateRect (const QRect &rect)
 
bool updateRectF (const QRectF &rect)
 
bool updateRegion (const QRectF &rect, const QTransform &xform)
 
void updateScroll ()
 
qint64 verticalScroll () const
 Returns the vertical scroll value (the X value of the top edge of the viewport). More...
 
- Public Functions inherited from QAbstractScrollAreaPrivate
void _q_hslide (int)
 
void _q_showOrHideScrollBars ()
 
void _q_vslide (int)
 
virtual QPoint contentsOffset () const
 
void init ()
 
void layoutChildren ()
 
 QAbstractScrollAreaPrivate ()
 
void replaceScrollBar (QScrollBar *scrollBar, Qt::Orientation orientation)
 
virtual void scrollBarPolicyChanged (Qt::Orientation, Qt::ScrollBarPolicy)
 
void setSingleFingerPanEnabled (bool on=true)
 
bool viewportEvent (QEvent *event)
 
- Public Functions inherited from QFramePrivate
void init ()
 
 QFramePrivate ()
 
void updateFrameWidth ()
 Updated the frameWidth parameter. More...
 
void updateStyledFrameWidths ()
 Updates the frame widths from the style. More...
 
- Public Functions inherited from QWidgetPrivate
void _q_showIfNotHidden ()
 
virtual void aboutToDestroy ()
 
void activateChildLayoutsRecursively ()
 
QSize adjustedSize () const
 
void adjustQuitOnCloseAttribute ()
 
QInputContextassignedInputContext () const
 
QPainterbeginSharedPainter ()
 
QWidgetchildAt_helper (const QPoint &, bool) const
 
QWidgetchildAtRecursiveHelper (const QPoint &p, bool, bool includeFrame=false) const
 
QRect clipRect () const
 
QRegion clipRegion () const
 
void clipToEffectiveMask (QRegion &region) const
 
bool close_helper (CloseMode mode)
 
void create_sys (WId window, bool initializeWindow, bool destroyOldWindow)
 
QWindowSurfacecreateDefaultWindowSurface ()
 
QWindowSurfacecreateDefaultWindowSurface_sys ()
 
void createExtra ()
 Creates the widget extra data. More...
 
void createRecursively ()
 
void createSysExtra ()
 
void createTLExtra ()
 
void createTLSysExtra ()
 
void createWinId (WId id=0)
 
void deactivateWidgetCleanup ()
 
void deleteExtra ()
 Deletes the widget extra data. More...
 
void deleteSysExtra ()
 
void deleteTLSysExtra ()
 
void drawWidget (QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
 
QWidgeteffectiveFocusWidget ()
 
QRect effectiveRectFor (const QRect &rect) const
 
bool endSharedPainter ()
 
void enforceNativeChildren ()
 
QWExtraextraData () const
 
QRect frameStrut () const
 
void getLayoutItemMargins (int *left, int *top, int *right, int *bottom) const
 
const QRegiongetOpaqueChildren () const
 
void handleSoftwareInputPanel (Qt::MouseButton button, bool clickCausedFocus)
 
virtual bool hasHeightForWidth () const
 
void hide_helper ()
 
void hide_sys ()
 Platform-specific part of QWidget::hide(). More...
 
void hideChildren (bool spontaneous)
 
void inheritStyle ()
 
void init (QWidget *desktopWidget, Qt::WindowFlags f)
 
QInputContextinputContext () const
 
void invalidateBuffer (const QRegion &)
 Invalidates the rgn (in widget's coordinates) of the backing store, i.e. More...
 
void invalidateBuffer (const QRect &)
 This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
void invalidateBuffer_resizeHelper (const QPoint &oldPos, const QSize &oldSize)
 Invalidates the buffer when the widget is resized. More...
 
void invalidateGraphicsEffectsRecursively ()
 
bool isAboutToShow () const
 
bool isBackgroundInherited () const
 
bool isOverlapped (const QRect &) const
 
void lower_sys ()
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QWidgetBackingStoremaybeBackingStore () const
 
QTLWExtramaybeTopData () const
 
void moveRect (const QRect &, int dx, int dy)
 
bool nativeChildrenForced () const
 
QFont naturalWidgetFont (uint inheritedMask) const
 
QPalette naturalWidgetPalette (uint inheritedMask) const
 Returns the palette that the widget w inherits from its ancestors and QApplication::palette. More...
 
void paintBackground (QPainter *, const QRegion &, int flags=DrawAsRoot) const
 
bool paintOnScreen () const
 
void paintSiblingsRecursive (QPaintDevice *pdev, const QObjectList &children, int index, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore)
 
bool pointInsideRectAndMask (const QPoint &) const
 
QRegion prepareToRender (const QRegion &region, QWidget::RenderFlags renderFlags)
 
void propagatePaletteChange ()
 Propagate this widget's palette to all children, except style sheet widgets, and windows that don't enable window propagation (palettes don't normally propagate to windows). More...
 
 QWidgetPrivate (int version=QObjectPrivateVersion)
 
void raise_sys ()
 
QPaintDeviceredirected (QPoint *offset) const
 
void registerDropSite (bool)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, bool readyToRender)
 
void render_helper (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint_sys (const QRegion &rgn)
 
void reparentFocusWidgets (QWidget *oldtlw)
 
void resolveFont ()
 Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). More...
 
void resolveLayoutDirection ()
 
void resolveLocale ()
 
void resolvePalette ()
 Determine which palette is inherited from this widget's ancestors and QApplication::palette, resolve this against this widget's palette (attributes from the inherited palette are copied over this widget's palette). More...
 
void restoreRedirected ()
 
void scroll_sys (int dx, int dy)
 
void scroll_sys (int dx, int dy, const QRect &r)
 
void scrollChildren (int dx, int dy)
 
void scrollRect (const QRect &, int dx, int dy)
 
void sendPendingMoveAndResizeEvents (bool recursive=false, bool disableUpdates=false)
 
void sendStartupMessage (const char *message) const
 Platform-specific part of QWidget::show(). More...
 
void setConstraints_sys ()
 
void setCursor_sys (const QCursor &cursor)
 
void setDirtyOpaqueRegion ()
 
void setEnabled_helper (bool)
 
void setFocus_sys ()
 
void setFont_helper (const QFont &font)
 
void setGeometry_sys (int, int, int, int, bool)
 
void setLayoutDirection_helper (Qt::LayoutDirection)
 
void setLayoutItemMargins (int left, int top, int right, int bottom)
 
void setLayoutItemMargins (QStyle::SubElement element, const QStyleOption *opt=0)
 
void setLocale_helper (const QLocale &l, bool forceUpdate=false)
 
void setMask_sys (const QRegion &)
 
bool setMaximumSize_helper (int &maxw, int &maxh)
 
bool setMinimumSize_helper (int &minw, int &minh)
 
void setModal_sys ()
 
void setNetWmWindowTypes ()
 
void setOpaque (bool opaque)
 
void setPalette_helper (const QPalette &)
 
void setParent_sys (QWidget *parent, Qt::WindowFlags)
 
void setRedirected (QPaintDevice *replacement, const QPoint &offset)
 
void setSharedPainter (QPainter *painter)
 
void setStyle_helper (QStyle *newStyle, bool propagate, bool metalHack=false)
 
void setUpdatesEnabled_helper (bool)
 
void setWindowFilePath_helper (const QString &filePath)
 
void setWindowIcon_helper ()
 
void setWindowIcon_sys (bool forceReset=false)
 
void setWindowIconText_helper (const QString &cap)
 
void setWindowIconText_sys (const QString &cap)
 
void setWindowOpacity_sys (qreal opacity)
 
void setWindowRole ()
 
void setWindowTitle_helper (const QString &cap)
 
void setWindowTitle_sys (const QString &cap)
 
void setWinId (WId)
 
QPaintersharedPainter () const
 
void show_helper ()
 
void show_recursive ()
 Makes the widget visible in the isVisible() meaning of the word. More...
 
void show_sys ()
 Platform-specific part of QWidget::show(). More...
 
void showChildren (bool spontaneous)
 
void stackUnder_sys (QWidget *)
 
void subtractOpaqueChildren (QRegion &rgn, const QRect &clipRect) const
 
void subtractOpaqueSiblings (QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
 
void syncBackingStore ()
 
void syncBackingStore (const QRegion &region)
 
QTLWExtratopData () const
 
void unsetCursor_sys ()
 
void updateFont (const QFont &)
 Assign font to this widget, and propagate it to all children, except style sheet widgets (handled differently) and windows that don't enable window propagation. More...
 
void updateFrameStrut ()
 Computes the frame rectangle when needed. More...
 
void updateGeometry_helper (bool forceUpdate)
 
void updateIsOpaque ()
 
void updateIsTranslucent ()
 
void updateSystemBackground ()
 
void updateX11AcceptFocus ()
 
void x11UpdateIsOpaque ()
 
 ~QWidgetPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static void translateTouchEvent (QGraphicsViewPrivate *d, QTouchEvent *touchEvent)
 
- Static Public Functions inherited from QWidgetPrivate
static void adjustFlags (Qt::WindowFlags &flags, QWidget *w=0)
 
static QGraphicsProxyWidgetnearestGraphicsProxyWidget (const QWidget *origin)
 Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget and its ancestors. More...
 
static int pointToRect (const QPoint &p, const QRect &r)
 
static QRect screenGeometry (const QWidget *widget)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

quint32 accelerateScrolling: 1
 
Qt::Alignment alignment
 
QBrush backgroundBrush
 
QPixmap backgroundPixmap
 
QRegion backgroundPixmapExposed
 
QGraphicsView::CacheMode cacheMode
 
quint32 connectedToScene: 1
 
QRect dirtyBoundingRect
 
QRegion dirtyRegion
 
quint32 dirtyScroll: 1
 
QPoint dirtyScrollOffset
 
QGraphicsView::DragMode dragMode
 
QRegion exposedRegion
 
QBrush foregroundBrush
 
quint32 fullUpdatePending: 1
 
quint32 handScrolling: 1
 
int handScrollMotions
 
quint32 hasSceneRect: 1
 
bool hasStoredOriginalCursor
 
quint32 hasUpdateClip: 1
 
quint32 identityMatrix: 1
 
quint32 keepLastCenterPoint: 1
 
QPointF lastCenterPoint
 
QGraphicsSceneDragDropEventlastDragDropEvent
 
QMouseEvent lastMouseEvent
 
QPointF lastMouseMoveScenePoint
 
QPoint lastMouseMoveScreenPoint
 
qreal leftIndent
 
QTransform matrix
 
Qt::MouseButton mousePressButton
 
QPointF mousePressItemPoint
 
QPointF mousePressScenePoint
 
QPoint mousePressScreenPoint
 
QPoint mousePressViewPoint
 
quint32 mustAllocateStyleOptions: 1
 
quint32 mustResizeBackgroundPixmap: 1
 
QGraphicsView::OptimizationFlags optimizationFlags
 
QCursor originalCursor
 
quint32 padding: 18
 
QPainter::RenderHints renderHints
 
QGraphicsView::ViewportAnchor resizeAnchor
 
bool rubberBanding
 
QRect rubberBandRect
 
Qt::ItemSelectionMode rubberBandSelectionMode
 
QPointer< QGraphicsScenescene
 
quint32 sceneInteractionAllowed: 1
 
QRectF sceneRect
 
qint64 scrollX
 
qint64 scrollY
 
QVector< QStyleOptionGraphicsItemstyleOptions
 
qreal topIndent
 
QGraphicsView::ViewportAnchor transformationAnchor
 
quint32 transforming: 1
 
QRect updateClip
 
bool updateSceneSlotReimplementedChecked
 
quint32 useLastMouseEvent: 1
 
QGraphicsView::ViewportUpdateMode viewportUpdateMode
 
- Public Variables inherited from QAbstractScrollAreaPrivate
int bottom
 
QRect cornerPaintingRect
 
QWidgetcornerWidget
 
QScrollBarhbar
 
Qt::ScrollBarPolicy hbarpolicy
 
int left
 
QRect reverseCornerPaintingRect
 
int right
 
QAbstractScrollAreaScrollBarContainerscrollBarContainers [Qt::Vertical+1]
 
bool singleFingerPanEnabled
 
int top
 
QScrollBarvbar
 
Qt::ScrollBarPolicy vbarpolicy
 
QWidgetviewport
 
QScopedPointer< QObjectviewportFilter
 
int xoffset
 
int yoffset
 
- Public Variables inherited from QFramePrivate
short bottomFrameWidth
 
int frameStyle
 
short frameWidth
 
QRect frect
 
short leftFrameWidth
 
short lineWidth
 
short midLineWidth
 
short rightFrameWidth
 
short topFrameWidth
 
- Public Variables inherited from QWidgetPrivate
QString accessibleDescription
 
QString accessibleName
 
QList< QAction * > actions
 
QPalette::ColorRole bg_role: 8
 
signed char bottomLayoutItemMargin
 
short bottommargin
 
QWidgetData data
 
QRegion dirty
 
uint dirtyOpaqueChildren: 1
 
QWExtraextra
 
QPaintEngineextraPaintEngine
 
QPalette::ColorRole fg_role: 8
 
QWidgetfocus_child
 
QWidgetfocus_next
 
QWidgetfocus_prev
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
QGraphicsEffectgraphicsEffect
 
Qt::HANDLE hd
 
uint high_attributes [4]
 
QPointer< QInputContextic
 
Qt::InputMethodHints imHints
 
uint inDirtyList: 1
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
uint inheritsInputMethodHints: 1
 
uint inSetParent: 1
 
uint isGLWidget: 1
 
uint isMoved: 1
 
uint isOpaque: 1
 
uint isScrolled: 1
 
QLayoutlayout
 
signed char leftLayoutItemMargin
 
short leftmargin
 
QLocale locale
 
QRegionneedsFlush
 
QRegion opaqueChildren
 
Qt::HANDLE picture
 
const QMetaObjectpolished
 
QPaintDeviceredirectDev
 
QPoint redirectOffset
 
signed char rightLayoutItemMargin
 
short rightmargin
 
QSizePolicy size_policy
 
QString statusTip
 
QString toolTip
 
signed char topLayoutItemMargin
 
short topmargin
 
uint usesDoubleBufferedGLContext: 1
 
QString whatsThis
 
QWidgetItemV2widgetItem
 
QX11Info xinfo
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QWidgetPrivate
enum  CloseMode { CloseNoEvent, CloseWithEvent, CloseWithSpontaneousEvent }
 
enum  Direction { DirectionNorth = 0x01, DirectionEast = 0x10, DirectionSouth = 0x02, DirectionWest = 0x20 }
 
enum  DrawWidgetFlags {
  DrawAsRoot = 0x01, DrawPaintOnScreen = 0x02, DrawRecursive = 0x04, DrawInvisible = 0x08,
  DontSubtractOpaqueChildren = 0x10, DontSetCompositionMode = 0x20, DontDrawOpaqueChildren = 0x40, DontDrawNativeChildren = 0x80
}
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Variables inherited from QWidgetPrivate
static QWidgetSetallWidgets = 0
 
static int instanceCounter = 0
 
static QWidgetkeyboardGrabber = 0
 
static QWidgetMappermapper = 0
 
static int maxInstances = 0
 
static QWidgetmouseGrabber = 0
 

Detailed Description

Definition at line 69 of file qgraphicsview_p.h.

Constructors and Destructors

◆ QGraphicsViewPrivate()

QGraphicsViewPrivate::QGraphicsViewPrivate ( )
Warning
This function is not part of the public interface.

Definition at line 342 of file qgraphicsview.cpp.

346  connectedToScene(false),
347  useLastMouseEvent(false),
348  identityMatrix(true),
349  dirtyScroll(true),
350  accelerateScrolling(true),
351  keepLastCenterPoint(true),
352  transforming(false),
353  handScrolling(false),
356  fullUpdatePending(true),
357  hasUpdateClip(false),
359  leftIndent(0), topIndent(0),
365  scene(0),
366 #ifndef QT_NO_RUBBERBAND
367  rubberBanding(false),
369 #endif
371 #ifndef QT_NO_CURSOR
373 #endif
376 {
378 }
QGraphicsView::CacheMode cacheMode
static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS
QMouseEvent lastMouseEvent
bool updateSceneSlotReimplementedChecked
QVector< QStyleOptionGraphicsItem > styleOptions
QPainter::RenderHints renderHints
QGraphicsView::ViewportAnchor transformationAnchor
QGraphicsView::ViewportUpdateMode viewportUpdateMode
Qt::Alignment alignment
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
Qt::MouseButton mousePressButton
QGraphicsView::DragMode dragMode
QGraphicsView::OptimizationFlags optimizationFlags
quint32 mustResizeBackgroundPixmap
void reserve(int size)
Attempts to allocate memory for at least size elements.
Definition: qvector.h:339
QGraphicsSceneDragDropEvent * lastDragDropEvent
quint32 mustAllocateStyleOptions
QPointer< QGraphicsScene > scene
Qt::ItemSelectionMode rubberBandSelectionMode
QGraphicsView::ViewportAnchor resizeAnchor

Functions

◆ _q_setViewportCursor()

void QGraphicsViewPrivate::_q_setViewportCursor ( const QCursor cursor)
Warning
This function is not part of the public interface.

Definition at line 736 of file qgraphicsview.cpp.

Referenced by _q_unsetViewportCursor(), and mouseMoveEventHandler().

737 {
741  }
742  viewport->setCursor(cursor);
743 }
void setCursor(const QCursor &)
Definition: qwidget.cpp:5290
QCursor cursor
the cursor shape for this widget
Definition: qwidget.h:183

◆ _q_unsetViewportCursor()

void QGraphicsViewPrivate::_q_unsetViewportCursor ( )
Warning
This function is not part of the public interface.

Definition at line 750 of file qgraphicsview.cpp.

751 {
753  foreach (QGraphicsItem *item, q->items(lastMouseEvent.pos())) {
754  if (item->hasCursor()) {
755  _q_setViewportCursor(item->cursor());
756  return;
757  }
758  }
759 
760  // Restore the original viewport cursor.
762  hasStoredOriginalCursor = false;
765  else
767  }
768 }
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
QMouseEvent lastMouseEvent
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
#define Q_Q(Class)
Definition: qglobal.h:2483
QCursor cursor() const
Returns the current cursor shape for the item.
void _q_setViewportCursor(const QCursor &cursor)
void setCursor(const QCursor &)
Definition: qwidget.cpp:5290
bool hasCursor() const
Returns true if this item has a cursor set; otherwise, false is returned.
QGraphicsView::DragMode dragMode
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64

◆ allocStyleOptionsArray()

QStyleOptionGraphicsItem * QGraphicsViewPrivate::allocStyleOptionsArray ( int  numItems)

Definition at line 1029 of file qgraphicsview.cpp.

1030 {
1031  if (mustAllocateStyleOptions || (numItems > styleOptions.capacity()))
1032  // too many items, let's allocate on-the-fly
1033  return new QStyleOptionGraphicsItem[numItems];
1034 
1035  // expand only whenever necessary
1036  if (numItems > styleOptions.size())
1037  styleOptions.resize(numItems);
1038 
1039  mustAllocateStyleOptions = true;
1040  return styleOptions.data();
1041 }
QVector< QStyleOptionGraphicsItem > styleOptions
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
int capacity() const
Returns the maximum number of items that can be stored in the vector without forcing a reallocation...
Definition: qvector.h:143
quint32 mustAllocateStyleOptions
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem...
Definition: qstyleoption.h:867
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ centerView()

void QGraphicsViewPrivate::centerView ( QGraphicsView::ViewportAnchor  anchor)
Warning
This function is not part of the public interface.

Definition at line 508 of file qgraphicsview.cpp.

509 {
511  switch (anchor) {
513  if (q->underMouse()) {
514  // Last scene pos: lastMouseMoveScenePoint
515  // Current mouse pos:
516  QPointF transformationDiff = q->mapToScene(viewport->rect().center())
517  - q->mapToScene(viewport->mapFromGlobal(QCursor::pos()));
518  q->centerOn(lastMouseMoveScenePoint + transformationDiff);
519  } else {
520  q->centerOn(lastCenterPoint);
521  }
522  break;
523  }
525  q->centerOn(lastCenterPoint);
526  break;
528  break;
529  }
530 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_Q(Class)
Definition: qglobal.h:2483
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310

◆ dispatchPendingUpdateRequests()

void QGraphicsViewPrivate::dispatchPendingUpdateRequests ( )
inline

Definition at line 182 of file qgraphicsview_p.h.

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.
194  } else
195 #endif // !Q_WS_MAC
196  {
199  else
201  }
202  }
bool paintOnScreen() const
Definition: qwidget.cpp:2255
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void qt_mac_dispatchPendingUpdateRequests(QWidget *widget)
static void sendPostedEvents()
static QString graphics_system_name
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920

◆ findItems()

QList< QGraphicsItem * > QGraphicsViewPrivate::findItems ( const QRegion exposedRegion,
bool *  allItems,
const QTransform viewTransform 
) const

Adjustments in findItems: mapToScene(QRect) forces us to adjust the

input rectangle by (0, 0, 1, 1), because it uses QRect::bottomRight() (etc) when mapping the rectangle to a polygon (which is wrong).

In addition, as QGraphicsItem::boundingRect() is defined in logical space, but the default pen for QPainter is cosmetic with a width of 0, QPainter is at risk of painting 1 pixel outside the bounding rect. Therefore we must search for items with an adjustment of (-1, -1, 1, 1).

Definition at line 1061 of file qgraphicsview.cpp.

1063 {
1064  Q_Q(const QGraphicsView);
1065 
1066  // Step 1) If all items are contained within the expose region, then
1067  // return a list of all visible items. ### the scene's growing bounding
1068  // rect does not take into account untransformable items.
1069  const QRectF exposedRegionSceneBounds = q->mapToScene(exposedRegion.boundingRect().adjusted(-1, -1, 1, 1))
1070  .boundingRect();
1071  if (exposedRegionSceneBounds.contains(scene->sceneRect())) {
1072  Q_ASSERT(allItems);
1073  *allItems = true;
1074 
1075  // All items are guaranteed within the exposed region.
1076  return scene->items(Qt::AscendingOrder);
1077  }
1078 
1079  // Step 2) If the expose region is a simple rect and the view is only
1080  // translated or scaled, search for items using
1081  // QGraphicsScene::items(QRectF).
1082  bool simpleRectLookup = exposedRegion.rectCount() == 1 && matrix.type() <= QTransform::TxScale;
1083  if (simpleRectLookup) {
1084  return scene->items(exposedRegionSceneBounds,
1086  Qt::AscendingOrder, viewTransform);
1087  }
1088 
1089  // If the region is complex or the view has a complex transform, adjust
1090  // the expose region, convert it to a path, and then search for items
1091  // using QGraphicsScene::items(QPainterPath);
1092  QRegion adjustedRegion;
1093  foreach (const QRect &r, exposedRegion.rects())
1094  adjustedRegion += r.adjusted(-1, -1, 1, 1);
1095 
1096  const QPainterPath exposedScenePath(q->mapToScene(qt_regionToPath(adjustedRegion)));
1097  return scene->items(exposedScenePath, Qt::IntersectsItemBoundingRect,
1098  Qt::AscendingOrder, viewTransform);
1099 }
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
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QList< QGraphicsItem * > items() const
Returns a list of all items in the scene in descending stacking order.
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
TransformationType type() const
Returns the transformation type of this matrix.
int rectCount() const
Returns the number of rectangles that will be returned in rects().
Definition: qregion.cpp:4461
#define Q_Q(Class)
Definition: qglobal.h:2483
static const QRectF boundingRect(const QPointF *points, int pointCount)
bool contains(const QPointF &p) const
Returns true if the given point is inside or on the edge of the rectangle; otherwise returns false...
Definition: qrect.cpp:2349
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QRectF sceneRect
the scene rectangle; the bounding rectangle of the scene
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath(const QRegion &region)
Definition: qregion.cpp:1160
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
QPointer< QGraphicsScene > scene

◆ freeStyleOptionsArray()

void QGraphicsViewPrivate::freeStyleOptionsArray ( QStyleOptionGraphicsItem array)

Definition at line 1043 of file qgraphicsview.cpp.

1044 {
1045  mustAllocateStyleOptions = false;
1046  if (array != styleOptions.data())
1047  delete [] array;
1048 }
QVector< QStyleOptionGraphicsItem > styleOptions
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
quint32 mustAllocateStyleOptions

◆ horizontalScroll()

qint64 QGraphicsViewPrivate::horizontalScroll ( ) const

Returns the horizontal scroll value (the X value of the left edge of the viewport).

Warning
This function is not part of the public interface.

Definition at line 550 of file qgraphicsview.cpp.

Referenced by setUpdateClip(), and updateHelper().

551 {
552  if (dirtyScroll)
553  const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
554  return scrollX;
555 }

◆ mapRectFromScene()

QRectF QGraphicsViewPrivate::mapRectFromScene ( const QRectF rect) const
Warning
This function is not part of the public interface.

Maps the given rectangle from the scene using QTransform::mapRect()

Definition at line 592 of file qgraphicsview.cpp.

593 {
594  if (dirtyScroll)
595  const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
596  return (identityMatrix ? rect : matrix.mapRect(rect)).translated(-scrollX, -scrollY);
597 }
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...

◆ mapRectToScene()

QRectF QGraphicsViewPrivate::mapRectToScene ( const QRect rect) const
Warning
This function is not part of the public interface.

Maps the given rectangle to the scene using QTransform::mapRect()

Definition at line 578 of file qgraphicsview.cpp.

579 {
580  if (dirtyScroll)
581  const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
582  QRectF scrolled = QRectF(rect.translated(scrollX, scrollY));
583  return identityMatrix ? scrolled : matrix.inverted().mapRect(scrolled);
584 }
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
QTransform inverted(bool *invertible=0) const
Returns an inverted copy of this matrix.
Definition: qtransform.cpp:364
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511

◆ mapToScene() [1/2]

QPointF QGraphicsViewPrivate::mapToScene ( const QPointF point) const

Definition at line 3958 of file qgraphicsview.cpp.

Referenced by translateTouchEvent().

3959 {
3960  QPointF p = point;
3961  p.rx() += horizontalScroll();
3962  p.ry() += verticalScroll();
3963  return identityMatrix ? p : matrix.inverted().map(p);
3964 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qint64 horizontalScroll() const
Returns the horizontal scroll value (the X value of the left edge of the viewport).
QTransform inverted(bool *invertible=0) const
Returns an inverted copy of this matrix.
Definition: qtransform.cpp:364
qreal & rx()
Returns a reference to the x coordinate of this point.
Definition: qpoint.h:302
QPoint map(const QPoint &p) const
Creates and returns a QPoint object that is a copy of the given point, mapped into the coordinate sys...
qreal & ry()
Returns a reference to the y coordinate of this point.
Definition: qpoint.h:307
qint64 verticalScroll() const
Returns the vertical scroll value (the X value of the top edge of the viewport).

◆ mapToScene() [2/2]

QRectF QGraphicsViewPrivate::mapToScene ( const QRectF rect) const

Definition at line 3966 of file qgraphicsview.cpp.

3967 {
3968  QPointF scrollOffset(horizontalScroll(), verticalScroll());
3969  QPointF tl = scrollOffset + rect.topLeft();
3970  QPointF tr = scrollOffset + rect.topRight();
3971  QPointF br = scrollOffset + rect.bottomRight();
3972  QPointF bl = scrollOffset + rect.bottomLeft();
3973 
3974  QPolygonF poly(4);
3975  if (!identityMatrix) {
3976  QTransform x = matrix.inverted();
3977  poly[0] = x.map(tl);
3978  poly[1] = x.map(tr);
3979  poly[2] = x.map(br);
3980  poly[3] = x.map(bl);
3981  } else {
3982  poly[0] = tl;
3983  poly[1] = tr;
3984  poly[2] = br;
3985  poly[3] = bl;
3986  }
3987  return poly.boundingRect();
3988 }
QPointF bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:540
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QPointF topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:539
QPointF bottomLeft() const
Returns the position of the rectangle&#39;s bottom-left corner.
Definition: qrect.h:542
qint64 horizontalScroll() const
Returns the horizontal scroll value (the X value of the left edge of the viewport).
QTransform inverted(bool *invertible=0) const
Returns an inverted copy of this matrix.
Definition: qtransform.cpp:364
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
QPoint map(const QPoint &p) const
Creates and returns a QPoint object that is a copy of the given point, mapped into the coordinate sys...
qint64 verticalScroll() const
Returns the vertical scroll value (the X value of the top edge of the viewport).
QPointF topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:541
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ mapToViewRect()

QRect QGraphicsViewPrivate::mapToViewRect ( const QGraphicsItem item,
const QRectF rect 
) const
Warning
This function is not part of the public interface.

Definition at line 817 of file qgraphicsview.cpp.

818 {
819  Q_Q(const QGraphicsView);
820  if (dirtyScroll)
821  const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
822 
823  if (item->d_ptr->itemIsUntransformable()) {
824  QTransform itv = item->deviceTransform(q->viewportTransform());
825  return itv.mapRect(rect).toAlignedRect();
826  }
827 
828  // Translate-only
829  // COMBINE
830  QPointF offset;
831  const QGraphicsItem *parentItem = item;
832  const QGraphicsItemPrivate *itemd;
833  do {
834  itemd = parentItem->d_ptr.data();
835  if (itemd->transformData)
836  break;
837  offset += itemd->pos;
838  } while ((parentItem = itemd->parent));
839 
840  QRectF baseRect = rect.translated(offset.x(), offset.y());
841  if (!parentItem) {
842  if (identityMatrix) {
843  baseRect.translate(-scrollX, -scrollY);
844  return baseRect.toAlignedRect();
845  }
846  return matrix.mapRect(baseRect).translated(-scrollX, -scrollY).toAlignedRect();
847  }
848 
849  QTransform tr = parentItem->sceneTransform();
850  if (!identityMatrix)
851  tr *= matrix;
852  QRectF r = tr.mapRect(baseRect);
853  r.translate(-scrollX, -scrollY);
854  return r.toAlignedRect();
855 }
QRect toAlignedRect() const
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle...
Definition: qrect.cpp:2817
QGraphicsItem * parent
QScopedPointer< QGraphicsItemPrivate > d_ptr
T * data() const
Returns the value of the pointer referenced by this object.
QTransform sceneTransform() const
Returns this item&#39;s scene transformation matrix.
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
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
#define Q_Q(Class)
Definition: qglobal.h:2483
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
bool itemIsUntransformable() const
void translate(qreal dx, qreal dy)
Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position...
Definition: qrect.h:716
QTransform deviceTransform(const QTransform &viewportTransform) const
Returns this item&#39;s device transformation matrix, using viewportTransform to map from scene to device...
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
TransformData * transformData
QRectF translated(qreal dx, qreal dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:740
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ mapToViewRegion()

QRegion QGraphicsViewPrivate::mapToViewRegion ( const QGraphicsItem item,
const QRectF rect 
) const
Warning
This function is not part of the public interface.

Definition at line 860 of file qgraphicsview.cpp.

861 {
862  Q_Q(const QGraphicsView);
863  if (dirtyScroll)
864  const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
865 
866  // Accurate bounding region
867  QTransform itv = item->deviceTransform(q->viewportTransform());
868  return item->boundingRegion(itv) & itv.mapRect(rect).toAlignedRect();
869 }
#define Q_Q(Class)
Definition: qglobal.h:2483
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
QTransform deviceTransform(const QTransform &viewportTransform) const
Returns this item&#39;s device transformation matrix, using viewportTransform to map from scene to device...
QRegion boundingRegion(const QTransform &itemToDeviceTransform) const
Returns the bounding region for this item.
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ mouseMoveEventHandler()

void QGraphicsViewPrivate::mouseMoveEventHandler ( QMouseEvent event)

Definition at line 641 of file qgraphicsview.cpp.

Referenced by replayLastMouseEvent().

642 {
644 
645  storeMouseEvent(event);
647 
649  return;
650  if (handScrolling)
651  return;
652  if (!scene)
653  return;
654 
656  mouseEvent.setWidget(viewport);
657  mouseEvent.setButtonDownScenePos(mousePressButton, mousePressScenePoint);
658  mouseEvent.setButtonDownScreenPos(mousePressButton, mousePressScreenPoint);
659  mouseEvent.setScenePos(q->mapToScene(event->pos()));
660  mouseEvent.setScreenPos(event->globalPos());
661  mouseEvent.setLastScenePos(lastMouseMoveScenePoint);
662  mouseEvent.setLastScreenPos(lastMouseMoveScreenPoint);
663  mouseEvent.setButtons(event->buttons());
664  mouseEvent.setButton(event->button());
665  mouseEvent.setModifiers(event->modifiers());
666  lastMouseMoveScenePoint = mouseEvent.scenePos();
667  lastMouseMoveScreenPoint = mouseEvent.screenPos();
668  mouseEvent.setAccepted(false);
669  if (event->spontaneous())
671  else
673 
674  // Remember whether the last event was accepted or not.
675  lastMouseEvent.setAccepted(mouseEvent.isAccepted());
676 
677  if (mouseEvent.isAccepted() && mouseEvent.buttons() != 0) {
678  // The event was delivered to a mouse grabber; the press is likely to
679  // have set a cursor, and we must not change it.
680  return;
681  }
682 
683 #ifndef QT_NO_CURSOR
684  // If all the items ignore hover events, we don't look-up any items
685  // in QGraphicsScenePrivate::dispatchHoverEvent, hence the
686  // cachedItemsUnderMouse list will be empty. We therefore do the look-up
687  // for cursor items here if not all items use the default cursor.
688  if (scene->d_func()->allItemsIgnoreHoverEvents && !scene->d_func()->allItemsUseDefaultCursor
689  && scene->d_func()->cachedItemsUnderMouse.isEmpty()) {
690  scene->d_func()->cachedItemsUnderMouse = scene->d_func()->itemsAtPosition(mouseEvent.screenPos(),
691  mouseEvent.scenePos(),
692  mouseEvent.widget());
693  }
694  // Find the topmost item under the mouse with a cursor.
695  foreach (QGraphicsItem *item, scene->d_func()->cachedItemsUnderMouse) {
696  if (item->hasCursor()) {
697  _q_setViewportCursor(item->cursor());
698  return;
699  }
700  }
701 
702  // No items with cursors found; revert to the view cursor.
704  // Restore the original viewport cursor.
705  hasStoredOriginalCursor = false;
707  }
708 #endif
709 }
void storeMouseEvent(QMouseEvent *event)
void setAccepted(bool accepted)
Definition: qcoreevent.h:306
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
QMouseEvent lastMouseEvent
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
#define Q_Q(Class)
Definition: qglobal.h:2483
QCursor cursor() const
Returns the current cursor shape for the item.
bool spontaneous() const
Returns true if the event originated outside the application (a system event); otherwise returns fals...
Definition: qcoreevent.h:304
void _q_setViewportCursor(const QCursor &cursor)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void setCursor(const QCursor &)
Definition: qwidget.cpp:5290
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
bool hasCursor() const
Returns true if this item has a cursor set; otherwise, false is returned.
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
Qt::MouseButton mousePressButton
static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
Definition: qtestmouse.h:71
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
QPointer< QGraphicsScene > scene
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
Definition: qevent.h:96

◆ populateSceneDragDropEvent()

void QGraphicsViewPrivate::populateSceneDragDropEvent ( QGraphicsSceneDragDropEvent dest,
QDropEvent source 
)
Warning
This function is not part of the public interface.

Definition at line 793 of file qgraphicsview.cpp.

795 {
796 #ifndef QT_NO_DRAGANDDROP
798  dest->setScenePos(q->mapToScene(source->pos()));
799  dest->setScreenPos(q->mapToGlobal(source->pos()));
800  dest->setButtons(source->mouseButtons());
801  dest->setModifiers(source->keyboardModifiers());
802  dest->setPossibleActions(source->possibleActions());
803  dest->setProposedAction(source->proposedAction());
804  dest->setDropAction(source->dropAction());
805  dest->setMimeData(source->mimeData());
806  dest->setWidget(viewport);
807  dest->setSource(source->source());
808 #else
809  Q_UNUSED(dest)
810  Q_UNUSED(source)
811 #endif
812 }
void setSource(QWidget *source)
This function set the source widget, i.
void setScenePos(const QPointF &pos)
Sets the scene position of the mouse to pos.
Qt::DropActions possibleActions() const
Returns an OR-combination of possible drop actions.
Definition: qevent.h:490
void setMimeData(const QMimeData *data)
This function sets the MIME data for the event.
Qt::DropAction dropAction() const
Returns the action to be performed on the data by the target.
Definition: qevent.h:494
void setWidget(QWidget *widget)
Sets the widget related to this event.
Qt::KeyboardModifiers keyboardModifiers() const
Returns the modifier keys that are pressed.
Definition: qevent.h:488
#define Q_Q(Class)
Definition: qglobal.h:2483
void setPossibleActions(Qt::DropActions actions)
Sets the possible drop actions that the drag can result in to actions.
void setDropAction(Qt::DropAction action)
This function lets the receiver of the drop set the drop action that was performed to action...
Qt::DropAction proposedAction() const
Returns the proposed drop action.
Definition: qevent.h:491
Qt::MouseButtons mouseButtons() const
Returns the mouse buttons that are pressed.
Definition: qevent.h:487
QWidget * source() const
If the source of the drag operation is a widget in this application, this function returns that sourc...
Definition: qevent.cpp:2739
void setModifiers(Qt::KeyboardModifiers modifiers)
Sets the keyboard modifiers that were pressed when the event was created to modifiers.
void setButtons(Qt::MouseButtons buttons)
Sets the mouse buttons that were pressed when the event was created to buttons.
void setProposedAction(Qt::DropAction action)
Sets the proposed action to action.
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
const QMimeData * mimeData() const
Returns the data that was dropped on the widget and its associated MIME type information.
Definition: qevent.h:498
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
void setScreenPos(const QPoint &pos)
Sets the mouse position relative to the screen to pos.
const QPoint & pos() const
Returns the position where the drop was made.
Definition: qevent.h:486

◆ processPendingUpdates()

void QGraphicsViewPrivate::processPendingUpdates ( )
Warning
This function is not part of the public interface.

Definition at line 874 of file qgraphicsview.cpp.

875 {
876  if (!scene)
877  return;
878 
879  if (fullUpdatePending) {
880  viewport->update();
883  } else {
884  viewport->update(dirtyRegion); // Already adjusted in updateRect/Region.
885  }
886 
888  dirtyRegion = QRegion();
889 }
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
QGraphicsView::ViewportUpdateMode viewportUpdateMode
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QPointer< QGraphicsScene > scene

◆ recalculateContentSize()

void QGraphicsViewPrivate::recalculateContentSize ( )
Warning
This function is not part of the public interface.

Definition at line 383 of file qgraphicsview.cpp.

384 {
386 
387  QSize maxSize = q->maximumViewportSize();
388  int width = maxSize.width();
389  int height = maxSize.height();
390  QRectF viewRect = matrix.mapRect(q->sceneRect());
391 
392  bool frameOnlyAround = (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q));
393  if (frameOnlyAround) {
395  height -= frameWidth * 2;
397  width -= frameWidth * 2;
398  }
399 
400  // Adjust the maximum width and height of the viewport based on the width
401  // of visible scroll bars.
402  int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q);
403  if (frameOnlyAround)
404  scrollBarExtent += frameWidth * 2;
405 
406  bool useHorizontalScrollBar = (viewRect.width() > width) && hbarpolicy != Qt::ScrollBarAlwaysOff;
407  bool useVerticalScrollBar = (viewRect.height() > height) && vbarpolicy != Qt::ScrollBarAlwaysOff;
408  if (useHorizontalScrollBar && !useVerticalScrollBar) {
409  if (viewRect.height() > height - scrollBarExtent)
410  useVerticalScrollBar = true;
411  }
412  if (useVerticalScrollBar && !useHorizontalScrollBar) {
413  if (viewRect.width() > width - scrollBarExtent)
414  useHorizontalScrollBar = true;
415  }
416  if (useHorizontalScrollBar && hbarpolicy != Qt::ScrollBarAlwaysOn)
417  height -= scrollBarExtent;
418  if (useVerticalScrollBar && vbarpolicy != Qt::ScrollBarAlwaysOn)
419  width -= scrollBarExtent;
420 
421  // Setting the ranges of these scroll bars can/will cause the values to
422  // change, and scrollContentsBy() will be called correspondingly. This
423  // will reset the last center point.
424  QPointF savedLastCenterPoint = lastCenterPoint;
425 
426  // Remember the former indent settings
427  qreal oldLeftIndent = leftIndent;
428  qreal oldTopIndent = topIndent;
429 
430  // If the whole scene fits horizontally, we center the scene horizontally,
431  // and ignore the horizontal scroll bars.
432  int left = q_round_bound(viewRect.left());
433  int right = q_round_bound(viewRect.right() - width);
434  if (left >= right) {
435  hbar->setRange(0, 0);
436 
438  case Qt::AlignLeft:
439  leftIndent = -viewRect.left();
440  break;
441  case Qt::AlignRight:
442  leftIndent = width - viewRect.width() - viewRect.left() - 1;
443  break;
444  case Qt::AlignHCenter:
445  default:
446  leftIndent = width / 2 - (viewRect.left() + viewRect.right()) / 2;
447  break;
448  }
449  } else {
450  hbar->setRange(left, right);
451  hbar->setPageStep(width);
452  hbar->setSingleStep(width / 20);
453  leftIndent = 0;
454  }
455 
456  // If the whole scene fits vertically, we center the scene vertically, and
457  // ignore the vertical scroll bars.
458  int top = q_round_bound(viewRect.top());
459  int bottom = q_round_bound(viewRect.bottom() - height);
460  if (top >= bottom) {
461  vbar->setRange(0, 0);
462 
463  switch (alignment & Qt::AlignVertical_Mask) {
464  case Qt::AlignTop:
465  topIndent = -viewRect.top();
466  break;
467  case Qt::AlignBottom:
468  topIndent = height - viewRect.height() - viewRect.top() - 1;
469  break;
470  case Qt::AlignVCenter:
471  default:
472  topIndent = height / 2 - (viewRect.top() + viewRect.bottom()) / 2;
473  break;
474  }
475  } else {
476  vbar->setRange(top, bottom);
477  vbar->setPageStep(height);
478  vbar->setSingleStep(height / 20);
479  topIndent = 0;
480  }
481 
482  // Restorethe center point from before the ranges changed.
483  lastCenterPoint = savedLastCenterPoint;
484 
485  // Issue a full update if the indents change.
486  // ### If the transform is still the same, we can get away with just a
487  // scroll instead.
488  if (oldLeftIndent != leftIndent || oldTopIndent != topIndent) {
489  dirtyScroll = true;
490  updateAll();
491  } else if (q->isRightToLeft() && !leftIndent) {
492  // In reverse mode, the horizontal scroll always changes after the content
493  // size has changed, as the scroll is calculated by summing the min and
494  // max values of the range and subtracting the current value. In normal
495  // mode the scroll remains unchanged unless the indent has changed.
496  dirtyScroll = true;
497  }
498 
500  // Invalidate the background pixmap
502  }
503 }
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
double qreal
Definition: qglobal.h:1193
QGraphicsView::CacheMode cacheMode
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:525
int q_round_bound(qreal d)
void setRange(int min, int max)
Sets the slider&#39;s minimum to min and its maximum to max.
#define Q_Q(Class)
Definition: qglobal.h:2483
int width() const
Returns the width.
Definition: qsize.h:126
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
short frameWidth
Definition: qframe_p.h:74
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
Qt::Alignment alignment
int height() const
Returns the height.
Definition: qsize.h:129
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
quint32 mustResizeBackgroundPixmap
qreal bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:528

◆ replayLastMouseEvent()

void QGraphicsViewPrivate::replayLastMouseEvent ( )
Warning
This function is not part of the public interface.

Definition at line 624 of file qgraphicsview.cpp.

625 {
626  if (!useLastMouseEvent || !scene)
627  return;
629 }
QMouseEvent lastMouseEvent
void mouseMoveEventHandler(QMouseEvent *event)
QPointer< QGraphicsScene > scene

◆ rubberBandRegion()

QRegion QGraphicsViewPrivate::rubberBandRegion ( const QWidget widget,
const QRect rect 
) const
Warning
This function is not part of the public interface.

Definition at line 715 of file qgraphicsview.cpp.

716 {
718  QStyleOptionRubberBand option;
719  option.initFrom(widget);
720  option.rect = rect;
721  option.opaque = false;
722  option.shape = QRubberBand::Rectangle;
723 
724  QRegion tmp;
725  tmp += rect;
726  if (widget->style()->styleHint(QStyle::SH_RubberBand_Mask, &option, widget, &mask))
727  tmp &= mask.region;
728  return tmp;
729 }
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
QStyle * style() const
Definition: qwidget.cpp:2742
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
bool opaque
whether the rubber band is required to be drawn in an opaque style
Definition: qstyleoption.h:676
The QStyleOptionRubberBand class is used to describe the parameters needed for drawing a rubber band...
Definition: qstyleoption.h:669
The QStyleHintReturnMask class provides style hints that return a QRegion.
Definition: qstyleoption.h:923
QRubberBand::Shape shape
the shape of the rubber band
Definition: qstyleoption.h:675
QRegion region
the region for style hints that return a QRegion
Definition: qstyleoption.h:930
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ setUpdateClip()

void QGraphicsViewPrivate::setUpdateClip ( QGraphicsItem item)

Definition at line 912 of file qgraphicsview.cpp.

913 {
915  // We simply ignore the request if the update mode is either FullViewportUpdate
916  // or NoViewportUpdate; in that case there's no point in clipping anything.
919  hasUpdateClip = false;
920  return;
921  }
922 
923  // Calculate the clip (item's bounding rect in view coordinates).
924  // Optimized version of:
925  // QRect clip = item->deviceTransform(q->viewportTransform())
926  // .mapRect(item->boundingRect()).toAlignedRect();
927  QRect clip;
928  if (item->d_ptr->itemIsUntransformable()) {
929  QTransform xform = item->deviceTransform(q->viewportTransform());
930  clip = xform.mapRect(item->boundingRect()).toAlignedRect();
931  } else if (item->d_ptr->sceneTransformTranslateOnly && identityMatrix) {
932  QRectF r(item->boundingRect());
934  item->d_ptr->sceneTransform.dy() - verticalScroll());
935  clip = r.toAlignedRect();
936  } else if (!q->isTransformed()) {
937  clip = item->d_ptr->sceneTransform.mapRect(item->boundingRect()).toAlignedRect();
938  } else {
939  QTransform xform = item->d_ptr->sceneTransform;
940  xform *= q->viewportTransform();
941  clip = xform.mapRect(item->boundingRect()).toAlignedRect();
942  }
943 
944  if (hasUpdateClip) {
945  // Intersect with old clip.
946  updateClip &= clip;
947  } else {
948  updateClip = clip;
949  hasUpdateClip = true;
950  }
951 }
qreal dy() const
Returns the vertical translation factor.
Definition: qtransform.h:277
QScopedPointer< QGraphicsItemPrivate > d_ptr
virtual QRectF boundingRect() const =0
This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be ...
qint64 horizontalScroll() const
Returns the horizontal scroll value (the X value of the left edge of the viewport).
#define Q_Q(Class)
Definition: qglobal.h:2483
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QGraphicsView::ViewportUpdateMode viewportUpdateMode
bool itemIsUntransformable() const
quint32 sceneTransformTranslateOnly
void translate(qreal dx, qreal dy)
Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position...
Definition: qrect.h:716
QTransform deviceTransform(const QTransform &viewportTransform) const
Returns this item&#39;s device transformation matrix, using viewportTransform to map from scene to device...
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
qreal dx() const
Returns the horizontal translation factor.
Definition: qtransform.h:273
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
qint64 verticalScroll() const
Returns the vertical scroll value (the X value of the top edge of the viewport).
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ storeDragDropEvent()

void QGraphicsViewPrivate::storeDragDropEvent ( const QGraphicsSceneDragDropEvent event)
Warning
This function is not part of the public interface.

Definition at line 774 of file qgraphicsview.cpp.

775 {
776  delete lastDragDropEvent;
788 }
Qt::DropAction dropAction() const
Returns the action that was performed in this drag and drop.
const QMimeData * mimeData() const
This function returns the MIME data of the event.
void setSource(QWidget *source)
This function set the source widget, i.
void setScenePos(const QPointF &pos)
Sets the scene position of the mouse to pos.
void setMimeData(const QMimeData *data)
This function sets the MIME data for the event.
Qt::MouseButtons buttons() const
Returns a Qt::MouseButtons value indicating which buttons were pressed on the mouse when this mouse e...
QWidget * widget() const
Returns the widget where the event originated, or 0 if the event originates from another application...
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifiers that were pressed when the drag and drop event was created...
void setWidget(QWidget *widget)
Sets the widget related to this event.
QWidget * source() const
This function returns the QGraphicsView that created the QGraphicsSceneDragDropEvent.
void setPossibleActions(Qt::DropActions actions)
Sets the possible drop actions that the drag can result in to actions.
void setDropAction(Qt::DropAction action)
This function lets the receiver of the drop set the drop action that was performed to action...
QPoint screenPos() const
Returns the position of the mouse relative to the screen.
Qt::DropAction proposedAction() const
Returns the drop action that is proposed, i.e., preferred.
Qt::DropActions possibleActions() const
Returns the possible drop actions that the drag and drop can result in.
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framewor...
void setModifiers(Qt::KeyboardModifiers modifiers)
Sets the keyboard modifiers that were pressed when the event was created to modifiers.
void setButtons(Qt::MouseButtons buttons)
Sets the mouse buttons that were pressed when the event was created to buttons.
void setProposedAction(Qt::DropAction action)
Sets the proposed action to action.
QPointF scenePos() const
Returns the position of the mouse in scene coordinates.
QGraphicsSceneDragDropEvent * lastDragDropEvent
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
void setScreenPos(const QPoint &pos)
Sets the mouse position relative to the screen to pos.

◆ storeMouseEvent()

void QGraphicsViewPrivate::storeMouseEvent ( QMouseEvent event)
Warning
This function is not part of the public interface.

Definition at line 634 of file qgraphicsview.cpp.

Referenced by mouseMoveEventHandler().

635 {
636  useLastMouseEvent = true;
637  lastMouseEvent = QMouseEvent(QEvent::MouseMove, event->pos(), event->globalPos(),
638  event->button(), event->buttons(), event->modifiers());
639 }
QMouseEvent lastMouseEvent
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85

◆ translateTouchEvent()

void QGraphicsViewPrivate::translateTouchEvent ( QGraphicsViewPrivate d,
QTouchEvent touchEvent 
)
static

Definition at line 322 of file qgraphicsview.cpp.

Referenced by QGraphicsView::viewportEvent().

323 {
324  QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
325  for (int i = 0; i < touchPoints.count(); ++i) {
326  QTouchEvent::TouchPoint &touchPoint = touchPoints[i];
327  // the scene will set the item local pos, startPos, lastPos, and rect before delivering to
328  // an item, but for now those functions are returning the view's local coordinates
329  touchPoint.setSceneRect(d->mapToScene(touchPoint.rect()));
330  touchPoint.setStartScenePos(d->mapToScene(touchPoint.startPos()));
331  touchPoint.setLastScenePos(d->mapToScene(touchPoint.lastPos()));
332 
333  // screenPos, startScreenPos, lastScreenPos, and screenRect are already set
334  }
335 
336  touchEvent->setTouchPoints(touchPoints);
337 }
QRectF rect() const
Returns the rect for this touch point, relative to the widget or QGraphicsItem that received the even...
Definition: qevent.cpp:4624
void setStartScenePos(const QPointF &startScenePos)
Definition: qevent.cpp:4719
QPointF mapToScene(const QPointF &point) const
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QPointF lastPos() const
Returns the position of this touch point from the previous touch event, relative to the widget or QGr...
Definition: qevent.cpp:4571
void setSceneRect(const QRectF &sceneRect)
Definition: qevent.cpp:4783
void setLastScenePos(const QPointF &lastScenePos)
Definition: qevent.cpp:4751
const QList< QTouchEvent::TouchPoint > & touchPoints() const
Returns the list of touch points contained in the touch event.
Definition: qevent.h:820
The TouchPoint class provides information about a touch point in a QTouchEvent.
Definition: qevent.h:744
void setTouchPoints(const QList< QTouchEvent::TouchPoint > &atouchPoints)
Sets the list of touch points for this event.
Definition: qevent.h:826
QPointF startPos() const
Returns the starting position of this touch point, relative to the widget or QGraphicsItem that recei...
Definition: qevent.cpp:4522

◆ updateAll()

void QGraphicsViewPrivate::updateAll ( )
inline

Definition at line 174 of file qgraphicsview_p.h.

Referenced by recalculateContentSize().

175  {
176  viewport->update();
177  fullUpdatePending = true;
179  dirtyRegion = QRegion();
180  }
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ updateInputMethodSensitivity()

void QGraphicsViewPrivate::updateInputMethodSensitivity ( )

Enables input methods for the view if and only if the current focus item of the scene accepts input methods.

Warning
This function is not part of the public interface.

Call function whenever that condition has potentially changed.

Definition at line 1111 of file qgraphicsview.cpp.

1112 {
1113  Q_Q(QGraphicsView);
1114  QGraphicsItem *focusItem = 0;
1115  bool enabled = scene && (focusItem = scene->focusItem())
1116  && (focusItem->d_ptr->flags & QGraphicsItem::ItemAcceptsInputMethod);
1117  q->setAttribute(Qt::WA_InputMethodEnabled, enabled);
1118  q->viewport()->setAttribute(Qt::WA_InputMethodEnabled, enabled);
1119 
1120  if (!enabled) {
1121  q->setInputMethodHints(0);
1122  return;
1123  }
1124 
1125  QGraphicsProxyWidget *proxy = focusItem->d_ptr->isWidget && focusItem->d_ptr->isProxyWidget()
1126  ? static_cast<QGraphicsProxyWidget *>(focusItem) : 0;
1127  if (!proxy) {
1128  q->setInputMethodHints(focusItem->inputMethodHints());
1129  } else if (QWidget *widget = proxy->widget()) {
1130  if (QWidget *fw = widget->focusWidget())
1131  widget = fw;
1133  } else {
1134  q->setInputMethodHints(0);
1135  }
1136 }
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
void setInputMethodHints(Qt::InputMethodHints hints)
Definition: qwidget.cpp:9736
QScopedPointer< QGraphicsLayoutItemPrivate > d_ptr
QPointer< QWidget > widget
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
#define Q_Q(Class)
Definition: qglobal.h:2483
QGraphicsItem * focusItem() const
When the scene is active, this functions returns the scene&#39;s current focus item, or 0 if no item curr...
The QGraphicsProxyWidget class provides a proxy layer for embedding a QWidget in a QGraphicsScene...
void setInputMethodHints(Qt::InputMethodHints hints)
Sets the current input method hints of this item to hints.
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
Qt::InputMethodHints inputMethodHints
What input method specific hints the widget has.
Definition: qwidget.h:224
QPointer< QGraphicsScene > scene
#define enabled
QWidget * widget() const
Returns a pointer to the embedded widget.

◆ updateLastCenterPoint()

void QGraphicsViewPrivate::updateLastCenterPoint ( )
Warning
This function is not part of the public interface.

Definition at line 535 of file qgraphicsview.cpp.

536 {
538  lastCenterPoint = q->mapToScene(viewport->rect().center());
539 }
#define Q_Q(Class)
Definition: qglobal.h:2483
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64

◆ updateRect()

bool QGraphicsViewPrivate::updateRect ( const QRect rect)

Definition at line 993 of file qgraphicsview.cpp.

Referenced by QGraphicsScenePrivate::markDirty(), QGraphicsScenePrivate::processDirtyItemsRecursive(), and QGraphicsItemPrivate::updatePaintedViewBoundingRects().

994 {
997  return false;
998  }
999 
1000  switch (viewportUpdateMode) {
1002  fullUpdatePending = true;
1003  viewport->update();
1004  break;
1006  if (hasUpdateClip)
1008  else
1011  fullUpdatePending = true;
1012  viewport->update();
1013  }
1014  break;
1015  case QGraphicsView::SmartViewportUpdate: // ### DEPRECATE
1017  if (hasUpdateClip)
1018  dirtyRegion += r & updateClip;
1019  else
1020  dirtyRegion += r;
1021  break;
1022  default:
1023  break;
1024  }
1025 
1026  return true;
1027 }
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
static bool containsViewport(const QRect &r, int width, int height)
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
static bool intersectsViewport(const QRect &r, int width, int height)
QGraphicsView::ViewportUpdateMode viewportUpdateMode
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
static void QRect_unite(QRect *rect, const QRect &other)

◆ updateRectF()

bool QGraphicsViewPrivate::updateRectF ( const QRectF rect)
inline

Definition at line 206 of file qgraphicsview_p.h.

Referenced by updateHelper(), and updateRegion().

207  {
208  if (rect.isEmpty())
209  return false;
211  return updateRect(rect.toAlignedRect().adjusted(-1, -1, 1, 1));
212  return updateRect(rect.toAlignedRect().adjusted(-2, -2, 2, 2));
213  }
QRect toAlignedRect() const
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle...
Definition: qrect.cpp:2817
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
bool updateRect(const QRect &rect)
QGraphicsView::OptimizationFlags optimizationFlags
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:658

◆ updateRegion()

bool QGraphicsViewPrivate::updateRegion ( const QRectF rect,
const QTransform xform 
)

Definition at line 953 of file qgraphicsview.cpp.

Referenced by updateHelper().

954 {
955  if (rect.isEmpty())
956  return false;
957 
960  // No point in updating with QRegion granularity; use the rect instead.
961  return updateRectF(xform.mapRect(rect));
962  }
963 
964  // Update mode is either Minimal or Smart, so we have to do a potentially slow operation,
965  // which is clearly documented here: QGraphicsItem::setBoundingRegionGranularity.
966  const QRegion region = xform.map(QRegion(rect.toAlignedRect()));
967  QRect viewRect = region.boundingRect();
968  const bool dontAdjustForAntialiasing = optimizationFlags & QGraphicsView::DontAdjustForAntialiasing;
969  if (dontAdjustForAntialiasing)
970  viewRect.adjust(-1, -1, 1, 1);
971  else
972  viewRect.adjust(-2, -2, 2, 2);
973  if (!intersectsViewport(viewRect, viewport->width(), viewport->height()))
974  return false; // Update region for sure outside viewport.
975 
976  const QVector<QRect> &rects = region.rects();
977  for (int i = 0; i < rects.size(); ++i) {
978  viewRect = rects.at(i);
979  if (dontAdjustForAntialiasing)
980  viewRect.adjust(-1, -1, 1, 1);
981  else
982  viewRect.adjust(-2, -2, 2, 2);
983  if (hasUpdateClip)
984  viewRect &= updateClip;
985  dirtyRegion += viewRect;
986  }
987 
988  return true;
989 }
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)
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
static bool intersectsViewport(const QRect &r, int width, int height)
QGraphicsView::ViewportUpdateMode viewportUpdateMode
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
QPoint map(const QPoint &p) const
Creates and returns a QPoint object that is a copy of the given point, mapped into the coordinate sys...
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QGraphicsView::OptimizationFlags optimizationFlags
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:658
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ updateScroll()

void QGraphicsViewPrivate::updateScroll ( )
Warning
This function is not part of the public interface.

Definition at line 602 of file qgraphicsview.cpp.

Referenced by horizontalScroll(), mapRectFromScene(), mapRectToScene(), mapToViewRect(), mapToViewRegion(), and verticalScroll().

603 {
606  if (q->isRightToLeft()) {
607  if (!leftIndent) {
608  scrollX += hbar->minimum();
609  scrollX += hbar->maximum();
610  scrollX -= hbar->value();
611  }
612  } else {
613  scrollX += hbar->value();
614  }
615 
617 
618  dirtyScroll = false;
619 }
int minimum() const
#define Q_Q(Class)
Definition: qglobal.h:2483
int value() const
__int64 qint64
Definition: qglobal.h:942
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
int maximum() const

◆ verticalScroll()

qint64 QGraphicsViewPrivate::verticalScroll ( ) const

Returns the vertical scroll value (the X value of the top edge of the viewport).

Warning
This function is not part of the public interface.

Definition at line 566 of file qgraphicsview.cpp.

Referenced by setUpdateClip(), and updateHelper().

567 {
568  if (dirtyScroll)
569  const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
570  return scrollY;
571 }

Properties

◆ accelerateScrolling

quint32 QGraphicsViewPrivate::accelerateScrolling

Definition at line 88 of file qgraphicsview_p.h.

◆ alignment

Qt::Alignment QGraphicsViewPrivate::alignment

Definition at line 130 of file qgraphicsview_p.h.

Referenced by recalculateContentSize().

◆ backgroundBrush

QBrush QGraphicsViewPrivate::backgroundBrush

Definition at line 152 of file qgraphicsview_p.h.

◆ backgroundPixmap

QPixmap QGraphicsViewPrivate::backgroundPixmap

Definition at line 154 of file qgraphicsview_p.h.

◆ backgroundPixmapExposed

QRegion QGraphicsViewPrivate::backgroundPixmapExposed

Definition at line 155 of file qgraphicsview_p.h.

◆ cacheMode

QGraphicsView::CacheMode QGraphicsViewPrivate::cacheMode

Definition at line 146 of file qgraphicsview_p.h.

Referenced by recalculateContentSize().

◆ connectedToScene

quint32 QGraphicsViewPrivate::connectedToScene

Definition at line 84 of file qgraphicsview_p.h.

◆ dirtyBoundingRect

QRect QGraphicsViewPrivate::dirtyBoundingRect

Definition at line 172 of file qgraphicsview_p.h.

Referenced by processPendingUpdates(), and updateRect().

◆ dirtyRegion

QRegion QGraphicsViewPrivate::dirtyRegion

Definition at line 171 of file qgraphicsview_p.h.

Referenced by processPendingUpdates(), updateRect(), and updateRegion().

◆ dirtyScroll

quint32 QGraphicsViewPrivate::dirtyScroll

◆ dirtyScrollOffset

QPoint QGraphicsViewPrivate::dirtyScrollOffset

◆ dragMode

QGraphicsView::DragMode QGraphicsViewPrivate::dragMode

Definition at line 80 of file qgraphicsview_p.h.

Referenced by _q_unsetViewportCursor().

◆ exposedRegion

QRegion QGraphicsViewPrivate::exposedRegion

Definition at line 218 of file qgraphicsview_p.h.

◆ foregroundBrush

QBrush QGraphicsViewPrivate::foregroundBrush

Definition at line 153 of file qgraphicsview_p.h.

◆ fullUpdatePending

quint32 QGraphicsViewPrivate::fullUpdatePending

◆ handScrolling

quint32 QGraphicsViewPrivate::handScrolling

Definition at line 91 of file qgraphicsview_p.h.

Referenced by mouseMoveEventHandler().

◆ handScrollMotions

int QGraphicsViewPrivate::handScrollMotions

Definition at line 144 of file qgraphicsview_p.h.

◆ hasSceneRect

quint32 QGraphicsViewPrivate::hasSceneRect

Definition at line 83 of file qgraphicsview_p.h.

◆ hasStoredOriginalCursor

bool QGraphicsViewPrivate::hasStoredOriginalCursor

◆ hasUpdateClip

quint32 QGraphicsViewPrivate::hasUpdateClip

Definition at line 95 of file qgraphicsview_p.h.

Referenced by setUpdateClip(), updateRect(), and updateRegion().

◆ identityMatrix

quint32 QGraphicsViewPrivate::identityMatrix

◆ keepLastCenterPoint

quint32 QGraphicsViewPrivate::keepLastCenterPoint

Definition at line 89 of file qgraphicsview_p.h.

◆ lastCenterPoint

QPointF QGraphicsViewPrivate::lastCenterPoint

Definition at line 129 of file qgraphicsview_p.h.

Referenced by centerView(), recalculateContentSize(), and updateLastCenterPoint().

◆ lastDragDropEvent

QGraphicsSceneDragDropEvent* QGraphicsViewPrivate::lastDragDropEvent

Definition at line 164 of file qgraphicsview_p.h.

Referenced by storeDragDropEvent().

◆ lastMouseEvent

QMouseEvent QGraphicsViewPrivate::lastMouseEvent

◆ lastMouseMoveScenePoint

QPointF QGraphicsViewPrivate::lastMouseMoveScenePoint

Definition at line 112 of file qgraphicsview_p.h.

Referenced by centerView(), and mouseMoveEventHandler().

◆ lastMouseMoveScreenPoint

QPoint QGraphicsViewPrivate::lastMouseMoveScreenPoint

Definition at line 113 of file qgraphicsview_p.h.

Referenced by mouseMoveEventHandler().

◆ leftIndent

qreal QGraphicsViewPrivate::leftIndent

Definition at line 120 of file qgraphicsview_p.h.

Referenced by recalculateContentSize(), and updateScroll().

◆ matrix

QTransform QGraphicsViewPrivate::matrix

◆ mousePressButton

Qt::MouseButton QGraphicsViewPrivate::mousePressButton

Definition at line 115 of file qgraphicsview_p.h.

Referenced by mouseMoveEventHandler().

◆ mousePressItemPoint

QPointF QGraphicsViewPrivate::mousePressItemPoint

Definition at line 108 of file qgraphicsview_p.h.

◆ mousePressScenePoint

QPointF QGraphicsViewPrivate::mousePressScenePoint

Definition at line 109 of file qgraphicsview_p.h.

Referenced by mouseMoveEventHandler().

◆ mousePressScreenPoint

QPoint QGraphicsViewPrivate::mousePressScreenPoint

Definition at line 111 of file qgraphicsview_p.h.

Referenced by mouseMoveEventHandler().

◆ mousePressViewPoint

QPoint QGraphicsViewPrivate::mousePressViewPoint

Definition at line 110 of file qgraphicsview_p.h.

◆ mustAllocateStyleOptions

quint32 QGraphicsViewPrivate::mustAllocateStyleOptions

Definition at line 92 of file qgraphicsview_p.h.

Referenced by allocStyleOptionsArray(), and freeStyleOptionsArray().

◆ mustResizeBackgroundPixmap

quint32 QGraphicsViewPrivate::mustResizeBackgroundPixmap

Definition at line 93 of file qgraphicsview_p.h.

Referenced by recalculateContentSize().

◆ optimizationFlags

QGraphicsView::OptimizationFlags QGraphicsViewPrivate::optimizationFlags

Definition at line 135 of file qgraphicsview_p.h.

Referenced by updateRegion().

◆ originalCursor

QCursor QGraphicsViewPrivate::originalCursor

◆ padding

quint32 QGraphicsViewPrivate::padding

Definition at line 96 of file qgraphicsview_p.h.

◆ renderHints

QPainter::RenderHints QGraphicsViewPrivate::renderHints

Definition at line 78 of file qgraphicsview_p.h.

◆ resizeAnchor

QGraphicsView::ViewportAnchor QGraphicsViewPrivate::resizeAnchor

Definition at line 133 of file qgraphicsview_p.h.

◆ rubberBanding

bool QGraphicsViewPrivate::rubberBanding

Definition at line 141 of file qgraphicsview_p.h.

◆ rubberBandRect

QRect QGraphicsViewPrivate::rubberBandRect

Definition at line 139 of file qgraphicsview_p.h.

◆ rubberBandSelectionMode

Qt::ItemSelectionMode QGraphicsViewPrivate::rubberBandSelectionMode

Definition at line 142 of file qgraphicsview_p.h.

◆ scene

QPointer<QGraphicsScene> QGraphicsViewPrivate::scene

◆ sceneInteractionAllowed

quint32 QGraphicsViewPrivate::sceneInteractionAllowed

Definition at line 82 of file qgraphicsview_p.h.

Referenced by mouseMoveEventHandler().

◆ sceneRect

QRectF QGraphicsViewPrivate::sceneRect

Definition at line 98 of file qgraphicsview_p.h.

◆ scrollX

qint64 QGraphicsViewPrivate::scrollX

◆ scrollY

qint64 QGraphicsViewPrivate::scrollY

◆ styleOptions

QVector<QStyleOptionGraphicsItem> QGraphicsViewPrivate::styleOptions

◆ topIndent

qreal QGraphicsViewPrivate::topIndent

Definition at line 121 of file qgraphicsview_p.h.

Referenced by recalculateContentSize(), and updateScroll().

◆ transformationAnchor

QGraphicsView::ViewportAnchor QGraphicsViewPrivate::transformationAnchor

Definition at line 132 of file qgraphicsview_p.h.

◆ transforming

quint32 QGraphicsViewPrivate::transforming

Definition at line 90 of file qgraphicsview_p.h.

◆ updateClip

QRect QGraphicsViewPrivate::updateClip

Definition at line 107 of file qgraphicsview_p.h.

Referenced by setUpdateClip(), updateRect(), and updateRegion().

◆ updateSceneSlotReimplementedChecked

bool QGraphicsViewPrivate::updateSceneSlotReimplementedChecked

Definition at line 217 of file qgraphicsview_p.h.

◆ useLastMouseEvent

quint32 QGraphicsViewPrivate::useLastMouseEvent

Definition at line 85 of file qgraphicsview_p.h.

Referenced by replayLastMouseEvent(), and storeMouseEvent().

◆ viewportUpdateMode

QGraphicsView::ViewportUpdateMode QGraphicsViewPrivate::viewportUpdateMode

The documentation for this class was generated from the following files: