1 | /* |
2 | This file is part of the KContacts framework. |
3 | SPDX-FileCopyrightText: 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #ifndef KCONTACTS_GEO_H |
9 | #define KCONTACTS_GEO_H |
10 | |
11 | #include "kcontacts_export.h" |
12 | |
13 | #include <QMetaType> |
14 | #include <QSharedDataPointer> |
15 | #include <QString> |
16 | |
17 | namespace KContacts |
18 | { |
19 | /*! |
20 | * \qmlvaluetype geo |
21 | * \inqmlmodule org.kde.contacts |
22 | * \nativetype KContacts::Geo |
23 | * |
24 | * \brief Geographic position. |
25 | * |
26 | * This class represents a geographic position. |
27 | */ |
28 | |
29 | /*! |
30 | * \class KContacts::Geo |
31 | * \inheaderfile KContacts/Geo |
32 | * \inmodule KContacts |
33 | * |
34 | * \brief Geographic position. |
35 | * |
36 | * This class represents a geographic position. |
37 | */ |
38 | class KCONTACTS_EXPORT Geo |
39 | { |
40 | friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Geo &); |
41 | friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Geo &); |
42 | |
43 | Q_GADGET |
44 | |
45 | /*! |
46 | * \qmlproperty real geo::latitude |
47 | */ |
48 | |
49 | /*! |
50 | * \property KContacts::Geo::latitude |
51 | */ |
52 | Q_PROPERTY(float latitude READ latitude WRITE setLatitude) |
53 | |
54 | /*! |
55 | * \qmlproperty real geo::longitude |
56 | */ |
57 | |
58 | /*! |
59 | * \property KContacts::Geo::longitude |
60 | */ |
61 | Q_PROPERTY(float longitude READ longitude WRITE setLongitude) |
62 | |
63 | /*! |
64 | * \qmlproperty real geo::isValid |
65 | */ |
66 | |
67 | /*! |
68 | * \property KContacts::Geo::isValid |
69 | */ |
70 | Q_PROPERTY(bool isValid READ isValid) |
71 | |
72 | public: |
73 | /*! |
74 | * Creates an invalid geographics position object. |
75 | */ |
76 | Geo(); |
77 | |
78 | /*! |
79 | * Creates a geographics position object. |
80 | * |
81 | * \a latitude Geographical latitude |
82 | * |
83 | * \a longitude Geographical longitude |
84 | */ |
85 | Geo(float latitude, float longitude); |
86 | |
87 | Geo(const Geo &other); |
88 | |
89 | ~Geo(); |
90 | |
91 | /*! |
92 | * Sets the \a latitude. |
93 | * |
94 | * \a latitude The location's latitude coordinate |
95 | */ |
96 | void setLatitude(float latitude); |
97 | |
98 | /*! |
99 | * Returns the latitude. |
100 | */ |
101 | Q_REQUIRED_RESULT float latitude() const; |
102 | |
103 | /*! |
104 | * Sets the \a longitude. |
105 | * |
106 | * \a longitude The location's longitude coordinate |
107 | */ |
108 | void setLongitude(float longitude); |
109 | |
110 | /*! |
111 | * Returns the longitude. |
112 | */ |
113 | Q_REQUIRED_RESULT float longitude() const; |
114 | |
115 | /*! |
116 | * Returns, whether this object contains a valid geographical position. |
117 | */ |
118 | Q_REQUIRED_RESULT bool isValid() const; |
119 | |
120 | /*! |
121 | * Equality operator. |
122 | * |
123 | * \note Two invalid Geo instance will return \c true |
124 | */ |
125 | Q_REQUIRED_RESULT bool operator==(const Geo &other) const; |
126 | |
127 | /*! |
128 | * Not-Equal operator. |
129 | */ |
130 | bool operator!=(const Geo &other) const; |
131 | |
132 | /*! |
133 | * Assignment operator. |
134 | * |
135 | * \a other The Geo instance to assign to \c this |
136 | */ |
137 | Geo &operator=(const Geo &other); |
138 | |
139 | /*! |
140 | * Returns string representation of geographical position. |
141 | */ |
142 | Q_REQUIRED_RESULT QString toString() const; |
143 | |
144 | /*! |
145 | * Clears the class, marking it as invalid. |
146 | * |
147 | * \since 5.6 |
148 | */ |
149 | void clear(); |
150 | |
151 | private: |
152 | class Private; |
153 | QSharedDataPointer<Private> d; |
154 | }; |
155 | |
156 | /*! |
157 | * \relates KContacts::Geo |
158 | * |
159 | * Serializes the geographical position \a object into the \a stream. |
160 | */ |
161 | KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Geo &object); |
162 | |
163 | /*! |
164 | * \relates KContacts::Geo |
165 | * |
166 | * Initializes the geographical position \a object from the \a stream. |
167 | */ |
168 | KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Geo &object); |
169 | } |
170 | |
171 | Q_DECLARE_TYPEINFO(KContacts::Geo, Q_RELOCATABLE_TYPE); |
172 | |
173 | #endif |
174 | |