• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • sources
  • kde-4.14
  • kdepimlibs
  • akonadi
indexpolicyattribute.cpp
1 /*
2  Copyright (c) 2010 Volker Krause <vkrause@kde.org>
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 <akonadi/private/imapparser_p.h>
23 
24 #include <QtCore/QString>
25 
26 using namespace Akonadi;
27 
28 class IndexPolicyAttribute::Private
29 {
30 public:
31  Private()
32  : enable(true)
33  {
34  }
35  bool enable;
36 };
37 
38 IndexPolicyAttribute::IndexPolicyAttribute()
39  : d(new Private)
40 {
41 }
42 
43 IndexPolicyAttribute::~IndexPolicyAttribute()
44 {
45  delete d;
46 }
47 
48 bool IndexPolicyAttribute::indexingEnabled() const
49 {
50  return d->enable;
51 }
52 
53 void IndexPolicyAttribute::setIndexingEnabled(bool enable)
54 {
55  d->enable = enable;
56 }
57 
58 QByteArray IndexPolicyAttribute::type() const
59 {
60  static const QByteArray sType( "INDEXPOLICY" );
61  return sType;
62 }
63 
64 Attribute *IndexPolicyAttribute::clone() const
65 {
66  IndexPolicyAttribute *attr = new IndexPolicyAttribute;
67  attr->setIndexingEnabled(indexingEnabled());
68  return attr;
69 }
70 
71 QByteArray IndexPolicyAttribute::serialized() const
72 {
73  QList<QByteArray> l;
74  l.append("ENABLE");
75  l.append(d->enable ? "true" : "false");
76  return "(" + ImapParser::join(l, " ") + ')'; //krazy:exclude=doublequote_chars
77 }
78 
79 void IndexPolicyAttribute::deserialize(const QByteArray &data)
80 {
81  QList<QByteArray> l;
82  ImapParser::parseParenthesizedList(data, l);
83  for (int i = 0; i < l.size() - 1; i += 2) {
84  const QByteArray key = l.at(i);
85  if (key == "ENABLE") {
86  d->enable = l.at(i + 1) == "true";
87  }
88  }
89 }
Akonadi::IndexPolicyAttribute::~IndexPolicyAttribute
~IndexPolicyAttribute()
Destroys the index policy attribute.
Definition: indexpolicyattribute.cpp:43
QByteArray
QList::at
const T & at(int i) const
Akonadi::Attribute::deserialize
virtual void deserialize(const QByteArray &data)=0
Sets the data of this attribute, using the same encoding as returned by toByteArray().
Akonadi::IndexPolicyAttribute
An attribute to specify how a collection should be indexed for searching.
Definition: indexpolicyattribute.h:35
Akonadi::Attribute
Provides interface for custom attributes for Entity.
Definition: attribute.h:138
QList::size
int size() const
QList::append
void append(const T &value)
QList< QByteArray >
Akonadi::IndexPolicyAttribute::setIndexingEnabled
void setIndexingEnabled(bool enable)
Sets whether this collection should be indexed at all.
Definition: indexpolicyattribute.cpp:53
Akonadi::Attribute::serialized
virtual QByteArray serialized() const =0
Returns a QByteArray representation of the attribute which will be storaged.
Akonadi::IndexPolicyAttribute::IndexPolicyAttribute
IndexPolicyAttribute()
Creates a new index policy attribute.
Definition: indexpolicyattribute.cpp:38
Akonadi::IndexPolicyAttribute::indexingEnabled
bool indexingEnabled() const
Returns whether this collection is supposed to be indexed at all.
Definition: indexpolicyattribute.cpp:48
Akonadi::Attribute::clone
virtual Attribute * clone() const =0
Creates a copy of this attribute.
Akonadi::Attribute::type
virtual QByteArray type() const =0
Returns the type of the attribute.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal