| 1 | /* |
| 2 | This file is part of the KContacts framework. |
| 3 | SPDX-FileCopyrightText: 2003 Tobias Koenig <tokoe@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef VCARDLINE_H |
| 9 | #define VCARDLINE_H |
| 10 | |
| 11 | #include <QDebug> |
| 12 | #include <QString> |
| 13 | #include <QStringList> |
| 14 | #include <QVariant> |
| 15 | |
| 16 | #include "kcontacts_export.h" |
| 17 | |
| 18 | #include "../parametermap_p.h" |
| 19 | |
| 20 | namespace KContacts |
| 21 | { |
| 22 | class KCONTACTS_EXPORT VCardLine |
| 23 | { |
| 24 | public: |
| 25 | typedef QList<VCardLine> List; |
| 26 | |
| 27 | VCardLine(); |
| 28 | VCardLine(const QString &identifier); |
| 29 | VCardLine(const QString &identifier, const QVariant &value); |
| 30 | VCardLine(const VCardLine &line); |
| 31 | |
| 32 | ~VCardLine(); |
| 33 | |
| 34 | VCardLine &operator=(const VCardLine &line); |
| 35 | |
| 36 | /*! |
| 37 | * Equality operator. |
| 38 | * |
| 39 | */ |
| 40 | [[nodiscard]] bool operator==(const VCardLine &other) const; |
| 41 | |
| 42 | /*! |
| 43 | * Sets the identifier of this line e.g. UID, FN, CLASS |
| 44 | * |
| 45 | * @param identifier The VCard identifier of this line |
| 46 | */ |
| 47 | void setIdentifier(const QString &identifier); |
| 48 | |
| 49 | /*! |
| 50 | * Returns the identifier of this line. |
| 51 | */ |
| 52 | [[nodiscard]] QString identifier() const; |
| 53 | |
| 54 | /*! |
| 55 | * Sets the value of this line. |
| 56 | */ |
| 57 | void setValue(const QVariant &value); |
| 58 | |
| 59 | /*! |
| 60 | * Returns the value of this line. |
| 61 | */ |
| 62 | [[nodiscard]] QVariant value() const; |
| 63 | |
| 64 | /*! |
| 65 | * Sets the group the line belongs to. |
| 66 | */ |
| 67 | void setGroup(const QString &group); |
| 68 | |
| 69 | /*! |
| 70 | * Returns the group the line belongs to. |
| 71 | */ |
| 72 | [[nodiscard]] QString group() const; |
| 73 | |
| 74 | /*! |
| 75 | * Returns whether the line belongs to a group. |
| 76 | */ |
| 77 | [[nodiscard]] bool hasGroup() const; |
| 78 | |
| 79 | /*! |
| 80 | * Returns all parameters. |
| 81 | */ |
| 82 | [[nodiscard]] QStringList parameterList() const; |
| 83 | |
| 84 | /*! |
| 85 | * Add a new parameter to the line. |
| 86 | * |
| 87 | * @param param Name of the parameter to insert |
| 88 | * @param value Value of the parameter to insert |
| 89 | */ |
| 90 | void addParameter(const QString ¶m, const QString &value); |
| 91 | |
| 92 | void addParameters(const ParameterMap ¶ms); |
| 93 | |
| 94 | /*! |
| 95 | * Returns the values of a special parameter. |
| 96 | * You can get a list of all parameters with paramList(). |
| 97 | * |
| 98 | * @param param Name of the parameter to look for |
| 99 | */ |
| 100 | [[nodiscard]] QStringList parameters(const QString ¶m) const; |
| 101 | |
| 102 | /*! |
| 103 | * Returns only the first value of a special parameter. |
| 104 | * You can get a list of all parameters with paramList(). |
| 105 | * |
| 106 | * @param param Name of the parameter to look for |
| 107 | */ |
| 108 | [[nodiscard]] QString parameter(const QString ¶m) const; |
| 109 | |
| 110 | /*! |
| 111 | * Returns all parameters |
| 112 | */ |
| 113 | [[nodiscard]] ParameterMap parameterMap() const; |
| 114 | |
| 115 | /*! |
| 116 | * Add base64 value |
| 117 | */ |
| 118 | [[nodiscard]] QByteArray base64Value() const; |
| 119 | void setBase64Value(const QByteArray &newBase64Value); |
| 120 | |
| 121 | private: |
| 122 | QByteArray mBase64Value; |
| 123 | ParameterMap mParamMap; |
| 124 | QString mIdentifier; |
| 125 | QString mGroup; |
| 126 | QVariant mValue; |
| 127 | }; |
| 128 | } |
| 129 | KCONTACTS_EXPORT QDebug operator<<(QDebug d, const KContacts::VCardLine &t); |
| 130 | #endif |
| 131 | |