|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2003 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter the data for a merge operation. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtCore import QRegExp |
|
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
|
14 |
|
15 from .Ui_SvnMergeDialog import Ui_SvnMergeDialog |
|
16 |
|
17 |
|
18 class SvnMergeDialog(QDialog, Ui_SvnMergeDialog): |
|
19 """ |
|
20 Class implementing a dialog to enter the data for a merge operation. |
|
21 """ |
|
22 def __init__(self, mergelist1, mergelist2, targetlist, force=False, |
|
23 parent=None): |
|
24 """ |
|
25 Constructor |
|
26 |
|
27 @param mergelist1 list of previously entered URLs/revisions |
|
28 (list of strings) |
|
29 @param mergelist2 list of previously entered URLs/revisions |
|
30 (list of strings) |
|
31 @param targetlist list of previously entered targets (list of strings) |
|
32 @param force flag indicating a forced merge (boolean) |
|
33 @param parent parent widget (QWidget) |
|
34 """ |
|
35 super(SvnMergeDialog, self).__init__(parent) |
|
36 self.setupUi(self) |
|
37 |
|
38 self.forceCheckBox.setChecked(force) |
|
39 |
|
40 self.okButton = self.buttonBox.button(QDialogButtonBox.Ok) |
|
41 self.okButton.setEnabled(False) |
|
42 |
|
43 self.rx_url = QRegExp('(?:file:|svn:|svn+ssh:|http:|https:)//.+') |
|
44 self.rx_rev = QRegExp('\\d+') |
|
45 |
|
46 self.tag1Combo.clear() |
|
47 self.tag1Combo.addItems(mergelist1) |
|
48 self.tag2Combo.clear() |
|
49 self.tag2Combo.addItems(mergelist2) |
|
50 self.targetCombo.clear() |
|
51 self.targetCombo.addItems(targetlist) |
|
52 |
|
53 msh = self.minimumSizeHint() |
|
54 self.resize(max(self.width(), msh.width()), msh.height()) |
|
55 |
|
56 def __enableOkButton(self): |
|
57 """ |
|
58 Private method used to enable/disable the OK-button. |
|
59 """ |
|
60 self.okButton.setDisabled( |
|
61 self.tag1Combo.currentText() == "" or |
|
62 self.tag2Combo.currentText() == "" or |
|
63 not ((self.rx_url.exactMatch(self.tag1Combo.currentText()) and |
|
64 self.rx_url.exactMatch(self.tag2Combo.currentText())) or |
|
65 (self.rx_rev.exactMatch(self.tag1Combo.currentText()) and |
|
66 self.rx_rev.exactMatch(self.tag2Combo.currentText())) |
|
67 ) |
|
68 ) |
|
69 |
|
70 def on_tag1Combo_editTextChanged(self, text): |
|
71 """ |
|
72 Private slot to handle the tag1Combo editTextChanged signal. |
|
73 |
|
74 @param text text of the combo (string) |
|
75 """ |
|
76 self.__enableOkButton() |
|
77 |
|
78 def on_tag2Combo_editTextChanged(self, text): |
|
79 """ |
|
80 Private slot to handle the tag2Combo editTextChanged signal. |
|
81 |
|
82 @param text text of the combo (string) |
|
83 """ |
|
84 self.__enableOkButton() |
|
85 |
|
86 def getParameters(self): |
|
87 """ |
|
88 Public method to retrieve the merge data. |
|
89 |
|
90 @return tuple naming two tag names or two revisions, a target and |
|
91 a flag indicating a forced merge (string, string, string, boolean) |
|
92 """ |
|
93 return (self.tag1Combo.currentText(), |
|
94 self.tag2Combo.currentText(), |
|
95 self.targetCombo.currentText(), |
|
96 self.forceCheckBox.isChecked()) |