many emptyfications

This commit is contained in:
Julien Veyssier 2013-03-15 12:43:51 +01:00
commit f6e2f0a657
13 changed files with 51 additions and 46 deletions

View file

@ -24,7 +24,7 @@ from PyQt4.QtGui import QFrame, QFileDialog
from weboob.applications.qcineoob.ui.torrent_ui import Ui_Torrent
from weboob.applications.weboorrents.weboorrents import sizeof_fmt
from weboob.capabilities.base import NotAvailable, NotLoaded
from weboob.capabilities.base import empty
class Torrent(QFrame):
def __init__(self, torrent, backend, parent=None):
@ -39,21 +39,21 @@ class Torrent(QFrame):
self.torrent = torrent
self.ui.idEdit.setText(u'%s@%s'%(torrent.id,backend.name))
self.ui.nameLabel.setText(u'%s'%torrent.name)
if torrent.url != NotAvailable:
if not empty(torrent.url):
self.ui.urlEdit.setText(u'%s'%torrent.url)
else:
self.ui.urlFrame.hide()
self.ui.downloadButton.setDisabled(True)
if torrent.magnet != NotAvailable and torrent.magnet != NotLoaded:
if not empty(torrent.magnet):
self.ui.downloadButton.setText(u'Download not available\nbut magnet link provided')
self.ui.downloadButton.setToolTip(u'Use the magnet link')
if torrent.magnet != NotAvailable and torrent.magnet != NotLoaded:
if not empty(torrent.magnet):
self.ui.magnetEdit.setText(u'%s'%torrent.magnet)
else:
self.ui.magnetFrame.hide()
if torrent.seeders != NotAvailable and torrent.leechers != NotAvailable:
if not empty(torrent.seeders) and not empty(torrent.leechers):
self.ui.seedLeechLabel.setText(u'%s/%s'%(torrent.seeders,torrent.leechers))
if torrent.size != NotAvailable:
if not empty(torrent.size):
self.ui.sizeLabel.setText(u'%s'%sizeof_fmt(torrent.size))
self.ui.verticalLayout.setAlignment(Qt.AlignTop)