22 |
22 |
23 class HgAddSubrepositoryDialog(QDialog, Ui_HgAddSubrepositoryDialog): |
23 class HgAddSubrepositoryDialog(QDialog, Ui_HgAddSubrepositoryDialog): |
24 """ |
24 """ |
25 Class implementing a dialog to add a sub-repository. |
25 Class implementing a dialog to add a sub-repository. |
26 """ |
26 """ |
|
27 |
27 def __init__(self, projectPath, parent=None): |
28 def __init__(self, projectPath, parent=None): |
28 """ |
29 """ |
29 Constructor |
30 Constructor |
30 |
31 |
31 @param projectPath project directory name (string) |
32 @param projectPath project directory name (string) |
32 @param parent reference to the parent widget (QWidget) |
33 @param parent reference to the parent widget (QWidget) |
33 """ |
34 """ |
34 super().__init__(parent) |
35 super().__init__(parent) |
35 self.setupUi(self) |
36 self.setupUi(self) |
36 |
37 |
37 self.pathPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
38 self.pathPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
38 self.pathPicker.setDefaultDirectory(projectPath) |
39 self.pathPicker.setDefaultDirectory(projectPath) |
39 |
40 |
40 self.__ok = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok) |
41 self.__ok = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok) |
41 self.__ok.setEnabled(False) |
42 self.__ok.setEnabled(False) |
42 |
43 |
43 self.__projectPath = Utilities.toNativeSeparators(projectPath) |
44 self.__projectPath = Utilities.toNativeSeparators(projectPath) |
44 |
45 |
45 self.typeCombo.addItem("Mercurial", "hg") |
46 self.typeCombo.addItem("Mercurial", "hg") |
46 self.typeCombo.addItem("GIT", "git") |
47 self.typeCombo.addItem("GIT", "git") |
47 self.typeCombo.addItem("Subversion", "svn") |
48 self.typeCombo.addItem("Subversion", "svn") |
48 |
49 |
49 msh = self.minimumSizeHint() |
50 msh = self.minimumSizeHint() |
50 self.resize(max(self.width(), msh.width()), msh.height()) |
51 self.resize(max(self.width(), msh.width()), msh.height()) |
51 |
52 |
52 def __updateOk(self): |
53 def __updateOk(self): |
53 """ |
54 """ |
54 Private slot to update the state of the OK button. |
55 Private slot to update the state of the OK button. |
55 """ |
56 """ |
56 path = self.pathPicker.text() |
57 path = self.pathPicker.text() |
57 url = self.urlEdit.text() |
58 url = self.urlEdit.text() |
58 |
59 |
59 self.__ok.setEnabled( |
60 self.__ok.setEnabled(path != "" and not os.path.isabs(path) and url != "") |
60 path != "" and |
61 |
61 not os.path.isabs(path) and |
|
62 url != "" |
|
63 ) |
|
64 |
|
65 @pyqtSlot(str) |
62 @pyqtSlot(str) |
66 def on_pathPicker_textChanged(self, p0): |
63 def on_pathPicker_textChanged(self, p0): |
67 """ |
64 """ |
68 Private slot to handle the update of the path. |
65 Private slot to handle the update of the path. |
69 |
66 |
70 @param p0 text of the path edit (string) |
67 @param p0 text of the path edit (string) |
71 """ |
68 """ |
72 self.__updateOk() |
69 self.__updateOk() |
73 |
70 |
74 @pyqtSlot(str) |
71 @pyqtSlot(str) |
75 def on_urlEdit_textChanged(self, p0): |
72 def on_urlEdit_textChanged(self, p0): |
76 """ |
73 """ |
77 Private slot to handle the update of the URL. |
74 Private slot to handle the update of the URL. |
78 |
75 |
79 @param p0 text of the URL edit (string) |
76 @param p0 text of the URL edit (string) |
80 """ |
77 """ |
81 self.__updateOk() |
78 self.__updateOk() |
82 |
79 |
83 @pyqtSlot(str) |
80 @pyqtSlot(str) |
84 def on_pathPicker_pathSelected(self, path): |
81 def on_pathPicker_pathSelected(self, path): |
85 """ |
82 """ |
86 Private slot handling the selection of a subrepository path. |
83 Private slot handling the selection of a subrepository path. |
87 |
84 |
88 @param path path of the subrepository |
85 @param path path of the subrepository |
89 @type str |
86 @type str |
90 """ |
87 """ |
91 if path.startswith(self.__projectPath + os.sep): |
88 if path.startswith(self.__projectPath + os.sep): |
92 path = path.replace(self.__projectPath + os.sep, "") |
89 path = path.replace(self.__projectPath + os.sep, "") |
93 self.pathPicker.setText(path) |
90 self.pathPicker.setText(path) |
94 else: |
91 else: |
95 EricMessageBox.critical( |
92 EricMessageBox.critical( |
96 self, |
93 self, |
97 self.tr("Add Sub-repository"), |
94 self.tr("Add Sub-repository"), |
98 self.tr("""The sub-repository path must be inside""" |
95 self.tr( |
99 """ the project.""")) |
96 """The sub-repository path must be inside""" """ the project.""" |
|
97 ), |
|
98 ) |
100 self.pathPicker.setText("") |
99 self.pathPicker.setText("") |
101 |
100 |
102 def getData(self): |
101 def getData(self): |
103 """ |
102 """ |
104 Public method to get the data. |
103 Public method to get the data. |
105 |
104 |
106 @return tuple containing the relative path within the project, the |
105 @return tuple containing the relative path within the project, the |
107 sub-repository type and the sub-repository URL (string, string, |
106 sub-repository type and the sub-repository URL (string, string, |
108 string) |
107 string) |
109 """ |
108 """ |
110 return ( |
109 return ( |
111 self.pathPicker.text(), |
110 self.pathPicker.text(), |
112 self.typeCombo.itemData(self.typeCombo.currentIndex()), |
111 self.typeCombo.itemData(self.typeCombo.currentIndex()), |
113 self.urlEdit.text() |
112 self.urlEdit.text(), |
114 ) |
113 ) |