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 << messageFormat();
50  s << remoteContent();
51 
52  return result;
53 }
54 
55 void MessageDisplayFormatAttribute::setMessageFormat(Viewer::DisplayFormatMessage format)
56 {
57  d->messageFormat = format;
58 }
59 
60 void MessageDisplayFormatAttribute::setRemoteContent(bool remote)
61 {
62  d->remoteContent = remote;
63 }
64 
65 bool MessageDisplayFormatAttribute::remoteContent() const
66 {
67  return d->remoteContent;
68 }
69 
70 bool MessageDisplayFormatAttribute::operator==(const MessageDisplayFormatAttribute &other) const
71 {
72  return (d->messageFormat == other.messageFormat()) && (d->remoteContent == other.remoteContent());
73 }
74 
75 Viewer::DisplayFormatMessage MessageDisplayFormatAttribute::messageFormat() const
76 {
77  return d->messageFormat;
78 }
79 
80 void MessageDisplayFormatAttribute::deserialize(const QByteArray &data)
81 {
82  QDataStream s(data);
83  int value = 0;
84  s >> value;
85  d->messageFormat = static_cast<Viewer::DisplayFormatMessage>(value);
86  s >> d->remoteContent;
87 }
The MessageDisplayFormatAttribute class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Mar 26 2023 04:08:11 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.