File indexing completed on 2025-03-09 04:54:37
0001 /* 0002 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 0006 */ 0007 0008 #include "scamattribute.h" 0009 #include <QByteArray> 0010 #include <QDataStream> 0011 #include <QIODevice> 0012 0013 using namespace MessageViewer; 0014 0015 class MessageViewer::ScamAttributePrivate 0016 { 0017 public: 0018 ScamAttributePrivate() = default; 0019 0020 bool isAScam = false; 0021 }; 0022 0023 ScamAttribute::ScamAttribute() 0024 : d(new ScamAttributePrivate) 0025 { 0026 } 0027 0028 ScamAttribute::~ScamAttribute() = default; 0029 0030 ScamAttribute *ScamAttribute::clone() const 0031 { 0032 auto attr = new ScamAttribute(); 0033 attr->setIsAScam(isAScam()); 0034 return attr; 0035 } 0036 0037 QByteArray ScamAttribute::type() const 0038 { 0039 static const QByteArray sType("ScamAttribute"); 0040 return sType; 0041 } 0042 0043 QByteArray ScamAttribute::serialized() const 0044 { 0045 QByteArray result; 0046 QDataStream s(&result, QIODevice::WriteOnly); 0047 s.setVersion(QDataStream::Qt_5_15); 0048 s << isAScam(); 0049 return result; 0050 } 0051 0052 void ScamAttribute::deserialize(const QByteArray &data) 0053 { 0054 QDataStream s(data); 0055 s.setVersion(QDataStream::Qt_5_15); 0056 bool value = false; 0057 s >> value; 0058 d->isAScam = value; 0059 } 0060 0061 bool ScamAttribute::isAScam() const 0062 { 0063 return d->isAScam; 0064 } 0065 0066 void ScamAttribute::setIsAScam(bool b) 0067 { 0068 d->isAScam = b; 0069 } 0070 0071 bool ScamAttribute::operator==(const ScamAttribute &other) const 0072 { 0073 return d->isAScam == other.isAScam(); 0074 }