diff options
Diffstat (limited to 'examples/models')
-rw-r--r-- | examples/models/models.pro | 3 | ||||
-rw-r--r-- | examples/models/quicktextfilemodel/main.qml | 64 | ||||
-rw-r--r-- | examples/models/quicktextfilemodel/quicktextfilemodel.qmlproject | 14 | ||||
-rw-r--r-- | examples/models/textfilemodel/main.cpp | 69 | ||||
-rw-r--r-- | examples/models/textfilemodel/main.qml | 86 | ||||
-rw-r--r-- | examples/models/textfilemodel/resources.qrc | 6 | ||||
-rw-r--r-- | examples/models/textfilemodel/textfilemodel.pro | 6 |
7 files changed, 247 insertions, 1 deletions
diff --git a/examples/models/models.pro b/examples/models/models.pro index 459bb7a..e1efe4f 100644 --- a/examples/models/models.pro +++ b/examples/models/models.pro @@ -1,4 +1,5 @@ TEMPLATE = subdirs SUBDIRS = \ fsviewer \ - completionmodel + completionmodel \ + textfilemodel diff --git a/examples/models/quicktextfilemodel/main.qml b/examples/models/quicktextfilemodel/main.qml new file mode 100644 index 0000000..d93d360 --- /dev/null +++ b/examples/models/quicktextfilemodel/main.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Instituto Nokia de Tecnologia (INdT). +** Contact: http://www.qt-project.org/ +** +** This file is part of the UiHelpers playground module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Playground.UiHelpers.Models 1.0 + +Rectangle { + id: root + + width: 200 + height: 400 + + TextFileModel { + id: fileModel + source: "../../shared/countries.txt" + } + + ListView { + anchors.fill: parent + model: fileModel + delegate: Text { + text: display + height: 20 + } + } +} diff --git a/examples/models/quicktextfilemodel/quicktextfilemodel.qmlproject b/examples/models/quicktextfilemodel/quicktextfilemodel.qmlproject new file mode 100644 index 0000000..bea5f85 --- /dev/null +++ b/examples/models/quicktextfilemodel/quicktextfilemodel.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + mainFile: "main.qml" + QmlFiles { + directory: "" + } + JavaScriptFiles { + directory: "" + } + ImageFiles { + directory: "" + } +} diff --git a/examples/models/textfilemodel/main.cpp b/examples/models/textfilemodel/main.cpp new file mode 100644 index 0000000..d3ad488 --- /dev/null +++ b/examples/models/textfilemodel/main.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Instituto Nokia de Tecnologia (INdT) +** Contact: http://www.qt-project.org/ +** +** This file is part of the UiHelpers playground module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/QGuiApplication> +#include <QtQuick/QQuickView> +#include <UiHelpers/UiCompletionModel> +#include <UiHelpers/UiTextFileModel> +#include <QtQml/QQmlContext> +#include <QObject> + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(resources); + QGuiApplication app(argc, argv); + + UiHelpers::UiTextFileModel *fileModel = new UiHelpers::UiTextFileModel(); + fileModel->setSource(":/countries.txt"); + + UiHelpers::UiCompletionModel model; + model.setCaseSensitivity(Qt::CaseInsensitive); + model.setSourceModel(fileModel); + + QQuickView v; + v.rootContext()->setContextProperty("completionModel", &model); + v.setWindowTitle(QObject::tr("Completion Model with TextFileModel")); + v.setSource(QString("qrc:/main.qml")); + + v.show(); + + return app.exec(); +} diff --git a/examples/models/textfilemodel/main.qml b/examples/models/textfilemodel/main.qml new file mode 100644 index 0000000..5bef718 --- /dev/null +++ b/examples/models/textfilemodel/main.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Instituto Nokia de Tecnologia (INdT). +** Contact: http://www.qt-project.org/ +** +** This file is part of the UiHelpers playground module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 300 + height: 400 + color: "blue" + + Rectangle { + y: 10 + anchors { + left: parent.left + leftMargin: 10 + right: parent.right + rightMargin: 10 + } + height: 20 + color: "white" + TextInput { + anchors.fill: parent + clip: true + onTextChanged: completionModel.setCompletionPrefix(text) + } + } + + Rectangle { + anchors { + fill: parent + topMargin: 40 + leftMargin: 10 + rightMargin: 10 + bottomMargin: 10 + } + color: "white" + + ListView { + anchors.fill: parent + model: completionModel + clip: true + delegate: Text { + text: display + height: 17 + } + } + } +} diff --git a/examples/models/textfilemodel/resources.qrc b/examples/models/textfilemodel/resources.qrc new file mode 100644 index 0000000..24d92c7 --- /dev/null +++ b/examples/models/textfilemodel/resources.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file alias="main.qml">main.qml</file> + <file alias="countries.txt">../../shared/countries.txt</file> +</qresource> +</RCC> diff --git a/examples/models/textfilemodel/textfilemodel.pro b/examples/models/textfilemodel/textfilemodel.pro new file mode 100644 index 0000000..d0ff25e --- /dev/null +++ b/examples/models/textfilemodel/textfilemodel.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +QT += uihelpers quick + +RESOURCES = resources.qrc + +SOURCES = main.cpp |