1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtContacts module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#ifndef QDECLARATIVECONTACTGEOLOCATION_H
35#define QDECLARATIVECONTACTGEOLOCATION_H
36
37#include <QtContacts/qcontactgeolocation.h>
38
39#include "qdeclarativecontactdetail_p.h"
40
41QTCONTACTS_USE_NAMESPACE
42
43QT_BEGIN_NAMESPACE
44
45class QDeclarativeContactGeoLocation : public QDeclarativeContactDetail
46{
47 Q_OBJECT
48
49 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY valueChanged)
50 Q_PROPERTY(double latitude READ latitude WRITE setLatitude NOTIFY valueChanged)
51 Q_PROPERTY(double longitude READ longitude WRITE setLongitude NOTIFY valueChanged)
52 Q_PROPERTY(double accuracy READ accuracy WRITE setAccuracy NOTIFY valueChanged)
53 Q_PROPERTY(double altitude READ altitude WRITE setAltitude NOTIFY valueChanged)
54 Q_PROPERTY(double altitudeAccuracy READ altitudeAccuracy WRITE setAltitudeAccuracy NOTIFY valueChanged)
55 Q_PROPERTY(double heading READ heading WRITE setHeading NOTIFY valueChanged)
56 Q_PROPERTY(double speed READ speed WRITE setSpeed NOTIFY valueChanged)
57 Q_PROPERTY(QDateTime timestamp READ timestamp WRITE setTimestamp NOTIFY valueChanged)
58 Q_CLASSINFO("DefaultProperty", "label")
59 Q_ENUMS(FieldType)
60public:
61 enum FieldType {
62 Label = QContactGeoLocation::FieldLabel,
63 Latitude = QContactGeoLocation::FieldLatitude,
64 Longitude = QContactGeoLocation::FieldLongitude,
65 Accuracy = QContactGeoLocation::FieldAccuracy,
66 Altitude = QContactGeoLocation::FieldAltitude,
67 AltitudeAccuracy = QContactGeoLocation::FieldAltitudeAccuracy,
68 Heading = QContactGeoLocation::FieldHeading,
69 Speed = QContactGeoLocation::FieldSpeed,
70 Timestamp = QContactGeoLocation::FieldTimestamp
71 };
72
73 QDeclarativeContactGeoLocation(QObject* parent = Q_NULLPTR)
74 :QDeclarativeContactDetail(parent)
75 {
76 setDetail(QContactGeoLocation());
77 connect(asender: this, SIGNAL(valueChanged()), SIGNAL(detailChanged()));
78 }
79 DetailType detailType() const
80 {
81 return QDeclarativeContactDetail::Geolocation;
82 }
83
84 void setLabel(const QString& v)
85 {
86 if (!readOnly() && v != label()) {
87 detail().setValue(field: QContactGeoLocation::FieldLabel, value: v);
88 emit valueChanged();
89 }
90 }
91 QString label() const {return detail().value(field: QContactGeoLocation::FieldLabel).toString();}
92 void setLatitude(double v)
93 {
94 if (!readOnly() && !qFuzzyCompare(p1: v, p2: latitude())) {
95 detail().setValue(field: QContactGeoLocation::FieldLatitude, value: v);
96 emit valueChanged();
97 }
98 }
99 double latitude() const {return detail().value(field: QContactGeoLocation::FieldLatitude).toDouble();}
100 void setLongitude(double v)
101 {
102 if (!readOnly() && !qFuzzyCompare(p1: v, p2: longitude())) {
103 detail().setValue(field: QContactGeoLocation::FieldLongitude, value: v);
104 emit valueChanged();
105 }
106 }
107 double longitude() const {return detail().value(field: QContactGeoLocation::FieldLongitude).toDouble();}
108 void setAccuracy(double v)
109 {
110 if (!readOnly() && !qFuzzyCompare(p1: v, p2: accuracy())) {
111 detail().setValue(field: QContactGeoLocation::FieldAccuracy, value: v);
112 emit valueChanged();
113 }
114 }
115 double accuracy() const {return detail().value(field: QContactGeoLocation::FieldAccuracy).toDouble();}
116 void setAltitude(double v)
117 {
118 if (!readOnly() && !qFuzzyCompare(p1: v, p2: altitude())) {
119 detail().setValue(field: QContactGeoLocation::FieldAltitude, value: v);
120 emit valueChanged();
121 }
122 }
123 double altitude() const {return detail().value(field: QContactGeoLocation::FieldAltitude).toDouble();}
124 void setAltitudeAccuracy(double v)
125 {
126 if (!readOnly() && !qFuzzyCompare(p1: v, p2: altitudeAccuracy())) {
127 detail().setValue(field: QContactGeoLocation::FieldAltitudeAccuracy, value: v);
128 emit valueChanged();
129 }
130 }
131 double altitudeAccuracy() const {return detail().value(field: QContactGeoLocation::FieldAltitudeAccuracy).toDouble();}
132 void setHeading(double v)
133 {
134 if (!readOnly() && v != heading()) {
135 detail().setValue(field: QContactGeoLocation::FieldHeading, value: v);
136 emit valueChanged();
137 }
138 }
139 double heading() const {return detail().value(field: QContactGeoLocation::FieldHeading).toDouble();}
140 void setSpeed(double v)
141 {
142 if (!readOnly() && !qFuzzyCompare(p1: v, p2: speed())) {
143 detail().setValue(field: QContactGeoLocation::FieldSpeed, value: v);
144 emit valueChanged();
145 }
146 }
147 double speed() const {return detail().value(field: QContactGeoLocation::FieldSpeed).toDouble();}
148 void setTimestamp(const QDateTime& v)
149 {
150 if (!readOnly() && v != timestamp()) {
151 detail().setValue(field: QContactGeoLocation::FieldTimestamp, value: v);
152 emit valueChanged();
153 }
154 }
155 QDateTime timestamp() const {return detail().value(field: QContactGeoLocation::FieldTimestamp).toDateTime();}
156signals:
157 void valueChanged();
158};
159
160QT_END_NAMESPACE
161
162QML_DECLARE_TYPE(QDeclarativeContactGeoLocation)
163
164#endif // QDECLARATIVECONTACTGEOLOCATION_H
165

source code of qtpim/src/imports/contacts/details/qdeclarativecontactgeolocation_p.h