Plugins/VcsPlugins/vcsMercurial/HgDiffDialog.py

changeset 3008
7848489bcb92
parent 2771
281c9b30dd91
child 3020
542e97d4ecb3
child 3057
10516539f238
equal deleted inserted replaced
3007:bad2e89047e7 3008:7848489bcb92
22 import Preferences 22 import Preferences
23 23
24 24
25 class HgDiffDialog(QWidget, Ui_HgDiffDialog): 25 class HgDiffDialog(QWidget, Ui_HgDiffDialog):
26 """ 26 """
27 Class implementing a dialog to show the output of the hg diff command process. 27 Class implementing a dialog to show the output of the hg diff command
28 process.
28 """ 29 """
29 def __init__(self, vcs, parent=None): 30 def __init__(self, vcs, parent=None):
30 """ 31 """
31 Constructor 32 Constructor
32 33
92 def start(self, fn, versions=None, bundle=None, qdiff=False): 93 def start(self, fn, versions=None, bundle=None, qdiff=False):
93 """ 94 """
94 Public slot to start the hg diff command. 95 Public slot to start the hg diff command.
95 96
96 @param fn filename to be diffed (string) 97 @param fn filename to be diffed (string)
97 @param versions list of versions to be diffed (list of up to 2 strings or None) 98 @param versions list of versions to be diffed (list of up to 2 strings
99 or None)
98 @param bundle name of a bundle file (string) 100 @param bundle name of a bundle file (string)
99 @param qdiff flag indicating qdiff command shall be used (boolean) 101 @param qdiff flag indicating qdiff command shall be used (boolean)
100 """ 102 """
101 self.errorGroup.hide() 103 self.errorGroup.hide()
102 self.inputGroup.show() 104 self.inputGroup.show()
206 """ 208 """
207 self.__finish() 209 self.__finish()
208 210
209 def __finish(self): 211 def __finish(self):
210 """ 212 """
211 Private slot called when the process finished or the user pressed the button. 213 Private slot called when the process finished or the user pressed
214 the button.
212 """ 215 """
213 QApplication.restoreOverrideCursor() 216 QApplication.restoreOverrideCursor()
214 self.inputGroup.setEnabled(False) 217 self.inputGroup.setEnabled(False)
215 self.inputGroup.hide() 218 self.inputGroup.hide()
216 219
219 self.trUtf8('There is no difference.')) 222 self.trUtf8('There is no difference.'))
220 return 223 return
221 224
222 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(True) 225 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(True)
223 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 226 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
224 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) 227 self.buttonBox.button(QDialogButtonBox.Close).setFocus(
228 Qt.OtherFocusReason)
225 229
226 tc = self.contents.textCursor() 230 tc = self.contents.textCursor()
227 tc.movePosition(QTextCursor.Start) 231 tc.movePosition(QTextCursor.Start)
228 self.contents.setTextCursor(tc) 232 self.contents.setTextCursor(tc)
229 self.contents.ensureCursorVisible() 233 self.contents.ensureCursorVisible()
230 234
231 self.filesCombo.addItem(self.trUtf8("<Start>"), 0) 235 self.filesCombo.addItem(self.trUtf8("<Start>"), 0)
232 self.filesCombo.addItem(self.trUtf8("<End>"), -1) 236 self.filesCombo.addItem(self.trUtf8("<End>"), -1)
233 for oldFile, newFile, pos in sorted(self.__fileSeparators): 237 for oldFile, newFile, pos in sorted(self.__fileSeparators):
234 if oldFile != newFile: 238 if oldFile != newFile:
235 self.filesCombo.addItem("{0}\n{1}".format(oldFile, newFile), pos) 239 self.filesCombo.addItem(
240 "{0}\n{1}".format(oldFile, newFile), pos)
236 else: 241 else:
237 self.filesCombo.addItem(oldFile, pos) 242 self.filesCombo.addItem(oldFile, pos)
238 243
239 def __appendText(self, txt, format): 244 def __appendText(self, txt, format):
240 """ 245 """
270 if line.startswith('---'): 275 if line.startswith('---'):
271 self.__oldFileLine = self.paras 276 self.__oldFileLine = self.paras
272 self.__oldFile = self.__extractFileName(line) 277 self.__oldFile = self.__extractFileName(line)
273 else: 278 else:
274 self.__fileSeparators.append( 279 self.__fileSeparators.append(
275 (self.__oldFile, self.__extractFileName(line), self.__oldFileLine)) 280 (self.__oldFile, self.__extractFileName(line),
281 self.__oldFileLine))
276 282
277 def __processOutputLine(self, line): 283 def __processOutputLine(self, line):
278 """ 284 """
279 Private method to process the lines of output. 285 Private method to process the lines of output.
280 286
369 self.contents.ensureCursorVisible() 375 self.contents.ensureCursorVisible()
370 376
371 # step 2: move cursor to desired line 377 # step 2: move cursor to desired line
372 tc = self.contents.textCursor() 378 tc = self.contents.textCursor()
373 delta = tc.blockNumber() - para 379 delta = tc.blockNumber() - para
374 tc.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor, delta) 380 tc.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor,
381 delta)
375 self.contents.setTextCursor(tc) 382 self.contents.setTextCursor(tc)
376 self.contents.ensureCursorVisible() 383 self.contents.ensureCursorVisible()
377 384
378 @pyqtSlot() 385 @pyqtSlot()
379 def on_saveButton_clicked(self): 386 def on_saveButton_clicked(self):

eric ide

mercurial