eric6/Plugins/VcsPlugins/vcsMercurial/HgTagDialog.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2010 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the data for a tagging operation.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
14
15 from .Ui_HgTagDialog import Ui_HgTagDialog
16
17 import UI.PixmapCache
18
19
20 class HgTagDialog(QDialog, Ui_HgTagDialog):
21 """
22 Class implementing a dialog to enter the data for a tagging operation.
23 """
24 CreateGlobalTag = 1
25 CreateLocalTag = 2
26 DeleteGlobalTag = 3
27 DeleteLocalTag = 4
28
29 def __init__(self, taglist, revision=None, tagName=None, parent=None):
30 """
31 Constructor
32
33 @param taglist list of previously entered tags (list of strings)
34 @param revision revision to set tag for (string)
35 @param tagName name of the tag (string)
36 @param parent parent widget (QWidget)
37 """
38 super(HgTagDialog, self).__init__(parent)
39 self.setupUi(self)
40
41 self.okButton = self.buttonBox.button(QDialogButtonBox.Ok)
42 self.okButton.setEnabled(False)
43
44 self.tagCombo.clear()
45 self.tagCombo.addItem("", False)
46 for tag, isLocal in sorted(taglist, reverse=True):
47 if isLocal:
48 icon = UI.PixmapCache.getIcon("vcsTagLocal.png")
49 else:
50 icon = UI.PixmapCache.getIcon("vcsTagGlobal.png")
51 self.tagCombo.addItem(icon, tag, isLocal)
52
53 if revision:
54 self.revisionEdit.setText(revision)
55
56 if tagName:
57 index = self.tagCombo.findText(tagName)
58 if index > -1:
59 self.tagCombo.setCurrentIndex(index)
60 # suggest the most relevant tag action
61 self.deleteTagButton.setChecked(True)
62 else:
63 self.tagCombo.setEditText(tagName)
64
65 msh = self.minimumSizeHint()
66 self.resize(max(self.width(), msh.width()), msh.height())
67
68 @pyqtSlot(str)
69 def on_tagCombo_editTextChanged(self, text):
70 """
71 Private method used to enable/disable the OK-button.
72
73 @param text tag name entered in the combo (string)
74 """
75 self.okButton.setDisabled(text == "")
76
77 @pyqtSlot(int)
78 def on_tagCombo_currentIndexChanged(self, index):
79 """
80 Private slot setting the local status of the selected entry.
81
82 @param index index of the selected entrie (integer)
83 """
84 isLocal = self.tagCombo.itemData(index)
85 if isLocal:
86 self.localTagButton.setChecked(True)
87 else:
88 self.globalTagButton.setChecked(True)
89
90 def getParameters(self):
91 """
92 Public method to retrieve the tag data.
93
94 @return tuple containing the tag, revision, tag operation and a flag
95 indicating to enforce the operation
96 @rtype tuple of str, str, int,bool
97 """
98 tag = self.tagCombo.currentText().replace(" ", "_")
99 tagOp = 0
100 if self.createTagButton.isChecked():
101 if self.globalTagButton.isChecked():
102 tagOp = HgTagDialog.CreateGlobalTag
103 else:
104 tagOp = HgTagDialog.CreateLocalTag
105 else:
106 if self.globalTagButton.isChecked():
107 tagOp = HgTagDialog.DeleteGlobalTag
108 else:
109 tagOp = HgTagDialog.DeleteLocalTag
110 return (tag, self.revisionEdit.text(), tagOp,
111 self.forceCheckBox.isChecked)

eric ide

mercurial