00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "collectionquotaattribute.h"
00021
00022 #include <QtCore/QByteArray>
00023
00024 using namespace Akonadi;
00025
00026 class CollectionQuotaAttribute::Private
00027 {
00028 public:
00029 Private( qint64 currentValue, qint64 maxValue )
00030 : mCurrentValue( currentValue ), mMaximumValue( maxValue )
00031 {
00032 }
00033
00034 qint64 mCurrentValue;
00035 qint64 mMaximumValue;
00036 };
00037
00038 CollectionQuotaAttribute::CollectionQuotaAttribute()
00039 : d( new Private( -1, -1 ) )
00040 {
00041 }
00042
00043 CollectionQuotaAttribute::CollectionQuotaAttribute( qint64 currentValue, qint64 maxValue )
00044 : d( new Private( currentValue, maxValue ) )
00045 {
00046 }
00047
00048 CollectionQuotaAttribute::~CollectionQuotaAttribute()
00049 {
00050 delete d;
00051 }
00052
00053 void CollectionQuotaAttribute::setCurrentValue( qint64 value )
00054 {
00055 d->mCurrentValue = value;
00056 }
00057
00058 void CollectionQuotaAttribute::setMaximumValue( qint64 value )
00059 {
00060 d->mMaximumValue = value;
00061 }
00062
00063 qint64 CollectionQuotaAttribute::currentValue() const
00064 {
00065 return d->mCurrentValue;
00066 }
00067
00068 qint64 CollectionQuotaAttribute::maximumValue() const
00069 {
00070 return d->mMaximumValue;
00071 }
00072
00073 QByteArray CollectionQuotaAttribute::type() const
00074 {
00075 return "collectionquota";
00076 }
00077
00078 Akonadi::Attribute* CollectionQuotaAttribute::clone() const
00079 {
00080 return new CollectionQuotaAttribute( d->mCurrentValue, d->mMaximumValue );
00081 }
00082
00083 QByteArray CollectionQuotaAttribute::serialized() const
00084 {
00085 return QByteArray::number( d->mCurrentValue )
00086 + ' '
00087 + QByteArray::number( d->mMaximumValue );
00088 }
00089
00090 void CollectionQuotaAttribute::deserialize( const QByteArray &data )
00091 {
00092 d->mCurrentValue = -1;
00093 d->mMaximumValue = -1;
00094
00095 const QList<QByteArray> items = data.simplified().split( ' ' );
00096
00097 if ( items.isEmpty() )
00098 return;
00099
00100 d->mCurrentValue = items[0].toLongLong();
00101
00102 if ( items.size() < 2 )
00103 return;
00104
00105 d->mMaximumValue = items[1].toLongLong();
00106 }