216 |
216 |
217 self.file1Completer = E5FileCompleter(self.file1Edit) |
217 self.file1Completer = E5FileCompleter(self.file1Edit) |
218 self.file2Completer = E5FileCompleter(self.file2Edit) |
218 self.file2Completer = E5FileCompleter(self.file2Edit) |
219 |
219 |
220 self.diffButton = self.buttonBox.addButton( |
220 self.diffButton = self.buttonBox.addButton( |
221 self.trUtf8("Compare"), QDialogButtonBox.ActionRole) |
221 self.tr("Compare"), QDialogButtonBox.ActionRole) |
222 self.diffButton.setToolTip( |
222 self.diffButton.setToolTip( |
223 self.trUtf8("Press to perform the comparison of the two files")) |
223 self.tr("Press to perform the comparison of the two files")) |
224 self.saveButton = self.buttonBox.addButton( |
224 self.saveButton = self.buttonBox.addButton( |
225 self.trUtf8("Save"), QDialogButtonBox.ActionRole) |
225 self.tr("Save"), QDialogButtonBox.ActionRole) |
226 self.saveButton.setToolTip( |
226 self.saveButton.setToolTip( |
227 self.trUtf8("Save the output to a patch file")) |
227 self.tr("Save the output to a patch file")) |
228 self.diffButton.setEnabled(False) |
228 self.diffButton.setEnabled(False) |
229 self.saveButton.setEnabled(False) |
229 self.saveButton.setEnabled(False) |
230 self.diffButton.setDefault(True) |
230 self.diffButton.setDefault(True) |
231 |
231 |
232 self.filename1 = '' |
232 self.filename1 = '' |
287 else: |
287 else: |
288 fname = dname |
288 fname = dname |
289 |
289 |
290 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
290 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
291 self, |
291 self, |
292 self.trUtf8("Save Diff"), |
292 self.tr("Save Diff"), |
293 fname, |
293 fname, |
294 self.trUtf8("Patch Files (*.diff)"), |
294 self.tr("Patch Files (*.diff)"), |
295 None, |
295 None, |
296 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
296 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
297 |
297 |
298 if not fname: |
298 if not fname: |
299 return |
299 return |
304 if ex: |
304 if ex: |
305 fname += ex |
305 fname += ex |
306 if QFileInfo(fname).exists(): |
306 if QFileInfo(fname).exists(): |
307 res = E5MessageBox.yesNo( |
307 res = E5MessageBox.yesNo( |
308 self, |
308 self, |
309 self.trUtf8("Save Diff"), |
309 self.tr("Save Diff"), |
310 self.trUtf8("<p>The patch file <b>{0}</b> already exists." |
310 self.tr("<p>The patch file <b>{0}</b> already exists." |
311 " Overwrite it?</p>").format(fname), |
311 " Overwrite it?</p>").format(fname), |
312 icon=E5MessageBox.Warning) |
312 icon=E5MessageBox.Warning) |
313 if not res: |
313 if not res: |
314 return |
314 return |
315 fname = Utilities.toNativeSeparators(fname) |
315 fname = Utilities.toNativeSeparators(fname) |
316 |
316 |
322 except UnicodeError: |
322 except UnicodeError: |
323 pass |
323 pass |
324 f.close() |
324 f.close() |
325 except IOError as why: |
325 except IOError as why: |
326 E5MessageBox.critical( |
326 E5MessageBox.critical( |
327 self, self.trUtf8('Save Diff'), |
327 self, self.tr('Save Diff'), |
328 self.trUtf8( |
328 self.tr( |
329 '<p>The patch file <b>{0}</b> could not be saved.<br />' |
329 '<p>The patch file <b>{0}</b> could not be saved.<br />' |
330 'Reason: {1}</p>').format(fname, str(why))) |
330 'Reason: {1}</p>').format(fname, str(why))) |
331 |
331 |
332 @pyqtSlot() |
332 @pyqtSlot() |
333 def on_diffButton_clicked(self): |
333 def on_diffButton_clicked(self): |
344 lines1 = f1.readlines() |
344 lines1 = f1.readlines() |
345 f1.close() |
345 f1.close() |
346 except IOError: |
346 except IOError: |
347 E5MessageBox.critical( |
347 E5MessageBox.critical( |
348 self, |
348 self, |
349 self.trUtf8("Compare Files"), |
349 self.tr("Compare Files"), |
350 self.trUtf8( |
350 self.tr( |
351 """<p>The file <b>{0}</b> could not be read.</p>""") |
351 """<p>The file <b>{0}</b> could not be read.</p>""") |
352 .format(self.filename1)) |
352 .format(self.filename1)) |
353 return |
353 return |
354 |
354 |
355 self.filename2 = Utilities.toNativeSeparators(self.file2Edit.text()) |
355 self.filename2 = Utilities.toNativeSeparators(self.file2Edit.text()) |
362 lines2 = f2.readlines() |
362 lines2 = f2.readlines() |
363 f2.close() |
363 f2.close() |
364 except IOError: |
364 except IOError: |
365 E5MessageBox.critical( |
365 E5MessageBox.critical( |
366 self, |
366 self, |
367 self.trUtf8("Compare Files"), |
367 self.tr("Compare Files"), |
368 self.trUtf8( |
368 self.tr( |
369 """<p>The file <b>{0}</b> could not be read.</p>""") |
369 """<p>The file <b>{0}</b> could not be read.</p>""") |
370 .format(self.filename2)) |
370 .format(self.filename2)) |
371 return |
371 return |
372 |
372 |
373 self.contents.clear() |
373 self.contents.clear() |
430 if not (paras % self.updateInterval): |
430 if not (paras % self.updateInterval): |
431 QApplication.processEvents() |
431 QApplication.processEvents() |
432 |
432 |
433 if paras == 0: |
433 if paras == 0: |
434 self.__appendText( |
434 self.__appendText( |
435 self.trUtf8('There is no difference.'), self.cNormalFormat) |
435 self.tr('There is no difference.'), self.cNormalFormat) |
436 |
436 |
437 def __generateContextDiff(self, a, b, fromfile, tofile, |
437 def __generateContextDiff(self, a, b, fromfile, tofile, |
438 fromfiledate, tofiledate): |
438 fromfiledate, tofiledate): |
439 """ |
439 """ |
440 Private slot to generate a context diff output. |
440 Private slot to generate a context diff output. |
465 if not (paras % self.updateInterval): |
465 if not (paras % self.updateInterval): |
466 QApplication.processEvents() |
466 QApplication.processEvents() |
467 |
467 |
468 if paras == 0: |
468 if paras == 0: |
469 self.__appendText( |
469 self.__appendText( |
470 self.trUtf8('There is no difference.'), self.cNormalFormat) |
470 self.tr('There is no difference.'), self.cNormalFormat) |
471 |
471 |
472 def __fileChanged(self): |
472 def __fileChanged(self): |
473 """ |
473 """ |
474 Private slot to enable/disable the Compare button. |
474 Private slot to enable/disable the Compare button. |
475 """ |
475 """ |