Akonadi

collectionquotaattribute.h
1/*
2 SPDX-FileCopyrightText: 2009 Kevin Ottens <ervin@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadicore_export.h"
10#include "attribute.h"
11
12#include <memory>
13
14namespace Akonadi
15{
16class CollectionQuotaAttributePrivate;
17
18/**
19 * @short Attribute that provides quota information for a collection.
20 *
21 * This attribute class provides quota information (e.g. current fill value
22 * and maximum fill value) for an Akonadi collection.
23 *
24 * Example:
25 *
26 * @code
27 *
28 * using namespace Akonadi;
29 *
30 * const Collection collection = collectionFetchJob->collections().at(0);
31 * if ( collection.hasAttribute<CollectionQuotaAttribute>() ) {
32 * const CollectionQuotaAttribute *attribute = collection.attribute<CollectionQuotaAttribute>();
33 * qDebug() << "current value" << attribute->currentValue();
34 * }
35 *
36 * @endcode
37 *
38 * @author Kevin Ottens <ervin@kde.org>
39 * @since 4.4
40 */
41class AKONADICORE_EXPORT CollectionQuotaAttribute : public Akonadi::Attribute
42{
43public:
44 /**
45 * Creates a new collection quota attribute.
46 */
47 explicit CollectionQuotaAttribute();
48
49 /**
50 * Creates a new collection quota attribute with initial values.
51 *
52 * @param currentValue The current quota value in bytes.
53 * @param maxValue The maximum quota value in bytes.
54 */
55 CollectionQuotaAttribute(qint64 currentValue, qint64 maxValue);
56
57 /**
58 * Destroys the collection quota attribute.
59 */
61
62 /**
63 * Sets the current quota @p value for the collection.
64 *
65 * @param value The current quota value in bytes.
66 */
67 void setCurrentValue(qint64 value);
68
69 /**
70 * Sets the maximum quota @p value for the collection.
71 *
72 * @param value The maximum quota value in bytes.
73 */
74 void setMaximumValue(qint64 value);
75
76 /**
77 * Returns the current quota value in bytes.
78 */
79 [[nodiscard]] qint64 currentValue() const;
80
81 /**
82 * Returns the maximum quota value in bytes.
83 */
84 [[nodiscard]] qint64 maximumValue() const;
85
86 QByteArray type() const override;
87 Attribute *clone() const override;
88 [[nodiscard]] QByteArray serialized() const override;
89 void deserialize(const QByteArray &data) override;
90
91private:
92 /// @cond PRIVATE
93 const std::unique_ptr<CollectionQuotaAttributePrivate> d;
94 /// @endcond
95};
96
97} // namespace Akonadi
Provides interface for custom attributes for Entity.
Definition attribute.h:132
Attribute that provides quota information for a collection.
~CollectionQuotaAttribute() override
Destroys the collection quota attribute.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:31:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.