14 pass |
15 pass |
15 |
16 |
16 import os |
17 import os |
17 |
18 |
18 from PyQt4.QtCore import QTimer, QFileInfo, QProcess, pyqtSlot, Qt |
19 from PyQt4.QtCore import QTimer, QFileInfo, QProcess, pyqtSlot, Qt |
19 from PyQt4.QtGui import QWidget, QColor, QLineEdit, QBrush, QTextCursor, QDialogButtonBox |
20 from PyQt4.QtGui import QWidget, QColor, QLineEdit, QBrush, QTextCursor, \ |
|
21 QDialogButtonBox |
20 |
22 |
21 from E5Gui.E5Application import e5App |
23 from E5Gui.E5Application import e5App |
22 from E5Gui import E5MessageBox, E5FileDialog |
24 from E5Gui import E5MessageBox, E5FileDialog |
23 |
25 |
24 from .Ui_SvnDiffDialog import Ui_SvnDiffDialog |
26 from .Ui_SvnDiffDialog import Ui_SvnDiffDialog |
92 def start(self, fn, versions=None, urls=None, summary=False): |
95 def start(self, fn, versions=None, urls=None, summary=False): |
93 """ |
96 """ |
94 Public slot to start the svn diff command. |
97 Public slot to start the svn diff command. |
95 |
98 |
96 @param fn filename to be diffed (string) |
99 @param fn filename to be diffed (string) |
97 @param versions list of versions to be diffed (list of up to 2 strings or None) |
100 @param versions list of versions to be diffed (list of up to 2 strings |
|
101 or None) |
98 @keyparam urls list of repository URLs (list of 2 strings) |
102 @keyparam urls list of repository URLs (list of 2 strings) |
99 @keyparam summary flag indicating a summarizing diff |
103 @keyparam summary flag indicating a summarizing diff |
100 (only valid for URL diffs) (boolean) |
104 (only valid for URL diffs) (boolean) |
101 """ |
105 """ |
102 self.errorGroup.hide() |
106 self.errorGroup.hide() |
198 self.trUtf8('There is no difference.')) |
202 self.trUtf8('There is no difference.')) |
199 return |
203 return |
200 |
204 |
201 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(True) |
205 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(True) |
202 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
206 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
203 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) |
207 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
|
208 Qt.OtherFocusReason) |
204 |
209 |
205 tc = self.contents.textCursor() |
210 tc = self.contents.textCursor() |
206 tc.movePosition(QTextCursor.Start) |
211 tc.movePosition(QTextCursor.Start) |
207 self.contents.setTextCursor(tc) |
212 self.contents.setTextCursor(tc) |
208 self.contents.ensureCursorVisible() |
213 self.contents.ensureCursorVisible() |
209 |
214 |
210 self.filesCombo.addItem(self.trUtf8("<Start>"), 0) |
215 self.filesCombo.addItem(self.trUtf8("<Start>"), 0) |
211 self.filesCombo.addItem(self.trUtf8("<End>"), -1) |
216 self.filesCombo.addItem(self.trUtf8("<End>"), -1) |
212 for oldFile, newFile, pos in sorted(self.__fileSeparators): |
217 for oldFile, newFile, pos in sorted(self.__fileSeparators): |
213 if oldFile != newFile: |
218 if oldFile != newFile: |
214 self.filesCombo.addItem("{0}\n{1}".format(oldFile, newFile), pos) |
219 self.filesCombo.addItem( |
|
220 "{0}\n{1}".format(oldFile, newFile), pos) |
215 else: |
221 else: |
216 self.filesCombo.addItem(oldFile, pos) |
222 self.filesCombo.addItem(oldFile, pos) |
217 |
223 |
218 def __appendText(self, txt, format): |
224 def __appendText(self, txt, format): |
219 """ |
225 """ |
248 if line.startswith('---'): |
254 if line.startswith('---'): |
249 self.__oldFileLine = self.paras |
255 self.__oldFileLine = self.paras |
250 self.__oldFile = self.__extractFileName(line) |
256 self.__oldFile = self.__extractFileName(line) |
251 else: |
257 else: |
252 self.__fileSeparators.append( |
258 self.__fileSeparators.append( |
253 (self.__oldFile, self.__extractFileName(line), self.__oldFileLine)) |
259 (self.__oldFile, self.__extractFileName(line), |
|
260 self.__oldFileLine)) |
254 |
261 |
255 def __readStdout(self): |
262 def __readStdout(self): |
256 """ |
263 """ |
257 Private slot to handle the readyReadStandardOutput signal. |
264 Private slot to handle the readyReadStandardOutput signal. |
258 |
265 |
270 line = " ".join(line.split()) |
277 line = " ".join(line.split()) |
271 if line.startswith("--- ") or \ |
278 if line.startswith("--- ") or \ |
272 line.startswith("+++ "): |
279 line.startswith("+++ "): |
273 self.__processFileLine(line) |
280 self.__processFileLine(line) |
274 |
281 |
275 if line.startswith('+') or line.startswith('>') or line.startswith('A '): |
282 if line.startswith('+') or line.startswith('>') or \ |
|
283 line.startswith('A '): |
276 format = self.cAddedFormat |
284 format = self.cAddedFormat |
277 elif line.startswith('-') or line.startswith('<') or line.startswith('D '): |
285 elif line.startswith('-') or line.startswith('<') or \ |
|
286 line.startswith('D '): |
278 format = self.cRemovedFormat |
287 format = self.cRemovedFormat |
279 elif line.startswith('@@'): |
288 elif line.startswith('@@'): |
280 format = self.cLineNoFormat |
289 format = self.cLineNoFormat |
281 else: |
290 else: |
282 format = self.cNormalFormat |
291 format = self.cNormalFormat |
334 self.contents.ensureCursorVisible() |
343 self.contents.ensureCursorVisible() |
335 |
344 |
336 # step 2: move cursor to desired line |
345 # step 2: move cursor to desired line |
337 tc = self.contents.textCursor() |
346 tc = self.contents.textCursor() |
338 delta = tc.blockNumber() - para |
347 delta = tc.blockNumber() - para |
339 tc.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor, delta) |
348 tc.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor, |
|
349 delta) |
340 self.contents.setTextCursor(tc) |
350 self.contents.setTextCursor(tc) |
341 self.contents.ensureCursorVisible() |
351 self.contents.ensureCursorVisible() |
342 |
352 |
343 @pyqtSlot() |
353 @pyqtSlot() |
344 def on_saveButton_clicked(self): |
354 def on_saveButton_clicked(self): |