kmail
folderdiaquotatab_p.cpp00001
00032 #include "folderdiaquotatab_p.h"
00033
00034 #include <qlayout.h>
00035 #include <qlabel.h>
00036 #include <qprogressbar.h>
00037 #include <qwhatsthis.h>
00038 #include <qcombobox.h>
00039
00040 #include <math.h>
00041
00042 #include "kmkernel.h"
00043 #include "klocale.h"
00044 #include "kconfig.h"
00045 #include "kdebug.h"
00046 #include "kdialog.h"
00047 #include "globalsettings.h"
00048 #include "quotajobs.h"
00049
00050 using namespace KMail;
00051
00052 struct QuotaInfo;
00053
00054 QuotaWidget::QuotaWidget( QWidget* parent, const char* name )
00055 :QWidget( parent, name )
00056 {
00057 QVBoxLayout *box = new QVBoxLayout(this);
00058 QWidget *stuff = new QWidget( this );
00059 QGridLayout* layout =
00060 new QGridLayout( stuff, 3, 3,
00061 KDialog::marginHint(),
00062 KDialog::spacingHint() );
00063 mInfoLabel = new QLabel("", stuff );
00064 mRootLabel = new QLabel("", stuff );
00065 mProgressBar = new QProgressBar( stuff );
00066 layout->addWidget( new QLabel( i18n("Root:" ), stuff ), 0, 0 );
00067 layout->addWidget( mRootLabel, 0, 1 );
00068 layout->addWidget( new QLabel( i18n("Usage:"), stuff ), 1, 0 );
00069
00070 layout->addWidget( mInfoLabel, 1, 1 );
00071 layout->addWidget( mProgressBar, 2, 1 );
00072 box->addWidget( stuff );
00073 box->addStretch( 2 );
00074
00075 readConfig();
00076 }
00077
00078 void QuotaWidget::setQuotaInfo( const QuotaInfo& info )
00079 {
00080
00081
00082 int current = info.current().toInt();
00083 int max = info.max().toInt();
00084 int factor = static_cast<int> ( pow( 1000, mFactor ) );
00085 mProgressBar->setProgress( current, max );
00086 mInfoLabel->setText( i18n("%1 of %2 %3 used").arg( current/factor )
00087 .arg( max/factor ).arg( mUnits ) );
00088 mRootLabel->setText( info.root() );
00089 }
00090
00091 void QuotaWidget::readConfig()
00092 {
00093 if( GlobalSettings::self()->quotaUnit() == GlobalSettings::EnumQuotaUnit::KB )
00094 {
00095 mUnits = QString( i18n("KB") );
00096 mFactor = 0;
00097 }
00098 else if( GlobalSettings::self()->quotaUnit() == GlobalSettings::EnumQuotaUnit::MB )
00099 {
00100 mUnits = QString( i18n("MB") );
00101 mFactor = 1;
00102 }
00103 else if( GlobalSettings::self()->quotaUnit() == GlobalSettings::EnumQuotaUnit::GB )
00104 {
00105 mUnits = QString( i18n("GB") );
00106 mFactor = 2;
00107 }
00108 }
00109
00110
00111 #include "folderdiaquotatab_p.moc"
|