summaryrefslogtreecommitdiffstats
path: root/qml
diff options
context:
space:
mode:
Diffstat (limited to 'qml')
-rw-r--r--qml/js/utils.js277
-rw-r--r--qml/main.qml178
-rw-r--r--qml/models/SearchResultModel.qml32
-rw-r--r--qml/models/WeatherModel.qml134
-rw-r--r--qml/pages/BasicPage.qml205
-rw-r--r--qml/pages/CitiesPage.qml148
-rw-r--r--qml/pages/LongTermDayItem.qml156
-rw-r--r--qml/pages/LongTermPage.qml135
-rw-r--r--qml/pages/OneDayPage.qml100
-rw-r--r--qml/pages/OneDaySliderItem.qml172
-rw-r--r--qml/pages/OneDayZoomItem.qml171
-rw-r--r--qml/pages/Separator.qml52
-rw-r--r--qml/touch/ListViewDelegate.qml158
-rw-r--r--qml/touch/Separator.qml29
-rw-r--r--qml/touch/TouchLabel.qml79
-rw-r--r--qml/touch/TouchScrollView.qml59
-rw-r--r--qml/touch/TouchSlider.qml81
-rw-r--r--qml/touch/TouchTextField.qml115
-rw-r--r--qml/touch/images/BackArrow.pngbin0 -> 376 bytes
-rw-r--r--qml/touch/images/Circle.pngbin0 -> 1219 bytes
-rw-r--r--qml/touch/images/Clear.pngbin0 -> 1783 bytes
-rw-r--r--qml/touch/images/Pointer.pngbin0 -> 5674 bytes
-rw-r--r--qml/touch/images/Pointer_pressed.pngbin0 -> 5690 bytes
-rw-r--r--qml/touch/images/darkclose.pngbin0 -> 3328 bytes
-rw-r--r--qml/touch/images/magnifier.pngbin0 -> 3422 bytes
25 files changed, 2281 insertions, 0 deletions
diff --git a/qml/js/utils.js b/qml/js/utils.js
new file mode 100644
index 0000000..caa21ea
--- /dev/null
+++ b/qml/js/utils.js
@@ -0,0 +1,277 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+.pragma library
+
+// LongTermPage utils
+
+function getAfternoonIndex(dayModel)
+{
+ var index = 0
+ var count = intervalCount
+ if (count > 1)
+ index = count - 1
+ return index
+}
+
+function getTemp(isMax, dayModel) {
+ var temp = getTemperature(0, dayModel)
+ var count = dayModel.periodCount()
+ for (var i = 0; i < count; i++) {
+ var currentTemp = getTemperature(i, dayModel)
+ if (isMax)
+ temp = Math.max(temp, currentTemp)
+ else
+ temp = Math.min(temp, currentTemp)
+ }
+ return temp
+}
+
+function getMinTemp(dayModel)
+{
+ return getTemp(false, dayModel)
+}
+
+function getMaxTemp(dayModel)
+{
+ return getTemp(true, dayModel)
+}
+
+function getTempFormat(temp)
+{
+ return temp + "°C"
+}
+
+function isNegative(val)
+{
+ return val < 0
+}
+
+// OneDayPage utils
+
+function getFromTime(index, dayModel) {
+ var timerange = dayModel.getDayDetails(index, 'timeRange')
+ var pattern_time = /(.*) - .*/
+ var time = timerange.replace(pattern_time, "$1")
+ return time
+}
+
+function getToTime(index, dayModel) {
+ var timerange = dayModel.getDayDetails(index, 'timeRange')
+ var pattern_time = /.* - (.*)/
+ var time = timerange.replace(pattern_time, "$1")
+ return time
+}
+
+function getMaxMinTemp(dayModel) {
+ // at least 1 data per day
+ var minTemp = dayModel.getDayDetails(0, 'temperature')
+ var maxTemp = dayModel.getDayDetails(0, 'temperature')
+ for (var i = 1; i < dayModel.periodCount(); i++)
+ {
+ var tempTemp = dayModel.getDayDetails(i, 'temperature')
+ maxTemp = Math.max(tempTemp, maxTemp)
+ minTemp = Math.min(tempTemp, minTemp)
+ }
+
+ return [minTemp, maxTemp]
+}
+
+function getMaxTempLenght(cityModel) {
+ var maxLength = 1
+ for (var indexDay = 0; indexDay < cityModel.daysCount(); indexDay++) {
+ var day = cityModel.getDayModel(indexDay)
+ var range = getMaxMinTemp(day)
+ maxLength = Math.max(range[0].toString().length, maxLength)
+ maxLength = Math.max(range[1].toString().length, maxLength)
+ }
+ var stringTemp = "555" // temperatures estimated between -55 and +55
+ if (maxLength === 3)
+ stringTemp = "-" + stringTemp
+ return stringTemp.substring(0, maxLength) + "°C."
+}
+
+// WeatherModel utils
+
+function getWindType(windspeed)
+{
+ var speed = parseFloat(windspeed)
+ if (speed <= 0.2)
+ return "Calm" // Calm
+ if (speed <= 1.5)
+ return "0000" // Light air
+ if (speed <= 3.3)
+ return "0025" // Light breeze
+ if (speed <= 5.4)
+ return "0050" // Glentle breeze
+ if (speed <= 7.9)
+ return "0075" // Moderate breeze
+ if (speed <= 10.7)
+ return "0100" // Fresh breeze
+ if (speed <= 13.8)
+ return "0125" // Strong breeze
+ if (speed <= 17.1)
+ return "0150" // Near gale
+ if (speed <= 18.0)
+ return "0175" // Near gale / Gale
+ if (speed <= 20.7)
+ return "0200" // Gale
+ if (speed <= 24.4)
+ return "0225" // Strong storm
+ if (speed <= 28.4)
+ return "0250" // Whole storm
+ if (speed <= 32.6)
+ return "0300" // Storm
+ return "0350" // Hurricane
+}
+
+function updateDayModel(dayModel, item)
+{
+ var windIconUrl = getWindSymbolUrl(item.windSpeed, item.windDirectionDeg)
+ var weatherUrl = extractSymbolUrl(item.symbolcode)
+ var day = Qt.formatDate(new Date(dayModel.date), "dddd")
+ var timeRange = getTimeRange(item)
+
+ dayModel.addRow(day, weatherUrl, timeRange, item.temperature, item.windSpeed, windIconUrl, item.rain, item.period)
+}
+
+function getItemDate(item)
+{
+ var fromDateTime = parseDateTime(item.from)
+ var toDateTime = parseDateTime(item.to)
+ var date = (item.period === "0") ? toDateTime[0] : fromDateTime[0]
+ return date
+}
+
+function getTimeRange(item)
+{
+ var fromDateTime = parseDateTime(item.from)
+ var toDateTime = parseDateTime(item.to)
+ var timeRange = fromDateTime[1] + " - " + toDateTime[1]
+ return timeRange
+}
+
+function parseDateTime(dt)
+{
+ var pattern_date = /(.*)T.*/
+ var pattern_time = /.*T([0-9][0-9]:[0-9][0-9]).*/
+ var time = dt.replace(pattern_time, "$1")
+ var date = dt.replace(pattern_date, "$1")
+ return [date, time]
+}
+
+function getWindSymbolUrl(windspeed, winddir)
+{
+ var windtype = getWindType(windspeed)
+ if (windtype === "Calm")
+ return "http://fil.nrk.no/yr/grafikk/vindpiler/32/vindstille.png"
+
+ var iconurl = "http://fil.nrk.no/yr/grafikk/vindpiler/32/vindpil.TYPE.WINDDIRCODE.png"
+ var windcode = Math.round((parseFloat(winddir).toFixed(0)) / 5) * 5
+ var codeLenght = windcode.toString().length;
+ for (var i = codeLenght; i < 3; i++)
+ windcode = "0" + windcode
+
+ if (windcode === 360)
+ windcode = "000"
+
+ iconurl = iconurl.replace("TYPE", windtype)
+ iconurl = iconurl.replace("WINDDIRCODE", windcode)
+ return iconurl
+}
+
+function extractSymbolUrl(code)
+{
+ // In order to use yr.no weather data service, refer to their terms
+ // and conditions of use. http://om.yr.no/verdata/free-weather-data/
+ var iconUrl = "http://symbol.yr.no/grafikk/sym/b100/__CODE__.png"
+ return iconUrl.replace("__CODE__", code)
+}
+
+// Global
+
+function getDay(index, dayModel)
+{
+ var day = dayModel.getDayDetails(index, "day")
+ return day
+}
+
+function getShortDate(date)
+{
+ return date.substr(8, 2) + "." + date.substr(5, 2) // dd.MM
+}
+
+function getLongDate(date)
+{
+ return date.substr(8, 2) + "." + date.substr(5, 2) + "." + date.substr(0, 4) // dd.MM.yyyy
+}
+
+function getRain(index, dayModel)
+{
+ return dayModel.getDayDetails(index, "rain")
+}
+
+function getTemperature(index, dayModel)
+{
+ return dayModel.getDayDetails(index, "temperature")
+}
+
+function getWindSpeed(index, dayModel)
+{
+ return dayModel.getDayDetails(index, "windSpeed")
+}
+
+function getWindUrl(index, dayModel)
+{
+ var url = dayModel.getDayDetails(index, "windUrl")
+ return dayModel.getCachedImageFile(url)
+}
+
+function getWeatherUrl(index, dayModel, size)
+{
+ var smallUrl = dayModel.getDayDetails(index, "weatherUrl")
+ if (size === "large")
+ smallUrl = smallUrl.replace("b100", "b200")
+ else
+ smallUrl = smallUrl
+ return dayModel.getCachedImageFile(smallUrl)
+}
+
diff --git a/qml/main.qml b/qml/main.qml
new file mode 100644
index 0000000..49720f7
--- /dev/null
+++ b/qml/main.qml
@@ -0,0 +1,178 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+import org.qtproject.demo.weather 1.0
+
+ApplicationWindow {
+ id: root
+ height: 700
+ width: 1200
+ title: qsTr("Quick Forecast")
+
+ property string statusBarMessage
+
+ property Component citiesPage: CitiesPage {
+ onUpdateStatusBar: statusBarMessage = message
+ onNextPage: if (!isLocked) {
+ isLocked = true
+ pageView.push(longTermPage)
+ clearSearchBox()
+ }
+ }
+ property Component longTermPage: LongTermPage {
+ onUpdateStatusBar: statusBarMessage = message
+ onNextPage: if (!isLocked) {
+ isLocked = true
+ pageView.push(oneDayPage)
+ }
+ onPreviousPage: {
+ ApplicationInfo.currentIndexDay = -1
+ pageView.pop()
+ }
+ }
+ property Component oneDayPage: OneDayPage {
+ onUpdateStatusBar: statusBarMessage = message
+ onPreviousPage: if (!isLocked) {
+ isLocked = true
+ pageView.pop()
+ }
+ }
+
+ StackView {
+ id: pageView
+ anchors.fill: parent
+ initialItem: citiesPage
+ delegate: StackViewDelegate {
+ pushTransition: StackViewTransition {
+ function transitionFinished(properties)
+ {
+ properties.exitItem.opacity = 1
+ }
+ PropertyAnimation {
+ target: enterItem
+ property: "x"
+ from: target.width
+ to: 0
+ duration: 500
+ easing.type: Easing.OutSine
+ }
+ PropertyAnimation {
+ target: exitItem
+ property: "x"
+ from: 0
+ to: -target.width
+ duration: 500
+ easing.type: Easing.OutSine
+ }
+ }
+ popTransition: StackViewTransition {
+ function transitionFinished(properties)
+ {
+ properties.exitItem.opacity = 1
+ }
+ PropertyAnimation {
+ target: enterItem
+ property: "x"
+ from: -target.width
+ to: 0
+ duration: 500
+ easing.type: Easing.OutSine
+ }
+ PropertyAnimation {
+ target: exitItem
+ property: "x"
+ from: 0
+ to: target.width
+ duration: 500
+ easing.type: Easing.OutSine
+
+ }
+ }
+ property Component replaceTransition: pushTransition
+ }
+ }
+
+ statusBar: StatusBar {
+ width: parent.width
+ opacity: label.text !== "" ? 1 : 0
+ height: label.text !== "" ? 65 * ApplicationInfo.ratio : 0
+
+ Behavior on height { NumberAnimation {easing.type: Easing.OutSine}}
+ Behavior on opacity { NumberAnimation {}}
+
+ style: StatusBarStyle {
+ padding { left: 0; right: 0 ; top: 0 ; bottom: 0}
+ property Component background: Rectangle {
+ implicitHeight: 65 * ApplicationInfo.ratio
+ implicitWidth: root.width
+ color: ApplicationInfo.colors.smokeGray
+ Rectangle {
+ width: parent.width
+ height: 1
+ color: Qt.darker(parent.color, 1.5)
+ }
+ Rectangle {
+ y: 1
+ width: parent.width
+ height: 1
+ color: "white"
+ }
+ }
+ }
+ TouchLabel {
+ id: label
+ y: 32 * ApplicationInfo.ratio - height/2
+ width: parent.width // The text will only wrap if an explicit width has been set
+ text: statusBarMessage
+ textFormat: Text.RichText
+ onLinkActivated: Qt.openUrlExternally(link)
+ wrapMode: Text.Wrap
+ pixelSize: 18
+ letterSpacing: -0.15
+ color: ApplicationInfo.colors.mediumGray
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ }
+ }
+}
diff --git a/qml/models/SearchResultModel.qml b/qml/models/SearchResultModel.qml
new file mode 100644
index 0000000..95a871e
--- /dev/null
+++ b/qml/models/SearchResultModel.qml
@@ -0,0 +1,32 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtQuick Enterprise Controls Demos.
+**
+** $QT_BEGIN_LICENSE$
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+
+ListModel {
+ ListElement { sourceXml: "http://www.yr.no/place/Norway/Oslo/Oslo/Oslo/forecast.xml"; name: "Oslo"; country: "Norway"}
+ ListElement { sourceXml: "http://www.yr.no/place/France/Île-de-France/Paris/forecast.xml"; name: "Paris"; country: "France"}
+ ListElement { sourceXml: "http://www.yr.no/place/United_Kingdom/England/London/forecast.xml"; name: "London"; country: "United Kingdom"}
+ ListElement { sourceXml: "http://www.yr.no/place/Germany/Berlin/Berlin/forecast.xml"; name: "Berlin"; country: "Germany"}
+ ListElement { sourceXml: "http://www.yr.no/place/United_States/California/San_Francisco/forecast.xml"; name: "San Francisco"; country: "United States"}
+ ListElement { sourceXml: "http://www.yr.no/place/Italy/Lazio/Rome/forecast.xml"; name: "Rome"; country: "Italia"}
+ ListElement { sourceXml: "http://www.yr.no/place/Antarctica/Other/Vostok_Station/forecast.xml"; name: "Vostok Station"; country: "Antarctica"}
+ ListElement { sourceXml: "http://www.yr.no/place/Mali/Tombouctou/Timbuktu/forecast.xml"; name: "Timbuktu"; country: "Mali"}
+}
diff --git a/qml/models/WeatherModel.qml b/qml/models/WeatherModel.qml
new file mode 100644
index 0000000..4ef3530
--- /dev/null
+++ b/qml/models/WeatherModel.qml
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.XmlListModel 2.0
+import org.qtproject.demo.weather 1.0
+import "../js/utils.js" as Utils
+
+Item {
+ id: modelitem
+ signal error(string errorMessage)
+ signal showLongTerm()
+
+ property var loadedCityModel
+ property string lastLoadedCity
+
+ function getLongTermModel(model)
+ {
+ if (model.sourceXml !== lastLoadedCity ||
+ standardmodel.xml !== model.contentXml ||
+ model.daysCount() === 0) {
+ if (!!model) model.clear()
+ if (standardmodel.xml !== model.contentXml) {
+ standardmodel.xml = model.contentXml
+ } else {
+ if (!!standardmodel.get(0)) {
+ // no error on last loading
+ model.copyright = standardmodel.get(0).copyright
+ currentCityForecastModel.reload()
+ } else {
+ error("The saved xml file cannot be parsed")
+ }
+ }
+ loadedCityModel = model
+ } else {
+ showLongTerm()
+ }
+ lastLoadedCity = model.sourceXml
+ }
+
+ XmlListModel {
+ id: standardmodel
+ property var city
+ query: "/weatherdata"
+ XmlRole { name: "copyright"; query: "credit/link/@text/string()"}
+ onStatusChanged : {
+ if (status === XmlListModel.Ready && count > 0) {
+ var item = get(0)
+ loadedCityModel.copyright = item.copyright
+ currentCityForecastModel.xml = xml
+ } else if ( status === XmlListModel.Error) {
+ error(errorString())
+ } else if (status === XmlListModel.Ready && count == 0) {
+ error(qsTr("Can't parse the xml file"))
+ }
+ }
+ }
+
+ XmlListModel {
+ id: currentCityForecastModel
+ query: "/weatherdata/forecast/tabular/time"
+ XmlRole { name: "from"; query: "@from/string()" }
+ XmlRole { name: "to"; query: "@to/string()" }
+ XmlRole { name: "period"; query: "@period/string()" }
+ XmlRole { name: "symbolcode"; query: "symbol/@var/string()" }
+ XmlRole { name: "windType"; query: "windSpeed/@name/string()" }
+ XmlRole { name: "windDirectionDeg"; query: "windDirection/@deg/string()" }
+ XmlRole { name: "windSpeed"; query: "windSpeed/@mps/string()" }
+ XmlRole { name: "temperature"; query: "temperature/@value/string()" }
+ XmlRole { name: "rain"; query: "precipitation/@value/string()" }
+
+ onStatusChanged: {
+ if (status === XmlListModel.Ready && count > 0) {
+ for (var i=0; i<count; i++) {
+ var item = get(i)
+ var date = Utils.getItemDate(item)
+ var dayModel = loadedCityModel.getDayModel(date)
+ if (dayModel === null) {
+ // add a dayModel to cityModel
+ dayModel = Qt.createQmlObject('import org.qtproject.demo.weather 1.0; DayModel {}', loadedCityModel, "")
+ dayModel.date = date
+ loadedCityModel.addDayModel(dayModel)
+ }
+ if (item.period === "2")
+ dayModel.afternoonIndex = dayModel.periodCount()
+ Utils.updateDayModel(dayModel, item)
+ }
+ modelitem.showLongTerm()
+ } else if ( status === XmlListModel.Error) {
+ error(errorString())
+ } else if (status === XmlListModel.Ready && count == 0) {
+ error(qsTr("Can't parse the xml file"))
+ }
+ }
+ }
+}
diff --git a/qml/pages/BasicPage.qml b/qml/pages/BasicPage.qml
new file mode 100644
index 0000000..874df94
--- /dev/null
+++ b/qml/pages/BasicPage.qml
@@ -0,0 +1,205 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Layouts 1.0
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+import org.qtproject.demo.weather 1.0
+
+Item {
+ id: page
+ signal updateStatusBar(string message)
+ signal nextPage
+ signal previousPage
+ signal clearSearchBox
+
+ property Component pageComponent
+ property bool isLocked: true
+ property string title1
+ property string title2
+ property string title3
+
+ property alias searchText: searchField.text
+ property alias hasNoSearchText: searchField.isEmpty
+ signal searchBoxReturn
+ property string statusBarMessageDefault
+
+ property alias blueRect: blueRect
+
+ Binding {
+ target: ApplicationInfo
+ property: "isPortraitMode"
+ value: page.height > page.width
+ when: !ApplicationInfo.isMobile
+ }
+
+ Binding {
+ target: ApplicationInfo
+ property: "applicationWidth"
+ value: page.width
+ }
+
+ Rectangle {
+ id: blueRect
+ z: 2 // so flickable doesn't draw on top
+ anchors.top: parent.top
+ height: 80 * ApplicationInfo.ratio
+ width: parent.width
+ color: page.Stack.index !== 0 && mouseBack.pressed ?
+ Qt.lighter(ApplicationInfo.colors.blue, 1.2) : ApplicationInfo.colors.blue
+ Rectangle {
+ color: Qt.lighter(parent.color, 1.2)
+ height: 1
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 1
+ width: parent.width
+ }
+ Rectangle {
+ z: 2 // so flickable doesn't draw on top
+ height: 1
+ width: parent.width
+ color: Qt.darker(ApplicationInfo.colors.blue, 1.6)
+ anchors.bottom: parent.bottom
+ }
+
+ RowLayout {
+ id: titleRow
+ anchors.left: parent.left
+ anchors.right: parent.right
+ spacing: 0
+ anchors.verticalCenter: parent.verticalCenter
+ Separator {}
+ Image {
+ source: ApplicationInfo.getImagePath("BackArrow.png")
+ Layout.preferredWidth: 22 * ApplicationInfo.ratio
+ Layout.preferredHeight: 35 * ApplicationInfo.ratio
+ visible: page.Stack.index > 0
+ }
+ Rectangle {
+ opacity: 0
+ Layout.preferredWidth: 20 * ApplicationInfo.ratio
+ Layout.fillHeight: true
+ visible: page.Stack.index > 0
+ }
+ TouchLabel {
+ id: t1
+ text: title1 + " "
+ color: ApplicationInfo.colors.white
+ pixelSize: 30
+ font.weight: Font.Bold
+ Layout.maximumWidth: ApplicationInfo.applicationWidth - t3.implicitWidth - 2 * ApplicationInfo.hMargin - 5 * ApplicationInfo.ratio - 42 * ApplicationInfo.ratio
+ Layout.alignment: Qt.AlignBaseline
+ }
+ TouchLabel {
+ text: "- " + title2
+ color: ApplicationInfo.colors.white
+ visible: title2 !== ""
+ pixelSize: 22
+ letterSpacing: -0.15
+ Layout.alignment: Qt.AlignBaseline
+ Layout.maximumWidth: freeSpace > implicitWidth ? freeSpace : 0
+ property real freeSpace: ApplicationInfo.applicationWidth - t1.width - t3.implicitWidth - 2 * ApplicationInfo.hMargin - 5 * ApplicationInfo.ratio - 42 * ApplicationInfo.ratio
+ }
+ Item {
+ Layout.fillWidth: true
+ height: 0
+ }
+ TouchLabel {
+ id: t3
+ text: title3
+ color: ApplicationInfo.colors.white
+ visible: title3 !== ""
+ pixelSize: 22
+ letterSpacing: -0.15
+ Layout.alignment: Qt.AlignBaseline
+ }
+ Separator {}
+ }
+ Rectangle {
+ width: parent.width
+ height: 5
+ anchors.top: parent.bottom
+ gradient: Gradient {
+ GradientStop {position: 0 ; color: "#40000000"}
+ GradientStop {position: 1 ; color: "#00000000"}
+ }
+ }
+ MouseArea {
+ id: mouseBack
+ anchors.fill: parent
+ onClicked: if (!isLocked) page.previousPage()
+ }
+ }
+
+ TouchTextField {
+ id: searchField
+ z: 2
+ visible: page.Stack.index === 0 ? 1 : 0
+ anchors.right: blueRect.right
+ anchors.top: blueRect.top
+ anchors.bottom: blueRect.bottom
+ width: ApplicationInfo.isPortraitMode ?
+ parent.width - t1.implicitWidth - ApplicationInfo.ratio * 50 :
+ parent.width/2.5
+ anchors.leftMargin: blueRect.width/2
+ anchors.rightMargin: 20 * ApplicationInfo.ratio
+ anchors.margins: 12 * ApplicationInfo.ratio
+
+ placeholderText: qsTr("Find City")
+ Layout.fillWidth: true
+ Keys.onReturnPressed: page.searchBoxReturn()
+ Keys.onEnterPressed: page.searchBoxReturn()
+ onClearButtonClicked: page.clearSearchBox()
+ }
+
+ Loader {
+ sourceComponent: pageComponent
+ anchors.top: blueRect.bottom
+ anchors.bottom: parent.bottom
+ width: parent.width
+ Rectangle {
+ z: -1
+ anchors.fill: parent
+ color: ApplicationInfo.colors.white
+ }
+ }
+}
diff --git a/qml/pages/CitiesPage.qml b/qml/pages/CitiesPage.qml
new file mode 100644
index 0000000..e5caec8
--- /dev/null
+++ b/qml/pages/CitiesPage.qml
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+import org.qtproject.demo.weather 1.0
+
+BasicPage {
+ id: page1
+ title1: qsTr("Cities")
+
+ signal cityDeleted(string city)
+ property int selected: -1
+
+ Binding {
+ target: page1
+ property: "pageComponent"
+ value: listViewComponent
+ when: hasNoSearchText
+ }
+ Binding {
+ target: page1
+ property: "pageComponent"
+ value: searchViewComponent
+ when: !hasNoSearchText
+ }
+
+ onSearchTextChanged : ApplicationInfo.queryCities(searchText)
+
+ property Component searchViewComponent: TouchScrollView {
+ flickableItem.interactive: true
+ flickableItem.flickableDirection: Flickable.VerticalFlick
+ ListView {
+ interactive: true
+ flickableDirection: Flickable.VerticalFlick
+ model: ApplicationInfo.foundCities
+ delegate: ListViewDelegate {
+ isSearchView: true
+ onClicked: validateSearchIndex(index)
+ }
+ }
+ }
+ property Component listViewComponent: TouchScrollView {
+ flickableItem.interactive: true
+ flickableItem.flickableDirection: Flickable.VerticalFlick
+ ListView {
+ id: listview
+ model: availableCities
+ interactive: true
+ flickableDirection: Flickable.VerticalFlick
+ delegate: ListViewDelegate {
+ onClicked: page1.processCity(index)
+ onDeleteCity: availableCities.removeCityModel(index)
+ }
+ currentIndex: page1.selected
+ TouchLabel {
+ z: 1
+ anchors.centerIn: parent
+ visible: listview.count === 0
+ text: "No Cities"
+ color: ApplicationInfo.colors.lightGray
+ }
+ }
+ }
+
+ Connections {
+ target: ApplicationInfo
+ onWaitForCitiesQueryReply: if (ApplicationInfo.isMobile) updateStatusBar(message)
+ onErrorOnQueryCities: updateStatusBar(errorMessage)
+ }
+
+ onSearchBoxReturn: validateSearchIndex(0)
+ onClearSearchBox: {
+ searchText = ""
+ blueRect.forceActiveFocus() // attempt to clear focus in TextField
+ Qt.inputMethod.hide()
+ }
+ function validateSearchIndex(index) {
+
+ if (!ApplicationInfo.foundCities.isEmpty) {
+ // get sourcexml at index
+ var foundIndex = availableCities.processSourceXml(ApplicationInfo.foundCities.getCitySourceXml(index))
+ if (foundIndex > -1)
+ processCity(foundIndex)
+ }
+ clearSearchBox()
+ }
+ function processCity(index)
+ {
+ if (!isLocked) {
+ page1.selected = index
+ ApplicationInfo.currentCityModel = availableCities.getCityModel(index)
+ nextPage()
+ }
+ }
+
+ Cities { id: availableCities }
+
+ Connections {
+ target: Qt.application
+ onStateChanged: if (ApplicationInfo.constants.isMobile && Qt.application.state === Qt.ApplicationSuspended) availableCities.saveCities()
+ }
+
+ Stack.onStatusChanged: {
+ isLocked = !(Stack.status === Stack.Active)
+ if (Stack.status === Stack.Activating)
+ updateStatusBar("")
+ }
+}
diff --git a/qml/pages/LongTermDayItem.qml b/qml/pages/LongTermDayItem.qml
new file mode 100644
index 0000000..6053cca
--- /dev/null
+++ b/qml/pages/LongTermDayItem.qml
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Layouts 1.0
+import "../js/utils.js" as Utils
+import org.qtproject.demo.weather 1.0
+
+Rectangle {
+ id: day
+ Layout.preferredHeight: 118 * ApplicationInfo.ratio
+ Layout.preferredWidth: scrollview.viewport.width - 5
+
+ signal next
+ property bool last
+ property var dayModel: ApplicationInfo.currentCityModel.getDayModel(index)
+
+ color: mouse.pressed ? ApplicationInfo.colors.smokeGray : ApplicationInfo.colors.white
+
+ MouseArea {
+ id: mouse
+ anchors.fill: parent
+ onClicked: {
+ ApplicationInfo.currentIndexDay = index
+ next()
+ }
+ }
+ RowLayout {
+ anchors.fill: parent
+ spacing: 0
+ Separator {}
+ TouchLabel {
+ id: shortDay
+ Layout.preferredWidth: expectedTextWidth("Wed.")
+ text: Utils.getDay(0, dayModel).substr(0, 3)
+ font.weight: Font.DemiBold
+ Layout.alignment: Qt.AlignBaseline
+ }
+ TouchLabel {
+ Layout.preferredWidth: expectedTextWidth("00.00")
+ text: Utils.getShortDate(dayModel.date)
+ pixelSize: 20
+ letterSpacing: -0.15
+ Layout.alignment: Qt.AlignBaseline
+ }
+ Separator {
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ Layout.minimumHeight: 5
+ Layout.minimumWidth: 5
+ }
+ Image {
+ source: Utils.getWeatherUrl(dayModel.afternoonIndex, dayModel)
+ property int weatherIconSize: 80 * ApplicationInfo.ratio
+ Layout.preferredHeight: weatherIconSize
+ Layout.preferredWidth: weatherIconSize
+ onStatusChanged: if (status === Image.Error) updateStatusBar(ApplicationInfo.constants.errorLoadingImage + ": " + source)
+ }
+ Separator {
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ Layout.minimumHeight: 5
+ Layout.minimumWidth: 5
+ }
+ TouchLabel {
+ Layout.preferredWidth: expectedTextWidth(Utils.getMaxTempLenght(ApplicationInfo.currentCityModel))
+ property string temp: Utils.getMinTemp(dayModel)
+ text: Utils.getTempFormat(temp)
+ color: temp < 0 ? ApplicationInfo.colors.blue : ApplicationInfo.colors.doubleDarkGray
+ Layout.alignment: Qt.AlignBaseline
+ }
+ Rectangle {
+ id: separator2
+ Layout.preferredWidth: 1
+ Layout.preferredHeight: day.height/5
+ color: ApplicationInfo.colors.lightGray
+ }
+ TouchLabel {
+ Layout.preferredWidth: expectedTextWidth(Utils.getMaxTempLenght(ApplicationInfo.currentCityModel))
+ property int temp: Utils.getMaxTemp(dayModel)
+ text: Utils.getTempFormat(temp)
+ horizontalAlignment: Qt.AlignRight
+ color: temp < 0 ? ApplicationInfo.colors.blue : ApplicationInfo.colors.doubleDarkGray
+ Layout.alignment: Qt.AlignBaseline
+ }
+ Separator {
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ Layout.minimumHeight: 5
+ Layout.minimumWidth: 5
+ }
+ Image {
+ property int windIconSize: 32 * ApplicationInfo.ratio
+ source: Utils.getWindUrl(dayModel.afternoonIndex, dayModel)
+ Layout.preferredHeight: windIconSize
+ Layout.preferredWidth: windIconSize
+ onStatusChanged: if (status === Image.Error) updateStatusBar(ApplicationInfo.constants.errorLoadingImage + ": " + source)
+ }
+ TouchLabel {
+ Layout.preferredWidth: expectedTextWidth("10.0")
+ text: Utils.getWindSpeed(dayModel.afternoonIndex, dayModel)
+ pixelSize: 24
+ Layout.alignment: Qt.AlignBaseline
+ }
+ TouchLabel {
+ text: qsTr("m/s")
+ pixelSize: 18
+ Layout.alignment: Qt.AlignBaseline
+ }
+ Separator {}
+ }
+ Rectangle {
+ width: parent.width
+ height: 1
+ visible: !last
+ color: ApplicationInfo.colors.paleGray
+ }
+}
diff --git a/qml/pages/LongTermPage.qml b/qml/pages/LongTermPage.qml
new file mode 100644
index 0000000..938b78d
--- /dev/null
+++ b/qml/pages/LongTermPage.qml
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.1
+import QtQuick.Layouts 1.0
+import org.qtproject.demo.weather 1.0
+
+BasicPage {
+ id: page2
+ title1: ApplicationInfo.currentCityModel.cityNameDisplay
+ title2: ApplicationInfo.currentCityModel.countryName
+ title3: qsTr("10 Days Forecast")
+
+ property bool cityLoaded: false
+
+ onCityLoadedChanged: updateStatusBar(ApplicationInfo.currentCityModel.copyright + " <a href=" + ApplicationInfo.currentCityModel.sourceXml + "\>(source)")
+
+ isLocked: true
+
+ pageComponent: Item {
+ TouchScrollView {
+ id: scrollview
+ anchors.fill: parent
+ flickableItem.interactive: true
+ flickableItem.flickableDirection: Flickable.VerticalFlick
+ ColumnLayout {
+ id: layout
+ spacing: 0
+ Repeater {
+ id: repeat
+ model: cityLoaded ? ApplicationInfo.currentCityModel.daysCount() : null
+ LongTermDayItem {
+ Layout.fillWidth: true
+ last: index === repeat.count
+ onNext: nextPage()
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ opacity: cityLoaded ? 0 : 1
+ Behavior on opacity { NumberAnimation{}}
+ TouchLabel {
+ id: label
+ opacity: cityLoaded ? 0 : 1
+ Behavior on opacity { NumberAnimation{} }
+ anchors.centerIn: parent
+ text: qsTr("Loading data...")
+ horizontalAlignment: Text.AlignCenter
+ verticalAlignment: Text.AlignTop
+ pixelSize: 28
+ color: ApplicationInfo.colors.mediumGray
+ height: label.implicitHeight + 80 * ApplicationInfo.ratio
+ BusyIndicator {
+ opacity: 0.8
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ height: implicitHeight * ApplicationInfo.ratio
+ width: implicitWidth * ApplicationInfo.ratio
+ }
+ }
+ }
+ }
+
+ Connections {
+ id: cityModelConnection
+ target: ApplicationInfo.currentCityModel
+ onError: {
+ cityLoaded = false
+ isLocked = false
+ previousPage()
+ updateStatusBar(errorMessage)
+ }
+ onContentXmlChanged: weathermodel.getLongTermModel(ApplicationInfo.currentCityModel)
+ }
+
+ WeatherModel {
+ id: weathermodel
+ onShowLongTerm: {
+ isLocked = false
+ cityLoaded = true
+ }
+ onError: {
+ cityLoaded = false
+ lastLoadedCity = ""
+ isLocked = false
+ previousPage()
+ updateStatusBar(qsTr("Problem loading the data: ") + errorMessage)
+ }
+ }
+
+ Stack.onStatusChanged: if (Stack.status === Stack.Active)
+ ApplicationInfo.currentCityModel.loadData()
+}
diff --git a/qml/pages/OneDayPage.qml b/qml/pages/OneDayPage.qml
new file mode 100644
index 0000000..8264899
--- /dev/null
+++ b/qml/pages/OneDayPage.qml
@@ -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 FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Layouts 1.0
+import QtQuick.Controls 1.0
+import org.qtproject.demo.weather 1.0
+import "../js/utils.js" as Utils
+
+BasicPage {
+ id : page3
+ title1: ApplicationInfo.currentCityModel.cityNameDisplay
+ title2: ApplicationInfo.currentCityModel.countryName
+
+ property QtObject dayModel: ApplicationInfo.currentCityModel.getDayModel(ApplicationInfo.currentIndexDay)
+
+ onDayModelChanged: if (!!dayModel) {
+ if (ApplicationInfo.currentIndexDay === 0)
+ title3 = qsTr("Today")
+ else if (ApplicationInfo.currentIndexDay === 1)
+ title3 = qsTr("Tomorrow")
+ else
+ title3 = Utils.getDay(0, dayModel) + " " + Utils.getLongDate(dayModel.date)
+ }
+
+ pageComponent: GridLayout {
+ id: splitview
+ flow: !ApplicationInfo.isPortraitMode ? GridLayout.LeftToRight : GridLayout.TopToBottom
+ property bool singleItem: sliderItem.slider.minimumValue === sliderItem.slider.maximumValue
+ Separator {
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ }
+ OneDayZoomItem {
+ id: zoom
+ slider: sliderItem.slider
+ model: page3.dayModel
+ singleItem: splitview.singleItem
+ }
+ Separator {
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ implicitHeight: 10 * ApplicationInfo.ratio
+ implicitWidth: 10 * ApplicationInfo.ratio
+ Layout.minimumWidth: 0
+ Layout.minimumHeight: 0
+ visible: !singleItem
+ }
+ OneDaySliderItem {
+ id: sliderItem
+ visible: !singleItem
+ model: page3.dayModel
+ }
+ Separator {
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ }
+ }
+
+ Stack.onStatusChanged: isLocked = !(Stack.status === Stack.Active)
+
+}
diff --git a/qml/pages/OneDaySliderItem.qml b/qml/pages/OneDaySliderItem.qml
new file mode 100644
index 0000000..dfd51db
--- /dev/null
+++ b/qml/pages/OneDaySliderItem.qml
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Layouts 1.0
+import "../js/utils.js" as Utils
+import org.qtproject.demo.weather 1.0
+
+GridLayout {
+ id: root
+ flow: ApplicationInfo.isPortraitMode ? GridLayout.LeftToRight : GridLayout.TopToBottom
+
+ property alias slider: touchSlider
+ property QtObject model
+
+ Separator {
+ Layout.fillHeight: true
+ Layout.fillWidth: ApplicationInfo.isPortraitMode ? true : false
+ Layout.minimumHeight: 10
+ }
+ Canvas {
+ id: canvasSlider
+ Layout.alignment: Qt.AlignHCenter
+
+ property int drawingOffset: ApplicationInfo.sliderGapWidth
+ property var rangeTemp: Utils.getMaxMinTemp(model)
+
+ implicitWidth: touchSlider.width + 2 * drawingOffset
+ implicitHeight: 3.8*drawingOffset
+
+ property int marginsTemperaturesDrawing: calibrate(rangeTemp[1]) + 10 * ApplicationInfo.ratio
+ property real circleIconWidth: 20 * ApplicationInfo.ratio
+ property real weatherIconWidth: 80 * ApplicationInfo.ratio
+
+ function calibrate(temperature) {
+ return 2 * ApplicationInfo.ratio * temperature
+ }
+
+ antialiasing: true
+ smooth: true
+ onPaint: {
+ var ctx = getContext('2d')
+ var count = model.periodCount()
+ ctx.save()
+ ctx.beginPath();
+ ctx.fillStyle = ApplicationInfo.colors.doubleDarkGray
+ ctx.lineWidth = 1
+ ctx.translate(touchSlider.x, marginsTemperaturesDrawing + weatherIconWidth + 15 * ApplicationInfo.ratio + circleIconWidth/2)
+ ctx.moveTo(drawingOffset/2, 0)
+ for (var i = 0; i < count; i++) {
+ ctx.moveTo((i + .5 )* drawingOffset, 0)
+ var temperatureStart = canvasSlider.calibrate(Utils.getTemperature(i, model))
+ var temperatureEnd = canvasSlider.calibrate(Utils.getTemperature(i + 1, model))
+ ctx.moveTo((i + 1 )* drawingOffset, -temperatureStart)
+ if ( (i+1) < count)
+ ctx.lineTo((i + 2) * drawingOffset, -temperatureEnd)
+ }
+ ctx.stroke()
+ ctx.closePath()
+ ctx.restore();
+ }
+ Repeater {
+ id: repeater
+ model: root.model.periodCount()
+ Column {
+ x: (index + 1.5) * ApplicationInfo.sliderGapWidth - canvasSlider.weatherIconWidth/2 - canvasSlider.circleIconWidth/2
+ y: -canvasSlider.calibrate(temperature) + canvasSlider.marginsTemperaturesDrawing
+ property int temperature: Utils.getTemperature(index, root.model)
+ height: parent.height
+ id: col
+ Image {
+ source: Utils.getWeatherUrl(index, root.model)
+ width: canvasSlider.weatherIconWidth
+ height: width
+ anchors.horizontalCenter: col.horizontalCenter
+ }
+ Item {
+ height: 15 * ApplicationInfo.ratio
+ width: height
+ }
+ Image {
+ id: circle
+ source: ApplicationInfo.getImagePath("Circle.png")
+ width: canvasSlider.circleIconWidth
+ height: width
+ anchors.horizontalCenter: col.horizontalCenter
+ }
+ Item {
+ height: 15 * ApplicationInfo.ratio
+ width: height
+ }
+ TouchLabel {
+ text: Utils.getTempFormat(temperature)
+ pixelSize: 24
+ color: temperature > 0 ? ApplicationInfo.colors.doubleDarkGray : ApplicationInfo.colors.blue
+ anchors.horizontalCenter: col.horizontalCenter
+ }
+ }
+ }
+ ColumnLayout {
+ id: column
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ TouchSlider {
+ id: touchSlider
+ Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
+ Layout.preferredWidth: (model.periodCount() - 1) * canvasSlider.drawingOffset + ApplicationInfo.sliderHandleWidth
+ minimumValue: 0
+ maximumValue: model.periodCount() - 1
+ }
+ RowLayout {
+ Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
+ Layout.preferredWidth: model.periodCount() * canvasSlider.drawingOffset + ApplicationInfo.sliderHandleWidth
+ spacing: 0
+ Repeater {
+ model: root.model.periodCount() + 1
+ TouchLabel {
+ pixelSize: 24
+ Layout.fillWidth: true
+ horizontalAlignment: Qt.AlignHCenter
+ Layout.alignment: Qt.AlignBaseline
+ text: (!!root.model && index !== root.model.periodCount()) ? Utils.getFromTime(index, root.model) : Utils.getToTime(index-1, root.model)
+ }
+ }
+ }
+ }
+
+ }
+ Separator {
+ Layout.fillHeight: true
+ Layout.fillWidth: ApplicationInfo.isPortraitMode ? true : false
+ Layout.minimumHeight: 10
+ }
+}
diff --git a/qml/pages/OneDayZoomItem.qml b/qml/pages/OneDayZoomItem.qml
new file mode 100644
index 0000000..5e2af42
--- /dev/null
+++ b/qml/pages/OneDayZoomItem.qml
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Layouts 1.0
+import "../js/utils.js" as Utils
+import org.qtproject.demo.weather 1.0
+
+GridLayout {
+ id: root
+ flow: ApplicationInfo.isPortraitMode ? GridLayout.LeftToRight : GridLayout.TopToBottom
+
+ property QtObject slider
+ property QtObject model
+ property bool singleItem
+ property string singleTimeString: "(" + Utils.getFromTime(0, dayModel) + " - " + Utils.getToTime(0, dayModel) + ")"
+
+ Separator {
+ Layout.fillHeight: true
+ Layout.fillWidth: ApplicationInfo.isPortraitMode ? true : false
+ }
+ GridLayout {
+ id: grid
+ rowSpacing: 0
+ columnSpacing: 15 * ApplicationInfo.ratio
+ columns: 3
+ TouchLabel {
+ id: longDay
+ text : Utils.getDay(root.slider.value, root.model)
+ font.weight: Font.Bold
+ Layout.alignment: Qt.AlignBaseline
+ }
+ TouchLabel {
+ text: Utils.getLongDate(root.model.date)
+ pixelSize: 30
+ Layout.alignment: Qt.AlignBaseline | Qt.AlignLeft
+ color: ApplicationInfo.colors.darkGray
+ }
+ TouchLabel {
+ text: root.singleItem ? root.singleTimeString : ""
+ pixelSize: 20
+ horizontalAlignment: Text.AlignRight
+ Layout.alignment: Qt.AlignBaseline
+ color: ApplicationInfo.colors.darkGray
+ }
+ Item {
+ Image {
+ id: mainIcon
+ source: Utils.getWeatherUrl(Math.round(root.slider.value), root.model, "large")
+ onStatusChanged: if (status === Image.Error) updateStatusBar(ApplicationInfo.constants.errorLoadingImage + ": " + source)
+ anchors.centerIn: parent
+ width: parent.width
+ height: parent.height
+ onSourceChanged: anim.running = true
+ anchors.verticalCenterOffset: offset
+ property real offset: 0
+ ParallelAnimation {
+ id: anim
+ alwaysRunToEnd: true
+ NumberAnimation {
+ target: mainIcon
+ property: "offset"
+ from: -30
+ to: 0
+ duration: 500
+ easing.type: Easing.OutCubic
+ }
+ NumberAnimation {
+ target: mainIcon
+ property: "opacity"
+ from: 0
+ to: 1
+ duration: 300
+ }
+ }
+ }
+
+ Layout.rowSpan: 1
+ Layout.preferredHeight: 200 * ApplicationInfo.ratio
+ Layout.preferredWidth: 200 * ApplicationInfo.ratio
+ Layout.alignment: Qt.AlignCenter
+ }
+ TouchLabel {
+ Layout.preferredWidth: expectedTextWidth(Utils.getMaxTempLenght(ApplicationInfo.currentCityModel))
+ property int temp: Utils.getTemperature(root.slider.value, root.model)
+ text : temp + qsTr("°C")
+ color: temp < 0 ? ApplicationInfo.colors.blue : ApplicationInfo.colors.doubleDarkGray
+ pixelSize: 72
+ letterSpacing: -0.5
+ Layout.alignment: Qt.AlignLeft
+ }
+ RowLayout {
+ Layout.columnSpan: 3
+ TouchLabel {
+ id: rainLabel
+ text : qsTr("Rain: ") + Utils.getRain(root.slider.value, root.model)
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ pixelSize: 30
+ }
+ TouchLabel {
+ text : qsTr("mm")
+ pixelSize: 24
+ Layout.alignment: Qt.AlignBaseline | Qt.AlignLeft
+ }
+ }
+ RowLayout {
+ Layout.columnSpan: 3
+ TouchLabel {
+ id: windLabel
+ text : qsTr("Wind: ") + Utils.getWindSpeed(root.slider.value, root.model) + " "
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ pixelSize: 30
+ }
+ TouchLabel {
+ text : qsTr("m/s")
+ pixelSize: 24
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ }
+ Image {
+ source: Utils.getWindUrl(root.slider.value, root.model)
+ property int windIconSize: 45 * ApplicationInfo.ratio
+ Layout.preferredHeight: windIconSize
+ Layout.preferredWidth: windIconSize
+ onStatusChanged: if (status === Image.Error) updateStatusBar(ApplicationInfo.constants.errorLoadingImage + ": " + source)
+ Layout.alignment: Qt.AlignLeft
+ }
+ }
+ }
+ Separator {
+ Layout.fillHeight: true
+ Layout.fillWidth: ApplicationInfo.isPortraitMode ? true : false
+ }
+}
diff --git a/qml/pages/Separator.qml b/qml/pages/Separator.qml
new file mode 100644
index 0000000..78c1f9f
--- /dev/null
+++ b/qml/pages/Separator.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Layouts 1.0
+import org.qtproject.demo.weather 1.0
+
+Rectangle {
+ implicitHeight: ApplicationInfo.hMargin
+ implicitWidth: ApplicationInfo.hMargin
+ Layout.minimumHeight: implicitHeight
+ Layout.minimumWidth: implicitWidth
+ opacity: 0
+}
diff --git a/qml/touch/ListViewDelegate.qml b/qml/touch/ListViewDelegate.qml
new file mode 100644
index 0000000..eecce49
--- /dev/null
+++ b/qml/touch/ListViewDelegate.qml
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Layouts 1.0
+import org.qtproject.demo.weather 1.0
+
+Rectangle {
+ id: rect
+ height: 118 * ApplicationInfo.ratio
+ width: parent.width
+ signal clicked
+ signal deleteCity
+
+ property bool isSearchView: false
+
+ color: mouseNext.pressed ? ApplicationInfo.colors.smokeGray : ApplicationInfo.colors.white
+
+ GridLayout {
+ id: _grid
+ anchors.fill: parent
+ flow: Qt.LeftToRight
+ rowSpacing: 4 * ApplicationInfo.ratio
+ columnSpacing: 0
+ columns: 2
+ Rectangle {
+ Layout.preferredWidth: ApplicationInfo.hMargin
+ Layout.fillHeight: true
+ opacity: 0
+ }
+ Loader {
+ sourceComponent: isSearchView ? searchViewRow : cityViewRow
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ }
+ Rectangle {
+ id: separator
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.columnSpan: 2
+ }
+ }
+ Rectangle {
+ z: 1
+ height: 1
+ anchors.bottom: parent.bottom
+ width: parent.width
+ color: ApplicationInfo.colors.paleGray
+ }
+ MouseArea {
+ id: mouseNext
+ anchors.left: parent.left
+ width: parent.width - 80 * ApplicationInfo.ratio - ApplicationInfo.hMargin
+ height: parent.height
+ onClicked: rect.clicked()
+ }
+
+ property Component searchViewRow: RowLayout {
+ spacing: 0
+ TouchLabel {
+ color: ApplicationInfo.colors.mediumGray
+ id: countryLabel
+ text: country
+ pixelSize: 28
+ Layout.alignment: Qt.AlignBaseline
+ Layout.fillWidth: true
+ Layout.maximumWidth: rect.width - 2 * ApplicationInfo.hMargin
+ }
+ Rectangle {
+ Layout.preferredWidth: ApplicationInfo.hMargin
+ Layout.fillHeight: true
+ opacity: 0
+ }
+ }
+
+ property Component cityViewRow: RowLayout {
+ spacing: 0
+ TouchLabel {
+ id: city
+ text: name
+ font.weight: Font.DemiBold
+ Layout.maximumWidth: maximumWidth * 2
+ Layout.alignment: Qt.AlignBaseline
+ }
+ Item {
+ implicitWidth: 12 * ApplicationInfo.ratio
+ Layout.minimumWidth: implicitWidth
+ }
+ TouchLabel {
+ color: ApplicationInfo.colors.mediumGray
+ id: countryLabel
+ text: country
+ pixelSize: 28
+ Layout.alignment: Qt.AlignBaseline | Qt.AlignLeft
+ Layout.fillWidth: true
+ Layout.minimumWidth: 0
+ }
+ MouseArea {
+ id: deleteMouse
+ implicitWidth: 110 * ApplicationInfo.ratio
+ implicitHeight: 110 * ApplicationInfo.ratio
+ Layout.minimumWidth: implicitWidth
+ onClicked: if (!isSearchView) rect.deleteCity()
+ Image {
+ id: imageRemove
+ anchors.centerIn: parent
+ source: ApplicationInfo.getImagePath("darkclose.png")
+ width: 31 * ApplicationInfo.ratio
+ height: 31 * ApplicationInfo.ratio
+ }
+ Rectangle {
+ anchors.fill: parent
+ color: ApplicationInfo.colors.smokeGray
+ opacity: deleteMouse.pressed ? 1 : 0
+ z: -1
+ radius: 8
+ }
+ }
+ }
+}
diff --git a/qml/touch/Separator.qml b/qml/touch/Separator.qml
new file mode 100644
index 0000000..dd7516e
--- /dev/null
+++ b/qml/touch/Separator.qml
@@ -0,0 +1,29 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the QtQuick Enterprise Controls Demos.
+**
+** $QT_BEGIN_LICENSE$
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Layouts 1.0
+import org.qtproject.demo.weather 1.0
+
+Rectangle {
+ Layout.minimumWidth: SystemInfo.hMargin
+ Layout.minimumHeight: SystemInfo.hMargin
+ opacity: 0
+}
diff --git a/qml/touch/TouchLabel.qml b/qml/touch/TouchLabel.qml
new file mode 100644
index 0000000..bea6b3b
--- /dev/null
+++ b/qml/touch/TouchLabel.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+import org.qtproject.demo.weather 1.0
+
+Label {
+ id: label
+ property int pixelSize: 34
+ property real letterSpacing: -0.25
+
+ font.family: "Open Sans"
+ font.pixelSize: pixelSize * ApplicationInfo.ratio * 1.1 // increasing fonts
+ font.letterSpacing: letterSpacing * ApplicationInfo.ratio
+ color: ApplicationInfo.colors.doubleDarkGray
+ verticalAlignment: Text.AlignBottom
+ horizontalAlignment: Text.AlignLeft
+ elide: Text.ElideRight
+ linkColor: ApplicationInfo.colors.blue
+
+ function expectedTextWidth(value)
+ {
+ dayText.text = value
+ return dayText.width
+ }
+
+ property int maximumWidth: (ApplicationInfo.constants.isMobile ? ApplicationInfo.applicationWidth : 1120) / 4
+ Layout.minimumWidth: Math.min(Layout.maximumWidth, implicitWidth + 1)
+
+ Text {
+ id: dayText
+ visible: false
+ font.family: label.font.family
+ font.pixelSize: label.font.pixelSize
+ font.letterSpacing: label.font.letterSpacing
+ wrapMode: label.wrapMode
+ elide: label.elide
+ }
+}
diff --git a/qml/touch/TouchScrollView.qml b/qml/touch/TouchScrollView.qml
new file mode 100644
index 0000000..5d2c211
--- /dev/null
+++ b/qml/touch/TouchScrollView.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+import org.qtproject.demo.weather 1.0
+
+ScrollView {
+ frameVisible: false
+ style: ScrollViewStyle {
+ property int handleWidth: 20 * ApplicationInfo.ratio
+ transientScrollBars: true
+ padding{ top: 4 ; bottom: 4 ; right: 4}
+ property bool hovered: false
+ }
+ Rectangle {
+ anchors.fill: parent
+ color: ApplicationInfo.colors.white
+ }
+}
diff --git a/qml/touch/TouchSlider.qml b/qml/touch/TouchSlider.qml
new file mode 100644
index 0000000..6969239
--- /dev/null
+++ b/qml/touch/TouchSlider.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+import org.qtproject.demo.weather 1.0
+
+Slider {
+ id: slider
+ implicitHeight: ApplicationInfo.sliderHandleHeight + ApplicationInfo.ratio * 25
+ style: SliderStyle {
+ groove: Rectangle {
+ Rectangle {
+ id: beforeHandle
+ width: control.value * ApplicationInfo.sliderGapWidth + ApplicationInfo.sliderHandleWidth/2
+ height: 20 * ApplicationInfo.ratio
+ color: ApplicationInfo.colors.blue
+ radius: 90
+ z: -1
+ }
+ Rectangle {
+ id: afterHandle
+ anchors.left: beforeHandle.right
+ anchors.right: parent.right
+ height: 20 * ApplicationInfo.ratio
+ color: ApplicationInfo.colors.darkGray
+ radius: 90
+ z: -1
+ }
+ }
+ handle: Item {
+ width: ApplicationInfo.sliderHandleWidth
+ height: ApplicationInfo.sliderHandleHeight
+ Image {
+ anchors.centerIn: parent
+ source: ApplicationInfo.getImagePath(control.pressed ? "Pointer_pressed.png" : "Pointer.png")
+ width: ApplicationInfo.sliderHandleWidth + 16 * ApplicationInfo.ratio
+ height: ApplicationInfo.sliderHandleHeight + 16 * ApplicationInfo.ratio
+ }
+ }
+ }
+}
diff --git a/qml/touch/TouchTextField.qml b/qml/touch/TouchTextField.qml
new file mode 100644
index 0000000..9e0ffb0
--- /dev/null
+++ b/qml/touch/TouchTextField.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the FOO 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$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+import org.qtproject.demo.weather 1.0
+
+TextField {
+ id: textfield
+ signal clearButtonClicked
+ implicitWidth: parent.width
+ property bool isEmpty: true
+ style: TextFieldStyle {
+ background :
+ Rectangle {
+ radius: 8
+ border.width: 1
+ border.color: Qt.darker(ApplicationInfo.colors.blue, 1.6)
+ color: ApplicationInfo.colors.white
+ gradient: Gradient {
+ GradientStop { position: 0 ; color: "#ddd"}
+ GradientStop { position: 0.05 ; color: "#fff"}
+ }
+
+ implicitHeight: 60 * ApplicationInfo.ratio
+ opacity: 1
+ }
+ padding.left : (12 + 50) * ApplicationInfo.ratio
+ padding.right: (12 + 50) * ApplicationInfo.ratio
+ font.pixelSize: 28 * ApplicationInfo.ratio
+ font.family: "Open Sans"
+ font.letterSpacing: -0.25 * ApplicationInfo.ratio
+ selectedTextColor : ApplicationInfo.colors.lightGray
+ selectionColor : ApplicationInfo.colors.darkBlue
+ textColor : ApplicationInfo.colors.mediumGray
+ }
+
+ Item {
+ id: item
+ anchors.left: parent.left
+ anchors.top: parent.top
+ height: parent.height
+ width: parent.height
+ Image {
+ opacity: 0.9
+ anchors.centerIn: item
+ height: iconSize
+ width: iconSize
+ source: ApplicationInfo.getImagePath("magnifier.png")
+ property int iconSize: 50 * ApplicationInfo.ratio
+ }
+ }
+
+ onTextChanged: isEmpty = (text === "")
+ inputMethodHints: Qt.ImhNoPredictiveText
+ MouseArea {
+ z: 2
+ opacity: !textfield.isEmpty ? 1 : 0
+ Behavior on opacity {NumberAnimation{}}
+ anchors.right: parent.right
+ anchors.rightMargin: 4 * ApplicationInfo.ratio
+ anchors.top: parent.top
+ height: parent.height
+ width: parent.height
+ Image {
+ anchors.centerIn: parent
+ source: ApplicationInfo.getImagePath("Clear.png")
+ property int iconSize: 40 * ApplicationInfo.ratio
+ opacity: parent.pressed ? 1 : 0.9
+ width: iconSize
+ height: iconSize
+ }
+ onClicked: textfield.clearButtonClicked()
+ }
+}
+
diff --git a/qml/touch/images/BackArrow.png b/qml/touch/images/BackArrow.png
new file mode 100644
index 0000000..9070d0f
--- /dev/null
+++ b/qml/touch/images/BackArrow.png
Binary files differ
diff --git a/qml/touch/images/Circle.png b/qml/touch/images/Circle.png
new file mode 100644
index 0000000..7b229ec
--- /dev/null
+++ b/qml/touch/images/Circle.png
Binary files differ
diff --git a/qml/touch/images/Clear.png b/qml/touch/images/Clear.png
new file mode 100644
index 0000000..883dffd
--- /dev/null
+++ b/qml/touch/images/Clear.png
Binary files differ
diff --git a/qml/touch/images/Pointer.png b/qml/touch/images/Pointer.png
new file mode 100644
index 0000000..45b075e
--- /dev/null
+++ b/qml/touch/images/Pointer.png
Binary files differ
diff --git a/qml/touch/images/Pointer_pressed.png b/qml/touch/images/Pointer_pressed.png
new file mode 100644
index 0000000..776e0d1
--- /dev/null
+++ b/qml/touch/images/Pointer_pressed.png
Binary files differ
diff --git a/qml/touch/images/darkclose.png b/qml/touch/images/darkclose.png
new file mode 100644
index 0000000..2f90820
--- /dev/null
+++ b/qml/touch/images/darkclose.png
Binary files differ
diff --git a/qml/touch/images/magnifier.png b/qml/touch/images/magnifier.png
new file mode 100644
index 0000000..42033b5
--- /dev/null
+++ b/qml/touch/images/magnifier.png
Binary files differ