aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates/qquickstackview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/templates/qquickstackview.cpp')
-rw-r--r--src/templates/qquickstackview.cpp96
1 files changed, 51 insertions, 45 deletions
diff --git a/src/templates/qquickstackview.cpp b/src/templates/qquickstackview.cpp
index bfa01e72..70194257 100644
--- a/src/templates/qquickstackview.cpp
+++ b/src/templates/qquickstackview.cpp
@@ -278,7 +278,7 @@ QQuickStackView::~QQuickStackView()
{
Q_D(QQuickStackView);
if (d->transitioner) {
- d->transitioner->setChangeListener(Q_NULLPTR);
+ d->transitioner->setChangeListener(nullptr);
delete d->transitioner;
}
qDeleteAll(d->removals);
@@ -290,7 +290,7 @@ QQuickStackAttached *QQuickStackView::qmlAttachedProperties(QObject *object)
QQuickItem *item = qobject_cast<QQuickItem *>(object);
if (!item) {
qmlInfo(object) << "StackView must be attached to an Item";
- return Q_NULLPTR;
+ return nullptr;
}
return new QQuickStackAttached(item);
}
@@ -347,7 +347,7 @@ QQuickItem *QQuickStackView::get(int index, LoadBehavior behavior)
element->load(this);
return element->item;
}
- return Q_NULLPTR;
+ return nullptr;
}
/*!
@@ -373,7 +373,7 @@ QQuickItem *QQuickStackView::find(const QJSValue &callback, LoadBehavior behavio
QJSValue func(callback);
QQmlEngine *engine = qmlEngine(this);
if (!engine || !func.isCallable()) // TODO: warning?
- return Q_NULLPTR;
+ return nullptr;
for (int i = d->elements.count() - 1; i >= 0; --i) {
QQuickStackElement *element = d->elements.at(i);
@@ -386,7 +386,7 @@ QQuickItem *QQuickStackView::find(const QJSValue &callback, LoadBehavior behavio
}
}
- return Q_NULLPTR;
+ return nullptr;
}
/*!
@@ -457,7 +457,7 @@ void QQuickStackView::push(QQmlV4Function *args)
return;
}
- QQuickStackElement *exit = Q_NULLPTR;
+ QQuickStackElement *exit = nullptr;
if (!d->elements.isEmpty())
exit = d->elements.top();
@@ -541,7 +541,7 @@ void QQuickStackView::pop(QQmlV4Function *args)
operation = static_cast<Operation>(lastArg->toInt32());
}
- QQuickItem *previousItem = Q_NULLPTR;
+ QQuickItem *previousItem = nullptr;
if (d->popElements(enter)) {
if (exit)
@@ -624,7 +624,7 @@ void QQuickStackView::replace(QQmlV4Function *args)
if (lastArg->isInt32())
operation = static_cast<Operation>(lastArg->toInt32());
- QQuickStackElement *target = Q_NULLPTR;
+ QQuickStackElement *target = nullptr;
QV4::ScopedValue firstArg(scope, (*args)[0]);
if (firstArg->isNull())
target = d->elements.value(0);
@@ -639,7 +639,7 @@ void QQuickStackView::replace(QQmlV4Function *args)
}
int depth = d->elements.count();
- QQuickStackElement* exit = Q_NULLPTR;
+ QQuickStackElement* exit = nullptr;
if (!d->elements.isEmpty())
exit = d->elements.pop();
@@ -667,7 +667,7 @@ void QQuickStackView::replace(QQmlV4Function *args)
void QQuickStackView::clear()
{
Q_D(QQuickStackView);
- d->setCurrentItem(Q_NULLPTR);
+ d->setCurrentItem(nullptr);
qDeleteAll(d->elements);
d->elements.clear();
emit depthChanged();
@@ -710,17 +710,18 @@ QQuickTransition *QQuickStackView::popEnter() const
Q_D(const QQuickStackView);
if (d->transitioner)
return d->transitioner->removeDisplacedTransition;
- return Q_NULLPTR;
+ return nullptr;
}
void QQuickStackView::setPopEnter(QQuickTransition *enter)
{
Q_D(QQuickStackView);
d->ensureTransitioner();
- if (d->transitioner->removeDisplacedTransition != enter) {
- d->transitioner->removeDisplacedTransition = enter;
- emit popEnterChanged();
- }
+ if (d->transitioner->removeDisplacedTransition == enter)
+ return;
+
+ d->transitioner->removeDisplacedTransition = enter;
+ emit popEnterChanged();
}
/*!
@@ -736,17 +737,18 @@ QQuickTransition *QQuickStackView::popExit() const
Q_D(const QQuickStackView);
if (d->transitioner)
return d->transitioner->removeTransition;
- return Q_NULLPTR;
+ return nullptr;
}
void QQuickStackView::setPopExit(QQuickTransition *exit)
{
Q_D(QQuickStackView);
d->ensureTransitioner();
- if (d->transitioner->removeTransition != exit) {
- d->transitioner->removeTransition = exit;
- emit popExitChanged();
- }
+ if (d->transitioner->removeTransition == exit)
+ return;
+
+ d->transitioner->removeTransition = exit;
+ emit popExitChanged();
}
/*!
@@ -762,17 +764,18 @@ QQuickTransition *QQuickStackView::pushEnter() const
Q_D(const QQuickStackView);
if (d->transitioner)
return d->transitioner->addTransition;
- return Q_NULLPTR;
+ return nullptr;
}
void QQuickStackView::setPushEnter(QQuickTransition *enter)
{
Q_D(QQuickStackView);
d->ensureTransitioner();
- if (d->transitioner->addTransition != enter) {
- d->transitioner->addTransition = enter;
- emit pushEnterChanged();
- }
+ if (d->transitioner->addTransition == enter)
+ return;
+
+ d->transitioner->addTransition = enter;
+ emit pushEnterChanged();
}
/*!
@@ -788,17 +791,18 @@ QQuickTransition *QQuickStackView::pushExit() const
Q_D(const QQuickStackView);
if (d->transitioner)
return d->transitioner->addDisplacedTransition;
- return Q_NULLPTR;
+ return nullptr;
}
void QQuickStackView::setPushExit(QQuickTransition *exit)
{
Q_D(QQuickStackView);
d->ensureTransitioner();
- if (d->transitioner->addDisplacedTransition != exit) {
- d->transitioner->addDisplacedTransition = exit;
- emit pushExitChanged();
- }
+ if (d->transitioner->addDisplacedTransition == exit)
+ return;
+
+ d->transitioner->addDisplacedTransition = exit;
+ emit pushExitChanged();
}
/*!
@@ -814,17 +818,18 @@ QQuickTransition *QQuickStackView::replaceEnter() const
Q_D(const QQuickStackView);
if (d->transitioner)
return d->transitioner->moveTransition;
- return Q_NULLPTR;
+ return nullptr;
}
void QQuickStackView::setReplaceEnter(QQuickTransition *enter)
{
Q_D(QQuickStackView);
d->ensureTransitioner();
- if (d->transitioner->moveTransition != enter) {
- d->transitioner->moveTransition = enter;
- emit replaceEnterChanged();
- }
+ if (d->transitioner->moveTransition == enter)
+ return;
+
+ d->transitioner->moveTransition = enter;
+ emit replaceEnterChanged();
}
/*!
@@ -840,17 +845,18 @@ QQuickTransition *QQuickStackView::replaceExit() const
Q_D(const QQuickStackView);
if (d->transitioner)
return d->transitioner->moveDisplacedTransition;
- return Q_NULLPTR;
+ return nullptr;
}
void QQuickStackView::setReplaceExit(QQuickTransition *exit)
{
Q_D(QQuickStackView);
d->ensureTransitioner();
- if (d->transitioner->moveDisplacedTransition != exit) {
- d->transitioner->moveDisplacedTransition = exit;
- emit replaceExitChanged();
- }
+ if (d->transitioner->moveDisplacedTransition == exit)
+ return;
+
+ d->transitioner->moveDisplacedTransition = exit;
+ emit replaceExitChanged();
}
void QQuickStackView::componentComplete()
@@ -858,7 +864,7 @@ void QQuickStackView::componentComplete()
QQuickControl::componentComplete();
Q_D(QQuickStackView);
- QQuickStackElement *element = Q_NULLPTR;
+ QQuickStackElement *element = nullptr;
if (QObject *o = d->initialItem.value<QObject *>())
element = QQuickStackElement::fromObject(o, this);
else if (d->initialItem.canConvert<QString>())
@@ -875,7 +881,7 @@ void QQuickStackView::geometryChanged(const QRectF &newGeometry, const QRectF &o
QQuickControl::geometryChanged(newGeometry, oldGeometry);
Q_D(QQuickStackView);
- foreach (QQuickStackElement *element, d->elements) {
+ for (QQuickStackElement *element : qAsConst(d->elements)) {
if (element->item) {
if (!element->widthValid)
element->item->setWidth(newGeometry.width());
@@ -903,11 +909,11 @@ void QQuickStackAttachedPrivate::itemParentChanged(QQuickItem *item, QQuickItem
{
Q_Q(QQuickStackAttached);
int oldIndex = element ? element->index : -1;
- QQuickStackView *oldView = element ? element->view : Q_NULLPTR;
+ QQuickStackView *oldView = element ? element->view : nullptr;
QQuickStackView::Status oldStatus = element ? element->status : QQuickStackView::Inactive;
QQuickStackView *newView = qobject_cast<QQuickStackView *>(parent);
- element = newView ? QQuickStackViewPrivate::get(newView)->findElement(item) : Q_NULLPTR;
+ element = newView ? QQuickStackViewPrivate::get(newView)->findElement(item) : nullptr;
int newIndex = element ? element->index : -1;
QQuickStackView::Status newStatus = element ? element->status : QQuickStackView::Inactive;
@@ -958,7 +964,7 @@ int QQuickStackAttached::index() const
QQuickStackView *QQuickStackAttached::view() const
{
Q_D(const QQuickStackAttached);
- return d->element ? d->element->view : Q_NULLPTR;
+ return d->element ? d->element->view : nullptr;
}
/*!