diff options
Diffstat (limited to 'src/imports')
44 files changed, 2977 insertions, 1140 deletions
diff --git a/src/imports/builtins/builtins.qmltypes b/src/imports/builtins/builtins.qmltypes index c783c63caf..765c92fcb9 100644 --- a/src/imports/builtins/builtins.qmltypes +++ b/src/imports/builtins/builtins.qmltypes @@ -1685,6 +1685,17 @@ Module { "ChecksumItuV41": 1 } } + Enum { + name: "HighDpiScaleFactorRoundingPolicy" + values: { + "Unset": 0, + "Round": 1, + "Ceil": 2, + "Floor": 3, + "RoundPreferFloor": 4, + "PassThrough": 5 + } + } } Component { name: "QEasingCurve"; prototype: "QQmlEasingValueType" } } diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp index 40968d5e1d..cbe4f9353d 100644 --- a/src/imports/folderlistmodel/plugin.cpp +++ b/src/imports/folderlistmodel/plugin.cpp @@ -55,18 +55,13 @@ public: void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.folderlistmodel")); - qmlRegisterType<QQuickFolderListModel>(uri,1,0,"FolderListModel"); - qmlRegisterType<QQuickFolderListModel>(uri,2,0,"FolderListModel"); - qmlRegisterType<QQuickFolderListModel,1>(uri,2,1,"FolderListModel"); - qmlRegisterType<QQuickFolderListModel,2>(uri,2,2,"FolderListModel"); - qmlRegisterModule(uri, 2, 15); + // Major version 1 only has a single revision, 0. + qmlRegisterType<QQuickFolderListModel>(uri, 1, 0, "FolderListModel"); - // revision in Qt 5.11: added status property - qmlRegisterType<QQuickFolderListModel,11>(uri, 2, 11, "FolderListModel"); + qmlRegisterTypesAndRevisions<QQuickFolderListModel>(uri, 2); - // revision in Qt 5.12: added sortCaseSensitive property - qmlRegisterType<QQuickFolderListModel,12>(uri, 2, 12, "FolderListModel"); + qmlRegisterModule(uri, 2, 15); } }; //![class decl] diff --git a/src/imports/folderlistmodel/plugins.qmltypes b/src/imports/folderlistmodel/plugins.qmltypes index 0fdbae66d3..7c53c99665 100644 --- a/src/imports/folderlistmodel/plugins.qmltypes +++ b/src/imports/folderlistmodel/plugins.qmltypes @@ -9,6 +9,280 @@ import QtQuick.tooling 1.2 Module { dependencies: ["QtQuick 2.0"] Component { + name: "QAbstractItemModel" + prototype: "QObject" + Enum { + name: "LayoutChangeHint" + values: { + "NoLayoutChangeHint": 0, + "VerticalSortHint": 1, + "HorizontalSortHint": 2 + } + } + Enum { + name: "CheckIndexOption" + values: { + "NoOption": 0, + "IndexIsValid": 1, + "DoNotUseParent": 2, + "ParentIsInvalid": 4 + } + } + Signal { + name: "dataChanged" + Parameter { name: "topLeft"; type: "QModelIndex" } + Parameter { name: "bottomRight"; type: "QModelIndex" } + Parameter { name: "roles"; type: "QVector<int>" } + } + Signal { + name: "dataChanged" + Parameter { name: "topLeft"; type: "QModelIndex" } + Parameter { name: "bottomRight"; type: "QModelIndex" } + } + Signal { + name: "headerDataChanged" + Parameter { name: "orientation"; type: "Qt::Orientation" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "layoutChanged" + Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" } + Parameter { name: "hint"; type: "QAbstractItemModel::LayoutChangeHint" } + } + Signal { + name: "layoutChanged" + Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" } + } + Signal { name: "layoutChanged" } + Signal { + name: "layoutAboutToBeChanged" + Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" } + Parameter { name: "hint"; type: "QAbstractItemModel::LayoutChangeHint" } + } + Signal { + name: "layoutAboutToBeChanged" + Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" } + } + Signal { name: "layoutAboutToBeChanged" } + Signal { + name: "rowsAboutToBeInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "rowsInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "rowsAboutToBeRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "rowsRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsAboutToBeInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsAboutToBeRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { name: "modelAboutToBeReset" } + Signal { name: "modelReset" } + Signal { + name: "rowsAboutToBeMoved" + Parameter { name: "sourceParent"; type: "QModelIndex" } + Parameter { name: "sourceStart"; type: "int" } + Parameter { name: "sourceEnd"; type: "int" } + Parameter { name: "destinationParent"; type: "QModelIndex" } + Parameter { name: "destinationRow"; type: "int" } + } + Signal { + name: "rowsMoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "start"; type: "int" } + Parameter { name: "end"; type: "int" } + Parameter { name: "destination"; type: "QModelIndex" } + Parameter { name: "row"; type: "int" } + } + Signal { + name: "columnsAboutToBeMoved" + Parameter { name: "sourceParent"; type: "QModelIndex" } + Parameter { name: "sourceStart"; type: "int" } + Parameter { name: "sourceEnd"; type: "int" } + Parameter { name: "destinationParent"; type: "QModelIndex" } + Parameter { name: "destinationColumn"; type: "int" } + } + Signal { + name: "columnsMoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "start"; type: "int" } + Parameter { name: "end"; type: "int" } + Parameter { name: "destination"; type: "QModelIndex" } + Parameter { name: "column"; type: "int" } + } + Method { name: "submit"; type: "bool" } + Method { name: "revert" } + Method { + name: "hasIndex" + type: "bool" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "hasIndex" + type: "bool" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + } + Method { + name: "index" + type: "QModelIndex" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "index" + type: "QModelIndex" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + } + Method { + name: "parent" + type: "QModelIndex" + Parameter { name: "child"; type: "QModelIndex" } + } + Method { + name: "sibling" + type: "QModelIndex" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + Parameter { name: "idx"; type: "QModelIndex" } + } + Method { + name: "rowCount" + type: "int" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { name: "rowCount"; type: "int" } + Method { + name: "columnCount" + type: "int" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { name: "columnCount"; type: "int" } + Method { + name: "hasChildren" + type: "bool" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { name: "hasChildren"; type: "bool" } + Method { + name: "data" + type: "QVariant" + Parameter { name: "index"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + } + Method { + name: "data" + type: "QVariant" + Parameter { name: "index"; type: "QModelIndex" } + } + Method { + name: "setData" + type: "bool" + Parameter { name: "index"; type: "QModelIndex" } + Parameter { name: "value"; type: "QVariant" } + Parameter { name: "role"; type: "int" } + } + Method { + name: "setData" + type: "bool" + Parameter { name: "index"; type: "QModelIndex" } + Parameter { name: "value"; type: "QVariant" } + } + Method { + name: "headerData" + type: "QVariant" + Parameter { name: "section"; type: "int" } + Parameter { name: "orientation"; type: "Qt::Orientation" } + Parameter { name: "role"; type: "int" } + } + Method { + name: "headerData" + type: "QVariant" + Parameter { name: "section"; type: "int" } + Parameter { name: "orientation"; type: "Qt::Orientation" } + } + Method { + name: "fetchMore" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "canFetchMore" + type: "bool" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "flags" + type: "Qt::ItemFlags" + Parameter { name: "index"; type: "QModelIndex" } + } + Method { + name: "match" + type: "QModelIndexList" + Parameter { name: "start"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + Parameter { name: "value"; type: "QVariant" } + Parameter { name: "hits"; type: "int" } + Parameter { name: "flags"; type: "Qt::MatchFlags" } + } + Method { + name: "match" + type: "QModelIndexList" + Parameter { name: "start"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + Parameter { name: "value"; type: "QVariant" } + Parameter { name: "hits"; type: "int" } + } + Method { + name: "match" + type: "QModelIndexList" + Parameter { name: "start"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + Parameter { name: "value"; type: "QVariant" } + } + } + Component { name: "QAbstractListModel"; prototype: "QAbstractItemModel" } + Component { name: "QQuickFolderListModel" prototype: "QAbstractListModel" exports: [ diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index affb1e9fe2..f5acfd86b7 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -539,6 +539,8 @@ QStringList QQuickFolderListModel::nameFilters() const void QQuickFolderListModel::setNameFilters(const QStringList &filters) { Q_D(QQuickFolderListModel); + if (d->nameFilters == filters) + return; d->fileInfoThread.setNameFilters(filters); d->nameFilters = filters; } @@ -731,6 +733,7 @@ void QQuickFolderListModel::setShowDotAndDotDot(bool on) if (on != d->showDotAndDotDot) { d->fileInfoThread.setShowDotAndDotDot(on); + d->showDotAndDotDot = on; } } @@ -756,6 +759,7 @@ void QQuickFolderListModel::setShowHidden(bool on) if (on != d->showHidden) { d->fileInfoThread.setShowHidden(on); + d->showHidden = on; } } @@ -781,6 +785,7 @@ void QQuickFolderListModel::setShowOnlyReadable(bool on) if (on != d->showOnlyReadable) { d->fileInfoThread.setShowOnlyReadable(on); + d->showOnlyReadable = on; } } @@ -805,6 +810,7 @@ void QQuickFolderListModel::setCaseSensitive(bool on) if (on != d->caseSensitive) { d->fileInfoThread.setCaseSensitive(on); + d->caseSensitive = on; } } @@ -852,7 +858,7 @@ QQuickFolderListModel::Status QQuickFolderListModel::status() const \qmlproperty bool FolderListModel::sortCaseSensitive \since 5.12 - If set to true, the sort is case sensitive. This property is true by default. + If set to \c true, the sort is case sensitive. This property is \c true by default. */ bool QQuickFolderListModel::sortCaseSensitive() const @@ -874,8 +880,8 @@ void QQuickFolderListModel::setSortCaseSensitive(bool on) /*! \qmlmethod var FolderListModel::get(int index, string property) - Get the folder property for the given index. The following properties - are available. + Returns the folder \a property for the given \a index. The following properties + are available: \list \li \c fileName @@ -902,7 +908,7 @@ QVariant QQuickFolderListModel::get(int idx, const QString &property) const \qmlmethod int FolderListModel::indexOf(url file) \since 5.6 - Get the index of the given file URL if the model contains it, + Returns the index of the given \a file URL if the model contains it, or -1 if not. */ int QQuickFolderListModel::indexOf(const QUrl &file) const diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.h b/src/imports/folderlistmodel/qquickfolderlistmodel.h index d93e7daf3f..5897bd2e0f 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.h +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.h @@ -79,6 +79,7 @@ class QQuickFolderListModel : public QAbstractListModel, public QQmlParserStatus Q_PROPERTY(bool sortCaseSensitive READ sortCaseSensitive WRITE setSortCaseSensitive REVISION 12) //![class props] + QML_NAMED_ELEMENT(FolderListModel) //![abslistmodel] public: QQuickFolderListModel(QObject *parent = nullptr); diff --git a/src/imports/imports.pro b/src/imports/imports.pro index a87b0a59f6..9973883024 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -28,6 +28,6 @@ qtHaveModule(quick) { qtConfig(quick-particles): \ SUBDIRS += particles - qtConfig(quick-path):qtConfig(thread): SUBDIRS += shapes + qtConfig(quick-path): SUBDIRS += shapes } diff --git a/src/imports/labsanimation/labsanimation.pro b/src/imports/labsanimation/labsanimation.pro index 64e076401f..128bc28ddb 100644 --- a/src/imports/labsanimation/labsanimation.pro +++ b/src/imports/labsanimation/labsanimation.pro @@ -4,8 +4,12 @@ TARGETPATH = Qt/labs/animation IMPORT_VERSION = 1.0 SOURCES += \ + qquickboundaryrule.cpp \ plugin.cpp +HEADERS += \ + qquickboundaryrule_p.h + QT = qml-private quick-private load(qml_plugin) diff --git a/src/imports/labsanimation/plugin.cpp b/src/imports/labsanimation/plugin.cpp index d8c0c071ca..a74a30663a 100644 --- a/src/imports/labsanimation/plugin.cpp +++ b/src/imports/labsanimation/plugin.cpp @@ -40,7 +40,7 @@ #include <QtQml/qqmlextensionplugin.h> #include <QtQml/qqml.h> -#include <private/qquickboundaryrule_p.h> +#include "qquickboundaryrule_p.h" QT_BEGIN_NAMESPACE @@ -70,7 +70,7 @@ public: void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.animation")); - qmlRegisterType<QQuickBoundaryRule>(uri, 1, 0, "BoundaryRule"); + qmlRegisterTypesAndRevisions<QQuickBoundaryRule>(uri, 1); qmlRegisterModule(uri, 1, 0); } }; diff --git a/src/imports/labsanimation/plugins.qmltypes b/src/imports/labsanimation/plugins.qmltypes index 065e65ad7a..2ecc5e6f5d 100644 --- a/src/imports/labsanimation/plugins.qmltypes +++ b/src/imports/labsanimation/plugins.qmltypes @@ -4,10 +4,10 @@ import QtQuick.tooling 1.2 // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -nonrelocatable Qt.labs.animation 1.0' +// 'qmlplugindump -nonrelocatable -dependencies dependencies.json Qt.labs.animation 1.0' Module { - dependencies: ["QtQuick 2.0"] + dependencies: [] Component { name: "QQuickBoundaryRule" prototype: "QObject" diff --git a/src/imports/labsanimation/qquickboundaryrule.cpp b/src/imports/labsanimation/qquickboundaryrule.cpp new file mode 100644 index 0000000000..3558c8bfa0 --- /dev/null +++ b/src/imports/labsanimation/qquickboundaryrule.cpp @@ -0,0 +1,574 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qquickboundaryrule_p.h" + +#include <qqmlcontext.h> +#include <qqmlinfo.h> +#include <private/qqmlproperty_p.h> +#include <private/qqmlengine_p.h> +#include <private/qobject_p.h> +#include <private/qquickanimation_p_p.h> +#include <QtCore/qloggingcategory.h> + +QT_BEGIN_NAMESPACE + +Q_LOGGING_CATEGORY(lcBR, "qt.quick.boundaryrule") + +class QQuickBoundaryReturnJob; +class QQuickBoundaryRulePrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QQuickBoundaryRule) +public: + QQuickBoundaryRulePrivate() {} + + QQmlProperty property; + QEasingCurve easing = QEasingCurve(QEasingCurve::OutQuad); + QQuickBoundaryReturnJob *returnAnimationJob = nullptr; + // read-only properties, updated on each write() + qreal targetValue = 0; // after easing was applied + qreal peakOvershoot = 0; + qreal currentOvershoot = 0; + // settable properties + qreal minimum = 0; + qreal maximum = 0; + qreal minimumOvershoot = 0; + qreal maximumOvershoot = 0; + qreal overshootScale = 0.5; + int returnDuration = 100; + QQuickBoundaryRule::OvershootFilter overshootFilter = QQuickBoundaryRule::OvershootFilter::None; + bool enabled = true; + bool finalized = false; + + qreal easedOvershoot(qreal overshootingValue); + void resetOvershoot(); +}; + +class QQuickBoundaryReturnJob : public QAbstractAnimationJob +{ +public: + QQuickBoundaryReturnJob(QQuickBoundaryRulePrivate *br, qreal to) + : QAbstractAnimationJob() + , boundaryRule(br) + , fromValue(br->targetValue) + , toValue(to) {} + + int duration() const override { return boundaryRule->returnDuration; } + + void updateCurrentTime(int) override; + + void updateState(QAbstractAnimationJob::State newState, + QAbstractAnimationJob::State oldState) override; + + QQuickBoundaryRulePrivate *boundaryRule; + qreal fromValue; // snapshot of initial value from which we're returning + qreal toValue; // target property value to which we're returning +}; + +void QQuickBoundaryReturnJob::updateCurrentTime(int t) +{ + // The easing property tells how to behave when the property is being + // externally manipulated beyond the bounds. During returnToBounds() + // we run it in reverse, by reversing time. + qreal progress = (duration() - t) / qreal(duration()); + qreal easingValue = boundaryRule->easing.valueForProgress(progress); + qreal delta = qAbs(fromValue - toValue) * easingValue; + qreal value = (fromValue > toValue ? toValue + delta : toValue - delta); + qCDebug(lcBR) << t << "ms" << qRound(progress * 100) << "% easing" << easingValue << "->" << value; + QQmlPropertyPrivate::write(boundaryRule->property, value, + QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding); +} + +void QQuickBoundaryReturnJob::updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) +{ + Q_UNUSED(oldState) + if (newState == QAbstractAnimationJob::Stopped) { + qCDebug(lcBR) << "return animation done"; + boundaryRule->resetOvershoot(); + boundaryRule->returnAnimationJob = nullptr; + delete this; + } +} + +/*! + \qmltype BoundaryRule + \instantiates QQuickBoundaryRule + \inqmlmodule Qt.labs.animation + \ingroup qtquick-transitions-animations + \ingroup qtquick-interceptors + \brief Defines a restriction on the range of values that can be set on a numeric property. + \since 5.14 + + A BoundaryRule defines the range of values that a particular property is + allowed to have. When an out-of-range value would otherwise be set, + it applies "resistance" via an easing curve. + + For example, the following BoundaryRule prevents DragHandler from dragging + the Rectangle too far: + + \snippet qml/boundaryRule.qml 0 + + Note that a property cannot have more than one assigned BoundaryRule. + + \sa {Animation and Transitions in Qt Quick}, {Qt Quick Examples - Animation#Behaviors}{Behavior example}, {Qt QML} +*/ + +QQuickBoundaryRule::QQuickBoundaryRule(QObject *parent) + : QObject(*(new QQuickBoundaryRulePrivate), parent) + , QQmlPropertyValueInterceptor() +{ +} + +QQuickBoundaryRule::~QQuickBoundaryRule() +{ + Q_D(QQuickBoundaryRule); + // stop any running animation and + // prevent QQuickBoundaryReturnJob::updateState() from accessing QQuickBoundaryRulePrivate + delete d->returnAnimationJob; +} + +/*! + \qmlproperty bool QtQuick::BoundaryRule::enabled + + This property holds whether the rule will be enforced when the tracked + property changes value. + + By default a BoundaryRule is enabled. +*/ +bool QQuickBoundaryRule::enabled() const +{ + Q_D(const QQuickBoundaryRule); + return d->enabled; +} + +void QQuickBoundaryRule::setEnabled(bool enabled) +{ + Q_D(QQuickBoundaryRule); + if (d->enabled == enabled) + return; + d->enabled = enabled; + emit enabledChanged(); +} + +/*! + \qmlproperty qreal QtQuick::BoundaryRule::minimum + + This property holds the smallest unconstrained value that the property is + allowed to have. If the property is set to a smaller value, it will be + constrained by \l easing and \l minimumOvershoot. + + The default is \c 0. +*/ +qreal QQuickBoundaryRule::minimum() const +{ + Q_D(const QQuickBoundaryRule); + return d->minimum; +} + +void QQuickBoundaryRule::setMinimum(qreal minimum) +{ + Q_D(QQuickBoundaryRule); + if (qFuzzyCompare(d->minimum, minimum)) + return; + d->minimum = minimum; + emit minimumChanged(); +} + +/*! + \qmlproperty qreal QtQuick::BoundaryRule::minimumOvershoot + + This property holds the amount that the property is allowed to be + less than \l minimum. Whenever the value is less than \l minimum + and greater than \c {minimum - minimumOvershoot}, it is constrained + by the \l easing curve. When the value attempts to go under + \c {minimum - minimumOvershoots} there is a hard stop. + + The default is \c 0. +*/ +qreal QQuickBoundaryRule::minimumOvershoot() const +{ + Q_D(const QQuickBoundaryRule); + return d->minimumOvershoot; +} + +void QQuickBoundaryRule::setMinimumOvershoot(qreal minimumOvershoot) +{ + Q_D(QQuickBoundaryRule); + if (qFuzzyCompare(d->minimumOvershoot, minimumOvershoot)) + return; + d->minimumOvershoot = minimumOvershoot; + emit minimumOvershootChanged(); +} + +/*! + \qmlproperty qreal QtQuick::BoundaryRule::maximum + + This property holds the largest unconstrained value that the property is + allowed to have. If the property is set to a larger value, it will be + constrained by \l easing and \l maximumOvershoot. + + The default is \c 1. +*/ +qreal QQuickBoundaryRule::maximum() const +{ + Q_D(const QQuickBoundaryRule); + return d->maximum; +} + +void QQuickBoundaryRule::setMaximum(qreal maximum) +{ + Q_D(QQuickBoundaryRule); + if (qFuzzyCompare(d->maximum, maximum)) + return; + d->maximum = maximum; + emit maximumChanged(); +} + +/*! + \qmlproperty qreal QtQuick::BoundaryRule::maximumOvershoot + + This property holds the amount that the property is allowed to be + more than \l maximum. Whenever the value is greater than \l maximum + and less than \c {maximum + maximumOvershoot}, it is constrained + by the \l easing curve. When the value attempts to exceed + \c {maximum + maximumOvershoot} there is a hard stop. + + The default is 0. +*/ +qreal QQuickBoundaryRule::maximumOvershoot() const +{ + Q_D(const QQuickBoundaryRule); + return d->maximumOvershoot; +} + +void QQuickBoundaryRule::setMaximumOvershoot(qreal maximumOvershoot) +{ + Q_D(QQuickBoundaryRule); + if (qFuzzyCompare(d->maximumOvershoot, maximumOvershoot)) + return; + d->maximumOvershoot = maximumOvershoot; + emit maximumOvershootChanged(); +} + +/*! + \qmlproperty qreal QtQuick::BoundaryRule::overshootScale + + This property holds the amount by which the \l easing is scaled during the + overshoot condition. For example if an Item is restricted from moving more + than 100 pixels beyond some limit, and the user (by means of some Input + Handler) is trying to drag it 100 pixels past the limit, if overshootScale + is set to 1, the user will succeed: the only effect of the easing curve is + to change the rate at which the item moves from overshoot 0 to overshoot + 100. But if it is set to 0.5, the BoundaryRule provides resistance such + that when the user tries to move 100 pixels, the Item will only move 50 + pixels; and the easing curve modulates the rate of movement such that it + may move in sync with the user's attempted movement at the beginning, and + then slows down, depending on the shape of the easing curve. + + The default is 0.5. +*/ +qreal QQuickBoundaryRule::overshootScale() const +{ + Q_D(const QQuickBoundaryRule); + return d->overshootScale; +} + +void QQuickBoundaryRule::setOvershootScale(qreal overshootScale) +{ + Q_D(QQuickBoundaryRule); + if (qFuzzyCompare(d->overshootScale, overshootScale)) + return; + d->overshootScale = overshootScale; + emit overshootScaleChanged(); +} + +/*! + \qmlproperty qreal QtQuick::BoundaryRule::currentOvershoot + + This property holds the amount by which the most recently set value of the + intercepted property exceeds \l maximum or is less than \l minimum. + + It is positive if the property value exceeds \l maximum, negative if the + property value is less than \l minimum, or 0 if the property value is + within both boundaries. +*/ +qreal QQuickBoundaryRule::currentOvershoot() const +{ + Q_D(const QQuickBoundaryRule); + return d->currentOvershoot; +} + +/*! + \qmlproperty qreal QtQuick::BoundaryRule::peakOvershoot + + This property holds the most-positive or most-negative value of + \l currentOvershoot that has been seen, until \l returnToBounds() is called. + + This can be useful when the intercepted property value is known to + fluctuate, and you want to find and react to the maximum amount of + overshoot rather than to the fluctuations. + + \sa overshootFilter +*/ +qreal QQuickBoundaryRule::peakOvershoot() const +{ + Q_D(const QQuickBoundaryRule); + return d->peakOvershoot; +} + +/*! + \qmlproperty enum QtQuick::BoundaryRule::overshootFilter + + This property specifies the aggregation function that will be applied to + the intercepted property value. + + If this is set to \c BoundaryRule.None (the default), the intercepted + property will hold a value whose overshoot is limited to \l currentOvershoot. + If this is set to \c BoundaryRule.Peak, the intercepted property will hold + a value whose overshoot is limited to \l peakOvershoot. +*/ +QQuickBoundaryRule::OvershootFilter QQuickBoundaryRule::overshootFilter() const +{ + Q_D(const QQuickBoundaryRule); + return d->overshootFilter; +} + +void QQuickBoundaryRule::setOvershootFilter(OvershootFilter overshootFilter) +{ + Q_D(QQuickBoundaryRule); + if (d->overshootFilter == overshootFilter) + return; + d->overshootFilter = overshootFilter; + emit overshootFilterChanged(); +} + +/*! + \qmlmethod bool QtQuick::BoundaryRule::returnToBounds + + Returns the intercepted property to a value between \l minimum and + \l maximum, such that \l currentOvershoot and \l peakOvershoot are both + zero. This will be animated if \l returnDuration is greater than zero. + + Returns true if the value needed to be adjusted, or false if it was already + within bounds. +*/ +bool QQuickBoundaryRule::returnToBounds() +{ + Q_D(QQuickBoundaryRule); + if (d->returnAnimationJob) { + qCDebug(lcBR) << "animation already in progress"; + return true; + } + if (currentOvershoot() > 0) { + if (d->returnDuration > 0) + d->returnAnimationJob = new QQuickBoundaryReturnJob(d, maximum()); + else + write(maximum()); + } else if (currentOvershoot() < 0) { + if (d->returnDuration > 0) + d->returnAnimationJob = new QQuickBoundaryReturnJob(d, minimum()); + else + write(minimum()); + } else { + return false; + } + if (d->returnAnimationJob) { + qCDebug(lcBR) << "animating from" << d->returnAnimationJob->fromValue << "to" << d->returnAnimationJob->toValue; + d->returnAnimationJob->start(); + } else { + d->resetOvershoot(); + qCDebug(lcBR) << "returned to" << d->property.read(); + } + return true; +} + +/*! + \qmlproperty qreal QtQuick::BoundaryRule::easing + + This property holds the easing curve to be applied in overshoot mode + (whenever the \l minimum or \l maximum constraint is violated, while + the value is still within the respective overshoot range). + + The default easing curve is \l QEasingCurve::OutQuad. +*/ +QEasingCurve QQuickBoundaryRule::easing() const +{ + Q_D(const QQuickBoundaryRule); + return d->easing; +} + +void QQuickBoundaryRule::setEasing(const QEasingCurve &easing) +{ + Q_D(QQuickBoundaryRule); + if (d->easing == easing) + return; + d->easing = easing; + emit easingChanged(); +} + +/*! + \qmlproperty int QtQuick::BoundaryRule::returnDuration + + This property holds the amount of time in milliseconds that + \l returnToBounds() will take to return the target property to the nearest bound. + If it is set to 0, returnToBounds() will set the property immediately + rather than creating an animation job. + + The default is 100 ms. +*/ +int QQuickBoundaryRule::returnDuration() const +{ + Q_D(const QQuickBoundaryRule); + return d->returnDuration; +} + +void QQuickBoundaryRule::setReturnDuration(int duration) +{ + Q_D(QQuickBoundaryRule); + if (d->returnDuration == duration) + return; + d->returnDuration = duration; + emit returnDurationChanged(); +} + +void QQuickBoundaryRule::write(const QVariant &value) +{ + bool conversionOk = false; + qreal rValue = value.toReal(&conversionOk); + if (!conversionOk) { + qWarning() << "BoundaryRule doesn't work with non-numeric values:" << value; + return; + } + Q_D(QQuickBoundaryRule); + bool bypass = !d->enabled || !d->finalized || QQmlEnginePrivate::designerMode(); + if (bypass) { + QQmlPropertyPrivate::write(d->property, value, + QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding); + return; + } + + qmlExecuteDeferred(this); + d->targetValue = d->easedOvershoot(rValue); + QQmlPropertyPrivate::write(d->property, d->targetValue, + QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding); +} + +void QQuickBoundaryRule::setTarget(const QQmlProperty &property) +{ + Q_D(QQuickBoundaryRule); + d->property = property; + + QQmlEnginePrivate *engPriv = QQmlEnginePrivate::get(qmlEngine(this)); + static int finalizedIdx = -1; + if (finalizedIdx < 0) + finalizedIdx = metaObject()->indexOfSlot("componentFinalized()"); + engPriv->registerFinalizeCallback(this, finalizedIdx); +} + +void QQuickBoundaryRule::componentFinalized() +{ + Q_D(QQuickBoundaryRule); + d->finalized = true; +} + +/*! + \internal + Given that something is trying to set the target property to \a value, + this function applies the easing curve and returns the value that the + property should actually get instead. +*/ +qreal QQuickBoundaryRulePrivate::easedOvershoot(qreal value) +{ + qreal ret = value; + Q_Q(QQuickBoundaryRule); + if (value > maximum) { + qreal overshootWas = currentOvershoot; + currentOvershoot = value - maximum; + if (!qFuzzyCompare(overshootWas, currentOvershoot)) + emit q->currentOvershootChanged(); + overshootWas = peakOvershoot; + peakOvershoot = qMax(currentOvershoot, peakOvershoot); + if (!qFuzzyCompare(overshootWas, peakOvershoot)) + emit q->peakOvershootChanged(); + ret = maximum + maximumOvershoot * easing.valueForProgress( + (overshootFilter == QQuickBoundaryRule::OvershootFilter::Peak ? peakOvershoot : currentOvershoot) + * overshootScale / maximumOvershoot); + qCDebug(lcBR).nospace() << value << " overshoots maximum " << maximum << " by " + << currentOvershoot << " (peak " << peakOvershoot << "): eased to " << ret; + } else if (value < minimum) { + qreal overshootWas = currentOvershoot; + currentOvershoot = value - minimum; + if (!qFuzzyCompare(overshootWas, currentOvershoot)) + emit q->currentOvershootChanged(); + overshootWas = peakOvershoot; + peakOvershoot = qMin(currentOvershoot, peakOvershoot); + if (!qFuzzyCompare(overshootWas, peakOvershoot)) + emit q->peakOvershootChanged(); + ret = minimum - minimumOvershoot * easing.valueForProgress( + -(overshootFilter == QQuickBoundaryRule::OvershootFilter::Peak ? peakOvershoot : currentOvershoot) + * overshootScale / minimumOvershoot); + qCDebug(lcBR).nospace() << value << " overshoots minimum " << minimum << " by " + << currentOvershoot << " (peak " << peakOvershoot << "): eased to " << ret; + } else { + resetOvershoot(); + } + return ret; +} + +/*! + \internal + Resets the currentOvershoot and peakOvershoot + properties to zero. +*/ +void QQuickBoundaryRulePrivate::resetOvershoot() +{ + Q_Q(QQuickBoundaryRule); + if (!qFuzzyCompare(peakOvershoot, 0)) { + peakOvershoot = 0; + emit q->peakOvershootChanged(); + } + if (!qFuzzyCompare(currentOvershoot, 0)) { + currentOvershoot = 0; + emit q->currentOvershootChanged(); + } +} + +QT_END_NAMESPACE + +#include "moc_qquickboundaryrule_p.cpp" diff --git a/src/imports/labsanimation/qquickboundaryrule_p.h b/src/imports/labsanimation/qquickboundaryrule_p.h new file mode 100644 index 0000000000..1681558304 --- /dev/null +++ b/src/imports/labsanimation/qquickboundaryrule_p.h @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKBOUNDARYRULE_H +#define QQUICKBOUNDARYRULE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qtquickglobal_p.h> + +#include <private/qqmlpropertyvalueinterceptor_p.h> +#include <qqml.h> + +QT_BEGIN_NAMESPACE + +class QQuickAbstractAnimation; +class QQuickBoundaryRulePrivate; +class QQuickBoundaryRule : public QObject, public QQmlPropertyValueInterceptor +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QQuickBoundaryRule) + + Q_INTERFACES(QQmlPropertyValueInterceptor) + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) + Q_PROPERTY(qreal minimum READ minimum WRITE setMinimum NOTIFY minimumChanged) + Q_PROPERTY(qreal minimumOvershoot READ minimumOvershoot WRITE setMinimumOvershoot NOTIFY minimumOvershootChanged) + Q_PROPERTY(qreal maximum READ maximum WRITE setMaximum NOTIFY maximumChanged) + Q_PROPERTY(qreal maximumOvershoot READ maximumOvershoot WRITE setMaximumOvershoot NOTIFY maximumOvershootChanged) + Q_PROPERTY(qreal overshootScale READ overshootScale WRITE setOvershootScale NOTIFY overshootScaleChanged) + Q_PROPERTY(qreal currentOvershoot READ currentOvershoot NOTIFY currentOvershootChanged) + Q_PROPERTY(qreal peakOvershoot READ peakOvershoot NOTIFY peakOvershootChanged) + Q_PROPERTY(OvershootFilter overshootFilter READ overshootFilter WRITE setOvershootFilter NOTIFY overshootFilterChanged) + Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged) + Q_PROPERTY(int returnDuration READ returnDuration WRITE setReturnDuration NOTIFY returnDurationChanged) + QML_NAMED_ELEMENT(BoundaryRule) + +public: + enum OvershootFilter { + None, + Peak + }; + Q_ENUM(OvershootFilter) + + QQuickBoundaryRule(QObject *parent=nullptr); + ~QQuickBoundaryRule(); + + void setTarget(const QQmlProperty &) override; + void write(const QVariant &value) override; + + bool enabled() const; + void setEnabled(bool enabled); + + qreal minimum() const; + void setMinimum(qreal minimum); + qreal minimumOvershoot() const; + void setMinimumOvershoot(qreal minimum); + + qreal maximum() const; + void setMaximum(qreal maximum); + qreal maximumOvershoot() const; + void setMaximumOvershoot(qreal maximum); + + qreal overshootScale() const; + void setOvershootScale(qreal scale); + + qreal currentOvershoot() const; + qreal peakOvershoot() const; + + OvershootFilter overshootFilter() const; + void setOvershootFilter(OvershootFilter overshootFilter); + + Q_INVOKABLE bool returnToBounds(); + + QEasingCurve easing() const; + void setEasing(const QEasingCurve &easing); + + int returnDuration() const; + void setReturnDuration(int duration); + +Q_SIGNALS: + void enabledChanged(); + void minimumChanged(); + void minimumOvershootChanged(); + void maximumChanged(); + void maximumOvershootChanged(); + void overshootScaleChanged(); + void currentOvershootChanged(); + void peakOvershootChanged(); + void overshootFilterChanged(); + void easingChanged(); + void returnDurationChanged(); + +private Q_SLOTS: + void componentFinalized(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QQuickBoundaryRule) + +#endif // QQUICKBOUNDARYRULE_H diff --git a/src/imports/layouts/plugin.cpp b/src/imports/layouts/plugin.cpp index 03a2c8fd00..28592213a8 100644 --- a/src/imports/layouts/plugin.cpp +++ b/src/imports/layouts/plugin.cpp @@ -57,15 +57,8 @@ public: { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Layouts")); - qmlRegisterType<QQuickRowLayout>(uri, 1, 0, "RowLayout"); - qmlRegisterType<QQuickColumnLayout>(uri, 1, 0, "ColumnLayout"); - qmlRegisterType<QQuickGridLayout>(uri, 1, 0, "GridLayout"); - qmlRegisterType<QQuickStackLayout>(uri, 1, 3, "StackLayout"); - qmlRegisterUncreatableType<QQuickLayout>(uri, 1, 0, "Layout", - QStringLiteral("Do not create objects of type Layout")); - qmlRegisterUncreatableType<QQuickLayout>(uri, 1, 2, "Layout", - QStringLiteral("Do not create objects of type Layout")); - qmlRegisterRevision<QQuickGridLayoutBase, 1>(uri, 1, 1); + qmlRegisterTypesAndRevisions<QQuickRowLayout, QQuickColumnLayout, QQuickGridLayout, + QQuickStackLayout, QQuickLayout, QQuickGridLayoutBase>(uri, 1); qmlRegisterModule(uri, 1, 15); } diff --git a/src/imports/layouts/plugins.qmltypes b/src/imports/layouts/plugins.qmltypes index 6015164511..4ebef4ac51 100644 --- a/src/imports/layouts/plugins.qmltypes +++ b/src/imports/layouts/plugins.qmltypes @@ -12,15 +12,27 @@ Module { name: "QQuickColumnLayout" defaultProperty: "data" prototype: "QQuickLinearLayout" - exports: ["QtQuick.Layouts/ColumnLayout 1.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Layouts/ColumnLayout 1.0", + "QtQuick.Layouts/ColumnLayout 1.1", + "QtQuick.Layouts/ColumnLayout 1.11", + "QtQuick.Layouts/ColumnLayout 1.4", + "QtQuick.Layouts/ColumnLayout 1.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] } Component { name: "QQuickGridLayout" defaultProperty: "data" prototype: "QQuickGridLayoutBase" - exports: ["QtQuick.Layouts/GridLayout 1.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Layouts/GridLayout 1.0", + "QtQuick.Layouts/GridLayout 1.1", + "QtQuick.Layouts/GridLayout 1.11", + "QtQuick.Layouts/GridLayout 1.4", + "QtQuick.Layouts/GridLayout 1.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Enum { name: "Flow" values: { @@ -45,9 +57,15 @@ Module { name: "QQuickLayout" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick.Layouts/Layout 1.0", "QtQuick.Layouts/Layout 1.2"] + exports: [ + "QtQuick.Layouts/Layout 1.0", + "QtQuick.Layouts/Layout 1.1", + "QtQuick.Layouts/Layout 1.11", + "QtQuick.Layouts/Layout 1.4", + "QtQuick.Layouts/Layout 1.7" + ] isCreatable: false - exportMetaObjectRevisions: [0, 0] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] attachedType: "QQuickLayoutAttached" } Component { @@ -82,15 +100,26 @@ Module { name: "QQuickRowLayout" defaultProperty: "data" prototype: "QQuickLinearLayout" - exports: ["QtQuick.Layouts/RowLayout 1.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Layouts/RowLayout 1.0", + "QtQuick.Layouts/RowLayout 1.1", + "QtQuick.Layouts/RowLayout 1.11", + "QtQuick.Layouts/RowLayout 1.4", + "QtQuick.Layouts/RowLayout 1.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] } Component { name: "QQuickStackLayout" defaultProperty: "data" prototype: "QQuickLayout" - exports: ["QtQuick.Layouts/StackLayout 1.3"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Layouts/StackLayout 1.11", + "QtQuick.Layouts/StackLayout 1.3", + "QtQuick.Layouts/StackLayout 1.4", + "QtQuick.Layouts/StackLayout 1.7" + ] + exportMetaObjectRevisions: [11, 3, 4, 7] Property { name: "count"; type: "int"; isReadonly: true } Property { name: "currentIndex"; type: "int" } Method { diff --git a/src/imports/layouts/qquicklayout_p.h b/src/imports/layouts/qquicklayout_p.h index b31bffa290..c022a2fd47 100644 --- a/src/imports/layouts/qquicklayout_p.h +++ b/src/imports/layouts/qquicklayout_p.h @@ -61,6 +61,10 @@ class QQuickLayout : public QQuickItem, public QQuickItemChangeListener { Q_OBJECT + QML_NAMED_ELEMENT(Layout) + QML_UNCREATABLE("Do not create objects of type Layout.") + QML_ATTACHED(QQuickLayoutAttached) + public: enum SizeHint { MinimumSize = 0, @@ -331,6 +335,5 @@ inline QQuickLayoutAttached *attachedLayoutObject(QQuickItem *item, bool create QT_END_NAMESPACE QML_DECLARE_TYPE(QQuickLayout) -QML_DECLARE_TYPEINFO(QQuickLayout, QML_HAS_ATTACHED_PROPERTIES) #endif // QQUICKLAYOUT_P_H diff --git a/src/imports/layouts/qquicklinearlayout_p.h b/src/imports/layouts/qquicklinearlayout_p.h index 6706ebf9fa..634e51a048 100644 --- a/src/imports/layouts/qquicklinearlayout_p.h +++ b/src/imports/layouts/qquicklinearlayout_p.h @@ -57,6 +57,8 @@ class QQuickGridLayoutBase : public QQuickLayout Q_OBJECT Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1) + QML_ANONYMOUS + QML_ADDED_IN_MINOR_VERSION(1) public: @@ -140,6 +142,7 @@ class QQuickGridLayout : public QQuickGridLayoutBase Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged) Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged) Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged) + QML_NAMED_ELEMENT(GridLayout) public: explicit QQuickGridLayout(QQuickItem *parent = 0); qreal columnSpacing() const; @@ -223,6 +226,7 @@ public: class QQuickRowLayout : public QQuickLinearLayout { Q_OBJECT + QML_NAMED_ELEMENT(RowLayout) public: explicit QQuickRowLayout(QQuickItem *parent = 0) @@ -238,6 +242,7 @@ public: class QQuickColumnLayout : public QQuickLinearLayout { Q_OBJECT + QML_NAMED_ELEMENT(ColumnLayout) public: explicit QQuickColumnLayout(QQuickItem *parent = 0) diff --git a/src/imports/layouts/qquickstacklayout.cpp b/src/imports/layouts/qquickstacklayout.cpp index 116e162aa9..4c1d611409 100644 --- a/src/imports/layouts/qquickstacklayout.cpp +++ b/src/imports/layouts/qquickstacklayout.cpp @@ -94,7 +94,7 @@ \sa ColumnLayout \sa GridLayout \sa RowLayout - \sa StackView + \sa {QtQuick.Controls::StackView}{StackView} */ QT_BEGIN_NAMESPACE diff --git a/src/imports/layouts/qquickstacklayout_p.h b/src/imports/layouts/qquickstacklayout_p.h index 46181c6f50..537d54900f 100644 --- a/src/imports/layouts/qquickstacklayout_p.h +++ b/src/imports/layouts/qquickstacklayout_p.h @@ -51,6 +51,8 @@ class QQuickStackLayout : public QQuickLayout Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) + QML_NAMED_ELEMENT(StackLayout) + QML_ADDED_IN_MINOR_VERSION(3) public: explicit QQuickStackLayout(QQuickItem *parent = 0); diff --git a/src/imports/localstorage/localstorage.pro b/src/imports/localstorage/localstorage.pro index 5c8177e238..607a6cbbdd 100644 --- a/src/imports/localstorage/localstorage.pro +++ b/src/imports/localstorage/localstorage.pro @@ -5,7 +5,12 @@ IMPORT_VERSION = 2.$$QT_MINOR_VERSION QT = sql qml-private core-private -SOURCES += plugin.cpp +SOURCES += \ + plugin.cpp \ + qquicklocalstorage.cpp + +HEADERS += \ + qquicklocalstorage_p.h load(qml_plugin) diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 740a394fa0..6366c51b47 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -36,781 +36,14 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include <QStringList> + +#include "qquicklocalstorage_p.h" + #include <QtQml/qqmlextensionplugin.h> #include <QtQml/qqml.h> -#include <private/qqmlengine_p.h> -#include <QDebug> -#include <QtSql/qsqldatabase.h> -#include <QtSql/qsqlquery.h> -#include <QtSql/qsqlerror.h> -#include <QtSql/qsqlrecord.h> -#include <QtSql/qsqlfield.h> -#include <QtCore/qstandardpaths.h> -#include <QtCore/qstack.h> -#include <QtCore/qcryptographichash.h> -#include <QtCore/qsettings.h> -#include <QtCore/qdir.h> -#include <private/qv4sqlerrors_p.h> -#include <private/qv4engine_p.h> -#include <private/qv4object_p.h> -#include <private/qv4functionobject_p.h> -#include <private/qv4objectproto_p.h> -#include <private/qv4scopedvalue_p.h> -#include <private/qv4jscall_p.h> -#include <private/qv4objectiterator_p.h> QT_BEGIN_NAMESPACE -#define V4THROW_SQL(error, desc) { \ - QV4::ScopedString v(scope, scope.engine->newString(desc)); \ - QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \ - ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Value::fromInt32(error))); \ - scope.engine->throwError(ex); \ - RETURN_UNDEFINED(); \ -} - -#define V4THROW_SQL2(error, desc) { \ - QV4::ScopedString v(scope, scope.engine->newString(desc)); \ - QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \ - ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Value::fromInt32(error))); \ - args->setReturnValue(scope.engine->throwError(ex)); \ - return; \ -} - -#define V4THROW_REFERENCE(string) { \ - QV4::ScopedString v(scope, scope.engine->newString(string)); \ - scope.engine->throwReferenceError(v); \ - RETURN_UNDEFINED(); \ -} - - -class QQmlSqlDatabaseData : public QV4::ExecutionEngine::Deletable -{ -public: - QQmlSqlDatabaseData(QV4::ExecutionEngine *engine); - ~QQmlSqlDatabaseData() override; - - QV4::PersistentValue databaseProto; - QV4::PersistentValue queryProto; - QV4::PersistentValue rowsProto; -}; - -V4_DEFINE_EXTENSION(QQmlSqlDatabaseData, databaseData) - -namespace QV4 { - -namespace Heap { - struct QQmlSqlDatabaseWrapper : public Object { - enum Type { Database, Query, Rows }; - void init() - { - Object::init(); - type = Database; - database = new QSqlDatabase; - version = new QString; - sqlQuery = new QSqlQuery; - } - - void destroy() { - delete database; - delete version; - delete sqlQuery; - Object::destroy(); - } - - Type type; - QSqlDatabase *database; - - QString *version; // type == Database - - bool inTransaction; // type == Query - bool readonly; // type == Query - - QSqlQuery *sqlQuery; // type == Rows - bool forwardOnly; // type == Rows - }; -} - -class QQmlSqlDatabaseWrapper : public Object -{ -public: - V4_OBJECT2(QQmlSqlDatabaseWrapper, Object) - V4_NEEDS_DESTROY - - static Heap::QQmlSqlDatabaseWrapper *create(QV4::ExecutionEngine *engine) - { - return engine->memoryManager->allocate<QQmlSqlDatabaseWrapper>(); - } - - ~QQmlSqlDatabaseWrapper() { - } - - static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); -}; - -} - -using namespace QV4; - -DEFINE_OBJECT_VTABLE(QV4::QQmlSqlDatabaseWrapper); - - - -static ReturnedValue qmlsqldatabase_version(const FunctionObject *b, const Value *thisObject, const QV4::Value *, int) -{ - Scope scope(b); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); - if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) - V4THROW_REFERENCE("Not a SQLDatabase object"); - - RETURN_RESULT(Encode(scope.engine->newString(*r->d()->version))); -} - -static ReturnedValue qmlsqldatabase_rows_length(const FunctionObject *b, const Value *thisObject, const QV4::Value *, int) -{ - Scope scope(b); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); - if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) - V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - - int s = r->d()->sqlQuery->size(); - if (s < 0) { - // Inefficient - if (r->d()->sqlQuery->last()) { - s = r->d()->sqlQuery->at() + 1; - } else { - s = 0; - } - } - RETURN_RESULT(Encode(s)); -} - -static ReturnedValue qmlsqldatabase_rows_forwardOnly(const FunctionObject *b, const Value *thisObject, const QV4::Value *, int) -{ - Scope scope(b); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); - if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) - V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - RETURN_RESULT(Encode(r->d()->sqlQuery->isForwardOnly())); -} - -static ReturnedValue qmlsqldatabase_rows_setForwardOnly(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) -{ - Scope scope(b); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); - if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) - V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - if (argc < 1) - RETURN_RESULT(scope.engine->throwTypeError()); - - r->d()->sqlQuery->setForwardOnly(argv[0].toBoolean()); - RETURN_UNDEFINED(); -} - -QQmlSqlDatabaseData::~QQmlSqlDatabaseData() -{ -} - -static ReturnedValue qmlsqldatabase_rows_index(const QQmlSqlDatabaseWrapper *r, ExecutionEngine *v4, quint32 index, bool *hasProperty = nullptr) -{ - Scope scope(v4); - - if (r->d()->sqlQuery->at() == (int)index || r->d()->sqlQuery->seek(index)) { - QSqlRecord record = r->d()->sqlQuery->record(); - // XXX optimize - ScopedObject row(scope, v4->newObject()); - for (int ii = 0; ii < record.count(); ++ii) { - QVariant v = record.value(ii); - ScopedString s(scope, v4->newIdentifier(record.fieldName(ii))); - ScopedValue val(scope, v.isNull() ? Encode::null() : v4->fromVariant(v)); - row->put(s.getPointer(), val); - } - if (hasProperty) - *hasProperty = true; - return row.asReturnedValue(); - } else { - if (hasProperty) - *hasProperty = false; - return Encode::undefined(); - } -} - -ReturnedValue QQmlSqlDatabaseWrapper::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) -{ - if (!id.isArrayIndex()) - return Object::virtualGet(m, id, receiver, hasProperty); - - uint index = id.asArrayIndex(); - Q_ASSERT(m->as<QQmlSqlDatabaseWrapper>()); - const QQmlSqlDatabaseWrapper *r = static_cast<const QQmlSqlDatabaseWrapper *>(m); - if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) - return Object::virtualGet(m, id, receiver, hasProperty); - - return qmlsqldatabase_rows_index(r, r->engine(), index, hasProperty); -} - -static ReturnedValue qmlsqldatabase_rows_item(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) -{ - Scope scope(b); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); - if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) - V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); - - RETURN_RESULT(qmlsqldatabase_rows_index(r, scope.engine, argc ? argv[0].toUInt32() : 0)); -} - -static QVariant toSqlVariant(QV4::ExecutionEngine *engine, const QV4::ScopedValue &value) -{ - // toVariant() maps a null JS value to QVariant(VoidStar), but the SQL module - // expects a null variant. (this is because of QTBUG-40880) - if (value->isNull()) - return QVariant(); - return engine->toVariant(value, /*typehint*/-1); -} - -static ReturnedValue qmlsqldatabase_executeSql(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) -{ - Scope scope(b); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); - if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Query) - V4THROW_REFERENCE("Not a SQLDatabase::Query object"); - - if (!r->d()->inTransaction) - V4THROW_SQL(SQLEXCEPTION_DATABASE_ERR,QQmlEngine::tr("executeSql called outside transaction()")); - - QSqlDatabase db = *r->d()->database; - - QString sql = argc ? argv[0].toQString() : QString(); - - if (r->d()->readonly && !sql.startsWith(QLatin1String("SELECT"),Qt::CaseInsensitive)) { - V4THROW_SQL(SQLEXCEPTION_SYNTAX_ERR, QQmlEngine::tr("Read-only Transaction")); - } - - QSqlQuery query(db); - bool err = false; - - ScopedValue result(scope, Value::undefinedValue()); - - if (query.prepare(sql)) { - if (argc > 1) { - ScopedValue values(scope, argv[1]); - if (values->as<ArrayObject>()) { - ScopedArrayObject array(scope, values); - quint32 size = array->getLength(); - QV4::ScopedValue v(scope); - for (quint32 ii = 0; ii < size; ++ii) { - query.bindValue(ii, toSqlVariant(scope.engine, (v = array->get(ii)))); - } - } else if (values->as<Object>()) { - ScopedObject object(scope, values); - ObjectIterator it(scope, object, ObjectIterator::EnumerableOnly); - ScopedValue key(scope); - QV4::ScopedValue val(scope); - while (1) { - key = it.nextPropertyName(val); - if (key->isNull()) - break; - QVariant v = toSqlVariant(scope.engine, val); - if (key->isString()) { - query.bindValue(key->stringValue()->toQString(), v); - } else { - Q_ASSERT(key->isInteger()); - query.bindValue(key->integerValue(), v); - } - } - } else { - query.bindValue(0, toSqlVariant(scope.engine, values)); - } - } - if (query.exec()) { - QV4::Scoped<QQmlSqlDatabaseWrapper> rows(scope, QQmlSqlDatabaseWrapper::create(scope.engine)); - QV4::ScopedObject p(scope, databaseData(scope.engine)->rowsProto.value()); - rows->setPrototypeUnchecked(p.getPointer()); - rows->d()->type = Heap::QQmlSqlDatabaseWrapper::Rows; - *rows->d()->database = db; - *rows->d()->sqlQuery = query; - - ScopedObject resultObject(scope, scope.engine->newObject()); - result = resultObject.asReturnedValue(); - // XXX optimize - ScopedString s(scope); - ScopedValue v(scope); - resultObject->put((s = scope.engine->newIdentifier("rowsAffected")).getPointer(), (v = Value::fromInt32(query.numRowsAffected()))); - resultObject->put((s = scope.engine->newIdentifier("insertId")).getPointer(), (v = scope.engine->newString(query.lastInsertId().toString()))); - resultObject->put((s = scope.engine->newIdentifier("rows")).getPointer(), rows); - } else { - err = true; - } - } else { - err = true; - } - if (err) - V4THROW_SQL(SQLEXCEPTION_DATABASE_ERR,query.lastError().text()); - - RETURN_RESULT(result->asReturnedValue()); -} - -struct TransactionRollback { - QSqlDatabase *db; - bool *inTransactionFlag; - - TransactionRollback(QSqlDatabase *database, bool *transactionFlag) - : db(database) - , inTransactionFlag(transactionFlag) - { - if (inTransactionFlag) - *inTransactionFlag = true; - } - - ~TransactionRollback() - { - if (inTransactionFlag) - *inTransactionFlag = false; - if (db) - db->rollback(); - } - - void clear() { - db = nullptr; - if (inTransactionFlag) - *inTransactionFlag = false; - inTransactionFlag = nullptr; - } -}; - - -static ReturnedValue qmlsqldatabase_changeVersion(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) -{ - Scope scope(b); - if (argc < 2) - RETURN_UNDEFINED(); - - Scoped<QQmlSqlDatabaseWrapper> r(scope, *thisObject); - if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) - V4THROW_REFERENCE("Not a SQLDatabase object"); - - QSqlDatabase db = *r->d()->database; - QString from_version = argv[0].toQString(); - QString to_version = argv[1].toQString(); - ScopedFunctionObject callback(scope, argc > 2 ? argv[2] : Value::undefinedValue()); - - if (from_version != *r->d()->version) - V4THROW_SQL(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("Version mismatch: expected %1, found %2").arg(from_version).arg(*r->d()->version)); - - bool ok = true; - if (!!callback) { - Scoped<QQmlSqlDatabaseWrapper> query(scope, QQmlSqlDatabaseWrapper::create(scope.engine)); - ScopedObject p(scope, databaseData(scope.engine)->queryProto.value()); - query->setPrototypeUnchecked(p.getPointer()); - query->d()->type = Heap::QQmlSqlDatabaseWrapper::Query; - *query->d()->database = db; - *query->d()->version = *r->d()->version; - - ok = false; - db.transaction(); - - JSCallData jsCall(scope, 1); - *jsCall->thisObject = scope.engine->globalObject; - jsCall->args[0] = query; - - TransactionRollback rollbackOnException(&db, &query->d()->inTransaction); - callback->call(jsCall); - rollbackOnException.clear(); - if (!db.commit()) { - db.rollback(); - V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR,QQmlEngine::tr("SQL transaction failed")); - } else { - ok = true; - } - } - - if (ok) { - Scoped<QQmlSqlDatabaseWrapper> w(scope, QQmlSqlDatabaseWrapper::create(scope.engine)); - ScopedObject p(scope, databaseData(scope.engine)->databaseProto.value()); - w->setPrototypeUnchecked(p.getPointer()); - w->d()->type = Heap::QQmlSqlDatabaseWrapper::Database; - *w->d()->database = db; - *w->d()->version = to_version; -#if QT_CONFIG(settings) - const QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(scope.engine->qmlEngine()); - QSettings ini(enginePrivate->offlineStorageDatabaseDirectory() + db.connectionName() + QLatin1String(".ini"), QSettings::IniFormat); - ini.setValue(QLatin1String("Version"), to_version); -#endif - RETURN_RESULT(w.asReturnedValue()); - } - - RETURN_UNDEFINED(); -} - -static ReturnedValue qmlsqldatabase_transaction_shared(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc, bool readOnly) -{ - Scope scope(b); - QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); - if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) - V4THROW_REFERENCE("Not a SQLDatabase object"); - - const FunctionObject *callback = argc ? argv[0].as<FunctionObject>() : nullptr; - if (!callback) - V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR, QQmlEngine::tr("transaction: missing callback")); - - QSqlDatabase db = *r->d()->database; - - Scoped<QQmlSqlDatabaseWrapper> w(scope, QQmlSqlDatabaseWrapper::create(scope.engine)); - QV4::ScopedObject p(scope, databaseData(scope.engine)->queryProto.value()); - w->setPrototypeUnchecked(p.getPointer()); - w->d()->type = Heap::QQmlSqlDatabaseWrapper::Query; - *w->d()->database = db; - *w->d()->version = *r->d()->version; - w->d()->readonly = readOnly; - - db.transaction(); - if (callback) { - JSCallData jsCall(scope, 1); - *jsCall->thisObject = scope.engine->globalObject; - jsCall->args[0] = w; - TransactionRollback rollbackOnException(&db, &w->d()->inTransaction); - callback->call(jsCall); - rollbackOnException.clear(); - - if (!db.commit()) - db.rollback(); - } - - RETURN_UNDEFINED(); -} - -static ReturnedValue qmlsqldatabase_transaction(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) -{ - return qmlsqldatabase_transaction_shared(f, thisObject, argv, argc, false); -} - -static ReturnedValue qmlsqldatabase_read_transaction(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) -{ - return qmlsqldatabase_transaction_shared(f, thisObject, argv, argc, true); -} - -QQmlSqlDatabaseData::QQmlSqlDatabaseData(ExecutionEngine *v4) -{ - Scope scope(v4); - { - ScopedObject proto(scope, v4->newObject()); - proto->defineDefaultProperty(QStringLiteral("transaction"), qmlsqldatabase_transaction); - proto->defineDefaultProperty(QStringLiteral("readTransaction"), qmlsqldatabase_read_transaction); - proto->defineAccessorProperty(QStringLiteral("version"), qmlsqldatabase_version, nullptr); - proto->defineDefaultProperty(QStringLiteral("changeVersion"), qmlsqldatabase_changeVersion); - databaseProto = proto; - } - - { - ScopedObject proto(scope, v4->newObject()); - proto->defineDefaultProperty(QStringLiteral("executeSql"), qmlsqldatabase_executeSql); - queryProto = proto; - } - { - ScopedObject proto(scope, v4->newObject()); - proto->defineDefaultProperty(QStringLiteral("item"), qmlsqldatabase_rows_item); - proto->defineAccessorProperty(QStringLiteral("length"), qmlsqldatabase_rows_length, nullptr); - proto->defineAccessorProperty(QStringLiteral("forwardOnly"), - qmlsqldatabase_rows_forwardOnly, qmlsqldatabase_rows_setForwardOnly); - rowsProto = proto; - } -} - -/* -HTML5 "spec" says "rs.rows[n]", but WebKit only impelments "rs.rows.item(n)". We do both (and property iterator). -We add a "forwardOnly" property that stops Qt caching results (code promises to only go forward -through the data. -*/ - - -/*! - \qmlmodule QtQuick.LocalStorage 2.\QtMinorVersion - \title Qt Quick Local Storage QML Types - \ingroup qmlmodules - \brief Provides a JavaScript object singleton type for accessing a local - SQLite database - - This is a singleton type for reading and writing to SQLite databases. - - - \section1 Methods - - \list - \li object \b{\l{#openDatabaseSync}{openDatabaseSync}}(string name, string version, string description, int estimated_size, jsobject callback(db)) - \endlist - - - \section1 Detailed Description - - To use the types in this module, import the module and call the - relevant functions using the \c LocalStorage type: - - \qml \QtMinorVersion - import QtQuick 2.\1 - import QtQuick.LocalStorage 2.\1 - - Item { - Component.onCompleted: { - var db = LocalStorage.openDatabaseSync(...) - } - } - \endqml - - -These databases are user-specific and QML-specific, but accessible to all QML applications. -They are stored in the \c Databases subdirectory -of QQmlEngine::offlineStoragePath(), currently as SQLite databases. - -Database connections are automatically closed during Javascript garbage collection. - -The API can be used from JavaScript functions in your QML: - -\snippet qml/localstorage/hello.qml 0 - -The API conforms to the Synchronous API of the HTML5 Web Database API, -\link http://www.w3.org/TR/2009/WD-webdatabase-20091029/ W3C Working Draft 29 October 2009\endlink. - -The \l{Qt Quick Examples - Local Storage}{SQL Local Storage example} demonstrates the basics of -using the Offline Storage API. - -\section3 Open or Create a Database - -\qml \QtMinorVersion -import QtQuick.LocalStorage 2.\1 as Sql - -db = Sql.openDatabaseSync(identifier, version, description, estimated_size, callback(db)) -\endqml - -The above code returns the database identified by \e identifier. If the database does not already exist, it -is created, and the function \e callback is called with the database as a parameter. \e identifier is the -name of the physical file (with or without full path) containing the database. \e description and -\e estimated_size are written to the INI file (described below), but are currently unused. - -May throw exception with code property SQLException.DATABASE_ERR, or SQLException.VERSION_ERR. - -When a database is first created, an INI file is also created specifying its characteristics: - -\table -\header \li \b {Key} \li \b {Value} -\row \li Identifier \li The name of the database passed to \c openDatabase() -\row \li Version \li The version of the database passed to \c openDatabase() -\row \li Description \li The description of the database passed to \c openDatabase() -\row \li EstimatedSize \li The estimated size (in bytes) of the database passed to \c openDatabase() -\row \li Driver \li Currently "QSQLITE" -\endtable - -This data can be used by application tools. - -\section3 db.changeVersion(from, to, callback(tx)) - -This method allows you to perform a \e{Scheme Upgrade}. If it succeeds it returns a new -database object of version \e to. Otherwise it returns \e undefined. - -If the current version of \e db is not \e from, then an exception is thrown. - -Otherwise, a database transaction is created and passed to \e callback. In this function, -you can call \e executeSql on \e tx to upgrade the database. - -May throw exception with code property SQLException.DATABASE_ERR or SQLException.UNKNOWN_ERR. - -See example below. - -\badcode - var db = LocalStorage.openDatabaseSync("ActivityTrackDB", "", "Database tracking sports activities", 1000000); - if (db.version == "0.1") { - db.changeVersion("0.1", "0.2", function(tx) { - tx.executeSql("INSERT INTO trip_log VALUES(?, ?, ?)", - [ "01/10/2016","Sylling - Vikersund", "53" ]); - } - }); -\endcode - -\section3 db.transaction(callback(tx)) - -This method creates a read/write transaction and passed to \e callback. In this function, -you can call \e executeSql on \e tx to read and modify the database. - -If the callback throws exceptions, the transaction is rolled back. -Below you will find an example of a database transaction which catches exceptions. - - -\quotefromfile localstorage/localstorage/Database.js -\skipuntil dbInit() -\printto dbGetHandle - -In the example you can see an \c insert statement where values are assigned to the fields, -and the record is written into the table. That is an \c insert statement with a syntax that is usual -for a relational database. It is however also possible to work with JSON objects and -store them in a table. - -Let's suppose a simple example where we store trips in JSON format using \c date as the unique key. -An example of a table that could be used for that purpose: - -\badcode - create table trip_log(date text, data text) -\endcode - -The assignment of values to a JSON object: - -\badcode - var obj = {description = "Vikersund - Noresund", distance = "60"} -\endcode - -In that case, the data could be saved in the following way: - -\badcode - db.transaction(function(tx) { - result = tx.executeSQL("insert into trip_log values (?,?)", - ["01/11/2016", JSON.stringify(obj)]) - -\endcode - -\section3 db.readTransaction(callback(tx)) - -This method creates a read-only transaction and passed to \e callback. In this function, -you can call \e executeSql on \e tx to read the database (with \c select statements). - -\section3 results = tx.executeSql(statement, values) - -This method executes an SQL \e statement, binding the list of \e values to SQL positional parameters ("?"). - -It returns a results object, with the following properties: - -\table -\header \li \b {Type} \li \b {Property} \li \b {Value} \li \b {Applicability} -\row \li int \li rows.length \li The number of rows in the result \li SELECT -\row \li var \li rows.item(i) \li Function that returns row \e i of the result \li SELECT -\row \li int \li rowsAffected \li The number of rows affected by a modification \li UPDATE, DELETE -\row \li string \li insertId \li The id of the row inserted \li INSERT -\endtable - -May throw exception with code property SQLException.DATABASE_ERR, SQLException.SYNTAX_ERR, or SQLException.UNKNOWN_ERR. - -See below for an example: - -\quotefromfile localstorage/localstorage/Database.js -\skipto dbReadAll() -\printto dbUpdate(Pdate - -\section1 Method Documentation - -\target openDatabaseSync -\code -object openDatabaseSync(string name, string version, string description, int estimated_size, jsobject callback(db)) -\endcode - -Opens or creates a local storage sql database by the given parameters. - -\list -\li \c name is the database name -\li \c version is the database version -\li \c description is the database display name -\li \c estimated_size is the database's estimated size, in bytes -\li \c callback is an optional parameter, which is invoked if the database has not yet been created. -\endlist - -Returns the created database object. - -*/ -class QQuickLocalStorage : public QObject -{ - Q_OBJECT -public: - QQuickLocalStorage(QObject *parent=nullptr) : QObject(parent) - { - } - ~QQuickLocalStorage() override { - } - - Q_INVOKABLE void openDatabaseSync(QQmlV4Function* args); -}; - -void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args) -{ -#if QT_CONFIG(settings) - QV4::Scope scope(args->v4engine()); - if (scope.engine->qmlEngine()->offlineStoragePath().isEmpty()) - V4THROW_SQL2(SQLEXCEPTION_DATABASE_ERR, QQmlEngine::tr("SQL: can't create database, offline storage is disabled.")); - - QV4::ScopedValue v(scope); - QString dbname = (v = (*args)[0])->toQStringNoThrow(); - QString dbversion = (v = (*args)[1])->toQStringNoThrow(); - QString dbdescription = (v = (*args)[2])->toQStringNoThrow(); - int dbestimatedsize = (v = (*args)[3])->toInt32(); - FunctionObject *dbcreationCallback = (v = (*args)[4])->as<FunctionObject>(); - QString basename = args->v4engine()->qmlEngine()->offlineStorageDatabaseFilePath(dbname); - QFileInfo dbFile(basename); - if (!QDir().mkpath(dbFile.dir().absolutePath())) { - const QString message = QQmlEngine::tr("LocalStorage: can't create path %1"). - arg(QDir::toNativeSeparators(dbFile.dir().absolutePath())); - V4THROW_SQL2(SQLEXCEPTION_DATABASE_ERR, message); - } - QString dbid = dbFile.fileName(); - bool created = false; - QString version = dbversion; - QSqlDatabase database; - - { - QSettings ini(basename+QLatin1String(".ini"),QSettings::IniFormat); - - if (QSqlDatabase::connectionNames().contains(dbid)) { - database = QSqlDatabase::database(dbid); - version = ini.value(QLatin1String("Version")).toString(); - if (version != dbversion && !dbversion.isEmpty() && !version.isEmpty()) - V4THROW_SQL2(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("SQL: database version mismatch")); - } else { - created = !QFile::exists(basename+QLatin1String(".sqlite")); - if (created) { - ini.setValue(QLatin1String("Name"), dbname); - if (dbcreationCallback) - version = QString(); - ini.setValue(QLatin1String("Version"), version); - ini.setValue(QLatin1String("Description"), dbdescription); - ini.setValue(QLatin1String("EstimatedSize"), dbestimatedsize); - ini.setValue(QLatin1String("Driver"), QLatin1String("QSQLITE")); - } else { - if (!dbversion.isEmpty() && ini.value(QLatin1String("Version")) != dbversion) { - // Incompatible - V4THROW_SQL2(SQLEXCEPTION_VERSION_ERR,QQmlEngine::tr("SQL: database version mismatch")); - } - version = ini.value(QLatin1String("Version")).toString(); - } - database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid); - database.setDatabaseName(basename+QLatin1String(".sqlite")); - } - if (!database.isOpen()) - database.open(); - } - - QV4::Scoped<QQmlSqlDatabaseWrapper> db(scope, QQmlSqlDatabaseWrapper::create(scope.engine)); - QV4::ScopedObject p(scope, databaseData(scope.engine)->databaseProto.value()); - db->setPrototypeUnchecked(p.getPointer()); - *db->d()->database = database; - *db->d()->version = version; - - if (created && dbcreationCallback) { - JSCallData jsCall(scope, 1); - *jsCall->thisObject = scope.engine->globalObject; - jsCall->args[0] = db; - dbcreationCallback->call(jsCall); - } - - args->setReturnValue(db.asReturnedValue()); -#else - Q_UNUSED(args) -#endif // settings -} - -static QObject *module_api_factory(QQmlEngine *engine, QJSEngine *scriptEngine) -{ - Q_UNUSED(engine) - Q_UNUSED(scriptEngine) - QQuickLocalStorage *api = new QQuickLocalStorage(); - - return api; -} - class QQmlLocalStoragePlugin : public QQmlExtensionPlugin { Q_OBJECT @@ -823,7 +56,7 @@ public: void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.LocalStorage")); - qmlRegisterSingletonType<QQuickLocalStorage>(uri, 2, 0, "LocalStorage", module_api_factory); + qmlRegisterTypesAndRevisions<QQuickLocalStorage>(uri, 2); qmlRegisterModule(uri, 2, 15); } diff --git a/src/imports/localstorage/qquicklocalstorage.cpp b/src/imports/localstorage/qquicklocalstorage.cpp new file mode 100644 index 0000000000..333e697e3c --- /dev/null +++ b/src/imports/localstorage/qquicklocalstorage.cpp @@ -0,0 +1,792 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qquicklocalstorage_p.h" + +#include <QtQml/private/qqmlengine_p.h> +#include <QtQml/private/qv4global_p.h> +#include <QtQml/private/qv4scopedvalue_p.h> +#include <QtQml/private/qv4object_p.h> +#include <QtQml/private/qv4sqlerrors_p.h> +#include <QtQml/private/qv4jscall_p.h> +#include <QtQml/private/qv4objectiterator_p.h> + +#include <QtCore/qfileinfo.h> +#include <QtCore/qdir.h> + +#include <QtSql/qsqldatabase.h> +#include <QtSql/qsqlquery.h> +#include <QtSql/qsqlrecord.h> +#include <QtSql/qsqlerror.h> + +#if QT_CONFIG(settings) +#include <QtCore/qsettings.h> +#endif + +QT_BEGIN_NAMESPACE + +#define V4THROW_SQL(error, desc) { \ + QV4::ScopedString v(scope, scope.engine->newString(desc)); \ + QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \ + ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Value::fromInt32(error))); \ + scope.engine->throwError(ex); \ + RETURN_UNDEFINED(); \ +} + +#define V4THROW_SQL2(error, desc) { \ + QV4::ScopedString v(scope, scope.engine->newString(desc)); \ + QV4::ScopedObject ex(scope, scope.engine->newErrorObject(v)); \ + ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, Value::fromInt32(error))); \ + args->setReturnValue(scope.engine->throwError(ex)); \ + return; \ +} + +#define V4THROW_REFERENCE(string) { \ + QV4::ScopedString v(scope, scope.engine->newString(string)); \ + scope.engine->throwReferenceError(v); \ + RETURN_UNDEFINED(); \ +} + + +class QQmlSqlDatabaseData : public QV4::ExecutionEngine::Deletable +{ +public: + QQmlSqlDatabaseData(QV4::ExecutionEngine *engine); + ~QQmlSqlDatabaseData() override; + + QV4::PersistentValue databaseProto; + QV4::PersistentValue queryProto; + QV4::PersistentValue rowsProto; +}; + +V4_DEFINE_EXTENSION(QQmlSqlDatabaseData, databaseData) + +namespace QV4 { + +namespace Heap { + struct QQmlSqlDatabaseWrapper : public Object { + enum Type { Database, Query, Rows }; + void init() + { + Object::init(); + type = Database; + database = new QSqlDatabase; + version = new QString; + sqlQuery = new QSqlQuery; + } + + void destroy() { + delete database; + delete version; + delete sqlQuery; + Object::destroy(); + } + + Type type; + QSqlDatabase *database; + + QString *version; // type == Database + + bool inTransaction; // type == Query + bool readonly; // type == Query + + QSqlQuery *sqlQuery; // type == Rows + bool forwardOnly; // type == Rows + }; +} + +class QQmlSqlDatabaseWrapper : public Object +{ +public: + V4_OBJECT2(QQmlSqlDatabaseWrapper, Object) + V4_NEEDS_DESTROY + + static Heap::QQmlSqlDatabaseWrapper *create(QV4::ExecutionEngine *engine) + { + return engine->memoryManager->allocate<QQmlSqlDatabaseWrapper>(); + } + + ~QQmlSqlDatabaseWrapper() { + } + + static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); +}; + +} + +using namespace QV4; + +DEFINE_OBJECT_VTABLE(QV4::QQmlSqlDatabaseWrapper); + + + +static ReturnedValue qmlsqldatabase_version(const FunctionObject *b, const Value *thisObject, const QV4::Value *, int) +{ + Scope scope(b); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); + if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) + V4THROW_REFERENCE("Not a SQLDatabase object"); + + RETURN_RESULT(Encode(scope.engine->newString(*r->d()->version))); +} + +static ReturnedValue qmlsqldatabase_rows_length(const FunctionObject *b, const Value *thisObject, const QV4::Value *, int) +{ + Scope scope(b); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); + if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) + V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); + + int s = r->d()->sqlQuery->size(); + if (s < 0) { + // Inefficient + if (r->d()->sqlQuery->last()) { + s = r->d()->sqlQuery->at() + 1; + } else { + s = 0; + } + } + RETURN_RESULT(Encode(s)); +} + +static ReturnedValue qmlsqldatabase_rows_forwardOnly(const FunctionObject *b, const Value *thisObject, const QV4::Value *, int) +{ + Scope scope(b); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); + if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) + V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); + RETURN_RESULT(Encode(r->d()->sqlQuery->isForwardOnly())); +} + +static ReturnedValue qmlsqldatabase_rows_setForwardOnly(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) +{ + Scope scope(b); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); + if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) + V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); + if (argc < 1) + RETURN_RESULT(scope.engine->throwTypeError()); + + r->d()->sqlQuery->setForwardOnly(argv[0].toBoolean()); + RETURN_UNDEFINED(); +} + +QQmlSqlDatabaseData::~QQmlSqlDatabaseData() +{ +} + +static ReturnedValue qmlsqldatabase_rows_index(const QQmlSqlDatabaseWrapper *r, ExecutionEngine *v4, quint32 index, bool *hasProperty = nullptr) +{ + Scope scope(v4); + + if (r->d()->sqlQuery->at() == (int)index || r->d()->sqlQuery->seek(index)) { + QSqlRecord record = r->d()->sqlQuery->record(); + // XXX optimize + ScopedObject row(scope, v4->newObject()); + for (int ii = 0; ii < record.count(); ++ii) { + QVariant v = record.value(ii); + ScopedString s(scope, v4->newIdentifier(record.fieldName(ii))); + ScopedValue val(scope, v.isNull() ? Encode::null() : v4->fromVariant(v)); + row->put(s.getPointer(), val); + } + if (hasProperty) + *hasProperty = true; + return row.asReturnedValue(); + } else { + if (hasProperty) + *hasProperty = false; + return Encode::undefined(); + } +} + +ReturnedValue QQmlSqlDatabaseWrapper::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) +{ + if (!id.isArrayIndex()) + return Object::virtualGet(m, id, receiver, hasProperty); + + uint index = id.asArrayIndex(); + Q_ASSERT(m->as<QQmlSqlDatabaseWrapper>()); + const QQmlSqlDatabaseWrapper *r = static_cast<const QQmlSqlDatabaseWrapper *>(m); + if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) + return Object::virtualGet(m, id, receiver, hasProperty); + + return qmlsqldatabase_rows_index(r, r->engine(), index, hasProperty); +} + +static ReturnedValue qmlsqldatabase_rows_item(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) +{ + Scope scope(b); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); + if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) + V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); + + RETURN_RESULT(qmlsqldatabase_rows_index(r, scope.engine, argc ? argv[0].toUInt32() : 0)); +} + +static QVariant toSqlVariant(QV4::ExecutionEngine *engine, const QV4::ScopedValue &value) +{ + // toVariant() maps a null JS value to QVariant(VoidStar), but the SQL module + // expects a null variant. (this is because of QTBUG-40880) + if (value->isNull()) + return QVariant(); + return engine->toVariant(value, /*typehint*/-1); +} + +static ReturnedValue qmlsqldatabase_executeSql(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) +{ + Scope scope(b); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); + if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Query) + V4THROW_REFERENCE("Not a SQLDatabase::Query object"); + + if (!r->d()->inTransaction) + V4THROW_SQL(SQLEXCEPTION_DATABASE_ERR,QQmlEngine::tr("executeSql called outside transaction()")); + + QSqlDatabase db = *r->d()->database; + + QString sql = argc ? argv[0].toQString() : QString(); + + if (r->d()->readonly && !sql.startsWith(QLatin1String("SELECT"),Qt::CaseInsensitive)) { + V4THROW_SQL(SQLEXCEPTION_SYNTAX_ERR, QQmlEngine::tr("Read-only Transaction")); + } + + QSqlQuery query(db); + bool err = false; + + ScopedValue result(scope, Value::undefinedValue()); + + if (query.prepare(sql)) { + if (argc > 1) { + ScopedValue values(scope, argv[1]); + if (values->as<ArrayObject>()) { + ScopedArrayObject array(scope, values); + quint32 size = array->getLength(); + QV4::ScopedValue v(scope); + for (quint32 ii = 0; ii < size; ++ii) { + query.bindValue(ii, toSqlVariant(scope.engine, (v = array->get(ii)))); + } + } else if (values->as<Object>()) { + ScopedObject object(scope, values); + ObjectIterator it(scope, object, ObjectIterator::EnumerableOnly); + ScopedValue key(scope); + QV4::ScopedValue val(scope); + while (1) { + key = it.nextPropertyName(val); + if (key->isNull()) + break; + QVariant v = toSqlVariant(scope.engine, val); + if (key->isString()) { + query.bindValue(key->stringValue()->toQString(), v); + } else { + Q_ASSERT(key->isInteger()); + query.bindValue(key->integerValue(), v); + } + } + } else { + query.bindValue(0, toSqlVariant(scope.engine, values)); + } + } + if (query.exec()) { + QV4::Scoped<QQmlSqlDatabaseWrapper> rows(scope, QQmlSqlDatabaseWrapper::create(scope.engine)); + QV4::ScopedObject p(scope, databaseData(scope.engine)->rowsProto.value()); + rows->setPrototypeUnchecked(p.getPointer()); + rows->d()->type = Heap::QQmlSqlDatabaseWrapper::Rows; + *rows->d()->database = db; + *rows->d()->sqlQuery = query; + + ScopedObject resultObject(scope, scope.engine->newObject()); + result = resultObject.asReturnedValue(); + // XXX optimize + ScopedString s(scope); + ScopedValue v(scope); + resultObject->put((s = scope.engine->newIdentifier("rowsAffected")).getPointer(), (v = Value::fromInt32(query.numRowsAffected()))); + resultObject->put((s = scope.engine->newIdentifier("insertId")).getPointer(), (v = scope.engine->newString(query.lastInsertId().toString()))); + resultObject->put((s = scope.engine->newIdentifier("rows")).getPointer(), rows); + } else { + err = true; + } + } else { + err = true; + } + if (err) + V4THROW_SQL(SQLEXCEPTION_DATABASE_ERR,query.lastError().text()); + + RETURN_RESULT(result->asReturnedValue()); +} + +struct TransactionRollback { + QSqlDatabase *db; + bool *inTransactionFlag; + + TransactionRollback(QSqlDatabase *database, bool *transactionFlag) + : db(database) + , inTransactionFlag(transactionFlag) + { + if (inTransactionFlag) + *inTransactionFlag = true; + } + + ~TransactionRollback() + { + if (inTransactionFlag) + *inTransactionFlag = false; + if (db) + db->rollback(); + } + + void clear() { + db = nullptr; + if (inTransactionFlag) + *inTransactionFlag = false; + inTransactionFlag = nullptr; + } +}; + + +static ReturnedValue qmlsqldatabase_changeVersion(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) +{ + Scope scope(b); + if (argc < 2) + RETURN_UNDEFINED(); + + Scoped<QQmlSqlDatabaseWrapper> r(scope, *thisObject); + if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) + V4THROW_REFERENCE("Not a SQLDatabase object"); + + QSqlDatabase db = *r->d()->database; + QString from_version = argv[0].toQString(); + QString to_version = argv[1].toQString(); + ScopedFunctionObject callback(scope, argc > 2 ? argv[2] : Value::undefinedValue()); + + if (from_version != *r->d()->version) + V4THROW_SQL(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("Version mismatch: expected %1, found %2").arg(from_version).arg(*r->d()->version)); + + bool ok = true; + if (!!callback) { + Scoped<QQmlSqlDatabaseWrapper> query(scope, QQmlSqlDatabaseWrapper::create(scope.engine)); + ScopedObject p(scope, databaseData(scope.engine)->queryProto.value()); + query->setPrototypeUnchecked(p.getPointer()); + query->d()->type = Heap::QQmlSqlDatabaseWrapper::Query; + *query->d()->database = db; + *query->d()->version = *r->d()->version; + + ok = false; + db.transaction(); + + JSCallData jsCall(scope, 1); + *jsCall->thisObject = scope.engine->globalObject; + jsCall->args[0] = query; + + TransactionRollback rollbackOnException(&db, &query->d()->inTransaction); + callback->call(jsCall); + rollbackOnException.clear(); + if (!db.commit()) { + db.rollback(); + V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR,QQmlEngine::tr("SQL transaction failed")); + } else { + ok = true; + } + } + + if (ok) { + Scoped<QQmlSqlDatabaseWrapper> w(scope, QQmlSqlDatabaseWrapper::create(scope.engine)); + ScopedObject p(scope, databaseData(scope.engine)->databaseProto.value()); + w->setPrototypeUnchecked(p.getPointer()); + w->d()->type = Heap::QQmlSqlDatabaseWrapper::Database; + *w->d()->database = db; + *w->d()->version = to_version; +#if QT_CONFIG(settings) + const QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(scope.engine->qmlEngine()); + QSettings ini(enginePrivate->offlineStorageDatabaseDirectory() + db.connectionName() + QLatin1String(".ini"), QSettings::IniFormat); + ini.setValue(QLatin1String("Version"), to_version); +#endif + RETURN_RESULT(w.asReturnedValue()); + } + + RETURN_UNDEFINED(); +} + +static ReturnedValue qmlsqldatabase_transaction_shared(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc, bool readOnly) +{ + Scope scope(b); + QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, thisObject->as<QQmlSqlDatabaseWrapper>()); + if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) + V4THROW_REFERENCE("Not a SQLDatabase object"); + + const FunctionObject *callback = argc ? argv[0].as<FunctionObject>() : nullptr; + if (!callback) + V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR, QQmlEngine::tr("transaction: missing callback")); + + QSqlDatabase db = *r->d()->database; + + Scoped<QQmlSqlDatabaseWrapper> w(scope, QQmlSqlDatabaseWrapper::create(scope.engine)); + QV4::ScopedObject p(scope, databaseData(scope.engine)->queryProto.value()); + w->setPrototypeUnchecked(p.getPointer()); + w->d()->type = Heap::QQmlSqlDatabaseWrapper::Query; + *w->d()->database = db; + *w->d()->version = *r->d()->version; + w->d()->readonly = readOnly; + + db.transaction(); + if (callback) { + JSCallData jsCall(scope, 1); + *jsCall->thisObject = scope.engine->globalObject; + jsCall->args[0] = w; + TransactionRollback rollbackOnException(&db, &w->d()->inTransaction); + callback->call(jsCall); + rollbackOnException.clear(); + + if (!db.commit()) + db.rollback(); + } + + RETURN_UNDEFINED(); +} + +static ReturnedValue qmlsqldatabase_transaction(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) +{ + return qmlsqldatabase_transaction_shared(f, thisObject, argv, argc, false); +} + +static ReturnedValue qmlsqldatabase_read_transaction(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) +{ + return qmlsqldatabase_transaction_shared(f, thisObject, argv, argc, true); +} + +QQmlSqlDatabaseData::QQmlSqlDatabaseData(ExecutionEngine *v4) +{ + Scope scope(v4); + { + ScopedObject proto(scope, v4->newObject()); + proto->defineDefaultProperty(QStringLiteral("transaction"), qmlsqldatabase_transaction); + proto->defineDefaultProperty(QStringLiteral("readTransaction"), qmlsqldatabase_read_transaction); + proto->defineAccessorProperty(QStringLiteral("version"), qmlsqldatabase_version, nullptr); + proto->defineDefaultProperty(QStringLiteral("changeVersion"), qmlsqldatabase_changeVersion); + databaseProto = proto; + } + + { + ScopedObject proto(scope, v4->newObject()); + proto->defineDefaultProperty(QStringLiteral("executeSql"), qmlsqldatabase_executeSql); + queryProto = proto; + } + { + ScopedObject proto(scope, v4->newObject()); + proto->defineDefaultProperty(QStringLiteral("item"), qmlsqldatabase_rows_item); + proto->defineAccessorProperty(QStringLiteral("length"), qmlsqldatabase_rows_length, nullptr); + proto->defineAccessorProperty(QStringLiteral("forwardOnly"), + qmlsqldatabase_rows_forwardOnly, qmlsqldatabase_rows_setForwardOnly); + rowsProto = proto; + } +} + +/* +HTML5 "spec" says "rs.rows[n]", but WebKit only impelments "rs.rows.item(n)". We do both (and property iterator). +We add a "forwardOnly" property that stops Qt caching results (code promises to only go forward +through the data. +*/ + + +/*! + \qmlmodule QtQuick.LocalStorage 2.\QtMinorVersion + \title Qt Quick Local Storage QML Types + \ingroup qmlmodules + \brief Provides a JavaScript object singleton type for accessing a local + SQLite database + + This is a singleton type for reading and writing to SQLite databases. + + + \section1 Methods + + \list + \li object \b{\l{#openDatabaseSync}{openDatabaseSync}}(string name, string version, string description, int estimated_size, jsobject callback(db)) + \endlist + + + \section1 Detailed Description + + To use the types in this module, import the module and call the + relevant functions using the \c LocalStorage type: + + \qml \QtMinorVersion + import QtQuick 2.\1 + import QtQuick.LocalStorage 2.\1 + + Item { + Component.onCompleted: { + var db = LocalStorage.openDatabaseSync(...) + } + } + \endqml + + +These databases are user-specific and QML-specific, but accessible to all QML applications. +They are stored in the \c Databases subdirectory +of QQmlEngine::offlineStoragePath(), currently as SQLite databases. + +Database connections are automatically closed during Javascript garbage collection. + +The API can be used from JavaScript functions in your QML: + +\snippet qml/localstorage/hello.qml 0 + +The API conforms to the Synchronous API of the HTML5 Web Database API, +\link http://www.w3.org/TR/2009/WD-webdatabase-20091029/ W3C Working Draft 29 October 2009\endlink. + +The \l{Qt Quick Examples - Local Storage}{SQL Local Storage example} demonstrates the basics of +using the Offline Storage API. + +\section3 Open or Create a Database + +\qml \QtMinorVersion +import QtQuick.LocalStorage 2.\1 as Sql + +db = Sql.openDatabaseSync(identifier, version, description, estimated_size, callback(db)) +\endqml + +The above code returns the database identified by \e identifier. If the database does not already exist, it +is created, and the function \e callback is called with the database as a parameter. \e identifier is the +name of the physical file (with or without full path) containing the database. \e description and +\e estimated_size are written to the INI file (described below), but are currently unused. + +May throw exception with code property SQLException.DATABASE_ERR, or SQLException.VERSION_ERR. + +When a database is first created, an INI file is also created specifying its characteristics: + +\table +\header \li \b {Key} \li \b {Value} +\row \li Identifier \li The name of the database passed to \c openDatabase() +\row \li Version \li The version of the database passed to \c openDatabase() +\row \li Description \li The description of the database passed to \c openDatabase() +\row \li EstimatedSize \li The estimated size (in bytes) of the database passed to \c openDatabase() +\row \li Driver \li Currently "QSQLITE" +\endtable + +This data can be used by application tools. + +\section3 db.changeVersion(from, to, callback(tx)) + +This method allows you to perform a \e{Scheme Upgrade}. If it succeeds it returns a new +database object of version \e to. Otherwise it returns \e undefined. + +If the current version of \e db is not \e from, then an exception is thrown. + +Otherwise, a database transaction is created and passed to \e callback. In this function, +you can call \e executeSql on \e tx to upgrade the database. + +May throw exception with code property SQLException.DATABASE_ERR or SQLException.UNKNOWN_ERR. + +See example below. + +\badcode + var db = LocalStorage.openDatabaseSync("ActivityTrackDB", "", "Database tracking sports activities", 1000000); + if (db.version == "0.1") { + db.changeVersion("0.1", "0.2", function(tx) { + tx.executeSql("INSERT INTO trip_log VALUES(?, ?, ?)", + [ "01/10/2016","Sylling - Vikersund", "53" ]); + } + }); +\endcode + +\section3 db.transaction(callback(tx)) + +This method creates a read/write transaction and passed to \e callback. In this function, +you can call \e executeSql on \e tx to read and modify the database. + +If the callback throws exceptions, the transaction is rolled back. +Below you will find an example of a database transaction which catches exceptions. + + +\quotefromfile localstorage/localstorage/Database.js +\skipuntil dbInit() +\printto dbGetHandle + +In the example you can see an \c insert statement where values are assigned to the fields, +and the record is written into the table. That is an \c insert statement with a syntax that is usual +for a relational database. It is however also possible to work with JSON objects and +store them in a table. + +Let's suppose a simple example where we store trips in JSON format using \c date as the unique key. +An example of a table that could be used for that purpose: + +\badcode + create table trip_log(date text, data text) +\endcode + +The assignment of values to a JSON object: + +\badcode + var obj = {description = "Vikersund - Noresund", distance = "60"} +\endcode + +In that case, the data could be saved in the following way: + +\badcode + db.transaction(function(tx) { + result = tx.executeSQL("insert into trip_log values (?,?)", + ["01/11/2016", JSON.stringify(obj)]) + +\endcode + +\section3 db.readTransaction(callback(tx)) + +This method creates a read-only transaction and passed to \e callback. In this function, +you can call \e executeSql on \e tx to read the database (with \c select statements). + +\section3 results = tx.executeSql(statement, values) + +This method executes an SQL \e statement, binding the list of \e values to SQL positional parameters ("?"). + +It returns a results object, with the following properties: + +\table +\header \li \b {Type} \li \b {Property} \li \b {Value} \li \b {Applicability} +\row \li int \li rows.length \li The number of rows in the result \li SELECT +\row \li var \li rows.item(i) \li Function that returns row \e i of the result \li SELECT +\row \li int \li rowsAffected \li The number of rows affected by a modification \li UPDATE, DELETE +\row \li string \li insertId \li The id of the row inserted \li INSERT +\endtable + +May throw exception with code property SQLException.DATABASE_ERR, SQLException.SYNTAX_ERR, or SQLException.UNKNOWN_ERR. + +See below for an example: + +\quotefromfile localstorage/localstorage/Database.js +\skipto dbReadAll() +\printto dbUpdate(Pdate + +\section1 Method Documentation + +\target openDatabaseSync +\code +object openDatabaseSync(string name, string version, string description, int estimated_size, jsobject callback(db)) +\endcode + +Opens or creates a local storage sql database by the given parameters. + +\list +\li \c name is the database name +\li \c version is the database version +\li \c description is the database display name +\li \c estimated_size is the database's estimated size, in bytes +\li \c callback is an optional parameter, which is invoked if the database has not yet been created. +\endlist + +Returns the created database object. + +*/ + +void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args) +{ +#if QT_CONFIG(settings) + QV4::Scope scope(args->v4engine()); + if (scope.engine->qmlEngine()->offlineStoragePath().isEmpty()) + V4THROW_SQL2(SQLEXCEPTION_DATABASE_ERR, QQmlEngine::tr("SQL: can't create database, offline storage is disabled.")); + + QV4::ScopedValue v(scope); + QString dbname = (v = (*args)[0])->toQStringNoThrow(); + QString dbversion = (v = (*args)[1])->toQStringNoThrow(); + QString dbdescription = (v = (*args)[2])->toQStringNoThrow(); + int dbestimatedsize = (v = (*args)[3])->toInt32(); + FunctionObject *dbcreationCallback = (v = (*args)[4])->as<FunctionObject>(); + QString basename = args->v4engine()->qmlEngine()->offlineStorageDatabaseFilePath(dbname); + QFileInfo dbFile(basename); + if (!QDir().mkpath(dbFile.dir().absolutePath())) { + const QString message = QQmlEngine::tr("LocalStorage: can't create path %1"). + arg(QDir::toNativeSeparators(dbFile.dir().absolutePath())); + V4THROW_SQL2(SQLEXCEPTION_DATABASE_ERR, message); + } + QString dbid = dbFile.fileName(); + bool created = false; + QString version = dbversion; + QSqlDatabase database; + + { + QSettings ini(basename+QLatin1String(".ini"),QSettings::IniFormat); + + if (QSqlDatabase::connectionNames().contains(dbid)) { + database = QSqlDatabase::database(dbid); + version = ini.value(QLatin1String("Version")).toString(); + if (version != dbversion && !dbversion.isEmpty() && !version.isEmpty()) + V4THROW_SQL2(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("SQL: database version mismatch")); + } else { + created = !QFile::exists(basename+QLatin1String(".sqlite")); + if (created) { + ini.setValue(QLatin1String("Name"), dbname); + if (dbcreationCallback) + version = QString(); + ini.setValue(QLatin1String("Version"), version); + ini.setValue(QLatin1String("Description"), dbdescription); + ini.setValue(QLatin1String("EstimatedSize"), dbestimatedsize); + ini.setValue(QLatin1String("Driver"), QLatin1String("QSQLITE")); + } else { + if (!dbversion.isEmpty() && ini.value(QLatin1String("Version")) != dbversion) { + // Incompatible + V4THROW_SQL2(SQLEXCEPTION_VERSION_ERR,QQmlEngine::tr("SQL: database version mismatch")); + } + version = ini.value(QLatin1String("Version")).toString(); + } + database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid); + database.setDatabaseName(basename+QLatin1String(".sqlite")); + } + if (!database.isOpen()) + database.open(); + } + + QV4::Scoped<QQmlSqlDatabaseWrapper> db(scope, QQmlSqlDatabaseWrapper::create(scope.engine)); + QV4::ScopedObject p(scope, databaseData(scope.engine)->databaseProto.value()); + db->setPrototypeUnchecked(p.getPointer()); + *db->d()->database = database; + *db->d()->version = version; + + if (created && dbcreationCallback) { + JSCallData jsCall(scope, 1); + *jsCall->thisObject = scope.engine->globalObject; + jsCall->args[0] = db; + dbcreationCallback->call(jsCall); + } + + args->setReturnValue(db.asReturnedValue()); +#else + Q_UNUSED(args) +#endif // settings +} + +QT_END_NAMESPACE diff --git a/src/imports/localstorage/qquicklocalstorage_p.h b/src/imports/localstorage/qquicklocalstorage_p.h new file mode 100644 index 0000000000..d2ebc85ce9 --- /dev/null +++ b/src/imports/localstorage/qquicklocalstorage_p.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKLOCALSTORAGE_P_H +#define QQUICKLOCALSTORAGE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtQml/qqml.h> +#include <QtQml/private/qv4engine_p.h> + +QT_BEGIN_NAMESPACE + +class QQuickLocalStorage : public QObject +{ + Q_OBJECT + QML_NAMED_ELEMENT(LocalStorage) + QML_SINGLETON + +public: + QQuickLocalStorage(QObject *parent = nullptr) : QObject(parent) {} + ~QQuickLocalStorage() override = default; + + Q_INVOKABLE void openDatabaseSync(QQmlV4Function* args); +}; + +QT_END_NAMESPACE + +#endif // QQUICKLOCALSTORAGE_P_H diff --git a/src/imports/models/plugins.qmltypes b/src/imports/models/plugins.qmltypes index 0d8b94df23..89a839e502 100644 --- a/src/imports/models/plugins.qmltypes +++ b/src/imports/models/plugins.qmltypes @@ -398,7 +398,7 @@ Module { defaultProperty: "delegate" prototype: "QQmlInstanceModel" exports: ["QtQml.Models/DelegateModel 2.1"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [1] attachedType: "QQmlDelegateModelAttached" Property { name: "model"; type: "QVariant" } Property { name: "delegate"; type: "QQmlComponent"; isPointer: true } @@ -434,7 +434,7 @@ Module { name: "QQmlDelegateModelGroup" prototype: "QObject" exports: ["QtQml.Models/DelegateModelGroup 2.1"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [1] Property { name: "count"; type: "int"; isReadonly: true } Property { name: "name"; type: "string" } Property { name: "includeByDefault"; type: "bool" } @@ -484,16 +484,68 @@ Module { } Component { name: "QQmlDelegateModelParts"; prototype: "QObject" } Component { + name: "QQmlInstanceModel" + prototype: "QObject" + Property { name: "count"; type: "int"; isReadonly: true } + Signal { + name: "modelUpdated" + Parameter { name: "changeSet"; type: "QQmlChangeSet" } + Parameter { name: "reset"; type: "bool" } + } + Signal { + name: "createdItem" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Signal { + name: "initItem" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Signal { + name: "destroyingItem" + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + } + Component { + name: "QQmlInstantiator" + defaultProperty: "delegate" + prototype: "QObject" + exports: ["QtQml.Models/Instantiator 2.14"] + exportMetaObjectRevisions: [0] + Property { name: "active"; type: "bool" } + Property { name: "asynchronous"; type: "bool" } + Property { name: "model"; type: "QVariant" } + Property { name: "count"; type: "int"; isReadonly: true } + Property { name: "delegate"; type: "QQmlComponent"; isPointer: true } + Property { name: "object"; type: "QObject"; isReadonly: true; isPointer: true } + Signal { + name: "objectAdded" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Signal { + name: "objectRemoved" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Method { + name: "objectAt" + type: "QObject*" + Parameter { name: "index"; type: "int" } + } + } + Component { name: "QQmlListElement" prototype: "QObject" exports: ["QtQml.Models/ListElement 2.1"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [1] } Component { name: "QQmlListModel" prototype: "QAbstractListModel" - exports: ["QtQml.Models/ListModel 2.1"] - exportMetaObjectRevisions: [0] + exports: ["QtQml.Models/ListModel 2.1", "QtQml.Models/ListModel 2.14"] + exportMetaObjectRevisions: [1, 14] Property { name: "count"; type: "int"; isReadonly: true } Property { name: "dynamicRoles"; type: "bool" } Property { name: "agent"; revision: 14; type: "QObject"; isReadonly: true; isPointer: true } @@ -590,7 +642,7 @@ Module { "QtQml.Models/ObjectModel 2.1", "QtQml.Models/ObjectModel 2.3" ] - exportMetaObjectRevisions: [0, 3] + exportMetaObjectRevisions: [1, 3] attachedType: "QQmlObjectModelAttached" Property { name: "children"; type: "QObject"; isList: true; isReadonly: true } Method { name: "clear"; revision: 3 } @@ -646,7 +698,7 @@ Module { defaultProperty: "data" prototype: "QObject" exports: ["QtQml.Models/Package 2.14"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [14] attachedType: "QQuickPackageAttached" Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } } diff --git a/src/imports/particles/plugins.qmltypes b/src/imports/particles/plugins.qmltypes index 0fe5dc808c..48da0b26ed 100644 --- a/src/imports/particles/plugins.qmltypes +++ b/src/imports/particles/plugins.qmltypes @@ -12,8 +12,14 @@ Module { name: "QQuickAgeAffector" defaultProperty: "data" prototype: "QQuickParticleAffector" - exports: ["QtQuick.Particles/Age 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/Age 2.0", + "QtQuick.Particles/Age 2.1", + "QtQuick.Particles/Age 2.11", + "QtQuick.Particles/Age 2.4", + "QtQuick.Particles/Age 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "lifeLeft"; type: "int" } Property { name: "advancePosition"; type: "bool" } Signal { @@ -79,8 +85,14 @@ Module { name: "QQuickAttractorAffector" defaultProperty: "data" prototype: "QQuickParticleAffector" - exports: ["QtQuick.Particles/Attractor 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/Attractor 2.0", + "QtQuick.Particles/Attractor 2.1", + "QtQuick.Particles/Attractor 2.11", + "QtQuick.Particles/Attractor 2.4", + "QtQuick.Particles/Attractor 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Enum { name: "Proportion" values: { @@ -157,8 +169,14 @@ Module { name: "QQuickCustomAffector" defaultProperty: "data" prototype: "QQuickParticleAffector" - exports: ["QtQuick.Particles/Affector 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/Affector 2.0", + "QtQuick.Particles/Affector 2.1", + "QtQuick.Particles/Affector 2.11", + "QtQuick.Particles/Affector 2.4", + "QtQuick.Particles/Affector 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "relative"; type: "bool" } Property { name: "position"; type: "QQuickDirection"; isPointer: true } Property { name: "velocity"; type: "QQuickDirection"; isPointer: true } @@ -205,8 +223,14 @@ Module { name: "QQuickCustomParticle" defaultProperty: "data" prototype: "QQuickParticlePainter" - exports: ["QtQuick.Particles/CustomParticle 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/CustomParticle 2.0", + "QtQuick.Particles/CustomParticle 2.1", + "QtQuick.Particles/CustomParticle 2.11", + "QtQuick.Particles/CustomParticle 2.4", + "QtQuick.Particles/CustomParticle 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "fragmentShader"; type: "QByteArray" } Property { name: "vertexShader"; type: "QByteArray" } } @@ -236,8 +260,14 @@ Module { name: "QQuickFrictionAffector" defaultProperty: "data" prototype: "QQuickParticleAffector" - exports: ["QtQuick.Particles/Friction 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/Friction 2.0", + "QtQuick.Particles/Friction 2.1", + "QtQuick.Particles/Friction 2.11", + "QtQuick.Particles/Friction 2.4", + "QtQuick.Particles/Friction 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "factor"; type: "double" } Property { name: "threshold"; type: "double" } Signal { @@ -261,8 +291,14 @@ Module { name: "QQuickGravityAffector" defaultProperty: "data" prototype: "QQuickParticleAffector" - exports: ["QtQuick.Particles/Gravity 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/Gravity 2.0", + "QtQuick.Particles/Gravity 2.1", + "QtQuick.Particles/Gravity 2.11", + "QtQuick.Particles/Gravity 2.4", + "QtQuick.Particles/Gravity 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "magnitude"; type: "double" } Property { name: "acceleration"; type: "double" } Property { name: "angle"; type: "double" } @@ -291,8 +327,14 @@ Module { name: "QQuickGroupGoalAffector" defaultProperty: "data" prototype: "QQuickParticleAffector" - exports: ["QtQuick.Particles/GroupGoal 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/GroupGoal 2.0", + "QtQuick.Particles/GroupGoal 2.1", + "QtQuick.Particles/GroupGoal 2.11", + "QtQuick.Particles/GroupGoal 2.4", + "QtQuick.Particles/GroupGoal 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "goalState"; type: "string" } Property { name: "jump"; type: "bool" } Signal { @@ -316,8 +358,14 @@ Module { name: "QQuickImageParticle" defaultProperty: "data" prototype: "QQuickParticlePainter" - exports: ["QtQuick.Particles/ImageParticle 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/ImageParticle 2.0", + "QtQuick.Particles/ImageParticle 2.1", + "QtQuick.Particles/ImageParticle 2.11", + "QtQuick.Particles/ImageParticle 2.4", + "QtQuick.Particles/ImageParticle 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Enum { name: "Status" values: { @@ -495,8 +543,14 @@ Module { name: "QQuickItemParticle" defaultProperty: "data" prototype: "QQuickParticlePainter" - exports: ["QtQuick.Particles/ItemParticle 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/ItemParticle 2.0", + "QtQuick.Particles/ItemParticle 2.1", + "QtQuick.Particles/ItemParticle 2.11", + "QtQuick.Particles/ItemParticle 2.4", + "QtQuick.Particles/ItemParticle 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] attachedType: "QQuickItemParticleAttached" Property { name: "fade"; type: "bool" } Property { name: "delegate"; type: "QQmlComponent"; isPointer: true } @@ -575,9 +629,15 @@ Module { name: "QQuickParticleAffector" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick.Particles/ParticleAffector 2.0"] + exports: [ + "QtQuick.Particles/ParticleAffector 2.0", + "QtQuick.Particles/ParticleAffector 2.1", + "QtQuick.Particles/ParticleAffector 2.11", + "QtQuick.Particles/ParticleAffector 2.4", + "QtQuick.Particles/ParticleAffector 2.7" + ] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "system"; type: "QQuickParticleSystem"; isPointer: true } Property { name: "groups"; type: "QStringList" } Property { name: "whenCollidingWith"; type: "QStringList" } @@ -643,8 +703,14 @@ Module { name: "QQuickParticleEmitter" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick.Particles/Emitter 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/Emitter 2.0", + "QtQuick.Particles/Emitter 2.1", + "QtQuick.Particles/Emitter 2.11", + "QtQuick.Particles/Emitter 2.4", + "QtQuick.Particles/Emitter 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Enum { name: "Lifetime" values: { @@ -839,9 +905,15 @@ Module { name: "QQuickParticlePainter" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick.Particles/ParticlePainter 2.0"] + exports: [ + "QtQuick.Particles/ParticlePainter 2.0", + "QtQuick.Particles/ParticlePainter 2.1", + "QtQuick.Particles/ParticlePainter 2.11", + "QtQuick.Particles/ParticlePainter 2.4", + "QtQuick.Particles/ParticlePainter 2.7" + ] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "system"; type: "QQuickParticleSystem"; isPointer: true } Property { name: "groups"; type: "QStringList" } Signal { name: "countChanged" } @@ -871,8 +943,14 @@ Module { name: "QQuickParticleSystem" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick.Particles/ParticleSystem 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/ParticleSystem 2.0", + "QtQuick.Particles/ParticleSystem 2.1", + "QtQuick.Particles/ParticleSystem 2.11", + "QtQuick.Particles/ParticleSystem 2.4", + "QtQuick.Particles/ParticleSystem 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "running"; type: "bool" } Property { name: "paused"; type: "bool" } Property { name: "empty"; type: "bool"; isReadonly: true } @@ -966,8 +1044,14 @@ Module { name: "QQuickSpriteGoalAffector" defaultProperty: "data" prototype: "QQuickParticleAffector" - exports: ["QtQuick.Particles/SpriteGoal 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/SpriteGoal 2.0", + "QtQuick.Particles/SpriteGoal 2.1", + "QtQuick.Particles/SpriteGoal 2.11", + "QtQuick.Particles/SpriteGoal 2.4", + "QtQuick.Particles/SpriteGoal 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "goalState"; type: "string" } Property { name: "jump"; type: "bool" } Property { name: "systemStates"; type: "bool" } @@ -997,6 +1081,56 @@ Module { } } Component { + name: "QQuickStochasticState" + prototype: "QObject" + Property { name: "duration"; type: "int" } + Property { name: "durationVariation"; type: "int" } + Property { name: "randomStart"; type: "bool" } + Property { name: "to"; type: "QVariantMap" } + Property { name: "name"; type: "string" } + Signal { + name: "durationChanged" + Parameter { name: "arg"; type: "int" } + } + Signal { + name: "nameChanged" + Parameter { name: "arg"; type: "string" } + } + Signal { + name: "toChanged" + Parameter { name: "arg"; type: "QVariantMap" } + } + Signal { + name: "durationVariationChanged" + Parameter { name: "arg"; type: "int" } + } + Signal { name: "entered" } + Signal { + name: "randomStartChanged" + Parameter { name: "arg"; type: "bool" } + } + Method { + name: "setDuration" + Parameter { name: "arg"; type: "int" } + } + Method { + name: "setName" + Parameter { name: "arg"; type: "string" } + } + Method { + name: "setTo" + Parameter { name: "arg"; type: "QVariantMap" } + } + Method { + name: "setDurationVariation" + Parameter { name: "arg"; type: "int" } + } + Method { + name: "setRandomStart" + Parameter { name: "arg"; type: "bool" } + } + } + Component { name: "QQuickTargetDirection" prototype: "QQuickDirection" exports: ["QtQuick.Particles/TargetDirection 2.0"] @@ -1069,8 +1203,14 @@ Module { name: "QQuickTrailEmitter" defaultProperty: "data" prototype: "QQuickParticleEmitter" - exports: ["QtQuick.Particles/TrailEmitter 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/TrailEmitter 2.0", + "QtQuick.Particles/TrailEmitter 2.1", + "QtQuick.Particles/TrailEmitter 2.11", + "QtQuick.Particles/TrailEmitter 2.4", + "QtQuick.Particles/TrailEmitter 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Enum { name: "EmitSize" values: { @@ -1132,8 +1272,14 @@ Module { name: "QQuickTurbulenceAffector" defaultProperty: "data" prototype: "QQuickParticleAffector" - exports: ["QtQuick.Particles/Turbulence 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/Turbulence 2.0", + "QtQuick.Particles/Turbulence 2.1", + "QtQuick.Particles/Turbulence 2.11", + "QtQuick.Particles/Turbulence 2.4", + "QtQuick.Particles/Turbulence 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "strength"; type: "double" } Property { name: "noiseSource"; type: "QUrl" } Signal { @@ -1157,8 +1303,14 @@ Module { name: "QQuickWanderAffector" defaultProperty: "data" prototype: "QQuickParticleAffector" - exports: ["QtQuick.Particles/Wander 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Particles/Wander 2.0", + "QtQuick.Particles/Wander 2.1", + "QtQuick.Particles/Wander 2.11", + "QtQuick.Particles/Wander 2.4", + "QtQuick.Particles/Wander 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Enum { name: "AffectableParameters" values: { diff --git a/src/imports/qtqml/plugins.qmltypes b/src/imports/qtqml/plugins.qmltypes index 63f5bada9b..e4ddb3ddd1 100644 --- a/src/imports/qtqml/plugins.qmltypes +++ b/src/imports/qtqml/plugins.qmltypes @@ -10,8 +10,8 @@ Module { dependencies: [] Component { name: "QObject" - exports: ["QML/QtObject 1.0", "QtQml/QtObject 2.0"] - exportMetaObjectRevisions: [0, 0] + exports: ["QtQml/QtObject 2.0"] + exportMetaObjectRevisions: [0] Property { name: "objectName"; type: "string" } Signal { name: "objectNameChanged" @@ -52,8 +52,8 @@ Module { Component { name: "QQmlComponent" prototype: "QObject" - exports: ["QML/Component 1.0", "QtQml/Component 2.0"] - exportMetaObjectRevisions: [0, 0] + exports: ["QtQml/Component 2.0"] + exportMetaObjectRevisions: [0] attachedType: "QQmlComponentAttached" Enum { name: "CompilationMode" @@ -170,7 +170,7 @@ Module { name: "QQmlLocale" exports: ["QtQml/Locale 2.2"] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [2] Enum { name: "MeasurementSystem" values: { @@ -213,7 +213,7 @@ Module { name: "QQmlLoggingCategory" prototype: "QObject" exports: ["QtQml/LoggingCategory 2.12", "QtQml/LoggingCategory 2.8"] - exportMetaObjectRevisions: [12, 0] + exportMetaObjectRevisions: [12, 8] Enum { name: "DefaultLogLevel" values: { @@ -242,18 +242,4 @@ Module { Method { name: "stop" } Method { name: "restart" } } - Component { - name: "QQuickMouseEvent" - prototype: "QObject" - Property { name: "x"; type: "double"; isReadonly: true } - Property { name: "y"; type: "double"; isReadonly: true } - Property { name: "button"; type: "int"; isReadonly: true } - Property { name: "buttons"; type: "int"; isReadonly: true } - Property { name: "modifiers"; type: "int"; isReadonly: true } - Property { name: "source"; revision: 7; type: "int"; isReadonly: true } - Property { name: "wasHeld"; type: "bool"; isReadonly: true } - Property { name: "isClick"; type: "bool"; isReadonly: true } - Property { name: "accepted"; type: "bool" } - Property { name: "flags"; revision: 11; type: "int"; isReadonly: true } - } } diff --git a/src/imports/qtquick2/plugins.qmltypes b/src/imports/qtquick2/plugins.qmltypes index c8aae2087d..a773a8c428 100644 --- a/src/imports/qtquick2/plugins.qmltypes +++ b/src/imports/qtquick2/plugins.qmltypes @@ -449,6 +449,22 @@ Module { } } Component { + name: "QObject" + exports: ["QtQuick/QtObject 2.0"] + exportMetaObjectRevisions: [0] + Property { name: "objectName"; type: "string" } + Signal { + name: "objectNameChanged" + Parameter { name: "objectName"; type: "string" } + } + Method { name: "toString" } + Method { name: "destroy" } + Method { + name: "destroy" + Parameter { name: "delay"; type: "int" } + } + } + Component { name: "QPointingDeviceUniqueId" exports: ["QtQuick/PointingDeviceUniqueId 2.9"] isCreatable: false @@ -482,6 +498,92 @@ Module { } } Component { + name: "QQmlBind" + prototype: "QObject" + exports: ["QtQuick/Binding 2.0", "QtQuick/Binding 2.8"] + exportMetaObjectRevisions: [0, 8] + Enum { + name: "RestorationMode" + values: { + "RestoreNone": 0, + "RestoreBinding": 1, + "RestoreValue": 2, + "RestoreBindingOrValue": 3 + } + } + Property { name: "target"; type: "QObject"; isPointer: true } + Property { name: "property"; type: "string" } + Property { name: "value"; type: "QVariant" } + Property { name: "when"; type: "bool" } + Property { name: "delayed"; revision: 8; type: "bool" } + Property { name: "restoreMode"; revision: 14; type: "RestorationMode" } + } + Component { + name: "QQmlComponent" + prototype: "QObject" + exports: ["QtQuick/Component 2.0"] + exportMetaObjectRevisions: [0] + attachedType: "QQmlComponentAttached" + Enum { + name: "CompilationMode" + values: { + "PreferSynchronous": 0, + "Asynchronous": 1 + } + } + Enum { + name: "Status" + values: { + "Null": 0, + "Ready": 1, + "Loading": 2, + "Error": 3 + } + } + Property { name: "progress"; type: "double"; isReadonly: true } + Property { name: "status"; type: "Status"; isReadonly: true } + Property { name: "url"; type: "QUrl"; isReadonly: true } + Signal { + name: "statusChanged" + Parameter { type: "QQmlComponent::Status" } + } + Signal { + name: "progressChanged" + Parameter { type: "double" } + } + Method { + name: "loadUrl" + Parameter { name: "url"; type: "QUrl" } + } + Method { + name: "loadUrl" + Parameter { name: "url"; type: "QUrl" } + Parameter { name: "mode"; type: "CompilationMode" } + } + Method { + name: "setData" + Parameter { type: "QByteArray" } + Parameter { name: "baseUrl"; type: "QUrl" } + } + Method { name: "errorString"; type: "string" } + } + Component { + name: "QQmlComponentAttached" + prototype: "QObject" + Signal { name: "completed" } + Signal { name: "destruction" } + } + Component { + name: "QQmlConnections" + prototype: "QObject" + exports: ["QtQuick/Connections 2.0", "QtQuick/Connections 2.7"] + exportMetaObjectRevisions: [0, 3] + Property { name: "target"; type: "QObject"; isPointer: true } + Property { name: "enabled"; revision: 3; type: "bool" } + Property { name: "ignoreUnknownSignals"; type: "bool" } + Signal { name: "enabledChanged"; revision: 3 } + } + Component { name: "QQmlDelegateModel" defaultProperty: "delegate" prototype: "QQmlInstanceModel" @@ -634,6 +736,58 @@ Module { Property { name: "bezierCurve"; type: "QVariantList" } } Component { + name: "QQmlInstanceModel" + prototype: "QObject" + Property { name: "count"; type: "int"; isReadonly: true } + Signal { + name: "modelUpdated" + Parameter { name: "changeSet"; type: "QQmlChangeSet" } + Parameter { name: "reset"; type: "bool" } + } + Signal { + name: "createdItem" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Signal { + name: "initItem" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Signal { + name: "destroyingItem" + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + } + Component { + name: "QQmlInstantiator" + defaultProperty: "delegate" + prototype: "QObject" + exports: ["QtQuick/Instantiator 2.1"] + exportMetaObjectRevisions: [0] + Property { name: "active"; type: "bool" } + Property { name: "asynchronous"; type: "bool" } + Property { name: "model"; type: "QVariant" } + Property { name: "count"; type: "int"; isReadonly: true } + Property { name: "delegate"; type: "QQmlComponent"; isPointer: true } + Property { name: "object"; type: "QObject"; isReadonly: true; isPointer: true } + Signal { + name: "objectAdded" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Signal { + name: "objectRemoved" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Method { + name: "objectAt" + type: "QObject*" + Parameter { name: "index"; type: "int" } + } + } + Component { name: "QQmlListElement" prototype: "QObject" exports: ["QtQuick/ListElement 2.0"] @@ -733,6 +887,70 @@ Module { Method { name: "sync" } } Component { + name: "QQmlLocale" + exports: ["QtQuick/Locale 2.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Enum { + name: "MeasurementSystem" + values: { + "MetricSystem": 0, + "ImperialSystem": 1, + "ImperialUSSystem": 1, + "ImperialUKSystem": 2 + } + } + Enum { + name: "FormatType" + values: { + "LongFormat": 0, + "ShortFormat": 1, + "NarrowFormat": 2 + } + } + Enum { + name: "CurrencySymbolFormat" + values: { + "CurrencyIsoCode": 0, + "CurrencySymbol": 1, + "CurrencyDisplayName": 2 + } + } + Enum { + name: "DayOfWeek" + values: { + "Sunday": 0, + "Monday": 1, + "Tuesday": 2, + "Wednesday": 3, + "Thursday": 4, + "Friday": 5, + "Saturday": 6 + } + } + } + Component { + name: "QQmlLoggingCategory" + prototype: "QObject" + exports: [ + "QtQuick/LoggingCategory 2.12", + "QtQuick/LoggingCategory 2.8" + ] + exportMetaObjectRevisions: [12, 0] + Enum { + name: "DefaultLogLevel" + values: { + "Debug": 0, + "Info": 4, + "Warning": 1, + "Critical": 2, + "Fatal": 3 + } + } + Property { name: "name"; type: "string" } + Property { name: "defaultLogLevel"; revision: 12; type: "DefaultLogLevel" } + } + Component { name: "QQmlObjectModel" defaultProperty: "children" prototype: "QQmlInstanceModel" @@ -789,6 +1007,21 @@ Module { Property { name: "index"; type: "int"; isReadonly: true } } Component { + name: "QQmlTimer" + prototype: "QObject" + exports: ["QtQuick/Timer 2.0"] + exportMetaObjectRevisions: [0] + Property { name: "interval"; type: "int" } + Property { name: "running"; type: "bool" } + Property { name: "repeat"; type: "bool" } + Property { name: "triggeredOnStart"; type: "bool" } + Property { name: "parent"; type: "QObject"; isReadonly: true; isPointer: true } + Signal { name: "triggered" } + Method { name: "start" } + Method { name: "stop" } + Method { name: "restart" } + } + Component { name: "QQuickAbstractAnimation" prototype: "QObject" exports: ["QtQuick/Animation 2.0", "QtQuick/Animation 2.12"] @@ -935,8 +1168,11 @@ Module { Component { name: "QQuickAnchorAnimation" prototype: "QQuickAbstractAnimation" - exports: ["QtQuick/AnchorAnimation 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/AnchorAnimation 2.0", + "QtQuick/AnchorAnimation 2.12" + ] + exportMetaObjectRevisions: [0, 12] Property { name: "targets"; type: "QQuickItem"; isList: true; isReadonly: true } Property { name: "duration"; type: "int" } Property { name: "easing"; type: "QEasingCurve" } @@ -1010,8 +1246,16 @@ Module { name: "QQuickAnimatedImage" defaultProperty: "data" prototype: "QQuickImage" - exports: ["QtQuick/AnimatedImage 2.0", "QtQuick/AnimatedImage 2.11"] - exportMetaObjectRevisions: [0, 11] + exports: [ + "QtQuick/AnimatedImage 2.0", + "QtQuick/AnimatedImage 2.1", + "QtQuick/AnimatedImage 2.11", + "QtQuick/AnimatedImage 2.3", + "QtQuick/AnimatedImage 2.4", + "QtQuick/AnimatedImage 2.5", + "QtQuick/AnimatedImage 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 3, 4, 5, 7] Property { name: "playing"; type: "bool" } Property { name: "paused"; type: "bool" } Property { name: "currentFrame"; type: "int" } @@ -1025,8 +1269,15 @@ Module { name: "QQuickAnimatedSprite" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick/AnimatedSprite 2.0", "QtQuick/AnimatedSprite 2.12"] - exportMetaObjectRevisions: [0, 12] + exports: [ + "QtQuick/AnimatedSprite 2.0", + "QtQuick/AnimatedSprite 2.1", + "QtQuick/AnimatedSprite 2.11", + "QtQuick/AnimatedSprite 2.12", + "QtQuick/AnimatedSprite 2.4", + "QtQuick/AnimatedSprite 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 12, 4, 7] Enum { name: "LoopParameters" values: { @@ -1203,9 +1454,9 @@ Module { Component { name: "QQuickAnimator" prototype: "QQuickAbstractAnimation" - exports: ["QtQuick/Animator 2.2"] + exports: ["QtQuick/Animator 2.12", "QtQuick/Animator 2.2"] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [12, 2] Property { name: "target"; type: "QQuickItem"; isPointer: true } Property { name: "easing"; type: "QEasingCurve" } Property { name: "duration"; type: "int" } @@ -1256,11 +1507,15 @@ Module { prototype: "QQuickImplicitSizeItem" exports: [ "QtQuick/Positioner 2.0", + "QtQuick/Positioner 2.1", + "QtQuick/Positioner 2.11", + "QtQuick/Positioner 2.4", "QtQuick/Positioner 2.6", + "QtQuick/Positioner 2.7", "QtQuick/Positioner 2.9" ] isCreatable: false - exportMetaObjectRevisions: [0, 6, 9] + exportMetaObjectRevisions: [0, 1, 11, 4, 6, 7, 9] attachedType: "QQuickPositionerAttached" Property { name: "spacing"; type: "double" } Property { name: "populate"; type: "QQuickTransition"; isPointer: true } @@ -1293,8 +1548,14 @@ Module { name: "QQuickBorderImage" defaultProperty: "data" prototype: "QQuickImageBase" - exports: ["QtQuick/BorderImage 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/BorderImage 2.0", + "QtQuick/BorderImage 2.1", + "QtQuick/BorderImage 2.11", + "QtQuick/BorderImage 2.4", + "QtQuick/BorderImage 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Enum { name: "TileMode" values: { @@ -1312,7 +1573,7 @@ Module { name: "QQuickBorderImageMesh" prototype: "QQuickShaderEffectMesh" exports: ["QtQuick/BorderImageMesh 2.8"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [8] Enum { name: "TileMode" values: { @@ -1330,8 +1591,14 @@ Module { name: "QQuickCanvasItem" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick/Canvas 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/Canvas 2.0", + "QtQuick/Canvas 2.1", + "QtQuick/Canvas 2.11", + "QtQuick/Canvas 2.4", + "QtQuick/Canvas 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Enum { name: "RenderTarget" values: { @@ -1422,8 +1689,8 @@ Module { Component { name: "QQuickColorAnimation" prototype: "QQuickPropertyAnimation" - exports: ["QtQuick/ColorAnimation 2.0"] - exportMetaObjectRevisions: [0] + exports: ["QtQuick/ColorAnimation 2.0", "QtQuick/ColorAnimation 2.12"] + exportMetaObjectRevisions: [0, 12] Property { name: "from"; type: "QColor" } Property { name: "to"; type: "QColor" } } @@ -1431,8 +1698,16 @@ Module { name: "QQuickColumn" defaultProperty: "data" prototype: "QQuickBasePositioner" - exports: ["QtQuick/Column 2.0", "QtQuick/Column 2.6"] - exportMetaObjectRevisions: [0, 6] + exports: [ + "QtQuick/Column 2.0", + "QtQuick/Column 2.1", + "QtQuick/Column 2.11", + "QtQuick/Column 2.4", + "QtQuick/Column 2.6", + "QtQuick/Column 2.7", + "QtQuick/Column 2.9" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 6, 7, 9] } Component { name: "QQuickCurve" @@ -1519,7 +1794,7 @@ Module { prototype: "QObject" exports: ["QtQuick/DragAxis 2.12"] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [12] Property { name: "minimum"; type: "double" } Property { name: "maximum"; type: "double" } Property { name: "enabled"; type: "bool" } @@ -1527,8 +1802,8 @@ Module { Component { name: "QQuickDragHandler" prototype: "QQuickMultiPointHandler" - exports: ["QtQuick/DragHandler 2.12"] - exportMetaObjectRevisions: [0] + exports: ["QtQuick/DragHandler 2.12", "QtQuick/DragHandler 2.14"] + exportMetaObjectRevisions: [12, 14] Enum { name: "SnapMode" values: { @@ -1541,14 +1816,21 @@ Module { Property { name: "xAxis"; type: "QQuickDragAxis"; isReadonly: true; isPointer: true } Property { name: "yAxis"; type: "QQuickDragAxis"; isReadonly: true; isPointer: true } Property { name: "translation"; type: "QVector2D"; isReadonly: true } - Property { name: "snapMode"; type: "SnapMode" } + Property { name: "snapMode"; revision: 14; type: "SnapMode" } + Signal { name: "snapModeChanged"; revision: 14 } } Component { name: "QQuickDropArea" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick/DropArea 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/DropArea 2.0", + "QtQuick/DropArea 2.1", + "QtQuick/DropArea 2.11", + "QtQuick/DropArea 2.4", + "QtQuick/DropArea 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "containsDrag"; type: "bool"; isReadonly: true } Property { name: "keys"; type: "QStringList" } Property { name: "drag"; type: "QQuickDropAreaDrag"; isReadonly: true; isPointer: true } @@ -1625,7 +1907,7 @@ Module { prototype: "QObject" exports: ["QtQuick/EventPoint 2.12"] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [12] Enum { name: "States" values: { @@ -1664,7 +1946,7 @@ Module { prototype: "QQuickEventPoint" exports: ["QtQuick/EventTouchPoint 2.12"] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [12] Property { name: "rotation"; type: "double"; isReadonly: true } Property { name: "pressure"; type: "double"; isReadonly: true } Property { name: "ellipseDiameters"; type: "QSizeF"; isReadonly: true } @@ -1676,11 +1958,15 @@ Module { prototype: "QQuickItem" exports: [ "QtQuick/Flickable 2.0", + "QtQuick/Flickable 2.1", "QtQuick/Flickable 2.10", + "QtQuick/Flickable 2.11", "QtQuick/Flickable 2.12", + "QtQuick/Flickable 2.4", + "QtQuick/Flickable 2.7", "QtQuick/Flickable 2.9" ] - exportMetaObjectRevisions: [0, 10, 12, 9] + exportMetaObjectRevisions: [0, 1, 10, 11, 12, 4, 7, 9] Enum { name: "BoundsBehavior" values: { @@ -1805,8 +2091,14 @@ Module { name: "QQuickFlipable" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick/Flipable 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/Flipable 2.0", + "QtQuick/Flipable 2.1", + "QtQuick/Flipable 2.11", + "QtQuick/Flipable 2.4", + "QtQuick/Flipable 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Enum { name: "Side" values: { @@ -1822,8 +2114,16 @@ Module { name: "QQuickFlow" defaultProperty: "data" prototype: "QQuickBasePositioner" - exports: ["QtQuick/Flow 2.0", "QtQuick/Flow 2.6"] - exportMetaObjectRevisions: [0, 6] + exports: [ + "QtQuick/Flow 2.0", + "QtQuick/Flow 2.1", + "QtQuick/Flow 2.11", + "QtQuick/Flow 2.4", + "QtQuick/Flow 2.6", + "QtQuick/Flow 2.7", + "QtQuick/Flow 2.9" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 6, 7, 9] Enum { name: "Flow" values: { @@ -1839,8 +2139,14 @@ Module { name: "QQuickFocusScope" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick/FocusScope 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/FocusScope 2.0", + "QtQuick/FocusScope 2.1", + "QtQuick/FocusScope 2.11", + "QtQuick/FocusScope 2.4", + "QtQuick/FocusScope 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] } Component { name: "QQuickFontLoader" @@ -1864,7 +2170,7 @@ Module { name: "QQuickFontMetrics" prototype: "QObject" exports: ["QtQuick/FontMetrics 2.4"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [4] Property { name: "font"; type: "QFont" } Property { name: "ascent"; type: "double"; isReadonly: true } Property { name: "descent"; type: "double"; isReadonly: true } @@ -2011,7 +2317,7 @@ Module { prototype: "QObject" exports: ["QtQuick/GraphicsInfo 2.8"] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [8] Enum { name: "GraphicsApi" values: { @@ -2080,8 +2386,16 @@ Module { name: "QQuickGrid" defaultProperty: "data" prototype: "QQuickBasePositioner" - exports: ["QtQuick/Grid 2.0", "QtQuick/Grid 2.1", "QtQuick/Grid 2.6"] - exportMetaObjectRevisions: [0, 1, 6] + exports: [ + "QtQuick/Grid 2.0", + "QtQuick/Grid 2.1", + "QtQuick/Grid 2.11", + "QtQuick/Grid 2.4", + "QtQuick/Grid 2.6", + "QtQuick/Grid 2.7", + "QtQuick/Grid 2.9" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 6, 7, 9] Enum { name: "Flow" values: { @@ -2150,10 +2464,16 @@ Module { exports: [ "QtQuick/GridView 2.0", "QtQuick/GridView 2.1", + "QtQuick/GridView 2.10", + "QtQuick/GridView 2.11", + "QtQuick/GridView 2.12", "QtQuick/GridView 2.13", - "QtQuick/GridView 2.7" + "QtQuick/GridView 2.3", + "QtQuick/GridView 2.4", + "QtQuick/GridView 2.7", + "QtQuick/GridView 2.9" ] - exportMetaObjectRevisions: [0, 1, 13, 7] + exportMetaObjectRevisions: [0, 1, 10, 11, 12, 13, 3, 4, 7, 9] attachedType: "QQuickGridViewAttached" Enum { name: "Flow" @@ -2185,7 +2505,7 @@ Module { name: "QQuickHoverHandler" prototype: "QQuickSinglePointHandler" exports: ["QtQuick/HoverHandler 2.12"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [12] Property { name: "hovered"; type: "bool"; isReadonly: true } } Component { @@ -2194,10 +2514,15 @@ Module { prototype: "QQuickImageBase" exports: [ "QtQuick/Image 2.0", + "QtQuick/Image 2.1", + "QtQuick/Image 2.11", + "QtQuick/Image 2.14", "QtQuick/Image 2.3", - "QtQuick/Image 2.5" + "QtQuick/Image 2.4", + "QtQuick/Image 2.5", + "QtQuick/Image 2.7" ] - exportMetaObjectRevisions: [0, 3, 5] + exportMetaObjectRevisions: [0, 1, 11, 14, 3, 4, 5, 7] Enum { name: "HAlignment" values: { @@ -2253,6 +2578,9 @@ Module { name: "QQuickImageBase" defaultProperty: "data" prototype: "QQuickImplicitSizeItem" + exports: ["QtQuick/ImageBase 2.14"] + isCreatable: false + exportMetaObjectRevisions: [14] Enum { name: "Status" values: { @@ -2269,6 +2597,8 @@ Module { Property { name: "cache"; type: "bool" } Property { name: "sourceSize"; type: "QSize" } Property { name: "mirror"; type: "bool" } + Property { name: "currentFrame"; revision: 14; type: "int" } + Property { name: "frameCount"; revision: 14; type: "int"; isReadonly: true } Signal { name: "sourceChanged" Parameter { type: "QUrl" } @@ -2281,6 +2611,8 @@ Module { name: "progressChanged" Parameter { name: "progress"; type: "double" } } + Signal { name: "currentFrameChanged"; revision: 14 } + Signal { name: "frameCountChanged"; revision: 14 } } Component { name: "QQuickImplicitSizeItem" @@ -2563,12 +2895,17 @@ Module { prototype: "QQuickFlickable" exports: [ "QtQuick/ItemView 2.1", + "QtQuick/ItemView 2.10", + "QtQuick/ItemView 2.11", + "QtQuick/ItemView 2.12", "QtQuick/ItemView 2.13", "QtQuick/ItemView 2.3", - "QtQuick/ItemView 2.7" + "QtQuick/ItemView 2.4", + "QtQuick/ItemView 2.7", + "QtQuick/ItemView 2.9" ] isCreatable: false - exportMetaObjectRevisions: [1, 13, 3, 7] + exportMetaObjectRevisions: [1, 10, 11, 12, 13, 3, 4, 7, 9] Enum { name: "LayoutDirection" values: { @@ -2921,10 +3258,16 @@ Module { exports: [ "QtQuick/ListView 2.0", "QtQuick/ListView 2.1", + "QtQuick/ListView 2.10", + "QtQuick/ListView 2.11", + "QtQuick/ListView 2.12", + "QtQuick/ListView 2.13", + "QtQuick/ListView 2.3", "QtQuick/ListView 2.4", - "QtQuick/ListView 2.7" + "QtQuick/ListView 2.7", + "QtQuick/ListView 2.9" ] - exportMetaObjectRevisions: [0, 1, 4, 7] + exportMetaObjectRevisions: [0, 1, 10, 11, 12, 13, 3, 4, 7, 9] attachedType: "QQuickListViewAttached" Enum { name: "Orientation" @@ -2977,8 +3320,14 @@ Module { name: "QQuickLoader" defaultProperty: "data" prototype: "QQuickImplicitSizeItem" - exports: ["QtQuick/Loader 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/Loader 2.0", + "QtQuick/Loader 2.1", + "QtQuick/Loader 2.11", + "QtQuick/Loader 2.4", + "QtQuick/Loader 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Enum { name: "Status" values: { @@ -3005,7 +3354,7 @@ Module { name: "QQuickMatrix4x4" prototype: "QQuickTransform" exports: ["QtQuick/Matrix4x4 2.3"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [3] Property { name: "matrix"; type: "QMatrix4x4" } } Component { @@ -3014,11 +3363,14 @@ Module { prototype: "QQuickItem" exports: [ "QtQuick/MouseArea 2.0", + "QtQuick/MouseArea 2.1", + "QtQuick/MouseArea 2.11", "QtQuick/MouseArea 2.4", "QtQuick/MouseArea 2.5", + "QtQuick/MouseArea 2.7", "QtQuick/MouseArea 2.9" ] - exportMetaObjectRevisions: [0, 4, 5, 9] + exportMetaObjectRevisions: [0, 1, 11, 4, 5, 7, 9] Property { name: "mouseX"; type: "double"; isReadonly: true } Property { name: "mouseY"; type: "double"; isReadonly: true } Property { name: "containsMouse"; type: "bool"; isReadonly: true } @@ -3079,6 +3431,20 @@ Module { Signal { name: "pressAndHoldIntervalChanged"; revision: 9 } } Component { + name: "QQuickMouseEvent" + prototype: "QObject" + Property { name: "x"; type: "double"; isReadonly: true } + Property { name: "y"; type: "double"; isReadonly: true } + Property { name: "button"; type: "int"; isReadonly: true } + Property { name: "buttons"; type: "int"; isReadonly: true } + Property { name: "modifiers"; type: "int"; isReadonly: true } + Property { name: "source"; revision: 7; type: "int"; isReadonly: true } + Property { name: "wasHeld"; type: "bool"; isReadonly: true } + Property { name: "isClick"; type: "bool"; isReadonly: true } + Property { name: "accepted"; type: "bool" } + Property { name: "flags"; revision: 11; type: "int"; isReadonly: true } + } + Component { name: "QQuickMultiPointHandler" prototype: "QQuickPointerDeviceHandler" Property { name: "minimumPointCount"; type: "int" } @@ -3090,8 +3456,14 @@ Module { name: "QQuickMultiPointTouchArea" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick/MultiPointTouchArea 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/MultiPointTouchArea 2.0", + "QtQuick/MultiPointTouchArea 2.1", + "QtQuick/MultiPointTouchArea 2.11", + "QtQuick/MultiPointTouchArea 2.4", + "QtQuick/MultiPointTouchArea 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "touchPoints"; type: "QQuickTouchPoint"; isList: true; isReadonly: true } Property { name: "minimumTouchPoints"; type: "int" } Property { name: "maximumTouchPoints"; type: "int" } @@ -3124,23 +3496,29 @@ Module { Component { name: "QQuickNumberAnimation" prototype: "QQuickPropertyAnimation" - exports: ["QtQuick/NumberAnimation 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/NumberAnimation 2.0", + "QtQuick/NumberAnimation 2.12" + ] + exportMetaObjectRevisions: [0, 12] Property { name: "from"; type: "double" } Property { name: "to"; type: "double" } } Component { name: "QQuickOpacityAnimator" prototype: "QQuickAnimator" - exports: ["QtQuick/OpacityAnimator 2.2"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/OpacityAnimator 2.12", + "QtQuick/OpacityAnimator 2.2" + ] + exportMetaObjectRevisions: [12, 2] } Component { name: "QQuickOpenGLInfo" prototype: "QObject" exports: ["QtQuick/OpenGLInfo 2.4"] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [4] Enum { name: "ContextProfile" values: { @@ -3180,9 +3558,15 @@ Module { name: "QQuickPaintedItem" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick/PaintedItem 2.0"] + exports: [ + "QtQuick/PaintedItem 2.0", + "QtQuick/PaintedItem 2.1", + "QtQuick/PaintedItem 2.11", + "QtQuick/PaintedItem 2.4", + "QtQuick/PaintedItem 2.7" + ] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Enum { name: "RenderTarget" values: { @@ -3207,15 +3591,21 @@ Module { name: "QQuickParallelAnimation" defaultProperty: "animations" prototype: "QQuickAnimationGroup" - exports: ["QtQuick/ParallelAnimation 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/ParallelAnimation 2.0", + "QtQuick/ParallelAnimation 2.12" + ] + exportMetaObjectRevisions: [0, 12] } Component { name: "QQuickParentAnimation" defaultProperty: "animations" prototype: "QQuickAnimationGroup" - exports: ["QtQuick/ParentAnimation 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/ParentAnimation 2.0", + "QtQuick/ParentAnimation 2.12" + ] + exportMetaObjectRevisions: [0, 12] Property { name: "target"; type: "QQuickItem"; isPointer: true } Property { name: "newParent"; type: "QQuickItem"; isPointer: true } Property { name: "via"; type: "QQuickItem"; isPointer: true } @@ -3258,7 +3648,7 @@ Module { name: "QQuickPathAngleArc" prototype: "QQuickCurve" exports: ["QtQuick/PathAngleArc 2.11"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [11] Property { name: "centerX"; type: "double" } Property { name: "centerY"; type: "double" } Property { name: "radiusX"; type: "double" } @@ -3270,8 +3660,8 @@ Module { Component { name: "QQuickPathAnimation" prototype: "QQuickAbstractAnimation" - exports: ["QtQuick/PathAnimation 2.0"] - exportMetaObjectRevisions: [0] + exports: ["QtQuick/PathAnimation 2.0", "QtQuick/PathAnimation 2.12"] + exportMetaObjectRevisions: [0, 12] Enum { name: "Orientation" values: { @@ -3393,15 +3783,15 @@ Module { name: "QQuickPathMove" prototype: "QQuickCurve" exports: ["QtQuick/PathMove 2.9"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [9] } Component { name: "QQuickPathMultiline" prototype: "QQuickCurve" exports: ["QtQuick/PathMultiline 2.14"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [14] Property { name: "start"; type: "QPointF"; isReadonly: true } - Property { name: "paths"; type: "QVariantList" } + Property { name: "paths"; type: "QVariant" } } Component { name: "QQuickPathPercent" @@ -3414,9 +3804,9 @@ Module { name: "QQuickPathPolyline" prototype: "QQuickCurve" exports: ["QtQuick/PathPolyline 2.14"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [14] Property { name: "start"; type: "QPointF"; isReadonly: true } - Property { name: "path"; type: "QVariantList" } + Property { name: "path"; type: "QVariant" } } Component { name: "QQuickPathQuad" @@ -3441,10 +3831,13 @@ Module { prototype: "QQuickItem" exports: [ "QtQuick/PathView 2.0", + "QtQuick/PathView 2.1", + "QtQuick/PathView 2.11", "QtQuick/PathView 2.13", + "QtQuick/PathView 2.4", "QtQuick/PathView 2.7" ] - exportMetaObjectRevisions: [0, 13, 7] + exportMetaObjectRevisions: [0, 1, 11, 13, 4, 7] attachedType: "QQuickPathViewAttached" Enum { name: "HighlightRangeMode" @@ -3550,8 +3943,8 @@ Module { Component { name: "QQuickPauseAnimation" prototype: "QQuickAbstractAnimation" - exports: ["QtQuick/PauseAnimation 2.0"] - exportMetaObjectRevisions: [0] + exports: ["QtQuick/PauseAnimation 2.0", "QtQuick/PauseAnimation 2.12"] + exportMetaObjectRevisions: [0, 12] Property { name: "duration"; type: "int" } Signal { name: "durationChanged" @@ -3597,8 +3990,15 @@ Module { name: "QQuickPinchArea" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick/PinchArea 2.0", "QtQuick/PinchArea 2.5"] - exportMetaObjectRevisions: [0, 5] + exports: [ + "QtQuick/PinchArea 2.0", + "QtQuick/PinchArea 2.1", + "QtQuick/PinchArea 2.11", + "QtQuick/PinchArea 2.4", + "QtQuick/PinchArea 2.5", + "QtQuick/PinchArea 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 5, 7] Property { name: "enabled"; type: "bool" } Property { name: "pinch"; type: "QQuickPinch"; isReadonly: true; isPointer: true } Signal { @@ -3641,7 +4041,7 @@ Module { name: "QQuickPinchHandler" prototype: "QQuickMultiPointHandler" exports: ["QtQuick/PinchHandler 2.12"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [12] Property { name: "minimumScale"; type: "double" } Property { name: "maximumScale"; type: "double" } Property { name: "minimumRotation"; type: "double" } @@ -3662,7 +4062,7 @@ Module { name: "QQuickPointHandler" prototype: "QQuickSinglePointHandler" exports: ["QtQuick/PointHandler 2.12"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [12] Property { name: "translation"; type: "QVector2D"; isReadonly: true } } Component { @@ -3670,7 +4070,7 @@ Module { prototype: "QObject" exports: ["QtQuick/PointerDevice 2.12"] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [12] Enum { name: "DeviceTypes" values: { @@ -3747,7 +4147,7 @@ Module { prototype: "QObject" exports: ["QtQuick/PointerEvent 2.12"] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [12] Property { name: "device"; type: "QQuickPointerDevice"; isReadonly: true; isPointer: true } Property { name: "modifiers"; type: "Qt::KeyboardModifiers"; isReadonly: true } Property { name: "button"; type: "Qt::MouseButtons"; isReadonly: true } @@ -3758,7 +4158,7 @@ Module { prototype: "QObject" exports: ["QtQuick/PointerHandler 2.12"] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [12] Enum { name: "GrabPermissions" values: { @@ -3796,14 +4196,14 @@ Module { prototype: "QQuickSinglePointEvent" exports: ["QtQuick/PointerMouseEvent 2.12"] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [12] } Component { name: "QQuickPointerTouchEvent" prototype: "QQuickPointerEvent" exports: ["QtQuick/PointerTouchEvent 2.12"] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [12] } Component { name: "QQuickPositionerAttached" @@ -3815,8 +4215,8 @@ Module { Component { name: "QQuickPropertyAction" prototype: "QQuickAbstractAnimation" - exports: ["QtQuick/PropertyAction 2.0"] - exportMetaObjectRevisions: [0] + exports: ["QtQuick/PropertyAction 2.0", "QtQuick/PropertyAction 2.12"] + exportMetaObjectRevisions: [0, 12] Property { name: "target"; type: "QObject"; isPointer: true } Property { name: "property"; type: "string" } Property { name: "properties"; type: "string" } @@ -3835,8 +4235,11 @@ Module { Component { name: "QQuickPropertyAnimation" prototype: "QQuickAbstractAnimation" - exports: ["QtQuick/PropertyAnimation 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/PropertyAnimation 2.0", + "QtQuick/PropertyAnimation 2.12" + ] + exportMetaObjectRevisions: [0, 12] Property { name: "duration"; type: "int" } Property { name: "from"; type: "QVariant" } Property { name: "to"; type: "QVariant" } @@ -3872,8 +4275,14 @@ Module { name: "QQuickRectangle" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick/Rectangle 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/Rectangle 2.0", + "QtQuick/Rectangle 2.1", + "QtQuick/Rectangle 2.11", + "QtQuick/Rectangle 2.4", + "QtQuick/Rectangle 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "color"; type: "QColor" } Property { name: "gradient"; type: "QJSValue" } Property { name: "border"; type: "QQuickPen"; isReadonly: true; isPointer: true } @@ -3883,8 +4292,14 @@ Module { name: "QQuickRepeater" defaultProperty: "delegate" prototype: "QQuickItem" - exports: ["QtQuick/Repeater 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/Repeater 2.0", + "QtQuick/Repeater 2.1", + "QtQuick/Repeater 2.11", + "QtQuick/Repeater 2.4", + "QtQuick/Repeater 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "model"; type: "QVariant" } Property { name: "delegate"; type: "QQmlComponent"; isPointer: true } Property { name: "count"; type: "int"; isReadonly: true } @@ -3916,8 +4331,11 @@ Module { Component { name: "QQuickRotationAnimation" prototype: "QQuickPropertyAnimation" - exports: ["QtQuick/RotationAnimation 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/RotationAnimation 2.0", + "QtQuick/RotationAnimation 2.12" + ] + exportMetaObjectRevisions: [0, 12] Enum { name: "RotationDirection" values: { @@ -3934,8 +4352,11 @@ Module { Component { name: "QQuickRotationAnimator" prototype: "QQuickAnimator" - exports: ["QtQuick/RotationAnimator 2.2"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/RotationAnimator 2.12", + "QtQuick/RotationAnimator 2.2" + ] + exportMetaObjectRevisions: [12, 2] Enum { name: "RotationDirection" values: { @@ -3955,8 +4376,16 @@ Module { name: "QQuickRow" defaultProperty: "data" prototype: "QQuickBasePositioner" - exports: ["QtQuick/Row 2.0", "QtQuick/Row 2.6"] - exportMetaObjectRevisions: [0, 6] + exports: [ + "QtQuick/Row 2.0", + "QtQuick/Row 2.1", + "QtQuick/Row 2.11", + "QtQuick/Row 2.4", + "QtQuick/Row 2.6", + "QtQuick/Row 2.7", + "QtQuick/Row 2.9" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 6, 7, 9] Property { name: "layoutDirection"; type: "Qt::LayoutDirection" } Property { name: "effectiveLayoutDirection"; type: "Qt::LayoutDirection"; isReadonly: true } } @@ -3974,8 +4403,8 @@ Module { Component { name: "QQuickScaleAnimator" prototype: "QQuickAnimator" - exports: ["QtQuick/ScaleAnimator 2.2"] - exportMetaObjectRevisions: [0] + exports: ["QtQuick/ScaleAnimator 2.12", "QtQuick/ScaleAnimator 2.2"] + exportMetaObjectRevisions: [12, 2] } Component { name: "QQuickScaleGrid" @@ -3993,8 +4422,8 @@ Module { Component { name: "QQuickScriptAction" prototype: "QQuickAbstractAnimation" - exports: ["QtQuick/ScriptAction 2.0"] - exportMetaObjectRevisions: [0] + exports: ["QtQuick/ScriptAction 2.0", "QtQuick/ScriptAction 2.12"] + exportMetaObjectRevisions: [0, 12] Property { name: "script"; type: "QQmlScriptString" } Property { name: "scriptName"; type: "string" } } @@ -4002,15 +4431,24 @@ Module { name: "QQuickSequentialAnimation" defaultProperty: "animations" prototype: "QQuickAnimationGroup" - exports: ["QtQuick/SequentialAnimation 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/SequentialAnimation 2.0", + "QtQuick/SequentialAnimation 2.12" + ] + exportMetaObjectRevisions: [0, 12] } Component { name: "QQuickShaderEffect" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick/ShaderEffect 2.0", "QtQuick/ShaderEffect 2.4"] - exportMetaObjectRevisions: [0, 4] + exports: [ + "QtQuick/ShaderEffect 2.0", + "QtQuick/ShaderEffect 2.1", + "QtQuick/ShaderEffect 2.11", + "QtQuick/ShaderEffect 2.4", + "QtQuick/ShaderEffect 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Enum { name: "CullMode" values: { @@ -4050,10 +4488,14 @@ Module { prototype: "QQuickItem" exports: [ "QtQuick/ShaderEffectSource 2.0", + "QtQuick/ShaderEffectSource 2.1", + "QtQuick/ShaderEffectSource 2.11", + "QtQuick/ShaderEffectSource 2.4", "QtQuick/ShaderEffectSource 2.6", + "QtQuick/ShaderEffectSource 2.7", "QtQuick/ShaderEffectSource 2.9" ] - exportMetaObjectRevisions: [0, 6, 9] + exportMetaObjectRevisions: [0, 1, 11, 4, 6, 7, 9] Enum { name: "WrapMode" values: { @@ -4101,7 +4543,7 @@ Module { "QtQuick/Shortcut 2.6", "QtQuick/Shortcut 2.9" ] - exportMetaObjectRevisions: [0, 6, 9] + exportMetaObjectRevisions: [5, 6, 9] Property { name: "sequence"; type: "QVariant" } Property { name: "sequences"; revision: 9; type: "QVariantList" } Property { name: "nativeText"; revision: 6; type: "string"; isReadonly: true } @@ -4122,8 +4564,11 @@ Module { Component { name: "QQuickSmoothedAnimation" prototype: "QQuickNumberAnimation" - exports: ["QtQuick/SmoothedAnimation 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/SmoothedAnimation 2.0", + "QtQuick/SmoothedAnimation 2.12" + ] + exportMetaObjectRevisions: [0, 12] Enum { name: "ReversingMode" values: { @@ -4139,8 +4584,11 @@ Module { Component { name: "QQuickSpringAnimation" prototype: "QQuickNumberAnimation" - exports: ["QtQuick/SpringAnimation 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/SpringAnimation 2.0", + "QtQuick/SpringAnimation 2.12" + ] + exportMetaObjectRevisions: [0, 12] Property { name: "velocity"; type: "double" } Property { name: "spring"; type: "double" } Property { name: "damping"; type: "double" } @@ -4272,8 +4720,14 @@ Module { name: "QQuickSpriteSequence" defaultProperty: "sprites" prototype: "QQuickItem" - exports: ["QtQuick/SpriteSequence 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/SpriteSequence 2.0", + "QtQuick/SpriteSequence 2.1", + "QtQuick/SpriteSequence 2.11", + "QtQuick/SpriteSequence 2.4", + "QtQuick/SpriteSequence 2.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Property { name: "running"; type: "bool" } Property { name: "interpolate"; type: "bool" } Property { name: "goalSprite"; type: "string" } @@ -4431,7 +4885,7 @@ Module { defaultProperty: "flickableData" prototype: "QQuickFlickable" exports: ["QtQuick/TableView 2.12", "QtQuick/TableView 2.14"] - exportMetaObjectRevisions: [0, 14] + exportMetaObjectRevisions: [12, 14] attachedType: "QQuickTableViewAttached" Property { name: "rows"; type: "int"; isReadonly: true } Property { name: "columns"; type: "int"; isReadonly: true } @@ -4461,7 +4915,7 @@ Module { name: "QQuickTapHandler" prototype: "QQuickSinglePointHandler" exports: ["QtQuick/TapHandler 2.12"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [12] Enum { name: "GesturePolicy" values: { @@ -4495,14 +4949,17 @@ Module { prototype: "QQuickImplicitSizeItem" exports: [ "QtQuick/Text 2.0", + "QtQuick/Text 2.1", "QtQuick/Text 2.10", - "QtQuick/Text 2.12", + "QtQuick/Text 2.11", "QtQuick/Text 2.2", "QtQuick/Text 2.3", + "QtQuick/Text 2.4", "QtQuick/Text 2.6", + "QtQuick/Text 2.7", "QtQuick/Text 2.9" ] - exportMetaObjectRevisions: [0, 10, 12, 2, 3, 6, 9] + exportMetaObjectRevisions: [0, 1, 10, 11, 2, 3, 4, 6, 7, 9] Enum { name: "HAlignment" values: { @@ -4698,12 +5155,14 @@ Module { "QtQuick/TextEdit 2.0", "QtQuick/TextEdit 2.1", "QtQuick/TextEdit 2.10", + "QtQuick/TextEdit 2.11", "QtQuick/TextEdit 2.2", "QtQuick/TextEdit 2.3", + "QtQuick/TextEdit 2.4", "QtQuick/TextEdit 2.6", "QtQuick/TextEdit 2.7" ] - exportMetaObjectRevisions: [0, 1, 10, 2, 3, 6, 7] + exportMetaObjectRevisions: [0, 1, 10, 11, 2, 3, 4, 6, 7] Enum { name: "HAlignment" values: { @@ -4982,13 +5441,15 @@ Module { prototype: "QQuickImplicitSizeItem" exports: [ "QtQuick/TextInput 2.0", + "QtQuick/TextInput 2.1", + "QtQuick/TextInput 2.11", "QtQuick/TextInput 2.2", "QtQuick/TextInput 2.4", "QtQuick/TextInput 2.6", "QtQuick/TextInput 2.7", "QtQuick/TextInput 2.9" ] - exportMetaObjectRevisions: [0, 2, 4, 6, 7, 9] + exportMetaObjectRevisions: [0, 1, 11, 2, 4, 6, 7, 9] Enum { name: "EchoMode" values: { @@ -5238,7 +5699,7 @@ Module { name: "QQuickTextMetrics" prototype: "QObject" exports: ["QtQuick/TextMetrics 2.4"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [4] Property { name: "font"; type: "QFont" } Property { name: "text"; type: "string" } Property { name: "advanceWidth"; type: "double"; isReadonly: true } @@ -5255,7 +5716,7 @@ Module { name: "QQuickTouchPoint" prototype: "QObject" exports: ["QtQuick/TouchPoint 2.0", "QtQuick/TouchPoint 2.9"] - exportMetaObjectRevisions: [0, 0] + exportMetaObjectRevisions: [0, 9] Property { name: "pointId"; type: "int"; isReadonly: true } Property { name: "uniqueId"; revision: 9; type: "QPointingDeviceUniqueId"; isReadonly: true } Property { name: "pressed"; type: "bool"; isReadonly: true } @@ -5301,8 +5762,11 @@ Module { Component { name: "QQuickUniformAnimator" prototype: "QQuickAnimator" - exports: ["QtQuick/UniformAnimator 2.2"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/UniformAnimator 2.12", + "QtQuick/UniformAnimator 2.2" + ] + exportMetaObjectRevisions: [12, 2] Property { name: "uniform"; type: "string" } Signal { name: "uniformChanged" @@ -5312,8 +5776,11 @@ Module { Component { name: "QQuickVector3dAnimation" prototype: "QQuickPropertyAnimation" - exports: ["QtQuick/Vector3dAnimation 2.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick/Vector3dAnimation 2.0", + "QtQuick/Vector3dAnimation 2.12" + ] + exportMetaObjectRevisions: [0, 12] Property { name: "from"; type: "QVector3D" } Property { name: "to"; type: "QVector3D" } } @@ -5371,7 +5838,7 @@ Module { name: "QQuickWheelHandler" prototype: "QQuickSinglePointHandler" exports: ["QtQuick/WheelHandler 2.14"] - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [14] Property { name: "orientation"; type: "Qt::Orientation" } Property { name: "invertible"; type: "bool" } Property { name: "activeTimeout"; type: "double" } @@ -5403,14 +5870,14 @@ Module { Component { name: "QQuickXAnimator" prototype: "QQuickAnimator" - exports: ["QtQuick/XAnimator 2.2"] - exportMetaObjectRevisions: [0] + exports: ["QtQuick/XAnimator 2.12", "QtQuick/XAnimator 2.2"] + exportMetaObjectRevisions: [12, 2] } Component { name: "QQuickYAnimator" prototype: "QQuickAnimator" - exports: ["QtQuick/YAnimator 2.2"] - exportMetaObjectRevisions: [0] + exports: ["QtQuick/YAnimator 2.12", "QtQuick/YAnimator 2.2"] + exportMetaObjectRevisions: [12, 2] } Component { name: "QRegExpValidator" diff --git a/src/imports/settings/plugin.cpp b/src/imports/settings/plugin.cpp index eb7d5027a4..db941d9845 100644 --- a/src/imports/settings/plugin.cpp +++ b/src/imports/settings/plugin.cpp @@ -54,7 +54,7 @@ public: void registerTypes(const char *uri) override { Q_ASSERT(QByteArray(uri) == QByteArray("Qt.labs.settings")); - qmlRegisterType<QQmlSettings>(uri, 1, 0, "Settings"); + qmlRegisterTypesAndRevisions<QQmlSettings>(uri, 1); qmlRegisterModule(uri, 1, 1); // QTBUG-73239 } }; diff --git a/src/imports/settings/qqmlsettings.cpp b/src/imports/settings/qqmlsettings.cpp index 287a70363a..d43f9bafb7 100644 --- a/src/imports/settings/qqmlsettings.cpp +++ b/src/imports/settings/qqmlsettings.cpp @@ -473,7 +473,7 @@ QVariant QQmlSettings::value(const QString &key, const QVariant &defaultValue) c /*! \qmlmethod Settings::setValue(string key, var value) - Sets the value of setting key to value. If the key already exists, + Sets the value of setting \a key to \a value. If the key already exists, the previous value is overwritten. \since Qt 5.12 diff --git a/src/imports/settings/qqmlsettings_p.h b/src/imports/settings/qqmlsettings_p.h index a86c8b4751..3f1b83f541 100644 --- a/src/imports/settings/qqmlsettings_p.h +++ b/src/imports/settings/qqmlsettings_p.h @@ -66,6 +66,7 @@ class QQmlSettings : public QObject, public QQmlParserStatus Q_INTERFACES(QQmlParserStatus) Q_PROPERTY(QString category READ category WRITE setCategory FINAL) Q_PROPERTY(QString fileName READ fileName WRITE setFileName FINAL) + QML_NAMED_ELEMENT(Settings) public: explicit QQmlSettings(QObject *parent = 0); diff --git a/src/imports/shapes/plugin.cpp b/src/imports/shapes/plugin.cpp index 6197b2fdf5..0b6191d5bb 100644 --- a/src/imports/shapes/plugin.cpp +++ b/src/imports/shapes/plugin.cpp @@ -57,20 +57,11 @@ public: void registerTypes(const char *uri) override { Q_ASSERT(QByteArray(uri) == QByteArray("QtQuick.Shapes")); - qmlRegisterType<QQuickShape>(uri, 1, 0, "Shape"); - qmlRegisterType<QQuickShapePath>(uri, 1, 0, "ShapePath"); - qmlRegisterUncreatableType<QQuickShapeGradient>(uri, 1, 0, "ShapeGradient", QQuickShapeGradient::tr("ShapeGradient is an abstract base class")); - qmlRegisterType<QQuickShapeLinearGradient>(uri, 1, 0, "LinearGradient"); - qmlRegisterType<QQuickShapeRadialGradient>(uri, 1, 0, "RadialGradient"); - qmlRegisterType<QQuickShapeConicalGradient>(uri, 1, 0, "ConicalGradient"); + qmlRegisterTypesAndRevisions<QQuickShape, QQuickShapePath, QQuickShapeGradient, + QQuickShapeLinearGradient, QQuickShapeRadialGradient, + QQuickShapeConicalGradient>(uri, 1); qmlRegisterModule(uri, 1, 15); - - // revision in Qt 5.11: added containsMode property - qmlRegisterType<QQuickShape, 11>(uri, 1, 11, "Shape"); - - // revision in Qt 5.14: added scale property - qmlRegisterType<QQuickShapePath, 14>(uri, 1, 14, "ShapePath"); // QTBUG-61942 } }; diff --git a/src/imports/shapes/plugins.qmltypes b/src/imports/shapes/plugins.qmltypes index cd779e7149..fed68b5137 100644 --- a/src/imports/shapes/plugins.qmltypes +++ b/src/imports/shapes/plugins.qmltypes @@ -12,8 +12,14 @@ Module { name: "QQuickShape" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtQuick.Shapes/Shape 1.0", "QtQuick.Shapes/Shape 1.11"] - exportMetaObjectRevisions: [0, 11] + exports: [ + "QtQuick.Shapes/Shape 1.0", + "QtQuick.Shapes/Shape 1.1", + "QtQuick.Shapes/Shape 1.11", + "QtQuick.Shapes/Shape 1.4", + "QtQuick.Shapes/Shape 1.7" + ] + exportMetaObjectRevisions: [0, 1, 11, 4, 7] Enum { name: "RendererType" values: { @@ -51,8 +57,11 @@ Module { name: "QQuickShapeConicalGradient" defaultProperty: "stops" prototype: "QQuickShapeGradient" - exports: ["QtQuick.Shapes/ConicalGradient 1.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Shapes/ConicalGradient 1.0", + "QtQuick.Shapes/ConicalGradient 1.12" + ] + exportMetaObjectRevisions: [0, 12] Property { name: "centerX"; type: "double" } Property { name: "centerY"; type: "double" } Property { name: "angle"; type: "double" } @@ -61,9 +70,12 @@ Module { name: "QQuickShapeGradient" defaultProperty: "stops" prototype: "QQuickGradient" - exports: ["QtQuick.Shapes/ShapeGradient 1.0"] + exports: [ + "QtQuick.Shapes/ShapeGradient 1.0", + "QtQuick.Shapes/ShapeGradient 1.12" + ] isCreatable: false - exportMetaObjectRevisions: [0] + exportMetaObjectRevisions: [0, 12] Enum { name: "SpreadMode" values: { @@ -78,8 +90,11 @@ Module { name: "QQuickShapeLinearGradient" defaultProperty: "stops" prototype: "QQuickShapeGradient" - exports: ["QtQuick.Shapes/LinearGradient 1.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Shapes/LinearGradient 1.0", + "QtQuick.Shapes/LinearGradient 1.12" + ] + exportMetaObjectRevisions: [0, 12] Property { name: "x1"; type: "double" } Property { name: "y1"; type: "double" } Property { name: "x2"; type: "double" } @@ -142,8 +157,11 @@ Module { name: "QQuickShapeRadialGradient" defaultProperty: "stops" prototype: "QQuickShapeGradient" - exports: ["QtQuick.Shapes/RadialGradient 1.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQuick.Shapes/RadialGradient 1.0", + "QtQuick.Shapes/RadialGradient 1.12" + ] + exportMetaObjectRevisions: [0, 12] Property { name: "centerX"; type: "double" } Property { name: "centerY"; type: "double" } Property { name: "centerRadius"; type: "double" } diff --git a/src/imports/statemachine/finalstate.h b/src/imports/statemachine/finalstate.h index 974d8a8fac..9cdbb51584 100644 --- a/src/imports/statemachine/finalstate.h +++ b/src/imports/statemachine/finalstate.h @@ -45,6 +45,7 @@ #include <QtCore/QFinalState> #include <QtQml/QQmlListProperty> +#include <QtQml/qqml.h> QT_BEGIN_NAMESPACE @@ -54,6 +55,7 @@ class FinalState : public QFinalState Q_OBJECT Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged) Q_CLASSINFO("DefaultProperty", "children") + QML_ELEMENT public: explicit FinalState(QState *parent = 0); diff --git a/src/imports/statemachine/plugin.cpp b/src/imports/statemachine/plugin.cpp index 0ec2c353fc..993e91afea 100644 --- a/src/imports/statemachine/plugin.cpp +++ b/src/imports/statemachine/plugin.cpp @@ -42,6 +42,7 @@ #include "state.h" #include "statemachine.h" #include "timeouttransition.h" +#include "statemachineforeign.h" #include <QHistoryState> #include <QQmlExtensionPlugin> @@ -58,15 +59,10 @@ public: QtQmlStateMachinePlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { } void registerTypes(const char *uri) override { - qmlRegisterType<State>(uri, 1, 0, "State"); - qmlRegisterType<StateMachine>(uri, 1, 0, "StateMachine"); - qmlRegisterType<QHistoryState>(uri, 1, 0, "HistoryState"); - qmlRegisterType<FinalState>(uri, 1, 0, "FinalState"); - qmlRegisterUncreatableType<QState>(uri, 1, 0, "QState", "Don't use this, use State instead"); - qmlRegisterUncreatableType<QAbstractState>(uri, 1, 0, "QAbstractState", "Don't use this, use State instead"); - qmlRegisterUncreatableType<QSignalTransition>(uri, 1, 0, "QSignalTransition", "Don't use this, use SignalTransition instead"); - qmlRegisterCustomType<SignalTransition>(uri, 1, 0, "SignalTransition", new SignalTransitionParser); - qmlRegisterType<TimeoutTransition>(uri, 1, 0, "TimeoutTransition"); + qmlRegisterTypesAndRevisions< + State, StateMachine, FinalState, TimeoutTransition, SignalTransition, + QHistoryStateForeign, QStateForeign, QAbstractStateForeign, QSignalTransitionForeign + >(uri, 1); qmlProtectModule(uri, 1); qmlRegisterModule(uri, 1, 15); diff --git a/src/imports/statemachine/plugins.qmltypes b/src/imports/statemachine/plugins.qmltypes index 541b1cc114..206159f057 100644 --- a/src/imports/statemachine/plugins.qmltypes +++ b/src/imports/statemachine/plugins.qmltypes @@ -137,8 +137,11 @@ Module { Component { name: "SignalTransition" prototype: "QSignalTransition" - exports: ["QtQml.StateMachine/SignalTransition 1.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQml.StateMachine/SignalTransition 1.0", + "QtQml.StateMachine/SignalTransition 1.1" + ] + exportMetaObjectRevisions: [0, 1] Property { name: "signal"; type: "QJSValue" } Property { name: "guard"; type: "QQmlScriptString" } Signal { name: "invokeYourself" } @@ -166,8 +169,11 @@ Module { Component { name: "TimeoutTransition" prototype: "QSignalTransition" - exports: ["QtQml.StateMachine/TimeoutTransition 1.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtQml.StateMachine/TimeoutTransition 1.0", + "QtQml.StateMachine/TimeoutTransition 1.1" + ] + exportMetaObjectRevisions: [0, 1] Property { name: "timeout"; type: "int" } } } diff --git a/src/imports/statemachine/signaltransition.h b/src/imports/statemachine/signaltransition.h index f005c5e9b1..748e230b3e 100644 --- a/src/imports/statemachine/signaltransition.h +++ b/src/imports/statemachine/signaltransition.h @@ -57,6 +57,7 @@ class SignalTransition : public QSignalTransition, public QQmlParserStatus Q_INTERFACES(QQmlParserStatus) Q_PROPERTY(QJSValue signal READ signal WRITE setSignal NOTIFY qmlSignalChanged) Q_PROPERTY(QQmlScriptString guard READ guard WRITE setGuard NOTIFY guardChanged) + QML_ELEMENT public: explicit SignalTransition(QState *parent = nullptr); @@ -101,6 +102,12 @@ public: void applyBindings(QObject *object, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override; }; +template<> +inline QQmlCustomParser *qmlCreateCustomParser<SignalTransition>() +{ + return new SignalTransitionParser; +} + QT_END_NAMESPACE #endif diff --git a/src/imports/statemachine/state.h b/src/imports/statemachine/state.h index 8e8cefab19..4b17ea0e5f 100644 --- a/src/imports/statemachine/state.h +++ b/src/imports/statemachine/state.h @@ -45,6 +45,7 @@ #include <QtCore/QState> #include <QtQml/QQmlParserStatus> #include <QtQml/QQmlListProperty> +#include <QtQml/qqml.h> QT_BEGIN_NAMESPACE @@ -54,6 +55,7 @@ class State : public QState, public QQmlParserStatus Q_INTERFACES(QQmlParserStatus) Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged) Q_CLASSINFO("DefaultProperty", "children") + QML_ELEMENT public: explicit State(QState *parent = 0); diff --git a/src/imports/statemachine/statemachine.h b/src/imports/statemachine/statemachine.h index 1fa7a9da43..04894477b3 100644 --- a/src/imports/statemachine/statemachine.h +++ b/src/imports/statemachine/statemachine.h @@ -45,6 +45,7 @@ #include <QtCore/QStateMachine> #include <QtQml/QQmlParserStatus> #include <QtQml/QQmlListProperty> +#include <QtQml/qqml.h> QT_BEGIN_NAMESPACE @@ -58,6 +59,7 @@ class StateMachine : public QStateMachine, public QQmlParserStatus Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY qmlRunningChanged) Q_CLASSINFO("DefaultProperty", "children") + QML_ELEMENT public: explicit StateMachine(QObject *parent = 0); diff --git a/src/imports/statemachine/statemachine.pro b/src/imports/statemachine/statemachine.pro index 926a9d4a5e..7affc768e2 100644 --- a/src/imports/statemachine/statemachine.pro +++ b/src/imports/statemachine/statemachine.pro @@ -19,6 +19,7 @@ HEADERS = \ $$PWD/signaltransition.h \ $$PWD/state.h \ $$PWD/statemachine.h \ - $$PWD/timeouttransition.h + $$PWD/timeouttransition.h \ + $$PWD/statemachineforeign.h load(qml_plugin) diff --git a/src/imports/statemachine/statemachineforeign.h b/src/imports/statemachine/statemachineforeign.h new file mode 100644 index 0000000000..363c9d0e31 --- /dev/null +++ b/src/imports/statemachine/statemachineforeign.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef STATEMACHINEFOREIGN_H +#define STATEMACHINEFOREIGN_H + +#include <QtQml/qqml.h> +#include <QtCore/qhistorystate.h> +#include <QtCore/qstate.h> +#include <QtCore/qabstractstate.h> +#include <QtCore/qsignaltransition.h> + +struct QHistoryStateForeign +{ + Q_GADGET + QML_FOREIGN(QHistoryState) + QML_NAMED_ELEMENT(HistoryState) +}; + +struct QStateForeign +{ + Q_GADGET + QML_FOREIGN(QState) + QML_NAMED_ELEMENT(QState) + QML_UNCREATABLE("Don't use this, use State instead.") +}; + +struct QAbstractStateForeign +{ + Q_GADGET + QML_FOREIGN(QAbstractState) + QML_NAMED_ELEMENT(QAbstractState) + QML_UNCREATABLE("Don't use this, use State instead.") +}; + +struct QSignalTransitionForeign +{ + Q_GADGET + QML_FOREIGN(QSignalTransition) + QML_NAMED_ELEMENT(QSignalTransition) + QML_UNCREATABLE("Don't use this, use SignalTransition instead.") +}; + +#endif // STATEMACHINEFOREIGN_H diff --git a/src/imports/statemachine/timeouttransition.h b/src/imports/statemachine/timeouttransition.h index 2fc850fc70..cc3a22e0e5 100644 --- a/src/imports/statemachine/timeouttransition.h +++ b/src/imports/statemachine/timeouttransition.h @@ -42,6 +42,7 @@ #include <QtCore/QSignalTransition> #include <QtQml/QQmlParserStatus> +#include <QtQml/qqml.h> QT_BEGIN_NAMESPACE class QTimer; @@ -51,6 +52,7 @@ class TimeoutTransition : public QSignalTransition, public QQmlParserStatus Q_OBJECT Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged) Q_INTERFACES(QQmlParserStatus) + QML_ELEMENT public: TimeoutTransition(QState *parent = nullptr); diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp index a8bcfa2764..86f0dd6dc7 100644 --- a/src/imports/testlib/main.cpp +++ b/src/imports/testlib/main.cpp @@ -37,99 +37,15 @@ ** ****************************************************************************/ -#include <private/qv4scopedvalue_p.h> #include <QtQml/qqmlextensionplugin.h> #include <QtQml/qqml.h> -#include <QtQml/qjsvalue.h> -#include <QtQml/qjsengine.h> -#include "QtQuickTest/private/quicktestresult_p.h" -#include "QtQuickTest/private/quicktestevent_p.h" -#include "private/qtestoptions_p.h" -#include "QtQuick/qquickitem.h" -#include <QtQml/private/qqmlengine_p.h> -#include <QtGui/QGuiApplication> -#include <QtGui/qstylehints.h> +#include <QtQuickTest/private/quicktestresult_p.h> +#include <QtQuickTest/private/quicktestevent_p.h> +#include <QtQuickTest/private/quicktestutil_p.h> +#include <QtQuickTest/private/qtestoptions_p.h> QML_DECLARE_TYPE(QuickTestResult) QML_DECLARE_TYPE(QuickTestEvent) - -#include <QtDebug> - -QT_BEGIN_NAMESPACE - -class QuickTestUtil : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool printAvailableFunctions READ printAvailableFunctions NOTIFY printAvailableFunctionsChanged) - Q_PROPERTY(int dragThreshold READ dragThreshold NOTIFY dragThresholdChanged) -public: - QuickTestUtil(QObject *parent = nullptr) - :QObject(parent) - {} - - ~QuickTestUtil() override - {} - bool printAvailableFunctions() const - { - return QTest::printAvailableFunctions; - } - int dragThreshold() const { return QGuiApplication::styleHints()->startDragDistance(); } - -Q_SIGNALS: - void printAvailableFunctionsChanged(); - void dragThresholdChanged(); - -public Q_SLOTS: - - QJSValue typeName(const QVariant& v) const - { - QString name(v.typeName()); - if (v.canConvert<QObject*>()) { - QQmlType type; - const QMetaObject *mo = v.value<QObject*>()->metaObject(); - while (!type.isValid() && mo) { - type = QQmlMetaType::qmlType(mo); - mo = mo->superClass(); - } - if (type.isValid()) { - name = type.qmlTypeName(); - } - } - - QQmlEngine *engine = qmlEngine(this); - QV4::ExecutionEngine *v4 = engine->handle(); - return QJSValue(v4, v4->newString(name)->asReturnedValue()); - } - - bool compare(const QVariant& act, const QVariant& exp) const { - return act == exp; - } - - QJSValue callerFile(int frameIndex = 0) const - { - QQmlEngine *engine = qmlEngine(this); - QV4::ExecutionEngine *v4 = engine->handle(); - QV4::Scope scope(v4); - - QVector<QV4::StackFrame> stack = v4->stackTrace(frameIndex + 2); - return (stack.size() > frameIndex + 1) - ? QJSValue(v4, v4->newString(stack.at(frameIndex + 1).source)->asReturnedValue()) - : QJSValue(); - } - int callerLine(int frameIndex = 0) const - { - QQmlEngine *engine = qmlEngine(this); - QV4::ExecutionEngine *v4 = engine->handle(); - - QVector<QV4::StackFrame> stack = v4->stackTrace(frameIndex + 2); - if (stack.size() > frameIndex + 1) - return stack.at(frameIndex + 1).line; - return -1; - } -}; - -QT_END_NAMESPACE - QML_DECLARE_TYPE(QuickTestUtil) QT_BEGIN_NAMESPACE @@ -144,13 +60,8 @@ public: void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtTest")); - qmlRegisterType<QuickTestResult, 0>(uri,1,0,"TestResult"); - qmlRegisterType<QuickTestResult, 1>(uri,1,1,"TestResult"); - qmlRegisterType<QuickTestResult, 13>(uri,1,13,"TestResult"); - qmlRegisterType<QuickTestEvent>(uri,1,0,"TestEvent"); - qmlRegisterType<QuickTestEvent>(uri,1,2,"TestEvent"); - qmlRegisterType<QuickTestUtil>(uri,1,0,"TestUtil"); - qmlRegisterAnonymousType<QQuickTouchEventSequence>(uri); + qmlRegisterTypesAndRevisions<QuickTestResult, QuickTestEvent, + QuickTestUtil, QQuickTouchEventSequence>(uri, 1); qmlRegisterModule(uri, 1, 15); } diff --git a/src/imports/testlib/plugins.qmltypes b/src/imports/testlib/plugins.qmltypes index 6a1371e5f1..0491079e86 100644 --- a/src/imports/testlib/plugins.qmltypes +++ b/src/imports/testlib/plugins.qmltypes @@ -46,7 +46,7 @@ Module { name: "QuickTestEvent" prototype: "QObject" exports: ["QtTest/TestEvent 1.0", "QtTest/TestEvent 1.2"] - exportMetaObjectRevisions: [0, 0] + exportMetaObjectRevisions: [0, 2] Property { name: "defaultMouseDelay"; type: "int"; isReadonly: true } Method { name: "keyPress" diff --git a/src/imports/wavefrontmesh/plugin.cpp b/src/imports/wavefrontmesh/plugin.cpp index c695b5d19c..937d3a8ff0 100644 --- a/src/imports/wavefrontmesh/plugin.cpp +++ b/src/imports/wavefrontmesh/plugin.cpp @@ -57,7 +57,7 @@ public: void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.wavefrontmesh")); - qmlRegisterType<QWavefrontMesh>(uri, 1, 0, "WavefrontMesh"); + qmlRegisterTypesAndRevisions<QWavefrontMesh>(uri, 1); qmlRegisterModule(uri, 1, 15); } diff --git a/src/imports/wavefrontmesh/qwavefrontmesh.h b/src/imports/wavefrontmesh/qwavefrontmesh.h index e3ded8078e..a8a40c1a6a 100644 --- a/src/imports/wavefrontmesh/qwavefrontmesh.h +++ b/src/imports/wavefrontmesh/qwavefrontmesh.h @@ -55,6 +55,8 @@ class QWavefrontMesh : public QQuickShaderEffectMesh Q_PROPERTY(Error lastError READ lastError NOTIFY lastErrorChanged) Q_PROPERTY(QVector3D projectionPlaneV READ projectionPlaneV WRITE setProjectionPlaneV NOTIFY projectionPlaneVChanged) Q_PROPERTY(QVector3D projectionPlaneW READ projectionPlaneW WRITE setProjectionPlaneW NOTIFY projectionPlaneWChanged) + QML_NAMED_ELEMENT(WavefrontMesh) + public: enum Error { NoError, diff --git a/src/imports/window/plugins.qmltypes b/src/imports/window/plugins.qmltypes index 82b7ce0fc5..5d6cf33f4f 100644 --- a/src/imports/window/plugins.qmltypes +++ b/src/imports/window/plugins.qmltypes @@ -24,9 +24,13 @@ Module { Component { name: "QQuickScreen" prototype: "QObject" - exports: ["QtQuick.Window/Screen 2.0", "QtQuick.Window/Screen 2.3"] + exports: [ + "QtQuick.Window/Screen 2.0", + "QtQuick.Window/Screen 2.10", + "QtQuick.Window/Screen 2.3" + ] isCreatable: false - exportMetaObjectRevisions: [0, 3] + exportMetaObjectRevisions: [0, 10, 3] attachedType: "QQuickScreenAttached" } Component { @@ -100,6 +104,12 @@ Module { "NativeTextRendering": 1 } } + Enum { + name: "NativeObjectType" + values: { + "NativeObjectTexture": 0 + } + } Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } Property { name: "color"; type: "QColor" } Property { name: "contentItem"; type: "QQuickItem"; isReadonly: true; isPointer: true } @@ -163,10 +173,11 @@ Module { exports: [ "QtQuick.Window/Window 2.1", "QtQuick.Window/Window 2.13", + "QtQuick.Window/Window 2.14", "QtQuick.Window/Window 2.2", "QtQuick.Window/Window 2.3" ] - exportMetaObjectRevisions: [0, 13, 2, 3] + exportMetaObjectRevisions: [1, 13, 14, 2, 3] attachedType: "QQuickWindowAttached" Property { name: "visible"; type: "bool" } Property { name: "visibility"; type: "Visibility" } |