Akonadi

collectionquotaattribute.cpp
1 /*
2  SPDX-FileCopyrightText: 2009 Kevin Ottens <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "collectionquotaattribute.h"
8 
9 #include <QByteArray>
10 
11 using namespace Akonadi;
12 
13 class Akonadi::CollectionQuotaAttributePrivate
14 {
15 public:
16  qint64 mCurrentValue = -1;
17  qint64 mMaximumValue = -1;
18 };
19 
21  : d(new CollectionQuotaAttributePrivate())
22 {
23 }
24 
25 CollectionQuotaAttribute::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 }
Attribute * clone() const override
Creates a copy of this attribute.
~CollectionQuotaAttribute() override
Destroys the collection quota attribute.
QByteArray serialized() const override
Returns a QByteArray representation of the attribute which will be storaged.
QByteArray number(int n, int base)
QList< QByteArray > split(char sep) const const
Provides interface for custom attributes for Entity.
Definition: attribute.h:124
void setCurrentValue(qint64 value)
Sets the current quota value for the collection.
QByteArray simplified() const const
qint64 currentValue() const
Returns the current quota value in bytes.
void setMaximumValue(qint64 value)
Sets the maximum quota value for the collection.
int size() const const
QByteArray type() const override
Returns the type of the attribute.
bool isEmpty() const const
CollectionQuotaAttribute()
Creates a new collection quota attribute.
void deserialize(const QByteArray &data) override
Sets the data of this attribute, using the same encoding as returned by toByteArray().
qint64 maximumValue() const
Returns the maximum quota value in bytes.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jun 25 2022 06:00:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.