Akonadi

collectionquotaattribute.cpp
1/*
2 SPDX-FileCopyrightText: 2009 Kevin Ottens <ervin@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "collectionquotaattribute.h"
8
9#include <QByteArray>
10
11using namespace Akonadi;
12
13class Akonadi::CollectionQuotaAttributePrivate
14{
15public:
16 qint64 mCurrentValue = -1;
17 qint64 mMaximumValue = -1;
18};
19
21 : d(new CollectionQuotaAttributePrivate())
22{
23}
24
25CollectionQuotaAttribute::CollectionQuotaAttribute(qint64 currentValue, qint64 maxValue)
26 : d(new CollectionQuotaAttributePrivate())
27{
28 d->mCurrentValue = currentValue;
29 d->mMaximumValue = maxValue;
30}
31
33
35{
36 d->mCurrentValue = value;
37}
38
40{
41 d->mMaximumValue = value;
42}
43
45{
46 return d->mCurrentValue;
47}
48
50{
51 return d->mMaximumValue;
52}
53
55{
56 return QByteArrayLiteral("collectionquota");
57}
58
60{
61 return new CollectionQuotaAttribute(d->mCurrentValue, d->mMaximumValue);
62}
63
65{
66 return QByteArray::number(d->mCurrentValue) + ' ' + QByteArray::number(d->mMaximumValue);
67}
68
70{
71 d->mCurrentValue = -1;
72 d->mMaximumValue = -1;
73
74 const QList<QByteArray> items = data.simplified().split(' ');
75
76 if (items.isEmpty()) {
77 return;
78 }
79
80 d->mCurrentValue = items[0].toLongLong();
81
82 if (items.size() < 2) {
83 return;
84 }
85
86 d->mMaximumValue = items[1].toLongLong();
87}
Provides interface for custom attributes for Entity.
Definition attribute.h:132
void setMaximumValue(qint64 value)
Sets the maximum quota value for the collection.
CollectionQuotaAttribute()
Creates a new collection quota attribute.
QByteArray type() const override
Returns the type of the attribute.
Attribute * clone() const override
Creates a copy of this attribute.
QByteArray serialized() const override
Returns a QByteArray representation of the attribute which will be storaged.
~CollectionQuotaAttribute() override
Destroys the collection quota attribute.
qint64 currentValue() const
Returns the current quota value in bytes.
void setCurrentValue(qint64 value)
Sets the current quota value for the collection.
qint64 maximumValue() const
Returns the maximum quota value in bytes.
void deserialize(const QByteArray &data) override
Sets the data of this attribute, using the same encoding as returned by toByteArray().
Helper integration between Akonadi and Qt.
QByteArray number(double n, char format, int precision)
QByteArray simplified() const const
QList< QByteArray > split(char sep) const const
bool isEmpty() const const
qsizetype size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.