39#include <tqvaluevector.h>
43#include "globalsettings.h"
52 QuotaInfo( const TQString& _name, const TQString& _root, const TQVariant& _current, const TQVariant& _max )
53 : mName( _name ), mRoot( _root ), mCurrent( _current ),mMax( _max ) {}
54 bool operator==( const QuotaInfo & other ) const {
55 return mName == other.mName && mRoot == other.mRoot && mMax == other.mMax && mCurrent == other.mCurrent;
57 bool operator!=( const QuotaInfo & other ) const {
58 return !(operator==(other) );
60 bool isValid() const { return !mName.isEmpty(); }
61 bool isEmpty() const { return mName.isEmpty() || ( mRoot.isEmpty() && !mCurrent.isValid() && !mMax.isValid() ); }
63 TQString name() const { return mName; }
64 void setName( const TQString& n ) { mName = n; }
65 TQString root() const { return mRoot; }
66 void setRoot( const TQString& r ) { mRoot = r; }
67 TQVariant max() const { return mMax; }
68 void setMax( const TQVariant& m ) { mMax = m; }
69 TQVariant current() const { return mCurrent; }
70 void setCurrent( const TQVariant& c ) { mCurrent = c; }
72 TQString toString() const {
73 if ( isValid() && !isEmpty() ) {
75 int factor = static_cast<int> ( pow( 1000, mFactor ) );
76 return i18n( "%1 of %2 %3 used").arg( mCurrent.toInt() / factor )
77 .arg( mMax.toInt() / factor ).arg( mUnits );
83 void readConfig() const {
84 if( GlobalSettings::self()->quotaUnit() == GlobalSettings::EnumQuotaUnit::KB )
89 else if( GlobalSettings::self()->quotaUnit() == GlobalSettings::EnumQuotaUnit::MB )
94 else if( GlobalSettings::self()->quotaUnit() == GlobalSettings::EnumQuotaUnit::GB )
105 mutable TQString mUnits;
109typedef TQValueVector<QuotaInfo> QuotaInfoList;
120class GetQuotarootJob;
126GetQuotarootJob* getQuotaroot( TDEIO::Slave* slave, const KURL& url );
128class GetStorageQuotaJob;
134GetStorageQuotaJob* getStorageQuota( TDEIO::Slave* slave, const KURL& url );
137class GetQuotarootJob : public TDEIO::SimpleJob
142 GetQuotarootJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo );
149 void quotaRootResult( const TQStringList& roots );
157 void quotaInfoReceived( const QuotaInfoList& info );
160 void slotInfoMessage( TDEIO::Job*, const TQString& );
164class GetStorageQuotaJob : public TDEIO::Job
169 GetStorageQuotaJob( TDEIO::Slave* slave, const KURL& url );
172 QuotaInfo storageQuotaInfo() const;
180 void storageQuotaResult( const QuotaInfo& info );
184 void slotQuotarootResult( const TQStringList& roots );
185 void slotQuotaInfoReceived( const QuotaInfoList& roots );
187 QuotaInfo mStorageQuotaInfo;
|