Warning, file /frameworks/kcontacts/src/email.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     This file is part of the KContacts framework.
0003     SPDX-FileCopyrightText: 2015-2019 Laurent Montel <montel@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef EMAIL_H
0009 #define EMAIL_H
0010 
0011 #include "kcontacts_export.h"
0012 
0013 #include <QMap>
0014 #include <QMetaType>
0015 #include <QSharedDataPointer>
0016 #include <QString>
0017 
0018 class EmailTest;
0019 
0020 namespace KContacts
0021 {
0022 class ParameterMap;
0023 
0024 /** @short Class that holds a Email for a contact.
0025  *  @since 4.14.5
0026  */
0027 class KCONTACTS_EXPORT Email
0028 {
0029     friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Email &);
0030     friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Email &);
0031     friend class VCardTool;
0032     friend class ::EmailTest;
0033 
0034     Q_GADGET
0035     Q_PROPERTY(QString email READ mail WRITE setEmail)
0036     Q_PROPERTY(bool isValid READ isValid)
0037     Q_PROPERTY(Type type READ type WRITE setType)
0038     Q_PROPERTY(bool isPreferred READ isPreferred WRITE setPreferred)
0039 
0040 public:
0041     /**
0042      * Creates an empty email object.
0043      */
0044     Email();
0045     Email(const Email &other);
0046     Email(const QString &mail);
0047 
0048     ~Email();
0049 
0050     typedef QVector<Email> List;
0051 
0052     /**
0053      * Email types.
0054      * @see Type
0055      */
0056     enum TypeFlag {
0057         Unknown = 0, /**< No or unknown email type is set. */
0058         Home = 1, /**< Personal email. */
0059         Work = 2, /**< Work email. */
0060         Other = 4, /**< Other email. */
0061     };
0062 
0063     /**
0064      * Stores a combination of #TypeFlag values.
0065      */
0066     Q_DECLARE_FLAGS(Type, TypeFlag)
0067     Q_FLAG(Type)
0068 
0069     void setEmail(const QString &mail);
0070     Q_REQUIRED_RESULT QString mail() const;
0071 
0072     Q_REQUIRED_RESULT bool isValid() const;
0073 
0074     /**
0075      * Returns the type of the email.
0076      * @since 5.12
0077      */
0078     Type type() const;
0079     /**
0080      * Sets the email type.
0081      * @since 5.12
0082      */
0083     void setType(Type type);
0084 
0085     /**
0086      * Returns whether this is the preferred email address.
0087      * @since 5.12
0088      */
0089     bool isPreferred() const;
0090     /**
0091      * Sets that this is the preferred email address.
0092      * @since 5.12
0093      */
0094     void setPreferred(bool preferred);
0095 
0096 #if KCONTACTS_ENABLE_DEPRECATED_SINCE(5, 88)
0097     /**
0098      * @deprecated Since 5.88 for lack of usage
0099      */
0100     KCONTACTS_DEPRECATED_VERSION(5, 88, "For lack of usage.")
0101     void setParameters(const QMap<QString, QStringList> &params);
0102 #endif
0103 
0104 #if KCONTACTS_ENABLE_DEPRECATED_SINCE(5, 88)
0105     /**
0106      * @deprecated Since 5.88 for lack of usage
0107      */
0108     Q_REQUIRED_RESULT
0109     KCONTACTS_DEPRECATED_VERSION(5, 88, "For lack of usage.")
0110     QMap<QString, QStringList> parameters() const;
0111 #endif
0112 
0113     Q_REQUIRED_RESULT bool operator==(const Email &other) const;
0114     Q_REQUIRED_RESULT bool operator!=(const Email &other) const;
0115 
0116     Email &operator=(const Email &other);
0117 
0118     Q_REQUIRED_RESULT QString toString() const;
0119 
0120 private:
0121     void setParams(const ParameterMap &params);
0122     Q_REQUIRED_RESULT ParameterMap params() const;
0123 
0124     class Private;
0125     QSharedDataPointer<Private> d;
0126 };
0127 
0128 Q_DECLARE_OPERATORS_FOR_FLAGS(Email::Type)
0129 
0130 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Email &object);
0131 
0132 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Email &object);
0133 }
0134 Q_DECLARE_METATYPE(KContacts::Email)
0135 Q_DECLARE_TYPEINFO(KContacts::Email, Q_MOVABLE_TYPE);
0136 #endif // EMAIL_H