def __updateFileTransfers(self, transfers):
		pridat = []

		for inf in self.__informations:
			inf[4] = True

		for transfer in transfers:
			pridame = True
			for inf in self.__informations:
				if inf[0] == (transfer['name'], transfer['project_url']):
					pridame = False
					inf[3] = transfer
					inf[4] = False
					break
			if pridame:
				pridat.append(transfer)

		for polozka in pridat:
			treeItem = QTreeWidgetItem(self.__treeWidget)
			progressBar = QProgressBar()
			progressBar.setAutoFillBackground(True)
			progressBar.setFixedHeight(self.__treeWidget.rowHeight(self.__treeWidget.indexFromItem(treeItem)))
			self.__treeWidget.setItemWidget(treeItem, 2, progressBar)
			self.__informations.append([(polozka['name'], polozka['project_url']), treeItem, progressBar, polozka, False])

			self.__updateData(polozka, treeItem, progressBar)

		for i in range(len(self.__informations) - 1, -1, -1):
			# odstranenie
			if self.__informations[i][4]:
				self.__treeWidget.takeTopLevelItem(i)
				self.__informations.pop(i)
			# aktualizacia
			else:
				inf = self.__informations[i]
				self.__updateData(inf[3], inf[1], inf[2])


		QTimer.singleShot(1000, self.sender().getFileTransfers)
class UploadTransactionView(QTreeWidgetItem,View):
    #The widget that shows the progress of the upload.

    #TODO: Add time estimate. Might want to alter the core
    #to include timestamps on the upload transaction for each
    #new uploadToken received.

    #IDEA: Instead of updating the upload token on the UploadTransaction
    #we can add each token to a list on the UploadTransaction (transaction_tokens), and add the
    #timestamp. Then based on past progress, we can tell 3 things:
    # - Get an approximation of the transfer rate kb/s
    # - Time spent uploading
    # - Time left
    COLUMN_FILENAME = 0
    COLUMN_STATUS = 1
    COLUMN_PERCENTAGE = 2
    COLUMN_TEST_WIDGET = 3
    _uploadTransactionModel = None #UploadTransactionModel object
    _treeWidget = None
    
    def __init__(self, parentWidget, uploadTransaction):
        QTreeWidgetItem.__init__(self, None,QTreeWidgetItem.UserType)
        View.__init__(self)
        
        self.setTreeWidget(parentWidget)

        #we bootstrap the inner components and put the "LEGO" together
        self._uploadTransactionModel = uploadTransaction
        self._uploadTransactionProgressBar = QProgressBar()
        self._uploadTransactionProgressBar.setTextVisible(True)
        self._uploadTransactionProgressBar.setAutoFillBackground(True)

        self.setText(UploadTransactionView.COLUMN_FILENAME,utils.getFileName(uploadTransaction.getFilePath()))
        self.setText(UploadTransactionView.COLUMN_STATUS,uploadTransaction.getHumanUploadStatus())
        self.getTreeWidget().setItemWidget(self,UploadTransactionView.COLUMN_PERCENTAGE,self._uploadTransactionProgressBar)
        
    def getUploadTransactionModel(self):
        return self._uploadTransactionModel
        
    def updateUploadTransactionModel(self,uploadTransaction):
        #Given the latest transaction object, we grab its token object
        #and we update the percentage of the transaction
        #and other things
        #print "UploadTransactionView.updateUploadTransactionModel",uploadTransaction

        self._uploadTransactionModel = uploadTransaction
        self.setText(UploadTransactionView.COLUMN_PERCENTAGE,str(uploadTransaction.getUploadPercentage())+'%')
        self.setText(UploadTransactionView.COLUMN_STATUS,uploadTransaction.getHumanUploadStatus())

        self.updateStatus()

    def updateStatus(self):
        self.setText(UploadTransactionView.COLUMN_STATUS,self._uploadTransactionModel.getHumanUploadStatus())

        #Update the progress bar
        if self._uploadTransactionModel:
            #self._uploadTransactionProgressBar.setValue(self._uploadTransactionModel.getUploadPercentage())
            self._uploadTransactionProgressBar = QProgressBar()
            self._uploadTransactionProgressBar.setAutoFillBackground(True)
            self._uploadTransactionProgressBar.setValue(self._uploadTransactionModel.getUploadPercentage())
            self.getTreeWidget().setItemWidget(self,UploadTransactionView.COLUMN_PERCENTAGE,self._uploadTransactionProgressBar)

        
    def setTreeWidget(self, parent):
        self._treeWidget = parent
        
    def getTreeWidget(self):
        return self._treeWidget