def create_file_table(): self.file_table = file_table = TableWidget(self) file_table.setColumnCount(5) file_table.setRowCount(self.row_number) file_table.setHorizontalHeaderLabels([ 'File Name', 'File Size', 'Remote Type', 'Published', 'File Encryption Hash' ]) file_list = get_file_list() for cur_row in range(self.row_number): if cur_row == len(file_list): break file_table.setItem(cur_row, 0, QTableWidgetItem(file_list[cur_row].name)) self.file_table.setItem( cur_row, 1, QTableWidgetItem(sizeof_fmt(file_list[cur_row].size))) self.file_table.setItem( cur_row, 2, QTableWidgetItem(file_list[cur_row].remote_type)) self.file_table.setItem( cur_row, 3, QTableWidgetItem(str(file_list[cur_row].is_published))) self.file_table.setItem( cur_row, 4, QTableWidgetItem(file_list[cur_row].hashcode))
def itemHandler(data): items = [] items.append(data.name) items.append(data.remote_type) items.append(str(sizeof_fmt(data.size))) status = data.is_published wid = QLabel('Published') if not status: wid.setText('Publish as product') wid.setStyleSheet("QLabel{color: #006bcf;}") Binder.click(wid, buildProductClickListener(data.id)) items.append(wid) return items
def update_table(self): file_list = get_file_list() print(file_list.__len__()) for cur_row in range(self.row_number): if cur_row == file_list.__len__(): break self.file_table.setItem(cur_row, 0, QTableWidgetItem(file_list[cur_row].name)) self.file_table.setItem( cur_row, 1, QTableWidgetItem(sizeof_fmt(file_list[cur_row].size))) self.file_table.setItem( cur_row, 2, QTableWidgetItem(file_list[cur_row].remote_type)) self.file_table.setItem( cur_row, 3, QTableWidgetItem(str(file_list[cur_row].is_published))) self.file_table.setItem( cur_row, 4, QTableWidgetItem(file_list[cur_row].hashcode))
def update_table(self): file_list = get_buyer_file_list() print(file_list.__len__()) for cur_row in range(self.row_number): if cur_row == file_list.__len__(): break self.file_table.setItem( cur_row, 0, QTableWidgetItem(file_list[cur_row].file_title)) self.file_table.setItem( cur_row, 2, QTableWidgetItem(str(file_list[cur_row].is_downloaded))) self.file_table.setItem( cur_row, 3, QTableWidgetItem(file_list[cur_row].market_hash)) if file_list[cur_row].is_downloaded: self.file_table.setItem( cur_row, 1, QTableWidgetItem(sizeof_fmt(file_list[cur_row].size))) self.file_table.setItem( cur_row, 4, QTableWidgetItem(file_list[cur_row].file_uuid))
def create_file_table(): self.file_table = file_table = TableWidget(self) def right_menu(): sel = file_table.selectionModel() if not sel.hasSelection(): return menu = QMenu(file_table) def get_item(): row = file_table.currentRow() col = 4 # File uuid column cur_item = file_table.item(row, col) # print("inside get_item" + str(row) + str(col)) return cur_item def open_file_action(): item = get_item() path = item.text() file_dir = os.path.expanduser(config.wallet.download_dir) file_path = os.path.join(file_dir, path) open_file(file_path + "_decrypted") action = QAction("Open Plain File", file_table, triggered=open_file_action) menu.addAction(action) # Encrypted file is not encoded in string, so can't be opened properly. def open_encrypted_file_action(): item = get_item() path = item.text() file_dir = os.path.expanduser(config.wallet.download_dir) file_path = os.path.join(file_dir, path) open_file(file_path) action = QAction("Open Encrypted File", file_table, triggered=open_encrypted_file_action) menu.addAction(action) menu.exec_(QCursor.pos()) file_table.set_right_menu(right_menu) file_table.setRowCount(self.row_number) headers = [ 'File Title', 'File Size', 'Downloaded', 'Market Hash', 'File UUID' ] file_table.setColumnCount(len(headers)) file_table.setColumnHidden(4, True) file_table.setHorizontalHeaderLabels(headers) file_list = get_buyer_file_list() for cur_row in range(self.row_number): if cur_row == len(file_list): break self.file_table.setItem( cur_row, 0, QTableWidgetItem(file_list[cur_row].file_title)) self.file_table.setItem( cur_row, 2, QTableWidgetItem(str(file_list[cur_row].is_downloaded))) self.file_table.setItem( cur_row, 3, QTableWidgetItem(file_list[cur_row].market_hash)) if file_list[cur_row].is_downloaded: self.file_table.setItem( cur_row, 1, QTableWidgetItem(sizeof_fmt(file_list[cur_row].size))) self.file_table.setItem( cur_row, 4, QTableWidgetItem(file_list[cur_row].file_uuid))