summaryrefslogtreecommitdiffstats
path: root/module/gui/Overview.py
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2011-02-12 18:04:24 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2011-02-12 18:04:24 +0100
commit5a6bcc04e4a0b0088b7ca08c2a782fbc1212d674 (patch)
treecdbdda06598c0f2dd85273b2f32642e1ab1a5405 /module/gui/Overview.py
parentFileserveCom: Fixes download check (diff)
downloadpyload-5a6bcc04e4a0b0088b7ca08c2a782fbc1212d674.tar.xz
GUI refactoring (now Thrift powered), closes #233
please test!
Diffstat (limited to 'module/gui/Overview.py')
-rw-r--r--module/gui/Overview.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/module/gui/Overview.py b/module/gui/Overview.py
index 1ac790515..ad63bf9fd 100644
--- a/module/gui/Overview.py
+++ b/module/gui/Overview.py
@@ -21,6 +21,15 @@ from PyQt4.QtGui import *
from time import sleep, time
+def formatSpeed(speed):
+ speed = int(speed)
+ steps = 0
+ sizes = ["B/s", "KiB/s", "MiB/s", "GiB/s"]
+ while speed > 1000:
+ speed /= 1024.0
+ steps += 1
+ return "%i %s" % (speed, sizes[steps])
+
class OverviewModel(QAbstractListModel):
PackageName = 10
Progress = 11
@@ -76,7 +85,7 @@ class OverviewModel(QAbstractListModel):
maxsize, currentsize = maxSize(p)
speed = self.queue.getSpeed(p)
if speed:
- eta = (maxsize - (maxsize * (progress/100.0)))/1024/speed
+ eta = (maxsize - (maxsize * (progress/100.0)))/speed
else:
eta = 0
if not speed and not progress:
@@ -152,7 +161,7 @@ class OverviewDelegate(QItemDelegate):
elif not status == _("Downloading"):
speedline = QString(status)
else:
- speedline = QString(formatEta(eta) + " " + _("Speed: %s kb/s") % speed)
+ speedline = QString(formatEta(eta) + " " + _("Speed: %s") % formatSpeed(speed))
def formatSize(size):
from math import ceil