summaryrefslogtreecommitdiff
path: root/examples/positioning/satelliteinfo/doc/src/satelliteinfo.qdoc
blob: fb314ea3adead4180372b0409ad2e54d2e9155cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \example satelliteinfo
    \title SatelliteInfo (C++/QML)

    \brief The SatelliteInfo example shows the available satellites
    at the user's current position and marks the satellites
    currently contributing to the GPS fix as pink.

    \ingroup qtpositioning-examples

    Key \l{Qt Positioning} classes used in this example:

    \list
    \li \l{QGeoSatelliteInfo}
    \li \l{QGeoSatelliteInfoSource}
    \endlist

    \image ../images/example-satelliteinfo.png

    The example displays the signal strength of all satellites in view. Any
    satellite that is currently used to calculate the GPS fix is marked pink.
    The number at the bottom of each signal bar is the individual satellite
    identifier.

    The application operates in three different modes:

    \table
        \header
            \li Application mode
            \li Description
        \row
            \li running
            \li The application continuously queries the system for satellite updates. When new data
                is available it will be displayed.
        \row
            \li stopped
            \li The application stops updating the satellite information.
        \row
            \li single
            \li The application makes a single update request with a timeout of 10s. The display
                remains empty until the request was answered by the system.
    \endtable

    If the platform does not provide satellite information, the application
    automatically switches into a demo mode, whereby it continuously switches
    between predefined sets of satellite data.

    \include examples-run.qdocinc

    \section1 Satellite Info Model

    The key part of this example is the \c SatelliteModel data model. It
    represents the information about the satellites.
    It uses the \l Q_PROPERTY and \l QML_ELEMENT macros, so that it can be
    available from QML.

    \snippet satelliteinfo/satellitemodel.h 0
    \snippet satelliteinfo/satellitemodel.h 1
    \snippet satelliteinfo/satellitemodel.h 2

    The \c SatelliteModel object creates an instance of
    \l QGeoSatelliteInfoSource using the \l {QGeoSatelliteInfoSource::}
    {createDefaultSource()} method. Once the source is created, the
    \l {QGeoSatelliteInfoSource::}{satellitesInViewUpdated()} and
    \l {QGeoSatelliteInfoSource::}{satellitesInUseUpdated()} signals are used
    to notify about the changes in satellite information.

    \snippet satelliteinfo/satellitemodel.cpp 0

    The aforementioned signals provide the lists of \l QGeoSatelliteInfo
    objects that represent satellites in view and satellites in use,
    respectively. This data is used to update the model.

    \snippet satelliteinfo/satellitemodel.cpp 1

    If the satellite info source is not available, demo data is used to simulate
    satellite information updates.

    \snippet satelliteinfo/satellitemodel.cpp 2

    The model is later used in QML to visualize the data.

    \section1 Exposing the Model to QML

    To expose \c SatelliteModel to QML, we use the \l QML_ELEMENT macro.
    See the \l QQmlEngine class documentation for more details on it.

    To make the type available in QML, we need to update our build accordingly.

    \section2 CMake Build

    For a CMake-based build, we need to add the following to the
    \c {CMakeLists.txt}:

    \quotefromfile satelliteinfo/CMakeLists.txt
    \skipto qt_add_qml_module(satelliteinfo
    \printuntil )

    \section2 qmake Build

    For a qmake build, we need to modify the \c {satelliteinfo.pro} file in the
    following way:

    \quotefromfile satelliteinfo/satelliteinfo.pro
    \skipto CONFIG
    \printuntil QML_IMPORT_MAJOR_VERSION
*/