def reset_interface(self, models): """ Resets the filter tab (usually after a directory change). """ current_branch = self._parent.current_branch self._models = models self._model = self._models[current_branch] self.gui.tableView.setModel(self._model) self.gui.tableView.verticalHeader().hide() self.gui.tableView.setItemDelegate(QGitDelegate(self.gui.tableView)) custom_resize_columns_to_contents(self.gui.tableView) self.gui.tableView.horizontalHeader().setStretchLastSection(True) self.create_checkboxes() index = 0 self.gui.currentBranchComboBox.clear() for branch in self._models: self.gui.currentBranchComboBox.addItem("%s" % str(branch)) if branch == current_branch: current_index = index index += 1 self.gui.currentBranchComboBox.setCurrentIndex(current_index)
def refresh_display_options(self, resize=True): """ When a "display option" is checked or unchecked, we set the display options on the model. """ model = self.gui.tableView.model() for option_name in AVAILABLE_OPTIONS: if self._checkboxes[option_name].isChecked(): model.enable_option(option_name) else: model.disable_option(option_name) if resize: custom_resize_columns_to_contents(self.gui.tableView) self.gui.tableView.horizontalHeader().setStretchLastSection(True)
def refresh_checkboxes(self, resize=True): """ When a "column checkbox" is checked or unchecked, we change the view's displayed columns model so that only the selected columns are displayed. """ self._shown_columns = [] for checkbox_name in AVAILABLE_CHOICES: column_index = AVAILABLE_CHOICES.index(checkbox_name) if self._checkboxes[checkbox_name].isChecked(): self.gui.tableView.showColumn(column_index) self._shown_columns.append(column_index) else: self.gui.tableView.hideColumn(column_index) if resize: custom_resize_columns_to_contents(self.gui.tableView) self.gui.tableView.horizontalHeader().setStretchLastSection(True)
def resize_table_view(self): """ Resize the table view to its contents. """ custom_resize_columns_to_contents(self._table_view) self._table_view.horizontalHeader().setStretchLastSection(True)