KContacts

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

KDE's Doxygen guidelines are available online.