File indexing completed on 2024-05-12 05:11:11

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