Akonadi

indexpolicyattribute.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "indexpolicyattribute.h"
8
9#include "private/imapparser_p.h"
10
11using namespace Akonadi;
12
13class Akonadi::IndexPolicyAttributePrivate
14{
15public:
16 bool enable = true;
17};
18
20 : d(new IndexPolicyAttributePrivate())
21{
22}
23
25
27{
28 return d->enable;
29}
30
32{
33 d->enable = enable;
34}
35
37{
38 static const QByteArray sType("INDEXPOLICY");
39 return sType;
40}
41
43{
44 auto attr = new IndexPolicyAttribute;
45 attr->setIndexingEnabled(indexingEnabled());
46 return attr;
47}
48
50{
52 l.reserve(2);
53 l.append("ENABLE");
54 l.append(d->enable ? "true" : "false");
55 return "(" + ImapParser::join(l, " ") + ')'; // krazy:exclude=doublequote_chars
56}
57
59{
61 ImapParser::parseParenthesizedList(data, l);
62 for (int i = 0; i < l.size() - 1; i += 2) {
63 const QByteArray &key = l.at(i);
64 if (key == "ENABLE") {
65 d->enable = l.at(i + 1) == "true";
66 }
67 }
68}
Provides interface for custom attributes for Entity.
Definition attribute.h:132
virtual void deserialize(const QByteArray &data)=0
Sets the data of this attribute, using the same encoding as returned by toByteArray().
virtual QByteArray serialized() const =0
Returns a QByteArray representation of the attribute which will be storaged.
virtual Attribute * clone() const =0
Creates a copy of this attribute.
virtual QByteArray type() const =0
Returns the type of the attribute.
IndexPolicyAttribute()
Creates a new index policy attribute.
bool indexingEnabled() const
Returns whether this collection is supposed to be indexed at all.
~IndexPolicyAttribute() override
Destroys the index policy attribute.
void setIndexingEnabled(bool enable)
Sets whether this collection should be indexed at all.
Helper integration between Akonadi and Qt.
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
void reserve(qsizetype size)
qsizetype size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:44:21 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.