KContacts

lang.cpp
1/*
2 This file is part of the KContacts framework.
3 SPDX-FileCopyrightText: 2015-2019 Laurent Montel <montel@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "lang.h"
9#include "parametermap_p.h"
10
11#include <QDataStream>
12#include <QStringList>
13
14using namespace KContacts;
15
16class Q_DECL_HIDDEN Lang::Private : public QSharedData
17{
18public:
19 Private()
20 {
21 }
22
23 Private(const Private &other)
24 : QSharedData(other)
25 {
26 mParamMap = other.mParamMap;
27 language = other.language;
28 }
29
30 ParameterMap mParamMap;
31 QString language;
32};
33
34Lang::Lang()
35 : d(new Private)
36{
37}
38
39Lang::Lang(const Lang &other)
40 : d(other.d)
41{
42}
43
44Lang::Lang(const QString &language)
45 : d(new Private)
46{
47 d->language = language;
48}
49
50Lang::~Lang()
51{
52}
53
54void Lang::setLanguage(const QString &lang)
55{
56 d->language = lang;
57}
58
59QString Lang::language() const
60{
61 return d->language;
62}
63
64bool Lang::isValid() const
65{
66 return !d->language.isEmpty();
67}
68
69void Lang::setParams(const ParameterMap &params)
70{
71 d->mParamMap = params;
72}
73
74ParameterMap Lang::params() const
75{
76 return d->mParamMap;
77}
78
79bool Lang::operator==(const Lang &other) const
80{
81 return (d->mParamMap == other.d->mParamMap) && (d->language == other.language());
82}
83
84bool Lang::operator!=(const Lang &other) const
85{
86 return !(other == *this);
87}
88
89Lang &Lang::operator=(const Lang &other)
90{
91 if (this != &other) {
92 d = other.d;
93 }
94
95 return *this;
96}
97
98QString Lang::toString() const
99{
100 QString str = QLatin1String("Lang {\n");
101 str += QStringLiteral(" language: %1\n").arg(d->language);
102 str += d->mParamMap.toString();
103 str += QLatin1String("}\n");
104 return str;
105}
106
107QDataStream &KContacts::operator<<(QDataStream &s, const Lang &lang)
108{
109 return s << lang.d->mParamMap << lang.d->language;
110}
111
112QDataStream &KContacts::operator>>(QDataStream &s, Lang &lang)
113{
114 s >> lang.d->mParamMap >> lang.d->language;
115 return s;
116}
Class that holds a Language for a contact.
Definition lang.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.