| 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 <QString> |
| 12 | #include <QStringList> |
| 13 | #include <QVariant> |
| 14 | |
| 15 | #include "kcontacts_export.h" |
| 16 | |
| 17 | #include "../parametermap_p.h" |
| 18 | |
| 19 | namespace KContacts |
| 20 | { |
| 21 | class KCONTACTS_EXPORT VCardLine |
| 22 | { |
| 23 | public: |
| 24 | typedef QList<VCardLine> List; |
| 25 | |
| 26 | VCardLine(); |
| 27 | VCardLine(const QString &identifier); |
| 28 | VCardLine(const QString &identifier, const QVariant &value); |
| 29 | VCardLine(const VCardLine &line); |
| 30 | |
| 31 | ~VCardLine(); |
| 32 | |
| 33 | VCardLine &operator=(const VCardLine &line); |
| 34 | |
| 35 | /*! |
| 36 | * Equality operator. |
| 37 | * |
| 38 | */ |
| 39 | Q_REQUIRED_RESULT bool operator==(const VCardLine &other) const; |
| 40 | |
| 41 | /*! |
| 42 | * Sets the identifier of this line e.g. UID, FN, CLASS |
| 43 | * |
| 44 | * @param identifier The VCard identifier of this line |
| 45 | */ |
| 46 | void setIdentifier(const QString &identifier); |
| 47 | |
| 48 | /*! |
| 49 | * Returns the identifier of this line. |
| 50 | */ |
| 51 | Q_REQUIRED_RESULT QString identifier() const; |
| 52 | |
| 53 | /*! |
| 54 | * Sets the value of this line. |
| 55 | */ |
| 56 | void setValue(const QVariant &value); |
| 57 | |
| 58 | /*! |
| 59 | * Returns the value of this line. |
| 60 | */ |
| 61 | Q_REQUIRED_RESULT QVariant value() const; |
| 62 | |
| 63 | /*! |
| 64 | * Sets the group the line belongs to. |
| 65 | */ |
| 66 | void setGroup(const QString &group); |
| 67 | |
| 68 | /*! |
| 69 | * Returns the group the line belongs to. |
| 70 | */ |
| 71 | Q_REQUIRED_RESULT QString group() const; |
| 72 | |
| 73 | /*! |
| 74 | * Returns whether the line belongs to a group. |
| 75 | */ |
| 76 | Q_REQUIRED_RESULT bool hasGroup() const; |
| 77 | |
| 78 | /*! |
| 79 | * Returns all parameters. |
| 80 | */ |
| 81 | Q_REQUIRED_RESULT QStringList parameterList() const; |
| 82 | |
| 83 | /*! |
| 84 | * Add a new parameter to the line. |
| 85 | * |
| 86 | * @param param Name of the parameter to insert |
| 87 | * @param value Value of the parameter to insert |
| 88 | */ |
| 89 | void addParameter(const QString ¶m, const QString &value); |
| 90 | |
| 91 | void addParameters(const ParameterMap ¶ms); |
| 92 | |
| 93 | /*! |
| 94 | * Returns the values of a special parameter. |
| 95 | * You can get a list of all parameters with paramList(). |
| 96 | * |
| 97 | * @param param Name of the parameter to look for |
| 98 | */ |
| 99 | Q_REQUIRED_RESULT QStringList parameters(const QString ¶m) const; |
| 100 | |
| 101 | /*! |
| 102 | * Returns only the first value of a special parameter. |
| 103 | * You can get a list of all parameters with paramList(). |
| 104 | * |
| 105 | * @param param Name of the parameter to look for |
| 106 | */ |
| 107 | Q_REQUIRED_RESULT QString parameter(const QString ¶m) const; |
| 108 | |
| 109 | /*! |
| 110 | * Returns all parameters |
| 111 | */ |
| 112 | Q_REQUIRED_RESULT ParameterMap parameterMap() const; |
| 113 | |
| 114 | private: |
| 115 | ParameterMap mParamMap; |
| 116 | QString mIdentifier; |
| 117 | QString mGroup; |
| 118 | QVariant mValue; |
| 119 | }; |
| 120 | } |
| 121 | |
| 122 | #endif |
| 123 | |