summaryrefslogtreecommitdiffstats
path: root/demos/qmlweather
diff options
context:
space:
mode:
Diffstat (limited to 'demos/qmlweather')
-rw-r--r--demos/qmlweather/main.cpp52
-rw-r--r--demos/qmlweather/qml/qmlweather/main.qml200
-rw-r--r--demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.cpp177
-rw-r--r--demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.h46
-rw-r--r--demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.pri13
-rw-r--r--demos/qmlweather/qmlweather.pro10
-rw-r--r--demos/qmlweather/resources.qrc5
7 files changed, 0 insertions, 503 deletions
diff --git a/demos/qmlweather/main.cpp b/demos/qmlweather/main.cpp
deleted file mode 100644
index fee07449..00000000
--- a/demos/qmlweather/main.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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 Qt Enterprise Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise 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$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <QtDeclarative/QDeclarativeContext>
-#include <QtDeclarative/QDeclarativeEngine>
-#include <QDebug>
-#include <QDir>
-#include "qmlapplicationviewer.h"
-
-Q_DECL_EXPORT int main(int argc, char *argv[])
-{
- QScopedPointer<QApplication> app(createApplication(argc, argv));
-
- QmlApplicationViewer viewer;
-#ifdef Q_OS_ANDROID
- viewer.addImportPath(QString::fromLatin1("assets:/imports"));
- viewer.engine()->addPluginPath(QString::fromLatin1("%1/../%2").arg(QDir::homePath(), QString::fromLatin1("lib")));
-#else
- viewer.addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QString::fromLatin1("imports")));
-#endif
-// viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
- QString appKey;
- if (argc > 1) {
- appKey = argv[1];
- qDebug() << "App key for worldweatheronline.com:" << appKey;
- } else {
- qWarning() << "No app key for worldweatheronline.com given. Using static test data instead of live data.";
- }
- viewer.rootContext()->setContextProperty("weatherAppKey", appKey);
- viewer.setSource(QUrl("qrc:/qml/qmlweather/main.qml"));
- viewer.setRenderHint(QPainter::Antialiasing, true);
- viewer.showExpanded();
- return app->exec();
-}
diff --git a/demos/qmlweather/qml/qmlweather/main.qml b/demos/qmlweather/qml/qmlweather/main.qml
deleted file mode 100644
index 16e48a38..00000000
--- a/demos/qmlweather/qml/qmlweather/main.qml
+++ /dev/null
@@ -1,200 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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 Qt Enterprise Charts Add-on.
-**
-** $QT_BEGIN_LICENSE$
-** Licensees holding valid Qt Enterprise licenses may use this file in
-** accordance with the Qt Enterprise 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 1.1
-import QtCommercial.Chart 1.2
-
-Rectangle {
- width: 500
- height: 400
- gradient: Gradient {
- GradientStop { position: 0.0; color: "lightblue" }
- GradientStop { position: 1.0; color: "white" }
- }
-
- //![1]
- ChartView {
- id: chartView
- title: "Weather forecast"
- //![1]
- anchors.top: parent.top
- anchors.bottom: weatherImageRow.top
- anchors.left: parent.left
- anchors.right: parent.right
- legend.alignment: Qt.AlignTop
-
- //![2]
- BarCategoriesAxis {
- id: barCategoriesAxis
- titleText: "Date"
- }
-
- ValueAxis{
- id: valueAxisY2
- min: 0
- max: 10
- titleText: "Rainfall [mm]"
- }
-
- ValueAxis {
- id: valueAxisX
- // Hide the value axis; it is only used to map the line series to bar categories axis
- visible: false
- min: 0
- max: 5
- }
-
- ValueAxis{
- id: valueAxisY
- min: 0
- max: 15
- titleText: "Temperature [&deg;C]"
- }
-
- LineSeries {
- id: maxTempSeries
- axisX: valueAxisX
- axisY: valueAxisY
- name: "Max. temperature"
- }
-
- LineSeries {
- id: minTempSeries
- axisX: valueAxisX
- axisY: valueAxisY
- name: "Min. temperature"
- }
-
- BarSeries {
- id: myBarSeries
- axisX: barCategoriesAxis
- axisYRight: valueAxisY2
- BarSet {
- id: rainfallSet
- label: "Rainfall"
- }
- }
- //![2]
- }
-
- // A timer to refresh the forecast every 5 minutes
- Timer {
- interval: 300000
- repeat: true
- triggeredOnStart: true
- running: true
- onTriggered: {
- if (weatherAppKey != "") {
- //![3]
- // Make HTTP GET request and parse the result
- var xhr = new XMLHttpRequest;
- xhr.open("GET",
- "http://free.worldweatheronline.com/feed/weather.ashx?q=Jyv%c3%a4skyl%c3%a4,Finland&format=json&num_of_days=5&key="
- + weatherAppKey);
- xhr.onreadystatechange = function() {
- if (xhr.readyState == XMLHttpRequest.DONE) {
- var a = JSON.parse(xhr.responseText);
- parseWeatherData(a);
- }
- }
- xhr.send();
- //![3]
- } else {
- // No app key for worldweatheronline.com given by the user -> use dummy static data
- var responseText = "{ \"data\": { \"current_condition\": [ {\"cloudcover\": \"10\", \"humidity\": \"61\", \"observation_time\": \"06:26 AM\", \"precipMM\": \"0.0\", \"pressure\": \"1022\", \"temp_C\": \"6\", \"temp_F\": \"43\", \"visibility\": \"10\", \"weatherCode\": \"113\", \"weatherDesc\": [ {\"value\": \"Sunny\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png\" } ], \"winddir16Point\": \"SE\", \"winddirDegree\": \"140\", \"windspeedKmph\": \"7\", \"windspeedMiles\": \"4\" } ], \"request\": [ {\"query\": \"Jyvaskyla, Finland\", \"type\": \"City\" } ], \"weather\": [ {\"date\": \"2012-05-09\", \"precipMM\": \"0.4\", \"tempMaxC\": \"14\", \"tempMaxF\": \"57\", \"tempMinC\": \"7\", \"tempMinF\": \"45\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"S\", \"winddirDegree\": \"179\", \"winddirection\": \"S\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-10\", \"precipMM\": \"2.4\", \"tempMaxC\": \"13\", \"tempMaxF\": \"55\", \"tempMinC\": \"8\", \"tempMinF\": \"46\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SW\", \"winddirDegree\": \"219\", \"winddirection\": \"SW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" }, {\"date\": \"2012-05-11\", \"precipMM\": \"11.1\", \"tempMaxC\": \"15\", \"tempMaxF\": \"59\", \"tempMinC\": \"7\", \"tempMinF\": \"44\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SSW\", \"winddirDegree\": \"200\", \"winddirection\": \"SSW\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-12\", \"precipMM\": \"2.8\", \"tempMaxC\": \"7\", \"tempMaxF\": \"44\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"317\", \"weatherDesc\": [ {\"value\": \"Light sleet\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0021_cloudy_with_sleet.png\" } ], \"winddir16Point\": \"NW\", \"winddirDegree\": \"311\", \"winddirection\": \"NW\", \"windspeedKmph\": \"24\", \"windspeedMiles\": \"15\" }, {\"date\": \"2012-05-13\", \"precipMM\": \"0.4\", \"tempMaxC\": \"6\", \"tempMaxF\": \"42\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"WNW\", \"winddirDegree\": \"281\", \"winddirection\": \"WNW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" } ] }}";
- var a = JSON.parse(responseText);
- parseWeatherData(a);
- }
- }
- }
-
- Row {
- id: weatherImageRow
- anchors.bottom: poweredByText.top
- anchors.bottomMargin: 10
- anchors.left: parent.left
- anchors.leftMargin: 25
- anchors.right: parent.right
- anchors.rightMargin: 25
-
- ListModel {
- id: weatherImageModel
- }
-
- Repeater {
- id: repeater
- model: weatherImageModel
- delegate: Image {
- source: imageSource
- width: weatherImageRow.width / weatherImageModel.count
- height: width
- fillMode: Image.PreserveAspectCrop
- }
- }
- }
-
- Text {
- id: poweredByText
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 10
- anchors.left: parent.left
- anchors.leftMargin: 25
- text: "Powered by World Weather Online"
- }
-
- function parseWeatherData(weatherData) {
- // Clear previous values
- maxTempSeries.clear();
- minTempSeries.clear();
- weatherImageModel.clear();
-
- //![4]
- // Loop through the parsed JSON
- for (var i in weatherData.data.weather) {
- var weatherObj = weatherData.data.weather[i];
- //![4]
-
- //![5]
- // Store temperature values, rainfall and weather icon.
- // The temperature values begin from 0.5 instead of 0.0 to make the start from the
- // middle of the rainfall bars. This makes the temperature lines visually better
- // synchronized with the rainfall bars.
- maxTempSeries.append(Number(i) + 0.5, weatherObj.tempMaxC);
- minTempSeries.append(Number(i) + 0.5, weatherObj.tempMinC);
- rainfallSet.append(i, weatherObj.precipMM);
- weatherImageModel.append({"imageSource":weatherObj.weatherIconUrl[0].value});
- //![5]
-
- // Update scale of the chart
- valueAxisY.max = Math.max(chartView.axisY().max,weatherObj.tempMaxC);
- valueAxisX.min = 0;
- valueAxisX.max = Number(i) + 1;
-
- // Set the x-axis labels to the dates of the forecast
- var xLabels = barCategoriesAxis.categories;
- xLabels[Number(i)] = weatherObj.date.substring(5, 10);
- barCategoriesAxis.categories = xLabels;
- barCategoriesAxis.visible = true;
- barCategoriesAxis.min = 0;
- barCategoriesAxis.max = xLabels.length - 1;
- }
- }
-
-}
diff --git a/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.cpp b/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.cpp
deleted file mode 100644
index cb227056..00000000
--- a/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-// checksum 0xaa72 version 0x90018
-/*
- This file was generated by the Qt Quick Application wizard of Qt Creator.
- QmlApplicationViewer is a convenience class containing mobile device specific
- code such as screen orientation handling. Also QML paths and debugging are
- handled here.
- It is recommended not to modify this file, since newer versions of Qt Creator
- may offer an updated version of it.
-*/
-
-#include "qmlapplicationviewer.h"
-
-#include <QDir>
-#include <QFileInfo>
-#include <QApplication>
-#include <QDeclarativeComponent>
-#include <QDeclarativeEngine>
-#include <QDeclarativeContext>
-
-#include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN
-
-#ifdef HARMATTAN_BOOSTER
-#include <MDeclarativeCache>
-#endif
-
-#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
-
-#include <qt_private/qdeclarativedebughelper_p.h>
-
-#if !defined(NO_JSDEBUGGER)
-#include <jsdebuggeragent.h>
-#endif
-#if !defined(NO_QMLOBSERVER)
-#include <qdeclarativeviewobserver.h>
-#endif
-
-// Enable debugging before any QDeclarativeEngine is created
-struct QmlJsDebuggingEnabler
-{
- QmlJsDebuggingEnabler()
- {
- QDeclarativeDebugHelper::enableDebugging();
- }
-};
-
-// Execute code in constructor before first QDeclarativeEngine is instantiated
-static QmlJsDebuggingEnabler enableDebuggingHelper;
-
-#endif // QMLJSDEBUGGER
-
-class QmlApplicationViewerPrivate
-{
- QString mainQmlFile;
- friend class QmlApplicationViewer;
- static QString adjustPath(const QString &path);
-};
-
-QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
-{
-#ifdef Q_OS_MAC
- if (!QDir::isAbsolutePath(path))
- return QString::fromLatin1("%1/../Resources/%2")
- .arg(QCoreApplication::applicationDirPath(), path);
-#elif defined(Q_OS_BLACKBERRY)
- if (!QDir::isAbsolutePath(path))
- return QString::fromLatin1("app/native/%1").arg(path);
-#elif !defined(Q_OS_ANDROID)
- QString pathInInstallDir =
- QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
- if (QFileInfo(pathInInstallDir).exists())
- return pathInInstallDir;
- pathInInstallDir =
- QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path);
- if (QFileInfo(pathInInstallDir).exists())
- return pathInInstallDir;
-#endif
- return path;
-}
-
-QmlApplicationViewer::QmlApplicationViewer(QWidget *parent)
- : QDeclarativeView(parent)
- , d(new QmlApplicationViewerPrivate())
-{
- connect(engine(), SIGNAL(quit()), SLOT(close()));
- setResizeMode(QDeclarativeView::SizeRootObjectToView);
-
- // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
-#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
-#if !defined(NO_JSDEBUGGER)
- new QmlJSDebugger::JSDebuggerAgent(engine());
-#endif
-#if !defined(NO_QMLOBSERVER)
- new QmlJSDebugger::QDeclarativeViewObserver(this, this);
-#endif
-#endif
-}
-
-QmlApplicationViewer::~QmlApplicationViewer()
-{
- delete d;
-}
-
-QmlApplicationViewer *QmlApplicationViewer::create()
-{
- return new QmlApplicationViewer();
-}
-
-void QmlApplicationViewer::setMainQmlFile(const QString &file)
-{
- d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file);
-#ifdef Q_OS_ANDROID
- setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile));
-#else
- setSource(QUrl::fromLocalFile(d->mainQmlFile));
-#endif
-}
-
-void QmlApplicationViewer::addImportPath(const QString &path)
-{
- engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path));
-}
-
-void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
-{
-#if QT_VERSION < 0x050000
- Qt::WidgetAttribute attribute;
- switch (orientation) {
-#if QT_VERSION < 0x040702
- // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
- case ScreenOrientationLockPortrait:
- attribute = static_cast<Qt::WidgetAttribute>(128);
- break;
- case ScreenOrientationLockLandscape:
- attribute = static_cast<Qt::WidgetAttribute>(129);
- break;
- default:
- case ScreenOrientationAuto:
- attribute = static_cast<Qt::WidgetAttribute>(130);
- break;
-#else // QT_VERSION < 0x040702
- case ScreenOrientationLockPortrait:
- attribute = Qt::WA_LockPortraitOrientation;
- break;
- case ScreenOrientationLockLandscape:
- attribute = Qt::WA_LockLandscapeOrientation;
- break;
- default:
- case ScreenOrientationAuto:
- attribute = Qt::WA_AutoOrientation;
- break;
-#endif // QT_VERSION < 0x040702
- };
- setAttribute(attribute, true);
-#else // QT_VERSION < 0x050000
- Q_UNUSED(orientation)
-#endif // QT_VERSION < 0x050000
-}
-
-void QmlApplicationViewer::showExpanded()
-{
-#if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR)
- showFullScreen();
-#elif defined(Q_WS_MAEMO_5) || defined(Q_OS_QNX)
- showMaximized();
-#else
- show();
-#endif
-}
-
-QApplication *createApplication(int &argc, char **argv)
-{
-#ifdef HARMATTAN_BOOSTER
- return MDeclarativeCache::qApplication(argc, argv);
-#else
- return new QApplication(argc, argv);
-#endif
-}
diff --git a/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.h b/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.h
deleted file mode 100644
index adcb232f..00000000
--- a/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// checksum 0xc67a version 0x90018
-/*
- This file was generated by the Qt Quick Application wizard of Qt Creator.
- QmlApplicationViewer is a convenience class containing mobile device specific
- code such as screen orientation handling. Also QML paths and debugging are
- handled here.
- It is recommended not to modify this file, since newer versions of Qt Creator
- may offer an updated version of it.
-*/
-
-#ifndef QMLAPPLICATIONVIEWER_H
-#define QMLAPPLICATIONVIEWER_H
-
-#include <QDeclarativeView>
-
-class QmlApplicationViewer : public QDeclarativeView
-{
- Q_OBJECT
-
-public:
- enum ScreenOrientation {
- ScreenOrientationLockPortrait,
- ScreenOrientationLockLandscape,
- ScreenOrientationAuto
- };
-
- explicit QmlApplicationViewer(QWidget *parent = 0);
- virtual ~QmlApplicationViewer();
-
- static QmlApplicationViewer *create();
-
- void setMainQmlFile(const QString &file);
- void addImportPath(const QString &path);
-
- // Note that this will only have an effect on Fremantle.
- void setOrientation(ScreenOrientation orientation);
-
- void showExpanded();
-
-private:
- class QmlApplicationViewerPrivate *d;
-};
-
-QApplication *createApplication(int &argc, char **argv);
-
-#endif // QMLAPPLICATIONVIEWER_H
diff --git a/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.pri b/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.pri
deleted file mode 100644
index 567c6dc6..00000000
--- a/demos/qmlweather/qmlapplicationviewer/qmlapplicationviewer.pri
+++ /dev/null
@@ -1,13 +0,0 @@
-QT += declarative
-
-SOURCES += $$PWD/qmlapplicationviewer.cpp
-HEADERS += $$PWD/qmlapplicationviewer.h
-INCLUDEPATH += $$PWD
-
-# Include JS debugger library if QMLJSDEBUGGER_PATH is set
-!isEmpty(QMLJSDEBUGGER_PATH) {
- include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri)
-} else {
- DEFINES -= QMLJSDEBUGGER
-}
-
diff --git a/demos/qmlweather/qmlweather.pro b/demos/qmlweather/qmlweather.pro
deleted file mode 100644
index 52fa5716..00000000
--- a/demos/qmlweather/qmlweather.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-!include( ../demos.pri ) {
- error( "Couldn't find the demos.pri file!" )
-}
-
-RESOURCES += resources.qrc
-SOURCES += main.cpp
-OTHER_FILES += qml/qmlweather/*
-
-include(qmlapplicationviewer/qmlapplicationviewer.pri)
-
diff --git a/demos/qmlweather/resources.qrc b/demos/qmlweather/resources.qrc
deleted file mode 100644
index 7205906f..00000000
--- a/demos/qmlweather/resources.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>qml/qmlweather/main.qml</file>
- </qresource>
-</RCC>