summaryrefslogtreecommitdiffstats
path: root/src/widgets/graphicsview
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-12-09 01:00:35 +0100
committerLars Knoll <lars.knoll@qt.io>2019-12-09 10:16:01 +0100
commitbef74b6c3a0a9c8649ea8eb333d80015f76863e4 (patch)
tree41cdf5b6776c90a6d04a1d6680f4d47a90593746 /src/widgets/graphicsview
parentf8d2975b6a8b36bf8dd304c99783947a72081b79 (diff)
parent4c3c63d4cbb81b38e88e06b72749e7e01497b6f1 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Diffstat (limited to 'src/widgets/graphicsview')
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp50
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayout.cpp8
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp84
-rw-r--r--src/widgets/graphicsview/qgraphicsitemanimation.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicslayout_p.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutitem.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicslinearlayout.cpp10
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp52
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp156
-rw-r--r--src/widgets/graphicsview/qgraphicssceneevent.cpp6
-rw-r--r--src/widgets/graphicsview/qgraphicstransform.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp30
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.cpp24
-rw-r--r--src/widgets/graphicsview/qgraphicswidget_p.cpp8
-rw-r--r--src/widgets/graphicsview/qsimplex_p.cpp10
17 files changed, 231 insertions, 223 deletions
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp
index ea6a8018ca..4f1855a606 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp
@@ -353,7 +353,7 @@ void QGraphicsAnchorLayout::addAnchors(QGraphicsLayoutItem *firstItem,
bool ok = true;
if (orientations & Qt::Horizontal) {
// Currently, if the first is ok, then the rest of the calls should be ok
- ok = addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft) != 0;
+ ok = addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft) != nullptr;
if (ok)
addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight);
}
@@ -465,7 +465,7 @@ void QGraphicsAnchorLayout::removeAt(int index)
d->removeAnchors(item);
d->items.remove(index);
- item->setParentLayoutItem(0);
+ item->setParentLayoutItem(nullptr);
invalidate();
}
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
index 4f44373cad..af0ee3d38c 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
const qreal g_offset = (sizeof(qreal) == sizeof(double)) ? QWIDGETSIZE_MAX : QWIDGETSIZE_MAX / 32;
QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version)
- : QObjectPrivate(version), layoutPrivate(0), data(0),
+ : QObjectPrivate(version), layoutPrivate(nullptr), data(nullptr),
sizePolicy(QSizePolicy::Fixed), preferredSize(0),
hasSize(true)
{
@@ -72,7 +72,7 @@ QGraphicsAnchorPrivate::~QGraphicsAnchorPrivate()
if (data) {
// The QGraphicsAnchor was already deleted at this moment. We must clean
// the dangling pointer to avoid double deletion in the AnchorData dtor.
- data->graphicsAnchor = 0;
+ data->graphicsAnchor = nullptr;
layoutPrivate->removeAnchor(data->from, data->to);
}
@@ -631,9 +631,9 @@ QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate()
spacings[i] = -1;
graphHasConflicts[i] = false;
- layoutFirstVertex[i] = 0;
- layoutCentralVertex[i] = 0;
- layoutLastVertex[i] = 0;
+ layoutFirstVertex[i] = nullptr;
+ layoutCentralVertex[i] = nullptr;
+ layoutLastVertex[i] = nullptr;
}
}
@@ -981,7 +981,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Orientation orientation)
feasible &= replaceVertex(orientation, next, newV, newV->m_secondAnchors);
// Update the layout vertex information if one of the vertices is a layout vertex.
- AnchorVertex *layoutVertex = 0;
+ AnchorVertex *layoutVertex = nullptr;
if (v->m_item == q)
layoutVertex = v;
else if (next->m_item == q)
@@ -1035,7 +1035,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
QSet<AnchorVertex *> visited;
QStack<QPair<AnchorVertex *, AnchorVertex *> > stack;
- stack.push(qMakePair(static_cast<AnchorVertex *>(0), layoutFirstVertex[orientation]));
+ stack.push(qMakePair(static_cast<AnchorVertex *>(nullptr), layoutFirstVertex[orientation]));
QVector<AnchorVertex*> candidates;
// Walk depth-first, in the stack we store start of the candidate sequence (beforeSequence)
@@ -1384,7 +1384,7 @@ void QGraphicsAnchorLayoutPrivate::createLayoutEdges()
// Save a reference to layout vertices
layoutFirstVertex[Horizontal] = internalVertex(layout, Qt::AnchorLeft);
- layoutCentralVertex[Horizontal] = 0;
+ layoutCentralVertex[Horizontal] = nullptr;
layoutLastVertex[Horizontal] = internalVertex(layout, Qt::AnchorRight);
// Vertical
@@ -1395,7 +1395,7 @@ void QGraphicsAnchorLayoutPrivate::createLayoutEdges()
// Save a reference to layout vertices
layoutFirstVertex[Vertical] = internalVertex(layout, Qt::AnchorTop);
- layoutCentralVertex[Vertical] = 0;
+ layoutCentralVertex[Vertical] = nullptr;
layoutLastVertex[Vertical] = internalVertex(layout, Qt::AnchorBottom);
}
@@ -1581,7 +1581,7 @@ void QGraphicsAnchorLayoutPrivate::removeCenterAnchors(
}
if (item == q) {
- layoutCentralVertex[orientation] = 0;
+ layoutCentralVertex[orientation] = nullptr;
}
}
@@ -1636,29 +1636,29 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *fi
qreal *spacing)
{
Q_Q(QGraphicsAnchorLayout);
- if ((firstItem == 0) || (secondItem == 0)) {
+ if ((firstItem == nullptr) || (secondItem == nullptr)) {
qWarning("QGraphicsAnchorLayout::addAnchor(): "
"Cannot anchor NULL items");
- return 0;
+ return nullptr;
}
if (firstItem == secondItem) {
qWarning("QGraphicsAnchorLayout::addAnchor(): "
"Cannot anchor the item to itself");
- return 0;
+ return nullptr;
}
if (edgeOrientation(secondEdge) != edgeOrientation(firstEdge)) {
qWarning("QGraphicsAnchorLayout::addAnchor(): "
"Cannot anchor edges of different orientations");
- return 0;
+ return nullptr;
}
const QGraphicsLayoutItem *parentWidget = q->parentLayoutItem();
if (firstItem == parentWidget || secondItem == parentWidget) {
qWarning("QGraphicsAnchorLayout::addAnchor(): "
"You cannot add the parent of the layout to the layout.");
- return 0;
+ return nullptr;
}
// In QGraphicsAnchorLayout, items are represented in its internal
@@ -1770,13 +1770,13 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *fi
{
// Do not expose internal anchors
if (firstItem == secondItem)
- return 0;
+ return nullptr;
const Orientation orientation = edgeOrientation(firstEdge);
AnchorVertex *v1 = internalVertex(firstItem, firstEdge);
AnchorVertex *v2 = internalVertex(secondItem, secondEdge);
- QGraphicsAnchor *graphicsAnchor = 0;
+ QGraphicsAnchor *graphicsAnchor = nullptr;
AnchorData *data = graph[orientation].edgeData(v1, v2);
if (data) {
@@ -1811,7 +1811,7 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor(AnchorVertex *firstVertex,
removeAnchor_helper(firstVertex, secondVertex);
// Ensure no dangling pointer is left behind
- firstVertex = secondVertex = 0;
+ firstVertex = secondVertex = nullptr;
// Checking if the item stays in the layout or not
bool keepFirstItem = false;
@@ -2017,13 +2017,13 @@ QLayoutStyleInfo &QGraphicsAnchorLayoutPrivate::styleInfo() const
if (styleInfoDirty) {
Q_Q(const QGraphicsAnchorLayout);
//### Fix this if QGV ever gets support for Metal style or different Aqua sizes.
- QWidget *wid = 0;
+ QWidget *wid = nullptr;
QGraphicsLayoutItem *parent = q->parentLayoutItem();
while (parent && parent->isLayout()) {
parent = parent->parentLayoutItem();
}
- QGraphicsWidget *w = 0;
+ QGraphicsWidget *w = nullptr;
if (parent) {
QGraphicsItem *parentItem = parent->graphicsItem();
if (parentItem && parentItem->isWidget())
@@ -2404,7 +2404,7 @@ QList<QSimplexConstraint *> QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin
// Look for the layout edge. That can be either the first half in case the
// layout is split in two, or the whole layout anchor.
Orientation orient = Orientation(anchors.first()->orientation);
- AnchorData *layoutEdge = 0;
+ AnchorData *layoutEdge = nullptr;
if (layoutCentralVertex[orient]) {
layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutCentralVertex[orient]);
} else {
@@ -2423,7 +2423,7 @@ QList<QSimplexConstraint *> QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin
actualMax = -layoutEdge->minSize;
}
if (actualMax != expectedMax) {
- layoutEdge = 0;
+ layoutEdge = nullptr;
}
// For each variable, create constraints based on size hints
@@ -2496,8 +2496,8 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation)
Q_ASSERT(layoutFirstVertex[orientation] && layoutLastVertex[orientation]);
- AnchorData *edgeL1 = 0;
- AnchorData *edgeL2 = 0;
+ AnchorData *edgeL1 = nullptr;
+ AnchorData *edgeL2 = nullptr;
// The layout may have a single anchor between Left and Right or two half anchors
// passing through the center
@@ -2625,7 +2625,7 @@ void QGraphicsAnchorLayoutPrivate::setItemsGeometries(const QRectF &geom)
qreal left;
qreal right;
- q->getContentsMargins(&left, &top, &right, 0);
+ q->getContentsMargins(&left, &top, &right, nullptr);
const Qt::LayoutDirection visualDir = visualDirection();
if (visualDir == Qt::RightToLeft)
qSwap(left, right);
diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.cpp b/src/widgets/graphicsview/qgraphicsgridlayout.cpp
index 6b7052a0ab..260e1861c7 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicsgridlayout.cpp
@@ -137,7 +137,7 @@ QGraphicsGridLayout::~QGraphicsGridLayout()
// ~QGraphicsLayoutItem.
removeAt(i);
if (item) {
- item->setParentLayoutItem(0);
+ item->setParentLayoutItem(nullptr);
if (item->ownedByLayout())
delete item;
}
@@ -535,11 +535,11 @@ QGraphicsLayoutItem *QGraphicsGridLayout::itemAt(int row, int column) const
Q_D(const QGraphicsGridLayout);
if (row < 0 || row >= rowCount() || column < 0 || column >= columnCount()) {
qWarning("QGraphicsGridLayout::itemAt: invalid row, column %d, %d", row, column);
- return 0;
+ return nullptr;
}
if (QGraphicsGridLayoutEngineItem *engineItem = static_cast<QGraphicsGridLayoutEngineItem*>(d->engine.itemAt(row, column)))
return engineItem->layoutItem();
- return 0;
+ return nullptr;
}
/*!
@@ -583,7 +583,7 @@ void QGraphicsGridLayout::removeAt(int index)
if (QGraphicsGridLayoutEngineItem *gridItem = static_cast<QGraphicsGridLayoutEngineItem*>(d->engine.itemAt(index))) {
if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem())
- layoutItem->setParentLayoutItem(0);
+ layoutItem->setParentLayoutItem(nullptr);
d->engine.removeItem(gridItem);
// recalculate rowInfo.count if we remove an item that is on the right/bottommost row
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index b58a8c0b3c..b410ba82c2 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -1250,7 +1250,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
if (isWidget)
static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent &&
- newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0,
+ newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : nullptr,
scene);
if (scene) {
// Deliver the change to the index
@@ -1293,7 +1293,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
// Ensure any last parent focus scope does not point to this item or any of
// its descendents.
QGraphicsItem *p = parent;
- QGraphicsItem *parentFocusScopeItem = 0;
+ QGraphicsItem *parentFocusScopeItem = nullptr;
while (p) {
if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
// If this item's focus scope's focus scope item points
@@ -1301,7 +1301,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
parentFocusScopeItem = fsi;
- p->d_ptr->focusScopeItem = 0;
+ p->d_ptr->focusScopeItem = nullptr;
fsi->d_ptr->focusScopeItemChange(false);
}
break;
@@ -1321,7 +1321,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
if (subFocusItem && subFocusItem != q_ptr) {
// Find the subFocusItem's topmost focus scope within the new parent's focusscope
- QGraphicsItem *ancestorScope = 0;
+ QGraphicsItem *ancestorScope = nullptr;
QGraphicsItem *p2 = subFocusItem->d_ptr->parent;
while (p2 && p2 != p) {
if (p2->d_ptr->flags & QGraphicsItem::ItemIsFocusScope)
@@ -1582,7 +1582,7 @@ QGraphicsItem::~QGraphicsItem()
p->wasDeleted = true; // needed, so that destroying the declarative data does the right thing
if (QAbstractDeclarativeData::destroyed)
QAbstractDeclarativeData::destroyed(p->declarativeData, o);
- p->declarativeData = 0;
+ p->declarativeData = nullptr;
p->wasDeleted = false;
}
}
@@ -1602,14 +1602,14 @@ QGraphicsItem::~QGraphicsItem()
#endif
clearFocus();
- setFocusProxy(0);
+ setFocusProxy(nullptr);
// Update focus scope item ptr.
QGraphicsItem *p = d_ptr->parent;
while (p) {
if (p->flags() & ItemIsFocusScope) {
if (p->d_ptr->focusScopeItem == this)
- p->d_ptr->focusScopeItem = 0;
+ p->d_ptr->focusScopeItem = nullptr;
break;
}
p = p->d_ptr->parent;
@@ -1625,7 +1625,7 @@ QGraphicsItem::~QGraphicsItem()
d_ptr->scene->d_func()->removeItemHelper(this);
} else {
d_ptr->resetFocusProxy();
- setParentItem(0);
+ setParentItem(nullptr);
}
#if QT_CONFIG(graphicseffect)
@@ -1634,7 +1634,7 @@ QGraphicsItem::~QGraphicsItem()
if (d_ptr->transformData) {
for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) {
QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i);
- static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = 0;
+ static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = nullptr;
delete t;
}
}
@@ -1746,7 +1746,7 @@ QGraphicsWidget *QGraphicsItem::parentWidget() const
QGraphicsItem *p = parentItem();
while (p && !p->isWidget())
p = p->parentItem();
- return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : 0;
+ return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : nullptr;
}
/*!
@@ -1806,7 +1806,7 @@ QGraphicsItem *QGraphicsItem::panel() const
*/
QGraphicsObject *QGraphicsItem::toGraphicsObject()
{
- return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0;
+ return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : nullptr;
}
/*!
@@ -1817,7 +1817,7 @@ QGraphicsObject *QGraphicsItem::toGraphicsObject()
*/
const QGraphicsObject *QGraphicsItem::toGraphicsObject() const
{
- return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : 0;
+ return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : nullptr;
}
/*!
@@ -2219,7 +2219,7 @@ bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const
return false;
- QGraphicsItem *dummy = 0;
+ QGraphicsItem *dummy = nullptr;
if (!blockingPanel)
blockingPanel = &dummy;
@@ -2415,7 +2415,7 @@ bool QGraphicsItem::isVisibleTo(const QGraphicsItem *parent) const
if (p->d_ptr->explicitlyHidden)
return false;
} while ((p = p->d_ptr->parent));
- return parent == 0;
+ return parent == nullptr;
}
/*!
@@ -2954,7 +2954,7 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect)
if (d_ptr->graphicsEffect) {
delete d_ptr->graphicsEffect;
- d_ptr->graphicsEffect = 0;
+ d_ptr->graphicsEffect = nullptr;
} else if (d_ptr->parent) {
d_ptr->parent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
}
@@ -2979,7 +2979,7 @@ void QGraphicsItemPrivate::updateChildWithGraphicsEffectFlagRecursively()
if (itemPrivate->mayHaveChildWithGraphicsEffect)
return;
itemPrivate->mayHaveChildWithGraphicsEffect = 1;
- } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0));
+ } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : nullptr));
#endif
}
@@ -3391,13 +3391,13 @@ void QGraphicsItem::setActive(bool active)
if (!activePanel || activePanel == thisPanel) {
// Deactivate this item, and reactivate the parent panel,
// or the last active panel (if any).
- QGraphicsItem *nextToActivate = 0;
+ QGraphicsItem *nextToActivate = nullptr;
if (d_ptr->parent)
nextToActivate = d_ptr->parent->panel();
if (!nextToActivate)
nextToActivate = d_ptr->scene->d_func()->lastActivePanel;
if (nextToActivate == this || isAncestorOf(nextToActivate))
- nextToActivate = 0;
+ nextToActivate = nullptr;
d_ptr->scene->setActivePanel(nextToActivate);
}
}
@@ -3494,7 +3494,7 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim
}
// Update the child focus chain.
- QGraphicsItem *commonAncestor = 0;
+ QGraphicsItem *commonAncestor = nullptr;
if (scene && scene->focusItem() && scene->focusItem()->panel() == q_ptr->panel()) {
commonAncestor = scene->focusItem()->commonAncestorItem(f);
scene->focusItem()->d_ptr->clearSubFocus(scene->focusItem(), commonAncestor);
@@ -3547,7 +3547,7 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent, bool hiddenB
while (p) {
if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
if (p->d_ptr->focusScopeItem == q_ptr) {
- p->d_ptr->focusScopeItem = 0;
+ p->d_ptr->focusScopeItem = nullptr;
if (!subFocusItem->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere
focusScopeItemChange(false);
}
@@ -3567,7 +3567,7 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent, bool hiddenB
clearSubFocus(q_ptr);
// If this item has the scene's input focus, clear it.
- scene->setFocusItem(0);
+ scene->setFocusItem(nullptr);
}
}
@@ -3616,7 +3616,7 @@ void QGraphicsItem::setFocusProxy(QGraphicsItem *item)
qWarning("QGraphicsItem::setFocusProxy: focus proxy must be in same scene");
return;
}
- for (QGraphicsItem *f = item->focusProxy(); f != 0; f = f->focusProxy()) {
+ for (QGraphicsItem *f = item->focusProxy(); f != nullptr; f = f->focusProxy()) {
if (f == this) {
qWarning("QGraphicsItem::setFocusProxy: %p is already in the focus proxy chain", item);
return;
@@ -4447,7 +4447,7 @@ QTransform QGraphicsItem::deviceTransform(const QTransform &viewportTransform) c
QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) const
{
// Catch simple cases first.
- if (other == 0) {
+ if (other == nullptr) {
qWarning("QGraphicsItem::itemTransform: null pointer passed");
return QTransform();
}
@@ -4887,7 +4887,7 @@ void QGraphicsItem::stackBefore(const QGraphicsItem *sibling)
}
QList<QGraphicsItem *> *siblings = d_ptr->parent
? &d_ptr->parent->d_ptr->children
- : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : 0);
+ : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : nullptr);
if (!siblings) {
qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);
return;
@@ -4944,7 +4944,7 @@ QRectF QGraphicsItem::childrenBoundingRect() const
return d_ptr->childrenBoundingRect;
d_ptr->childrenBoundingRect = QRectF();
- d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect, 0);
+ d_ptr->childrenBoundingRectHelper(nullptr, &d_ptr->childrenBoundingRect, nullptr);
d_ptr->dirtyChildrenBoundingRect = 0;
return d_ptr->childrenBoundingRect;
}
@@ -5417,7 +5417,7 @@ QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) c
// Render
QStyleOptionGraphicsItem option;
- const_cast<QGraphicsItem *>(this)->paint(&p, &option, 0);
+ const_cast<QGraphicsItem *>(this)->paint(&p, &option, nullptr);
p.end();
// Transform QRegion back to device space
@@ -5570,7 +5570,7 @@ void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively()
if (!itemPrivate->updateDueToGraphicsEffect)
static_cast<QGraphicsItemEffectSourcePrivate *>(itemPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();
}
- } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0));
+ } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : nullptr));
}
void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::InvalidateReason reason)
@@ -5734,7 +5734,7 @@ void QGraphicsItemPrivate::ensureSceneTransformRecursive(QGraphicsItem **topMost
if (*topMostDirtyItem == q_ptr) {
if (!dirtySceneTransform)
return; // OK, neither my ancestors nor I have dirty scene transforms.
- *topMostDirtyItem = 0;
+ *topMostDirtyItem = nullptr;
} else if (*topMostDirtyItem) {
return; // Continue backtrack.
}
@@ -5766,7 +5766,7 @@ void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem, QGraphicsItem *s
if (parent != q_ptr && parent->d_ptr->subFocusItem) {
if (parent->d_ptr->subFocusItem == q_ptr)
break;
- parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(0, stopItem);
+ parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(nullptr, stopItem);
}
parent->d_ptr->subFocusItem = q_ptr;
parent->d_ptr->subFocusItemChange();
@@ -5788,7 +5788,7 @@ void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem
do {
if (parent->d_ptr->subFocusItem != q_ptr)
break;
- parent->d_ptr->subFocusItem = 0;
+ parent->d_ptr->subFocusItem = nullptr;
if (parent != stopItem && !parent->isAncestorOf(stopItem))
parent->d_ptr->subFocusItemChange();
} while (!parent->isPanel() && (parent = parent->d_ptr->parent));
@@ -5803,7 +5803,7 @@ void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem
void QGraphicsItemPrivate::resetFocusProxy()
{
for (int i = 0; i < focusProxyRefs.size(); ++i)
- *focusProxyRefs.at(i) = 0;
+ *focusProxyRefs.at(i) = nullptr;
focusProxyRefs.clear();
}
@@ -7317,7 +7317,7 @@ void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
// Find the active view.
- QGraphicsView *view = 0;
+ QGraphicsView *view = nullptr;
if (event->widget())
view = qobject_cast<QGraphicsView *>(event->widget()->parentWidget());
@@ -7325,7 +7325,7 @@ void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
int i = 0;
bool movedMe = false;
while (i <= selectedItems.size()) {
- QGraphicsItem *item = 0;
+ QGraphicsItem *item = nullptr;
if (i < selectedItems.size())
item = selectedItems.at(i);
else
@@ -7886,7 +7886,7 @@ void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObj
if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) {
item->setParentItem(graphicsObject);
} else {
- QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0);
+ QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, nullptr, nullptr);
}
}
}
@@ -7903,7 +7903,7 @@ QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGra
if (index >= 0 && index < d->children.count())
return d->children.at(index)->toGraphicsObject();
else
- return 0;
+ return nullptr;
}
void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObject> *list)
@@ -7912,10 +7912,10 @@ void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObje
int childCount = d->children.count();
if (d->sendParentChangeNotification) {
for (int index = 0; index < childCount; index++)
- d->children.at(0)->setParentItem(0);
+ d->children.at(0)->setParentItem(nullptr);
} else {
for (int index = 0; index < childCount; index++)
- QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0);
+ QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(nullptr, nullptr, nullptr);
}
}
@@ -9944,7 +9944,7 @@ class QGraphicsTextItemPrivate
{
public:
QGraphicsTextItemPrivate()
- : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0)
+ : control(nullptr), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0)
{ }
mutable QWidgetTextControl *control;
@@ -11227,7 +11227,7 @@ void QGraphicsItemGroup::removeFromGroup(QGraphicsItem *item)
// ### Expensive, we could maybe use dirtySceneTransform bit for optimization
item->setTransform(itemTransform);
- item->d_func()->setIsMemberOfGroup(item->group() != 0);
+ item->d_func()->setIsMemberOfGroup(item->group() != nullptr);
// ### Quite expensive. But removeFromGroup() isn't called very often.
prepareGeometryChange();
@@ -11407,18 +11407,18 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP
QTransform sceneTransform = item->sceneTransform();
QTransform newEffectTransform = sceneTransform.inverted();
newEffectTransform *= effectTransform;
- scened->draw(item, &pixmapPainter, 0, &sceneTransform, 0, 0, qreal(1.0),
+ scened->draw(item, &pixmapPainter, nullptr, &sceneTransform, nullptr, nullptr, qreal(1.0),
&newEffectTransform, false, true);
} else if (deviceCoordinates) {
// Device coordinates with info.
- scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,
+ scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, nullptr,
info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
info->drawItem);
} else {
// Item coordinates with info.
QTransform newEffectTransform = info->transformPtr->inverted();
newEffectTransform *= effectTransform;
- scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,
+ scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, nullptr,
info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform,
info->drawItem);
}
diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
index ad77e2f260..1c5dbf265c 100644
--- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp
+++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
@@ -106,7 +106,7 @@ class QGraphicsItemAnimationPrivate
{
public:
inline QGraphicsItemAnimationPrivate()
- : q(0), timeLine(0), item(0), step(0)
+ : q(nullptr), timeLine(nullptr), item(nullptr), step(0)
{ }
QGraphicsItemAnimation *q;
diff --git a/src/widgets/graphicsview/qgraphicslayout_p.cpp b/src/widgets/graphicsview/qgraphicslayout_p.cpp
index 59ed7acd72..c10763d065 100644
--- a/src/widgets/graphicsview/qgraphicslayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicslayout_p.cpp
@@ -97,7 +97,7 @@ void QGraphicsLayoutPrivate::getMargin(qreal *result, qreal userMargin, QStyle::
*result = 0.0;
if (QGraphicsItem *layoutParentItem = parentItem()) {
if (layoutParentItem->isWidget())
- *result = (qreal)static_cast<QGraphicsWidget*>(layoutParentItem)->style()->pixelMetric(pm, 0);
+ *result = (qreal)static_cast<QGraphicsWidget*>(layoutParentItem)->style()->pixelMetric(pm, nullptr);
}
}
}
diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.cpp b/src/widgets/graphicsview/qgraphicslayoutitem.cpp
index 1192bad51e..8694dcb36b 100644
--- a/src/widgets/graphicsview/qgraphicslayoutitem.cpp
+++ b/src/widgets/graphicsview/qgraphicslayoutitem.cpp
@@ -105,7 +105,7 @@ static void normalizeHints(qreal &minimum, qreal &preferred, qreal &maximum, qre
\internal
*/
QGraphicsLayoutItemPrivate::QGraphicsLayoutItemPrivate(QGraphicsLayoutItem *par, bool layout)
- : parent(par), userSizeHints(0), isLayout(layout), ownedByLayout(false), graphicsItem(0)
+ : parent(par), userSizeHints(nullptr), isLayout(layout), ownedByLayout(false), graphicsItem(nullptr)
{
}
diff --git a/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp b/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp
index da2510a8cb..2f1526cc78 100644
--- a/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp
+++ b/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp
@@ -48,7 +48,7 @@
QT_BEGIN_NAMESPACE
QGraphicsLayoutStyleInfo::QGraphicsLayoutStyleInfo(const QGraphicsLayoutPrivate *layout)
- : m_layout(layout), m_style(0)
+ : m_layout(layout), m_style(nullptr)
{
m_widget.reset(new QWidget); // pixelMetric might need a widget ptr
m_styleOption.initFrom(m_widget.get());
diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
index 22633df4e3..f76cc61586 100644
--- a/src/widgets/graphicsview/qgraphicslinearlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
@@ -211,7 +211,7 @@ QGraphicsLinearLayout::~QGraphicsLinearLayout()
// ~QGraphicsLayoutItem.
removeAt(i);
if (item) {
- item->setParentLayoutItem(0);
+ item->setParentLayoutItem(nullptr);
if (item->ownedByLayout())
delete item;
}
@@ -310,7 +310,7 @@ void QGraphicsLinearLayout::removeItem(QGraphicsLayoutItem *item)
{
Q_D(QGraphicsLinearLayout);
if (QGraphicsGridLayoutEngineItem *gridItem = d->engine.findLayoutItem(item)) {
- item->setParentLayoutItem(0);
+ item->setParentLayoutItem(nullptr);
d->removeGridItem(gridItem);
delete gridItem;
invalidate();
@@ -333,7 +333,7 @@ void QGraphicsLinearLayout::removeAt(int index)
if (QGraphicsGridLayoutEngineItem *gridItem = static_cast<QGraphicsGridLayoutEngineItem*>(d->engine.itemAt(index))) {
if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem())
- layoutItem->setParentLayoutItem(0);
+ layoutItem->setParentLayoutItem(nullptr);
d->removeGridItem(gridItem);
delete gridItem;
invalidate();
@@ -483,9 +483,9 @@ QGraphicsLayoutItem *QGraphicsLinearLayout::itemAt(int index) const
Q_D(const QGraphicsLinearLayout);
if (index < 0 || index >= d->engine.itemCount()) {
qWarning("QGraphicsLinearLayout::itemAt: invalid index %d", index);
- return 0;
+ return nullptr;
}
- QGraphicsLayoutItem *item = 0;
+ QGraphicsLayoutItem *item = nullptr;
if (QGraphicsGridLayoutEngineItem *gridItem = static_cast<QGraphicsGridLayoutEngineItem *>(d->engine.itemAt(index)))
item = gridItem->layoutItem();
return item;
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index c60dca7a90..4d4958c674 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -291,7 +291,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
}
if (!lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0, event->screenPos());
+ QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, nullptr, event->screenPos());
lastWidgetUnderMouse = receiver;
}
@@ -315,10 +315,10 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
if (q->rect().contains(event->pos()) && q->acceptHoverEvents())
lastWidgetUnderMouse = alienWidget ? alienWidget : widget;
else // released on the frame our outside the item, or doesn't accept hover events.
- lastWidgetUnderMouse = 0;
+ lastWidgetUnderMouse = nullptr;
QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber, event->screenPos());
- embeddedMouseGrabber = 0;
+ embeddedMouseGrabber = nullptr;
#ifndef QT_NO_CURSOR
// ### Restore the cursor, don't override it.
@@ -368,7 +368,7 @@ void QGraphicsProxyWidgetPrivate::removeSubFocusHelper(QWidget *widget, Qt::Focu
QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) const
{
if (!widget)
- return 0;
+ return nullptr;
// Run around the focus chain until we find a widget that can take tab focus.
if (!child) {
@@ -376,12 +376,12 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next)
} else {
child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
if ((next && child == widget) || (!next && child == widget->d_func()->focus_prev)) {
- return 0;
+ return nullptr;
}
}
if (!child)
- return 0;
+ return nullptr;
QWidget *oldChild = child;
uint focus_flag = qt_tab_all_widgets() ? Qt::TabFocus : Qt::StrongFocus;
@@ -394,7 +394,7 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next)
}
child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
} while (child != oldChild && !(next && child == widget) && !(!next && child == widget->d_func()->focus_prev));
- return 0;
+ return nullptr;
}
/*!
@@ -405,9 +405,9 @@ void QGraphicsProxyWidgetPrivate::_q_removeWidgetSlot()
Q_Q(QGraphicsProxyWidget);
if (!widget.isNull()) {
if (const auto &extra = widget->d_func()->extra)
- extra->proxyWidget = 0;
+ extra->proxyWidget = nullptr;
}
- widget = 0;
+ widget = nullptr;
delete q;
}
@@ -430,7 +430,7 @@ void QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget()
QRectF widgetGeometry = widget->geometry();
QWidget *parentWidget = widget->parentWidget();
if (widget->isWindow()) {
- QGraphicsProxyWidget *proxyParent = 0;
+ QGraphicsProxyWidget *proxyParent = nullptr;
if (parentWidget && (proxyParent = qobject_cast<QGraphicsProxyWidget *>(q->parentWidget()))) {
// Nested window proxy (e.g., combobox popup), map widget to the
// parent widget's global coordinates, and map that to the parent
@@ -497,7 +497,7 @@ void QGraphicsProxyWidgetPrivate::unembedSubWindow(QWidget *subWin)
if (child->isWidget()) {
if (QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(child))) {
if (proxy->widget() == subWin) {
- proxy->setWidget(0);
+ proxy->setWidget(nullptr);
scene->removeItem(proxy);
delete proxy;
return;
@@ -598,7 +598,7 @@ void QGraphicsProxyWidgetPrivate::setWidget_helper(QWidget *newWidget, bool auto
QObject::disconnect(widget, SIGNAL(destroyed()), q, SLOT(_q_removeWidgetSlot()));
widget->removeEventFilter(q);
widget->setAttribute(Qt::WA_DontShowOnScreen, false);
- widget->d_func()->extra->proxyWidget = 0;
+ widget->d_func()->extra->proxyWidget = nullptr;
resolveFont(inheritedFontResolveMask);
resolvePalette(inheritedPaletteResolveMask);
widget->update();
@@ -1081,7 +1081,7 @@ void QGraphicsProxyWidget::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
return;
QDragLeaveEvent proxyDragLeave;
QCoreApplication::sendEvent(d->dragDropWidget, &proxyDragLeave);
- d->dragDropWidget = 0;
+ d->dragDropWidget = nullptr;
#endif
}
@@ -1143,7 +1143,7 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
// Leave the last drag drop item
QDragLeaveEvent dragLeave;
QCoreApplication::sendEvent(d->dragDropWidget, &dragLeave);
- d->dragDropWidget = 0;
+ d->dragDropWidget = nullptr;
}
// Propagate
event->setDropAction(Qt::IgnoreAction);
@@ -1165,7 +1165,7 @@ void QGraphicsProxyWidget::dropEvent(QGraphicsSceneDragDropEvent *event)
QDropEvent dropEvent(widgetPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
QCoreApplication::sendEvent(d->dragDropWidget, &dropEvent);
event->setAccepted(dropEvent.isAccepted());
- d->dragDropWidget = 0;
+ d->dragDropWidget = nullptr;
}
#endif
}
@@ -1188,8 +1188,8 @@ void QGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Q_D(QGraphicsProxyWidget);
// If hoverMove was compressed away, make sure we update properly here.
if (d->lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
- d->lastWidgetUnderMouse = 0;
+ QApplicationPrivate::dispatchEnterLeave(nullptr, d->lastWidgetUnderMouse, event->screenPos());
+ d->lastWidgetUnderMouse = nullptr;
}
}
@@ -1205,13 +1205,13 @@ void QGraphicsProxyWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
// Ignore events on the window frame.
if (!d->widget || !rect().contains(event->pos())) {
if (d->lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
- d->lastWidgetUnderMouse = 0;
+ QApplicationPrivate::dispatchEnterLeave(nullptr, d->lastWidgetUnderMouse, event->screenPos());
+ d->lastWidgetUnderMouse = nullptr;
}
return;
}
- d->embeddedMouseGrabber = 0;
+ d->embeddedMouseGrabber = nullptr;
d->sendWidgetMouseEvent(event);
}
@@ -1230,7 +1230,7 @@ void QGraphicsProxyWidget::ungrabMouseEvent(QEvent *event)
{
Q_D(QGraphicsProxyWidget);
Q_UNUSED(event);
- d->embeddedMouseGrabber = 0;
+ d->embeddedMouseGrabber = nullptr;
}
/*!
@@ -1372,12 +1372,12 @@ void QGraphicsProxyWidget::focusInEvent(QFocusEvent *event)
switch (event->reason()) {
case Qt::TabFocusReason: {
- if (QWidget *focusChild = d->findFocusChild(0, true))
+ if (QWidget *focusChild = d->findFocusChild(nullptr, true))
focusChild->setFocus(event->reason());
break;
}
case Qt::BacktabFocusReason:
- if (QWidget *focusChild = d->findFocusChild(0, false))
+ if (QWidget *focusChild = d->findFocusChild(nullptr, false))
focusChild->setFocus(event->reason());
break;
default:
@@ -1578,16 +1578,16 @@ QGraphicsProxyWidget *QGraphicsProxyWidget::createProxyForChildWidget(QWidget *c
return proxy;
if (!child->parentWidget()) {
qWarning("QGraphicsProxyWidget::createProxyForChildWidget: top-level widget not in a QGraphicsScene");
- return 0;
+ return nullptr;
}
QGraphicsProxyWidget *parentProxy = createProxyForChildWidget(child->parentWidget());
if (!parentProxy)
- return 0;
+ return nullptr;
if (!QMetaObject::invokeMethod(parentProxy, "newProxyWidget", Qt::DirectConnection,
Q_RETURN_ARG(QGraphicsProxyWidget*, proxy), Q_ARG(const QWidget*, child)))
- return 0;
+ return nullptr;
proxy->setParent(parentProxy);
proxy->setWidget(child);
return proxy;
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index a47d0d879d..1c6e68def1 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -278,7 +278,7 @@ static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraph
*/
QGraphicsScenePrivate::QGraphicsScenePrivate()
: indexMethod(QGraphicsScene::BspTreeIndex),
- index(0),
+ index(nullptr),
lastItemCount(0),
hasSceneRect(false),
dirtyGrowingItemsBoundingRect(true),
@@ -301,19 +301,19 @@ QGraphicsScenePrivate::QGraphicsScenePrivate()
minimumRenderSize(0.0),
selectionChanging(0),
rectAdjust(2),
- focusItem(0),
- lastFocusItem(0),
- passiveFocusItem(0),
- tabFocusFirst(0),
- activePanel(0),
- lastActivePanel(0),
+ focusItem(nullptr),
+ lastFocusItem(nullptr),
+ passiveFocusItem(nullptr),
+ tabFocusFirst(nullptr),
+ activePanel(nullptr),
+ lastActivePanel(nullptr),
activationRefCount(0),
childExplicitActivation(0),
- lastMouseGrabberItem(0),
- dragDropItem(0),
- enterWidget(0),
+ lastMouseGrabberItem(nullptr),
+ dragDropItem(nullptr),
+ enterWidget(nullptr),
lastDropAction(Qt::IgnoreAction),
- style(0)
+ style(nullptr)
{
}
@@ -443,8 +443,8 @@ void QGraphicsScenePrivate::_q_polishItems()
return;
const QVariant booleanTrueVariant(true);
- QGraphicsItem *item = 0;
- QGraphicsItemPrivate *itemd = 0;
+ QGraphicsItem *item = nullptr;
+ QGraphicsItemPrivate *itemd = nullptr;
const int oldUnpolishedCount = unpolishedItems.count();
for (int i = 0; i < oldUnpolishedCount; ++i) {
@@ -602,7 +602,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
unregisterScenePosItem(item);
QGraphicsScene *oldScene = item->d_func()->scene;
- item->d_func()->scene = 0;
+ item->d_func()->scene = nullptr;
//We need to remove all children first because they might use their parent
//attributes (e.g. sceneTransform).
@@ -614,7 +614,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
if (!item->d_ptr->inDestructor && !item->parentItem() && item->isWidget()) {
QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
- widget->d_func()->fixFocusChainBeforeReparenting(0, oldScene, 0);
+ widget->d_func()->fixFocusChainBeforeReparenting(nullptr, oldScene, nullptr);
}
// Unregister focus proxy.
@@ -625,7 +625,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
if (parentItem->scene()) {
Q_ASSERT_X(parentItem->scene() == q, "QGraphicsScene::removeItem",
"Parent item's scene is different from this item's scene");
- item->setParentItem(0);
+ item->setParentItem(nullptr);
}
} else {
unregisterTopLevelItem(item);
@@ -633,17 +633,17 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
// Reset the mouse grabber and focus item data.
if (item == focusItem)
- focusItem = 0;
+ focusItem = nullptr;
if (item == lastFocusItem)
- lastFocusItem = 0;
+ lastFocusItem = nullptr;
if (item == passiveFocusItem)
- passiveFocusItem = 0;
+ passiveFocusItem = nullptr;
if (item == activePanel) {
// ### deactivate...
- activePanel = 0;
+ activePanel = nullptr;
}
if (item == lastActivePanel)
- lastActivePanel = 0;
+ lastActivePanel = nullptr;
// Change tabFocusFirst to the next widget in focus chain if removing the current one.
if (item == tabFocusFirst) {
@@ -651,7 +651,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
if (wd->focusNext && wd->focusNext != tabFocusFirst && wd->focusNext->scene() == q)
tabFocusFirst = wd->focusNext;
else
- tabFocusFirst = 0;
+ tabFocusFirst = nullptr;
}
// Cancel active touches
@@ -705,11 +705,11 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
// Reset the last mouse grabber item
if (item == lastMouseGrabberItem)
- lastMouseGrabberItem = 0;
+ lastMouseGrabberItem = nullptr;
// Reset the current drop item
if (item == dragDropItem)
- dragDropItem = 0;
+ dragDropItem = nullptr;
// Reenable selectionChanged() for individual items
--selectionChanging;
@@ -752,8 +752,8 @@ void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool durin
q->setFocus(Qt::ActiveWindowFocusReason);
// Find the item's panel.
- QGraphicsItem *panel = item ? item->panel() : 0;
- lastActivePanel = panel ? activePanel : 0;
+ QGraphicsItem *panel = item ? item->panel() : nullptr;
+ lastActivePanel = panel ? activePanel : nullptr;
if (panel == activePanel || (!q->isActive() && !duringActivationEvent))
return;
@@ -764,7 +764,7 @@ void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool durin
if (QGraphicsItem *fi = activePanel->focusItem()) {
// Remove focus from the current focus item.
if (fi == q->focusItem())
- setFocusItemHelper(0, Qt::ActiveWindowFocusReason, /* emitFocusChanged = */ false);
+ setFocusItemHelper(nullptr, Qt::ActiveWindowFocusReason, /* emitFocusChanged = */ false);
}
QEvent event(QEvent::WindowDeactivate);
@@ -841,7 +841,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
// accept input focus.
if (item && (!(item->flags() & QGraphicsItem::ItemIsFocusable)
|| !item->isVisible() || !item->isEnabled())) {
- item = 0;
+ item = nullptr;
}
// Set focus on the scene if an item requests focus.
@@ -849,7 +849,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
q->setFocus(focusReason);
if (item == focusItem) {
if (emitFocusChanged)
- emit q->focusItemChanged(focusItem, (QGraphicsItem *)0, focusReason);
+ emit q->focusItemChanged(focusItem, (QGraphicsItem *)nullptr, focusReason);
return;
}
}
@@ -869,7 +869,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
}
#endif //QT_NO_IM
- focusItem = 0;
+ focusItem = nullptr;
QFocusEvent event(QEvent::FocusOut, focusReason);
sendEvent(lastFocusItem, &event);
}
@@ -877,7 +877,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
// This handles the case that the item has been removed from the
// scene in response to the FocusOut event.
if (item && item->scene() != q)
- item = 0;
+ item = nullptr;
if (item)
focusItem = item;
@@ -1039,7 +1039,7 @@ void QGraphicsScenePrivate::clearMouseGrabber()
{
if (!mouseGrabberItems.isEmpty())
mouseGrabberItems.first()->ungrabMouse();
- lastMouseGrabberItem = 0;
+ lastMouseGrabberItem = nullptr;
}
/*!
@@ -1365,10 +1365,10 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
// Update window activation.
QGraphicsItem *topItem = cachedItemsUnderMouse.value(0);
- QGraphicsWidget *newActiveWindow = topItem ? topItem->window() : 0;
+ QGraphicsWidget *newActiveWindow = topItem ? topItem->window() : nullptr;
if (newActiveWindow && newActiveWindow->isBlockedByModalPanel(&topItem)) {
// pass activation to the blocking modal window
- newActiveWindow = topItem ? topItem->window() : 0;
+ newActiveWindow = topItem ? topItem->window() : nullptr;
}
if (newActiveWindow != q->activeWindow())
@@ -1409,7 +1409,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
// If nobody could take focus, clear it.
if (!stickyFocus && !setFocus && !sceneModality)
- q->setFocusItem(0, Qt::MouseFocusReason);
+ q->setFocusItem(nullptr, Qt::MouseFocusReason);
// Any item will do.
if (sceneModality && cachedItemsUnderMouse.isEmpty())
@@ -1694,7 +1694,7 @@ QGraphicsScene::~QGraphicsScene()
// Remove this scene from all associated views.
for (int j = 0; j < d->views.size(); ++j)
- d->views.at(j)->setScene(0);
+ d->views.at(j)->setScene(nullptr);
}
/*!
@@ -2432,7 +2432,7 @@ QGraphicsItemGroup *QGraphicsScene::createItemGroup(const QList<QGraphicsItem *>
}
// Find the common ancestor for all items
- QGraphicsItem *commonAncestor = 0;
+ QGraphicsItem *commonAncestor = nullptr;
if (!ancestors.isEmpty()) {
while (n < items.size()) {
int commonIndex = -1;
@@ -2446,7 +2446,7 @@ QGraphicsItemGroup *QGraphicsScene::createItemGroup(const QList<QGraphicsItem *>
} while ((parent = parent->parentItem()));
if (commonIndex == -1) {
- commonAncestor = 0;
+ commonAncestor = nullptr;
break;
}
@@ -2545,7 +2545,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
// from this scene.
if (QGraphicsItem *itemParent = item->d_ptr->parent) {
if (itemParent->d_ptr->scene != this)
- item->setParentItem(0);
+ item->setParentItem(nullptr);
}
// Add the item to this scene
@@ -2568,8 +2568,16 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
++d->selectionChanging;
int oldSelectedItemSize = d->selectedItems.size();
- // Enable mouse tracking if the item accepts hover events or has a cursor set.
- if (d->allItemsIgnoreHoverEvents && d->itemAcceptsHoverEvents_helper(item)) {
+ // Enable mouse tracking if we haven't already done so, and the item needs it.
+ // We cannot use itemAcceptsHoverEvents_helper() here, since we need to enable
+ // mouse tracking also if this item is temporarily blocked by a modal panel.
+
+ auto needsMouseTracking = [](const QGraphicsItemPrivate *item) {
+ return item->acceptsHover
+ || (item->isWidget && static_cast<const QGraphicsWidgetPrivate *>(item)->hasDecoration());
+ };
+
+ if (d->allItemsIgnoreHoverEvents && needsMouseTracking(item->d_ptr.data())) {
d->allItemsIgnoreHoverEvents = false;
d->enableMouseTrackingOnViews();
}
@@ -2903,7 +2911,7 @@ QGraphicsSimpleTextItem *QGraphicsScene::addSimpleText(const QString &text, cons
*/
QGraphicsProxyWidget *QGraphicsScene::addWidget(QWidget *widget, Qt::WindowFlags wFlags)
{
- QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, wFlags);
+ QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(nullptr, wFlags);
proxy->setWidget(widget);
addItem(proxy);
return proxy;
@@ -2936,7 +2944,7 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
QVariant::fromValue<QGraphicsScene *>(0)));
QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);
- if (targetScene != 0 && targetScene != this) {
+ if (targetScene != nullptr && targetScene != this) {
targetScene->addItem(item);
return;
}
@@ -3038,7 +3046,7 @@ void QGraphicsScene::clearFocus()
if (d->hasFocus) {
d->hasFocus = false;
d->passiveFocusItem = d->focusItem;
- setFocusItem(0, Qt::OtherFocusReason);
+ setFocusItem(nullptr, Qt::OtherFocusReason);
}
}
@@ -3484,7 +3492,7 @@ bool QGraphicsScene::event(QEvent *event)
// Deactivate the active panel (but keep it so we can
// reactivate it later).
QGraphicsItem *lastActivePanel = d->activePanel;
- d->setActivePanelHelper(0, true);
+ d->setActivePanelHelper(nullptr, true);
d->lastActivePanel = lastActivePanel;
} else {
// Activate all toplevel items.
@@ -3613,7 +3621,7 @@ void QGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMen
void QGraphicsScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
Q_D(QGraphicsScene);
- d->dragDropItem = 0;
+ d->dragDropItem = nullptr;
d->lastDropAction = Qt::IgnoreAction;
event->accept();
}
@@ -3697,7 +3705,7 @@ void QGraphicsScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave);
d->cloneDragDropEvent(&dragLeave, event);
d->sendDragDropEvent(d->dragDropItem, &dragLeave);
- d->dragDropItem = 0;
+ d->dragDropItem = nullptr;
}
// Propagate
event->setDropAction(Qt::IgnoreAction);
@@ -3717,7 +3725,7 @@ void QGraphicsScene::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
if (d->dragDropItem) {
// Leave the last drag drop item
d->sendDragDropEvent(d->dragDropItem, event);
- d->dragDropItem = 0;
+ d->dragDropItem = nullptr;
}
}
@@ -3735,7 +3743,7 @@ void QGraphicsScene::dropEvent(QGraphicsSceneDragDropEvent *event)
if (d->dragDropItem) {
// Drop on the last drag drop item
d->sendDragDropEvent(d->dragDropItem, event);
- d->dragDropItem = 0;
+ d->dragDropItem = nullptr;
}
}
@@ -3785,7 +3793,7 @@ void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent)
Q_D(QGraphicsScene);
d->hasFocus = false;
d->passiveFocusItem = d->focusItem;
- setFocusItem(0, focusEvent->reason());
+ setFocusItem(nullptr, focusEvent->reason());
// Remove all popups when the scene loses focus.
if (!d->popupWidgets.isEmpty())
@@ -3817,7 +3825,7 @@ void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent)
QList<QGraphicsItem *> itemsAtPos = d->itemsAtPosition(helpEvent->screenPos(),
helpEvent->scenePos(),
helpEvent->widget());
- QGraphicsItem *toolTipItem = 0;
+ QGraphicsItem *toolTipItem = nullptr;
for (int i = 0; i < itemsAtPos.size(); ++i) {
QGraphicsItem *tmp = itemsAtPos.at(i);
if (tmp->d_func()->isProxyWidget()) {
@@ -3875,7 +3883,7 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv
hoverEvent->widget());
}
- QGraphicsItem *item = 0;
+ QGraphicsItem *item = nullptr;
for (int i = 0; i < cachedItemsUnderMouse.size(); ++i) {
QGraphicsItem *tmp = cachedItemsUnderMouse.at(i);
if (itemAcceptsHoverEvents_helper(tmp)) {
@@ -3886,13 +3894,13 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv
// Find the common ancestor item for the new topmost hoverItem and the
// last item in the hoverItem list.
- QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.constLast()) : 0;
+ QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.constLast()) : nullptr;
while (commonAncestorItem && !itemAcceptsHoverEvents_helper(commonAncestorItem))
commonAncestorItem = commonAncestorItem->parentItem();
if (commonAncestorItem && commonAncestorItem->panel() != item->panel()) {
// The common ancestor isn't in the same panel as the two hovered
// items.
- commonAncestorItem = 0;
+ commonAncestorItem = nullptr;
}
// Check if the common ancestor item is known.
@@ -4122,7 +4130,7 @@ void QGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
if (d->lastMouseGrabberItemHasImplicitMouseGrab)
d->mouseGrabberItems.constLast()->ungrabMouse();
} else {
- d->lastMouseGrabberItem = 0;
+ d->lastMouseGrabberItem = nullptr;
}
// Generate a hoverevent
@@ -4354,7 +4362,7 @@ static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion &
pixmapPainter.setWorldTransform(itemToPixmap, true);
// Render.
- _q_paintItem(item, &pixmapPainter, option, 0, false, painterStateProtection);
+ _q_paintItem(item, &pixmapPainter, option, nullptr, false, painterStateProtection);
pixmapPainter.end();
if (!subPix.isNull()) {
@@ -4748,7 +4756,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
return;
QTransform transform(Qt::Uninitialized);
- QTransform *transformPtr = 0;
+ QTransform *transformPtr = nullptr;
bool translateOnlyTransform = false;
#define ENSURE_TRANSFORM_PTR \
if (!transformPtr) { \
@@ -4858,7 +4866,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
item->d_ptr->graphicsEffect->draw(painter);
painter->setWorldTransform(restoreTransform);
- sourced->info = 0;
+ sourced->info = nullptr;
} else
#endif // QT_CONFIG(graphicseffect)
{
@@ -4936,7 +4944,7 @@ void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const Q
Q_ASSERT(!(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents));
Q_ASSERT(transformPtr);
item->d_ptr->initStyleOption(&styleOptionTmp, *transformPtr, exposedRegion
- ? *exposedRegion : QRegion(), exposedRegion == 0);
+ ? *exposedRegion : QRegion(), exposedRegion == nullptr);
const bool itemClipsToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsToShape;
bool restorePainterClip = false;
@@ -5322,7 +5330,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool
if (itemClipsChildrenToShape) {
// Reset updateClip.
for (int i = 0; i < views.size(); ++i)
- views.at(i)->d_func()->setUpdateClip(0);
+ views.at(i)->d_func()->setUpdateClip(nullptr);
}
} else if (wasDirtyParentSceneTransform) {
item->d_ptr->invalidateChildrenSceneTransform();
@@ -5378,7 +5386,7 @@ void QGraphicsScene::drawItems(QPainter *painter,
// Determine view, expose and flags.
QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0;
- QRegion *expose = 0;
+ QRegion *expose = nullptr;
const quint32 oldRectAdjust = d->rectAdjust;
if (view) {
d->updateAll = false;
@@ -5462,7 +5470,7 @@ bool QGraphicsScene::focusNextPrevChild(bool next)
}
// The item must be a widget.
- QGraphicsWidget *widget = 0;
+ QGraphicsWidget *widget = nullptr;
if (!item) {
widget = next ? d->tabFocusFirst : d->tabFocusFirst->d_func()->focusPrev;
} else {
@@ -5478,7 +5486,7 @@ bool QGraphicsScene::focusNextPrevChild(bool next)
// Run around the focus chain until we find a widget that can take tab focus.
do {
if (widget->flags() & QGraphicsItem::ItemIsFocusable
- && widget->isEnabled() && widget->isVisibleTo(0)
+ && widget->isEnabled() && widget->isVisibleTo(nullptr)
&& (widget->focusPolicy() & Qt::TabFocus)
&& (!item || !item->isPanel() || item->isAncestorOf(widget))
) {
@@ -5763,7 +5771,7 @@ void QGraphicsScene::setActiveWindow(QGraphicsWidget *widget)
}
// Activate the widget's panel (all windows are panels).
- QGraphicsItem *panel = widget ? widget->panel() : 0;
+ QGraphicsItem *panel = widget ? widget->panel() : nullptr;
setActivePanel(panel);
// Raise
@@ -5945,7 +5953,7 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent)
const QTouchEvent::TouchPoint &touchPoint = sceneTouchEvent->touchPoints().at(i);
// update state
- QGraphicsItem *item = 0;
+ QGraphicsItem *item = nullptr;
if (touchPoint.state() == Qt::TouchPointPressed) {
if (sceneTouchEvent->device()->type() == QTouchDevice::TouchPad) {
// on touch-pad devices, send all touch points to the same item
@@ -6103,7 +6111,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
// If nobody could take focus, clear it.
if (!stickyFocus && !setFocus)
- q->setFocusItem(0, Qt::MouseFocusReason);
+ q->setFocusItem(nullptr, Qt::MouseFocusReason);
}
bool res = false;
@@ -6117,7 +6125,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
eventAccepted = touchEvent->isAccepted();
if (itemForTouchPointId.value(touchEvent->touchPoints().first().id()) == 0) {
// item was deleted
- item = 0;
+ item = nullptr;
} else {
item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted);
}
@@ -6251,7 +6259,7 @@ void QGraphicsScenePrivate::gestureTargetsAtHotSpots(const QSet<QGesture *> &ges
if (!gesture->hasHotSpot())
continue;
const Qt::GestureType gestureType = gesture->gestureType();
- QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), gesture->d_func()->sceneHotSpot, 0);
+ QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), gesture->d_func()->sceneHotSpot, nullptr);
for (int j = 0; j < items.size(); ++j) {
QGraphicsItem *item = items.at(j);
@@ -6323,7 +6331,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event)
if (!startedGestures.isEmpty()) {
QSet<QGesture *> normalGestures; // that have just one target
QSet<QGesture *> conflictedGestures; // that have multiple possible targets
- gestureTargetsAtHotSpots(startedGestures, Qt::GestureFlag(0), &cachedItemGestures, 0,
+ gestureTargetsAtHotSpots(startedGestures, Qt::GestureFlag(0), &cachedItemGestures, nullptr,
&normalGestures, &conflictedGestures);
cachedTargetItems = cachedItemGestures.keys();
std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
@@ -6497,7 +6505,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event)
}
gestureTargetsAtHotSpots(ignoredGestures, Qt::ReceivePartialGestures,
- &cachedItemGestures, &targetsSet, 0, 0);
+ &cachedItemGestures, &targetsSet, nullptr, nullptr);
cachedTargetItems = targetsSet.values();
std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
@@ -6537,7 +6545,7 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original)
{
Q_ASSERT(original);
QGraphicsItem *originalItem = gestureTargets.value(original);
- if (originalItem == 0) // we only act on accepted gestures, which implies it has a target.
+ if (originalItem == nullptr) // we only act on accepted gestures, which implies it has a target.
return;
// iterate over all active gestures and for each find the owner
@@ -6560,13 +6568,13 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original)
QSet<QGesture *> almostCanceledGestures = canceledGestures;
QSet<QGesture *>::Iterator setIter;
while (!almostCanceledGestures.isEmpty()) {
- QGraphicsObject *target = 0;
+ QGraphicsObject *target = nullptr;
QSet<QGesture*> gestures;
setIter = almostCanceledGestures.begin();
// sort per target item
while (setIter != almostCanceledGestures.end()) {
QGraphicsObject *item = gestureTargets.value(*setIter);
- if (target == 0)
+ if (target == nullptr)
target = item;
if (target == item) {
gestures << *setIter;
@@ -6590,7 +6598,7 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original)
if (!g->hasHotSpot())
continue;
- QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), g->d_func()->sceneHotSpot, 0);
+ QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), g->d_func()->sceneHotSpot, nullptr);
for (int j = 0; j < items.size(); ++j) {
QGraphicsObject *item = items.at(j)->toGraphicsObject();
if (!item)
diff --git a/src/widgets/graphicsview/qgraphicssceneevent.cpp b/src/widgets/graphicsview/qgraphicssceneevent.cpp
index 768dd07d4e..048ea6dc7d 100644
--- a/src/widgets/graphicsview/qgraphicssceneevent.cpp
+++ b/src/widgets/graphicsview/qgraphicssceneevent.cpp
@@ -278,8 +278,8 @@ class QGraphicsSceneEventPrivate
{
public:
inline QGraphicsSceneEventPrivate()
- : widget(0),
- q_ptr(0)
+ : widget(nullptr),
+ q_ptr(nullptr)
{ }
inline virtual ~QGraphicsSceneEventPrivate()
@@ -1290,7 +1290,7 @@ class QGraphicsSceneDragDropEventPrivate : public QGraphicsSceneEventPrivate
Q_DECLARE_PUBLIC(QGraphicsSceneDragDropEvent)
public:
inline QGraphicsSceneDragDropEventPrivate()
- : source(0), mimeData(0)
+ : source(nullptr), mimeData(nullptr)
{ }
QPointF pos;
diff --git a/src/widgets/graphicsview/qgraphicstransform.cpp b/src/widgets/graphicsview/qgraphicstransform.cpp
index 0f0d9aaddc..fa763de05d 100644
--- a/src/widgets/graphicsview/qgraphicstransform.cpp
+++ b/src/widgets/graphicsview/qgraphicstransform.cpp
@@ -112,7 +112,7 @@ void QGraphicsTransformPrivate::setItem(QGraphicsItem *i)
Q_ASSERT(d_ptr->transformData);
d_ptr->transformData->graphicsTransforms.removeAll(q);
d_ptr->dirtySceneTransform = 1;
- item = 0;
+ item = nullptr;
}
item = i;
@@ -138,7 +138,7 @@ QGraphicsTransform::QGraphicsTransform(QObject *parent)
QGraphicsTransform::~QGraphicsTransform()
{
Q_D(QGraphicsTransform);
- d->setItem(0);
+ d->setItem(nullptr);
}
/*!
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index 4c270b1af2..7589a1ebbd 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -352,7 +352,7 @@ QGraphicsViewPrivate::QGraphicsViewPrivate()
alignment(Qt::AlignCenter),
transformationAnchor(QGraphicsView::AnchorViewCenter), resizeAnchor(QGraphicsView::NoAnchor),
viewportUpdateMode(QGraphicsView::MinimalViewportUpdate),
- scene(0),
+ scene(nullptr),
#if QT_CONFIG(rubberband)
rubberBanding(false),
rubberBandSelectionMode(Qt::IntersectsItemShape),
@@ -362,7 +362,7 @@ QGraphicsViewPrivate::QGraphicsViewPrivate()
#ifndef QT_NO_CURSOR
hasStoredOriginalCursor(false),
#endif
- lastDragDropEvent(0),
+ lastDragDropEvent(nullptr),
updateSceneSlotReimplementedChecked(false)
{
styleOptions.reserve(QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS);
@@ -384,7 +384,7 @@ void QGraphicsViewPrivate::recalculateContentSize()
int height = maxSize.height();
QRectF viewRect = matrix.mapRect(q->sceneRect());
- bool frameOnlyAround = (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q));
+ bool frameOnlyAround = (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, nullptr, q));
if (frameOnlyAround) {
if (hbarpolicy == Qt::ScrollBarAlwaysOn)
height -= frameWidth * 2;
@@ -394,7 +394,7 @@ void QGraphicsViewPrivate::recalculateContentSize()
// Adjust the maximum width and height of the viewport based on the width
// of visible scroll bars.
- int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q);
+ int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, q);
if (frameOnlyAround)
scrollBarExtent += frameWidth * 2;
@@ -1162,7 +1162,7 @@ QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedReg
void QGraphicsViewPrivate::updateInputMethodSensitivity()
{
Q_Q(QGraphicsView);
- QGraphicsItem *focusItem = 0;
+ QGraphicsItem *focusItem = nullptr;
bool enabled = scene && (focusItem = scene->focusItem())
&& (focusItem->d_ptr->flags & QGraphicsItem::ItemAcceptsInputMethod);
q->setAttribute(Qt::WA_InputMethodEnabled, enabled);
@@ -1174,7 +1174,7 @@ void QGraphicsViewPrivate::updateInputMethodSensitivity()
}
QGraphicsProxyWidget *proxy = focusItem->d_ptr->isWidget && focusItem->d_ptr->isProxyWidget()
- ? static_cast<QGraphicsProxyWidget *>(focusItem) : 0;
+ ? static_cast<QGraphicsProxyWidget *>(focusItem) : nullptr;
if (!proxy) {
q->setInputMethodHints(focusItem->inputMethodHints());
} else if (QWidget *widget = proxy->widget()) {
@@ -1192,7 +1192,7 @@ void QGraphicsViewPrivate::updateInputMethodSensitivity()
QGraphicsView::QGraphicsView(QWidget *parent)
: QAbstractScrollArea(*new QGraphicsViewPrivate, parent)
{
- setViewport(0);
+ setViewport(nullptr);
setAcceptDrops(true);
setBackgroundRole(QPalette::Base);
// Investigate leaving these disabled by default.
@@ -1208,7 +1208,7 @@ QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent)
: QAbstractScrollArea(*new QGraphicsViewPrivate, parent)
{
setScene(scene);
- setViewport(0);
+ setViewport(nullptr);
setAcceptDrops(true);
setBackgroundRole(QPalette::Base);
// Investigate leaving these disabled by default.
@@ -1222,7 +1222,7 @@ QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent)
QGraphicsView::QGraphicsView(QGraphicsViewPrivate &dd, QWidget *parent)
: QAbstractScrollArea(dd, parent)
{
- setViewport(0);
+ setViewport(nullptr);
setAcceptDrops(true);
setBackgroundRole(QPalette::Base);
// Investigate leaving these disabled by default.
@@ -2374,7 +2374,7 @@ QGraphicsItem *QGraphicsView::itemAt(const QPoint &pos) const
{
Q_D(const QGraphicsView);
if (!d->scene)
- return 0;
+ return nullptr;
const QList<QGraphicsItem *> itemsAtPos = items(pos);
return itemsAtPos.isEmpty() ? 0 : itemsAtPos.first();
}
@@ -2888,7 +2888,7 @@ bool QGraphicsView::viewportEvent(QEvent *event)
}
d->useLastMouseEvent = false;
// a hack to pass a viewport pointer to the scene inside the leave event
- Q_ASSERT(event->d == 0);
+ Q_ASSERT(event->d == nullptr);
QScopedValueRollback<QEventPrivate *> rb(event->d);
event->d = reinterpret_cast<QEventPrivate *>(viewport());
QCoreApplication::sendEvent(d->scene, event);
@@ -3019,7 +3019,7 @@ void QGraphicsView::dropEvent(QDropEvent *event)
event->setDropAction(sceneEvent.dropAction());
delete d->lastDragDropEvent;
- d->lastDragDropEvent = 0;
+ d->lastDragDropEvent = nullptr;
}
/*!
@@ -3077,7 +3077,7 @@ void QGraphicsView::dragLeaveEvent(QDragLeaveEvent *event)
sceneEvent.setWidget(d->lastDragDropEvent->widget());
sceneEvent.setSource(d->lastDragDropEvent->source());
delete d->lastDragDropEvent;
- d->lastDragDropEvent = 0;
+ d->lastDragDropEvent = nullptr;
// Send it to the scene.
QCoreApplication::sendEvent(d->scene, &sceneEvent);
@@ -3525,7 +3525,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
d->scene->d_func()->rectAdjust = 1;
else
d->scene->d_func()->rectAdjust = 2;
- d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : 0,
+ d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : nullptr,
&d->exposedRegion, viewport());
d->scene->d_func()->rectAdjust = oldRectAdjust;
// Make sure the painter's world transform is restored correctly when
@@ -3794,7 +3794,7 @@ void QGraphicsView::drawItems(QPainter *painter, int numItems,
{
Q_D(QGraphicsView);
if (d->scene) {
- QWidget *widget = painter->device() == viewport() ? viewport() : 0;
+ QWidget *widget = painter->device() == viewport() ? viewport() : nullptr;
d->scene->drawItems(painter, numItems, items, options, widget);
}
}
diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp
index cf041b9817..1035ed3575 100644
--- a/src/widgets/graphicsview/qgraphicswidget.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget.cpp
@@ -172,7 +172,7 @@ QT_BEGIN_NAMESPACE
window, a tool, a popup, etc).
*/
QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
- : QGraphicsObject(*new QGraphicsWidgetPrivate, 0), QGraphicsLayoutItem(0, false)
+ : QGraphicsObject(*new QGraphicsWidgetPrivate, nullptr), QGraphicsLayoutItem(nullptr, false)
{
Q_D(QGraphicsWidget);
d->init(parent, wFlags);
@@ -184,7 +184,7 @@ QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
Constructs a new QGraphicsWidget, using \a dd as parent.
*/
QGraphicsWidget::QGraphicsWidget(QGraphicsWidgetPrivate &dd, QGraphicsItem *parent, Qt::WindowFlags wFlags)
- : QGraphicsObject(dd, 0), QGraphicsLayoutItem(0, false)
+ : QGraphicsObject(dd, nullptr), QGraphicsLayoutItem(nullptr, false)
{
Q_D(QGraphicsWidget);
d->init(parent, wFlags);
@@ -241,7 +241,7 @@ QGraphicsWidget::~QGraphicsWidget()
if (QGraphicsScene *scn = scene()) {
QGraphicsScenePrivate *sceneD = scn->d_func();
if (sceneD->tabFocusFirst == this)
- sceneD->tabFocusFirst = (d->focusNext == this ? 0 : d->focusNext);
+ sceneD->tabFocusFirst = (d->focusNext == this ? nullptr : d->focusNext);
}
d->focusPrev->d_func()->focusNext = d->focusNext;
d->focusNext->d_func()->focusPrev = d->focusPrev;
@@ -263,15 +263,15 @@ QGraphicsWidget::~QGraphicsWidget()
if (item->isWidget()) {
QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
if (widget->parentLayoutItem() == d->layout)
- widget->setParentLayoutItem(0);
+ widget->setParentLayoutItem(nullptr);
}
}
- d->layout = 0;
+ d->layout = nullptr;
delete temp;
}
// Remove this graphics widget from widgetStyles
- widgetStyles()->setStyleForWidget(this, 0);
+ widgetStyles()->setStyleForWidget(this, nullptr);
// Unset the parent here, when we're still a QGraphicsWidget.
// It is otherwise done in ~QGraphicsItem() where we'd be
@@ -942,7 +942,7 @@ QStyle *QGraphicsWidget::style() const
*/
void QGraphicsWidget::setStyle(QStyle *style)
{
- setAttribute(Qt::WA_SetStyle, style != 0);
+ setAttribute(Qt::WA_SetStyle, style != nullptr);
widgetStyles()->setStyleForWidget(this, style);
// Deliver StyleChange to the widget itself (doesn't propagate).
@@ -1557,7 +1557,7 @@ bool QGraphicsWidget::focusNextPrevChild(bool next)
{
Q_D(QGraphicsWidget);
// Let the parent's focusNextPrevChild implementation decide what to do.
- QGraphicsWidget *parent = 0;
+ QGraphicsWidget *parent = nullptr;
if (!isWindow() && (parent = parentWidget()))
return parent->focusNextPrevChild(next);
if (!d->scene)
@@ -1995,7 +1995,7 @@ void QGraphicsWidget::setShortcutAutoRepeat(int id, bool enabled)
*/
void QGraphicsWidget::addAction(QAction *action)
{
- insertAction(0, action);
+ insertAction(nullptr, action);
}
/*!
@@ -2012,7 +2012,7 @@ void QGraphicsWidget::addActions(QList<QAction *> actions)
#endif
{
for (int i = 0; i < actions.count(); ++i)
- insertAction(0, actions.at(i));
+ insertAction(nullptr, actions.at(i));
}
/*!
@@ -2041,7 +2041,7 @@ void QGraphicsWidget::insertAction(QAction *before, QAction *action)
int pos = d->actions.indexOf(before);
if (pos < 0) {
- before = 0;
+ before = nullptr;
pos = d->actions.size();
}
d->actions.insert(pos, action);
@@ -2346,7 +2346,7 @@ void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGrap
frameOptions.palette.setCurrentColorGroup(isActive ? QPalette::Active : QPalette::Normal);
frameOptions.rect = windowFrameRect;
- frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, widget);
+ frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, widget);
frameOptions.midLineWidth = 1;
style()->drawPrimitive(QStyle::PE_FrameWindow, &frameOptions, painter, widget);
diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp
index 0156faf8e4..e6f39d6803 100644
--- a/src/widgets/graphicsview/qgraphicswidget_p.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp
@@ -322,7 +322,7 @@ void QGraphicsWidgetPrivate::initStyleOptionTitleBar(QStyleOptionTitleBar *optio
option->titleBarState = Qt::WindowNoState;
}
QFont windowTitleFont = QApplication::font("QMdiSubWindowTitleBar");
- QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, 0);
+ QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, nullptr);
option->text = QFontMetrics(windowTitleFont).elidedText(
windowData->windowTitle, Qt::ElideRight, textRect.width());
}
@@ -690,7 +690,7 @@ void QGraphicsWidgetPrivate::windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent
break;
case Qt::TitleBarArea:
windowData->buttonRect = q->style()->subControlRect(
- QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarCloseButton, 0);
+ QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarCloseButton, nullptr);
if (windowData->buttonRect.contains(pos.toPoint()))
windowData->buttonMouseOver = true;
event->ignore();
@@ -707,7 +707,7 @@ void QGraphicsWidgetPrivate::windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent
Q_UNUSED(cursorShape);
#endif
// update buttons if we hover over them
- windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), 0);
+ windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), nullptr);
if (windowData->hoveredSubControl != QStyle::SC_TitleBarCloseButton)
windowData->hoveredSubControl = QStyle::SC_TitleBarLabel;
@@ -781,7 +781,7 @@ void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *new
if (!parent && oldScene && oldScene != newScene && oldScene->d_func()->tabFocusFirst == q) {
// detach from old scene's top level focus chain.
- oldScene->d_func()->tabFocusFirst = (focusAfter != q) ? focusAfter : 0;
+ oldScene->d_func()->tabFocusFirst = (focusAfter != q) ? focusAfter : nullptr;
}
// detach from current focus chain; skip this widget subtree.
diff --git a/src/widgets/graphicsview/qsimplex_p.cpp b/src/widgets/graphicsview/qsimplex_p.cpp
index e18f1fa4c4..38c2df5fc6 100644
--- a/src/widgets/graphicsview/qsimplex_p.cpp
+++ b/src/widgets/graphicsview/qsimplex_p.cpp
@@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE
/*!
\internal
*/
-QSimplex::QSimplex() : objective(0), rows(0), columns(0), firstArtificial(0), matrix(0)
+QSimplex::QSimplex() : objective(nullptr), rows(0), columns(0), firstArtificial(0), matrix(nullptr)
{
}
@@ -93,7 +93,7 @@ QSimplex::~QSimplex()
*/
void QSimplex::clearDataStructures()
{
- if (matrix == 0)
+ if (matrix == nullptr)
return;
// Matrix
@@ -101,7 +101,7 @@ void QSimplex::clearDataStructures()
columns = 0;
firstArtificial = 0;
free(matrix);
- matrix = 0;
+ matrix = nullptr;
// Constraints
for (int i = 0; i < constraints.size(); ++i) {
@@ -113,7 +113,7 @@ void QSimplex::clearDataStructures()
// Other
variables.clear();
- objective = 0;
+ objective = nullptr;
}
/*!
@@ -195,7 +195,7 @@ bool QSimplex::setConstraints(const QList<QSimplexConstraint *> &newConstraints)
QSimplexVariable *artificial;
Q_ASSERT(constraints[i]->helper.first == 0);
- Q_ASSERT(constraints[i]->artificial == 0);
+ Q_ASSERT(constraints[i]->artificial == nullptr);
switch(constraints[i]->ratio) {
case QSimplexConstraint::LessOrEqual: