summaryrefslogtreecommitdiffstats
path: root/examples/models/textfilemodel
diff options
context:
space:
mode:
Diffstat (limited to 'examples/models/textfilemodel')
-rw-r--r--examples/models/textfilemodel/main.cpp69
-rw-r--r--examples/models/textfilemodel/main.qml86
-rw-r--r--examples/models/textfilemodel/resources.qrc6
-rw-r--r--examples/models/textfilemodel/textfilemodel.pro6
4 files changed, 167 insertions, 0 deletions
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