diff --git a/Changelog b/Changelog index 03c2f89ea..e0de258cd 100644 --- a/Changelog +++ b/Changelog @@ -41,6 +41,7 @@ - COSMETIC: Display Seeds and Peers in two separate columns - COSMETIC: New deletion confirmation dialog (Merged delete/delete permanently actions) - 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 - v1.5.0 - FEATURE: Added Magnet URI support diff --git a/src/misc.h b/src/misc.h index 6253fbc93..6e28fa54e 100644 --- a/src/misc.h +++ b/src/misc.h @@ -157,14 +157,14 @@ public: // use Binary prefix standards from IEC 60027-2 // see http://en.wikipedia.org/wiki/Kilobyte // value must be given in bytes - static QString friendlyUnit(float val) { + static QString friendlyUnit(double val) { if(val < 0) 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)")}; char i = 0; while(val > 1024. && i++<6) 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){ diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index 94a7197d7..70abcdece 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -306,11 +306,11 @@ void PropertiesWidget::loadDynamicData() { if(h.upload_limit() <= 0) lbl_uplimit->setText(tr("Unlimited")); 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) lbl_dllimit->setText(tr("Unlimited")); 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()); if(h.is_seed()) { elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(misc::userFriendlyDuration(h.seeding_time()))+")"; diff --git a/src/statusbar.h b/src/statusbar.h index b9ab7e72d..a7357f677 100644 --- a/src/statusbar.h +++ b/src/statusbar.h @@ -160,8 +160,8 @@ public slots: //statusSep1->setVisible(false); } // 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))); - 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))); + 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/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() { diff --git a/src/transferlistdelegate.h b/src/transferlistdelegate.h index 07e4682f3..e261172ed 100644 --- a/src/transferlistdelegate.h +++ b/src/transferlistdelegate.h @@ -112,9 +112,9 @@ public: case TR_UPSPEED: case TR_DLSPEED:{ QItemDelegate::drawBackground(painter, opt, index); - double speed = index.data().toDouble(); + qulonglong speed = index.data().toULongLong(); 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; } case TR_RATIO:{