diff options
Diffstat (limited to 'src/quicktemplates/qquickstackview_p.h')
-rw-r--r-- | src/quicktemplates/qquickstackview_p.h | 81 |
1 files changed, 71 insertions, 10 deletions
diff --git a/src/quicktemplates/qquickstackview_p.h b/src/quicktemplates/qquickstackview_p.h index b36976a395..8606759a7c 100644 --- a/src/quicktemplates/qquickstackview_p.h +++ b/src/quicktemplates/qquickstackview_p.h @@ -15,30 +15,67 @@ // We mean it. // +#include <QtCore/qdebug.h> #include <QtQuickTemplates2/private/qquickcontrol_p.h> QT_BEGIN_NAMESPACE -class QQmlV4Function; class QQuickTransition; class QQuickStackElement; class QQuickStackViewPrivate; class QQuickStackViewAttached; class QQuickStackViewAttachedPrivate; -class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickStackView : public QQuickControl +/*! + \internal + + Input from the user that is turned into QQuickStackElements. + + This was added to support the QML-compiler-friendly pushElement[s] + functions. +*/ +class QQuickStackViewArg +{ + Q_GADGET + QML_CONSTRUCTIBLE_VALUE + QML_ANONYMOUS + +public: + QQuickStackViewArg() = default; + Q_INVOKABLE QQuickStackViewArg(QQuickItem *item); + Q_INVOKABLE QQuickStackViewArg(const QUrl &url); + Q_INVOKABLE QQuickStackViewArg(QQmlComponent *component); + Q_INVOKABLE QQuickStackViewArg(const QVariantMap &properties); + +#ifndef QT_NO_DEBUG_STREAM + friend QDebug operator<<(QDebug debug, const QQuickStackViewArg &arg); +#endif + +private: + friend class QQuickStackViewPrivate; + friend class QQuickStackElement; + + QQuickItem *mItem = nullptr; + QQmlComponent *mComponent = nullptr; + QUrl mUrl; + QVariantMap mProperties; +}; + +class Q_QUICKTEMPLATES2_EXPORT QQuickStackView : public QQuickControl { Q_OBJECT Q_PROPERTY(bool busy READ isBusy NOTIFY busyChanged FINAL) Q_PROPERTY(int depth READ depth NOTIFY depthChanged FINAL) Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged FINAL) Q_PROPERTY(QJSValue initialItem READ initialItem WRITE setInitialItem FINAL) +#if QT_CONFIG(quick_viewtransitions) Q_PROPERTY(QQuickTransition *popEnter READ popEnter WRITE setPopEnter NOTIFY popEnterChanged FINAL) Q_PROPERTY(QQuickTransition *popExit READ popExit WRITE setPopExit NOTIFY popExitChanged FINAL) Q_PROPERTY(QQuickTransition *pushEnter READ pushEnter WRITE setPushEnter NOTIFY pushEnterChanged FINAL) Q_PROPERTY(QQuickTransition *pushExit READ pushExit WRITE setPushExit NOTIFY pushExitChanged FINAL) Q_PROPERTY(QQuickTransition *replaceEnter READ replaceEnter WRITE setReplaceEnter NOTIFY replaceEnterChanged FINAL) Q_PROPERTY(QQuickTransition *replaceExit READ replaceExit WRITE setReplaceExit NOTIFY replaceExitChanged FINAL) +#endif // 2.3 (Qt 5.10) Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged FINAL REVISION(2, 3)) QML_NAMED_ELEMENT(StackView) @@ -66,6 +103,7 @@ public: QJSValue initialItem() const; void setInitialItem(const QJSValue &item); +#if QT_CONFIG(quick_viewtransitions) QQuickTransition *popEnter() const; void setPopEnter(QQuickTransition *enter); @@ -83,6 +121,7 @@ public: QQuickTransition *replaceExit() const; void setReplaceExit(QQuickTransition *exit); +#endif enum LoadBehavior { DontLoad, @@ -90,8 +129,8 @@ public: }; Q_ENUM(LoadBehavior) - Q_INVOKABLE QQuickItem *get(int index, LoadBehavior behavior = DontLoad); - Q_INVOKABLE QQuickItem *find(const QJSValue &callback, LoadBehavior behavior = DontLoad); + Q_INVOKABLE QQuickItem *get(int index, QQuickStackView::LoadBehavior behavior = DontLoad); + Q_INVOKABLE QQuickItem *find(const QJSValue &callback, QQuickStackView::LoadBehavior behavior = DontLoad); enum Operation { Transition = -1, // ### Deprecated in Qt 6; remove in Qt 7. @@ -102,9 +141,31 @@ public: }; Q_ENUM(Operation) - Q_INVOKABLE void push(QQmlV4Function *args); - Q_INVOKABLE void pop(QQmlV4Function *args); - Q_INVOKABLE void replace(QQmlV4Function *args); + Q_INVOKABLE void push(QQmlV4FunctionPtr args); + Q_INVOKABLE void pop(QQmlV4FunctionPtr args); + Q_INVOKABLE void replace(QQmlV4FunctionPtr args); + + Q_REVISION(6, 7) Q_INVOKABLE QQuickItem *pushItems(QList<QQuickStackViewArg> args, + Operation operation = Immediate); + Q_REVISION(6, 7) Q_INVOKABLE QQuickItem *pushItem(QQuickItem *item, const QVariantMap &properties = {}, + Operation operation = Immediate); + Q_REVISION(6, 7) Q_INVOKABLE QQuickItem *pushItem(QQmlComponent *component, const QVariantMap &properties = {}, + Operation operation = Immediate); + Q_REVISION(6, 7) Q_INVOKABLE QQuickItem *pushItem(const QUrl &url, const QVariantMap &properties = {}, + Operation operation = Immediate); + + Q_REVISION(6, 7) Q_INVOKABLE QQuickItem *popToItem(QQuickItem *item, Operation operation = PopTransition); + Q_REVISION(6, 7) Q_INVOKABLE QQuickItem *popToIndex(int index, Operation operation = PopTransition); + Q_REVISION(6, 7) Q_INVOKABLE QQuickItem *popCurrentItem(Operation operation = PopTransition); + + Q_REVISION(6, 7) Q_INVOKABLE QQuickItem *replaceCurrentItem(const QList<QQuickStackViewArg> &args, + Operation operation = ReplaceTransition); + Q_REVISION(6, 7) Q_INVOKABLE QQuickItem *replaceCurrentItem(QQuickItem *item, + const QVariantMap &properties = {}, Operation operation = ReplaceTransition); + Q_REVISION(6, 7) Q_INVOKABLE QQuickItem *replaceCurrentItem(QQmlComponent *component, + const QVariantMap &properties = {}, Operation operation = ReplaceTransition); + Q_REVISION(6, 7) Q_INVOKABLE QQuickItem *replaceCurrentItem(const QUrl &url, + const QVariantMap &properties = {}, Operation operation = ReplaceTransition); // 2.3 (Qt 5.10) bool isEmpty() const; @@ -116,12 +177,14 @@ Q_SIGNALS: void busyChanged(); void depthChanged(); void currentItemChanged(); +#if QT_CONFIG(quick_viewtransitions) void popEnterChanged(); void popExitChanged(); void pushEnterChanged(); void pushExitChanged(); void replaceEnterChanged(); void replaceExitChanged(); +#endif // 2.3 (Qt 5.10) Q_REVISION(2, 3) void emptyChanged(); @@ -143,7 +206,7 @@ private: Q_DECLARE_PRIVATE(QQuickStackView) }; -class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickStackViewAttached : public QObject +class Q_QUICKTEMPLATES2_EXPORT QQuickStackViewAttached : public QObject { Q_OBJECT Q_PROPERTY(int index READ index NOTIFY indexChanged FINAL) @@ -185,6 +248,4 @@ private: QT_END_NAMESPACE -QML_DECLARE_TYPE(QQuickStackView) - #endif // QQUICKSTACKVIEW_P_H |