Plugins/VcsPlugins/vcsPySvn/SvnOptionsDialog.py

changeset 0
de9c2efb9d02
child 12
1d8dd9706f46
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2002 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter options used to start a project in the VCS.
8 """
9
10 import os
11
12 from PyQt4.QtCore import *
13 from PyQt4.QtGui import *
14
15 from E4Gui.E4Completers import E4DirCompleter
16
17 from SvnRepoBrowserDialog import SvnRepoBrowserDialog
18 from Ui_SvnOptionsDialog import Ui_SvnOptionsDialog
19 from Config import ConfigSvnProtocols
20
21 import Utilities
22
23 class SvnOptionsDialog(QDialog, Ui_SvnOptionsDialog):
24 """
25 Class implementing a dialog to enter options used to start a project in the
26 repository.
27 """
28 def __init__(self, vcs, project, parent = None):
29 """
30 Constructor
31
32 @param vcs reference to the version control object
33 @param project reference to the project object
34 @param parent parent widget (QWidget)
35 """
36 QDialog.__init__(self, parent)
37 self.setupUi(self)
38
39 self.vcsDirectoryCompleter = E4DirCompleter(self.vcsUrlEdit)
40
41 self.project = project
42
43 self.protocolCombo.addItems(ConfigSvnProtocols)
44
45 hd = Utilities.toNativeSeparators(QDir.homePath())
46 hd = os.path.join(hd, 'subversionroot')
47 self.vcsUrlEdit.setText(hd)
48
49 self.vcs = vcs
50
51 self.localPath = hd
52 self.networkPath = "localhost/"
53 self.localProtocol = True
54
55 @pyqtSlot()
56 def on_vcsUrlButton_clicked(self):
57 """
58 Private slot to display a selection dialog.
59 """
60 if self.protocolCombo.currentText() == "file://":
61 directory = QFileDialog.getExistingDirectory(\
62 self,
63 self.trUtf8("Select Repository-Directory"),
64 self.vcsUrlEdit.text(),
65 QFileDialog.Options(QFileDialog.ShowDirsOnly))
66
67 if directory:
68 self.vcsUrlEdit.setText(Utilities.toNativeSeparators(directory))
69 else:
70 dlg = SvnRepoBrowserDialog(self.vcs, mode = "select", parent = self)
71 dlg.start(self.protocolCombo.currentText() + self.vcsUrlEdit.text())
72 if dlg.exec_() == QDialog.Accepted:
73 url = dlg.getSelectedUrl()
74 if url:
75 protocol = url.split("://")[0]
76 path = url.split("://")[1]
77 self.protocolCombo.setCurrentIndex(\
78 self.protocolCombo.findText(protocol + "://"))
79 self.vcsUrlEdit.setText(path)
80
81 @pyqtSlot(str)
82 def on_protocolCombo_activated(self, protocol):
83 """
84 Private slot to switch the status of the directory selection button.
85 """
86 if protocol == "file://":
87 self.networkPath = self.vcsUrlEdit.text()
88 self.vcsUrlEdit.setText(self.localPath)
89 self.localProtocol = True
90 else:
91 if self.localProtocol:
92 self.localPath = self.vcsUrlEdit.text()
93 self.vcsUrlEdit.setText(self.networkPath)
94 self.localProtocol = False
95
96 def getData(self):
97 """
98 Public slot to retrieve the data entered into the dialog.
99
100 @return a dictionary containing the data entered
101 """
102 scheme = self.protocolCombo.currentText()
103 url = self.vcsUrlEdit.text()
104 if scheme == "file://" and url[0] not in ["\\", "/"]:
105 url = "/%s" % url
106 vcsdatadict = {
107 "url" : '%s%s' % (scheme, url),
108 "message" : self.vcsLogEdit.text(),
109 "standardLayout" : self.layoutCheckBox.isChecked(),
110 }
111 return vcsdatadict

eric ide

mercurial