aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates/qquickdrawer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/templates/qquickdrawer.cpp')
-rw-r--r--src/templates/qquickdrawer.cpp76
1 files changed, 40 insertions, 36 deletions
diff --git a/src/templates/qquickdrawer.cpp b/src/templates/qquickdrawer.cpp
index 5f3d95c9..a28d11a6 100644
--- a/src/templates/qquickdrawer.cpp
+++ b/src/templates/qquickdrawer.cpp
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-navigation
\ingroup qtlabscontrols-containers
- \brief A side panel control.
+ \brief Provides a swipe-based side panel.
Drawer provides a swipe-based side panel, similar to those often used in
touch interfaces to provide a central location for navigation.
@@ -97,14 +97,14 @@ class QQuickDrawerPrivate : public QQuickControlPrivate, public QQuickItemChange
public:
QQuickDrawerPrivate() : edge(Qt::LeftEdge), offset(0), position(0),
- content(Q_NULLPTR), animation(Q_NULLPTR) { }
+ content(nullptr), animation(nullptr) { }
void updateContent();
bool handleMousePressEvent(QQuickItem *item, QMouseEvent *event);
bool handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event);
bool handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event);
- void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &) Q_DECL_OVERRIDE;
+ void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &) override;
Qt::Edge edge;
qreal offset;
@@ -290,12 +290,13 @@ Qt::Edge QQuickDrawer::edge() const
void QQuickDrawer::setEdge(Qt::Edge edge)
{
Q_D(QQuickDrawer);
- if (d->edge != edge) {
- d->edge = edge;
- if (isComponentComplete())
- d->updateContent();
- emit edgeChanged();
- }
+ if (d->edge == edge)
+ return;
+
+ d->edge = edge;
+ if (isComponentComplete())
+ d->updateContent();
+ emit edgeChanged();
}
/*!
@@ -315,12 +316,13 @@ void QQuickDrawer::setPosition(qreal position)
{
Q_D(QQuickDrawer);
position = qBound<qreal>(0.0, position, 1.0);
- if (!qFuzzyCompare(d->position, position)) {
- d->position = position;
- if (isComponentComplete())
- d->updateContent();
- emit positionChanged();
- }
+ if (qFuzzyCompare(d->position, position))
+ return;
+
+ d->position = position;
+ if (isComponentComplete())
+ d->updateContent();
+ emit positionChanged();
}
@@ -338,20 +340,21 @@ QQuickItem *QQuickDrawer::contentItem() const
void QQuickDrawer::setContentItem(QQuickItem *item)
{
Q_D(QQuickDrawer);
- if (d->content != item) {
- if (d->content) {
- QQuickItemPrivate::get(d->content)->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
- delete d->content;
- }
- d->content = item;
- if (item) {
- item->setParentItem(this);
- QQuickItemPrivate::get(item)->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
- if (isComponentComplete())
- d->updateContent();
- }
- emit contentItemChanged();
+ if (d->content == item)
+ return;
+
+ if (d->content) {
+ QQuickItemPrivate::get(d->content)->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
+ delete d->content;
}
+ d->content = item;
+ if (item) {
+ item->setParentItem(this);
+ QQuickItemPrivate::get(item)->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
+ if (isComponentComplete())
+ d->updateContent();
+ }
+ emit contentItemChanged();
}
/*!
@@ -371,15 +374,16 @@ QQuickPropertyAnimation *QQuickDrawer::animation() const
void QQuickDrawer::setAnimation(QQuickPropertyAnimation *animation)
{
Q_D(QQuickDrawer);
- if (d->animation != animation) {
- delete d->animation;
- d->animation = animation;
- if (animation) {
- animation->setTargetObject(this);
- animation->setProperty(QStringLiteral("position"));
- }
- emit animationChanged();
+ if (d->animation == animation)
+ return;
+
+ delete d->animation;
+ d->animation = animation;
+ if (animation) {
+ animation->setTargetObject(this);
+ animation->setProperty(QStringLiteral("position"));
}
+ emit animationChanged();
}
/*!