KContacts

geo.h
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
17namespace KContacts
18{
19/**
20 * @short Geographic position
21 *
22 * This class represents a geographic position.
23 */
24class KCONTACTS_EXPORT Geo
25{
26 friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Geo &);
27 friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Geo &);
28
29 Q_GADGET
30 Q_PROPERTY(float latitude READ latitude WRITE setLatitude)
31 Q_PROPERTY(float longitude READ longitude WRITE setLongitude)
32 Q_PROPERTY(bool isValid READ isValid)
33
34public:
35 /**
36 * Creates an invalid geographics position object.
37 */
38 Geo();
39
40 /**
41 * Creates a geographics position object.
42 *
43 * @param latitude Geographical latitude
44 * @param longitude Geographical longitude
45 */
46 Geo(float latitude, float longitude);
47
48 /**
49 * Copy constructor.
50 */
51 Geo(const Geo &other);
52
53 /**
54 * Destroys the geographics position object.
55 */
56 ~Geo();
57
58 /**
59 * Sets the @p latitude.
60 *
61 * @param latitude The location's latitude coordinate
62 */
63 void setLatitude(float latitude);
64
65 /**
66 * Returns the latitude.
67 */
68 Q_REQUIRED_RESULT float latitude() const;
69
70 /**
71 * Sets the @p longitude.
72 *
73 * @param longitude The location's longitude coordinate
74 */
75 void setLongitude(float longitude);
76
77 /**
78 * Returns the longitude.
79 */
80 Q_REQUIRED_RESULT float longitude() const;
81
82 /**
83 * Returns, whether this object contains a valid geographical position.
84 */
85 Q_REQUIRED_RESULT bool isValid() const;
86
87 /**
88 * Equality operator.
89 *
90 * @note Two invalid Geo instance will return @c true
91 */
92 Q_REQUIRED_RESULT bool operator==(const Geo &other) const;
93
94 /**
95 * Not-Equal operator.
96 */
97 bool operator!=(const Geo &other) const;
98
99 /**
100 * Assignment operator.
101 *
102 * @param other The Geo instance to assign to @c this
103 */
104 Geo &operator=(const Geo &other);
105
106 /**
107 * Returns string representation of geographical position.
108 */
109 Q_REQUIRED_RESULT QString toString() const;
110
111 /**
112 * Clears the class, marking it as invalid.
113 *
114 * @since 5.6
115 */
116 void clear();
117
118private:
119 class Private;
121};
122
123/**
124 * Serializes the geographical position @p object into the @p stream.
125 */
126KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Geo &object);
127
128/**
129 * Initializes the geographical position @p object from the @p stream.
130 */
131KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Geo &object);
132}
133
134Q_DECLARE_TYPEINFO(KContacts::Geo, Q_RELOCATABLE_TYPE);
135
136#endif
Geographic position.
Definition geo.h:25
friend KCONTACTS_EXPORT QDataStream & operator<<(QDataStream &, const Geo &)
Serializes the geographical position object into the stream.
friend KCONTACTS_EXPORT QDataStream & operator>>(QDataStream &, Geo &)
Initializes the geographical position object from the stream.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:56:24 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.