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 
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:
38  Email();
39  Email(const Email &other);
40  Email(const QString &mail);
41 
42  ~Email();
43 
44  typedef QVector<Email> List;
45 
50  enum TypeFlag {
51  Unknown = 0,
52  Home = 1,
53  Work = 2,
54  Other = 4,
55  };
56 
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 
72  Type type() const;
77  void setType(Type type);
78 
83  bool isPreferred() const;
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 private:
100  class Private;
101  QSharedDataPointer<Private> d;
102 };
103 
104 Q_DECLARE_OPERATORS_FOR_FLAGS(Email::Type)
105 
106 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Email &object);
107 
108 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Email &object);
109 }
110 Q_DECLARE_METATYPE(KContacts::Email)
111 Q_DECLARE_TYPEINFO(KContacts::Email, Q_MOVABLE_TYPE);
112 #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-2020 The KDE developers.
Generated on Fri Jul 3 2020 22:54:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.