eric7/Plugins/VcsPlugins/vcsMercurial/HgTagDialog.py

branch
eric7
changeset 8312
800c432b34c8
parent 8259
2bbec88047dd
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2010 - 2021 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 PyQt5.QtCore import pyqtSlot
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
12
13 from .Ui_HgTagDialog import Ui_HgTagDialog
14
15 import UI.PixmapCache
16
17
18 class HgTagDialog(QDialog, Ui_HgTagDialog):
19 """
20 Class implementing a dialog to enter the data for a tagging operation.
21 """
22 CreateGlobalTag = 1
23 CreateLocalTag = 2
24 DeleteGlobalTag = 3
25 DeleteLocalTag = 4
26
27 def __init__(self, taglist, revision=None, tagName=None, parent=None):
28 """
29 Constructor
30
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)
34 @param parent parent widget (QWidget)
35 """
36 super().__init__(parent)
37 self.setupUi(self)
38
39 self.okButton = self.buttonBox.button(
40 QDialogButtonBox.StandardButton.Ok)
41 self.okButton.setEnabled(False)
42
43 self.tagCombo.clear()
44 self.tagCombo.addItem("", False)
45 for tag, isLocal in sorted(taglist, reverse=True):
46 icon = (
47 UI.PixmapCache.getIcon("vcsTagLocal")
48 if isLocal else
49 UI.PixmapCache.getIcon("vcsTagGlobal")
50 )
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