KContacts

title.cpp
1 /*
2  This file is part of the KContacts framework.
3  SPDX-FileCopyrightText: 2016-2019 Laurent Montel <[email protected]>
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 
14 using namespace KContacts;
15 
16 class Q_DECL_HIDDEN Title::Private : public QSharedData
17 {
18 public:
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 
34 Title::Title()
35  : d(new Private)
36 {
37 }
38 
39 Title::Title(const Title &other)
40  : d(other.d)
41 {
42 }
43 
44 Title::Title(const QString &title)
45  : d(new Private)
46 {
47  d->title = title;
48 }
49 
50 Title::~Title()
51 {
52 }
53 
54 void Title::setTitle(const QString &title)
55 {
56  d->title = title;
57 }
58 
59 QString Title::title() const
60 {
61  return d->title;
62 }
63 
64 bool Title::isValid() const
65 {
66  return !d->title.isEmpty();
67 }
68 
69 #if KCONTACTS_BUILD_DEPRECATED_SINCE(5, 88)
71 {
72  d->mParamMap = ParameterMap::fromQMap(params);
73 }
74 #endif
75 
76 #if KCONTACTS_BUILD_DEPRECATED_SINCE(5, 88)
78 {
79  return d->mParamMap.toQMap();
80 }
81 #endif
82 
83 void Title::setParams(const ParameterMap &params)
84 {
85  d->mParamMap = params;
86 }
87 
88 ParameterMap Title::params() const
89 {
90  return d->mParamMap;
91 }
92 
93 bool Title::operator==(const Title &other) const
94 {
95  return (d->mParamMap == other.d->mParamMap) && (d->title == other.title());
96 }
97 
98 bool Title::operator!=(const Title &other) const
99 {
100  return !(other == *this);
101 }
102 
103 Title &Title::operator=(const Title &other)
104 {
105  if (this != &other) {
106  d = other.d;
107  }
108 
109  return *this;
110 }
111 
112 QString Title::toString() const
113 {
114  QString str = QLatin1String("Title {\n");
115  str += QStringLiteral(" title: %1\n").arg(d->title);
116  str += d->mParamMap.toString();
117  str += QLatin1String("}\n");
118  return str;
119 }
120 
121 QDataStream &KContacts::operator<<(QDataStream &s, const Title &title)
122 {
123  return s << title.d->mParamMap << title.d->title;
124 }
125 
126 QDataStream &KContacts::operator>>(QDataStream &s, Title &title)
127 {
128  s >> title.d->mParamMap >> title.d->title;
129  return s;
130 }
Class that holds a Title for a contact.
Definition: title.h:26
QMap< QString, QStringList > parameters() const
Definition: title.cpp:77
void setParameters(const QMap< QString, QStringList > &params)
Definition: title.cpp:70
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue Sep 27 2022 04:19:29 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.