Plugins/VcsPlugins/vcsMercurial/HgTagDialog.py

changeset 3185
d4fa462547bc
parent 3160
209a07d7e401
child 3191
a237994f4235
equal deleted inserted replaced
3182:a4ce50816cba 3185:d4fa462547bc
10 from PyQt4.QtCore import pyqtSlot 10 from PyQt4.QtCore import pyqtSlot
11 from PyQt4.QtGui import QDialog, QDialogButtonBox 11 from PyQt4.QtGui import QDialog, QDialogButtonBox
12 12
13 from .Ui_HgTagDialog import Ui_HgTagDialog 13 from .Ui_HgTagDialog import Ui_HgTagDialog
14 14
15 import UI.PixmapCache
16
15 17
16 class HgTagDialog(QDialog, Ui_HgTagDialog): 18 class HgTagDialog(QDialog, Ui_HgTagDialog):
17 """ 19 """
18 Class implementing a dialog to enter the data for a tagging operation. 20 Class implementing a dialog to enter the data for a tagging operation.
19 """ 21 """
20 CreateRegularTag = 1 22 CreateGlobalTag = 1
21 CreateLocalTag = 2 23 CreateLocalTag = 2
22 DeleteTag = 3 24 DeleteGlobalTag = 3
23 CreateBranch = 4 25 DeleteLocalTag = 4
24 26
25 def __init__(self, taglist, parent=None): 27 def __init__(self, taglist, revision=None, tagName=None, parent=None):
26 """ 28 """
27 Constructor 29 Constructor
28 30
29 @param taglist list of previously entered tags (list of strings) 31 @param taglist list of previously entered tags (list of strings)
32 @param revision revision to set tag for (string)
33 @param tagName name of the tag (string)
30 @param parent parent widget (QWidget) 34 @param parent parent widget (QWidget)
31 """ 35 """
32 super().__init__(parent) 36 super().__init__(parent)
33 self.setupUi(self) 37 self.setupUi(self)
34 38
35 self.okButton = self.buttonBox.button(QDialogButtonBox.Ok) 39 self.okButton = self.buttonBox.button(QDialogButtonBox.Ok)
36 self.okButton.setEnabled(False) 40 self.okButton.setEnabled(False)
37 41
38 self.tagCombo.clear() 42 self.tagCombo.clear()
39 self.tagCombo.addItems(sorted(taglist)) 43 self.tagCombo.addItem("", False)
44 for tag, isLocal in sorted(taglist):
45 if isLocal:
46 icon = UI.PixmapCache.getIcon("vcsTagLocal.png")
47 else:
48 icon = UI.PixmapCache.getIcon("vcsTagGlobal.png")
49 self.tagCombo.addItem(icon, tag, isLocal)
50
51 if revision:
52 self.revisionEdit.setText(revision)
53
54 if tagName:
55 index = self.tagCombo.findText(tagName)
56 if index > -1:
57 self.tagCombo.setCurrentIndex(index)
58 # suggest the most relevant tag action
59 self.deleteTagButton.setChecked(True)
60 else:
61 self.tagCombo.setEditText(tagName)
40 62
41 @pyqtSlot(str) 63 @pyqtSlot(str)
42 def on_tagCombo_editTextChanged(self, text): 64 def on_tagCombo_editTextChanged(self, text):
43 """ 65 """
44 Private method used to enable/disable the OK-button. 66 Private method used to enable/disable the OK-button.
45 67
46 @param text tag name entered in the combo (string) 68 @param text tag name entered in the combo (string)
47 """ 69 """
48 self.okButton.setDisabled(text == "") 70 self.okButton.setDisabled(text == "")
49 71
72 @pyqtSlot(int)
73 def on_tagCombo_currentIndexChanged(self, index):
74 """
75 Private slot setting the local status of the selected entry.
76 """
77 isLocal = self.tagCombo.itemData(index)
78 if isLocal:
79 self.localTagButton.setChecked(True)
80 else:
81 self.globalTagButton.setChecked(True)
82
50 def getParameters(self): 83 def getParameters(self):
51 """ 84 """
52 Public method to retrieve the tag data. 85 Public method to retrieve the tag data.
53 86
54 @return tuple of string and int (tag, tag operation) 87 @return tuple of two strings and int (tag, revision, tag operation)
55 """ 88 """
56 tag = self.tagCombo.currentText() 89 tag = self.tagCombo.currentText()
57 tagOp = 0 90 tagOp = 0
58 if self.createRegularButton.isChecked(): 91 if self.createTagButton.isChecked():
59 tagOp = HgTagDialog.CreateRegularTag 92 if self.globalTagButton.isChecked():
60 elif self.createLocalButton.isChecked(): 93 tagOp = HgTagDialog.CreateGlobalTag
61 tagOp = HgTagDialog.CreateLocalTag 94 else:
62 elif self.deleteButton.isChecked(): 95 tagOp = HgTagDialog.CreateLocalTag
63 tagOp = HgTagDialog.DeleteTag 96 else:
64 return (tag, tagOp) 97 if self.globalTagButton.isChecked():
98 tagOp = HgTagDialog.DeleteGlobalTag
99 else:
100 tagOp = HgTagDialog.DeleteLocalTag
101 return (tag, self.revisionEdit.text(), tagOp)

eric ide

mercurial