예제 #1
0
    def show_selection(self):
        """Show the selected item."""
        # Sync the selection model
        cola.selection_model().set_selection(self.selection())

        selection = self.selected_indexes()
        if not selection:
            return
        category, idx = selection[0]
        # A header item e.g. 'Staged', 'Modified', etc.
        if category == self.idx_header:
            cls = {
                self.idx_staged:
                cmds.DiffStagedSummary,
                self.idx_modified:
                cmds.Diffstat,
                # TODO implement UnmergedSummary
                #self.idx_unmerged: cmds.UnmergedSummary,
                self.idx_untracked:
                cmds.UntrackedSummary,
            }.get(idx, cmds.Diffstat)
            cmds.do(cls)
        # A staged file
        elif category == self.idx_staged:
            cmds.do(cmds.DiffStaged, self.staged())

        # A modified file
        elif category == self.idx_modified:
            cmds.do(cmds.Diff, self.modified())

        elif category == self.idx_unmerged:
            cmds.do(cmds.Diff, self.unmerged())

        elif category == self.idx_untracked:
            cmds.do(cmds.ShowUntracked, self.unstaged())
예제 #2
0
파일: status.py 프로젝트: moreati/git-cola
    def show_selection(self):
        """Show the selected item."""
        # Sync the selection model
        cola.selection_model().set_selection(self.selection())

        selection = self.selected_indexes()
        if not selection:
            return
        category, idx = selection[0]
        # A header item e.g. 'Staged', 'Modified', etc.
        if category == self.idx_header:
            signal = {
                self.idx_staged: signals.staged_summary,
                self.idx_modified: signals.modified_summary,
                self.idx_unmerged: signals.unmerged_summary,
                self.idx_untracked: signals.untracked_summary,
            }.get(idx, signals.diffstat)
            cola.notifier().broadcast(signal)
        # A staged file
        elif category == self.idx_staged:
            cola.notifier().broadcast(signals.diff_staged, self.staged())

        # A modified file
        elif category == self.idx_modified:
            cola.notifier().broadcast(signals.diff, self.modified())

        elif category == self.idx_unmerged:
            cola.notifier().broadcast(signals.diff, self.unmerged())

        elif category == self.idx_untracked:
            cola.notifier().broadcast(signals.show_untracked, self.unstaged())
예제 #3
0
    def show_selection(self):
        """Show the selected item."""
        # Sync the selection model
        cola.selection_model().set_selection(self.selection())

        selection = self.selected_indexes()
        if not selection:
            return
        category, idx = selection[0]
        # A header item e.g. 'Staged', 'Modified', etc.
        if category == self.idx_header:
            cls = {
                self.idx_staged: cmds.DiffStagedSummary,
                self.idx_modified: cmds.Diffstat,
                # TODO implement UnmergedSummary
                #self.idx_unmerged: cmds.UnmergedSummary,
                self.idx_untracked: cmds.UntrackedSummary,
            }.get(idx, cmds.Diffstat)
            cmds.do(cls)
        # A staged file
        elif category == self.idx_staged:
            cmds.do(cmds.DiffStaged, self.staged())

        # A modified file
        elif category == self.idx_modified:
            cmds.do(cmds.Diff, self.modified())

        elif category == self.idx_unmerged:
            cmds.do(cmds.Diff, self.unmerged())

        elif category == self.idx_untracked:
            cmds.background(self, cmds.ShowUntracked, self.unstaged())
예제 #4
0
파일: status.py 프로젝트: mwh/git-cola
    def clicked(self, item=None, idx=None):
        """Called when a repo status tree item is clicked.

        This handles the behavior where clicking on the icon invokes
        the a context-specific action.

        """
        if self.m.read_only():
            return

        # Sync the selection model
        staged, modified, unmerged, untracked = self.selection()
        cola.selection_model().set_selection(staged, modified,
                                             unmerged, untracked)

        # Clear the selection if an empty area was clicked
        selection = self.selected_indexes()
        if not selection:
            if self.mode == self.m.mode_amend:
                cola.notifier().broadcast(signals.set_diff_text, '')
            else:
                cola.notifier().broadcast(signals.reset_mode)
            self.blockSignals(True)
            self.clearSelection()
            self.blockSignals(False)
            return

        if staged:
            qtutils.set_clipboard(staged[0])
        elif modified:
            qtutils.set_clipboard(modified[0])
        elif unmerged:
            qtutils.set_clipboard(unmerged[0])
        elif untracked:
            qtutils.set_clipboard(untracked[0])
예제 #5
0
파일: view.py 프로젝트: moreati/git-cola
    def sync_selection(self):
        """Push selection into the selection model."""
        staged = []
        unmerged = []
        modified = []
        untracked = []
        state = State(staged, unmerged, modified, untracked)

        paths = self.selected_paths()
        model = cola.model()
        model_staged = utils.add_parents(set(model.staged))
        model_modified = utils.add_parents(set(model.modified))
        model_unmerged = utils.add_parents(set(model.unmerged))
        model_untracked = utils.add_parents(set(model.untracked))

        for path in paths:
            if path in model_unmerged:
                unmerged.append(path)
            elif path in model_untracked:
                untracked.append(path)
            elif path in model_staged:
                staged.append(path)
            elif path in model_modified:
                modified.append(path)
            else:
                staged.append(path)
        # Push the new selection into the model.
        cola.selection_model().set_selection(state)
        return paths
예제 #6
0
파일: status.py 프로젝트: kbielefe/git-cola
    def tree_click(self, event):
        """
        Called when a repo status tree item is clicked.

        This handles the behavior where clicking on the icon invokes
        the same appropriate action.

        """
        result = QtGui.QTreeWidget.mouseReleaseEvent(self.tree, event)

        # Sync the selection model
        s, m, um, ut = self.selection()
        cola.selection_model().set_selection(s, m, um, ut)

        # Get the item that was clicked
        item = self.tree.itemAt(event.pos())
        if not item:
            # Nothing was clicked -- reset the display and return
            cola.notifier().broadcast(signals.reset_mode)
            items = self.tree.selectedItems()
            self.tree.blockSignals(True)
            for i in items:
                self.tree.setItemSelected(i, False)
            self.tree.blockSignals(False)
        return result
예제 #7
0
    def sync_selection(self):
        """Push selection into the selection model."""
        staged = []
        modified = []
        unmerged = []
        untracked = []
        paths = self.selected_paths()

        model = cola.model()
        model_staged = set(model.staged)
        model_modified = set(model.modified)
        model_unmerged = set(model.unmerged)
        model_untracked = set(model.untracked)

        for path in paths:
            if path in model_unmerged:
                unmerged.append(path)
            elif path in model_untracked:
                untracked.append(path)
            elif path in model_staged:
                staged.append(path)
            elif path in model_modified:
                modified.append(path)
        # Push the new selection into the model.
        cola.selection_model().set_selection(staged, modified,
                                             unmerged, untracked)
        return paths
예제 #8
0
파일: main.py 프로젝트: kbielefe/git-cola
 def unstage(self):
     """Unstage selected files, or all files if no selection exists."""
     paths = cola.selection_model().staged
     if not paths:
         cola.notifier().broadcast(signals.unstage_all)
     else:
         cola.notifier().broadcast(signals.unstage, paths)
예제 #9
0
파일: action.py 프로젝트: gdebure/git-cola
 def stage(self):
     """Stage selected files, or all files if no selection exists."""
     paths = cola.selection_model().unstaged
     if not paths:
         cmds.do(cmds.StageModified)
     else:
         cmds.do(cmds.Stage, paths)
예제 #10
0
파일: action.py 프로젝트: gdebure/git-cola
 def unstage(self):
     """Unstage selected files, or all files if no selection exists."""
     paths = cola.selection_model().staged
     if not paths:
         cmds.do(cmds.UnstageAll)
     else:
         cmds.do(cmds.Unstage, paths)
예제 #11
0
파일: view.py 프로젝트: moreati/git-cola
 def unstage(self):
     """Unstage selected files, or all files if no selection exists."""
     paths = cola.selection_model().staged
     if not paths:
         cola.notifier().broadcast(signals.unstage_all)
     else:
         cola.notifier().broadcast(signals.unstage, paths)
예제 #12
0
파일: diff.py 프로젝트: dillonko/git-cola
 def process_diff_selection(self, selected=False,
                            staged=True, apply_to_worktree=False,
                            reverse=False):
     """Implement un/staging of selected lines or sections."""
     offset, selection = self.offset_and_selection()
     if cola.selection_model().is_empty():
         return
     cmds.do(cmds.ApplyDiffSelection,
             staged, selected, offset, selection, apply_to_worktree)
예제 #13
0
    def tree_click(self, event):
        """
        Called when a repo status tree item is clicked.

        This handles the behavior where clicking on the icon invokes
        the same appropriate action.

        """
        result = QtGui.QTreeWidget.mousePressEvent(self.tree, event)

        # Sync the selection model
        s, m, um, ut = self.selection()
        cola.selection_model().set_selection(s, m, um, ut)

        # Get the item that was clicked
        item = self.tree.itemAt(event.pos())
        if not item:
            # Nothing was clicked -- reset the display and return
            cola.notifier().broadcast(signals.reset_mode)
            items = self.tree.selectedItems()
            self.tree.blockSignals(True)
            for i in items:
                i.setSelected(False)
            self.tree.blockSignals(False)
            return result

        # An item was clicked -- get its index in the model
        staged, idx = self.index_for_item(item)
        if idx == self.idx_header:
            return result

        if self.model.read_only():
            return result

        # Handle when the icons are clicked
        # TODO query Qt for the event position relative to the icon.
        xpos = event.pos().x()
        if xpos > 45 and xpos < 59:
            if staged:
                cola.notifier().broadcast(signals.unstage, self.staged())
            else:
                cola.notifier().broadcast(signals.stage, self.unstaged())
        return result
예제 #14
0
파일: status.py 프로젝트: moreati/git-cola
    def clicked(self, item=None, idx=None):
        """Called when a repo status tree item is clicked.

        This handles the behavior where clicking on the icon invokes
        the a context-specific action.

        """
        # Sync the selection model
        s = self.selection()
        cola.selection_model().set_selection(s)

        # Clear the selection if an empty area was clicked
        selection = self.selected_indexes()
        if not selection:
            if self.m.amending():
                cola.notifier().broadcast(signals.set_diff_text, '')
            else:
                cola.notifier().broadcast(signals.reset_mode)
            self.blockSignals(True)
            self.clearSelection()
            self.blockSignals(False)
            return
예제 #15
0
    def clicked(self, item=None, idx=None):
        """Called when a repo status tree item is clicked.

        This handles the behavior where clicking on the icon invokes
        the a context-specific action.

        """
        # Sync the selection model
        s = self.selection()
        cola.selection_model().set_selection(s)

        # Clear the selection if an empty area was clicked
        selection = self.selected_indexes()
        if not selection:
            if self.m.amending():
                cmds.do(cmds.SetDiffText, '')
            else:
                cmds.do(cmds.ResetMode)
            self.blockSignals(True)
            self.clearSelection()
            self.blockSignals(False)
            return
예제 #16
0
파일: cmds.py 프로젝트: kbielefe/git-cola
 def __init__(self):
     Unstage.__init__(self, cola.selection_model().staged)
예제 #17
0
파일: cmds.py 프로젝트: moreati/git-cola
 def __init__(self):
     Unstage.__init__(self, cola.selection_model().staged)
예제 #18
0
 def copy_path(self):
     """Copy a selected path to the clipboard"""
     filename = cola.selection_model().filename()
     if filename is not None:
         curdir = os.getcwdu()
         qtutils.set_clipboard(os.path.join(curdir, filename))
예제 #19
0
파일: status.py 프로젝트: moreati/git-cola
 def copy_path(self):
     """Copy a selected path to the clipboard"""
     filename = cola.selection_model().filename()
     if filename is not None:
         curdir = os.getcwdu()
         qtutils.set_clipboard(os.path.join(curdir, filename))