KContacts

fieldgroup.cpp
1/*
2 This file is part of the KContacts framework.
3 SPDX-FileCopyrightText: 2016-2019 Laurent Montel <montel@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "fieldgroup.h"
9#include "parametermap_p.h"
10
11#include <QDataStream>
12#include <QStringList>
13
14using namespace KContacts;
15
16class Q_DECL_HIDDEN FieldGroup::Private : public QSharedData
17{
18public:
19 Private()
20 {
21 }
22
23 Private(const Private &other)
24 : QSharedData(other)
25 {
26 mParamMap = other.mParamMap;
27 fieldGroupName = other.fieldGroupName;
28 value = other.value;
29 }
30
31 ParameterMap mParamMap;
32 QString fieldGroupName;
33 QString value;
34};
35
36FieldGroup::FieldGroup()
37 : d(new Private)
38{
39}
40
41FieldGroup::FieldGroup(const FieldGroup &other)
42 : d(other.d)
43{
44}
45
46FieldGroup::FieldGroup(const QString &FieldGroupName)
47 : d(new Private)
48{
49 d->fieldGroupName = FieldGroupName;
50}
51
52FieldGroup::~FieldGroup()
53{
54}
55
56void FieldGroup::setFieldGroupName(const QString &fieldGroup)
57{
58 d->fieldGroupName = fieldGroup;
59}
60
61QString FieldGroup::fieldGroupName() const
62{
63 return d->fieldGroupName;
64}
65
66bool FieldGroup::isValid() const
67{
68 return !d->fieldGroupName.isEmpty();
69}
70
71void FieldGroup::setValue(const QString &value)
72{
73 d->value = value;
74}
75
76QString FieldGroup::value() const
77{
78 return d->value;
79}
80
81void FieldGroup::setParams(const ParameterMap &params)
82{
83 d->mParamMap = params;
84}
85
86ParameterMap FieldGroup::params() const
87{
88 return d->mParamMap;
89}
90
91bool FieldGroup::operator==(const FieldGroup &other) const
92{
93 return (d->mParamMap == other.d->mParamMap) && (d->fieldGroupName == other.fieldGroupName()) && (d->value == other.value());
94}
95
96bool FieldGroup::operator!=(const FieldGroup &other) const
97{
98 return !(other == *this);
99}
100
101FieldGroup &FieldGroup::operator=(const FieldGroup &other)
102{
103 if (this != &other) {
104 d = other.d;
105 }
106
107 return *this;
108}
109
110QString FieldGroup::toString() const
111{
112 QString str = QLatin1String("FieldGroup {\n");
113 str += QStringLiteral(" FieldGroupName: %1 Value %2\n").arg(d->fieldGroupName).arg(d->value);
114 str += d->mParamMap.toString();
115 str += QLatin1String("}\n");
116 return str;
117}
118
119QDataStream &KContacts::operator<<(QDataStream &s, const FieldGroup &fieldGroup)
120{
121 return s << fieldGroup.d->mParamMap << fieldGroup.d->fieldGroupName << fieldGroup.d->value;
122}
123
124QDataStream &KContacts::operator>>(QDataStream &s, FieldGroup &fieldGroup)
125{
126 s >> fieldGroup.d->mParamMap >> fieldGroup.d->fieldGroupName >> fieldGroup.d->value;
127 return s;
128}
Class that holds a FieldGroup for a contact.
Definition fieldgroup.h:27
QString arg(Args &&... args) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.