File indexing completed on 2024-12-22 05:01:14

0001 /*
0002     SPDX-FileCopyrightText: 2010 Till Adam <adam@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "searchdescriptionattribute.h"
0008 
0009 #include <QDataStream>
0010 #include <QIODevice>
0011 
0012 using namespace Akonadi;
0013 
0014 SearchDescriptionAttribute::SearchDescriptionAttribute() = default;
0015 
0016 QByteArray SearchDescriptionAttribute::type() const
0017 {
0018     static const QByteArray sType("kmailsearchdescription");
0019     return sType;
0020 }
0021 
0022 Akonadi::Attribute *SearchDescriptionAttribute::clone() const
0023 {
0024     return new SearchDescriptionAttribute(*this);
0025 }
0026 
0027 QByteArray SearchDescriptionAttribute::serialized() const
0028 {
0029     QByteArray ba;
0030     QDataStream s(&ba, QIODevice::WriteOnly);
0031     s.setVersion(QDataStream::Qt_5_15);
0032     s << mBaseCollection.id();
0033     s << mRecursive;
0034     s << mDescription;
0035     s << mListCollection;
0036     return ba;
0037 }
0038 
0039 void SearchDescriptionAttribute::deserialize(const QByteArray &data)
0040 {
0041     QDataStream s(data);
0042     s.setVersion(QDataStream::Qt_5_15);
0043     Akonadi::Collection::Id id;
0044     s >> id;
0045     mBaseCollection = Akonadi::Collection(id);
0046     s >> mRecursive;
0047     s >> mDescription;
0048     s >> mListCollection;
0049 }
0050 
0051 QByteArray SearchDescriptionAttribute::description() const
0052 {
0053     return mDescription;
0054 }
0055 
0056 void SearchDescriptionAttribute::setDescription(const QByteArray &desc)
0057 {
0058     mDescription = desc;
0059 }
0060 
0061 Akonadi::Collection SearchDescriptionAttribute::baseCollection() const
0062 {
0063     return mBaseCollection;
0064 }
0065 
0066 void SearchDescriptionAttribute::setBaseCollection(const Akonadi::Collection &col)
0067 {
0068     mBaseCollection = col;
0069 }
0070 
0071 bool SearchDescriptionAttribute::recursive() const
0072 {
0073     return mRecursive;
0074 }
0075 
0076 void SearchDescriptionAttribute::setRecursive(bool r)
0077 {
0078     mRecursive = r;
0079 }
0080 
0081 void SearchDescriptionAttribute::setListCollection(const QList<Akonadi::Collection::Id> &col)
0082 {
0083     mListCollection = col;
0084 }
0085 
0086 QList<Akonadi::Collection::Id> SearchDescriptionAttribute::listCollection() const
0087 {
0088     return mListCollection;
0089 }