Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

new pathedit.py

Changeset 802d9928f76c

Parent 2e5826b34b54

by Adrian Buehlmann

Changes to 3 files · Browse files at 802d9928f76c Showing diff from parent 2e5826b34b54 Diff from another changeset...

Change 1 of 1 Show Entire File tortoisehg/​hgqt/​pathedit.py Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@@ -0,0 +1,50 @@
+# pathedit.py +# +# Copyright 2010 Adrian Buehlmann <adrian@cadifra.com> +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2 or any later version. + +from PyQt4.QtCore import * +from PyQt4.QtGui import * + +from tortoisehg.hgqt.i18n import _ + + +class PathEditDialog(QDialog): + + def __init__(self, parent, alias, url_): + super(PathEditDialog, self).__init__(parent) + self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) + + layout = QVBoxLayout() + + self.setLayout(layout) + self.setWindowTitle(_("Edit Path")) + + form = QFormLayout() + layout.addLayout(form) + + self.edit = QLineEdit(url_) + form.addRow(alias, self.edit) + + BB = QDialogButtonBox + bb = QDialogButtonBox(BB.Ok|BB.Cancel) + layout.addWidget(bb) + bb.accepted.connect(self.accept) + bb.rejected.connect(self.reject) + bb.button(BB.Ok).setDefault(True) + + self.setMinimumWidth(400) + h = self.sizeHint().height() + 6 + self.setMaximumHeight(h) + self.setMinimumHeight(h) + + def accept(self): + QDialog.accept(self) + + def reject(self): + QDialog.reject(self) + + def url(self): + return str(self.edit.text())
 
13
14
15
 
16
17
18
 
98
99
100
 
 
101
102
103
 
154
155
156
 
 
 
 
 
 
 
 
 
 
 
157
158
159
 
13
14
15
16
17
18
19
 
99
100
101
102
103
104
105
106
 
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
@@ -13,6 +13,7 @@
 from tortoisehg.hgqt.qtlib import geticon  from tortoisehg.hgqt import cmdui  from tortoisehg.hgqt.repotreemodel import RepoTreeModel +from tortoisehg.hgqt.pathedit import PathEditDialog    from PyQt4 import QtCore, QtGui   @@ -98,6 +99,8 @@
  _("Remove the entry"), None, self.removeSelected),   ("pull", _("Pull"), None,   _("Pull from remote"), None, self.pull), + ("editpath", _("Edit"), None, + _("Edit Path"), None, self.editPath),   ]   return a   @@ -154,6 +157,17 @@
  cmd.show_output(False)   cmd.exec_()   + def editPath(self): + if not self.selitem: + return + pathitem = self.selitem.internalPointer() + d = PathEditDialog(self, pathitem.alias(), pathitem.url()) + d.show() + if d.exec_(): + pathitem.setUrl(d.url()) + i = self.selitem + self.model().dataChanged.emit(i, i) +   def newGroup(self):   m = self.model()   m.addGroup(_('New Group'))
 
230
231
232
 
 
 
 
 
 
233
234
235
 
244
245
246
247
 
248
249
250
 
230
231
232
233
234
235
236
237
238
239
240
241
 
250
251
252
 
253
254
255
256
@@ -230,6 +230,12 @@
  def url(self):   return self._path   + def setUrl(self, url): + self._path = url + + def alias(self): + return self._alias +   def data(self, column, role):   if role == Qt.DecorationRole:   if column == 0: @@ -244,7 +250,7 @@
  return QVariant()     def menulist(self): - return ['pull'] + return ['pull', None, 'editpath' ]     def flags(self):   return Qt.ItemIsEnabled | Qt.ItemIsSelectable