Messagelib

messagedisplayformatattribute.cpp
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5
6*/
7
8#include "messagedisplayformatattribute.h"
9#include <QByteArray>
10#include <QDataStream>
11#include <QIODevice>
12
13using namespace MessageViewer;
14
15class MessageViewer::MessageDisplayFormatAttributePrivate
16{
17public:
18 MessageDisplayFormatAttributePrivate() = default;
19
20 Viewer::DisplayFormatMessage messageFormat = Viewer::UseGlobalSetting;
21 bool remoteContent = false;
22};
23
24MessageDisplayFormatAttribute::MessageDisplayFormatAttribute()
25 : d(new MessageDisplayFormatAttributePrivate)
26{
27}
28
29MessageDisplayFormatAttribute::~MessageDisplayFormatAttribute() = default;
30
31MessageDisplayFormatAttribute *MessageDisplayFormatAttribute::clone() const
32{
33 auto messageDisplayFormatAttr = new MessageDisplayFormatAttribute();
34 messageDisplayFormatAttr->setMessageFormat(messageFormat());
35 messageDisplayFormatAttr->setRemoteContent(remoteContent());
36 return messageDisplayFormatAttr;
37}
38
39QByteArray MessageDisplayFormatAttribute::type() const
40{
41 static const QByteArray sType("MessageDisplayFormatAttribute");
42 return sType;
43}
44
45QByteArray MessageDisplayFormatAttribute::serialized() const
46{
47 QByteArray result;
49 s.setVersion(QDataStream::Qt_5_15);
50 s << messageFormat();
51 s << remoteContent();
52
53 return result;
54}
55
56void MessageDisplayFormatAttribute::setMessageFormat(Viewer::DisplayFormatMessage format)
57{
58 d->messageFormat = format;
59}
60
61void MessageDisplayFormatAttribute::setRemoteContent(bool remote)
62{
63 d->remoteContent = remote;
64}
65
66bool MessageDisplayFormatAttribute::remoteContent() const
67{
68 return d->remoteContent;
69}
70
71bool MessageDisplayFormatAttribute::operator==(const MessageDisplayFormatAttribute &other) const
72{
73 return (d->messageFormat == other.messageFormat()) && (d->remoteContent == other.remoteContent());
74}
75
76Viewer::DisplayFormatMessage MessageDisplayFormatAttribute::messageFormat() const
77{
78 return d->messageFormat;
79}
80
81void MessageDisplayFormatAttribute::deserialize(const QByteArray &data)
82{
83 QDataStream s(data);
84 s.setVersion(QDataStream::Qt_5_15);
85 int value = 0;
86 s >> value;
87 d->messageFormat = static_cast<Viewer::DisplayFormatMessage>(value);
88 s >> d->remoteContent;
89}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:55:44 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.