summaryrefslogtreecommitdiff
path: root/src/dialogs/Private
diff options
context:
space:
mode:
Diffstat (limited to 'src/dialogs/Private')
-rw-r--r--src/dialogs/Private/Private.pro17
-rw-r--r--src/dialogs/Private/dialogsprivateplugin.cpp66
-rw-r--r--src/dialogs/Private/qmldir3
-rw-r--r--src/dialogs/Private/qquickfontlistmodel.cpp290
-rw-r--r--src/dialogs/Private/qquickfontlistmodel_p.h125
-rw-r--r--src/dialogs/Private/qquickwritingsystemlistmodel.cpp176
-rw-r--r--src/dialogs/Private/qquickwritingsystemlistmodel_p.h100
7 files changed, 777 insertions, 0 deletions
diff --git a/src/dialogs/Private/Private.pro b/src/dialogs/Private/Private.pro
new file mode 100644
index 00000000..7f04617e
--- /dev/null
+++ b/src/dialogs/Private/Private.pro
@@ -0,0 +1,17 @@
+CXX_MODULE = qml
+TARGET = dialogsprivateplugin
+TARGETPATH = QtQuick/Dialogs/Private
+IMPORT_VERSION = 1.1
+
+SOURCES += \
+ qquickfontlistmodel.cpp \
+ qquickwritingsystemlistmodel.cpp \
+ dialogsprivateplugin.cpp
+
+HEADERS += \
+ qquickfontlistmodel_p.h \
+ qquickwritingsystemlistmodel_p.h
+
+QT += gui-private core-private qml-private
+
+load(qml_plugin)
diff --git a/src/dialogs/Private/dialogsprivateplugin.cpp b/src/dialogs/Private/dialogsprivateplugin.cpp
new file mode 100644
index 00000000..f920df30
--- /dev/null
+++ b/src/dialogs/Private/dialogsprivateplugin.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include "qquickwritingsystemlistmodel_p.h"
+#include "qquickfontlistmodel_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QtQuick2DialogsPrivatePlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
+
+public:
+ virtual void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Dialogs.Private"));
+
+ qmlRegisterType<QQuickWritingSystemListModel>(uri, 1, 1, "WritingSystemListModel");
+ qmlRegisterType<QQuickFontListModel>(uri, 1, 1, "FontListModel");
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "dialogsprivateplugin.moc"
diff --git a/src/dialogs/Private/qmldir b/src/dialogs/Private/qmldir
new file mode 100644
index 00000000..e1847155
--- /dev/null
+++ b/src/dialogs/Private/qmldir
@@ -0,0 +1,3 @@
+module QtQuick.Dialogs.Private
+plugin dialogsprivateplugin
+typeinfo plugins.qmltypes
diff --git a/src/dialogs/Private/qquickfontlistmodel.cpp b/src/dialogs/Private/qquickfontlistmodel.cpp
new file mode 100644
index 00000000..96d1824e
--- /dev/null
+++ b/src/dialogs/Private/qquickfontlistmodel.cpp
@@ -0,0 +1,290 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQuick.Dialogs 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickfontlistmodel_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>
+
+QT_BEGIN_NAMESPACE
+
+using namespace QV4;
+
+class QQuickFontListModelPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickFontListModel)
+
+public:
+ QQuickFontListModelPrivate(QQuickFontListModel *q)
+ : q_ptr(q), ws(QFontDatabase::Any)
+ , options(QSharedPointer<QFontDialogOptions>(new QFontDialogOptions()))
+ {}
+
+ QQuickFontListModel *q_ptr;
+ QFontDatabase db;
+ QFontDatabase::WritingSystem ws;
+ QSharedPointer<QFontDialogOptions> options;
+ QStringList families;
+ QHash<int, QByteArray> roleNames;
+ ~QQuickFontListModelPrivate() {}
+ void init();
+};
+
+
+void QQuickFontListModelPrivate::init()
+{
+ Q_Q(QQuickFontListModel);
+
+ families = db.families();
+
+ emit q->rowCountChanged();
+ emit q->writingSystemChanged();
+}
+
+QQuickFontListModel::QQuickFontListModel(QObject *parent)
+ : QAbstractListModel(parent), d_ptr(new QQuickFontListModelPrivate(this))
+{
+ Q_D(QQuickFontListModel);
+ d->roleNames[FontFamilyRole] = "family";
+ d->init();
+}
+
+QQuickFontListModel::~QQuickFontListModel()
+{
+}
+
+QVariant QQuickFontListModel::data(const QModelIndex &index, int role) const
+{
+ Q_D(const QQuickFontListModel);
+ QVariant rv;
+
+ if (index.row() >= d->families.size())
+ return rv;
+
+ switch (role)
+ {
+ case FontFamilyRole:
+ rv = d->families.at(index.row());
+ break;
+ default:
+ break;
+ }
+ return rv;
+}
+
+QHash<int, QByteArray> QQuickFontListModel::roleNames() const
+{
+ Q_D(const QQuickFontListModel);
+ return d->roleNames;
+}
+
+int QQuickFontListModel::rowCount(const QModelIndex &parent) const
+{
+ Q_D(const QQuickFontListModel);
+ Q_UNUSED(parent);
+ return d->families.size();
+}
+
+QModelIndex QQuickFontListModel::index(int row, int , const QModelIndex &) const
+{
+ return createIndex(row, 0);
+}
+
+QString QQuickFontListModel::writingSystem() const
+{
+ Q_D(const QQuickFontListModel);
+ return QFontDatabase::writingSystemName(d->ws);
+}
+
+void QQuickFontListModel::setWritingSystem(const QString &wSystem)
+{
+ Q_D(QQuickFontListModel);
+
+ if (wSystem == writingSystem())
+ return;
+
+ QList<QFontDatabase::WritingSystem> wss;
+ wss << QFontDatabase::Any;
+ wss << d->db.writingSystems();
+ QFontDatabase::WritingSystem ws;
+ foreach (ws, wss) {
+ if (wSystem == QFontDatabase::writingSystemName(ws)) {
+ d->ws = ws;
+ updateFamilies();
+ return;
+ }
+ }
+}
+
+void QQuickFontListModel::updateFamilies()
+{
+ Q_D(QQuickFontListModel);
+
+ beginResetModel();
+ const QFontDialogOptions::FontDialogOptions scalableMask = (QFontDialogOptions::FontDialogOptions)(QFontDialogOptions::ScalableFonts | QFontDialogOptions::NonScalableFonts);
+ const QFontDialogOptions::FontDialogOptions spacingMask = (QFontDialogOptions::FontDialogOptions)(QFontDialogOptions::ProportionalFonts | QFontDialogOptions::MonospacedFonts);
+ const QFontDialogOptions::FontDialogOptions options = d->options->options();
+
+ d->families.clear();
+ foreach (const QString &family, d->db.families(d->ws)) {
+ if ((options & scalableMask) && (options & scalableMask) != scalableMask) {
+ if (bool(options & QFontDialogOptions::ScalableFonts) != d->db.isSmoothlyScalable(family))
+ continue;
+ }
+ if ((options & spacingMask) && (options & spacingMask) != spacingMask) {
+ if (bool(options & QFontDialogOptions::MonospacedFonts) != d->db.isFixedPitch(family))
+ continue;
+ }
+ d->families << family;
+ }
+ endResetModel();
+}
+
+bool QQuickFontListModel::scalableFonts() const
+{
+ Q_D(const QQuickFontListModel);
+ return d->options->testOption(QFontDialogOptions::ScalableFonts);
+}
+
+bool QQuickFontListModel::nonScalableFonts() const
+{
+ Q_D(const QQuickFontListModel);
+ return d->options->testOption(QFontDialogOptions::NonScalableFonts);
+}
+
+bool QQuickFontListModel::monospacedFonts() const
+{
+ Q_D(const QQuickFontListModel);
+ return d->options->testOption(QFontDialogOptions::MonospacedFonts);
+}
+
+bool QQuickFontListModel::proportionalFonts() const
+{
+ Q_D(const QQuickFontListModel);
+ return d->options->testOption(QFontDialogOptions::ProportionalFonts);
+}
+
+QQmlV4Handle QQuickFontListModel::get(int idx) const
+{
+ Q_D(const QQuickFontListModel);
+
+ 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 QQmlV4Handle(o);
+}
+
+QQmlV4Handle QQuickFontListModel::pointSizes()
+{
+ QQmlEngine *engine = qmlContext(this)->engine();
+ QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine);
+ ExecutionEngine *v4engine = QV8Engine::getV4(v8engine);
+ Scope scope(v4engine);
+
+ QList<int> pss = QFontDatabase::standardSizes();
+ int size = pss.size();
+
+ Scoped<QV4::ArrayObject> a(scope, v4engine->newArrayObject());
+ a->arrayReserve(size);
+ a->arrayDataLen = size;
+ for (int i = 0; i < size; ++i)
+ a->arrayData[i].value = Primitive::fromInt32(pss.at(i));
+ a->setArrayLengthUnchecked(size);
+
+ return QQmlV4Handle(ScopedValue(scope, a.asReturnedValue()));
+}
+
+void QQuickFontListModel::classBegin()
+{
+}
+
+void QQuickFontListModel::componentComplete()
+{
+}
+
+void QQuickFontListModel::setScalableFonts(bool arg)
+{
+ Q_D(QQuickFontListModel);
+ d->options->setOption(QFontDialogOptions::ScalableFonts, arg);
+ updateFamilies();
+ emit scalableFontsChanged();
+}
+
+void QQuickFontListModel::setNonScalableFonts(bool arg)
+{
+ Q_D(QQuickFontListModel);
+ d->options->setOption(QFontDialogOptions::NonScalableFonts, arg);
+ updateFamilies();
+ emit nonScalableFontsChanged();
+}
+
+void QQuickFontListModel::setMonospacedFonts(bool arg)
+{
+ Q_D(QQuickFontListModel);
+ d->options->setOption(QFontDialogOptions::MonospacedFonts, arg);
+ updateFamilies();
+ emit monospacedFontsChanged();
+}
+
+void QQuickFontListModel::setProportionalFonts(bool arg)
+{
+ Q_D(QQuickFontListModel);
+ d->options->setOption(QFontDialogOptions::ProportionalFonts, arg);
+ updateFamilies();
+ emit proportionalFontsChanged();
+}
+
+QT_END_NAMESPACE
diff --git a/src/dialogs/Private/qquickfontlistmodel_p.h b/src/dialogs/Private/qquickfontlistmodel_p.h
new file mode 100644
index 00000000..3e2e7f71
--- /dev/null
+++ b/src/dialogs/Private/qquickfontlistmodel_p.h
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQuick.Dialogs 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKFONTLISTMODEL_P_H
+#define QQUICKFONTLISTMODEL_P_H
+
+#include <QtCore/qstringlist.h>
+#include <QtCore/qabstractitemmodel.h>
+#include <QtGui/qpa/qplatformdialoghelper.h>
+#include <QtQml/qqmlparserstatus.h>
+#include <private/qv8engine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QModelIndex;
+
+class QQuickFontListModelPrivate;
+
+class QQuickFontListModel : public QAbstractListModel, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+ Q_PROPERTY(QString writingSystem READ writingSystem WRITE setWritingSystem NOTIFY writingSystemChanged)
+
+ Q_PROPERTY(bool scalableFonts READ scalableFonts WRITE setScalableFonts NOTIFY scalableFontsChanged)
+ Q_PROPERTY(bool nonScalableFonts READ nonScalableFonts WRITE setNonScalableFonts NOTIFY nonScalableFontsChanged)
+ Q_PROPERTY(bool monospacedFonts READ monospacedFonts WRITE setMonospacedFonts NOTIFY monospacedFontsChanged)
+ Q_PROPERTY(bool proportionalFonts READ proportionalFonts WRITE setProportionalFonts NOTIFY proportionalFontsChanged)
+
+ Q_PROPERTY(int count READ count NOTIFY rowCountChanged)
+
+public:
+ QQuickFontListModel(QObject *parent = 0);
+ ~QQuickFontListModel();
+
+ enum Roles {
+ FontFamilyRole = Qt::UserRole + 1
+ };
+
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ virtual QHash<int, QByteArray> roleNames() const;
+
+ int count() const { return rowCount(QModelIndex()); }
+
+ QString writingSystem() const;
+ void setWritingSystem(const QString& writingSystem);
+
+ bool scalableFonts() const;
+ bool nonScalableFonts() const;
+ bool monospacedFonts() const;
+ bool proportionalFonts() const;
+
+ Q_INVOKABLE QQmlV4Handle get(int index) const;
+ Q_INVOKABLE QQmlV4Handle pointSizes();
+
+ virtual void classBegin();
+ virtual void componentComplete();
+
+public Q_SLOTS:
+ void setScalableFonts(bool arg);
+ void setNonScalableFonts(bool arg);
+ void setMonospacedFonts(bool arg);
+ void setProportionalFonts(bool arg);
+
+Q_SIGNALS:
+ void scalableFontsChanged();
+ void nonScalableFontsChanged();
+ void monospacedFontsChanged();
+ void proportionalFontsChanged();
+ void writingSystemChanged();
+ void rowCountChanged() const;
+
+protected:
+ void updateFamilies();
+
+private:
+ Q_DISABLE_COPY(QQuickFontListModel)
+ Q_DECLARE_PRIVATE(QQuickFontListModel)
+ QScopedPointer<QQuickFontListModelPrivate> d_ptr;
+
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKFONTLISTMODEL_P_H
diff --git a/src/dialogs/Private/qquickwritingsystemlistmodel.cpp b/src/dialogs/Private/qquickwritingsystemlistmodel.cpp
new file mode 100644
index 00000000..f2b4ff8b
--- /dev/null
+++ b/src/dialogs/Private/qquickwritingsystemlistmodel.cpp
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQuick.Dialogs 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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>
+
+QT_BEGIN_NAMESPACE
+
+using namespace QV4;
+
+class QQuickWritingSystemListModelPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickWritingSystemListModel)
+
+public:
+ QQuickWritingSystemListModelPrivate(QQuickWritingSystemListModel *q)
+ : q_ptr(q)
+ {}
+
+ QQuickWritingSystemListModel *q_ptr;
+ QList<QFontDatabase::WritingSystem> wss;
+ QHash<int, QByteArray> roleNames;
+ ~QQuickWritingSystemListModelPrivate() {}
+ void init();
+};
+
+
+void QQuickWritingSystemListModelPrivate::init()
+{
+ Q_Q(QQuickWritingSystemListModel);
+ wss << QFontDatabase::Any;
+ QFontDatabase db;
+ wss << db.writingSystems();
+
+ emit q->rowCountChanged();
+ emit q->writingSystemsChanged();
+}
+
+QQuickWritingSystemListModel::QQuickWritingSystemListModel(QObject *parent)
+ : QAbstractListModel(parent), d_ptr(new QQuickWritingSystemListModelPrivate(this))
+{
+ Q_D(QQuickWritingSystemListModel);
+ d->roleNames[WritingSystemNameRole] = "name";
+ d->roleNames[WritingSystemSampleRole] = "sample";
+ d->init();
+}
+
+QQuickWritingSystemListModel::~QQuickWritingSystemListModel()
+{
+}
+
+QVariant QQuickWritingSystemListModel::data(const QModelIndex &index, int role) const
+{
+ Q_D(const QQuickWritingSystemListModel);
+ QVariant rv;
+
+ if (index.row() >= d->wss.size())
+ return rv;
+
+ switch (role)
+ {
+ case WritingSystemNameRole:
+ rv = QFontDatabase::writingSystemName(d->wss.at(index.row()));
+ break;
+ case WritingSystemSampleRole:
+ rv = QFontDatabase::writingSystemSample(d->wss.at(index.row()));
+ break;
+ default:
+ break;
+ }
+ return rv;
+}
+
+QHash<int, QByteArray> QQuickWritingSystemListModel::roleNames() const
+{
+ Q_D(const QQuickWritingSystemListModel);
+ return d->roleNames;
+}
+
+int QQuickWritingSystemListModel::rowCount(const QModelIndex &parent) const
+{
+ Q_D(const QQuickWritingSystemListModel);
+ Q_UNUSED(parent);
+ return d->wss.size();
+}
+
+QModelIndex QQuickWritingSystemListModel::index(int row, int , const QModelIndex &) const
+{
+ return createIndex(row, 0);
+}
+
+QStringList QQuickWritingSystemListModel::writingSystems() const
+{
+ Q_D(const QQuickWritingSystemListModel);
+ QStringList result;
+ QFontDatabase::WritingSystem ws;
+ foreach (ws, d->wss)
+ result.append(QFontDatabase::writingSystemName(ws));
+
+ return result;
+}
+
+QQmlV4Handle QQuickWritingSystemListModel::get(int idx) const
+{
+ Q_D(const QQuickWritingSystemListModel);
+
+ 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 QQmlV4Handle(o);
+}
+
+void QQuickWritingSystemListModel::classBegin()
+{
+}
+
+void QQuickWritingSystemListModel::componentComplete()
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/dialogs/Private/qquickwritingsystemlistmodel_p.h b/src/dialogs/Private/qquickwritingsystemlistmodel_p.h
new file mode 100644
index 00000000..31058bbf
--- /dev/null
+++ b/src/dialogs/Private/qquickwritingsystemlistmodel_p.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQuick.Dialogs 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWRITINGSYSTEMLISTMODEL_P_H
+#define QQUICKWRITINGSYSTEMLISTMODEL_P_H
+
+#include <QtCore/qstringlist.h>
+#include <QtCore/qabstractitemmodel.h>
+#include <QtQml/qqmlparserstatus.h>
+#include <private/qv8engine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QModelIndex;
+
+class QQuickWritingSystemListModelPrivate;
+
+class QQuickWritingSystemListModel : public QAbstractListModel, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+ Q_PROPERTY(QStringList writingSystems READ writingSystems NOTIFY writingSystemsChanged)
+
+ Q_PROPERTY(int count READ count NOTIFY rowCountChanged)
+
+public:
+ QQuickWritingSystemListModel(QObject *parent = 0);
+ ~QQuickWritingSystemListModel();
+
+ enum Roles {
+ WritingSystemNameRole = Qt::UserRole + 1,
+ WritingSystemSampleRole = Qt::UserRole + 2
+ };
+
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ virtual QHash<int, QByteArray> roleNames() const;
+
+ int count() const { return rowCount(QModelIndex()); }
+
+ QStringList writingSystems() const;
+
+ Q_INVOKABLE QQmlV4Handle get(int index) const;
+
+ virtual void classBegin();
+ virtual void componentComplete();
+
+Q_SIGNALS:
+ void writingSystemsChanged();
+ void rowCountChanged() const;
+
+private:
+ Q_DISABLE_COPY(QQuickWritingSystemListModel)
+ Q_DECLARE_PRIVATE(QQuickWritingSystemListModel)
+ QScopedPointer<QQuickWritingSystemListModelPrivate> d_ptr;
+
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKWRITINGSYSTEMLISTMODEL_P_H