diff options
| author | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-03-03 18:36:51 +0100 |
|---|---|---|
| committer | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-03-22 16:20:10 +0000 |
| commit | ae1c3eba3e7e11a9b1ab4d18792c82c9bb6e62de (patch) | |
| tree | 0afbf5ed19f00a91ff8873ef52c190f50acc1436 /src/qml/jsruntime/qv4sequenceobject.cpp | |
| parent | 226419514e9a05040e691ac84bae5e1fb5e5191a (diff) | |
Remove QModelIndexList value type, use Array instead
We implement this by adding QModelIndexList to the
set of sequence types.
Change-Id: If7e0e88ab0c2916c2b65a926f8241549520d7391
Reviewed-by: Stephen Kelly <steveire@gmail.com>
Diffstat (limited to 'src/qml/jsruntime/qv4sequenceobject.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4sequenceobject.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index a7e3b22cd2..f7adf6eb18 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -41,6 +41,9 @@ #include <private/qv4scopedvalue_p.h> #include "qv4runtime_p.h" #include "qv4objectiterator_p.h" +#include <private/qqmlvaluetypewrapper_p.h> +#include <private/qqmlmodelindexvaluetype_p.h> +#include <QtCore/qabstractitemmodel.h> #include <algorithm> @@ -71,7 +74,8 @@ static void generateWarning(QV4::ExecutionEngine *v4, const QString& description F(bool, Bool, QList<bool>, false) \ F(QString, String, QList<QString>, QString()) \ F(QString, QString, QStringList, QString()) \ - F(QUrl, Url, QList<QUrl>, QUrl()) + F(QUrl, Url, QList<QUrl>, QUrl()) \ + F(QModelIndex, QModelIndex, QModelIndexList, QModelIndex()) static QV4::ReturnedValue convertElementToValue(QV4::ExecutionEngine *engine, const QString &element) { @@ -88,6 +92,12 @@ static QV4::ReturnedValue convertElementToValue(QV4::ExecutionEngine *engine, co return engine->newString(element.toString())->asReturnedValue(); } +static QV4::ReturnedValue convertElementToValue(QV4::ExecutionEngine *engine, const QModelIndex &element) +{ + const QMetaObject *vtmo = QQmlValueTypeFactory::metaObjectForMetaType(QMetaType::QModelIndex); + return QV4::QQmlValueTypeWrapper::create(engine, QVariant(element), vtmo, QMetaType::QModelIndex); +} + static QV4::ReturnedValue convertElementToValue(QV4::ExecutionEngine *, qreal element) { return QV4::Encode(element); @@ -113,6 +123,11 @@ static QString convertElementToString(const QUrl &element) return element.toString(); } +static QString convertElementToString(const QModelIndex &element) +{ + return reinterpret_cast<const QQmlModelIndexValueType *>(&element)->toString(); +} + static QString convertElementToString(qreal element) { QString qstr; @@ -145,6 +160,14 @@ template <> QUrl convertValueToElement(const Value &value) return QUrl(value.toQString()); } +template <> QModelIndex convertValueToElement(const Value &value) +{ + const QQmlValueTypeWrapper *v = value_cast<QQmlValueTypeWrapper>(value); + if (v) + return v->toVariant().toModelIndex(); + return QModelIndex(); +} + template <> qreal convertValueToElement(const Value &value) { return value.toNumber(); @@ -541,6 +564,9 @@ DEFINE_OBJECT_VTABLE(QQmlIntList); typedef QQmlSequence<QList<QUrl> > QQmlUrlList; template<> DEFINE_OBJECT_VTABLE(QQmlUrlList); +typedef QQmlSequence<QModelIndexList> QQmlQModelIndexList; +template<> +DEFINE_OBJECT_VTABLE(QQmlQModelIndexList); typedef QQmlSequence<QList<bool> > QQmlBoolList; template<> DEFINE_OBJECT_VTABLE(QQmlBoolList); |
