diff options
author | mkaay <mkaay@mkaay.de> | 2011-01-27 01:56:58 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2011-01-27 01:56:58 +0100 |
commit | 7eb04fbfb9287f59da58800e2546ccfddbe1902f (patch) | |
tree | d137b515e4d521185090d287297ed3843a84d758 /module/gui/Overview.py | |
parent | gui overview size calc fix, width issue (diff) | |
download | pyload-7eb04fbfb9287f59da58800e2546ccfddbe1902f.tar.xz |
some improvements
Diffstat (limited to 'module/gui/Overview.py')
-rw-r--r-- | module/gui/Overview.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/module/gui/Overview.py b/module/gui/Overview.py index c036875a7..205d85234 100644 --- a/module/gui/Overview.py +++ b/module/gui/Overview.py @@ -30,6 +30,7 @@ class OverviewModel(QAbstractListModel): Speed = 15 CurrentSize = 16 MaxSize = 17 + Status = 18 def __init__(self, view, connector): QAbstractListModel.__init__(self) @@ -51,18 +52,29 @@ class OverviewModel(QAbstractListModel): def maxSize(p): s = 0 for c in p.children: - s += c.data["size"] + try: + s += c.data["downloading"]["size"] + except: + s += c.data["size"] return s + def getProgress(p): + for c in p.children: + if c.data["status"] == 13: + return (_("Unpacking"), int(c.data["progress"])) + return (_("Downloading"), self.queue.getProgress(p)) + d = self.queue._data for p in d: - progress = self.queue.getProgress(p) + status, progress = getProgress(p) maxsize = maxSize(p) speed = self.queue.getSpeed(p) if speed: eta = (maxsize - (maxsize * (progress/100.0)))/1024/speed else: eta = 0 + if not speed and not progress: + status = _("Queued") info = { OverviewModel.PackageName: p.data["name"], OverviewModel.Progress: progress, @@ -72,6 +84,7 @@ class OverviewModel(QAbstractListModel): OverviewModel.Speed: speed, OverviewModel.CurrentSize: int(maxsize * (progress/100.0)), OverviewModel.MaxSize: maxsize, + OverviewModel.Status: status, } self.packages.append(info) @@ -85,7 +98,7 @@ class OverviewModel(QAbstractListModel): return len(self.packages) def data(self, index, role=Qt.DisplayRole): - if role in [OverviewModel.PackageName, OverviewModel.Progress, OverviewModel.PartsFinished, OverviewModel.Parts, OverviewModel.ETA, OverviewModel.Speed, OverviewModel.CurrentSize, OverviewModel.MaxSize]: + if role in [OverviewModel.PackageName, OverviewModel.Progress, OverviewModel.PartsFinished, OverviewModel.Parts, OverviewModel.ETA, OverviewModel.Speed, OverviewModel.CurrentSize, OverviewModel.MaxSize, OverviewModel.Status]: return QVariant(self.packages[index.row()][role]) return QVariant() @@ -119,6 +132,7 @@ class OverviewDelegate(QItemDelegate): progress = int(index.data(OverviewModel.Progress).toString()) currentSize = int(index.data(OverviewModel.CurrentSize).toString()) maxSize = int(index.data(OverviewModel.MaxSize).toString()) + status = index.data(OverviewModel.Status).toString() def formatEta(seconds): if seconds <= 0: return "" @@ -129,6 +143,8 @@ class OverviewDelegate(QItemDelegate): statusline = QString(_("Parts: ") + "%s/%s" % (partsf, parts)) if partsf == parts: speedline = _("Finished") + elif not status == _("Downloading"): + speedline = QString(status) else: speedline = QString(formatEta(eta) + " " + _("Speed: %s kb/s") % speed) |