diff options
Diffstat (limited to 'src/dialogs/Private/qquickwritingsystemlistmodel.cpp')
| -rw-r--r-- | src/dialogs/Private/qquickwritingsystemlistmodel.cpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/dialogs/Private/qquickwritingsystemlistmodel.cpp b/src/dialogs/Private/qquickwritingsystemlistmodel.cpp index f2b4ff8b8..b4dcf6315 100644 --- a/src/dialogs/Private/qquickwritingsystemlistmodel.cpp +++ b/src/dialogs/Private/qquickwritingsystemlistmodel.cpp @@ -42,16 +42,11 @@ #include "qquickwritingsystemlistmodel_p.h" #include <QtGui/qfontdatabase.h> #include <QtQml/qqmlcontext.h> -#include <private/qqmlengine_p.h> -#include <private/qv8engine_p.h> -#include <private/qv4value_p.h> -#include <private/qv4engine_p.h> -#include <private/qv4object_p.h> +#include <QtQml/qqml.h> +#include <QtQml/qqmlengine.h> QT_BEGIN_NAMESPACE -using namespace QV4; - class QQuickWritingSystemListModelPrivate { Q_DECLARE_PUBLIC(QQuickWritingSystemListModel) @@ -144,25 +139,22 @@ QStringList QQuickWritingSystemListModel::writingSystems() const return result; } -QQmlV4Handle QQuickWritingSystemListModel::get(int idx) const +QJSValue QQuickWritingSystemListModel::get(int idx) const { Q_D(const QQuickWritingSystemListModel); + QJSEngine *engine = qmlEngine(this); + if (idx < 0 || idx >= count()) - return QQmlV4Handle(Encode::undefined()); - - QQmlEngine *engine = qmlContext(this)->engine(); - QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine); - ExecutionEngine *v4engine = QV8Engine::getV4(v8engine); - Scope scope(v4engine); - ScopedObject o(scope, v4engine->newObject()); - ScopedString s(scope); - for (int ii = 0; ii < d->roleNames.keys().count(); ++ii) { - Property *p = o->insertMember((s = v4engine->newIdentifier(d->roleNames[Qt::UserRole + ii + 1])), PropertyAttributes()); - p->value = v8engine->fromVariant(data(index(idx, 0), Qt::UserRole + ii + 1)); - } + return engine->newObject(); + + QJSValue result = engine->newObject(); + int count = d->roleNames.keys().count(); + for (int i = 0; i < count; ++i) + result.setProperty(QString(d->roleNames[Qt::UserRole + i + 1]), data(index(idx, 0), Qt::UserRole + i + 1).toString()); + + return result; - return QQmlV4Handle(o); } void QQuickWritingSystemListModel::classBegin() |
