|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter the data for a bundle operation. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtCore import pyqtSlot |
|
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
|
12 |
|
13 from .Ui_GitBundleDialog import Ui_GitBundleDialog |
|
14 |
|
15 |
|
16 class GitBundleDialog(QDialog, Ui_GitBundleDialog): |
|
17 """ |
|
18 Class implementing a dialog to enter the data for a bundle operation. |
|
19 """ |
|
20 def __init__(self, tagsList, branchesList, parent=None): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param tagsList list of tags (list of strings) |
|
25 @param branchesList list of branches (list of strings) |
|
26 @param parent parent widget (QWidget) |
|
27 """ |
|
28 super().__init__(parent) |
|
29 self.setupUi(self) |
|
30 |
|
31 self.buttonBox.button( |
|
32 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
|
33 |
|
34 self.tagCombo.addItems(sorted(tagsList)) |
|
35 self.branchCombo.addItems(["master"] + sorted(branchesList)) |
|
36 |
|
37 def __updateOK(self): |
|
38 """ |
|
39 Private slot to update the OK button. |
|
40 """ |
|
41 enabled = True |
|
42 if self.revisionsButton.isChecked(): |
|
43 enabled = self.revisionsEdit.text() != "" |
|
44 elif self.tagButton.isChecked(): |
|
45 enabled = self.tagCombo.currentText() != "" |
|
46 elif self.branchButton.isChecked(): |
|
47 enabled = self.branchCombo.currentText() != "" |
|
48 |
|
49 self.buttonBox.button( |
|
50 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
|
51 |
|
52 @pyqtSlot(bool) |
|
53 def on_revisionsButton_toggled(self, checked): |
|
54 """ |
|
55 Private slot to handle changes of the revisions select button. |
|
56 |
|
57 @param checked state of the button (boolean) |
|
58 """ |
|
59 self.__updateOK() |
|
60 |
|
61 @pyqtSlot(bool) |
|
62 def on_tagButton_toggled(self, checked): |
|
63 """ |
|
64 Private slot to handle changes of the Tag select button. |
|
65 |
|
66 @param checked state of the button (boolean) |
|
67 """ |
|
68 self.__updateOK() |
|
69 |
|
70 @pyqtSlot(bool) |
|
71 def on_branchButton_toggled(self, checked): |
|
72 """ |
|
73 Private slot to handle changes of the Branch select button. |
|
74 |
|
75 @param checked state of the button (boolean) |
|
76 """ |
|
77 self.__updateOK() |
|
78 |
|
79 @pyqtSlot(str) |
|
80 def on_revisionsEdit_textChanged(self, txt): |
|
81 """ |
|
82 Private slot to handle changes of the Revisions edit. |
|
83 |
|
84 @param txt text of the line edit (string) |
|
85 """ |
|
86 self.__updateOK() |
|
87 |
|
88 @pyqtSlot(str) |
|
89 def on_tagCombo_editTextChanged(self, txt): |
|
90 """ |
|
91 Private slot to handle changes of the Tag combo. |
|
92 |
|
93 @param txt text of the combo (string) |
|
94 """ |
|
95 self.__updateOK() |
|
96 |
|
97 @pyqtSlot(str) |
|
98 def on_branchCombo_editTextChanged(self, txt): |
|
99 """ |
|
100 Private slot to handle changes of the Branch combo. |
|
101 |
|
102 @param txt text of the combo (string) |
|
103 """ |
|
104 self.__updateOK() |
|
105 |
|
106 def getData(self): |
|
107 """ |
|
108 Public method to retrieve the bundle data. |
|
109 |
|
110 @return list of revision expressions (list of strings) |
|
111 """ |
|
112 if self.revisionsButton.isChecked(): |
|
113 revs = self.revisionsEdit.text().strip().split() |
|
114 elif self.tagButton.isChecked(): |
|
115 revs = [self.tagCombo.currentText()] |
|
116 elif self.branchButton.isChecked(): |
|
117 revs = [self.branchCombo.currentText()] |
|
118 else: |
|
119 revs = [] |
|
120 |
|
121 return revs |