summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/models/models.pro3
-rw-r--r--examples/models/quicktextfilemodel/main.qml64
-rw-r--r--examples/models/quicktextfilemodel/quicktextfilemodel.qmlproject14
-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
-rw-r--r--examples/shared/README2
-rw-r--r--examples/shared/countries.txt241
9 files changed, 490 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
diff --git a/examples/shared/README b/examples/shared/README
new file mode 100644
index 0000000..7764c48
--- /dev/null
+++ b/examples/shared/README
@@ -0,0 +1,2 @@
+These files are shared between multiple examples as a set of common and
+reusuable components.
diff --git a/examples/shared/countries.txt b/examples/shared/countries.txt
new file mode 100644
index 0000000..39e7f3d
--- /dev/null
+++ b/examples/shared/countries.txt
@@ -0,0 +1,241 @@
+Afghanistan
+Albania
+Algeria
+American Samoa
+Andorra
+Angola
+Anguilla
+Antarctica
+Antigua And Barbuda
+Argentina
+Armenia
+Aruba
+Australia
+Austria
+Azerbaijan
+Bahamas
+Bahrain
+Bangladesh
+Barbados
+Belarus
+Belgium
+Belize
+Benin
+Bermuda
+Bhutan
+Bolivia
+Bosnia And Herzegowina
+Botswana
+Bouvet Island
+Brazil
+British Indian Ocean Territory
+British Virgin Islands
+Brunei Darussalam
+Bulgaria
+Burkina Faso
+Burundi
+Cambodia
+Cameroon
+Canada
+Cape Verde
+Cayman Islands
+Central African Republic
+Chad
+Chile
+China
+Christmas Island
+Cocos Islands
+Colombia
+Comoros
+Cook Islands
+Costa Rica
+Croatia
+Cuba
+Cyprus
+Czech Republic
+Democratic Republic Of Congo
+Democratic Republic Of Korea
+Denmark
+Djibouti
+Dominica
+Dominican Republic
+EastTimor
+Ecuador
+Egypt
+El Salvador
+Equatorial Guinea
+Eritrea
+Estonia
+Ethiopia
+Falkland Islands
+Faroe Islands
+Fiji
+Finland
+France
+French Guiana
+French Polynesia
+French Southern Territories
+Gabon
+Gambia
+Georgia
+Germany
+Ghana
+Gibraltar
+Greece
+Greenland
+Grenada
+Guadeloupe
+Guam
+Guatemala
+Guinea
+Guinea Bissau
+Guyana
+Haiti
+Heard And McDonald Islands
+Honduras
+Hong Kong
+Hungary
+Iceland
+India
+Indonesia
+Iran
+Iraq
+Ireland
+Israel
+Italy
+Ivory Coast
+Jamaica
+Japan
+Jordan
+Kazakhstan
+Kenya
+Kiribati
+Kuwait
+Kyrgyzstan
+Lao
+Latvia
+Lebanon
+Lesotho
+Liberia
+Libyan Arab Jamahiriya
+Liechtenstein
+Lithuania
+Luxembourg
+Macau
+Macedonia
+Madagascar
+Malawi
+Malaysia
+Maldives
+Mali
+Malta
+Marshall Islands
+Martinique
+Mauritania
+Mauritius
+Mayotte
+Metropolitan France
+Mexico
+Micronesia
+Moldova
+Monaco
+Mongolia
+Montserrat
+Morocco
+Mozambique
+Myanmar
+Namibia
+Nauru
+Nepal
+Netherlands
+Netherlands Antilles
+New Caledonia
+New Zealand
+Nicaragua
+Niger
+Nigeria
+Niue
+Norfolk Island
+Northern Mariana Islands
+Norway
+Oman
+Pakistan
+Palau
+Palestinian Territory
+Panama
+Papua New Guinea
+Paraguay
+Peoples Republic Of Congo
+Peru
+Philippines
+Pitcairn
+Poland
+Portugal
+Puerto Rico
+Qatar
+Republic Of Korea
+Reunion
+Romania
+Russian Federation
+Rwanda
+Saint Kitts And Nevis
+Samoa
+San Marino
+Sao Tome And Principe
+Saudi Arabia
+Senegal
+Serbia And Montenegro
+Seychelles
+Sierra Leone
+Singapore
+Slovakia
+Slovenia
+Solomon Islands
+Somalia
+South Africa
+South Georgia And The South Sandwich Islands
+Spain
+Sri Lanka
+St Helena
+St Lucia
+St Pierre And Miquelon
+St Vincent And The Grenadines
+Sudan
+Suriname
+Svalbard And Jan Mayen Islands
+Swaziland
+Sweden
+Switzerland
+Syrian Arab Republic
+Taiwan
+Tajikistan
+Tanzania
+Thailand
+Togo
+Tokelau
+Tonga
+Trinidad And Tobago
+Tunisia
+Turkey
+Turkmenistan
+Turks And Caicos Islands
+Tuvalu
+US Virgin Islands
+Uganda
+Ukraine
+United Arab Emirates
+United Kingdom
+United States
+United States Minor Outlying Islands
+Uruguay
+Uzbekistan
+Vanuatu
+Vatican City State
+Venezuela
+Viet Nam
+Wallis And Futuna Islands
+Western Sahara
+Yemen
+Yugoslavia
+Zambia
+Zimbabwe