summaryrefslogtreecommitdiff
path: root/examples/positioning/weatherinfo/doc/src/weatherinfo.qdoc
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2016-02-24 12:26:27 +0100
committerMichal Klocek <michal.klocek@theqtcompany.com>2016-02-26 12:08:19 +0000
commit3a9590241cf54eccb9d28957c3d58268e0d23b60 (patch)
tree58af4b96b308e22592845612e2ec251d807e54b1 /examples/positioning/weatherinfo/doc/src/weatherinfo.qdoc
parentd3b4d490599d9846cf5a43526493cb0072012913 (diff)
downloadqtlocation-3a9590241cf54eccb9d28957c3d58268e0d23b60.tar.gz
Update examples documentation location
The current way of documenting examples is to include qdoc and images source into example directory. Fix examples in location and positioning. Replace planespotter.jpg with png. Change-Id: I4eeacbfa575e7ae3ef747703348f2f201899e548 Reviewed-by: Topi Reiniƶ <topi.reinio@theqtcompany.com>
Diffstat (limited to 'examples/positioning/weatherinfo/doc/src/weatherinfo.qdoc')
-rw-r--r--examples/positioning/weatherinfo/doc/src/weatherinfo.qdoc113
1 files changed, 113 insertions, 0 deletions
diff --git a/examples/positioning/weatherinfo/doc/src/weatherinfo.qdoc b/examples/positioning/weatherinfo/doc/src/weatherinfo.qdoc
new file mode 100644
index 00000000..3db6fcbf
--- /dev/null
+++ b/examples/positioning/weatherinfo/doc/src/weatherinfo.qdoc
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example weatherinfo
+ \title Weather Info (C++/QML)
+
+ \brief The Weather Info example shows how to use the user's current position
+ to retrieve local content from a web service in a C++ plugin for QML.
+
+ \ingroup qtpositioning-examples
+
+ Key \l{Qt Positioning} classes used in this example:
+
+ \list
+ \li \l{QGeoPositionInfo}
+ \li \l{QGeoPositionInfoSource}
+ \endlist
+
+ \image ../images/example-weatherinfo.png
+
+ \include examples-run.qdocinc
+
+ The example uses weather data provided by \l http://www.openweathermap.org.
+
+ The key part of this example is the application's data model, contained
+ in the WeatherData and AppModel classes. WeatherData represents the weather
+ information taken from the HTTP service. It is a simple data class, but we
+ give it Q_PROPERTies to expose it nicely to QML, later.
+
+ \snippet weatherinfo/appmodel.h 0
+ \snippet weatherinfo/appmodel.h 1
+
+ AppModel models the state of the entire application. At startup, the
+ application first begins by waiting for network connectivity. We do
+ this using the QNetworkConfigurationManager and QNetworkSession family
+ of C++ APIs.
+
+ \snippet weatherinfo/appmodel.cpp 0
+ \snippet weatherinfo/appmodel.cpp 1
+
+ Once the network session is open, we proceed to get the platform's
+ default position source using QGeoPositionInfo::createDefaultSource()
+
+ \snippet weatherinfo/appmodel.cpp 2
+
+ If no default source is available, we take a static position and fetch
+ weather for that. If, however, we do have a position source, we connect
+ its positionUpdated() signal to a slot on the AppModel and call
+ startUpdates(), which begins regular updates of device position.
+
+ When a position update is received, we use the longitude and latitude
+ of the returned coordinate to retrieve the current "city" name for use
+ in the weather lookup.
+
+ \snippet weatherinfo/appmodel.cpp 3
+
+ To inform the UI about this process, the cityChanged() signal is emitted
+ when a new city is used, and the weatherChanged() signal whenever a
+ weather update occurs.
+
+ \snippet weatherinfo/appmodel.h 2
+ \snippet weatherinfo/appmodel.h 3
+ \snippet weatherinfo/appmodel.h 4
+
+ We use a QQmlListProperty for the weather forecast information,
+ which contains the next 4 days of forecast weather. This makes it
+ easy to access from QML.
+
+ To expose these to the QML UI layer, we use the qmlRegisterType()
+ function. We call this once for each type we wish to register, before
+ loading the actual QML file.
+
+ \snippet weatherinfo/main.cpp 0
+ \snippet weatherinfo/main.cpp 1
+
+ Finally, in the actual QML, we instantiate the AppModel.
+
+ \snippet weatherinfo/weatherinfo.qml 0
+ \snippet weatherinfo/weatherinfo.qml 1
+ \snippet weatherinfo/weatherinfo.qml 2
+
+ Once instantiated like this, we can use its properties elsewhere in the
+ QML document:
+
+ \snippet weatherinfo/weatherinfo.qml 3
+ \snippet weatherinfo/weatherinfo.qml 4
+
+*/