Plugins/VcsPlugins/vcsPySvn/SvnNewProjectOptionsDialog.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 the Subversion Options Dialog for a new project from the repository.
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_SvnNewProjectOptionsDialog import Ui_SvnNewProjectOptionsDialog
19 from Config import ConfigSvnProtocols
20
21 import Utilities
22
23 class SvnNewProjectOptionsDialog(QDialog, Ui_SvnNewProjectOptionsDialog):
24 """
25 Class implementing the Options Dialog for a new project from the repository.
26 """
27 def __init__(self, vcs, parent = None):
28 """
29 Constructor
30
31 @param vcs reference to the version control object
32 @param parent parent widget (QWidget)
33 """
34 QDialog.__init__(self, parent)
35 self.setupUi(self)
36
37 self.vcsDirectoryCompleter = E4DirCompleter(self.vcsUrlEdit)
38 self.vcsProjectDirCompleter = E4DirCompleter(self.vcsProjectDirEdit)
39
40 self.protocolCombo.addItems(ConfigSvnProtocols)
41
42 hd = Utilities.toNativeSeparators(QDir.homePath())
43 hd = os.path.join(hd, 'subversionroot')
44 self.vcsUrlEdit.setText(hd)
45
46 self.vcs = vcs
47
48 self.localPath = hd
49 self.networkPath = "localhost/"
50 self.localProtocol = True
51
52 @pyqtSlot()
53 def on_vcsUrlButton_clicked(self):
54 """
55 Private slot to display a selection dialog.
56 """
57 if self.protocolCombo.currentText() == "file://":
58 directory = QFileDialog.getExistingDirectory(\
59 self,
60 self.trUtf8("Select Repository-Directory"),
61 self.vcsUrlEdit.text(),
62 QFileDialog.Options(QFileDialog.ShowDirsOnly))
63
64 if directory:
65 self.vcsUrlEdit.setText(Utilities.toNativeSeparators(directory))
66 else:
67 dlg = SvnRepoBrowserDialog(self.vcs, mode = "select", parent = self)
68 dlg.start(self.protocolCombo.currentText() + self.vcsUrlEdit.text())
69 if dlg.exec_() == QDialog.Accepted:
70 url = dlg.getSelectedUrl()
71 if url:
72 protocol = url.split("://")[0]
73 path = url.split("://")[1]
74 self.protocolCombo.setCurrentIndex(\
75 self.protocolCombo.findText(protocol + "://"))
76 self.vcsUrlEdit.setText(path)
77
78 @pyqtSlot()
79 def on_projectDirButton_clicked(self):
80 """
81 Private slot to display a directory selection dialog.
82 """
83 directory = QFileDialog.getExistingDirectory(\
84 self,
85 self.trUtf8("Select Project Directory"),
86 self.vcsProjectDirEdit.text(),
87 QFileDialog.Options(QFileDialog.ShowDirsOnly))
88
89 if directory:
90 self.vcsProjectDirEdit.setText(Utilities.toNativeSeparators(directory))
91
92 def on_layoutCheckBox_toggled(self, checked):
93 """
94 Private slot to handle the change of the layout checkbox.
95
96 @param checked flag indicating the state of the checkbox (boolean)
97 """
98 self.vcsTagLabel.setEnabled(checked)
99 self.vcsTagEdit.setEnabled(checked)
100 if not checked:
101 self.vcsTagEdit.clear()
102
103 @pyqtSlot(str)
104 def on_protocolCombo_activated(self, protocol):
105 """
106 Private slot to switch the status of the directory selection button.
107
108 @param protocol name of the selected protocol (string)
109 """
110 if protocol == "file://":
111 self.networkPath = self.vcsUrlEdit.text()
112 self.vcsUrlEdit.setText(self.localPath)
113 self.localProtocol = True
114 else:
115 if self.localProtocol:
116 self.localPath = self.vcsUrlEdit.text()
117 self.vcsUrlEdit.setText(self.networkPath)
118 self.localProtocol = False
119
120 def getData(self):
121 """
122 Public slot to retrieve the data entered into the dialog.
123
124 @return a tuple of a string (project directory) and a dictionary
125 containing the data entered.
126 """
127 scheme = self.protocolCombo.currentText()
128 url = self.vcsUrlEdit.text()
129 if scheme == "file://" and url[0] not in ["\\", "/"]:
130 url = "/%s" % url
131 vcsdatadict = {
132 "url" : '%s%s' % (scheme, url),
133 "tag" : self.vcsTagEdit.text(),
134 "standardLayout" : self.layoutCheckBox.isChecked(),
135 }
136 return (self.vcsProjectDirEdit.text(), vcsdatadict)

eric ide

mercurial