diff options
author | mkaay <mkaay@mkaay.de> | 2010-09-06 19:14:02 +0200 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2010-09-06 19:14:02 +0200 |
commit | 0b6f0dd36f5b4c02a444825c77cae02cc5066f34 (patch) | |
tree | 6efe97789b316dc80f8d62d322ec19d63109b6fd /module/gui | |
parent | gui double logging fix (diff) | |
download | pyload-0b6f0dd36f5b4c02a444825c77cae02cc5066f34.tar.xz |
gui: status translation, core: added scheduler -> better account fetching UploadedTo + ShareonlineBiz account fix
Diffstat (limited to 'module/gui')
-rw-r--r-- | module/gui/Accounts.py | 10 | ||||
-rw-r--r-- | module/gui/Collector.py | 25 | ||||
-rw-r--r-- | module/gui/Queue.py | 6 |
3 files changed, 32 insertions, 9 deletions
diff --git a/module/gui/Accounts.py b/module/gui/Accounts.py index f47928c1a..b83ce9827 100644 --- a/module/gui/Accounts.py +++ b/module/gui/Accounts.py @@ -30,8 +30,8 @@ class AccountModel(QAbstractItemModel): self.cols = 4 self.mutex = QMutex() - def reloadData(self): - data = self.connector.proxy.get_accounts() + def reloadData(self, force=True): + data = self.connector.proxy.get_accounts(force) self.beginRemoveRows(QModelIndex(), 0, len(self._data)) self._data = [] self.endRemoveRows() @@ -62,8 +62,6 @@ class AccountModel(QAbstractItemModel): return QVariant(fmtime) else: return QVariant(_("unlimited")) - elif index.column() == 3: - return QVariant(self.toData(index)["trafficleft"]) #elif role == Qt.EditRole: # if index.column() == 0: # return QVariant(index.internalPointer().data["name"]) @@ -145,7 +143,7 @@ class AccountDelegate(QItemDelegate): opts = QStyleOptionProgressBarV2() opts.minimum = 0 if data["trafficleft"]: - if data["trafficleft"] == -1: + if data["trafficleft"] == -1 or data["trafficleft"] is None: opts.maximum = opts.progress = 1 else: opts.maximum = opts.progress = data["trafficleft"] @@ -159,6 +157,8 @@ class AccountDelegate(QItemDelegate): opts.textAlignment = Qt.AlignCenter if data["trafficleft"] and data["trafficleft"] == -1: opts.text = QString(_("unlimited")) + elif data["trafficleft"] is None: + opts.text = QString(_("n/a")) else: opts.text = QString.number(round(float(opts.progress)/1024/1024, 2)) + " GB" QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter) diff --git a/module/gui/Collector.py b/module/gui/Collector.py index f7bfcbebf..08d82daf8 100644 --- a/module/gui/Collector.py +++ b/module/gui/Collector.py @@ -37,6 +37,8 @@ statusMap = { } statusMapReverse = dict((v,k) for k, v in statusMap.iteritems()) +translatedStatusMap = {} # -> CollectorModel.__init__ + class CollectorModel(QAbstractItemModel): def __init__(self, view, connector): QAbstractItemModel.__init__(self) @@ -46,6 +48,27 @@ class CollectorModel(QAbstractItemModel): self.cols = 3 self.interval = 1 self.mutex = QMutex() + + global translatedStatusMap # workaround because i18n is not running at import time + translatedStatusMap = { + "finished": _("finished"), + "offline": _("offline"), + "online": _("online"), + "queued": _("queued"), + "checking": _("checking"), + "waiting": _("waiting"), + "reconnected": _("reconnected"), + "starting": _("starting"), + "failed": _("failed"), + "aborted": _("aborted"), + "decrypting": _("decrypting"), + "custom": _("custom"), + "downloading": _("downloading"), + "processing": _("processing") + } + + def translateStatus(self, string): + return translatedStatusMap[string] def addEvent(self, event): locker = QMutexLocker(self.mutex) @@ -150,7 +173,7 @@ class CollectorModel(QAbstractItemModel): status = child.data["status"] else: status = item.data["status"] - return QVariant(statusMapReverse[status]) + return QVariant(self.translateStatus(statusMapReverse[status])) elif index.column() == 1: item = index.internalPointer() plugins = [] diff --git a/module/gui/Queue.py b/module/gui/Queue.py index ca527bb2c..9225df58f 100644 --- a/module/gui/Queue.py +++ b/module/gui/Queue.py @@ -185,9 +185,9 @@ class QueueModel(CollectorModel): status = item.data["status"] if speed is None or status == 7 or status == 10 or status == 5: - return QVariant(statusMapReverse[status]) + return QVariant(self.translateStatus(statusMapReverse[status])) else: - return QVariant("%s (%s KB/s)" % (statusMapReverse[status], speed)) + return QVariant("%s (%s KB/s)" % (self.translateStatus(statusMapReverse[status]), speed)) elif index.column() == 3: item = index.internalPointer() if isinstance(item, Package): @@ -251,7 +251,7 @@ class QueueProgressBarDelegate(QItemDelegate): opts.textVisible = True opts.textAlignment = Qt.AlignCenter if not wait is None: - opts.text = QString("waiting %d seconds" % (wait,)) + opts.text = QString(_("waiting %d seconds") % (wait,)) else: opts.text = QString.number(opts.progress) + "%" QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter) |