Akonadi

indexpolicyattribute.cpp
1 /*
2  SPDX-FileCopyrightText: 2010 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "indexpolicyattribute.h"
8 
9 #include "private/imapparser_p.h"
10 
11 using namespace Akonadi;
12 
13 class Akonadi::IndexPolicyAttributePrivate
14 {
15 public:
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 }
void append(const T &value)
virtual QByteArray type() const =0
Returns the type of the attribute.
IndexPolicyAttribute()
Creates a new index policy attribute.
~IndexPolicyAttribute() override
Destroys the index policy attribute.
Provides interface for custom attributes for Entity.
Definition: attribute.h:124
void reserve(int alloc)
virtual QByteArray serialized() const =0
Returns a QByteArray representation of the attribute which will be storaged.
int size() const const
bool indexingEnabled() const
Returns whether this collection is supposed to be indexed at all.
const T & at(int i) const const
void setIndexingEnabled(bool enable)
Sets whether this collection should be indexed at all.
virtual Attribute * clone() const =0
Creates a copy of this attribute.
virtual void deserialize(const QByteArray &data)=0
Sets the data of this attribute, using the same encoding as returned by toByteArray().
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jun 30 2022 03:51:46 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.