KContacts

email.h
1 /*
2  This file is part of the KContacts framework.
3  SPDX-FileCopyrightText: 2015-2019 Laurent Montel <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef EMAIL_H
9 #define EMAIL_H
10 
11 #include "kcontacts_export.h"
12 
13 #include <QMap>
14 #include <QMetaType>
15 #include <QSharedDataPointer>
16 #include <QString>
17 
18 namespace KContacts
19 {
20 /** @short Class that holds a Email for a contact.
21  * @since 4.14.5
22  */
23 class KCONTACTS_EXPORT Email
24 {
25  friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Email &);
26  friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Email &);
27 
28  Q_GADGET
29  Q_PROPERTY(QString email READ mail WRITE setEmail)
30  Q_PROPERTY(bool isValid READ isValid)
31  Q_PROPERTY(Type type READ type WRITE setType)
32  Q_PROPERTY(bool isPreferred READ isPreferred WRITE setPreferred)
33 
34 public:
35  /**
36  * Creates an empty email object.
37  */
38  Email();
39  Email(const Email &other);
40  Email(const QString &mail);
41 
42  ~Email();
43 
44  typedef QVector<Email> List;
45 
46  /**
47  * Email types.
48  * @see Type
49  */
50  enum TypeFlag {
51  Unknown = 0, /**< No or unknown email type is set. */
52  Home = 1, /**< Personal email. */
53  Work = 2, /**< Work email. */
54  Other = 4, /**< Other email. */
55  };
56 
57  /**
58  * Stores a combination of #TypeFlag values.
59  */
60  Q_DECLARE_FLAGS(Type, TypeFlag)
61  Q_FLAG(Type)
62 
63  void setEmail(const QString &mail);
64  Q_REQUIRED_RESULT QString mail() const;
65 
66  Q_REQUIRED_RESULT bool isValid() const;
67 
68  /**
69  * Returns the type of the email.
70  * @since 5.12
71  */
72  Type type() const;
73  /**
74  * Sets the email type.
75  * @since 5.12
76  */
77  void setType(Type type);
78 
79  /**
80  * Returns whether this is the preferred email address.
81  * @since 5.12
82  */
83  bool isPreferred() const;
84  /**
85  * Sets that this is the preferred email address.
86  * @since 5.12
87  */
88  void setPreferred(bool preferred);
89 
90  void setParameters(const QMap<QString, QStringList> &params);
91  Q_REQUIRED_RESULT QMap<QString, QStringList> parameters() const;
92 
93  Q_REQUIRED_RESULT bool operator==(const Email &other) const;
94  Q_REQUIRED_RESULT bool operator!=(const Email &other) const;
95 
96  Email &operator=(const Email &other);
97 
98  Q_REQUIRED_RESULT QString toString() const;
99 
100 private:
101  class Private;
102  QSharedDataPointer<Private> d;
103 };
104 
105 Q_DECLARE_OPERATORS_FOR_FLAGS(Email::Type)
106 
107 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Email &object);
108 
109 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Email &object);
110 }
111 Q_DECLARE_METATYPE(KContacts::Email)
112 Q_DECLARE_TYPEINFO(KContacts::Email, Q_MOVABLE_TYPE);
113 #endif // EMAIL_H
Class that holds a Email for a contact.
Definition: email.h:23
QDataStream & operator>>(QDataStream &in, KDateTime::Spec &spec)
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
TypeFlag
Email types.
Definition: email.h:50
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Sep 20 2021 22:56:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.