diff options
| author | Mitch Curtis <mitch.curtis@qt.io> | 2023-05-25 13:55:46 +0800 |
|---|---|---|
| committer | Mitch Curtis <mitch.curtis@qt.io> | 2023-07-05 13:06:53 +0800 |
| commit | 3e619367b13399eb17224594722af06c6620cf03 (patch) | |
| tree | d64076b83bbdab8ec8776373011ff821e2f2f9c6 /src/quicktemplates/qquickstackelement.cpp | |
| parent | 4f88841b29ab5f72c13050f78bb34aeffb1f6079 (diff) | |
StackView: add strongly-typed push functions
[ChangeLog][Controls][StackView] Added strongly-typed pushItem
and pushItems functions. These can be compiled to C++ by the
QML Compiler.
Task-number: QTBUG-112475
Change-Id: Ib69181701127513ba7a0095370f7a7c8b21d4649
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/quicktemplates/qquickstackelement.cpp')
| -rw-r--r-- | src/quicktemplates/qquickstackelement.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/quicktemplates/qquickstackelement.cpp b/src/quicktemplates/qquickstackelement.cpp index 12c3fbdd94..f6a5ffdd74 100644 --- a/src/quicktemplates/qquickstackelement.cpp +++ b/src/quicktemplates/qquickstackelement.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qquickstackelement_p_p.h" +#include "qquickstackview_p.h" #include "qquickstackview_p_p.h" #include <QtQml/qqmlinfo.h> @@ -126,6 +127,31 @@ QQuickStackElement *QQuickStackElement::fromObject(QObject *object, QQuickStackV return element; } +QQuickStackElement *QQuickStackElement::fromStackViewArg(QQuickStackView *view, QQuickStackViewArg arg) +{ + QQuickStackElement *element = new QQuickStackElement; +#if QT_CONFIG(quick_viewtransitions) + element->item = arg.mItem; + if (element->item) { + element->originalParent = element->item->parentItem(); + + Q_ASSERT(!arg.mComponent); + Q_ASSERT(!arg.mUrl.isValid()); + } else +#endif + if (arg.mComponent) { + element->component = arg.mComponent; + + Q_ASSERT(!arg.mUrl.isValid()); + } else if (arg.mUrl.isValid()) { + element->component = new QQmlComponent(qmlEngine(view), arg.mUrl, view); + element->ownComponent = true; + } else { + qFatal("No Item, Component or URL set on arg passed to fromStrictArg"); + } + return element; +} + bool QQuickStackElement::load(QQuickStackView *parent) { setView(parent); |
