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 
26 /**
27  * An Akonadi Relation.
28  *
29  * A Relation object represents an relation between two Akonadi items.
30  *
31  * An example usecase could be a association of a note with an email. The note (that for instance contains personal notes for the email),
32  * can be stored independently but is easily retrieved by asking for relations the email.
33  *
34  * The relation type allows to distinguish various types of relations that could for instance be bidirectional or not.
35  *
36  * @since 4.15
37  */
38 class AKONADICORE_EXPORT Relation
39 {
40 public:
41  using List = QVector<Relation>;
42 
43  /**
44  * The GENERIC type represents a generic relation between two items.
45  */
46  static const char *GENERIC;
47 
48  /**
49  * Creates an invalid relation.
50  */
51  Relation();
52 
53  /**
54  * Creates a relation
55  */
56  explicit Relation(const QByteArray &type, const Item &left, const Item &right);
57 
58  Relation(const Relation &);
59  Relation(Relation &&) noexcept;
60  ~Relation();
61 
62  Relation &operator=(const Relation &);
63  Relation &operator=(Relation &&) noexcept;
64 
65  bool operator==(const Relation &) const;
66  bool operator!=(const Relation &) const;
67 
68  /**
69  * Sets the @p item of the left side of the relation.
70  */
71  void setLeft(const Item &item);
72 
73  /**
74  * Returns the identifier of the left side of the relation.
75  */
76  Q_REQUIRED_RESULT Item left() const;
77 
78  /**
79  * Sets the @p item of the right side of the relation.
80  */
81  void setRight(const Akonadi::Item &item);
82 
83  /**
84  * Returns the identifier of the right side of the relation.
85  */
86  Q_REQUIRED_RESULT Item right() const;
87 
88  /**
89  * Sets the type of the relation.
90  */
91  void setType(const QByteArray &type);
92 
93  /**
94  * Returns the type of the relation.
95  */
96  Q_REQUIRED_RESULT QByteArray type() const;
97 
98  /**
99  * Sets the remote id of the relation.
100  */
101  void setRemoteId(const QByteArray &type);
102 
103  /**
104  * Returns the remote id of the relation.
105  */
106  Q_REQUIRED_RESULT QByteArray remoteId() const;
107 
108  Q_REQUIRED_RESULT bool isValid() const;
109 
110 private:
111  struct Private;
112  QSharedDataPointer<Private> 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:38
KCALENDARCORE_EXPORT uint qHash(const KCalendarCore::Period &key)
Helper integration between Akonadi and Qt.
static const char * GENERIC
The GENERIC type represents a generic relation between two items.
Definition: relation.h:46
Represents a PIM item stored in Akonadi storage.
Definition: item.h:100
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Jul 29 2021 23:17:48 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.