1/*
2 Copyright (C) 2009 Kevin Ottens <ervin@kde.org>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#ifndef AKONADI_COLLECTIONQUOTAATTRIBUTE_H
21#define AKONADI_COLLECTIONQUOTAATTRIBUTE_H
22
23#include <akonadi/attribute.h>
24
25namespace Akonadi {
26
27/**
28 * @short Attribute that provides quota information for a collection.
29 *
30 * This attribute class provides quota information (e.g. current fill value
31 * and maximum fill value) for an Akonadi collection.
32 *
33 * Example:
34 *
35 * @code
36 *
37 * using namespace Akonadi;
38 *
39 * const Collection collection = collectionFetchJob->collections().first();
40 * if ( collection.hasAttribute<CollectionQuotaAttribute>() ) {
41 * const CollectionQuotaAttribute *attribute = collection.attribute<CollectionQuotaAttribute>();
42 * qDebug() << "current value" << attribute->currentValue();
43 * }
44 *
45 * @endcode
46 *
47 * @author Kevin Ottens <ervin@kde.org>
48 * @since 4.4
49 */
50class AKONADI_EXPORT CollectionQuotaAttribute : public Akonadi::Attribute
51{
52public:
53 /**
54 * Creates a new collection quota attribute.
55 */
56 CollectionQuotaAttribute();
57
58 /**
59 * Creates a new collection quota attribute with initial values.
60 *
61 * @param currentValue The current quota value in bytes.
62 * @param maxValue The maximum quota value in bytes.
63 */
64 CollectionQuotaAttribute(qint64 currentValue, qint64 maxValue);
65
66 /**
67 * Destroys the collection quota attribute.
68 */
69 ~CollectionQuotaAttribute();
70
71 /**
72 * Sets the current quota @p value for the collection.
73 *
74 * @param value The current quota value in bytes.
75 */
76 void setCurrentValue(qint64 value);
77
78 /**
79 * Sets the maximum quota @p value for the collection.
80 *
81 * @param value The maximum quota value in bytes.
82 */
83 void setMaximumValue(qint64 value);
84
85 /**
86 * Returns the current quota value in bytes.
87 */
88 qint64 currentValue() const;
89
90 /**
91 * Returns the maximum quota value in bytes.
92 */
93 qint64 maximumValue() const;
94
95 virtual QByteArray type() const;
96 virtual Attribute *clone() const;
97 virtual QByteArray serialized() const;
98 virtual void deserialize(const QByteArray &data);
99
100private:
101 //@cond PRIVATE
102 class Private;
103 Private *const d;
104 //@endcond
105};
106
107}
108
109#endif
110