/*
Bacula® - The Network Backup Solution
- Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2007-2010 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
*/
/*
- * Version $Id$
*
* Helper functions for tree widget formatting
*
Freeze::Freeze(QWidget &q):
qw(&q)
{
- QApplication::setOverrideCursor(Qt::WaitCursor);
qw->setUpdatesEnabled(false);
}
{
if (qw) {
qw->setUpdatesEnabled(true);
- QApplication::restoreOverrideCursor();
qw->update();
}
}
ItemFormatterBase::BYTES_CONVERSION ItemFormatterBase::cnvFlag(BYTES_CONVERSION_IEC);
-QString ItemFormatterBase::convertBytesIEC(qint64 qfld)
+QString convertBytesIEC(qint64 qfld)
{
static const qint64 KB = Q_INT64_C(1024);
static const qint64 MB = (KB * KB);
return QString("%1 %2iB").arg(qfld / 1000.0, 0, 'f', 2).arg(suffix);
}
-QString ItemFormatterBase::convertBytesSI(qint64 qfld)
+QString convertBytesSI(qint64 qfld)
{
static const qint64 KB = Q_INT64_C(1000);
static const qint64 MB = (KB * KB);
{
}
+void ItemFormatterBase::setPercent(int index, float value)
+{
+ char buf[100];
+ bsnprintf(buf, sizeof(buf), "%.2f%%", value);
+ QString val = buf;
+ QString pix;
+ if (value < 8) {
+ pix = ":images/0p.png";
+ } else if (value < 24) {
+ pix = ":images/16p.png";
+ } else if (value < 40) {
+ pix = ":images/32p.png";
+ } else if (value < 56) {
+ pix = ":images/48p.png";
+ } else if (value < 72) {
+ pix = ":images/64p.png";
+ } else if (value < 88) {
+ pix = ":images/80p.png";
+ } else {
+ pix = ":images/96p.png";
+ }
+ setPixmap(index, QPixmap(pix), val);
+ //setSortValue(index, (int) value);
+ //setBackground(index, Qt::green);
+}
+
+/* By default, the setPixmap implementation with tooltip don't implement
+ * the tooltip stuff
+ */
+void ItemFormatterBase::setPixmap(int index, const QPixmap &pix,
+ const QString & /* tip */)
+{
+ setPixmap(index, pix);
+}
+
+void ItemFormatterBase::setInChanger(int index, const QString &InChanger)
+{
+ setPixmap(index, QPixmap(":images/inflag"+InChanger+".png"));
+ //setSortValue(index, InChanger.toInt() );
+}
+
void ItemFormatterBase::setTextFld(int index, const QString &fld, bool center)
{
setText(index, fld.trimmed());
char suffix = 's';
if (dfld) {
for (int pos = 0 ; sufs[pos] ; ++pos) {
- if (dfld % divs[pos] == 0) {
- dfld /= divs[pos];
- suffix = sufs[pos];
- break;
- }
+ if (dfld % divs[pos] == 0) {
+ dfld /= divs[pos];
+ suffix = sufs[pos];
+ break;
+ }
}
}
QString msg;
dfld = fld.trimmed().toLongLong();
msg = "";
for (int pos = 0 ; sufs[pos] ; ++pos) {
- if (dfld / divs[pos] != 0) {
- msg += QString(" %1%2").arg(dfld / divs[pos]).arg(sufs[pos]);
- dfld %= divs[pos];
- }
+ if (dfld / divs[pos] != 0) {
+ msg += QString(" %1%2").arg(dfld / divs[pos]).arg(sufs[pos]);
+ dfld %= divs[pos];
+ }
}
if (dfld)
- msg += QString(" %1s").arg(dfld);
+ msg += QString(" %1s").arg(dfld);
}
setNumericFld(index, msg, fld.trimmed().toLongLong());
{
}
+void TreeItemFormatter::setPixmap(int index, const QPixmap &pix)
+{
+ wdg->setIcon(index, QIcon(pix));
+}
+
/***********************************************
*
* Specialized table widget used for sorting
{
}
+void TableItemFormatter::setPixmap(int index, const QPixmap &pix)
+{
+// Centered, but not sortable !
+ QLabel *lbl = new QLabel();
+ lbl->setAlignment(Qt::AlignCenter);
+ lbl->setPixmap(pix);
+ parent->setCellWidget(row, index, lbl);
+}
+
+void TableItemFormatter::setPixmap(int index, const QPixmap &pix,
+ const QString &tips)
+{
+// Centered, but not sortable !
+ QLabel *lbl = new QLabel();
+ lbl->setAlignment(Qt::AlignCenter);
+ lbl->setPixmap(pix);
+ if (!tips.isEmpty()) {
+ lbl->setToolTip(tips);
+ }
+ parent->setCellWidget(row, index, lbl);
+
+// last = new BatSortingTableItem;
+// parent->setItem(row, index, last);
+// last->setIcon(pix);
+}
+
void TableItemFormatter::setText(int col, const QString &fld)
{
last = new BatSortingTableItem;
{
return parent->item(row, col);
}
-