184 |
184 |
185 @param filename name of a file to use as the first file (string) |
185 @param filename name of a file to use as the first file (string) |
186 """ |
186 """ |
187 if filename: |
187 if filename: |
188 self.file1Picker.setText(filename) |
188 self.file1Picker.setText(filename) |
189 super(CompareDialog, self).show() |
189 super().show() |
190 |
190 |
191 def __appendText(self, pane, linenumber, line, charFormat, |
191 def __appendText(self, pane, linenumber, line, charFormat, |
192 interLine=False): |
192 interLine=False): |
193 """ |
193 """ |
194 Private method to append text to the end of the contents pane. |
194 Private method to append text to the end of the contents pane. |
305 # counters for changes |
305 # counters for changes |
306 added = 0 |
306 added = 0 |
307 deleted = 0 |
307 deleted = 0 |
308 changed = 0 |
308 changed = 0 |
309 |
309 |
310 paras = 1 |
|
311 self.diffParas = [] |
310 self.diffParas = [] |
312 self.currentDiffPos = -1 |
311 self.currentDiffPos = -1 |
313 oldOpcode = '' |
312 oldOpcode = '' |
314 for opcode, ln1, l1, ln2, l2 in sbsdiff(lines1, lines2): |
313 for paras, (opcode, ln1, l1, ln2, l2) in enumerate( |
|
314 sbsdiff(lines1, lines2), start=1 |
|
315 ): |
315 if opcode in 'idr': |
316 if opcode in 'idr': |
316 if oldOpcode != opcode: |
317 if oldOpcode != opcode: |
317 oldOpcode = opcode |
318 oldOpcode = opcode |
318 self.diffParas.append(paras) |
319 self.diffParas.append(paras) |
319 # update counters |
320 # update counters |
342 oldOpcode = '' |
343 oldOpcode = '' |
343 format1 = self.cNormalFormat |
344 format1 = self.cNormalFormat |
344 format2 = self.cNormalFormat |
345 format2 = self.cNormalFormat |
345 self.__appendText(self.contents_1, ln1, l1, format1, opcode == 'r') |
346 self.__appendText(self.contents_1, ln1, l1, format1, opcode == 'r') |
346 self.__appendText(self.contents_2, ln2, l2, format2, opcode == 'r') |
347 self.__appendText(self.contents_2, ln2, l2, format2, opcode == 'r') |
347 paras += 1 |
|
348 if not (paras % self.updateInterval): |
348 if not (paras % self.updateInterval): |
349 QApplication.processEvents() |
349 QApplication.processEvents() |
350 |
350 |
351 self.vsb1.setValue(0) |
351 self.vsb1.setValue(0) |
352 self.vsb2.setValue(0) |
352 self.vsb2.setValue(0) |
468 |
468 |
469 @param files list of files to compare and their label |
469 @param files list of files to compare and their label |
470 (list of two tuples of two strings) |
470 (list of two tuples of two strings) |
471 @param parent reference to the parent widget (QWidget) |
471 @param parent reference to the parent widget (QWidget) |
472 """ |
472 """ |
473 super(CompareWindow, self).__init__(parent) |
473 super().__init__(parent) |
474 |
474 |
475 self.setStyle(Preferences.getUI("Style"), |
475 self.setStyle(Preferences.getUI("Style"), |
476 Preferences.getUI("StyleSheet")) |
476 Preferences.getUI("StyleSheet")) |
477 |
477 |
478 self.cw = CompareDialog(files, self) |
478 self.cw = CompareDialog(files, self) |