[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/plasma/applets/system-monitor
From: Petri Damstén <petri.damsten () kdemail ! net>
Date: 2009-09-14 11:47:06
Message-ID: 1252928826.403117.15567.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1023272 by pdamsten:
Use correct scale and unit.
BUG:207316
M +13 -6 ram.cpp
--- trunk/KDE/kdebase/workspace/plasma/applets/system-monitor/ram.cpp #1023271:1023272
@@ -102,7 +102,7 @@
plotter->setHorizontalLinesCount(4);
plotter->setSvgBackground("widgets/plot-background");
plotter->setTitle(ram);
- plotter->setUnit("MB");
+ plotter->setUnit("B");
appendPlotter(source, plotter);
mainLayout()->addItem(plotter);
setPreferredItemHeight(80);
@@ -125,17 +125,24 @@
if (plotter) {
/* A factor to convert from default units to bytes.
* If units is not "KB", assume it is bytes. */
- const double factor = (data["units"].toString() == "KB") ? 1024. : 1.;
+ const double factor = (data["units"].toString() == "KB") ? 1024.0 : 1.0;
const double value_b = data["value"].toDouble() * factor;
const double max_b = data["max"].toDouble() * factor;
- const double value_kb = value_b / 1024.;
- const double max_kb = max_b / 1024.;
+ static const QStringList units = QStringList() << "B" << "KiB" << "MiB" << "GiB" << "TiB";
if (value_b > m_max[source]) {
m_max[source] = max_b;
- plotter->setVerticalRange(0.0, max_kb);
+ plotter->setVerticalRange(0.0, max_b);
+ qreal scale = 1.0;
+ int i = 0;
+ while (max_b / scale > 1024.0 && i < units.size()) {
+ scale *= 1024.0;
+ ++i;
+ }
+ plotter->setUnit(units[i]);
+ plotter->scale(scale);
}
- plotter->addSample(QList<double>() << value_kb);
+ plotter->addSample(QList<double>() << value_b);
if (mode() == SM::Applet::Panel) {
m_html[source] = QString("<tr><td>%1</td><td>%2</td><td>of</td><td>%3</td></tr>")
.arg(plotter->title())
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic