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  return (mParamMap == other.parameterMap())
56  && (mValue == other.value())
57  && (mIdentifier == other.identifier())
58  && (mGroup == other.group());
59 }
60 
61 void VCardLine::setIdentifier(const QString &identifier)
62 {
63  mIdentifier = identifier;
64 }
65 
66 QString VCardLine::identifier() const
67 {
68  return mIdentifier;
69 }
70 
71 void VCardLine::setValue(const QVariant &value)
72 {
73  mValue = value;
74 }
75 
76 QVariant VCardLine::value() const
77 {
78  return mValue;
79 }
80 
81 void VCardLine::setGroup(const QString &group)
82 {
83  mGroup = group;
84 }
85 
86 QString VCardLine::group() const
87 {
88  return mGroup;
89 }
90 
91 bool VCardLine::hasGroup() const
92 {
93  return !mGroup.isEmpty();
94 }
95 
96 QStringList VCardLine::parameterList() const
97 {
98  return mParamMap.keys();
99 }
100 
101 void VCardLine::addParameter(const QString &param, const QString &value)
102 {
103  QStringList &list = mParamMap[ param ];
104  if (!list.contains(value)) { // not included yet
105  list.append(value);
106  }
107 }
108 
109 QStringList VCardLine::parameters(const QString &param) const
110 {
111  ParamMap::ConstIterator it = mParamMap.find(param);
112  if (it == mParamMap.end()) {
113  return QStringList();
114  } else {
115  return *it;
116  }
117 }
118 
119 QString VCardLine::parameter(const QString &param) const
120 {
121  ParamMap::ConstIterator it = mParamMap.find(param);
122  if (it == mParamMap.end()) {
123  return QString();
124  } else {
125  if ((*it).isEmpty()) {
126  return QString();
127  } else {
128  return (*it).first();
129  }
130  }
131 }
132 
133 VCardLine::ParamMap VCardLine::parameterMap() const
134 {
135  return mParamMap;
136 }
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-2020 The KDE developers.
Generated on Sat Jul 11 2020 22:54:19 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.