Beispiel #1
0
 def data(self, index, role):
     if not index.isValid():
         return None
     item = model_item(index)
     if role == Qt.DisplayRole:
         return self.column_getters[index.column()](item)
     if role == Qt.DecorationRole:
         if index.column() > 0:
             return None
         return apply_status_to_icon(self.icon_provider[item.os_path],
             item.index_status, item.work_tree_status)
Beispiel #2
0
 def create_ui(self):
     super(FileView, self).create_ui()
     self.toggle_deep_button.setIcon(QApplication.style().standardIcon(
         QStyle.SP_DirIcon))
     self.toggle_deep_button.toggled.connect(self.deep_toggled)
     self.toggle_unmodified_button.setIcon(apply_status_to_icon(
         QApplication.style().standardIcon(QStyle.SP_FileIcon),
         git_api.UNMODIFIED, git_api.UNMODIFIED))
     self.toggle_unmodified_button.toggled.connect(self.toggle_filter(
         exclude_unmodified))
     self.toggle_untracked_button.setIcon(apply_status_to_icon(
         QApplication.style().standardIcon(QStyle.SP_FileIcon),
         git_api.UNTRACKED, git_api.UNTRACKED))
     self.toggle_untracked_button.toggled.connect(self.toggle_filter(
         exclude_untracked))
     self.toggle_ignored_button.setIcon(apply_status_to_icon(
         QApplication.style().standardIcon(QStyle.SP_FileIcon),
         git_api.IGNORED, git_api.IGNORED))
     self.toggle_ignored_button.toggled.connect(self.toggle_filter(
         exclude_ignored))
     self.filter_text.textEdited.connect(self.filter_text_edited)
     workspace = self.app.workspace
     self._directory = None
     self._file_lister = shallow_file_list
     self.file_model = FileModel(workspace, parent=self)
     self.file_model.file_source = lambda: (self._file_lister(self._directory)
         if self._directory else None)
     self.filter_model = FilterModel(parent=self)
     self.filter_model.setSourceModel(self.file_model)
     self.file_list.setModel(self.filter_model)
     # We must assign the selection model to a variable, to avoid triggering
     # a segfault bug (temporary PyObject* destroyed prematurely)
     # see https://bugreports.qt-project.org/browse/PYSIDE-79
     selection_model = self.file_list.selectionModel()
     selection_model.currentChanged.connect(self.current_item_changed)
     selection_model.selectionChanged.connect(self.item_selection_changed)
     self.app.view_focus_out[self] += self.lost_focus
     self.app.view_focus_in[self] += self.gained_focus
Beispiel #3
0
 def data(self, index, role):
     if not index.isValid():
         return None
     item = self.changeset[index.row()]
     if role == Qt.DisplayRole:
         return self.column_getters[index.column()](item)
     if role == Qt.DecorationRole:
         if index.column() > 0:
             return None
         workspace_item = self.repo.resolve(
             item.new_path or item.path)
         return apply_status_to_icon(
             self.icon_provider[workspace_item.os_path],
             workspace_item.index_status, workspace_item.work_tree_status)