Warning, file /frameworks/kcontacts/src/related.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 "related.h"
0009 #include "parametermap_p.h"
0010 
0011 #include <QDataStream>
0012 #include <QStringList>
0013 
0014 using namespace KContacts;
0015 
0016 class Q_DECL_HIDDEN Related::Private : public QSharedData
0017 {
0018 public:
0019     Private()
0020     {
0021     }
0022 
0023     Private(const Private &other)
0024         : QSharedData(other)
0025     {
0026         mParamMap = other.mParamMap;
0027         relatedTo = other.relatedTo;
0028     }
0029 
0030     ParameterMap mParamMap;
0031     QString relatedTo;
0032 };
0033 
0034 Related::Related()
0035     : d(new Private)
0036 {
0037 }
0038 
0039 Related::Related(const Related &other)
0040     : d(other.d)
0041 {
0042 }
0043 
0044 Related::Related(const QString &relatedTo)
0045     : d(new Private)
0046 {
0047     d->relatedTo = relatedTo;
0048 }
0049 
0050 Related::~Related()
0051 {
0052 }
0053 
0054 void Related::setRelated(const QString &relatedTo)
0055 {
0056     d->relatedTo = relatedTo;
0057 }
0058 
0059 QString Related::related() const
0060 {
0061     return d->relatedTo;
0062 }
0063 
0064 bool Related::isValid() const
0065 {
0066     return !d->relatedTo.isEmpty();
0067 }
0068 
0069 #if KCONTACTS_BUILD_DEPRECATED_SINCE(5, 88)
0070 void Related::setParameters(const QMap<QString, QStringList> &params)
0071 {
0072     d->mParamMap = ParameterMap::fromQMap(params);
0073 }
0074 #endif
0075 
0076 #if KCONTACTS_BUILD_DEPRECATED_SINCE(5, 88)
0077 QMap<QString, QStringList> Related::parameters() const
0078 {
0079     return d->mParamMap.toQMap();
0080 }
0081 #endif
0082 
0083 void Related::setParams(const ParameterMap &params)
0084 {
0085     d->mParamMap = params;
0086 }
0087 
0088 ParameterMap Related::params() const
0089 {
0090     return d->mParamMap;
0091 }
0092 
0093 bool Related::operator==(const Related &other) const
0094 {
0095     return (d->mParamMap == other.d->mParamMap) && (d->relatedTo == other.related());
0096 }
0097 
0098 bool Related::operator!=(const Related &other) const
0099 {
0100     return !(other == *this);
0101 }
0102 
0103 Related &Related::operator=(const Related &other)
0104 {
0105     if (this != &other) {
0106         d = other.d;
0107     }
0108 
0109     return *this;
0110 }
0111 
0112 QString Related::toString() const
0113 {
0114     QString str = QLatin1String("Related {\n");
0115     str += QStringLiteral("    relatedTo: %1\n").arg(d->relatedTo);
0116     str += d->mParamMap.toString();
0117     str += QLatin1String("}\n");
0118     return str;
0119 }
0120 
0121 QDataStream &KContacts::operator<<(QDataStream &s, const Related &related)
0122 {
0123     return s << related.d->mParamMap << related.d->relatedTo;
0124 }
0125 
0126 QDataStream &KContacts::operator>>(QDataStream &s, Related &related)
0127 {
0128     s >> related.d->mParamMap >> related.d->relatedTo;
0129     return s;
0130 }