7#if QT_CONFIG(quick_viewtransitions)
11#include <QtCore/qscopedvaluerollback.h>
12#include <QtQml/qjsvalue.h>
13#include <QtQml/qqmlengine.h>
14#include <QtQml/qqmlinfo.h>
16#include <private/qv4qobjectwrapper_p.h>
17#include <private/qqmlengine_p.h>
41#ifndef QT_NO_DEBUG_STREAM
45 debug.nospace() <<
"QQuickStackViewArg("
46 <<
"mItem=" <<
arg.mItem
47 <<
" mComponent=" <<
arg.mComponent
48 <<
" mUrl=" <<
arg.mUrl
395#if QT_CONFIG(quick_viewtransitions)
396 if (
d->transitioner) {
397 d->transitioner->setChangeListener(
nullptr);
398 delete d->transitioner;
430 return d->elements.size();
441 return d->currentItem;
461 return element->
item;
491 for (
int i =
d->elements.size() - 1;
i >= 0; --
i) {
498 return element->
item;
574 if (
d->modifyingElements) {
579 QScopedValueRollback<bool> modifyingElements(
d->modifyingElements,
true);
580 QScopedValueRollback<QString> operationNameRollback(
d->operation,
operationName);
590#if QT_CONFIG(quick_viewtransitions)
593 if (lastArg->isInt32())
598 QList<QQuickStackElement *>
elements =
d->parseElements(0,
args, &errors);
602 return element->item && d->findElement(element->item);
608 if (!errors.isEmpty() ||
elements.isEmpty()) {
609 if (!errors.isEmpty()) {
619#if QT_CONFIG(quick_viewtransitions)
621 if (!
d->elements.isEmpty())
622 exit =
d->elements.top();
625 int oldDepth =
d->elements.size();
627 d->depthChange(
d->elements.size(), oldDepth);
629#if QT_CONFIG(quick_viewtransitions)
634 d->setCurrentItem(enter);
637 if (
d->currentItem) {
639 args->setReturnValue(rv->asReturnedValue());
688 if (
d->modifyingElements) {
694 QScopedValueRollback<bool> modifyingElements(
d->modifyingElements,
true);
695 QScopedValueRollback<QString> operationNameRollback(
d->operation,
operationName);
697 if (
d->elements.size() <= 1 || argc > 2) {
704 int oldDepth =
d->elements.size();
713 if (
value->isNull()) {
714 enter =
d->elements.value(0);
717 enter =
d->findElement(
item);
719 if (
item !=
d->currentItem)
722 d->elements.push(exit);
728#if QT_CONFIG(quick_viewtransitions)
732 if (lastArg->isInt32())
737 QPointer<QQuickItem> previousItem;
739 if (
d->popElements(enter)) {
742 d->removing.insert(exit);
743 previousItem = exit->
item;
745 d->depthChange(
d->elements.size(), oldDepth);
746#if QT_CONFIG(quick_viewtransitions)
751 d->setCurrentItem(enter);
756 args->setReturnValue(rv->asReturnedValue());
860 if (
d->modifyingElements) {
866 QScopedValueRollback<bool> modifyingElements(
d->modifyingElements,
true);
867 QScopedValueRollback<QString> operationNameRollback(
d->operation,
operationName);
877#if QT_CONFIG(quick_viewtransitions)
880 if (lastArg->isInt32())
886 if (firstArg->isNull())
888 else if (!firstArg->isInt32())
889 target =
d->findElement(firstArg);
893 if (!errors.isEmpty() ||
elements.isEmpty()) {
894 if (!errors.isEmpty()) {
904 int oldDepth =
d->elements.size();
906 if (!
d->elements.isEmpty())
907 exit =
d->elements.pop();
910 d->depthChange(
d->elements.size(), oldDepth);
913 d->removing.insert(exit);
916#if QT_CONFIG(quick_viewtransitions)
921 d->setCurrentItem(enter);
924 if (
d->currentItem) {
926 args->setReturnValue(rv->asReturnedValue());
988 if (
d->modifyingElements) {
993 QScopedValueRollback<bool> modifyingElements(
d->modifyingElements,
true);
994 QScopedValueRollback<QString> operationNameRollback(
d->operation,
operationName);
996 const QList<QQuickStackElement *> stackElements =
d->parseElements(
args);
998#if QT_CONFIG(quick_viewtransitions)
1000 if (!
d->elements.isEmpty())
1001 exit =
d->elements.top();
1004 const int oldDepth =
d->elements.size();
1005 if (
d->pushElements(stackElements)) {
1006 d->depthChange(
d->elements.size(), oldDepth);
1008#if QT_CONFIG(quick_viewtransitions)
1013 d->setCurrentItem(enter);
1016 return d->currentItem;
1139 if (index < 0 || index >=
d->elements.size()) {
1145 if (
index ==
d->elements.size() - 1) {
1151 element->
load(
this);
1175 if (
d->elements.size() == 1) {
1176 auto lastItemRemoved =
d->elements.last()->item;
1178 return lastItemRemoved;
1224QQuickItem *QQuickStackView::replaceCurrentItem(
const QList<QQuickStackViewArg> &
args,
1229 if (
d->modifyingElements) {
1234 QScopedValueRollback<bool> modifyingElements(
d->modifyingElements,
true);
1235 QScopedValueRollback<QString> operationNameRollback(
d->operation,
operationName);
1239 const QList<QQuickStackElement *> stackElements =
d->parseElements(
args);
1241 int oldDepth =
d->elements.size();
1243 if (!
d->elements.isEmpty())
1244 exit =
d->elements.pop();
1246 const bool successfullyReplaced = exit != currentElement
1247 ?
d->replaceElements(currentElement, stackElements)
1248 :
d->pushElements(stackElements);
1249 if (successfullyReplaced) {
1250 d->depthChange(
d->elements.size(), oldDepth);
1253 d->removing.insert(exit);
1256#if QT_CONFIG(quick_viewtransitions)
1261 d->setCurrentItem(enter);
1264 return d->currentItem;
1360 return d->elements.isEmpty();
1379#if !QT_CONFIG(quick_viewtransitions)
1383 if (
d->elements.isEmpty())
1387 if (
d->modifyingElements) {
1392 const int oldDepth =
d->elements.size();
1394 QScopedValueRollback<bool> modifyingElements(
d->modifyingElements,
true);
1395 QScopedValueRollback<QString> operationNameRollback(
d->operation,
operationName);
1396#if QT_CONFIG(quick_viewtransitions)
1400 d->removing.insert(exit);
1406 d->setCurrentItem(
nullptr);
1408 d->elements.clear();
1409 d->depthChange(0, oldDepth);
1427 return d->initialItem;
1433 d->initialItem =
item;
1436#if QT_CONFIG(quick_viewtransitions)
1448 if (
d->transitioner)
1449 return d->transitioner->removeDisplacedTransition;
1456 d->ensureTransitioner();
1457 if (
d->transitioner->removeDisplacedTransition == enter)
1460 d->transitioner->removeDisplacedTransition = enter;
1461 emit popEnterChanged();
1475 if (
d->transitioner)
1476 return d->transitioner->removeTransition;
1483 d->ensureTransitioner();
1484 if (
d->transitioner->removeTransition == exit)
1487 d->transitioner->removeTransition = exit;
1488 emit popExitChanged();
1502 if (
d->transitioner)
1503 return d->transitioner->addTransition;
1510 d->ensureTransitioner();
1511 if (
d->transitioner->addTransition == enter)
1514 d->transitioner->addTransition = enter;
1515 emit pushEnterChanged();
1529 if (
d->transitioner)
1530 return d->transitioner->addDisplacedTransition;
1537 d->ensureTransitioner();
1538 if (
d->transitioner->addDisplacedTransition == exit)
1541 d->transitioner->addDisplacedTransition = exit;
1542 emit pushExitChanged();
1556 if (
d->transitioner)
1557 return d->transitioner->moveTransition;
1564 d->ensureTransitioner();
1565 if (
d->transitioner->moveTransition == enter)
1568 d->transitioner->moveTransition = enter;
1569 emit replaceEnterChanged();
1583 if (
d->transitioner)
1584 return d->transitioner->moveDisplacedTransition;
1591 d->ensureTransitioner();
1592 if (
d->transitioner->moveDisplacedTransition == exit)
1595 d->transitioner->moveDisplacedTransition = exit;
1596 emit replaceExitChanged();
1605 QScopedValueRollback<QString> operationNameRollback(
d->operation,
QStringLiteral(
"initialItem"));
1608 int oldDepth =
d->elements.size();
1609 if (
QObject *
o =
d->initialItem.toQObject())
1611 else if (
d->initialItem.isString())
1613 if (!
error.isEmpty()) {
1616 }
else if (
d->pushElement(element)) {
1617 d->depthChange(
d->elements.size(), oldDepth);
1618 d->setCurrentItem(element);
1629 if (element->
item) {
1654#if QT_CONFIG(quicktemplates2_multitouch)
1661#if QT_CONFIG(accessibility)
1662QAccessible::Role QQuickStackView::accessibleRole()
const
1664 return QAccessible::LayeredPane;
1681 if (oldIndex != newIndex)
1682 emit q->indexChanged();
1683 if (oldView != newView)
1684 emit q->viewChanged();
1685 if (oldStatus != newStatus)
1686 emit q->statusChanged();
1721 return d->element ?
d->element->index : -1;
1734 return d->element ?
d->element->view :
nullptr;
1780 return parentItem && parentItem->
isVisible();
1786 d->explicitVisible =
true;
1795 d->explicitVisible =
false;
1796 if (!
d->element || !
d->element->view)
1801 parentItem->
setVisible(parentItem ==
d->element->view->currentItem());
1861#include "moc_qquickstackview_p.cpp"
QGraphicsWidget * window() const
QGraphicsItem * parentItem() const
Returns a pointer to this item's parent item.
QJSValue newQObject(QObject *object)
Creates a JavaScript object that wraps the given QObject object, using JavaScriptOwnership.
The QJSValue class acts as a container for Qt/JavaScript data types.
QJSValue call(const QJSValueList &args=QJSValueList()) const
Calls this QJSValue as a function, passing args as arguments to the function, and using the globalObj...
static constexpr Policy Preferred
qsizetype length() const noexcept
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
The QQmlComponent class encapsulates a QML component definition.
The QQmlEngine class provides an environment for instantiating QML components.
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
QQuickWindow * window() const
Returns the window in which this item is rendered.
virtual void touchEvent(QTouchEvent *event)
This event handler can be reimplemented in a subclass to receive touch events for an item.
static QQuickStackElement * fromObject(QObject *object, QQuickStackView *view, QString *error)
void setStatus(QQuickStackView::Status status)
static QQuickStackElement * fromString(const QString &str, QQuickStackView *view, QString *error)
QQuickStackView::Status status
bool load(QQuickStackView *parent)
QQuickStackViewArg()=default
void itemParentChanged(QQuickItem *item, QQuickItem *parent) override
QQuickStackElement * element
void setVisible(bool visible)
QQuickStackViewAttached(QObject *parent=nullptr)
~QQuickStackViewAttached()
QQuickStackView::Status status
static QQuickStackViewPrivate * get(QQuickStackView *view)
QQuickStackView(QQuickItem *parent=nullptr)
Provides a stack-based navigation model.
static QQuickStackViewAttached * qmlAttachedProperties(QObject *object)
bool isBusy() const
\qmlproperty bool QtQuick.Controls::StackView::busy \readonly This property holds whether a transitio...
void clear(Operation operation=Immediate)
\qmlmethod void QtQuick.Controls::StackView::clear(transition)
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
Q_INVOKABLE void pop(QQmlV4FunctionPtr args)
\qmlmethod Item QtQuick.Controls::StackView::pop(item, operation)
void setInitialItem(const QJSValue &item)
Q_INVOKABLE void push(QQmlV4FunctionPtr args)
\qmlmethod Item QtQuick.Controls::StackView::push(item, properties, operation)
Q_INVOKABLE QQuickItem * get(int index, QQuickStackView::LoadBehavior behavior=DontLoad)
\qmlmethod Item QtQuick.Controls::StackView::get(index, behavior)
Q_INVOKABLE void replace(QQmlV4FunctionPtr args)
\qmlmethod Item QtQuick.Controls::StackView::replace(target, item, properties, operation)
Q_INVOKABLE QQuickItem * find(const QJSValue &callback, QQuickStackView::LoadBehavior behavior=DontLoad)
\qmlmethod Item QtQuick.Controls::StackView::find(callback, behavior)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
bool childMouseEventFilter(QQuickItem *, QEvent *) override
Reimplement this method to filter the pointer events that are received by this item's children.
const QVariantMap & properties
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QTouchEvent class contains parameters that describe a touch event.
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static const QCssKnownValue properties[NumProperties - 1]
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
QList< QJSValue > QJSValueList
GLdouble GLdouble GLdouble GLdouble q
static qreal component(const QPointF &point, unsigned int i)
QQmlEngine * qmlEngine(const QObject *obj)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
QQuickItem * qobject_cast< QQuickItem * >(QObject *o)
QDebug operator<<(QDebug debug, const QQuickStackViewArg &arg)
static QLatin1StringView operationName(QNetworkAccessManager::Operation operation)
#define QStringLiteral(str)
static const QTextHtmlElement elements[Html_NumElements]
QUrl url("example.com")
[constructor-url-reference]
static QQuickStackTransition pushExit(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
static QQuickStackTransition replaceExit(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
static QQuickStackTransition replaceEnter(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
static QQuickStackTransition popExit(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
static QQuickStackTransition popEnter(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
static QQuickStackTransition pushEnter(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
static constexpr ReturnedValue null()
static ReturnedValue wrap(ExecutionEngine *engine, QObject *object)