Akonadi

relation.h
1 /*
2  SPDX-FileCopyrightText: 2014 Christian Mollekopf <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "akonadicore_export.h"
10 
11 namespace Akonadi
12 {
13 class Relation;
14 
15 AKONADICORE_EXPORT unsigned int qHash(const Akonadi::Relation &);
16 }
17 
18 #include <QByteArray>
19 #include <QDebug>
20 #include <QSharedDataPointer>
21 
22 namespace Akonadi
23 {
24 class Item;
25 class RelationPrivate;
26 
27 /**
28  * An Akonadi Relation.
29  *
30  * A Relation object represents an relation between two Akonadi items.
31  *
32  * An example usecase could be a association of a note with an email. The note (that for instance contains personal notes for the email),
33  * can be stored independently but is easily retrieved by asking for relations the email.
34  *
35  * The relation type allows to distinguish various types of relations that could for instance be bidirectional or not.
36  *
37  * @since 4.15
38  */
39 class AKONADICORE_EXPORT Relation
40 {
41 public:
42  using List = QVector<Relation>;
43 
44  /**
45  * The GENERIC type represents a generic relation between two items.
46  */
47  static const char *GENERIC;
48 
49  /**
50  * Creates an invalid relation.
51  */
52  Relation();
53 
54  /**
55  * Creates a relation
56  */
57  explicit Relation(const QByteArray &type, const Item &left, const Item &right);
58 
59  Relation(const Relation &);
60  Relation(Relation &&) noexcept;
61  ~Relation();
62 
63  Relation &operator=(const Relation &);
64  Relation &operator=(Relation &&) noexcept;
65 
66  bool operator==(const Relation &) const;
67  bool operator!=(const Relation &) const;
68 
69  /**
70  * Sets the @p item of the left side of the relation.
71  */
72  void setLeft(const Item &item);
73 
74  /**
75  * Returns the identifier of the left side of the relation.
76  */
77  Q_REQUIRED_RESULT Item left() const;
78 
79  /**
80  * Sets the @p item of the right side of the relation.
81  */
82  void setRight(const Akonadi::Item &item);
83 
84  /**
85  * Returns the identifier of the right side of the relation.
86  */
87  Q_REQUIRED_RESULT Item right() const;
88 
89  /**
90  * Sets the type of the relation.
91  */
92  void setType(const QByteArray &type);
93 
94  /**
95  * Returns the type of the relation.
96  */
97  Q_REQUIRED_RESULT QByteArray type() const;
98 
99  /**
100  * Sets the remote id of the relation.
101  */
102  void setRemoteId(const QByteArray &type);
103 
104  /**
105  * Returns the remote id of the relation.
106  */
107  Q_REQUIRED_RESULT QByteArray remoteId() const;
108 
109  Q_REQUIRED_RESULT bool isValid() const;
110 
111 private:
112  QSharedDataPointer<RelationPrivate> d;
113 };
114 
115 }
116 
117 AKONADICORE_EXPORT QDebug &operator<<(QDebug &debug, const Akonadi::Relation &tag);
118 
119 Q_DECLARE_METATYPE(Akonadi::Relation)
120 Q_DECLARE_METATYPE(Akonadi::Relation::List)
121 Q_DECLARE_METATYPE(QSet<Akonadi::Relation>)
122 Q_DECLARE_TYPEINFO(Akonadi::Relation, Q_MOVABLE_TYPE);
An Akonadi Relation.
Definition: relation.h:39
KCALENDARCORE_EXPORT uint qHash(const KCalendarCore::Period &key)
static const char * GENERIC
The GENERIC type represents a generic relation between two items.
Definition: relation.h:47
Represents a PIM item stored in Akonadi storage.
Definition: item.h:104
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.