aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@gmail.com>2017-04-03 09:53:19 +0200
committerJ-P Nurmi <jpnurmi@gmail.com>2017-04-03 09:53:19 +0200
commit4bd9acec8876e1c36168010758d0fea645a25ba2 (patch)
treea79345df4902efdf7827cc6c4ac6aafefdfaa39b /src
parentc3cc73e3087db62a8427ff569abff1a8289dae83 (diff)
parentf720bc8e38dfdc14c48ffe3178a704f5d130f932 (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: src/imports/controls/ComboBox.qml src/imports/controls/material/ComboBox.qml src/imports/controls/universal/ComboBox.qml Change-Id: Ib900bb6298c32245399f52980b44575b64b7409f
Diffstat (limited to 'src')
-rw-r--r--src/imports/controls/ComboBox.qml1
-rw-r--r--src/imports/controls/Popup.qml2
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc4
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-index.qdoc42
-rw-r--r--src/imports/controls/material/ComboBox.qml1
-rw-r--r--src/imports/controls/material/Popup.qml2
-rw-r--r--src/imports/controls/universal/ComboBox.qml1
-rw-r--r--src/imports/controls/universal/Popup.qml2
-rw-r--r--src/imports/controls/universal/SwipeDelegate.qml1
-rw-r--r--src/quicktemplates2/qquickapplicationwindow.cpp14
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp4
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp8
-rw-r--r--src/quicktemplates2/qquickdial.cpp2
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox.cpp2
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp2
-rw-r--r--src/quicktemplates2/qquickstackelement.cpp25
-rw-r--r--src/quicktemplates2/qquickstackelement_p_p.h4
-rw-r--r--src/quicktemplates2/qquickstackview.cpp46
-rw-r--r--src/quicktemplates2/qquickstackview_p.cpp28
-rw-r--r--src/quicktemplates2/qquickstackview_p_p.h7
-rw-r--r--src/quicktemplates2/qquickswipedelegate.cpp2
-rw-r--r--src/quicktemplates2/qquickswipeview.cpp1
22 files changed, 152 insertions, 49 deletions
diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml
index b19b8e14..83492aef 100644
--- a/src/imports/controls/ComboBox.qml
+++ b/src/imports/controls/ComboBox.qml
@@ -35,7 +35,6 @@
****************************************************************************/
import QtQuick 2.9
-import QtQuick.Window 2.2
import QtQuick.Controls 2.3
import QtQuick.Controls.impl 2.3
import QtQuick.Templates 2.3 as T
diff --git a/src/imports/controls/Popup.qml b/src/imports/controls/Popup.qml
index e97aee52..7a94aaab 100644
--- a/src/imports/controls/Popup.qml
+++ b/src/imports/controls/Popup.qml
@@ -45,7 +45,7 @@ T.Popup {
implicitWidth: Math.max(background ? background.implicitWidth : 0,
contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- contentWidth > 0 ? contentHeight + topPadding + bottomPadding : 0)
+ contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0)
contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc
index 633fb217..c2b1e640 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc
@@ -200,9 +200,9 @@
style will illustrate the elevation with a drop shadow; the higher the
elevation, the larger the shadow.
- The first step is to \l {Creating Qt Quick Projects}{create a new Qt Quick
+ The first step is to \l {Qt Creator: Creating Qt Quick Projects}{create a new Qt Quick
Controls 2 application} in Qt Creator. After that, we
- \l {Creating C++ Classes}{add a C++ type} that stores the elevation. Since
+ \l {Qt Creator: Creating C++ Classes}{add a C++ type} that stores the elevation. Since
the type will be used for every control supported by our style, and because
we may wish to add other attached properties later on, we'll call it
MyStyle. Here is \c MyStyle.h:
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc
index 90d0c9d7..99b6c2ea 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc
@@ -60,6 +60,48 @@
For more details, see \l {Getting Started with Qt Quick Controls 2}.
+ \section1 Versions
+
+ Qt Quick Controls 2.0 was released in Qt 5.7. Subsequent minor Qt releases
+ increment the import version of the Qt Quick Controls 2 modules by one. The
+ experimental Qt Labs modules use import version 1.0.
+
+ \table
+ \header
+ \li \c Qt
+ \li \l {Qt Quick QML Types}{\c QtQuick}
+ \li \l {Qt Quick Controls 2 QML Types}{\c QtQuick.Controls},\br
+ \l {Qt Quick Templates 2 QML Types}{\c QtQuick.Templates},
+ \li \l {Material Style}{\c QtQuick.Controls.Material},\br
+ \l {Universal Style}{\c QtQuick.Controls.Universal}
+ \li \l {Qt Labs Calendar QML Types}{\c Qt.labs.calendar},\br
+ \l {Qt Labs Platform QML Types}{\c Qt.labs.platform}
+ \row
+ \li 5.7
+ \li 2.7
+ \li 2.0
+ \li 2.0
+ \li 1.0
+ \row
+ \li 5.8
+ \li 2.8
+ \li 2.1
+ \li 2.1
+ \li 1.0
+ \row
+ \li 5.9
+ \li 2.9
+ \li 2.2
+ \li 2.2
+ \li 1.0
+ \row
+ \li ...
+ \li ...
+ \li ...
+ \li ...
+ \li ...
+ \endtable
+
\section1 Important Concepts in Qt Quick Controls 2
\list
diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml
index e86d9f4c..2d2a479e 100644
--- a/src/imports/controls/material/ComboBox.qml
+++ b/src/imports/controls/material/ComboBox.qml
@@ -35,7 +35,6 @@
****************************************************************************/
import QtQuick 2.9
-import QtQuick.Window 2.2
import QtQuick.Controls 2.3
import QtQuick.Templates 2.3 as T
import QtQuick.Controls.Material 2.3
diff --git a/src/imports/controls/material/Popup.qml b/src/imports/controls/material/Popup.qml
index e270b77d..49b39a6c 100644
--- a/src/imports/controls/material/Popup.qml
+++ b/src/imports/controls/material/Popup.qml
@@ -47,7 +47,7 @@ T.Popup {
implicitWidth: Math.max(background ? background.implicitWidth : 0,
contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- contentWidth > 0 ? contentHeight + topPadding + bottomPadding : 0)
+ contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0)
contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml
index cf2a7e28..89391613 100644
--- a/src/imports/controls/universal/ComboBox.qml
+++ b/src/imports/controls/universal/ComboBox.qml
@@ -35,7 +35,6 @@
****************************************************************************/
import QtQuick 2.9
-import QtQuick.Window 2.2
import QtQuick.Controls 2.3
import QtQuick.Templates 2.3 as T
import QtQuick.Controls.Universal 2.3
diff --git a/src/imports/controls/universal/Popup.qml b/src/imports/controls/universal/Popup.qml
index 8c0b8d8f..f844d8e1 100644
--- a/src/imports/controls/universal/Popup.qml
+++ b/src/imports/controls/universal/Popup.qml
@@ -44,7 +44,7 @@ T.Popup {
implicitWidth: Math.max(background ? background.implicitWidth : 0,
contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- contentWidth > 0 ? contentHeight + topPadding + bottomPadding : 0)
+ contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0)
contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
diff --git a/src/imports/controls/universal/SwipeDelegate.qml b/src/imports/controls/universal/SwipeDelegate.qml
index c737df35..60430d74 100644
--- a/src/imports/controls/universal/SwipeDelegate.qml
+++ b/src/imports/controls/universal/SwipeDelegate.qml
@@ -66,7 +66,6 @@ T.SwipeDelegate {
visible: control.text
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
- renderType: Text.NativeRendering
opacity: enabled ? 1.0 : 0.2
color: control.Universal.foreground
diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp
index d49c9b0e..9b220a2b 100644
--- a/src/quicktemplates2/qquickapplicationwindow.cpp
+++ b/src/quicktemplates2/qquickapplicationwindow.cpp
@@ -638,6 +638,20 @@ void QQuickApplicationWindow::resetFont()
}
+/*!
+ \qmlproperty Locale QtQuick.Controls::ApplicationWindow::locale
+
+ This property holds the locale of the window.
+
+ The default locale depends on the system environment. You can set the
+ default locale by calling QLocale::setDefault(), before loading any QML.
+
+ ApplicationWindow propagates the locale to child controls. If you change
+ the window's locale, that locale propagates to all child controls in the
+ window, overriding the system default locale.
+
+ \sa Control::locale, {LayoutMirroring}{LayoutMirroring}
+*/
QLocale QQuickApplicationWindow::locale() const
{
Q_D(const QQuickApplicationWindow);
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index 29fa5e55..786db55b 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -633,9 +633,7 @@ QQuickComboBox::QQuickComboBox(QQuickItem *parent)
QQuickComboBox::~QQuickComboBox()
{
- Q_D(QQuickComboBox);
- delete d->popup;
- d->popup = nullptr;
+ setPopup(nullptr);
}
/*!
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index c707aede..4adf80e0 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -802,14 +802,14 @@ void QQuickControl::resetSpacing()
\qmlproperty Locale QtQuick.Controls::Control::locale
This property holds the locale of the control.
+
It contains locale specific properties for formatting data and numbers.
Unless a special locale has been set, this is either the parent's locale
or the default locale.
- Control propagates explicit locale properties from parent to children.
- If you change a specific property on a control's locale, that property
- propagates to all of the control's children, overriding any system defaults
- for that property.
+ Control propagates the locale from parent to children. If you change the
+ control's locale, that locale propagates to all of the control's children,
+ overriding the system default locale.
\sa mirrored, {LayoutMirroring}{LayoutMirroring}
*/
diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp
index 198bd631..24a8df01 100644
--- a/src/quicktemplates2/qquickdial.cpp
+++ b/src/quicktemplates2/qquickdial.cpp
@@ -521,7 +521,7 @@ void QQuickDial::setPressed(bool pressed)
The default value is \c true.
- \sa value, valueAt()
+ \sa value
*/
bool QQuickDial::live() const
{
diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp
index a912ba6a..f1971635 100644
--- a/src/quicktemplates2/qquickdialogbuttonbox.cpp
+++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp
@@ -312,7 +312,7 @@ QQuickAbstractButton *QQuickDialogButtonBoxPrivate::createStandardButton(QPlatfo
QQmlContext *creationContext = delegate->creationContext();
if (!creationContext)
creationContext = qmlContext(q);
- QQmlContext *context = new QQmlContext(creationContext);
+ QQmlContext *context = new QQmlContext(creationContext, q);
context->setContextObject(q);
QObject *object = delegate->beginCreate(context);
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index e3910509..c72979ae 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -80,7 +80,7 @@ static QQuickItem *createDimmer(QQmlComponent *component, QQuickPopup *popup, QQ
QQmlContext *creationContext = component->creationContext();
if (!creationContext)
creationContext = qmlContext(parent);
- QQmlContext *context = new QQmlContext(creationContext);
+ QQmlContext *context = new QQmlContext(creationContext, parent);
context->setContextObject(popup);
item = qobject_cast<QQuickItem*>(component->beginCreate(context));
}
diff --git a/src/quicktemplates2/qquickstackelement.cpp b/src/quicktemplates2/qquickstackelement.cpp
index 2744c3e9..a3bb840e 100644
--- a/src/quicktemplates2/qquickstackelement.cpp
+++ b/src/quicktemplates2/qquickstackelement.cpp
@@ -122,17 +122,30 @@ QQuickStackElement::~QQuickStackElement()
delete context;
}
-QQuickStackElement *QQuickStackElement::fromString(const QString &str, QQuickStackView *view)
+QQuickStackElement *QQuickStackElement::fromString(const QString &str, QQuickStackView *view, QString *error)
{
+ QUrl url(str);
+ if (!url.isValid()) {
+ *error = QStringLiteral("invalid url: ") + str;
+ return nullptr;
+ }
+
QQuickStackElement *element = new QQuickStackElement;
- element->component = new QQmlComponent(qmlEngine(view), QUrl(str), view);
+ element->component = new QQmlComponent(qmlEngine(view), url, view);
element->ownComponent = true;
return element;
}
-QQuickStackElement *QQuickStackElement::fromObject(QObject *object, QQuickStackView *view)
+QQuickStackElement *QQuickStackElement::fromObject(QObject *object, QQuickStackView *view, QString *error)
{
Q_UNUSED(view);
+ QQmlComponent *component = qobject_cast<QQmlComponent *>(object);
+ QQuickItem *item = qobject_cast<QQuickItem *>(object);
+ if (!component && !item) {
+ *error = QQmlMetaType::prettyTypeName(object) + QStringLiteral(" is not supported. Must be Item or Component.");
+ return nullptr;
+ }
+
QQuickStackElement *element = new QQuickStackElement;
element->component = qobject_cast<QQmlComponent *>(object);
element->item = qobject_cast<QQuickItem *>(object);
@@ -152,7 +165,7 @@ bool QQuickStackElement::load(QQuickStackView *parent)
if (status == QQmlComponent::Ready)
load(view);
else if (status == QQmlComponent::Error)
- qWarning() << qPrintable(component->errorString().trimmed());
+ QQuickStackViewPrivate::get(view)->warn(component->errorString().trimmed());
});
return true;
}
@@ -160,13 +173,13 @@ bool QQuickStackElement::load(QQuickStackView *parent)
QQmlContext *creationContext = component->creationContext();
if (!creationContext)
creationContext = qmlContext(parent);
- context = new QQmlContext(creationContext);
+ context = new QQmlContext(creationContext, parent);
context->setContextObject(parent);
QQuickStackIncubator incubator(this);
component->create(incubator, context);
if (component->isError())
- qWarning() << qPrintable(component->errorString().trimmed());
+ QQuickStackViewPrivate::get(parent)->warn(component->errorString().trimmed());
} else {
initialize();
}
diff --git a/src/quicktemplates2/qquickstackelement_p_p.h b/src/quicktemplates2/qquickstackelement_p_p.h
index 9cb11855..2308f47d 100644
--- a/src/quicktemplates2/qquickstackelement_p_p.h
+++ b/src/quicktemplates2/qquickstackelement_p_p.h
@@ -67,8 +67,8 @@ class QQuickStackElement : public QQuickItemViewTransitionableItem, public QQuic
public:
~QQuickStackElement();
- static QQuickStackElement *fromString(const QString &str, QQuickStackView *view);
- static QQuickStackElement *fromObject(QObject *object, QQuickStackView *view);
+ static QQuickStackElement *fromString(const QString &str, QQuickStackView *view, QString *error);
+ static QQuickStackElement *fromObject(QObject *object, QQuickStackView *view, QString *error);
bool load(QQuickStackView *parent);
void incubate(QObject *object);
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp
index a9922704..155f5f4d 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;
}
@@ -488,7 +490,8 @@ void QQuickStackView::push(QQmlV4Function *args)
if (lastArg->isInt32())
operation = static_cast<Operation>(lastArg->toInt32());
- QList<QQuickStackElement *> elements = d->parseElements(args);
+ QStringList errors;
+ QList<QQuickStackElement *> elements = d->parseElements(0, args, &errors);
// Remove any items that are already in the stack, as they can't be in two places at once.
for (int i = 0; i < elements.size(); ) {
QQuickStackElement *element = elements.at(i);
@@ -498,8 +501,13 @@ void QQuickStackView::push(QQmlV4Function *args)
++i;
}
- if (elements.isEmpty()) {
- qmlWarning(this) << "push: nothing to push";
+ if (!errors.isEmpty() || elements.isEmpty()) {
+ if (!errors.isEmpty()) {
+ for (const QString &error : qAsConst(errors))
+ d->warn(error);
+ } else {
+ d->warn(QStringLiteral("nothing to push"));
+ }
args->setReturnValue(QV4::Encode::null());
return;
}
@@ -557,10 +565,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 +589,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 +717,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;
}
@@ -729,9 +739,15 @@ void QQuickStackView::replace(QQmlV4Function *args)
else if (!firstArg->isInt32())
target = d->findElement(firstArg);
- QList<QQuickStackElement *> elements = d->parseElements(args, target ? 1 : 0);
- if (elements.isEmpty()) {
- qmlWarning(this) << "replace: nothing to push";
+ QStringList errors;
+ QList<QQuickStackElement *> elements = d->parseElements(target ? 1 : 0, args, &errors);
+ if (!errors.isEmpty() || elements.isEmpty()) {
+ if (!errors.isEmpty()) {
+ for (const QString &error : qAsConst(errors))
+ d->warn(error);
+ } else {
+ d->warn(QStringLiteral("nothing to push"));
+ }
args->setReturnValue(QV4::Encode::null());
return;
}
@@ -968,12 +984,16 @@ void QQuickStackView::componentComplete()
QQuickControl::componentComplete();
Q_D(QQuickStackView);
+ QScopedValueRollback<QString> rollback(d->operation, QStringLiteral("initialItem"));
QQuickStackElement *element = nullptr;
+ QString error;
if (QObject *o = d->initialItem.value<QObject *>())
- element = QQuickStackElement::fromObject(o, this);
+ element = QQuickStackElement::fromObject(o, this, &error);
else if (d->initialItem.canConvert<QString>())
- element = QQuickStackElement::fromString(d->initialItem.toString(), this);
- if (d->pushElement(element)) {
+ element = QQuickStackElement::fromString(d->initialItem.toString(), this, &error);
+ if (!error.isEmpty()) {
+ d->warn(error);
+ } else if (d->pushElement(element)) {
emit depthChanged();
d->setCurrentItem(element);
element->setStatus(QQuickStackView::Active);
diff --git a/src/quicktemplates2/qquickstackview_p.cpp b/src/quicktemplates2/qquickstackview_p.cpp
index 89b3c6e3..c6f9291d 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);
@@ -80,7 +90,7 @@ static bool initProperties(QQuickStackElement *element, const QV4::Value &props,
return false;
}
-QList<QQuickStackElement *> QQuickStackViewPrivate::parseElements(QQmlV4Function *args, int from)
+QList<QQuickStackElement *> QQuickStackViewPrivate::parseElements(int from, QQmlV4Function *args, QStringList *errors)
{
QV4::ExecutionEngine *v4 = args->v4engine();
QV4::Scope scope(v4);
@@ -93,8 +103,9 @@ QList<QQuickStackElement *> QQuickStackViewPrivate::parseElements(QQmlV4Function
if (QV4::ArrayObject *array = arg->as<QV4::ArrayObject>()) {
int len = array->getLength();
for (int j = 0; j < len; ++j) {
+ QString error;
QV4::ScopedValue value(scope, array->getIndexed(j));
- QQuickStackElement *element = createElement(value);
+ QQuickStackElement *element = createElement(value, &error);
if (element) {
if (j < len - 1) {
QV4::ScopedValue props(scope, array->getIndexed(j + 1));
@@ -102,10 +113,13 @@ QList<QQuickStackElement *> QQuickStackViewPrivate::parseElements(QQmlV4Function
++j;
}
elements += element;
+ } else if (!error.isEmpty()) {
+ *errors += error;
}
}
} else {
- QQuickStackElement *element = createElement(arg);
+ QString error;
+ QQuickStackElement *element = createElement(arg, &error);
if (element) {
if (i < argc - 1) {
QV4::ScopedValue props(scope, (*args)[i + 1]);
@@ -113,6 +127,8 @@ QList<QQuickStackElement *> QQuickStackViewPrivate::parseElements(QQmlV4Function
++i;
}
elements += element;
+ } else if (!error.isEmpty()) {
+ *errors += error;
}
}
}
@@ -137,13 +153,13 @@ QQuickStackElement *QQuickStackViewPrivate::findElement(const QV4::Value &value)
return nullptr;
}
-QQuickStackElement *QQuickStackViewPrivate::createElement(const QV4::Value &value)
+QQuickStackElement *QQuickStackViewPrivate::createElement(const QV4::Value &value, QString *error)
{
Q_Q(QQuickStackView);
if (const QV4::String *s = value.as<QV4::String>())
- return QQuickStackElement::fromString(s->toQString(), q);
+ return QQuickStackElement::fromString(s->toQString(), q, error);
if (const QV4::QObjectWrapper *o = value.as<QV4::QObjectWrapper>())
- return QQuickStackElement::fromObject(o->object(), q);
+ return QQuickStackElement::fromObject(o->object(), q, error);
return nullptr;
}
diff --git a/src/quicktemplates2/qquickstackview_p_p.h b/src/quicktemplates2/qquickstackview_p_p.h
index ca610153..26d741f8 100644
--- a/src/quicktemplates2/qquickstackview_p_p.h
+++ b/src/quicktemplates2/qquickstackview_p_p.h
@@ -72,12 +72,14 @@ public:
return view->d_func();
}
+ void warn(const QString &error);
+
void setCurrentItem(QQuickStackElement *element);
- QList<QQuickStackElement *> parseElements(QQmlV4Function *args, int from = 0);
+ QList<QQuickStackElement *> parseElements(int from, QQmlV4Function *args, QStringList *errors);
QQuickStackElement *findElement(QQuickItem *item) const;
QQuickStackElement *findElement(const QV4::Value &value) const;
- QQuickStackElement *createElement(const QV4::Value &value);
+ QQuickStackElement *createElement(const QV4::Value &value, QString *error);
bool pushElements(const QList<QQuickStackElement *> &elements);
bool pushElement(QQuickStackElement *element);
bool popElements(QQuickStackElement *element);
@@ -91,6 +93,7 @@ public:
void setBusy(bool busy);
bool busy;
+ QString operation;
QVariant initialItem;
QQuickItem *currentItem;
QSet<QQuickStackElement*> removing;
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp
index 7824708a..97a784b6 100644
--- a/src/quicktemplates2/qquickswipedelegate.cpp
+++ b/src/quicktemplates2/qquickswipedelegate.cpp
@@ -237,7 +237,7 @@ QQuickItem *QQuickSwipePrivate::createDelegateItem(QQmlComponent *component)
// the creation context will be null and we have to create it ourselves.
if (!creationContext)
creationContext = qmlContext(control);
- QQmlContext *context = new QQmlContext(creationContext);
+ QQmlContext *context = new QQmlContext(creationContext, control);
context->setContextObject(control);
QQuickItem *item = qobject_cast<QQuickItem*>(component->beginCreate(context));
if (item) {
diff --git a/src/quicktemplates2/qquickswipeview.cpp b/src/quicktemplates2/qquickswipeview.cpp
index 631869ef..d278beb7 100644
--- a/src/quicktemplates2/qquickswipeview.cpp
+++ b/src/quicktemplates2/qquickswipeview.cpp
@@ -182,6 +182,7 @@ void QQuickSwipeView::setInteractive(bool interactive)
}
/*!
+ \since QtQuick.Controls 2.2
\qmlproperty enumeration QtQuick.Controls::SwipeView::orientation
This property holds the orientation.