diff options
| author | Simon Hausmann <simon.hausmann@digia.com> | 2014-01-08 13:41:07 +0100 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-08 14:28:58 +0100 |
| commit | 06178e0d0f18d15635fbcf23e179e4fbdf8c68a8 (patch) | |
| tree | 790f1122900cc1a101be5a6c54f93e4209992da3 /src/dialogs/Private/qquickwritingsystemlistmodel.cpp | |
| parent | c549c7795884d1e858aa7963a550b74c76a2f02d (diff) | |
Revert "dialog-private: replace QJSValue with QQmlV4Handle in js functions"
This reverts commit b365471f0abc79f08bf0d852aea3be0a601c6901.
We need to be able to change the internal API in QtQml, which is difficult if
other modules are using it. It's much easier here to simply use QJSValue.
Change-Id: Ibbc078d8deffcf4f5a96a4cfe50c836d6653d666
Reviewed-by: Liang Qi <liang.qi@digia.com>
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() |
