File indexing completed on 2024-10-06 12:17:03

0001 /*
0002     This file is part of the KContacts framework.
0003     SPDX-FileCopyrightText: 2016-2019 Laurent Montel <montel@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef NICKNAME_H
0009 #define NICKNAME_H
0010 
0011 #include "kcontacts_export.h"
0012 
0013 #include <QMap>
0014 #include <QSharedDataPointer>
0015 #include <QString>
0016 
0017 class NickNameTest;
0018 
0019 namespace KContacts
0020 {
0021 class ParameterMap;
0022 
0023 /** @short Class that holds a NickName for a contact.
0024  *  @since 5.3
0025  */
0026 class KCONTACTS_EXPORT NickName
0027 {
0028     friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const NickName &);
0029     friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, NickName &);
0030     friend class VCardTool;
0031     friend class ::NickNameTest;
0032 
0033 public:
0034     NickName();
0035     NickName(const NickName &other);
0036     NickName(const QString &nickname);
0037 
0038     ~NickName();
0039 
0040     typedef QVector<NickName> List;
0041 
0042     void setNickName(const QString &nickname);
0043     Q_REQUIRED_RESULT QString nickname() const;
0044 
0045     Q_REQUIRED_RESULT bool isValid() const;
0046 
0047 #if KCONTACTS_ENABLE_DEPRECATED_SINCE(5, 88)
0048     /**
0049      * @deprecated Since 5.88 for lack of usage
0050      */
0051     KCONTACTS_DEPRECATED_VERSION(5, 88, "For lack of usage.")
0052     void setParameters(const QMap<QString, QStringList> &params);
0053 #endif
0054 
0055 #if KCONTACTS_ENABLE_DEPRECATED_SINCE(5, 88)
0056     /**
0057      * @deprecated Since 5.88 for lack of usage
0058      */
0059     Q_REQUIRED_RESULT
0060     KCONTACTS_DEPRECATED_VERSION(5, 88, "For lack of usage.")
0061     QMap<QString, QStringList> parameters() const;
0062 #endif
0063 
0064     Q_REQUIRED_RESULT bool operator==(const NickName &other) const;
0065     Q_REQUIRED_RESULT bool operator!=(const NickName &other) const;
0066 
0067     NickName &operator=(const NickName &other);
0068 
0069     Q_REQUIRED_RESULT QString toString() const;
0070 
0071 private:
0072     // exported for NickNameTest
0073     void setParams(const ParameterMap &params);
0074     Q_REQUIRED_RESULT ParameterMap params() const;
0075 
0076     class Private;
0077     QSharedDataPointer<Private> d;
0078 };
0079 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const NickName &object);
0080 
0081 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, NickName &object);
0082 }
0083 Q_DECLARE_TYPEINFO(KContacts::NickName, Q_MOVABLE_TYPE);
0084 #endif // NICKNAME_H