Akonadi

indexpolicyattribute.cpp
1 /*
2  Copyright (c) 2010 Volker Krause <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "indexpolicyattribute.h"
21 
22 #include "private/imapparser_p.h"
23 
24 
25 using namespace Akonadi;
26 
27 class Q_DECL_HIDDEN IndexPolicyAttribute::Private
28 {
29 public:
30  Private()
31  {
32  }
33  bool enable = true;
34 };
35 
37  : d(new Private)
38 {
39 }
40 
42 {
43  delete d;
44 }
45 
47 {
48  return d->enable;
49 }
50 
52 {
53  d->enable = enable;
54 }
55 
57 {
58  static const QByteArray sType("INDEXPOLICY");
59  return sType;
60 }
61 
63 {
66  return attr;
67 }
68 
70 {
72  l.reserve(2);
73  l.append("ENABLE");
74  l.append(d->enable ? "true" : "false");
75  return "(" + ImapParser::join(l, " ") + ')'; //krazy:exclude=doublequote_chars
76 }
77 
79 {
81  ImapParser::parseParenthesizedList(data, l);
82  for (int i = 0; i < l.size() - 1; i += 2) {
83  const QByteArray key = l.at(i);
84  if (key == "ENABLE") {
85  d->enable = l.at(i + 1) == "true";
86  }
87  }
88 }
void reserve(int alloc)
const T & at(int i) const const
virtual void deserialize(const QByteArray &data)=0
Sets the data of this attribute, using the same encoding as returned by toByteArray().
An attribute to specify how a collection should be indexed for searching.
Provides interface for custom attributes for Entity.
Definition: attribute.h:139
virtual QByteArray type() const =0
Returns the type of the attribute.
int size() const const
void append(const T &value)
~IndexPolicyAttribute() override
Destroys the index policy attribute.
virtual Attribute * clone() const =0
Creates a copy of this attribute.
Helper integration between Akonadi and Qt.
void setIndexingEnabled(bool enable)
Sets whether this collection should be indexed at all.
IndexPolicyAttribute()
Creates a new index policy attribute.
bool indexingEnabled() const
Returns whether this collection is supposed to be indexed at all.
virtual QByteArray serialized() const =0
Returns a QByteArray representation of the attribute which will be storaged.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jun 5 2020 23:08:55 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.