Plugins/VcsPlugins/vcsSubversion/SvnUrlSelectionDialog.py

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

eric ide

mercurial