KContacts

email.h
1/*
2 This file is part of the KContacts framework.
3 SPDX-FileCopyrightText: 2015-2019 Laurent Montel <montel@kde.org>
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
18class EmailTest;
19
20namespace KContacts
21{
22class ParameterMap;
23
24/** @short Class that holds a Email for a contact.
25 * @since 4.14.5
26 */
27class 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
40public:
41 /**
42 * Creates an empty email object.
43 */
44 Email();
45 Email(const Email &other);
46 Q_INVOKABLE Email(const QString &mail);
47
48 ~Email();
49
50 typedef QList<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 Q_REQUIRED_RESULT bool operator==(const Email &other) const;
97 Q_REQUIRED_RESULT bool operator!=(const Email &other) const;
98
99 Email &operator=(const Email &other);
100
101 Q_REQUIRED_RESULT QString toString() const;
102
103private:
104 void setParams(const ParameterMap &params);
105 Q_REQUIRED_RESULT ParameterMap params() const;
106
107 class Private;
109};
110
111Q_DECLARE_OPERATORS_FOR_FLAGS(Email::Type)
112
113KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Email &object);
114
115KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Email &object);
116}
117
118Q_DECLARE_TYPEINFO(KContacts::Email, Q_RELOCATABLE_TYPE);
119
120#endif // EMAIL_H
Class that holds a Email for a contact.
Definition email.h:28
TypeFlag
Email types.
Definition email.h:56
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.