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 class EmailTest;
19 
20 namespace KContacts
21 {
22 class ParameterMap;
23 
24 /** @short Class that holds a Email for a contact.
25  * @since 4.14.5
26  */
27 class KCONTACTS_EXPORT Email
28 {
29  friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Email &);
30  friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Email &);
31  friend class VCardTool;
32  friend class ::EmailTest;
33 
34  Q_GADGET
35  Q_PROPERTY(QString email READ mail WRITE setEmail)
36  Q_PROPERTY(bool isValid READ isValid)
37  Q_PROPERTY(Type type READ type WRITE setType)
38  Q_PROPERTY(bool isPreferred READ isPreferred WRITE setPreferred)
39 
40 public:
41  /**
42  * Creates an empty email object.
43  */
44  Email();
45  Email(const Email &other);
46  Email(const QString &mail);
47 
48  ~Email();
49 
50  typedef QVector<Email> List;
51 
52  /**
53  * Email types.
54  * @see Type
55  */
56  enum TypeFlag {
57  Unknown = 0, /**< No or unknown email type is set. */
58  Home = 1, /**< Personal email. */
59  Work = 2, /**< Work email. */
60  Other = 4, /**< Other email. */
61  };
62 
63  /**
64  * Stores a combination of #TypeFlag values.
65  */
66  Q_DECLARE_FLAGS(Type, TypeFlag)
67  Q_FLAG(Type)
68 
69  void setEmail(const QString &mail);
70  Q_REQUIRED_RESULT QString mail() const;
71 
72  Q_REQUIRED_RESULT bool isValid() const;
73 
74  /**
75  * Returns the type of the email.
76  * @since 5.12
77  */
78  Type type() const;
79  /**
80  * Sets the email type.
81  * @since 5.12
82  */
83  void setType(Type type);
84 
85  /**
86  * Returns whether this is the preferred email address.
87  * @since 5.12
88  */
89  bool isPreferred() const;
90  /**
91  * Sets that this is the preferred email address.
92  * @since 5.12
93  */
94  void setPreferred(bool preferred);
95 
96 #if KCONTACTS_ENABLE_DEPRECATED_SINCE(5, 88)
97  /**
98  * @deprecated Since 5.88 for lack of usage
99  */
100  KCONTACTS_DEPRECATED_VERSION(5, 88, "For lack of usage.")
101  void setParameters(const QMap<QString, QStringList> &params);
102 #endif
103 
104 #if KCONTACTS_ENABLE_DEPRECATED_SINCE(5, 88)
105  /**
106  * @deprecated Since 5.88 for lack of usage
107  */
108  Q_REQUIRED_RESULT
109  KCONTACTS_DEPRECATED_VERSION(5, 88, "For lack of usage.")
110  QMap<QString, QStringList> parameters() const;
111 #endif
112 
113  Q_REQUIRED_RESULT bool operator==(const Email &other) const;
114  Q_REQUIRED_RESULT bool operator!=(const Email &other) const;
115 
116  Email &operator=(const Email &other);
117 
118  Q_REQUIRED_RESULT QString toString() const;
119 
120 private:
121  void setParams(const ParameterMap &params);
122  Q_REQUIRED_RESULT ParameterMap params() const;
123 
124  class Private;
126 };
127 
128 Q_DECLARE_OPERATORS_FOR_FLAGS(Email::Type)
129 
130 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Email &object);
131 
132 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Email &object);
133 }
134 Q_DECLARE_METATYPE(KContacts::Email)
135 Q_DECLARE_TYPEINFO(KContacts::Email, Q_MOVABLE_TYPE);
136 #endif // EMAIL_H
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
Class that holds a Email for a contact.
Definition: email.h:27
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
TypeFlag
Email types.
Definition: email.h:56
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Dec 11 2023 03:48:47 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.