def add_folder(self, folder_name, uuid, is_synced, selected=False): row_idx = self.rowCount() self.insertRow(row_idx) item = FolderTableItem(is_synced) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.ICON, item) item = CustomTableItem(folder_name) item.setData(NAME_DATA_INDEX, folder_name) item.setToolTip("\n".join(folder_name[i:i + 64] for i in range(0, len(folder_name), 64))) item.setData(TYPE_DATA_INDEX, FileType.Folder) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.NAME, item) item = CustomTableItem() item.setData(NAME_DATA_INDEX, pendulum.datetime(1970, 1, 1)) item.setData(TYPE_DATA_INDEX, FileType.Folder) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.CREATED, item) item = CustomTableItem() item.setData(NAME_DATA_INDEX, pendulum.datetime(1970, 1, 1)) item.setData(TYPE_DATA_INDEX, FileType.Folder) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.UPDATED, item) item = CustomTableItem() item.setData(NAME_DATA_INDEX, -1) item.setData(TYPE_DATA_INDEX, FileType.Folder) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.SIZE, item) if selected: self.setRangeSelected( QTableWidgetSelectionRange(row_idx, 0, row_idx, len(Column) - 1), True)
def add_file( self, file_name, entry_id, file_size, created_on, updated_on, is_synced, is_confined, selected=False, ): if is_confined and not self.config.gui_show_confined: return entry_id = entry_id.hex row_idx = self.rowCount() self.insertRow(row_idx) item = FileTableItem(is_synced, is_confined, file_name.str) item.setData(NAME_DATA_INDEX, 1) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.ICON, item) item = CustomTableItem(file_name.str) item.setToolTip("\n".join(file_name.str[i:i + 64] for i in range(0, len(file_name.str), 64))) item.setData(NAME_DATA_INDEX, file_name.str) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.NAME, item) item = CustomTableItem(format_datetime(created_on)) item.setData(NAME_DATA_INDEX, created_on) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.CREATED, item) item = CustomTableItem(format_datetime(updated_on)) item.setData(NAME_DATA_INDEX, updated_on) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.UPDATED, item) item = CustomTableItem(get_filesize(file_size)) item.setData(NAME_DATA_INDEX, file_size) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.SIZE, item) if selected: self.setRangeSelected( QTableWidgetSelectionRange(row_idx, 0, row_idx, len(Column) - 1), True)
def add_parent_workspace(self): row_idx = self.rowCount() self.insertRow(row_idx) items = [] p = Pixmap(":/icons/images/material/arrow_upward.svg") p.replace_color(QColor(0, 0, 0), QColor(0x99, 0x99, 0x99)) items.append(CustomTableItem(QIcon(p), "")) items.append(CustomTableItem(_("TEXT_FILE_TREE_PARENT_WORKSPACE"))) items.append(CustomTableItem()) items.append(CustomTableItem()) items.append(CustomTableItem()) for col, item in zip(Column, items): item.setData(NAME_DATA_INDEX, "") item.setData(TYPE_DATA_INDEX, FileType.ParentWorkspace) item.setData(UUID_DATA_INDEX, None) item.setFlags(Qt.ItemIsEnabled) self.setItem(row_idx, col, item)
def add_file(self, file_name, uuid, file_size, created_on, updated_on, is_synced, selected=False): row_idx = self.rowCount() self.insertRow(row_idx) item = FileTableItem(is_synced, file_name) item.setData(NAME_DATA_INDEX, 1) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.ICON, item) item = CustomTableItem(file_name) item.setToolTip("\n".join(file_name[i:i + 64] for i in range(0, len(file_name), 64))) item.setData(NAME_DATA_INDEX, file_name) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.NAME, item) item = CustomTableItem(format_datetime(created_on)) item.setData(NAME_DATA_INDEX, created_on) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.CREATED, item) item = CustomTableItem(format_datetime(updated_on)) item.setData(NAME_DATA_INDEX, updated_on) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.UPDATED, item) item = CustomTableItem(get_filesize(file_size)) item.setData(NAME_DATA_INDEX, file_size) item.setData(TYPE_DATA_INDEX, FileType.File) item.setData(UUID_DATA_INDEX, uuid) self.setItem(row_idx, Column.SIZE, item) if selected: self.setRangeSelected( QTableWidgetSelectionRange(row_idx, 0, row_idx, len(Column) - 1), True)
def add_folder(self, folder_name, entry_id, is_synced, is_confined, selected=False): if is_confined and not self.config.gui_show_confined: return entry_id = entry_id.hex row_idx = self.rowCount() self.insertRow(row_idx) item = FolderTableItem(is_synced, is_confined) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.ICON, item) item = CustomTableItem(folder_name.str) item.setData(NAME_DATA_INDEX, folder_name.str) item.setToolTip("\n".join(folder_name.str[i:i + 64] for i in range(0, len(folder_name.str), 64))) item.setData(TYPE_DATA_INDEX, FileType.Folder) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.NAME, item) item = CustomTableItem() item.setData(NAME_DATA_INDEX, pendulum.datetime(1970, 1, 1)) item.setData(TYPE_DATA_INDEX, FileType.Folder) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.CREATED, item) item = CustomTableItem() item.setData(NAME_DATA_INDEX, pendulum.datetime(1970, 1, 1)) item.setData(TYPE_DATA_INDEX, FileType.Folder) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.UPDATED, item) item = CustomTableItem() item.setData(NAME_DATA_INDEX, -1) item.setData(TYPE_DATA_INDEX, FileType.Folder) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.SIZE, item) if selected: self.setRangeSelected( QTableWidgetSelectionRange(row_idx, 0, row_idx, len(Column) - 1), True)
def add_inconsistency(self, file_name, entry_id): inconsistency_color = QColor(255, 144, 155) row_idx = self.rowCount() entry_id = entry_id.hex self.insertRow(row_idx) item = InconsistencyTableItem(False, False) item.setData(NAME_DATA_INDEX, 1) item.setData(TYPE_DATA_INDEX, FileType.Inconsistency) item.setData(ENTRY_ID_DATA_INDEX, entry_id) item.setBackground(inconsistency_color) self.setItem(row_idx, Column.ICON, item) item = CustomTableItem(file_name.str) item.setToolTip("\n".join(file_name.str[i:i + 64] for i in range(0, len(file_name.str), 64))) item.setData(NAME_DATA_INDEX, file_name.str) item.setData(TYPE_DATA_INDEX, FileType.Inconsistency) item.setData(ENTRY_ID_DATA_INDEX, entry_id) item.setBackground(inconsistency_color) self.setItem(row_idx, Column.NAME, item) item = CustomTableItem() item.setData(NAME_DATA_INDEX, pendulum.datetime(1970, 1, 1)) item.setData(TYPE_DATA_INDEX, FileType.Inconsistency) item.setBackground(inconsistency_color) item.setData(ENTRY_ID_DATA_INDEX, entry_id) self.setItem(row_idx, Column.CREATED, item) item = CustomTableItem() item.setData(NAME_DATA_INDEX, pendulum.datetime(1970, 1, 1)) item.setData(TYPE_DATA_INDEX, FileType.Inconsistency) item.setData(ENTRY_ID_DATA_INDEX, entry_id) item.setBackground(inconsistency_color) self.setItem(row_idx, Column.UPDATED, item) item = CustomTableItem(-1) item.setData(NAME_DATA_INDEX, -1) item.setData(TYPE_DATA_INDEX, FileType.Inconsistency) item.setData(ENTRY_ID_DATA_INDEX, entry_id) item.setBackground(inconsistency_color) self.setItem(row_idx, Column.SIZE, item)