Browse Source

COSMETIC: Display speeds with more user friendly units instead of always using KiB/s

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
8b41d1973c
  1. 1
      Changelog
  2. 4
      src/misc.h
  3. 4
      src/propertieswidget.cpp
  4. 4
      src/statusbar.h
  5. 4
      src/transferlistdelegate.h

1
Changelog

@ -41,6 +41,7 @@
- COSMETIC: Display Seeds and Peers in two separate columns - COSMETIC: Display Seeds and Peers in two separate columns
- COSMETIC: New deletion confirmation dialog (Merged delete/delete permanently actions) - COSMETIC: New deletion confirmation dialog (Merged delete/delete permanently actions)
- COSMETIC: Improved status bar layout spacing - COSMETIC: Improved status bar layout spacing
- COSMETIC: Display speeds with more user friendly units instead of always using KiB/s
* Thu Sep 3 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.5.0 * Thu Sep 3 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.5.0
- FEATURE: Added Magnet URI support - FEATURE: Added Magnet URI support

4
src/misc.h

@ -157,14 +157,14 @@ public:
// use Binary prefix standards from IEC 60027-2 // use Binary prefix standards from IEC 60027-2
// see http://en.wikipedia.org/wiki/Kilobyte // see http://en.wikipedia.org/wiki/Kilobyte
// value must be given in bytes // value must be given in bytes
static QString friendlyUnit(float val) { static QString friendlyUnit(double val) {
if(val < 0) if(val < 0)
return tr("Unknown", "Unknown (size)"); return tr("Unknown", "Unknown (size)");
const QString units[5] = {tr("B", "bytes"), tr("KiB", "kibibytes (1024 bytes)"), tr("MiB", "mebibytes (1024 kibibytes)"), tr("GiB", "gibibytes (1024 mibibytes)"), tr("TiB", "tebibytes (1024 gibibytes)")}; const QString units[5] = {tr("B", "bytes"), tr("KiB", "kibibytes (1024 bytes)"), tr("MiB", "mebibytes (1024 kibibytes)"), tr("GiB", "gibibytes (1024 mibibytes)"), tr("TiB", "tebibytes (1024 gibibytes)")};
char i = 0; char i = 0;
while(val > 1024. && i++<6) while(val > 1024. && i++<6)
val /= 1024.; val /= 1024.;
return QString(QByteArray::number(val, 'f', 1)) + units[(int)i]; return QString(QByteArray::number(val, 'f', 1)) + " " + units[(int)i];
} }
static bool isPreviewable(QString extension){ static bool isPreviewable(QString extension){

4
src/propertieswidget.cpp

@ -306,11 +306,11 @@ void PropertiesWidget::loadDynamicData() {
if(h.upload_limit() <= 0) if(h.upload_limit() <= 0)
lbl_uplimit->setText(tr("Unlimited")); lbl_uplimit->setText(tr("Unlimited"));
else else
lbl_uplimit->setText(QString::number(h.upload_limit(), 'f', 1)+" "+tr("KiB/s")); lbl_uplimit->setText(misc::friendlyUnit(h.upload_limit())+tr("/s", "/second (i.e. per second)"));
if(h.download_limit() <= 0) if(h.download_limit() <= 0)
lbl_dllimit->setText(tr("Unlimited")); lbl_dllimit->setText(tr("Unlimited"));
else else
lbl_dllimit->setText(QString::number(h.download_limit(), 'f', 1)+" "+tr("KiB/s")); lbl_dllimit->setText(misc::friendlyUnit(h.download_limit())+tr("/s", "/second (i.e. per second)"));
QString elapsed_txt = misc::userFriendlyDuration(h.active_time()); QString elapsed_txt = misc::userFriendlyDuration(h.active_time());
if(h.is_seed()) { if(h.is_seed()) {
elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(misc::userFriendlyDuration(h.seeding_time()))+")"; elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(misc::userFriendlyDuration(h.seeding_time()))+")";

4
src/statusbar.h

@ -160,8 +160,8 @@ public slots:
//statusSep1->setVisible(false); //statusSep1->setVisible(false);
} }
// Update speed labels // Update speed labels
dlSpeedLbl->setText(tr("D: %1 KiB/s - T: %2", "Download speed: x KiB/s - Transferred: xMiB").arg(QString::number(sessionStatus.payload_download_rate/1024., 'f', 1)).arg(misc::friendlyUnit(sessionStatus.total_payload_download))); dlSpeedLbl->setText(tr("D: %1/s - T: %2", "Download speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_download_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_download)));
upSpeedLbl->setText(tr("U: %1 KiB/s - T: %2", "Upload speed: x KiB/s - Transferred: xMiB").arg(QString::number(sessionStatus.payload_upload_rate/1024., 'f', 1)).arg(misc::friendlyUnit(sessionStatus.total_payload_upload))); upSpeedLbl->setText(tr("U: %1/s - T: %2", "Upload speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_upload_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_upload)));
} }
void capDownloadSpeed() { void capDownloadSpeed() {

4
src/transferlistdelegate.h

@ -112,9 +112,9 @@ public:
case TR_UPSPEED: case TR_UPSPEED:
case TR_DLSPEED:{ case TR_DLSPEED:{
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
double speed = index.data().toDouble(); qulonglong speed = index.data().toULongLong();
opt.displayAlignment = Qt::AlignRight; opt.displayAlignment = Qt::AlignRight;
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(speed/1024., 'f', 1)+" "+tr("KiB/s")); QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (.i.e per second)"));
break; break;
} }
case TR_RATIO:{ case TR_RATIO:{

Loading…
Cancel
Save