eric6/Plugins/VcsPlugins/vcsPySvn/SvnDiffDialog.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8176
31965986ecd1
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
44 super(SvnDiffDialog, self).__init__(parent) 44 super(SvnDiffDialog, self).__init__(parent)
45 self.setupUi(self) 45 self.setupUi(self)
46 SvnDialogMixin.__init__(self) 46 SvnDialogMixin.__init__(self)
47 47
48 self.refreshButton = self.buttonBox.addButton( 48 self.refreshButton = self.buttonBox.addButton(
49 self.tr("Refresh"), QDialogButtonBox.ActionRole) 49 self.tr("Refresh"), QDialogButtonBox.ButtonRole.ActionRole)
50 self.refreshButton.setToolTip( 50 self.refreshButton.setToolTip(
51 self.tr("Press to refresh the display")) 51 self.tr("Press to refresh the display"))
52 self.refreshButton.setEnabled(False) 52 self.refreshButton.setEnabled(False)
53 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False) 53 self.buttonBox.button(
54 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 54 QDialogButtonBox.StandardButton.Save).setEnabled(False)
55 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 55 self.buttonBox.button(
56 QDialogButtonBox.StandardButton.Close).setEnabled(False)
57 self.buttonBox.button(
58 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
56 59
57 self.searchWidget.attachTextEdit(self.contents) 60 self.searchWidget.attachTextEdit(self.contents)
58 61
59 self.vcs = vcs 62 self.vcs = vcs
60 63
80 """ 83 """
81 if isinstance(version, int): 84 if isinstance(version, int):
82 return pysvn.Revision(pysvn.opt_revision_kind.number, version) 85 return pysvn.Revision(pysvn.opt_revision_kind.number, version)
83 elif version.startswith("{"): 86 elif version.startswith("{"):
84 dateStr = version[1:-1] 87 dateStr = version[1:-1]
85 secs = QDateTime.fromString(dateStr, Qt.ISODate).toTime_t() 88 secs = QDateTime.fromString(
89 dateStr, Qt.DateFormat.ISODate).toTime_t()
86 return pysvn.Revision(pysvn.opt_revision_kind.date, secs) 90 return pysvn.Revision(pysvn.opt_revision_kind.date, secs)
87 elif version == "HEAD": 91 elif version == "HEAD":
88 return pysvn.Revision(pysvn.opt_revision_kind.head) 92 return pysvn.Revision(pysvn.opt_revision_kind.head)
89 elif version == "COMMITTED": 93 elif version == "COMMITTED":
90 return pysvn.Revision(pysvn.opt_revision_kind.committed) 94 return pysvn.Revision(pysvn.opt_revision_kind.committed)
129 @param pegRev revision number the filename is valid (integer) 133 @param pegRev revision number the filename is valid (integer)
130 @param refreshable flag indicating a refreshable diff (boolean) 134 @param refreshable flag indicating a refreshable diff (boolean)
131 """ 135 """
132 self.refreshButton.setVisible(refreshable) 136 self.refreshButton.setVisible(refreshable)
133 137
134 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False) 138 self.buttonBox.button(
135 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 139 QDialogButtonBox.StandardButton.Save).setEnabled(False)
136 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 140 self.buttonBox.button(
137 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 141 QDialogButtonBox.StandardButton.Close).setEnabled(False)
142 self.buttonBox.button(
143 QDialogButtonBox.StandardButton.Cancel).setEnabled(True)
144 self.buttonBox.button(
145 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
138 146
139 self._reset() 147 self._reset()
140 self.errorGroup.hide() 148 self.errorGroup.hide()
141 149
142 self.filename = fn 150 self.filename = fn
268 self.__finish() 276 self.__finish()
269 277
270 if self.paras == 0: 278 if self.paras == 0:
271 self.contents.setPlainText(self.tr('There is no difference.')) 279 self.contents.setPlainText(self.tr('There is no difference.'))
272 280
273 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(self.paras > 0) 281 self.buttonBox.button(
282 QDialogButtonBox.StandardButton.Save).setEnabled(self.paras > 0)
274 283
275 def __appendText(self, line): 284 def __appendText(self, line):
276 """ 285 """
277 Private method to append text to the end of the contents pane. 286 Private method to append text to the end of the contents pane.
278 287
279 @param line line of text to insert (string) 288 @param line line of text to insert (string)
280 """ 289 """
281 tc = self.contents.textCursor() 290 tc = self.contents.textCursor()
282 tc.movePosition(QTextCursor.End) 291 tc.movePosition(QTextCursor.MoveOperation.End)
283 self.contents.setTextCursor(tc) 292 self.contents.setTextCursor(tc)
284 self.contents.insertPlainText(line) 293 self.contents.insertPlainText(line)
285 self.paras += 1 294 self.paras += 1
286 295
287 def __extractFileName(self, line): 296 def __extractFileName(self, line):
312 def __finish(self): 321 def __finish(self):
313 """ 322 """
314 Private slot called when the user pressed the button. 323 Private slot called when the user pressed the button.
315 """ 324 """
316 self.refreshButton.setEnabled(True) 325 self.refreshButton.setEnabled(True)
317 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 326 self.buttonBox.button(
318 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 327 QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
319 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 328 self.buttonBox.button(
320 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 329 QDialogButtonBox.StandardButton.Close).setEnabled(True)
330 self.buttonBox.button(
331 QDialogButtonBox.StandardButton.Close).setEnabled(True)
332 self.buttonBox.button(
333 QDialogButtonBox.StandardButton.Close).setDefault(True)
321 334
322 tc = self.contents.textCursor() 335 tc = self.contents.textCursor()
323 tc.movePosition(QTextCursor.Start) 336 tc.movePosition(QTextCursor.MoveOperation.Start)
324 self.contents.setTextCursor(tc) 337 self.contents.setTextCursor(tc)
325 self.contents.ensureCursorVisible() 338 self.contents.ensureCursorVisible()
326 339
327 self.filesCombo.addItem(self.tr("<Start>"), 0) 340 self.filesCombo.addItem(self.tr("<Start>"), 0)
328 self.filesCombo.addItem(self.tr("<End>"), -1) 341 self.filesCombo.addItem(self.tr("<End>"), -1)
339 """ 352 """
340 Private slot called by a button of the button box clicked. 353 Private slot called by a button of the button box clicked.
341 354
342 @param button button that was clicked (QAbstractButton) 355 @param button button that was clicked (QAbstractButton)
343 """ 356 """
344 if button == self.buttonBox.button(QDialogButtonBox.Close): 357 if button == self.buttonBox.button(
358 QDialogButtonBox.StandardButton.Close
359 ):
345 self.close() 360 self.close()
346 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): 361 elif button == self.buttonBox.button(
362 QDialogButtonBox.StandardButton.Cancel
363 ):
347 self.__finish() 364 self.__finish()
348 elif button == self.buttonBox.button(QDialogButtonBox.Save): 365 elif button == self.buttonBox.button(
366 QDialogButtonBox.StandardButton.Save
367 ):
349 self.on_saveButton_clicked() 368 self.on_saveButton_clicked()
350 elif button == self.refreshButton: 369 elif button == self.refreshButton:
351 self.on_refreshButton_clicked() 370 self.on_refreshButton_clicked()
352 371
353 @pyqtSlot(int) 372 @pyqtSlot(int)
359 """ 378 """
360 para = self.filesCombo.itemData(index) 379 para = self.filesCombo.itemData(index)
361 380
362 if para == 0: 381 if para == 0:
363 tc = self.contents.textCursor() 382 tc = self.contents.textCursor()
364 tc.movePosition(QTextCursor.Start) 383 tc.movePosition(QTextCursor.MoveOperation.Start)
365 self.contents.setTextCursor(tc) 384 self.contents.setTextCursor(tc)
366 self.contents.ensureCursorVisible() 385 self.contents.ensureCursorVisible()
367 elif para == -1: 386 elif para == -1:
368 tc = self.contents.textCursor() 387 tc = self.contents.textCursor()
369 tc.movePosition(QTextCursor.End) 388 tc.movePosition(QTextCursor.MoveOperation.End)
370 self.contents.setTextCursor(tc) 389 self.contents.setTextCursor(tc)
371 self.contents.ensureCursorVisible() 390 self.contents.ensureCursorVisible()
372 else: 391 else:
373 # step 1: move cursor to end 392 # step 1: move cursor to end
374 tc = self.contents.textCursor() 393 tc = self.contents.textCursor()
375 tc.movePosition(QTextCursor.End) 394 tc.movePosition(QTextCursor.MoveOperation.End)
376 self.contents.setTextCursor(tc) 395 self.contents.setTextCursor(tc)
377 self.contents.ensureCursorVisible() 396 self.contents.ensureCursorVisible()
378 397
379 # step 2: move cursor to desired line 398 # step 2: move cursor to desired line
380 tc = self.contents.textCursor() 399 tc = self.contents.textCursor()
381 delta = tc.blockNumber() - para 400 delta = tc.blockNumber() - para
382 tc.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor, 401 tc.movePosition(
383 delta) 402 QTextCursor.MoveOperation.PreviousBlock,
403 QTextCursor.MoveMode.MoveAnchor,
404 delta)
384 self.contents.setTextCursor(tc) 405 self.contents.setTextCursor(tc)
385 self.contents.ensureCursorVisible() 406 self.contents.ensureCursorVisible()
386 407
387 @pyqtSlot() 408 @pyqtSlot()
388 def on_saveButton_clicked(self): 409 def on_saveButton_clicked(self):
446 @pyqtSlot() 467 @pyqtSlot()
447 def on_refreshButton_clicked(self): 468 def on_refreshButton_clicked(self):
448 """ 469 """
449 Private slot to refresh the display. 470 Private slot to refresh the display.
450 """ 471 """
451 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 472 self.buttonBox.button(
452 473 QDialogButtonBox.StandardButton.Close).setEnabled(False)
453 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False) 474
475 self.buttonBox.button(
476 QDialogButtonBox.StandardButton.Save).setEnabled(False)
454 self.refreshButton.setEnabled(False) 477 self.refreshButton.setEnabled(False)
455 478
456 self.start(self.filename, refreshable=True) 479 self.start(self.filename, refreshable=True)
457 480
458 def __showError(self, msg): 481 def __showError(self, msg):

eric ide

mercurial