KContacts

vcardline.cpp
1 /*
2  This file is part of the KContacts framework.
3  SPDX-FileCopyrightText: 2003 Tobias Koenig <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #include "vcardline.h"
9 
10 using namespace KContacts;
11 
12 VCardLine::VCardLine()
13 {
14 }
15 
16 VCardLine::VCardLine(const QString &identifier)
17 {
18  mIdentifier = identifier;
19 }
20 
21 VCardLine::VCardLine(const QString &identifier, const QVariant &value)
22 {
23  mIdentifier = identifier;
24  mValue = value;
25 }
26 
27 VCardLine::VCardLine(const VCardLine &line)
28 {
29  mParamMap = line.mParamMap;
30  mValue = line.mValue;
31  mIdentifier = line.mIdentifier;
32  mGroup = line.mGroup;
33 }
34 
35 VCardLine::~VCardLine()
36 {
37 }
38 
39 VCardLine &VCardLine::operator=(const VCardLine &line)
40 {
41  if (&line == this) {
42  return *this;
43  }
44 
45  mParamMap = line.mParamMap;
46  mValue = line.mValue;
47  mIdentifier = line.mIdentifier;
48  mGroup = line.mGroup;
49 
50  return *this;
51 }
52 
53 bool VCardLine::operator==(const VCardLine &other) const
54 {
55  // clang-format off
56  return (mParamMap == other.parameterMap())
57  && (mValue == other.value())
58  && (mIdentifier == other.identifier())
59  && (mGroup == other.group());
60  // clang-format on
61 }
62 
63 void VCardLine::setIdentifier(const QString &identifier)
64 {
65  mIdentifier = identifier;
66 }
67 
68 QString VCardLine::identifier() const
69 {
70  return mIdentifier;
71 }
72 
73 void VCardLine::setValue(const QVariant &value)
74 {
75  mValue = value;
76 }
77 
78 QVariant VCardLine::value() const
79 {
80  return mValue;
81 }
82 
83 void VCardLine::setGroup(const QString &group)
84 {
85  mGroup = group;
86 }
87 
88 QString VCardLine::group() const
89 {
90  return mGroup;
91 }
92 
93 bool VCardLine::hasGroup() const
94 {
95  return !mGroup.isEmpty();
96 }
97 
98 QStringList VCardLine::parameterList() const
99 {
100  return mParamMap.keys();
101 }
102 
103 void VCardLine::addParameter(const QString &param, const QString &value)
104 {
105  QStringList &list = mParamMap[param];
106  if (!list.contains(value)) { // not included yet
107  list.append(value);
108  }
109 }
110 
111 QStringList VCardLine::parameters(const QString &param) const
112 {
113  ParamMap::ConstIterator it = mParamMap.find(param);
114  if (it == mParamMap.end()) {
115  return QStringList();
116  } else {
117  return *it;
118  }
119 }
120 
121 QString VCardLine::parameter(const QString &param) const
122 {
123  ParamMap::ConstIterator it = mParamMap.find(param);
124  if (it == mParamMap.end()) {
125  return QString();
126  } else {
127  if ((*it).isEmpty()) {
128  return QString();
129  } else {
130  return (*it).first();
131  }
132  }
133 }
134 
135 VCardLine::ParamMap VCardLine::parameterMap() const
136 {
137  return mParamMap;
138 }
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
void append(const T &value)
bool isEmpty() const const
KIOFILEWIDGETS_EXPORT QStringList list(const QString &fileClass)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Jun 18 2021 22:54:49 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.