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 "title.h"
9#include "parametermap_p.h"
10
11#include <QDataStream>
12#include <QStringList>
13
14using namespace KContacts;
15
16class Q_DECL_HIDDEN Title::Private : public QSharedData
17{
18public:
19 Private()
20 {
21 }
22
23 Private(const Private &other)
24 : QSharedData(other)
25 {
26 mParamMap = other.mParamMap;
27 title = other.title;
28 }
29
30 ParameterMap mParamMap;
31 QString title;
32};
33
34Title::Title()
35 : d(new Private)
36{
37}
38
39Title::Title(const Title &other)
40 : d(other.d)
41{
42}
43
44Title::Title(const QString &title)
45 : d(new Private)
46{
47 d->title = title;
48}
49
50Title::~Title() = default;
51
52void Title::setTitle(const QString &title)
53{
54 d->title = title;
55}
56
57QString Title::title() const
58{
59 return d->title;
60}
61
62bool Title::isValid() const
63{
64 return !d->title.isEmpty();
65}
66
67void Title::setParams(const ParameterMap &params)
68{
69 d->mParamMap = params;
70}
71
72ParameterMap Title::params() const
73{
74 return d->mParamMap;
75}
76
77bool Title::operator==(const Title &other) const
78{
79 return (d->mParamMap == other.d->mParamMap) && (d->title == other.title());
80}
81
82bool Title::operator!=(const Title &other) const
83{
84 return !(other == *this);
85}
86
87Title &Title::operator=(const Title &other)
88{
89 if (this != &other) {
90 d = other.d;
91 }
92
93 return *this;
94}
95
96QString Title::toString() const
97{
98 QString str = QLatin1String("Title {\n");
99 str += QStringLiteral(" title: %1\n").arg(a: d->title);
100 str += d->mParamMap.toString();
101 str += QLatin1String("}\n");
102 return str;
103}
104
105QDataStream &KContacts::operator<<(QDataStream &s, const Title &title)
106{
107 return s << title.d->mParamMap << title.d->title;
108}
109
110QDataStream &KContacts::operator>>(QDataStream &s, Title &title)
111{
112 s >> title.d->mParamMap >> title.d->title;
113 return s;
114}
115

source code of kcontacts/src/title.cpp