diff options
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r-- | src/quicktemplates2/qquickstackview.cpp | 16 | ||||
-rw-r--r-- | src/quicktemplates2/qquickstackview_p.cpp | 10 | ||||
-rw-r--r-- | src/quicktemplates2/qquickstackview_p_p.h | 3 |
3 files changed, 23 insertions, 6 deletions
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp index a9922704..dbc8c7bb 100644 --- a/src/quicktemplates2/qquickstackview.cpp +++ b/src/quicktemplates2/qquickstackview.cpp @@ -39,6 +39,7 @@ #include "qquickstackelement_p_p.h" #include "qquickstacktransition_p_p.h" +#include <QtCore/qscopedvaluerollback.h> #include <QtQml/qjsvalue.h> #include <QtQml/qqmlengine.h> #include <QtQml/qqmlinfo.h> @@ -474,8 +475,9 @@ QQuickItem *QQuickStackView::find(const QJSValue &callback, LoadBehavior behavio void QQuickStackView::push(QQmlV4Function *args) { Q_D(QQuickStackView); + QScopedValueRollback<QString> rollback(d->operation, QStringLiteral("push")); if (args->length() <= 0) { - qmlWarning(this) << "push: missing arguments"; + d->warn(QStringLiteral("missing arguments")); args->setReturnValue(QV4::Encode::null()); return; } @@ -499,7 +501,7 @@ void QQuickStackView::push(QQmlV4Function *args) } if (elements.isEmpty()) { - qmlWarning(this) << "push: nothing to push"; + d->warn(QStringLiteral("nothing to push")); args->setReturnValue(QV4::Encode::null()); return; } @@ -557,10 +559,11 @@ void QQuickStackView::push(QQmlV4Function *args) void QQuickStackView::pop(QQmlV4Function *args) { Q_D(QQuickStackView); + QScopedValueRollback<QString> rollback(d->operation, QStringLiteral("pop")); int argc = args->length(); if (d->elements.count() <= 1 || argc > 2) { if (argc > 2) - qmlWarning(this) << "pop: too many arguments"; + d->warn(QStringLiteral("too many arguments")); args->setReturnValue(QV4::Encode::null()); return; } @@ -580,7 +583,7 @@ void QQuickStackView::pop(QQmlV4Function *args) enter = d->findElement(item); if (!enter) { if (item != d->currentItem) - qmlWarning(this) << "pop: unknown argument: " << value->toQString(); // TODO: safe? + d->warn(QStringLiteral("unknown argument: ") + value->toQString()); // TODO: safe? args->setReturnValue(QV4::Encode::null()); d->elements.push(exit); // restore return; @@ -708,8 +711,9 @@ void QQuickStackView::pop(QQmlV4Function *args) void QQuickStackView::replace(QQmlV4Function *args) { Q_D(QQuickStackView); + QScopedValueRollback<QString> rollback(d->operation, QStringLiteral("replace")); if (args->length() <= 0) { - qmlWarning(this) << "replace: missing arguments"; + d->warn(QStringLiteral("missing arguments")); args->setReturnValue(QV4::Encode::null()); return; } @@ -731,7 +735,7 @@ void QQuickStackView::replace(QQmlV4Function *args) QList<QQuickStackElement *> elements = d->parseElements(args, target ? 1 : 0); if (elements.isEmpty()) { - qmlWarning(this) << "replace: nothing to push"; + d->warn(QStringLiteral("nothing to push")); args->setReturnValue(QV4::Encode::null()); return; } diff --git a/src/quicktemplates2/qquickstackview_p.cpp b/src/quicktemplates2/qquickstackview_p.cpp index 89b3c6e3..077c13e3 100644 --- a/src/quicktemplates2/qquickstackview_p.cpp +++ b/src/quicktemplates2/qquickstackview_p.cpp @@ -38,6 +38,7 @@ #include "qquickstackelement_p_p.h" #include "qquickstacktransition_p_p.h" +#include <QtQml/qqmlinfo.h> #include <QtQml/qqmllist.h> #include <QtQml/private/qv4qmlcontext_p.h> #include <QtQml/private/qv4qobjectwrapper_p.h> @@ -53,6 +54,15 @@ QQuickStackViewPrivate::QQuickStackViewPrivate() { } +void QQuickStackViewPrivate::warn(const QString &error) +{ + Q_Q(QQuickStackView); + if (operation.isEmpty()) + qmlWarning(q) << error; + else + qmlWarning(q) << operation << ": " << error; +} + void QQuickStackViewPrivate::setCurrentItem(QQuickStackElement *element) { Q_Q(QQuickStackView); diff --git a/src/quicktemplates2/qquickstackview_p_p.h b/src/quicktemplates2/qquickstackview_p_p.h index ca610153..532a2b57 100644 --- a/src/quicktemplates2/qquickstackview_p_p.h +++ b/src/quicktemplates2/qquickstackview_p_p.h @@ -72,6 +72,8 @@ public: return view->d_func(); } + void warn(const QString &error); + void setCurrentItem(QQuickStackElement *element); QList<QQuickStackElement *> parseElements(QQmlV4Function *args, int from = 0); @@ -91,6 +93,7 @@ public: void setBusy(bool busy); bool busy; + QString operation; QVariant initialItem; QQuickItem *currentItem; QSet<QQuickStackElement*> removing; |