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

akonadi

  • akonadi
entity.h
1/*
2 Copyright (c) 2008 Tobias Koenig <tokoe@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#ifndef AKONADI_ENTITY_H
21#define AKONADI_ENTITY_H
22
23#include "akonadi_export.h"
24#include <QString>
25
26namespace Akonadi {
27class Entity;
28}
29
30AKONADI_EXPORT uint qHash(const Akonadi::Entity &);
31
32#include <akonadi/attribute.h>
33
34#include <KDE/KDebug>
35
36#include <QtCore/QHash>
37#include <QtCore/QSharedDataPointer>
38
39#define AKONADI_DECLARE_PRIVATE( Class ) \
40 Class##Private *d_func(); \
41 const Class##Private *d_func() const; \
42 friend class Class##Private;
43
44namespace Akonadi {
45
46class Collection;
47class EntityPrivate;
48
59class AKONADI_EXPORT Entity
60{
61public:
65 typedef qint64 Id;
66
70 void setId(Id identifier);
71
75 Id id() const;
76
80 void setRemoteId(const QString &id);
81
85 QString remoteId() const;
86
96 void setRemoteRevision(const QString &revision);
97
104 QString remoteRevision() const;
105
109 bool isValid() const;
110
115 bool operator==(const Entity &other) const;
116
121 bool operator!=(const Entity &other) const;
122
127 Entity &operator=(const Entity &other);
128
134 bool operator<(const Entity &other) const;
135
142 Collection parentCollection() const;
143
150 Collection &parentCollection();
151
161 void setParentCollection(const Collection &parent);
162
173 void addAttribute(Attribute *attribute);
174
178 void removeAttribute(const QByteArray &name);
179
184 bool hasAttribute(const QByteArray &name) const;
185
189 Attribute::List attributes() const;
190
194 void clearAttributes();
195
199 Attribute *attribute(const QByteArray &name) const;
200
204 enum CreateOption {
205 AddIfMissing
206 };
207
215 template <typename T> inline T *attribute(CreateOption option)
216 {
217 Q_UNUSED(option);
218
219 const T dummy;
220 if (hasAttribute(dummy.type())) {
221 T *attr = dynamic_cast<T *>(attribute(dummy.type()));
222 if (attr) {
223 return attr;
224 }
225 kWarning(5250) << "Found attribute of unknown type" << dummy.type()
226 << ". Did you forget to call AttributeFactory::registerAttribute()?";
227 }
228
229 T *attr = new T();
230 addAttribute(attr);
231 return attr;
232 }
233
237 template <typename T> inline T *attribute() const
238 {
239 const T dummy;
240 if (hasAttribute(dummy.type())) {
241 T *attr = dynamic_cast<T *>(attribute(dummy.type()));
242 if (attr) {
243 return attr;
244 }
245 kWarning(5250) << "Found attribute of unknown type" << dummy.type()
246 << ". Did you forget to call AttributeFactory::registerAttribute()?";
247 }
248
249 return 0;
250 }
251
255 template <typename T> inline void removeAttribute()
256 {
257 const T dummy;
258 removeAttribute(dummy.type());
259 }
260
264 template <typename T> inline bool hasAttribute() const
265 {
266 const T dummy;
267 return hasAttribute(dummy.type());
268 }
269
270protected:
274 Entity(const Entity &other);
275
279 ~Entity();
280
281 //@cond PRIVATE
282 Entity(EntityPrivate *dd);
283 QSharedDataPointer<EntityPrivate> d_ptr;
284 //@endcond
285
286 AKONADI_DECLARE_PRIVATE(Entity)
287};
288
289}
290
291#endif
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::Collection
Represents a collection of PIM items.
Definition: collection.h:76
Akonadi::EntityPrivate
Definition: entity_p.h:40
Akonadi::Entity
The base class for Item and Collection.
Definition: entity.h:60
Akonadi::Entity::CreateOption
CreateOption
Describes the options that can be passed to access attributes.
Definition: entity.h:204
Akonadi::Entity::attribute
T * attribute(CreateOption option)
Returns the attribute of the requested type.
Definition: entity.h:215
Akonadi::Entity::removeAttribute
void removeAttribute()
Removes and deletes the attribute of the requested type.
Definition: entity.h:255
Akonadi::Entity::attribute
T * attribute() const
Returns the attribute of the requested type or 0 if it is not available.
Definition: entity.h:237
Akonadi::Entity::hasAttribute
bool hasAttribute() const
Returns whether the entity has an attribute of the requested type.
Definition: entity.h:264
Akonadi::Entity::Id
qint64 Id
Describes the unique id type.
Definition: entity.h:65
Akonadi
FreeBusyManager::Singleton.
Definition: actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 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-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