Messagelib

messagedisplayformatattribute.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2023 Laurent Montel <[email protected]>
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 
13 using namespace MessageViewer;
14 
15 class MessageViewer::MessageDisplayFormatAttributePrivate
16 {
17 public:
18  MessageDisplayFormatAttributePrivate() = default;
19 
20  Viewer::DisplayFormatMessage messageFormat = Viewer::UseGlobalSetting;
21  bool remoteContent = false;
22 };
23 
24 MessageDisplayFormatAttribute::MessageDisplayFormatAttribute()
25  : d(new MessageDisplayFormatAttributePrivate)
26 {
27 }
28 
29 MessageDisplayFormatAttribute::~MessageDisplayFormatAttribute() = default;
30 
31 MessageDisplayFormatAttribute *MessageDisplayFormatAttribute::clone() const
32 {
33  auto messageDisplayFormatAttr = new MessageDisplayFormatAttribute();
34  messageDisplayFormatAttr->setMessageFormat(messageFormat());
35  messageDisplayFormatAttr->setRemoteContent(remoteContent());
36  return messageDisplayFormatAttr;
37 }
38 
39 QByteArray MessageDisplayFormatAttribute::type() const
40 {
41  static const QByteArray sType("MessageDisplayFormatAttribute");
42  return sType;
43 }
44 
45 QByteArray 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 
56 void MessageDisplayFormatAttribute::setMessageFormat(Viewer::DisplayFormatMessage format)
57 {
58  d->messageFormat = format;
59 }
60 
61 void MessageDisplayFormatAttribute::setRemoteContent(bool remote)
62 {
63  d->remoteContent = remote;
64 }
65 
66 bool MessageDisplayFormatAttribute::remoteContent() const
67 {
68  return d->remoteContent;
69 }
70 
71 bool MessageDisplayFormatAttribute::operator==(const MessageDisplayFormatAttribute &other) const
72 {
73  return (d->messageFormat == other.messageFormat()) && (d->remoteContent == other.remoteContent());
74 }
75 
76 Viewer::DisplayFormatMessage MessageDisplayFormatAttribute::messageFormat() const
77 {
78  return d->messageFormat;
79 }
80 
81 void 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 }
The MessageDisplayFormatAttribute class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Dec 5 2023 04:03:17 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.