コード例 #1
0
ファイル: status.py プロジェクト: ciaravero/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
        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.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

        filename = cola.selection_model().filename()
        if filename is not None:
            qtutils.set_clipboard(filename)
コード例 #2
0
ファイル: view.py プロジェクト: dcfrancisco/git-cola
 def _commits_selected(self, commits):
     if len(commits) != 1:
         return
     commit = commits[0]
     sha1 = commit.sha1
     merge = len(commit.parents) > 1
     self.diff.setText(gitcmds.diff_info(sha1, merge=merge))
     qtutils.set_clipboard(sha1)
コード例 #3
0
 def display(self, *args):
     revision = self.selected_revision()
     if revision is None:
         self.commit_text.setText('')
     else:
         qtutils.set_clipboard(revision)
         diff = gitcmds.commit_diff(revision)
         self.commit_text.setText(diff)
コード例 #4
0
ファイル: search.py プロジェクト: Jobava/git-cola
 def display(self, *args):
     revision = self.selected_revision()
     if revision is None:
         self.commit_text.setText('')
     else:
         qtutils.set_clipboard(revision)
         diff = gitcmds.commit_diff(revision)
         self.commit_text.setText(diff)
コード例 #5
0
ファイル: search.py プロジェクト: johnpaulett/git-cola
 def display_callback(self, *args):
     widget = self.view.commit_list
     row, selected = qtutils.selected_row(widget)
     if not selected or len(self.results) < row:
         return
     revision = self.results[row][0]
     qtutils.set_clipboard(revision)
     diff = gitcmds.commit_diff(revision)
     self.view.commit_text.setText(diff)
コード例 #6
0
ファイル: search.py プロジェクト: yjpark/git-cola
 def display(self, *args):
     widget = self.commit_list
     row, selected = qtutils.selected_row(widget)
     if not selected or len(self.results) < row:
         self.commit_text.setText('')
         return
     revision = self.results[row][0]
     qtutils.set_clipboard(revision)
     diff = gitcmds.commit_diff(revision)
     self.commit_text.setText(diff)
コード例 #7
0
ファイル: status.py プロジェクト: pombredanne/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.model.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.model.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])
コード例 #8
0
ファイル: compare.py プロジェクト: kbielefe/git-cola
    def update_widgets(self, left=True):
        """Updates the list of available revisions for comparison
        """
        # This callback can be triggered by either the 'start'
        # listwidget or the 'end' list widget.  The behavior
        # is identical; the only difference is the attribute names.
        if left:
            tree_widget = self.view.descriptions_start
            revisions_param = 'revisions_start'
            revision_param = 'revision_start'
        else:
            tree_widget = self.view.descriptions_end
            revisions_param = 'revisions_end'
            revision_param = 'revision_end'

        # Is anything selected?
        id_num, selected = qtutils.selected_treeitem(tree_widget)
        if not selected:
            return

        # Is this a valid revision?
        revisionlist = self.model.param(revisions_param)
        if id_num < len(revisionlist):
            revision = self.model.param(revisions_param)[id_num]
            self.model.set_param(revision_param, revision)

        # get the changed files list
        start = self.model.revision_start
        end = self.model.revision_end
        files = gitcmds.changed_files(start, end)

        # get the old name of any renamed files, and prune them
        # from the changes list
        renamed_files = gitcmds.renamed_files(start, end)
        for renamed in renamed_files:
            try:
                files.remove(renamed)
            except:
                pass
        # Sets the "changed files" list
        self.model.set_compare_files(files)

        # Updates the listwidget's icons
        icon = qtutils.icon('script.png')
        for idx in xrange(0, self.view.compare_files.topLevelItemCount()):
            item = self.view.compare_files.topLevelItem(idx)
            item.setIcon(0, icon)
        # Throw the selected SHA-1 into the clipboard
        qtutils.set_clipboard(self.model.param(revision_param))
コード例 #9
0
ファイル: repobrowser.py プロジェクト: kbielefe/git-cola
    def item_changed(self,*rest):
        """Called when the current item changes"""
        current = self.view.commit_list.currentRow()
        item = self.view.commit_list.item(current)
        if item is None or not item.isSelected():
            self.view.revision.setText('')
            self.view.commit_text.setText('')
            return
        directories = self.model.directories
        directory_entries = self.model.directory_entries
        if current < len(directories):
            # This is a directory...
            self.filename = None
            dirent = directories[current]
            if dirent != '..':
                # This is a real directory for which
                # we have child entries
                entries = directory_entries[dirent]
            else:
                # This is '..' which is a special case
                # since it doesn't really exist
                entries = []
            self.view.commit_text.setText('\n'.join(entries))
            self.view.revision.setText('')
        else:
            # This is a file entry.  The current row is absolute,
            # so get a relative index by subtracting the number
            # of directory entries
            idx = current - len(directories)
            if idx >= len(self.model.subtree_sha1s):
                # This can happen when changing directories
                self.filename = None
                return
            objtype, sha1, name = self.model.subtree_node(idx)

            curdir = self.model.directory
            if curdir:
                self.filename = os.path.join(curdir, name)
            else:
                self.filename = name

            catguts = git.cat_file(objtype, sha1, with_raw_output=True)
            self.view.commit_text.setText(catguts)

            self.view.revision.setText(sha1)
            self.view.revision.selectAll()

            # Copy the sha1 into the clipboard
            qtutils.set_clipboard(sha1)
コード例 #10
0
ファイル: selectcommits.py プロジェクト: johnpaulett/git-cola
    def commit_sha1_selected(self):
        row, selected = qtutils.selected_row(self.view.commit_list)
        if not selected:
            self.view.commit_text.setText('')
            self.view.revision.setText('')
            return
        # Get the sha1 and put it in the revision line
        sha1 = self.model.revision_sha1(row)
        self.view.revision.setText(sha1)
        self.view.revision.selectAll()

        # Lookup the sha1's commit
        commit_diff = gitcmds.commit_diff(sha1)
        self.view.commit_text.setText(commit_diff)

        # Copy the sha1 into the clipboard
        qtutils.set_clipboard(sha1)
コード例 #11
0
ファイル: status.py プロジェクト: kbielefe/git-cola
 def tree_click(self, column=None):
     """Called when an item is clicked in the repo status tree."""
     if self.model.read_only():
         return
     staged, modified, unmerged, untracked = self.selection()
     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])
コード例 #12
0
 def copy_path(self):
     """Copy a selected path to the clipboard"""
     filename = selection.selection_model().filename()
     if filename is not None:
         curdir = os.getcwdu()
         qtutils.set_clipboard(os.path.join(curdir, filename))
コード例 #13
0
ファイル: bookmarks.py プロジェクト: PauloVAF/git-cola
 def copy(self):
     item = self.selected_item()
     if not item:
         return
     qtutils.set_clipboard(item.path)
コード例 #14
0
ファイル: dag.py プロジェクト: PauloVAF/git-cola
 def copy_to_clipboard(self):
     sha1 = self.selected_sha1()
     if sha1 is None:
         return
     qtutils.set_clipboard(sha1)
コード例 #15
0
ファイル: bookmarks.py プロジェクト: wmwong/git-cola
 def copy(self):
     item = self.selected_item()
     if not item:
         return
     qtutils.set_clipboard(item.path)
コード例 #16
0
ファイル: bookmarks.py プロジェクト: assem-ch/git-cola
 def copy(self):
     self.apply_fn(lambda item: qtutils.set_clipboard(item.path))
コード例 #17
0
ファイル: dag.py プロジェクト: B-Rich/git-cola
 def copy_to_clipboard(self):
     sha1 = self.selected_sha1()
     if sha1 is None:
         return
     qtutils.set_clipboard(sha1)
コード例 #18
0
ファイル: status.py プロジェクト: jamie-pate/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))
コード例 #19
0
ファイル: main.py プロジェクト: kbielefe/git-cola
 def copy_display(self):
     cursor = self.display_text.textCursor()
     selection = cursor.selection().toPlainText()
     qtutils.set_clipboard(selection)
コード例 #20
0
ファイル: main.py プロジェクト: kbielefe/git-cola
 def action_copy(self):
     cursor = self.commitmsg.textCursor()
     selection = cursor.selection().toPlainText()
     qtutils.set_clipboard(selection)
コード例 #21
0
 def copy(self):
     self.apply_fn(lambda item: qtutils.set_clipboard(item.path))
コード例 #22
0
 def copy_oid(self):
     item = self.selected_item()
     if item is None:
         return
     clipboard = item.oid or item.cmdexec
     qtutils.set_clipboard(clipboard)