diff options
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsitem.cpp')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitem.cpp | 81 |
1 files changed, 10 insertions, 71 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 9008b54d84..17ea830cab 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -904,7 +904,6 @@ QGraphicsItemPrivate::QGraphicsItemPrivate() scenePosDescendants(false), pendingPolish(false), mayHaveChildWithGraphicsEffect(false), - isDeclarativeItem(false), sendParentChangeNotification(false), dirtyChildrenBoundingRect(true), globalStackingOrder(-1), @@ -1036,7 +1035,7 @@ void QGraphicsItemPrivate::setIsMemberOfGroup(bool enabled) Q_Q(QGraphicsItem); isMemberOfGroup = enabled; if (!qgraphicsitem_cast<QGraphicsItemGroup *>(q)) { - for (QGraphicsItem *child : qAsConst(children)) + for (QGraphicsItem *child : std::as_const(children)) child->d_func()->setIsMemberOfGroup(enabled); } } @@ -2175,7 +2174,7 @@ bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const if (!scene_d->popupWidgets.isEmpty() && scene_d->popupWidgets.first() == this) return false; - for (int i = 0; i < scene_d->modalPanels.count(); ++i) { + for (int i = 0; i < scene_d->modalPanels.size(); ++i) { QGraphicsItem *modalPanel = scene_d->modalPanels.at(i); if (modalPanel->panelModality() == QGraphicsItem::SceneModal) { // Scene modal panels block all non-descendents. @@ -2458,7 +2457,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, const bool updateChildren = update && !((flags & QGraphicsItem::ItemClipsChildrenToShape || flags & QGraphicsItem::ItemContainsChildrenInShape) && !(flags & QGraphicsItem::ItemHasNoContents)); - for (QGraphicsItem *child : qAsConst(children)) { + for (QGraphicsItem *child : std::as_const(children)) { if (!newVisible || !child->d_ptr->explicitlyHidden) child->d_ptr->setVisibleHelper(newVisible, false, updateChildren, hiddenByPanel); } @@ -2650,7 +2649,7 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo if (update) q_ptr->update(); - for (QGraphicsItem *child : qAsConst(children)) { + for (QGraphicsItem *child : std::as_const(children)) { if (!newEnabled || !child->d_ptr->explicitlyDisabled) child->d_ptr->setEnabledHelper(newEnabled, /* explicitly = */ false); } @@ -3917,7 +3916,7 @@ void QGraphicsItem::ensureVisible(const QRectF &rect, int xmargin, int ymargin) sceneRect = sceneTransform().mapRect(rect); else sceneRect = sceneBoundingRect(); - for (QGraphicsView *view : qAsConst(d_ptr->scene->d_func()->views)) + for (QGraphicsView *view : std::as_const(d_ptr->scene->d_func()->views)) view->ensureVisible(sceneRect, xmargin, ymargin); } } @@ -4627,7 +4626,7 @@ inline void QGraphicsItemPrivate::sendScenePosChange() if (flags & QGraphicsItem::ItemSendsScenePositionChanges) q->itemChange(QGraphicsItem::ItemScenePositionHasChanged, q->scenePos()); if (scenePosDescendants) { - for (QGraphicsItem *item : qAsConst(scene->d_func()->scenePosItems)) { + for (QGraphicsItem *item : std::as_const(scene->d_func()->scenePosItems)) { if (q->isAncestorOf(item)) item->itemChange(QGraphicsItem::ItemScenePositionHasChanged, item->scenePos()); } @@ -6502,7 +6501,7 @@ void QGraphicsItem::setData(int key, const QVariant &value) } /*! - \fn T qgraphicsitem_cast(QGraphicsItem *item) + \fn template <class T> qgraphicsitem_cast(QGraphicsItem *item) \relates QGraphicsItem \since 4.2 @@ -7083,7 +7082,7 @@ void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) selectedItems = d_ptr->scene->selectedItems(); initialPositions = d_ptr->scene->d_func()->movingItemsInitialPositions; if (initialPositions.isEmpty()) { - for (QGraphicsItem *item : qAsConst(selectedItems)) + for (QGraphicsItem *item : std::as_const(selectedItems)) initialPositions[item] = item->pos(); initialPositions[this] = pos(); } @@ -7192,7 +7191,7 @@ void QGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) // temporarily removing this item from the selection list. if (d_ptr->selected) { scene->d_func()->selectedItems.remove(this); - for (QGraphicsItem *item : qAsConst(scene->d_func()->selectedItems)) { + for (QGraphicsItem *item : std::as_const(scene->d_func()->selectedItems)) { if (item->isSelected()) { selectionChanged = true; break; @@ -7650,66 +7649,6 @@ void QGraphicsObject::updateMicroFocus() QGraphicsItem::updateMicroFocus(); } -void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item) -{ - if (item) { - QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object); - if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) { - item->setParentItem(graphicsObject); - } else { - QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, nullptr, nullptr); - } - } -} - -int QGraphicsItemPrivate::children_count(QDeclarativeListProperty<QGraphicsObject> *list) -{ - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); - return d->children.count(); -} - -QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGraphicsObject> *list, int index) -{ - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); - if (index >= 0 && index < d->children.count()) - return d->children.at(index)->toGraphicsObject(); - else - return nullptr; -} - -void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObject> *list) -{ - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); - int childCount = d->children.count(); - if (d->sendParentChangeNotification) { - for (int index = 0; index < childCount; index++) - d->children.at(0)->setParentItem(nullptr); - } else { - for (int index = 0; index < childCount; index++) - QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(nullptr, nullptr, nullptr); - } -} - -/*! - Returns a list of this item's children. - - The items are sorted by stacking order. This takes into account both the - items' insertion order and their Z-values. - -*/ -QDeclarativeListProperty<QGraphicsObject> QGraphicsItemPrivate::childrenList() -{ - Q_Q(QGraphicsItem); - if (isObject) { - QGraphicsObject *that = static_cast<QGraphicsObject *>(q); - return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append, - children_count, children_at, children_clear); - } else { - //QGraphicsItem is not supported for this property - return QDeclarativeListProperty<QGraphicsObject>(); - } -} - /*! \internal Returns the width of the item @@ -10749,7 +10688,7 @@ void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic } else { QTextLayout::FormatRange range; range.start = 0; - range.length = layout.text().length(); + range.length = layout.text().size(); range.format.setTextOutline(d->pen); layout.setFormats(QList<QTextLayout::FormatRange>(1, range)); } |