size for this mediatype.
<RCC>
<qresource prefix="/" >
+ <file>images/0p.png</file>
+ <file>images/16p.png</file>
+ <file>images/32p.png</file>
+ <file>images/48p.png</file>
+ <file>images/64p.png</file>
+ <file>images/80p.png</file>
+ <file>images/96p.png</file>
<file>images/A.png</file>
<file>images/R.png</file>
<file>images/T.png</file>
query =
"SELECT AVG(VolBytes) AS size, COUNT(1) as nb, "
- "MediaType, VolStatus FROM Media "
+ "MediaType FROM Media "
"WHERE VolStatus IN ('Full', 'Used') "
- "GROUP BY MediaType, VolStatus";
+ "GROUP BY MediaType";
if (m_console->sql_cmd(query, results)) {
foreach (resultline, results) {
fieldlist = resultline.split("\t");
- if (fieldlist.at(1).toInt() > 2) {
- // MediaType + VolStatus (Used or Full)
- hash_size[fieldlist.at(2) + fieldlist.at(3)]
+ if (fieldlist.at(1).toInt() >= 1) {
+ // MediaType
+ hash_size[fieldlist.at(2)]
= fieldlist.at(0).toFloat();
}
}
/* Usage */
usage = 0;
- if (hash_size.contains(MediaType + VolStatus) &&
- hash_size[MediaType + VolStatus] != 0)
+ if (hash_size.contains(MediaType) &&
+ hash_size[MediaType] != 0)
{
- usage = VolBytes.toLongLong() * 100 / hash_size[MediaType + VolStatus];
+ usage = VolBytes.toLongLong() * 100 / hash_size[MediaType];
}
- mediaitem.setTextFld(index++, str_usage.setNum(usage, 'f'));
+ mediaitem.setPercent(index++, usage);
/* Volstatus */
mediaitem.setVolStatusFld(index++, VolStatus);
{
}
+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);
+}
+
+/* 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,
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);
- last = new BatSortingTableItem;
- parent->setItem(row, index, last);
- last->setIcon(pix);
+ 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)
void setBoolFld(int index, const QString &fld, bool center = true);
void setBoolFld(int index, int fld, bool center = true);
+ /* Print nice icon to represent percent */
+ void setPercent(int index, float number);
+
/* Normal text field. Centers field if center true*/
void setTextFld(int index, const QString &fld, bool center = false);
virtual void setTextAlignment(int index, int align) = 0;
virtual void setBackground(int index, const QBrush &) = 0;
virtual void setPixmap(int index, const QPixmap &pix) = 0;
+ virtual void setPixmap(int index, const QPixmap &pix, const QString &tip);
/* sets the *optional* value used for sorting */
virtual void setSortValue(int index, const QVariant &value) = 0;
virtual void setBackground(int index, const QBrush &);
virtual void setSortValue(int index, const QVariant &value);
virtual void setPixmap(int index, const QPixmap &pix);
+ virtual void setPixmap(int index, const QPixmap &pix, const QString &tip);
private:
QTableWidget *parent;