KContacts

address.h
1 /*
2  This file is part of the KContacts framework.
3  SPDX-FileCopyrightText: 2001 Cornelius Schumacher <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KCONTACTS_ADDRESS_H
9 #define KCONTACTS_ADDRESS_H
10 
11 #include "kcontacts_export.h"
12 #include "geo.h"
13 
14 #include <QMetaType>
15 #include <QSharedDataPointer>
16 #include <QString>
17 #include <QVector>
18 
19 namespace KContacts {
20 class Geo;
27 class KCONTACTS_EXPORT Address
28 {
29  friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &s, const Address &addr);
30  friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &s, Address &addr);
31 
32  Q_GADGET
33  Q_PROPERTY(QString id READ id WRITE setId)
34  Q_PROPERTY(bool isEmpty READ isEmpty)
35  Q_PROPERTY(Type type READ type WRITE setType)
36  Q_PROPERTY(QString typeLabel READ typeLabel)
37  Q_PROPERTY(QString postOfficeBox READ postOfficeBox WRITE setPostOfficeBox)
38  Q_PROPERTY(QString extended READ extended WRITE setExtended)
39  Q_PROPERTY(QString street READ street WRITE setStreet)
40  Q_PROPERTY(QString locality READ locality WRITE setLocality)
41  Q_PROPERTY(QString region READ region WRITE setRegion)
42  Q_PROPERTY(QString postalCode READ postalCode WRITE setPostalCode)
43  Q_PROPERTY(QString country READ country WRITE setCountry)
44  Q_PROPERTY(QString label READ label WRITE setLabel)
45  Q_PROPERTY(KContacts::Geo geo READ geo WRITE setGeo)
52  Q_PROPERTY(QString formattedAddress READ formattedAddress)
53 
54 public:
58  typedef QVector<Address> List;
59 
64  enum TypeFlag {
65  Dom = 1,
66  Intl = 2,
67  Postal = 4,
68  Parcel = 8,
69  Home = 16,
70  Work = 32,
71  Pref = 64
72  };
73 
77  Q_DECLARE_FLAGS(Type, TypeFlag)
78  Q_FLAG(Type)
79 
84 
88  Address();
89 
93  Address(Type type);
94 
98  Address(const Address &address);
99 
103  ~Address();
104 
111  Q_REQUIRED_RESULT bool operator==(const Address &other) const;
112 
119  Q_REQUIRED_RESULT bool operator!=(const Address &other) const;
120 
127  Address &operator=(const Address &other);
128 
132  Q_REQUIRED_RESULT bool isEmpty() const;
133 
137  void clear();
138 
142  void setId(const QString &identifier);
143 
147  Q_REQUIRED_RESULT QString id() const;
148 
154  void setType(Type type);
155 
159  Q_REQUIRED_RESULT Type type() const;
160 
164  Q_REQUIRED_RESULT QString typeLabel() const;
165 
169  void setPostOfficeBox(const QString &postOfficeBox);
170 
174  Q_REQUIRED_RESULT QString postOfficeBox() const;
175 
179  static QString postOfficeBoxLabel();
180 
184  void setExtended(const QString &extended);
185 
189  Q_REQUIRED_RESULT QString extended() const;
190 
194  static QString extendedLabel();
195 
199  void setStreet(const QString &street);
200 
204  Q_REQUIRED_RESULT QString street() const;
205 
209  static QString streetLabel();
210 
216  void setLocality(const QString &locality);
217 
221  Q_REQUIRED_RESULT QString locality() const;
222 
226  static QString localityLabel();
227 
233  void setRegion(const QString &region);
234 
238  Q_REQUIRED_RESULT QString region() const;
239 
243  static QString regionLabel();
244 
248  void setPostalCode(const QString &code);
249 
253  Q_REQUIRED_RESULT QString postalCode() const;
254 
258  static QString postalCodeLabel();
259 
263  void setCountry(const QString &country);
264 
268  Q_REQUIRED_RESULT QString country() const;
269 
273  static QString countryLabel();
274 
280  void setLabel(const QString &label);
281 
285  Q_REQUIRED_RESULT QString label() const;
286 
290  static QString labelLabel();
291 
295  static TypeList typeList();
296 
300  static QString typeLabel(Type type);
301 
305  Q_REQUIRED_RESULT QString toString() const;
306 
318  Q_REQUIRED_RESULT QString formattedAddress(const QString &realName = QString(), const QString &orgaName = QString()) const;
319 
327  static QString countryToISO(const QString &cname);
328 
335  static QString ISOtoCountry(const QString &ISOname);
336 
337  static QString typeFlagLabel(TypeFlag type);
338 
342  void setGeo(const Geo &geo);
343 
347  Q_REQUIRED_RESULT Geo geo() const;
348 
349 private:
350  class Private;
351  QSharedDataPointer<Private> d;
352 };
353 
354 Q_DECLARE_OPERATORS_FOR_FLAGS(Address::Type)
355 
359 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Address &address);
360 
364 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Address &address);
365 }
366 
367 Q_DECLARE_METATYPE(KContacts::Address)
368 
369 #endif
QDataStream & operator>>(QDataStream &in, KDateTime::Spec &spec)
Geographic position.
Definition: geo.h:23
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
Postal address information.
Definition: address.h:27
TypeFlag
Address types:
Definition: address.h:64
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Oct 27 2020 23:00:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.