aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicklayouts/qquickstacklayout_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicklayouts/qquickstacklayout_p.h')
-rw-r--r--src/quicklayouts/qquickstacklayout_p.h75
1 files changed, 24 insertions, 51 deletions
diff --git a/src/quicklayouts/qquickstacklayout_p.h b/src/quicklayouts/qquickstacklayout_p.h
index 07c2fc3727..0ace1e63a3 100644
--- a/src/quicklayouts/qquickstacklayout_p.h
+++ b/src/quicklayouts/qquickstacklayout_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Quick Layouts module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QQUICKSTACKLAYOUT_H
#define QQUICKSTACKLAYOUT_H
@@ -59,7 +23,7 @@ QT_BEGIN_NAMESPACE
class QQuickStackLayoutPrivate;
class QQuickStackLayoutAttached;
-class Q_QUICKLAYOUT_PRIVATE_EXPORT QQuickStackLayout : public QQuickLayout
+class Q_QUICKLAYOUTS_EXPORT QQuickStackLayout : public QQuickLayout
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
@@ -69,7 +33,7 @@ class Q_QUICKLAYOUT_PRIVATE_EXPORT QQuickStackLayout : public QQuickLayout
QML_ATTACHED(QQuickStackLayoutAttached)
public:
- explicit QQuickStackLayout(QQuickItem *parent = 0);
+ explicit QQuickStackLayout(QQuickItem *parent = nullptr);
int count() const;
int currentIndex() const;
void setCurrentIndex(int index);
@@ -78,26 +42,34 @@ public:
void itemChange(ItemChange change, const ItemChangeData &value) override;
QSizeF sizeHint(Qt::SizeHint whichSizeHint) const override;
void setAlignment(QQuickItem *item, Qt::Alignment align) override;
- void invalidate(QQuickItem *childItem = 0) override;
- void updateLayoutItems() override;
+ void invalidate(QQuickItem *childItem = nullptr) override;
+ void updateLayoutItems() override { }
void rearrange(const QSizeF &) override;
+ void setStretchFactor(QQuickItem *item, int stretchFactor, Qt::Orientation orient) override;
// iterator
Q_INVOKABLE QQuickItem *itemAt(int index) const override;
int itemCount() const override;
int indexOf(QQuickItem *item) const;
+ /* QQuickItemChangeListener */
+ void itemSiblingOrderChanged(QQuickItem *item) override;
+
static QQuickStackLayoutAttached *qmlAttachedProperties(QObject *object);
-signals:
+Q_SIGNALS:
void currentIndexChanged();
void countChanged();
-public slots:
-
private:
+ enum AdjustCurrentIndexPolicy {
+ DontAdjustCurrentIndex,
+ AdjustCurrentIndex
+ };
+
static void collectItemSizeHints(QQuickItem *item, QSizeF *sizeHints);
bool shouldIgnoreItem(QQuickItem *item) const;
+ void childItemsChanged(AdjustCurrentIndexPolicy adjustCurrentIndexPolicy = DontAdjustCurrentIndex);
Q_DECLARE_PRIVATE(QQuickStackLayout)
friend class QQuickStackLayoutAttached;
@@ -111,8 +83,9 @@ private:
QSizeF array[Qt::NSizeHints];
};
- mutable QVector<SizeHints> m_cachedItemSizeHints;
+ mutable QHash<QQuickItem*, SizeHints> m_cachedItemSizeHints;
mutable QSizeF m_cachedSizeHints[Qt::NSizeHints];
+ SizeHints &cachedItemSizeHints(int index) const;
};
class QQuickStackLayoutPrivate : public QQuickLayoutPrivate
@@ -126,12 +99,12 @@ private:
bool explicitCurrentIndex;
};
-class QQuickStackLayoutAttached : public QObject
+class Q_QUICKLAYOUTS_EXPORT QQuickStackLayoutAttached : public QObject
{
Q_OBJECT
- Q_PROPERTY(int index READ index NOTIFY indexChanged)
- Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY isCurrentItemChanged)
- Q_PROPERTY(QQuickStackLayout *layout READ layout NOTIFY layoutChanged)
+ Q_PROPERTY(int index READ index NOTIFY indexChanged FINAL)
+ Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY isCurrentItemChanged FINAL)
+ Q_PROPERTY(QQuickStackLayout *layout READ layout NOTIFY layoutChanged FINAL)
public:
QQuickStackLayoutAttached(QObject *object);
@@ -145,7 +118,7 @@ public:
QQuickStackLayout *layout() const;
void setLayout(QQuickStackLayout *layout);
-signals:
+Q_SIGNALS:
void indexChanged();
void isCurrentItemChanged();
void layoutChanged();