|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2007 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter the URLs for the svn diff command. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtCore import QRegExp, pyqtSlot |
|
13 from PyQt5.QtWidgets import QDialog |
|
14 |
|
15 from E5Gui.E5Application import e5App |
|
16 from E5Gui import E5MessageBox |
|
17 |
|
18 from .Ui_SvnUrlSelectionDialog import Ui_SvnUrlSelectionDialog |
|
19 |
|
20 import Utilities |
|
21 |
|
22 |
|
23 class SvnUrlSelectionDialog(QDialog, Ui_SvnUrlSelectionDialog): |
|
24 """ |
|
25 Class implementing a dialog to enter the URLs for the svn diff command. |
|
26 """ |
|
27 def __init__(self, vcs, tagsList, branchesList, path, parent=None): |
|
28 """ |
|
29 Constructor |
|
30 |
|
31 @param vcs reference to the vcs object |
|
32 @param tagsList list of tags (list of strings) |
|
33 @param branchesList list of branches (list of strings) |
|
34 @param path pathname to determine the repository URL from (string) |
|
35 @param parent parent widget of the dialog (QWidget) |
|
36 """ |
|
37 super(SvnUrlSelectionDialog, self).__init__(parent) |
|
38 self.setupUi(self) |
|
39 |
|
40 if vcs.version < (1, 4, 0): |
|
41 self.summaryCheckBox.setEnabled(False) |
|
42 self.summaryCheckBox.setChecked(False) |
|
43 |
|
44 self.vcs = vcs |
|
45 self.tagsList = tagsList |
|
46 self.branchesList = branchesList |
|
47 |
|
48 self.typeCombo1.addItems(["trunk/", "tags/", "branches/"]) |
|
49 self.typeCombo2.addItems(["trunk/", "tags/", "branches/"]) |
|
50 |
|
51 reposURL = self.vcs.svnGetReposName(path) |
|
52 if reposURL is None: |
|
53 E5MessageBox.critical( |
|
54 self, |
|
55 self.tr("Subversion Error"), |
|
56 self.tr( |
|
57 """The URL of the project repository could not be""" |
|
58 """ retrieved from the working copy. The operation will""" |
|
59 """ be aborted""")) |
|
60 self.reject() |
|
61 return |
|
62 |
|
63 if self.vcs.otherData["standardLayout"]: |
|
64 # determine the base path of the project in the repository |
|
65 rx_base = QRegExp('(.+/)(trunk|tags|branches).*') |
|
66 if not rx_base.exactMatch(reposURL): |
|
67 E5MessageBox.critical( |
|
68 self, |
|
69 self.tr("Subversion Error"), |
|
70 self.tr( |
|
71 """The URL of the project repository has an""" |
|
72 """ invalid format. The list operation will""" |
|
73 """ be aborted""")) |
|
74 self.reject() |
|
75 return |
|
76 |
|
77 reposRoot = rx_base.cap(1) |
|
78 self.repoRootLabel1.setText(reposRoot) |
|
79 self.repoRootLabel2.setText(reposRoot) |
|
80 else: |
|
81 project = e5App().getObject('Project') |
|
82 if Utilities.normcasepath(path) != \ |
|
83 Utilities.normcasepath(project.getProjectPath()): |
|
84 path = project.getRelativePath(path) |
|
85 reposURL = reposURL.replace(path, '') |
|
86 self.repoRootLabel1.hide() |
|
87 self.typeCombo1.hide() |
|
88 self.labelCombo1.addItems([reposURL] + sorted(self.vcs.tagsList)) |
|
89 self.labelCombo1.setEnabled(True) |
|
90 self.repoRootLabel2.hide() |
|
91 self.typeCombo2.hide() |
|
92 self.labelCombo2.addItems([reposURL] + sorted(self.vcs.tagsList)) |
|
93 self.labelCombo2.setEnabled(True) |
|
94 |
|
95 msh = self.minimumSizeHint() |
|
96 self.resize(max(self.width(), msh.width()), msh.height()) |
|
97 |
|
98 def __changeLabelCombo(self, labelCombo, type_): |
|
99 """ |
|
100 Private method used to change the label combo depending on the |
|
101 selected type. |
|
102 |
|
103 @param labelCombo reference to the labelCombo object (QComboBox) |
|
104 @param type_ type string (string) |
|
105 """ |
|
106 if type_ == "trunk/": |
|
107 labelCombo.clear() |
|
108 labelCombo.setEditText("") |
|
109 labelCombo.setEnabled(False) |
|
110 elif type_ == "tags/": |
|
111 labelCombo.clear() |
|
112 labelCombo.clearEditText() |
|
113 labelCombo.addItems(sorted(self.tagsList)) |
|
114 labelCombo.setEnabled(True) |
|
115 elif type_ == "branches/": |
|
116 labelCombo.clear() |
|
117 labelCombo.clearEditText() |
|
118 labelCombo.addItems(sorted(self.branchesList)) |
|
119 labelCombo.setEnabled(True) |
|
120 |
|
121 @pyqtSlot(str) |
|
122 def on_typeCombo1_currentIndexChanged(self, type_): |
|
123 """ |
|
124 Private slot called when the selected type was changed. |
|
125 |
|
126 @param type_ selected type (string) |
|
127 """ |
|
128 self.__changeLabelCombo(self.labelCombo1, type_) |
|
129 |
|
130 @pyqtSlot(str) |
|
131 def on_typeCombo2_currentIndexChanged(self, type_): |
|
132 """ |
|
133 Private slot called when the selected type was changed. |
|
134 |
|
135 @param type_ selected type (string) |
|
136 """ |
|
137 self.__changeLabelCombo(self.labelCombo2, type_) |
|
138 |
|
139 def getURLs(self): |
|
140 """ |
|
141 Public method to get the entered URLs. |
|
142 |
|
143 @return tuple of list of two URL strings (list of strings) and |
|
144 a flag indicating a diff summary (boolean) |
|
145 """ |
|
146 if self.vcs.otherData["standardLayout"]: |
|
147 url1 = self.repoRootLabel1.text() + \ |
|
148 self.typeCombo1.currentText() + \ |
|
149 self.labelCombo1.currentText() |
|
150 url2 = self.repoRootLabel2.text() + \ |
|
151 self.typeCombo2.currentText() + \ |
|
152 self.labelCombo2.currentText() |
|
153 else: |
|
154 url1 = self.labelCombo1.currentText() |
|
155 url2 = self.labelCombo2.currentText() |
|
156 |
|
157 return [url1, url2], self.summaryCheckBox.isChecked() |