KContacts

gender.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 "gender.h"
9#include "parametermap_p.h"
10
11using namespace KContacts;
12
13class Q_DECL_HIDDEN Gender::Private : public QSharedData
14{
15public:
16 Private()
17 {
18 }
19
20 Private(const Private &other)
21 : QSharedData(other)
22 {
23 comment = other.comment;
24 gender = other.gender;
25 }
26
27 QString gender;
28 QString comment;
29};
30
32 : d(new Private)
33{
34}
35
36Gender::Gender(const QString &gender)
37 : d(new Private)
38{
39 d->gender = gender;
40}
41
42Gender::Gender(const Gender &other)
43 : d(other.d)
44{
45}
46
47Gender::~Gender()
48{
49}
50
51bool Gender::operator==(const Gender &other) const
52{
53 return (d->comment == other.comment()) && (d->gender == other.gender());
54}
55
56bool Gender::operator!=(const Gender &other) const
57{
58 return !(other == *this);
59}
60
61Gender &Gender::operator=(const Gender &other)
62{
63 if (this != &other) {
64 d = other.d;
65 }
66
67 return *this;
68}
69
70QString Gender::toString() const
71{
72 QString str = QLatin1String("Gender {\n");
73 str += QStringLiteral(" gender: %1\n").arg(d->gender);
74 str += QStringLiteral(" comment: %1\n").arg(d->comment);
75 str += QLatin1String("}\n");
76 return str;
77}
78
79void Gender::setGender(const QString &gender)
80{
81 d->gender = gender;
82}
83
84QString Gender::gender() const
85{
86 return d->gender;
87}
88
89void Gender::setComment(const QString &comment)
90{
91 d->comment = comment;
92}
93
94QString Gender::comment() const
95{
96 return d->comment;
97}
98
99bool Gender::isValid() const
100{
101 return !d->gender.isEmpty() || !d->comment.isEmpty();
102}
103
104QDataStream &KContacts::operator<<(QDataStream &s, const Gender &gender)
105{
106 return s << gender.d->comment << gender.d->gender;
107}
108
109QDataStream &KContacts::operator>>(QDataStream &s, Gender &gender)
110{
111 s >> gender.d->comment >> gender.d->gender;
112 return s;
113}
Class that holds a Gender for a contact.
Definition gender.h:20
Gender()
Creates an empty Gender object.
Definition gender.cpp:31
QString arg(Args &&... args) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:08 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.