UI/CompareDialog.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3271
86df7bf80760
child 3656
441956d8fce5
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
100 @param parent parent widget (QWidget) 100 @param parent parent widget (QWidget)
101 """ 101 """
102 super(CompareDialog, self).__init__(parent) 102 super(CompareDialog, self).__init__(parent)
103 self.setupUi(self) 103 self.setupUi(self)
104 104
105 self.file1Button.setIcon(UI.PixmapCache.getIcon("open.png"))
106 self.file2Button.setIcon(UI.PixmapCache.getIcon("open.png"))
107
105 self.file1Completer = E5FileCompleter(self.file1Edit) 108 self.file1Completer = E5FileCompleter(self.file1Edit)
106 self.file2Completer = E5FileCompleter(self.file2Edit) 109 self.file2Completer = E5FileCompleter(self.file2Edit)
107 110
108 self.diffButton = self.buttonBox.addButton( 111 self.diffButton = self.buttonBox.addButton(
109 self.trUtf8("Compare"), QDialogButtonBox.ActionRole) 112 self.tr("Compare"), QDialogButtonBox.ActionRole)
110 self.diffButton.setToolTip( 113 self.diffButton.setToolTip(
111 self.trUtf8("Press to perform the comparison of the two files")) 114 self.tr("Press to perform the comparison of the two files"))
112 self.diffButton.setEnabled(False) 115 self.diffButton.setEnabled(False)
113 self.diffButton.setDefault(True) 116 self.diffButton.setDefault(True)
114 117
115 self.firstButton.setIcon(UI.PixmapCache.getIcon("2uparrow.png")) 118 self.firstButton.setIcon(UI.PixmapCache.getIcon("2uparrow.png"))
116 self.upButton.setIcon(UI.PixmapCache.getIcon("1uparrow.png")) 119 self.upButton.setIcon(UI.PixmapCache.getIcon("1uparrow.png"))
117 self.downButton.setIcon(UI.PixmapCache.getIcon("1downarrow.png")) 120 self.downButton.setIcon(UI.PixmapCache.getIcon("1downarrow.png"))
118 self.lastButton.setIcon(UI.PixmapCache.getIcon("2downarrow.png")) 121 self.lastButton.setIcon(UI.PixmapCache.getIcon("2downarrow.png"))
119 122
120 self.totalLabel.setText(self.trUtf8('Total: {0}').format(0)) 123 self.totalLabel.setText(self.tr('Total: {0}').format(0))
121 self.changedLabel.setText(self.trUtf8('Changed: {0}').format(0)) 124 self.changedLabel.setText(self.tr('Changed: {0}').format(0))
122 self.addedLabel.setText(self.trUtf8('Added: {0}').format(0)) 125 self.addedLabel.setText(self.tr('Added: {0}').format(0))
123 self.deletedLabel.setText(self.trUtf8('Deleted: {0}').format(0)) 126 self.deletedLabel.setText(self.tr('Deleted: {0}').format(0))
124 127
125 self.updateInterval = 20 # update every 20 lines 128 self.updateInterval = 20 # update every 20 lines
126 129
127 self.vsb1 = self.contents_1.verticalScrollBar() 130 self.vsb1 = self.contents_1.verticalScrollBar()
128 self.hsb1 = self.contents_1.horizontalScrollBar() 131 self.hsb1 = self.contents_1.horizontalScrollBar()
147 self.cReplacedFormat.setBackground(QBrush(QColor(190, 190, 237))) 150 self.cReplacedFormat.setBackground(QBrush(QColor(190, 190, 237)))
148 151
149 # connect some of our widgets explicitly 152 # connect some of our widgets explicitly
150 self.file1Edit.textChanged.connect(self.__fileChanged) 153 self.file1Edit.textChanged.connect(self.__fileChanged)
151 self.file2Edit.textChanged.connect(self.__fileChanged) 154 self.file2Edit.textChanged.connect(self.__fileChanged)
152 self.synchronizeCheckBox.toggled[bool].connect(
153 self.on_synchronizeCheckBox_toggled)
154 self.vsb1.valueChanged.connect(self.__scrollBarMoved) 155 self.vsb1.valueChanged.connect(self.__scrollBarMoved)
155 self.vsb1.valueChanged.connect(self.vsb2.setValue) 156 self.vsb1.valueChanged.connect(self.vsb2.setValue)
156 self.vsb2.valueChanged.connect(self.vsb1.setValue) 157 self.vsb2.valueChanged.connect(self.vsb1.setValue)
157 158
158 self.diffParas = [] 159 self.diffParas = []
235 lines1 = f1.readlines() 236 lines1 = f1.readlines()
236 f1.close() 237 f1.close()
237 except IOError: 238 except IOError:
238 E5MessageBox.critical( 239 E5MessageBox.critical(
239 self, 240 self,
240 self.trUtf8("Compare Files"), 241 self.tr("Compare Files"),
241 self.trUtf8( 242 self.tr(
242 """<p>The file <b>{0}</b> could not be read.</p>""") 243 """<p>The file <b>{0}</b> could not be read.</p>""")
243 .format(filename1)) 244 .format(filename1))
244 return 245 return
245 246
246 filename2 = Utilities.toNativeSeparators(self.file2Edit.text()) 247 filename2 = Utilities.toNativeSeparators(self.file2Edit.text())
249 lines2 = f2.readlines() 250 lines2 = f2.readlines()
250 f2.close() 251 f2.close()
251 except IOError: 252 except IOError:
252 E5MessageBox.critical( 253 E5MessageBox.critical(
253 self, 254 self,
254 self.trUtf8("Compare Files"), 255 self.tr("Compare Files"),
255 self.trUtf8( 256 self.tr(
256 """<p>The file <b>{0}</b> could not be read.</p>""") 257 """<p>The file <b>{0}</b> could not be read.</p>""")
257 .format(filename2)) 258 .format(filename2))
258 return 259 return
259 260
260 self.__compare(lines1, lines2) 261 self.__compare(lines1, lines2)
352 (self.vsb1.isVisible() or self.vsb2.isVisible())) 353 (self.vsb1.isVisible() or self.vsb2.isVisible()))
353 self.lastButton.setEnabled( 354 self.lastButton.setEnabled(
354 len(self.diffParas) > 0 and 355 len(self.diffParas) > 0 and
355 (self.vsb1.isVisible() or self.vsb2.isVisible())) 356 (self.vsb1.isVisible() or self.vsb2.isVisible()))
356 357
357 self.totalLabel.setText(self.trUtf8('Total: {0}') 358 self.totalLabel.setText(self.tr('Total: {0}')
358 .format(added + deleted + changed)) 359 .format(added + deleted + changed))
359 self.changedLabel.setText(self.trUtf8('Changed: {0}').format(changed)) 360 self.changedLabel.setText(self.tr('Changed: {0}').format(changed))
360 self.addedLabel.setText(self.trUtf8('Added: {0}').format(added)) 361 self.addedLabel.setText(self.tr('Added: {0}').format(added))
361 self.deletedLabel.setText(self.trUtf8('Deleted: {0}').format(deleted)) 362 self.deletedLabel.setText(self.tr('Deleted: {0}').format(deleted))
362 363
363 def __moveTextToCurrentDiffPos(self): 364 def __moveTextToCurrentDiffPos(self):
364 """ 365 """
365 Private slot to move the text display to the current diff position. 366 Private slot to move the text display to the current diff position.
366 """ 367 """
442 @param lineEdit field for the display of the selected filename 443 @param lineEdit field for the display of the selected filename
443 (QLineEdit) 444 (QLineEdit)
444 """ 445 """
445 filename = E5FileDialog.getOpenFileName( 446 filename = E5FileDialog.getOpenFileName(
446 self, 447 self,
447 self.trUtf8("Select file to compare"), 448 self.tr("Select file to compare"),
448 lineEdit.text(), 449 lineEdit.text(),
449 "") 450 "")
450 451
451 if filename: 452 if filename:
452 lineEdit.setText(Utilities.toNativeSeparators(filename)) 453 lineEdit.setText(Utilities.toNativeSeparators(filename))

eric ide

mercurial