Exemple #1
0
 def fillData(self, size, downloaded, uploaded, ratio, percent, downspeed, upspeed, state):
   progressLabel = "%s/%s, uploaded %s (Ratio %0.1f)"
   speedLabel = "%s, ↓ %s/s ↑ %s/s"
   self.progressLabel.setText(progressLabel % (from_bit_to(downloaded), from_bit_to(size), from_bit_to(uploaded), ratio))
   self.percentLabel.setText(("%0.1f" % percent) + "%")
   self.speedLabel.setText(self.trUtf8(speedLabel % (states[state][0], from_bit_to(downspeed), from_bit_to(upspeed))))
   self.downloadedBar.setValue(percent)
Exemple #2
0
  def makeModel(self, results, index = 2):
    getAttr = [lambda obj: obj.name,
               lambda obj: obj.size[0]*(1024**obj.size[1]),
               lambda obj: obj.seed,
               lambda obj: obj.leach]

    col = len(results)

    ascending = False if index == self.currentColumnSort[0] and self.currentColumnSort[1] else True
    self.currentColumnSort = [index, ascending]

    model = QStandardItemModel(col, 4, self)
    columnHeaderItems = [QStandardItem(column) for column in "Name", "Size", "Seeds", "Leachs"]
    columnHeaderItems[index].setIcon(self.ascendingIcon if ascending else self.descendingIcon)
    for i in range(4):
      model.setHorizontalHeaderItem(i, columnHeaderItems[i])

    if results:
      results = list_to_tree(results, lambda x, y: getAttr[index](x) > getAttr[index](y))
      if ascending: results = results.postOrder()
      else: results = results.preOrder()
      self.results = results

    for i in range(col):
      result = results[i]
      size = from_bit_to(result.size[0]*1024**result.size[1])

      model.setItem(i, 0, QStandardItem(result.name))
      model.setItem(i, 1, QStandardItem(size))
      model.setItem(i, 2, QStandardItem(str(result.seed)))
      model.setItem(i, 3, QStandardItem(str(result.leach)))
    return model
Exemple #3
0
 def updateNetStatusLabel(self, downspeed, upspeed):
   text = "<small>↓ %s/s ↑ %s/s</small>" % (from_bit_to(downspeed), from_bit_to(upspeed))
   self.netStatusLabel.setText(QObject().trUtf8(text))