diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-03-28 22:32:14 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-06-28 02:47:08 +0200 |
commit | b1fffc3a1b2dbbb807213b85f538e59251b9bf35 (patch) | |
tree | c373d3234dcb474bb424371a3d89341bed8a9e07 /module/gui/Overview.py | |
parent | Plugins licensing doc (diff) | |
download | pyload-b1fffc3a1b2dbbb807213b85f538e59251b9bf35.tar.xz |
Remove bad whitespaces
Merged vuolter/pyload@00288e6
Diffstat (limited to 'module/gui/Overview.py')
-rw-r--r-- | module/gui/Overview.py | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/module/gui/Overview.py b/module/gui/Overview.py index 183383b5e..a7c82e7d0 100644 --- a/module/gui/Overview.py +++ b/module/gui/Overview.py @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>. - + @author: mkaay """ @@ -31,24 +31,24 @@ class OverviewModel(QAbstractListModel): CurrentSize = 16 MaxSize = 17 Status = 18 - + def __init__(self, view, connector): QAbstractListModel.__init__(self) - + self.packages = [] - + def queueChanged(self): #dirty.. self.beginResetModel() - + self.packages = [] - + def partsFinished(p): f = 0 for c in p.children: if c.data["status"] == 0: f += 1 return f - + def maxSize(p): ms = 0 cs = 0 @@ -63,13 +63,13 @@ class OverviewModel(QAbstractListModel): cs += s ms += s return ms, cs - + def getProgress(p): for c in p.children: if c.data["status"] == 13: pass # TODO return _("Unpacking"), int(c.data["progress"]) return _("Downloading"), self.queue.getProgress(p) - + d = self.queue._data for p in d: status, progress = getProgress(p) @@ -92,27 +92,27 @@ class OverviewModel(QAbstractListModel): OverviewModel.MaxSize: maxsize, OverviewModel.Status: status, } - + self.packages.append(info) - + self.endResetModel() - + def headerData(self, section, orientation, role=Qt.DisplayRole): return QVariant(_("Package")) - + def rowCount(self, parent=QModelIndex()): 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, OverviewModel.Status]: return QVariant(self.packages[index.row()][role]) return QVariant() - + class OverviewView(QListView): def __init__(self, connector): QListView.__init__(self) self.setModel(OverviewModel(self, connector)) - + self.setAlternatingRowColors(True) self.delegate = OverviewDelegate(self) self.setItemDelegate(self.delegate) @@ -122,14 +122,14 @@ class OverviewDelegate(QItemDelegate): QItemDelegate.__init__(self, parent) self.parent = parent self.model = parent.model() - + def paint(self, painter, option, index): option.rect.setHeight(59+16) option.rect.setWidth(self.parent.width()-20) - + #if option.state & QStyle.State_Selected: # painter.fillRect(option.rect, option.palette.color(QPalette.Highlight)) - + packagename = index.data(OverviewModel.PackageName).toString() partsf = index.data(OverviewModel.PartsFinished).toString() parts = index.data(OverviewModel.Parts).toString() @@ -139,13 +139,13 @@ class OverviewDelegate(QItemDelegate): currentSize = int(index.data(OverviewModel.CurrentSize).toString()) maxSize = int(index.data(OverviewModel.MaxSize).toString()) status = index.data(OverviewModel.Status).toString() - + def formatEta(seconds): #TODO add to utils if seconds <= 0: return "" hours, seconds = divmod(seconds, 3600) minutes, seconds = divmod(seconds, 60) return _("ETA: ") + "%.2i:%.2i:%.2i" % (hours, minutes, seconds) - + statusline = QString(_("Parts: ") + "%s/%s" % (partsf, parts)) if partsf == parts: speedline = _("Finished") @@ -153,25 +153,25 @@ class OverviewDelegate(QItemDelegate): speedline = QString(status) else: speedline = QString(formatEta(eta) + " " + _("Speed: %s") % formatSpeed(speed)) - + if progress in (0,100): sizeline = QString(_("Size:") + "%s" % formatSize(maxSize)) else: sizeline = QString(_("Size:") + "%s / %s" % (formatSize(currentSize), formatSize(maxSize))) - + f = painter.font() f.setPointSize(12) f.setBold(True) painter.setFont(f) - + r = option.rect.adjusted(4, 4, -4, -4) painter.drawText(r.left(), r.top(), r.width(), r.height(), Qt.AlignTop | Qt.AlignLeft, packagename) newr = painter.boundingRect(r.left(), r.top(), r.width(), r.height(), Qt.AlignTop | Qt.AlignLeft, packagename) - + f.setPointSize(10) f.setBold(False) painter.setFont(f) - + painter.drawText(r.left(), newr.bottom()+5, r.width(), r.height(), Qt.AlignTop | Qt.AlignLeft, statusline) painter.drawText(r.left(), newr.bottom()+5, r.width(), r.height(), Qt.AlignTop | Qt.AlignHCenter, sizeline) painter.drawText(r.left(), newr.bottom()+5, r.width(), r.height(), Qt.AlignTop | Qt.AlignRight, speedline) @@ -179,10 +179,10 @@ class OverviewDelegate(QItemDelegate): newr.setTop(newr.bottom()+8) newr.setBottom(newr.top()+20) newr.setRight(self.parent.width()-25) - + f.setPointSize(10) painter.setFont(f) - + opts = QStyleOptionProgressBarV2() opts.maximum = 100 opts.minimum = 0 @@ -192,6 +192,6 @@ class OverviewDelegate(QItemDelegate): opts.textAlignment = Qt.AlignCenter opts.text = QString.number(opts.progress) + "%" QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter) - + def sizeHint(self, option, index): return QSize(self.parent.width()-22, 59+16) |