File indexing completed on 2024-05-12 16:25:44

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "messageattachmentfield.h"
0008 #include <QJsonObject>
0009 
0010 MessageAttachmentField::MessageAttachmentField() = default;
0011 
0012 MessageAttachmentField::~MessageAttachmentField() = default;
0013 
0014 bool MessageAttachmentField::operator==(const MessageAttachmentField &other) const
0015 {
0016     return mTitle == other.title() && mValue == other.value();
0017 }
0018 
0019 QString MessageAttachmentField::title() const
0020 {
0021     return mTitle;
0022 }
0023 
0024 void MessageAttachmentField::setTitle(const QString &title)
0025 {
0026     mTitle = title;
0027 }
0028 
0029 QString MessageAttachmentField::value() const
0030 {
0031     return mValue;
0032 }
0033 
0034 void MessageAttachmentField::setValue(const QString &value)
0035 {
0036     mValue = value;
0037 }
0038 
0039 QJsonObject MessageAttachmentField::serialize(const MessageAttachmentField &message)
0040 {
0041     QJsonObject obj;
0042     obj[QLatin1String("title")] = message.title();
0043     obj[QLatin1String("value")] = message.value();
0044     return obj;
0045 }
0046 
0047 MessageAttachmentField MessageAttachmentField::deserialize(const QJsonObject &o)
0048 {
0049     MessageAttachmentField att;
0050     att.setValue(o.value(QLatin1String("value")).toString());
0051     att.setTitle(o.value(QLatin1String("title")).toString());
0052     return att;
0053 }
0054 
0055 QDebug operator<<(QDebug d, const MessageAttachmentField &t)
0056 {
0057     d.space() << "title" << t.title();
0058     d.space() << "value" << t.value();
0059     return d;
0060 }