aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates/qquickpageindicator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/templates/qquickpageindicator.cpp')
-rw-r--r--src/templates/qquickpageindicator.cpp51
1 files changed, 28 insertions, 23 deletions
diff --git a/src/templates/qquickpageindicator.cpp b/src/templates/qquickpageindicator.cpp
index a360627e..1035085e 100644
--- a/src/templates/qquickpageindicator.cpp
+++ b/src/templates/qquickpageindicator.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickPageIndicator
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-indicators
- \brief A page indicator control.
+ \brief Indicates the currently active page.
PageIndicator is used to indicate the currently active page
in a container of multiple pages. PageIndicator consists of
@@ -70,7 +70,7 @@ class QQuickPageIndicatorPrivate : public QQuickControlPrivate, public QQuickIte
public:
QQuickPageIndicatorPrivate() : count(0), currentIndex(0),
- interactive(false), delegate(Q_NULLPTR), pressedItem(Q_NULLPTR)
+ interactive(false), delegate(nullptr), pressedItem(nullptr)
{
}
@@ -91,7 +91,7 @@ QQuickItem *QQuickPageIndicatorPrivate::itemAt(const QPoint &pos) const
{
Q_Q(const QQuickPageIndicator);
if (!contentItem || !q->contains(pos))
- return Q_NULLPTR;
+ return nullptr;
QPointF contentPos = q->mapToItem(contentItem, pos);
QQuickItem *item = contentItem->childAt(contentPos.x(), contentPos.y());
@@ -102,8 +102,9 @@ QQuickItem *QQuickPageIndicatorPrivate::itemAt(const QPoint &pos) const
// find the nearest
qreal distance = qInf();
- QQuickItem *nearest = Q_NULLPTR;
- foreach (QQuickItem *child, contentItem->childItems()) {
+ QQuickItem *nearest = nullptr;
+ const auto childItems = contentItem->childItems();
+ for (QQuickItem *child : childItems) {
if (QQuickItemPrivate::get(child)->isTransparentForPositioner())
continue;
@@ -122,7 +123,7 @@ QQuickItem *QQuickPageIndicatorPrivate::itemAt(const QPoint &pos) const
void QQuickPageIndicatorPrivate::updatePressed(bool pressed, const QPoint &pos)
{
QQuickItem *prevItem = pressedItem;
- pressedItem = pressed ? itemAt(pos) : Q_NULLPTR;
+ pressedItem = pressed ? itemAt(pos) : nullptr;
if (prevItem != pressedItem) {
setContextProperty(prevItem, QStringLiteral("pressed"), false);
setContextProperty(pressedItem, QStringLiteral("pressed"), pressed);
@@ -164,10 +165,11 @@ int QQuickPageIndicator::count() const
void QQuickPageIndicator::setCount(int count)
{
Q_D(QQuickPageIndicator);
- if (d->count != count) {
- d->count = count;
- emit countChanged();
- }
+ if (d->count == count)
+ return;
+
+ d->count = count;
+ emit countChanged();
}
/*!
@@ -184,10 +186,11 @@ int QQuickPageIndicator::currentIndex() const
void QQuickPageIndicator::setCurrentIndex(int index)
{
Q_D(QQuickPageIndicator);
- if (d->currentIndex != index) {
- d->currentIndex = index;
- emit currentIndexChanged();
- }
+ if (d->currentIndex == index)
+ return;
+
+ d->currentIndex = index;
+ emit currentIndexChanged();
}
/*!
@@ -208,11 +211,12 @@ bool QQuickPageIndicator::isInteractive() const
void QQuickPageIndicator::setInteractive(bool interactive)
{
Q_D(QQuickPageIndicator);
- if (d->interactive != interactive) {
- d->interactive = interactive;
- setAcceptedMouseButtons(interactive ? Qt::LeftButton : Qt::NoButton);
- emit interactiveChanged();
- }
+ if (d->interactive == interactive)
+ return;
+
+ d->interactive = interactive;
+ setAcceptedMouseButtons(interactive ? Qt::LeftButton : Qt::NoButton);
+ emit interactiveChanged();
}
/*!
@@ -235,10 +239,11 @@ QQmlComponent *QQuickPageIndicator::delegate() const
void QQuickPageIndicator::setDelegate(QQmlComponent *delegate)
{
Q_D(QQuickPageIndicator);
- if (d->delegate != delegate) {
- d->delegate = delegate;
- emit delegateChanged();
- }
+ if (d->delegate == delegate)
+ return;
+
+ d->delegate = delegate;
+ emit delegateChanged();
}
void QQuickPageIndicator::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)