diff options
author | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2009-09-18 14:26:43 (GMT) |
---|---|---|
committer | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2009-09-22 15:08:47 (GMT) |
commit | 6ad6dcd4c714dfff700029461638c235469f08d7 (patch) | |
tree | 1f0780cbeeb2b20e5a98fc772f6393fa9863aeb5 /src | |
parent | 77b1f0ab8c8055835a3fc92d784d536efdc6acbf (diff) | |
download | Qt-6ad6dcd4c714dfff700029461638c235469f08d7.zip Qt-6ad6dcd4c714dfff700029461638c235469f08d7.tar.gz Qt-6ad6dcd4c714dfff700029461638c235469f08d7.tar.bz2 |
Inverts the SortOrder in graphics scene to reflect the stacking order
Inverted all references of Qt::AscendingiOrder <-> Qt::DescendingOrder
to make the order parameter consistent with the stacking order, as stated in
the docs. The graphics scene index was using the wrong ordering convention.
Reviewed-by: andreas
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 28 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp | 14 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h | 2 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicssceneindex.cpp | 4 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicssceneindex_p.h | 6 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscenelinearindex.cpp | 2 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscenelinearindex_p.h | 2 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsview.cpp | 16 |
8 files changed, 37 insertions, 37 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index a267996..0655ecc 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -925,19 +925,19 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::itemsAtPosition(const QPoint &scre Q_Q(const QGraphicsScene); QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0; if (!view) - return q->items(scenePos, Qt::IntersectsItemShape, Qt::AscendingOrder, QTransform()); + return q->items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder, QTransform()); const QRectF pointRect(QPointF(widget->mapFromGlobal(screenPos)), QSizeF(1, 1)); if (!view->isTransformed()) - return q->items(pointRect, Qt::IntersectsItemShape, Qt::AscendingOrder); + return q->items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder); const QTransform viewTransform = view->viewportTransform(); if (viewTransform.type() <= QTransform::TxScale) { return q->items(viewTransform.inverted().mapRect(pointRect), Qt::IntersectsItemShape, - Qt::AscendingOrder, viewTransform); + Qt::DescendingOrder, viewTransform); } return q->items(viewTransform.inverted().map(pointRect), Qt::IntersectsItemShape, - Qt::AscendingOrder, viewTransform); + Qt::DescendingOrder, viewTransform); } /*! @@ -1584,7 +1584,7 @@ void QGraphicsScene::setItemIndexMethod(ItemIndexMethod method) d->indexMethod = method; - QList<QGraphicsItem *> oldItems = d->index->items(Qt::AscendingOrder); + QList<QGraphicsItem *> oldItems = d->index->items(Qt::DescendingOrder); delete d->index; if (method == BspTreeIndex) d->index = new QGraphicsSceneBspTreeIndex(this); @@ -1693,7 +1693,7 @@ QRectF QGraphicsScene::itemsBoundingRect() const QList<QGraphicsItem *> QGraphicsScene::items() const { Q_D(const QGraphicsScene); - return d->index->items(Qt::AscendingOrder); + return d->index->items(Qt::DescendingOrder); } /*! @@ -1724,7 +1724,7 @@ QList<QGraphicsItem *> QGraphicsScene::items(Qt::SortOrder order) const QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos) const { Q_D(const QGraphicsScene); - return d->index->items(pos, Qt::IntersectsItemShape, Qt::AscendingOrder); + return d->index->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder); } /*! @@ -1746,7 +1746,7 @@ QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos) const QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rectangle, Qt::ItemSelectionMode mode) const { Q_D(const QGraphicsScene); - return d->index->items(rectangle, mode, Qt::AscendingOrder); + return d->index->items(rectangle, mode, Qt::DescendingOrder); } /*! @@ -1794,7 +1794,7 @@ QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rectangle, Qt::ItemSe QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode) const { Q_D(const QGraphicsScene); - return d->index->items(polygon, mode, Qt::AscendingOrder); + return d->index->items(polygon, mode, Qt::DescendingOrder); } /*! @@ -1816,7 +1816,7 @@ QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemS QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode) const { Q_D(const QGraphicsScene); - return d->index->items(path, mode, Qt::AscendingOrder); + return d->index->items(path, mode, Qt::DescendingOrder); } /*! @@ -1928,7 +1928,7 @@ QList<QGraphicsItem *> QGraphicsScene::collidingItems(const QGraphicsItem *item, // Does not support ItemIgnoresTransformations. QList<QGraphicsItem *> tmp; - foreach (QGraphicsItem *itemInVicinity, d->index->estimateItems(item->sceneBoundingRect(), Qt::AscendingOrder)) { + foreach (QGraphicsItem *itemInVicinity, d->index->estimateItems(item->sceneBoundingRect(), Qt::DescendingOrder)) { if (item != itemInVicinity && item->collidesWithItem(itemInVicinity, mode)) tmp << itemInVicinity; } @@ -1972,7 +1972,7 @@ QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position) const QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform &deviceTransform) const { QList<QGraphicsItem *> itemsAtPoint = items(position, Qt::IntersectsItemShape, - Qt::AscendingOrder, deviceTransform); + Qt::DescendingOrder, deviceTransform); return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first(); } @@ -2127,7 +2127,7 @@ void QGraphicsScene::setSelectionArea(const QPainterPath &path, Qt::ItemSelectio bool changed = false; // Set all items in path to selected. - foreach (QGraphicsItem *item, items(path, mode, Qt::AscendingOrder, deviceTransform)) { + foreach (QGraphicsItem *item, items(path, mode, Qt::DescendingOrder, deviceTransform)) { if (item->flags() & QGraphicsItem::ItemIsSelectable) { if (!item->isSelected()) changed = true; @@ -4371,7 +4371,7 @@ void QGraphicsScenePrivate::drawItems(QPainter *painter, const QTransform *const if (viewTransform) exposedSceneRect = viewTransform->inverted().mapRect(exposedSceneRect); } - const QList<QGraphicsItem *> tli = index->estimateTopLevelItems(exposedSceneRect, Qt::DescendingOrder); + const QList<QGraphicsItem *> tli = index->estimateTopLevelItems(exposedSceneRect, Qt::AscendingOrder); for (int i = 0; i < tli.size(); ++i) drawSubtreeRecursive(tli.at(i), painter, viewTransform, exposedRegion, widget); } diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp index 7c46144..e21183a 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp @@ -480,23 +480,23 @@ void QGraphicsSceneBspTreeIndexPrivate::sortItems(QList<QGraphicsItem *> *itemLi return; if (onlyTopLevelItems) { - if (order == Qt::AscendingOrder) + if (order == Qt::DescendingOrder) qSort(itemList->begin(), itemList->end(), qt_closestLeaf); - else if (order == Qt::DescendingOrder) + else if (order == Qt::AscendingOrder) qSort(itemList->begin(), itemList->end(), qt_notclosestLeaf); return; } if (sortCacheEnabled) { - if (order == Qt::AscendingOrder) { + if (order == Qt::DescendingOrder) { qSort(itemList->begin(), itemList->end(), closestItemFirst_withCache); - } else if (order == Qt::DescendingOrder) { + } else if (order == Qt::AscendingOrder) { qSort(itemList->begin(), itemList->end(), closestItemLast_withCache); } } else { - if (order == Qt::AscendingOrder) { + if (order == Qt::DescendingOrder) { qSort(itemList->begin(), itemList->end(), closestItemFirst_withoutCache); - } else if (order == Qt::DescendingOrder) { + } else if (order == Qt::AscendingOrder) { qSort(itemList->begin(), itemList->end(), closestItemLast_withoutCache); } } @@ -605,7 +605,7 @@ QList<QGraphicsItem *> QGraphicsSceneBspTreeIndex::estimateTopLevelItems(const Q } /*! - \fn QList<QGraphicsItem *> QGraphicsSceneBspTreeIndex::items(Qt::SortOrder order = Qt::AscendingOrder) const; + \fn QList<QGraphicsItem *> QGraphicsSceneBspTreeIndex::items(Qt::SortOrder order = Qt::DescendingOrder) const; Return all items in the BSP index and sort them using \a order. */ diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h index cf85ba8..0a86bb7 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h @@ -81,7 +81,7 @@ public: QList<QGraphicsItem *> estimateItems(const QRectF &rect, Qt::SortOrder order) const; QList<QGraphicsItem *> estimateTopLevelItems(const QRectF &rect, Qt::SortOrder order) const; - QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::AscendingOrder) const; + QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::DescendingOrder) const; int bspTreeDepth(); void setBspTreeDepth(int depth); diff --git a/src/gui/graphicsview/qgraphicssceneindex.cpp b/src/gui/graphicsview/qgraphicssceneindex.cpp index e01ad10..3ea957f 100644 --- a/src/gui/graphicsview/qgraphicssceneindex.cpp +++ b/src/gui/graphicsview/qgraphicssceneindex.cpp @@ -542,7 +542,7 @@ QList<QGraphicsItem *> QGraphicsSceneIndex::estimateTopLevelItems(const QRectF & Q_UNUSED(rect); QGraphicsScenePrivate *scened = d->scene->d_func(); scened->ensureSortedTopLevelItems(); - if (order == Qt::AscendingOrder) { + if (order == Qt::DescendingOrder) { QList<QGraphicsItem *> sorted; for (int i = scened->topLevelItems.size() - 1; i >= 0; --i) sorted << scened->topLevelItems.at(i); @@ -552,7 +552,7 @@ QList<QGraphicsItem *> QGraphicsSceneIndex::estimateTopLevelItems(const QRectF & } /*! - \fn QList<QGraphicsItem *> QGraphicsSceneIndex::items(Qt::SortOrder order = Qt::AscendingOrder) const + \fn QList<QGraphicsItem *> QGraphicsSceneIndex::items(Qt::SortOrder order = Qt::DescendingOrder) const This pure virtual function all items in the index and sort them using \a order. diff --git a/src/gui/graphicsview/qgraphicssceneindex_p.h b/src/gui/graphicsview/qgraphicssceneindex_p.h index ab7b38c..768c724 100644 --- a/src/gui/graphicsview/qgraphicssceneindex_p.h +++ b/src/gui/graphicsview/qgraphicssceneindex_p.h @@ -88,7 +88,7 @@ public: QGraphicsScene *scene() const; - virtual QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::AscendingOrder) const = 0; + virtual QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::DescendingOrder) const = 0; virtual QList<QGraphicsItem *> items(const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform = QTransform()) const; virtual QList<QGraphicsItem *> items(const QRectF &rect, Qt::ItemSelectionMode mode, @@ -154,10 +154,10 @@ inline void QGraphicsSceneIndexPrivate::items_helper(const QRectF &rect, QGraphi Qt::ItemSelectionMode mode, Qt::SortOrder order) const { Q_Q(const QGraphicsSceneIndex); - const QList<QGraphicsItem *> tli = q->estimateTopLevelItems(rect, Qt::DescendingOrder); + const QList<QGraphicsItem *> tli = q->estimateTopLevelItems(rect, Qt::AscendingOrder); for (int i = 0; i < tli.size(); ++i) recursive_items_helper(tli.at(i), rect, intersector, items, viewTransform, mode, order); - if (order == Qt::AscendingOrder) { + if (order == Qt::DescendingOrder) { const int n = items->size(); for (int i = 0; i < n / 2; ++i) items->swap(i, n - i - 1); diff --git a/src/gui/graphicsview/qgraphicsscenelinearindex.cpp b/src/gui/graphicsview/qgraphicsscenelinearindex.cpp index 70fed64..d6faf05 100644 --- a/src/gui/graphicsview/qgraphicsscenelinearindex.cpp +++ b/src/gui/graphicsview/qgraphicsscenelinearindex.cpp @@ -62,7 +62,7 @@ */ /*! - \fn QList<QGraphicsItem *> QGraphicsSceneLinearIndex::items(Qt::SortOrder order = Qt::AscendingOrder) const; + \fn QList<QGraphicsItem *> QGraphicsSceneLinearIndex::items(Qt::SortOrder order = Qt::DescendingOrder) const; Return all items in the index and sort them using \a order. */ diff --git a/src/gui/graphicsview/qgraphicsscenelinearindex_p.h b/src/gui/graphicsview/qgraphicsscenelinearindex_p.h index 4c4aa9f..0aaee14 100644 --- a/src/gui/graphicsview/qgraphicsscenelinearindex_p.h +++ b/src/gui/graphicsview/qgraphicsscenelinearindex_p.h @@ -76,7 +76,7 @@ public: QGraphicsSceneLinearIndex(QGraphicsScene *scene = 0) : QGraphicsSceneIndex(scene) { } - QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::AscendingOrder) const + QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::DescendingOrder) const { Q_UNUSED(order); return m_items; } virtual QList<QGraphicsItem *> estimateItems(const QRectF &rect, Qt::SortOrder order) const diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index b0829c5..98b2c9c 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -971,7 +971,7 @@ QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedReg *allItems = true; // All items are guaranteed within the exposed region. - return scene->items(Qt::DescendingOrder); + return scene->items(Qt::AscendingOrder); } // Step 2) If the expose region is a simple rect and the view is only @@ -981,7 +981,7 @@ QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedReg if (simpleRectLookup) { return scene->items(exposedRegionSceneBounds, Qt::IntersectsItemBoundingRect, - Qt::DescendingOrder, viewTransform); + Qt::AscendingOrder, viewTransform); } // If the region is complex or the view has a complex transform, adjust @@ -993,7 +993,7 @@ QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedReg const QPainterPath exposedScenePath(q->mapToScene(qt_regionToPath(adjustedRegion))); return scene->items(exposedScenePath, Qt::IntersectsItemBoundingRect, - Qt::DescendingOrder, viewTransform); + Qt::AscendingOrder, viewTransform); } /*! @@ -2055,13 +2055,13 @@ QList<QGraphicsItem *> QGraphicsView::items(const QPoint &pos) const QTransform xinv = viewportTransform().inverted(); return d->scene->items(xinv.mapRect(QRectF(pos.x(), pos.y(), 1, 1)), Qt::IntersectsItemShape, - Qt::AscendingOrder, + Qt::DescendingOrder, viewportTransform()); } // Use the polygon version return d->scene->items(mapToScene(pos.x(), pos.y(), 1, 1), Qt::IntersectsItemShape, - Qt::AscendingOrder, + Qt::DescendingOrder, viewportTransform()); } @@ -2089,7 +2089,7 @@ QList<QGraphicsItem *> QGraphicsView::items(const QRect &rect, Qt::ItemSelection Q_D(const QGraphicsView); if (!d->scene) return QList<QGraphicsItem *>(); - return d->scene->items(mapToScene(rect), mode, Qt::AscendingOrder, viewportTransform()); + return d->scene->items(mapToScene(rect), mode, Qt::DescendingOrder, viewportTransform()); } /*! @@ -2117,7 +2117,7 @@ QList<QGraphicsItem *> QGraphicsView::items(const QPolygon &polygon, Qt::ItemSel Q_D(const QGraphicsView); if (!d->scene) return QList<QGraphicsItem *>(); - return d->scene->items(mapToScene(polygon), mode, Qt::AscendingOrder, viewportTransform()); + return d->scene->items(mapToScene(polygon), mode, Qt::DescendingOrder, viewportTransform()); } /*! @@ -2137,7 +2137,7 @@ QList<QGraphicsItem *> QGraphicsView::items(const QPainterPath &path, Qt::ItemSe Q_D(const QGraphicsView); if (!d->scene) return QList<QGraphicsItem *>(); - return d->scene->items(mapToScene(path), mode, Qt::AscendingOrder, viewportTransform()); + return d->scene->items(mapToScene(path), mode, Qt::DescendingOrder, viewportTransform()); } /*! |