Changeset 561 for trunk/src/gui/graphicsview/qgraphicsscene_p.h
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/graphicsview/qgraphicsscene_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 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 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 48 48 // 49 49 // This file is not part of the Qt API. It exists for the convenience 50 // of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header51 // file may change from version toversion without notice, or even be removed.50 // of other Qt classes. This header file may change from version to 51 // version without notice, or even be removed. 52 52 // 53 53 // We mean it. … … 58 58 #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW 59 59 60 #include "qgraphicsscene_bsp_p.h" 60 #include "qgraphicssceneevent.h" 61 #include "qgraphicsview.h" 62 #include "qgraphicsview_p.h" 61 63 #include "qgraphicsitem_p.h" 62 64 … … 69 71 #include <QtGui/qpalette.h> 70 72 #include <QtGui/qstyle.h> 73 #include <QtGui/qstyleoption.h> 71 74 72 75 QT_BEGIN_NAMESPACE 73 76 77 class QGraphicsSceneIndex; 74 78 class QGraphicsView; 75 79 class QGraphicsWidget; 76 80 77 class Q GraphicsScenePrivate : public QObjectPrivate81 class Q_AUTOTEST_EXPORT QGraphicsScenePrivate : public QObjectPrivate 78 82 { 79 83 Q_DECLARE_PUBLIC(QGraphicsScene) … … 82 86 void init(); 83 87 84 quint32 changedSignalMask; 88 static QGraphicsScenePrivate *get(QGraphicsScene *q); 89 90 static int changedSignalIndex; 85 91 86 92 QGraphicsScene::ItemIndexMethod indexMethod; 87 int bspTreeDepth; 88 89 QList<QGraphicsItem *> estimateItemsInRect(const QRectF &rect) const; 90 void addToIndex(QGraphicsItem *item); 91 void removeFromIndex(QGraphicsItem *item); 92 void resetIndex(); 93 94 QGraphicsSceneBspTree bspTree; 95 void _q_updateIndex(); 93 QGraphicsSceneIndex *index; 94 96 95 int lastItemCount; 97 96 98 97 QRectF sceneRect; 99 98 bool hasSceneRect; 99 bool dirtyGrowingItemsBoundingRect; 100 100 QRectF growingItemsBoundingRect; 101 QRectF largestUntransformableItem;102 101 103 102 void _q_emitUpdated(); … … 105 104 bool updateAll; 106 105 bool calledEmitUpdated; 106 bool processDirtyItemsEmitted; 107 107 108 108 QPainterPath selectionArea; 109 109 int selectionChanging; 110 110 QSet<QGraphicsItem *> selectedItems; 111 QList<QGraphicsItem *> unindexedItems; 112 QList<QGraphicsItem *> indexedItems; 113 QList<QGraphicsItem *> dirtyItems; 114 QList<QGraphicsItem *> pendingUpdateItems; 115 QList<QGraphicsItem *> unpolishedItems; 111 QSet<QGraphicsItem *> unpolishedItems; 112 QList<QGraphicsItem *> topLevelItems; 113 bool needSortTopLevelItems; 114 bool unpolishedItemsModified; 115 bool holesInTopLevelSiblingIndex; 116 bool topLevelSequentialOrdering; 117 116 118 QMap<QGraphicsItem *, QPointF> movingItemsInitialPositions; 119 void registerTopLevelItem(QGraphicsItem *item); 120 void unregisterTopLevelItem(QGraphicsItem *item); 117 121 void _q_updateLater(); 118 122 void _q_polishItems(); 119 123 120 void _q_resetDirtyItems(); 121 void resetDirtyItemsLater(); 122 bool dirtyItemResetPending; 123 124 QList<int> freeItemIndexes; 125 bool regenerateIndex; 126 127 bool purgePending; 128 void _q_removeItemLater(QGraphicsItem *item); 129 QSet<QGraphicsItem *> removedItems; 130 void purgeRemovedItems(); 124 void _q_processDirtyItems(); 125 126 QSet<QGraphicsItem *> scenePosItems; 127 bool scenePosDescendantsUpdatePending; 128 void setScenePosItemEnabled(QGraphicsItem *item, bool enabled); 129 void registerScenePosItem(QGraphicsItem *item); 130 void unregisterScenePosItem(QGraphicsItem *item); 131 void _q_updateScenePosDescendants(); 132 133 void removeItemHelper(QGraphicsItem *item); 131 134 132 135 QBrush backgroundBrush; 133 136 QBrush foregroundBrush; 134 135 int indexTimerId;136 bool restartIndexTimer;137 void startIndexTimer();138 137 139 138 bool stickyFocus; … … 142 141 QGraphicsItem *lastFocusItem; 143 142 QGraphicsWidget *tabFocusFirst; 144 QGraphicsWidget *activeWindow; 143 QGraphicsItem *activePanel; 144 QGraphicsItem *lastActivePanel; 145 145 int activationRefCount; 146 int childExplicitActivation; 147 void setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent); 148 void setFocusItemHelper(QGraphicsItem *item, Qt::FocusReason focusReason); 146 149 147 150 QList<QGraphicsWidget *> popupWidgets; … … 160 163 void ungrabKeyboard(QGraphicsItem *item, bool itemIsDying = false); 161 164 void clearKeyboardGrabber(); 162 165 163 166 QGraphicsItem *dragDropItem; 164 167 QGraphicsWidget *enterWidget; … … 166 169 QList<QGraphicsItem *> cachedItemsUnderMouse; 167 170 QList<QGraphicsItem *> hoverItems; 171 QPointF lastSceneMousePos; 172 bool allItemsIgnoreHoverEvents; 173 bool allItemsUseDefaultCursor; 174 void enableMouseTrackingOnViews(); 168 175 QMap<Qt::MouseButton, QPointF> mouseGrabberButtonDownPos; 169 176 QMap<Qt::MouseButton, QPointF> mouseGrabberButtonDownScenePos; … … 172 179 const QPointF &scenePos, 173 180 QWidget *widget) const; 174 static bool itemCollidesWithPath(QGraphicsItem *item, const QPainterPath &path, Qt::ItemSelectionMode mode);175 181 void storeMouseButtonsForMouseGrabber(QGraphicsSceneMouseEvent *event); 176 182 177 183 QList<QGraphicsView *> views; 184 void addView(QGraphicsView *view); 185 void removeView(QGraphicsView *view); 186 178 187 bool painterStateProtection; 179 188 … … 181 190 void installSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter); 182 191 void removeSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter); 192 bool filterDescendantEvent(QGraphicsItem *item, QEvent *event); 183 193 bool filterEvent(QGraphicsItem *item, QEvent *event); 184 194 bool sendEvent(QGraphicsItem *item, QEvent *event); … … 198 208 QGraphicsWidget *windowForItem(const QGraphicsItem *item) const; 199 209 200 QList<QGraphicsItem *> items_helper(const QPointF &pos) const; 201 QList<QGraphicsItem *> items_helper(const QRectF &rect, 202 Qt::ItemSelectionMode mode, 203 Qt::SortOrder order) const; 204 QList<QGraphicsItem *> items_helper(const QPolygonF &rect, 205 Qt::ItemSelectionMode mode, 206 Qt::SortOrder order) const; 207 QList<QGraphicsItem *> items_helper(const QPainterPath &rect, 208 Qt::ItemSelectionMode mode, 209 Qt::SortOrder order) const; 210 void childItems_helper(QList<QGraphicsItem *> *items, 211 const QGraphicsItem *parent, 212 const QPointF &pos) const; 213 void childItems_helper(QList<QGraphicsItem *> *items, 214 const QGraphicsItem *parent, 215 const QRectF &rect, 216 Qt::ItemSelectionMode mode) const; 217 void childItems_helper(QList<QGraphicsItem *> *items, 218 const QGraphicsItem *parent, 219 const QPolygonF &polygon, 220 Qt::ItemSelectionMode mode) const; 221 void childItems_helper(QList<QGraphicsItem *> *items, 222 const QGraphicsItem *parent, 223 const QPainterPath &path, 224 Qt::ItemSelectionMode mode) const; 225 226 bool sortCacheEnabled; 227 bool updatingSortCache; 228 void invalidateSortCache(); 229 static void climbTree(QGraphicsItem *item, int *stackingOrder); 230 void _q_updateSortCache(); 231 232 static bool closestItemFirst_withoutCache(const QGraphicsItem *item1, const QGraphicsItem *item2); 233 static bool closestItemLast_withoutCache(const QGraphicsItem *item1, const QGraphicsItem *item2); 234 235 static inline bool closestItemFirst_withCache(const QGraphicsItem *item1, const QGraphicsItem *item2) 236 { 237 return item1->d_ptr->globalStackingOrder < item2->d_ptr->globalStackingOrder; 238 } 239 static inline bool closestItemLast_withCache(const QGraphicsItem *item1, const QGraphicsItem *item2) 240 { 241 return item1->d_ptr->globalStackingOrder >= item2->d_ptr->globalStackingOrder; 242 } 243 244 static void sortItems(QList<QGraphicsItem *> *itemList, Qt::SortOrder order, bool cached); 210 bool sortCacheEnabled; // for compatibility 245 211 246 212 void drawItemHelper(QGraphicsItem *item, QPainter *painter, 247 213 const QStyleOptionGraphicsItem *option, QWidget *widget, 248 214 bool painterStateProtection); 249 215 216 void drawItems(QPainter *painter, const QTransform *const viewTransform, 217 QRegion *exposedRegion, QWidget *widget); 218 219 void drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, const QTransform *const, 220 QRegion *exposedRegion, QWidget *widget, qreal parentOpacity = qreal(1.0), 221 const QTransform *const effectTransform = 0); 222 void draw(QGraphicsItem *, QPainter *, const QTransform *const, const QTransform *const, 223 QRegion *, QWidget *, qreal, const QTransform *const, bool, bool); 224 225 void markDirty(QGraphicsItem *item, const QRectF &rect = QRectF(), bool invalidateChildren = false, 226 bool force = false, bool ignoreOpacity = false, bool removingItemFromScene = false); 227 void processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren = false, 228 qreal parentOpacity = qreal(1.0)); 229 230 inline void resetDirtyItem(QGraphicsItem *item, bool recursive = false) 231 { 232 Q_ASSERT(item); 233 item->d_ptr->dirty = 0; 234 item->d_ptr->paintedViewBoundingRectsNeedRepaint = 0; 235 item->d_ptr->geometryChanged = 0; 236 if (!item->d_ptr->dirtyChildren) 237 recursive = false; 238 item->d_ptr->dirtyChildren = 0; 239 item->d_ptr->needsRepaint = QRectF(); 240 item->d_ptr->allChildrenDirty = 0; 241 item->d_ptr->fullUpdatePending = 0; 242 item->d_ptr->ignoreVisible = 0; 243 item->d_ptr->ignoreOpacity = 0; 244 #ifndef QT_NO_GRAPHICSEFFECT 245 QGraphicsEffect::ChangeFlags flags; 246 if (item->d_ptr->notifyBoundingRectChanged) { 247 flags |= QGraphicsEffect::SourceBoundingRectChanged; 248 item->d_ptr->notifyBoundingRectChanged = 0; 249 } 250 if (item->d_ptr->notifyInvalidated) { 251 flags |= QGraphicsEffect::SourceInvalidated; 252 item->d_ptr->notifyInvalidated = 0; 253 } 254 #endif //QT_NO_GRAPHICSEFFECT 255 if (recursive) { 256 for (int i = 0; i < item->d_ptr->children.size(); ++i) 257 resetDirtyItem(item->d_ptr->children.at(i), recursive); 258 } 259 #ifndef QT_NO_GRAPHICSEFFECT 260 if (flags && item->d_ptr->graphicsEffect) 261 item->d_ptr->graphicsEffect->sourceChanged(flags); 262 #endif //QT_NO_GRAPHICSEFFECT 263 } 264 265 inline void ensureSortedTopLevelItems() 266 { 267 if (needSortTopLevelItems) { 268 qSort(topLevelItems.begin(), topLevelItems.end(), qt_notclosestLeaf); 269 topLevelSequentialOrdering = false; 270 needSortTopLevelItems = false; 271 } 272 } 273 274 void ensureSequentialTopLevelSiblingIndexes(); 275 250 276 QStyle *style; 251 277 QFont font; … … 258 284 void updatePalette(const QPalette &palette); 259 285 260 mutable QVector<QTransform> sceneTransformCache; 261 mutable QBitArray validTransforms; 262 mutable QVector<int> freeSceneTransformSlots; 286 QStyleOptionGraphicsItem styleOptionTmp; 287 288 QMap<int, QTouchEvent::TouchPoint> sceneCurrentTouchPoints; 289 QMap<int, QGraphicsItem *> itemForTouchPointId; 290 static void updateTouchPointsForItem(QGraphicsItem *item, QTouchEvent *touchEvent); 291 int findClosestTouchPointId(const QPointF &scenePos); 292 void touchEventHandler(QTouchEvent *touchEvent); 293 bool sendTouchBeginEvent(QGraphicsItem *item, QTouchEvent *touchEvent); 294 bool allItemsIgnoreTouchEvents; 295 void enableTouchEventsOnViews(); 296 297 QHash<QGesture *, QGraphicsObject *> gestureTargets; 298 void gestureEventHandler(QGestureEvent *event); 299 void getGestureTargets(const QSet<QGesture *> &gestures, QWidget *viewport, 300 QMap<Qt::GestureType, QGesture *> *conflictedGestures, 301 QList<QList<QGraphicsObject *> > *conflictedItems, 302 QHash<QGesture *, QGraphicsObject *> *normalGestures); 303 void cancelGesturesForChildren(QGesture *original, QWidget *viewport); 304 305 void updateInputMethodSensitivityInViews(); 306 307 QList<QGraphicsItem *> modalPanels; 308 void enterModal(QGraphicsItem *item, 309 QGraphicsItem::PanelModality panelModality = QGraphicsItem::NonModal); 310 void leaveModal(QGraphicsItem *item); 263 311 }; 264 312 313 // QRectF::intersects() returns false always if either the source or target 314 // rectangle's width or height are 0. This works around that problem. 315 static inline void _q_adjustRect(QRectF *rect) 316 { 317 Q_ASSERT(rect); 318 if (!rect->width()) 319 rect->adjust(qreal(-0.00001), 0, qreal(0.00001), 0); 320 if (!rect->height()) 321 rect->adjust(0, qreal(-0.00001), 0, qreal(0.00001)); 322 } 323 324 static inline QRectF adjustedItemBoundingRect(const QGraphicsItem *item) 325 { 326 Q_ASSERT(item); 327 QRectF boundingRect(item->boundingRect()); 328 _q_adjustRect(&boundingRect); 329 return boundingRect; 330 } 331 332 static inline QRectF adjustedItemEffectiveBoundingRect(const QGraphicsItem *item) 333 { 334 Q_ASSERT(item); 335 QRectF boundingRect(QGraphicsItemPrivate::get(item)->effectiveBoundingRect()); 336 _q_adjustRect(&boundingRect); 337 return boundingRect; 338 } 339 265 340 QT_END_NAMESPACE 266 341
Note:
See TracChangeset
for help on using the changeset viewer.