1 /* 2 * SPDX-FileCopyrightText: 2009 Volker Krause <vkrause@kde.org> 3 * SPDX-FileCopyrightText: 2015 Daniel Vrátil <dvratil@redhat.com> 4 * 5 * SPDX-License-Identifier: LGPL-2.0-or-later 6 */ 7 8 // krazy:excludeall=dpointer 9 10 #pragma once 11 12 #include "akonadiprivate_export.h" 13 14 #include <QSharedDataPointer> 15 16 #include <QString> 17 class QJsonObject; 18 #include <QStringList> 19 20 namespace Akonadi 21 { 22 class ImapSet; 23 class ImapInterval; 24 25 namespace Protocol 26 { 27 class DataStream; 28 } 29 30 class ScopePrivate; 31 class AKONADIPRIVATE_EXPORT Scope 32 { 33 public: 34 enum SelectionScope : uchar { 35 Invalid = 0, 36 Uid = 1 << 0, 37 Rid = 1 << 1, 38 HierarchicalRid = 1 << 2, 39 Gid = 1 << 3, 40 }; 41 42 class AKONADIPRIVATE_EXPORT HRID 43 { 44 public: 45 HRID(); 46 explicit HRID(qint64 id, const QString &remoteId = QString()); 47 HRID(const HRID &other); 48 HRID(HRID &&other) noexcept; 49 50 HRID &operator=(const HRID &other); 51 HRID &operator=(HRID &&other) noexcept; 52 53 ~HRID() = default; 54 55 bool isEmpty() const; 56 bool operator==(const HRID &other) const; 57 58 void toJson(QJsonObject &json) const; 59 60 qint64 id; 61 QString remoteId; 62 }; 63 64 explicit Scope(); 65 Scope(SelectionScope scope, const QStringList &ids); 66 67 /* UID */ 68 Scope(qint64 id); // krazy:exclude=explicit 69 Scope(const ImapSet &uidSet); // krazy:exclude=explicit 70 Scope(const ImapInterval &interval); // krazy:exclude=explicit 71 Scope(const QVector<qint64> &interval); // krazy:exclude=explicit 72 Scope(const QVector<HRID> &hridChain); // krazy:exclude=explicit 73 74 Scope(const Scope &other); 75 Scope(Scope &&other) noexcept; 76 ~Scope(); 77 78 Scope &operator=(const Scope &other); 79 Scope &operator=(Scope &&other) noexcept; 80 81 bool operator==(const Scope &other) const; 82 bool operator!=(const Scope &other) const; 83 84 SelectionScope scope() const; 85 86 bool isEmpty() const; 87 88 ImapSet uidSet() const; 89 void setUidSet(const ImapSet &uidSet); 90 91 void setRidSet(const QStringList &ridSet); 92 QStringList ridSet() const; 93 94 void setHRidChain(const QVector<HRID> &ridChain); 95 QVector<HRID> hridChain() const; 96 97 void setGidSet(const QStringList &gidChain); 98 QStringList gidSet() const; 99 100 qint64 uid() const; 101 QString rid() const; 102 QString gid() const; 103 104 void toJson(QJsonObject &json) const; 105 106 private: 107 QSharedDataPointer<ScopePrivate> d; 108 friend class ScopePrivate; 109 110 friend Protocol::DataStream &operator<<(Protocol::DataStream &stream, const Akonadi::Scope &scope); 111 friend Protocol::DataStream &operator>>(Protocol::DataStream &stream, Akonadi::Scope &scope); 112 }; 113 114 } // namespace Akonadi 115 116 Q_DECLARE_TYPEINFO(Akonadi::Scope::HRID, Q_MOVABLE_TYPE); 117 118 AKONADIPRIVATE_EXPORT QDebug operator<<(QDebug debug, const Akonadi::Scope &scope); 119 120