Messagelib

messagedisplayformatattribute.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 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 
12 using namespace MessageViewer;
13 
14 class MessageViewer::MessageDisplayFormatAttributePrivate
15 {
16 public:
17  MessageDisplayFormatAttributePrivate() = default;
18 
19  Viewer::DisplayFormatMessage messageFormat = Viewer::UseGlobalSetting;
20  bool remoteContent = false;
21 };
22 
23 MessageDisplayFormatAttribute::MessageDisplayFormatAttribute()
24  : d(new MessageDisplayFormatAttributePrivate)
25 {
26 }
27 
28 MessageDisplayFormatAttribute::~MessageDisplayFormatAttribute() = default;
29 
30 MessageDisplayFormatAttribute *MessageDisplayFormatAttribute::clone() const
31 {
32  auto messageDisplayFormatAttr = new MessageDisplayFormatAttribute();
33  messageDisplayFormatAttr->setMessageFormat(messageFormat());
34  messageDisplayFormatAttr->setRemoteContent(remoteContent());
35  return messageDisplayFormatAttr;
36 }
37 
38 QByteArray MessageDisplayFormatAttribute::type() const
39 {
40  static const QByteArray sType("MessageDisplayFormatAttribute");
41  return sType;
42 }
43 
44 QByteArray MessageDisplayFormatAttribute::serialized() const
45 {
46  QByteArray result;
48  s << messageFormat();
49  s << remoteContent();
50 
51  return result;
52 }
53 
54 void MessageDisplayFormatAttribute::setMessageFormat(Viewer::DisplayFormatMessage format)
55 {
56  d->messageFormat = format;
57 }
58 
59 void MessageDisplayFormatAttribute::setRemoteContent(bool remote)
60 {
61  d->remoteContent = remote;
62 }
63 
64 bool MessageDisplayFormatAttribute::remoteContent() const
65 {
66  return d->remoteContent;
67 }
68 
69 bool MessageDisplayFormatAttribute::operator==(const MessageDisplayFormatAttribute &other) const
70 {
71  return (d->messageFormat == other.messageFormat()) && (d->remoteContent == other.remoteContent());
72 }
73 
74 Viewer::DisplayFormatMessage MessageDisplayFormatAttribute::messageFormat() const
75 {
76  return d->messageFormat;
77 }
78 
79 void MessageDisplayFormatAttribute::deserialize(const QByteArray &data)
80 {
81  QDataStream s(data);
82  int value = 0;
83  s >> value;
84  d->messageFormat = static_cast<Viewer::DisplayFormatMessage>(value);
85  s >> d->remoteContent;
86 }
The MessageDisplayFormatAttribute class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Dec 4 2021 23:12:53 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.