diff options
author | mkaay <mkaay@mkaay.de> | 2011-02-11 21:45:41 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2011-02-11 21:45:41 +0100 |
commit | d72a24be3c9100b183ad58acd58d1b3cdf727bd9 (patch) | |
tree | d704af73903310e0141f92e64440eacc872f3146 | |
parent | Thrift with SSL (diff) | |
download | pyload-d72a24be3c9100b183ad58acd58d1b3cdf727bd9.tar.xz |
Ev0InFetcher fix, gui cleanup
-rw-r--r-- | module/database/StorageDatabase.py | 2 | ||||
-rw-r--r-- | module/gui/Queue.py | 62 | ||||
-rw-r--r-- | module/plugins/hooks/Ev0InFetcher.py | 4 |
3 files changed, 36 insertions, 32 deletions
diff --git a/module/database/StorageDatabase.py b/module/database/StorageDatabase.py index dc3135c30..3ed29625f 100644 --- a/module/database/StorageDatabase.py +++ b/module/database/StorageDatabase.py @@ -38,7 +38,7 @@ class StorageMethods(): else: db.c.execute("SELECT key, value FROM storage WHERE identifier=?", (identifier, )) d = {} - if row in db.c: + for row in db.c: d[row[0]] = row[1] return d diff --git a/module/gui/Queue.py b/module/gui/Queue.py index 1b9f98259..4e8bcc04b 100644 --- a/module/gui/Queue.py +++ b/module/gui/Queue.py @@ -38,7 +38,7 @@ def formatSize(size): class QueueModel(CollectorModel): def __init__(self, view, connector): CollectorModel.__init__(self, view, connector) - self.cols = 9 + self.cols = 7 self.wait_dict = {} self.updater = self.QueueUpdater(self.interval) @@ -118,14 +118,10 @@ class QueueModel(CollectorModel): elif section == 3: return QVariant(_("Priority")) elif section == 4: - return QVariant(_("Current")) - elif section == 5: - return QVariant(_("Left")) - elif section == 6: return QVariant(_("Size")) - elif section == 7: + elif section == 5: return QVariant(_("ETA")) - elif section == 8: + elif section == 6: return QVariant(_("Progress")) return QVariant() @@ -233,27 +229,36 @@ class QueueModel(CollectorModel): elif index.column() == 4: item = index.internalPointer() if isinstance(item, Link): - if item.data["downloading"]: - return QVariant("%s" % formatSize(item.data["size"]-item.data["downloading"]["bleft"])) - elif isinstance(item, Package): - return QVariant("packRecv") + if self.getProgress(item) == 100: + return QVariant(formatSize(item.data["size"])) + elif self.getProgress(item) == 0: + return QVariant("0 B / %s" % formatSize(item.data["size"])) + else: + try: + return QVariant("%s / %s" % (formatSize(item.data["size"]-item.data["downloading"]["bleft"]), formatSize(item.data["size"]))) + except: + return QVariant("? / %s" % formatSize(item.data["size"])) + else: + ms = 0 + cs = 0 + for c in item.children: + try: + s = c.data["downloading"]["size"] + except: + s = c.data["size"] + if c.data["downloading"]: + cs += s - item.data["downloading"]["bleft"] + elif self.getProgress(c) == 100: + cs += s + ms += s + if cs == 0 or cs == ms: + return QVariant(formatSize(ms)) + else: + return QVariant("%s / %s" % (formatSize(cs), formatSize(ms))) elif index.column() == 5: item = index.internalPointer() if isinstance(item, Link): if item.data["downloading"]: - return QVariant("%s" % formatSize(item.data["downloading"]["bleft"])) - elif isinstance(item, Package): - return QVariant("packLeft") - elif index.column() == 6: - item = index.internalPointer() - if isinstance(item, Link): - return QVariant("%s" % item.data["format_size"]) - elif isinstance(item, Package): - return QVariant("packSize") - elif index.column() == 7: - item = index.internalPointer() - if isinstance(item, Link): - if item.data["downloading"]: return QVariant(item.data["downloading"]["format_eta"]) elif role == Qt.EditRole: if index.column() == 0: @@ -272,16 +277,15 @@ class QueueView(CollectorView): self.setColumnWidth(0, 300) self.setColumnWidth(1, 100) - self.setColumnWidth(2, 150) + self.setColumnWidth(2, 100) self.setColumnWidth(3, 50) - self.setColumnWidth(4, 80) + self.setColumnWidth(4, 100) self.setColumnWidth(5, 70) - self.setColumnWidth(6, 80) self.setEditTriggers(QAbstractItemView.NoEditTriggers) self.delegate = QueueProgressBarDelegate(self, self.model()) - self.setItemDelegateForColumn(8, self.delegate) + self.setItemDelegateForColumn(6, self.delegate) class QueueProgressBarDelegate(QItemDelegate): def __init__(self, parent, queue): @@ -291,7 +295,7 @@ class QueueProgressBarDelegate(QItemDelegate): def paint(self, painter, option, index): if not index.isValid(): return - if index.column() == 8: + if index.column() == 6: item = index.internalPointer() w = self.queue.getWaitingProgress(item) wait = None diff --git a/module/plugins/hooks/Ev0InFetcher.py b/module/plugins/hooks/Ev0InFetcher.py index f20031e40..f3703ea04 100644 --- a/module/plugins/hooks/Ev0InFetcher.py +++ b/module/plugins/hooks/Ev0InFetcher.py @@ -81,7 +81,7 @@ class Ev0InFetcher(Hook, PluginStorage): if not found: self.core.log.debug("Ev0InFetcher: no new episodes found") - for show, lastfound in showStorage.iteritems(): - if lastfound > 0 and lastfound + (3600*24*30) < int(time()): + for show, lastfound in self.getStorage().iteritems(): + if int(lastfound) > 0 and int(lastfound) + (3600*24*30) < int(time()): self.delStorage("show_%s_lastfound" % show) self.core.log.debug("Ev0InFetcher: cleaned '%s' record" % show) |