File indexing completed on 2024-06-23 05:06:46
0001 /* 0002 SPDX-FileCopyrightText: 2019 David Faure <faure@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "akonaditests_export.h" 0010 #include "attribute.h" 0011 #include <QExplicitlySharedDataPointer> 0012 #include <QHash> 0013 #include <QSet> 0014 #include <set> 0015 #include <vector> 0016 0017 namespace Akonadi 0018 { 0019 /** 0020 * The AttributeStorage class is used by Collection, Item, Tag... 0021 * to store a set of attributes, remembering modifications. 0022 * I.e. it knows which attributes have been added or removed 0023 * compared to the initial set (e.g. fetched from server). 0024 */ 0025 class AttributeStoragePrivate; 0026 class AKONADI_TESTS_EXPORT AttributeStorage 0027 { 0028 public: 0029 AttributeStorage(); 0030 AttributeStorage(const AttributeStorage &other); 0031 AttributeStorage(AttributeStorage &&other) noexcept; 0032 AttributeStorage &operator=(const AttributeStorage &other); 0033 AttributeStorage &operator=(AttributeStorage &&other) noexcept; 0034 0035 ~AttributeStorage(); 0036 0037 void addAttribute(Attribute *attr); 0038 void removeAttribute(const QByteArray &type); 0039 bool hasAttribute(const QByteArray &type) const; 0040 [[nodiscard]] Attribute::List attributes() const; 0041 void clearAttributes(); 0042 const Attribute *attribute(const QByteArray &type) const; 0043 Attribute *attribute(const QByteArray &type); 0044 void markAttributeModified(const QByteArray &type); 0045 void resetChangeLog(); 0046 0047 QSet<QByteArray> deletedAttributes() const; 0048 [[nodiscard]] bool hasModifiedAttributes() const; 0049 std::vector<Attribute *> modifiedAttributes() const; 0050 0051 private: 0052 QExplicitlySharedDataPointer<AttributeStoragePrivate> d; 0053 }; 0054 0055 } // namespace Akonadi