15 pass |
15 pass |
16 |
16 |
17 import os |
17 import os |
18 |
18 |
19 from PyQt5.QtCore import QTimer, QFileInfo, QProcess, pyqtSlot, Qt |
19 from PyQt5.QtCore import QTimer, QFileInfo, QProcess, pyqtSlot, Qt |
20 from PyQt5.QtGui import QColor, QBrush, QTextCursor |
20 from PyQt5.QtGui import QTextCursor |
21 from PyQt5.QtWidgets import QWidget, QLineEdit, QDialogButtonBox |
21 from PyQt5.QtWidgets import QWidget, QLineEdit, QDialogButtonBox |
22 |
22 |
23 from E5Gui.E5Application import e5App |
23 from E5Gui.E5Application import e5App |
24 from E5Gui import E5MessageBox, E5FileDialog |
24 from E5Gui import E5MessageBox, E5FileDialog |
25 |
25 |
26 from .Ui_SvnDiffDialog import Ui_SvnDiffDialog |
26 from .Ui_SvnDiffDialog import Ui_SvnDiffDialog |
|
27 from .SvnDiffHighlighter import SvnDiffHighlighter |
27 |
28 |
28 import Utilities |
29 import Utilities |
29 import Preferences |
30 import Preferences |
30 |
31 |
31 |
32 |
59 |
60 |
60 font = Preferences.getEditorOtherFonts("MonospacedFont") |
61 font = Preferences.getEditorOtherFonts("MonospacedFont") |
61 self.contents.setFontFamily(font.family()) |
62 self.contents.setFontFamily(font.family()) |
62 self.contents.setFontPointSize(font.pointSize()) |
63 self.contents.setFontPointSize(font.pointSize()) |
63 |
64 |
64 self.cNormalFormat = self.contents.currentCharFormat() |
65 self.highlighter = SvnDiffHighlighter(self.contents.document()) |
65 self.cAddedFormat = self.contents.currentCharFormat() |
|
66 self.cAddedFormat.setBackground(QBrush(QColor(190, 237, 190))) |
|
67 self.cRemovedFormat = self.contents.currentCharFormat() |
|
68 self.cRemovedFormat.setBackground(QBrush(QColor(237, 190, 190))) |
|
69 self.cLineNoFormat = self.contents.currentCharFormat() |
|
70 self.cLineNoFormat.setBackground(QBrush(QColor(255, 220, 168))) |
|
71 |
66 |
72 self.process.finished.connect(self.__procFinished) |
67 self.process.finished.connect(self.__procFinished) |
73 self.process.readyReadStandardOutput.connect(self.__readStdout) |
68 self.process.readyReadStandardOutput.connect(self.__readStdout) |
74 self.process.readyReadStandardError.connect(self.__readStderr) |
69 self.process.readyReadStandardError.connect(self.__readStderr) |
75 |
70 |
210 self.inputGroup.setEnabled(False) |
205 self.inputGroup.setEnabled(False) |
211 self.inputGroup.hide() |
206 self.inputGroup.hide() |
212 self.refreshButton.setEnabled(True) |
207 self.refreshButton.setEnabled(True) |
213 |
208 |
214 if self.paras == 0: |
209 if self.paras == 0: |
215 self.contents.setCurrentCharFormat(self.cNormalFormat) |
210 self.contents.setPlainText(self.tr('There is no difference.')) |
216 self.contents.setPlainText( |
|
217 self.tr('There is no difference.')) |
|
218 |
211 |
219 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(self.paras > 0) |
212 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(self.paras > 0) |
220 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
213 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
221 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
214 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
222 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
215 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
234 self.filesCombo.addItem( |
227 self.filesCombo.addItem( |
235 "{0}\n{1}".format(oldFile, newFile), pos) |
228 "{0}\n{1}".format(oldFile, newFile), pos) |
236 else: |
229 else: |
237 self.filesCombo.addItem(oldFile, pos) |
230 self.filesCombo.addItem(oldFile, pos) |
238 |
231 |
239 def __appendText(self, txt, format): |
232 def __appendText(self, txt): |
240 """ |
233 """ |
241 Private method to append text to the end of the contents pane. |
234 Private method to append text to the end of the contents pane. |
242 |
235 |
243 @param txt text to insert (string) |
236 @param txt text to insert (string) |
244 @param format text format to be used (QTextCharFormat) |
|
245 """ |
237 """ |
246 tc = self.contents.textCursor() |
238 tc = self.contents.textCursor() |
247 tc.movePosition(QTextCursor.End) |
239 tc.movePosition(QTextCursor.End) |
248 self.contents.setTextCursor(tc) |
240 self.contents.setTextCursor(tc) |
249 self.contents.setCurrentCharFormat(format) |
|
250 self.contents.insertPlainText(txt) |
241 self.contents.insertPlainText(txt) |
251 |
242 |
252 def __extractFileName(self, line): |
243 def __extractFileName(self, line): |
253 """ |
244 """ |
254 Private method to extract the file name out of a file separator line. |
245 Private method to extract the file name out of a file separator line. |
291 line = line.replace(self.summaryPath + '/', '') |
282 line = line.replace(self.summaryPath + '/', '') |
292 line = " ".join(line.split()) |
283 line = " ".join(line.split()) |
293 if line.startswith("--- ") or line.startswith("+++ "): |
284 if line.startswith("--- ") or line.startswith("+++ "): |
294 self.__processFileLine(line) |
285 self.__processFileLine(line) |
295 |
286 |
296 if line.startswith('+') or line.startswith('>') or \ |
287 self.__appendText(line) |
297 line.startswith('A '): |
|
298 format = self.cAddedFormat |
|
299 elif line.startswith('-') or line.startswith('<') or \ |
|
300 line.startswith('D '): |
|
301 format = self.cRemovedFormat |
|
302 elif line.startswith('@@'): |
|
303 format = self.cLineNoFormat |
|
304 else: |
|
305 format = self.cNormalFormat |
|
306 self.__appendText(line, format) |
|
307 self.paras += 1 |
288 self.paras += 1 |
308 |
289 |
309 def __readStderr(self): |
290 def __readStderr(self): |
310 """ |
291 """ |
311 Private slot to handle the readyReadStandardError signal. |
292 Private slot to handle the readyReadStandardError signal. |