File indexing completed on 2024-07-14 03:52:29

0001 /*
0002     This file is part of the KContacts framework.
0003     SPDX-FileCopyrightText: 2015-2019 Laurent Montel <montel@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #include "gender.h"
0009 #include "parametermap_p.h"
0010 
0011 using namespace KContacts;
0012 
0013 class Q_DECL_HIDDEN Gender::Private : public QSharedData
0014 {
0015 public:
0016     Private()
0017     {
0018     }
0019 
0020     Private(const Private &other)
0021         : QSharedData(other)
0022     {
0023         comment = other.comment;
0024         gender = other.gender;
0025     }
0026 
0027     QString gender;
0028     QString comment;
0029 };
0030 
0031 Gender::Gender()
0032     : d(new Private)
0033 {
0034 }
0035 
0036 Gender::Gender(const QString &gender)
0037     : d(new Private)
0038 {
0039     d->gender = gender;
0040 }
0041 
0042 Gender::Gender(const Gender &other)
0043     : d(other.d)
0044 {
0045 }
0046 
0047 Gender::~Gender()
0048 {
0049 }
0050 
0051 bool Gender::operator==(const Gender &other) const
0052 {
0053     return (d->comment == other.comment()) && (d->gender == other.gender());
0054 }
0055 
0056 bool Gender::operator!=(const Gender &other) const
0057 {
0058     return !(other == *this);
0059 }
0060 
0061 Gender &Gender::operator=(const Gender &other)
0062 {
0063     if (this != &other) {
0064         d = other.d;
0065     }
0066 
0067     return *this;
0068 }
0069 
0070 QString Gender::toString() const
0071 {
0072     QString str = QLatin1String("Gender {\n");
0073     str += QStringLiteral("    gender: %1\n").arg(d->gender);
0074     str += QStringLiteral("    comment: %1\n").arg(d->comment);
0075     str += QLatin1String("}\n");
0076     return str;
0077 }
0078 
0079 void Gender::setGender(const QString &gender)
0080 {
0081     d->gender = gender;
0082 }
0083 
0084 QString Gender::gender() const
0085 {
0086     return d->gender;
0087 }
0088 
0089 void Gender::setComment(const QString &comment)
0090 {
0091     d->comment = comment;
0092 }
0093 
0094 QString Gender::comment() const
0095 {
0096     return d->comment;
0097 }
0098 
0099 bool Gender::isValid() const
0100 {
0101     return !d->gender.isEmpty() || !d->comment.isEmpty();
0102 }
0103 
0104 QDataStream &KContacts::operator<<(QDataStream &s, const Gender &gender)
0105 {
0106     return s << gender.d->comment << gender.d->gender;
0107 }
0108 
0109 QDataStream &KContacts::operator>>(QDataStream &s, Gender &gender)
0110 {
0111     s >> gender.d->comment >> gender.d->gender;
0112     return s;
0113 }