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

akonadi

  • akonadi
attributeentity.h
1/*
2 Copyright (c) 2014 Christian Mollekopf <mollekopf@kolabsys.com>
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#ifndef AKONADI_ATTRIBUTEENTITY_H
21#define AKONADI_ATTRIBUTEENTITY_H
22
23#include <akonadi/job.h>
24#include <QVector>
25#include <qsharedpointer.h>
26#include "attribute.h"
27#include <kdebug.h>
28
29namespace Akonadi {
30
40class AKONADI_EXPORT AttributeEntity {
41public:
42 AttributeEntity();
43
44 AttributeEntity(const AttributeEntity &other);
45 virtual ~AttributeEntity();
46
47 //Each subclass must override this to avoid slicing
48 virtual AttributeEntity &operator=(const AttributeEntity &other);
49
60 void addAttribute(Attribute *attribute);
61
65 void removeAttribute(const QByteArray &name);
66
71 bool hasAttribute(const QByteArray &name) const;
72
76 Attribute::List attributes() const;
77
81 void clearAttributes();
82
86 Attribute *attribute(const QByteArray &name) const;
87
91 enum CreateOption {
92 AddIfMissing
93 };
94
102 template <typename T> inline T *attribute(CreateOption option)
103 {
104 Q_UNUSED(option);
105
106 const T dummy;
107 if (hasAttribute(dummy.type())) {
108 T *attr = dynamic_cast<T *>(attribute(dummy.type()));
109 if (attr) {
110 return attr;
111 }
112 kWarning(5250) << "Found attribute of unknown type" << dummy.type()
113 << ". Did you forget to call AttributeFactory::registerAttribute()?";
114 }
115
116 T *attr = new T();
117 addAttribute(attr);
118 return attr;
119 }
120
124 template <typename T> inline T *attribute() const
125 {
126 const T dummy;
127 if (hasAttribute(dummy.type())) {
128 T *attr = dynamic_cast<T *>(attribute(dummy.type()));
129 if (attr) {
130 return attr;
131 }
132 kWarning(5250) << "Found attribute of unknown type" << dummy.type()
133 << ". Did you forget to call AttributeFactory::registerAttribute()?";
134 }
135
136 return 0;
137 }
138
142 template <typename T> inline void removeAttribute()
143 {
144 const T dummy;
145 removeAttribute(dummy.type());
146 }
147
151 template <typename T> inline bool hasAttribute() const
152 {
153 const T dummy;
154 return hasAttribute(dummy.type());
155 }
156private:
157 friend class TagModifyJob;
158 QSet<QByteArray> &removedAttributes() const;
159
160 class Private;
161 QSharedPointer<Private> d_ptr;
162};
163
164}
165
166#endif
Akonadi::AttributeEntity
Parent class for entities that can have attributes.
Definition attributeentity.h:40
Akonadi::AttributeEntity::removeAttribute
void removeAttribute()
Removes and deletes the attribute of the requested type.
Definition attributeentity.h:142
Akonadi::AttributeEntity::attribute
T * attribute(CreateOption option)
Returns the attribute of the requested type.
Definition attributeentity.h:102
Akonadi::AttributeEntity::hasAttribute
bool hasAttribute() const
Returns whether the entity has an attribute of the requested type.
Definition attributeentity.h:151
Akonadi::AttributeEntity::attribute
T * attribute() const
Returns the attribute of the requested type or 0 if it is not available.
Definition attributeentity.h:124
Akonadi::AttributeEntity::CreateOption
CreateOption
Describes the options that can be passed to access attributes.
Definition attributeentity.h:91
Akonadi::Attribute
Provides interface for custom attributes for Entity.
Definition attribute.h:139
Akonadi::Attribute::List
QList< Attribute * > List
Describes a list of attributes.
Definition attribute.h:144
Akonadi::TagModifyJob
Job that modifies a tag in the Akonadi storage.
Definition tagmodifyjob.h:35
Akonadi
FreeBusyManager::Singleton.
Definition actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 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
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 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
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