Akonadi

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

KDE's Doxygen guidelines are available online.