--- a/Plugins/VcsPlugins/vcsSubversion/SvnDiffDialog.py Fri Dec 23 15:29:00 2011 +0100 +++ b/Plugins/VcsPlugins/vcsSubversion/SvnDiffDialog.py Fri Dec 23 17:48:33 2011 +0100 @@ -103,6 +103,12 @@ self.contents.clear() self.paras = 0 + self.filesCombo.clear() + + self.__oldFile = "" + self.__oldFileLine = -1 + self.__fileSeparators = [] + args = [] args.append('diff') self.vcs.addArguments(args, self.vcs.options['global']) @@ -190,6 +196,14 @@ self.contents.setTextCursor(tc) self.contents.ensureCursorVisible() + self.filesCombo.addItem(self.trUtf8("<Start>"), 0) + self.filesCombo.addItem(self.trUtf8("<End>"), -1) + for oldFile, newFile, pos in sorted(self.__fileSeparators): + if oldFile != newFile: + self.filesCombo.addItem("{0}\n{1}".format(oldFile, newFile), pos) + else: + self.filesCombo.addItem(oldFile, pos) + def __appendText(self, txt, format): """ Private method to append text to the end of the contents pane. @@ -203,6 +217,30 @@ self.contents.setCurrentCharFormat(format) self.contents.insertPlainText(txt) + def __extractFileName(self, line): + """ + Private method to extract the file name out of a file separator line. + + @param line line to be processed (string) + @return extracted file name (string) + """ + f = line.split(None, 1)[1] + f = f.rsplit(None, 2)[0] + return f + + def __processFileLine(self, line): + """ + Private slot to process a line giving the old/new file. + + @param line line to be processed (string) + """ + if line.startswith('---'): + self.__oldFileLine = self.paras + self.__oldFile = self.__extractFileName(line) + else: + self.__fileSeparators.append( + (self.__oldFile, self.__extractFileName(line), self.__oldFileLine)) + def __readStdout(self): """ Private slot to handle the readyReadStandardOutput signal. @@ -219,6 +257,10 @@ if self.summaryPath: line = line.replace(self.summaryPath + '/', '') line = " ".join(line.split()) + if line.startswith("---") or \ + line.startswith("+++"): + self.__processFileLine(line) + if line.startswith('+') or line.startswith('>') or line.startswith('A '): format = self.cAddedFormat elif line.startswith('-') or line.startswith('<') or line.startswith('D '): @@ -254,6 +296,39 @@ if button == self.buttonBox.button(QDialogButtonBox.Save): self.on_saveButton_clicked() + @pyqtSlot(int) + def on_filesCombo_activated(self, index): + """ + Private slot to handle the selection of a file. + + @param index activated row (integer) + """ + para = self.filesCombo.itemData(index) + + if para == 0: + tc = self.contents.textCursor() + tc.movePosition(QTextCursor.Start) + self.contents.setTextCursor(tc) + self.contents.ensureCursorVisible() + elif para == -1: + tc = self.contents.textCursor() + tc.movePosition(QTextCursor.End) + self.contents.setTextCursor(tc) + self.contents.ensureCursorVisible() + else: + # step 1: move cursor to end + tc = self.contents.textCursor() + tc.movePosition(QTextCursor.End) + self.contents.setTextCursor(tc) + self.contents.ensureCursorVisible() + + # step 2: move cursor to desired line + tc = self.contents.textCursor() + delta = tc.blockNumber() - para + tc.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor, delta) + self.contents.setTextCursor(tc) + self.contents.ensureCursorVisible() + @pyqtSlot() def on_saveButton_clicked(self): """