Plugins/VcsPlugins/vcsGit/GitTagDialog.py

changeset 6020
baf6da1ae288
child 6048
82ad8ec9548c
equal deleted inserted replaced
6019:58ecdaf0b789 6020:baf6da1ae288
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2014 - 2017 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_GitTagDialog import Ui_GitTagDialog
16
17
18 class GitTagDialog(QDialog, Ui_GitTagDialog):
19 """
20 Class implementing a dialog to enter the data for a tagging operation.
21 """
22 CreateTag = 1
23 DeleteTag = 2
24 VerifyTag = 3
25
26 AnnotatedTag = 1
27 SignedTag = 2
28 LocalTag = 3
29
30 def __init__(self, taglist, revision=None, tagName=None, parent=None):
31 """
32 Constructor
33
34 @param taglist list of previously entered tags (list of strings)
35 @param revision revision to set tag for (string)
36 @param tagName name of the tag (string)
37 @param parent parent widget (QWidget)
38 """
39 super(GitTagDialog, self).__init__(parent)
40 self.setupUi(self)
41
42 self.okButton = self.buttonBox.button(QDialogButtonBox.Ok)
43 self.okButton.setEnabled(False)
44
45 self.tagCombo.clear()
46 self.tagCombo.addItem("")
47 self.tagCombo.addItems(sorted(taglist, reverse=True))
48
49 if revision:
50 self.revisionEdit.setText(revision)
51
52 if tagName:
53 index = self.tagCombo.findText(tagName)
54 if index > -1:
55 self.tagCombo.setCurrentIndex(index)
56 # suggest the most relevant tag action
57 self.verifyTagButton.setChecked(True)
58 else:
59 self.tagCombo.setEditText(tagName)
60 self.createTagButton.setChecked(True)
61
62 msh = self.minimumSizeHint()
63 self.resize(max(self.width(), msh.width()), msh.height())
64
65 @pyqtSlot(str)
66 def on_tagCombo_editTextChanged(self, text):
67 """
68 Private method used to enable/disable the OK-button.
69
70 @param text tag name entered in the combo (string)
71 """
72 self.okButton.setDisabled(text == "")
73
74 def getParameters(self):
75 """
76 Public method to retrieve the tag data.
77
78 @return tuple of two strings, two int and a boolean (tag, revision,
79 tag operation, tag type, enforce operation)
80 """
81 tag = self.tagCombo.currentText().replace(" ", "_")
82
83 if self.createTagButton.isChecked():
84 tagOp = GitTagDialog.CreateTag
85 elif self.deleteTagButton.isChecked():
86 tagOp = GitTagDialog.DeleteTag
87 else:
88 tagOp = GitTagDialog.VerifyTag
89
90 if self.globalTagButton.isChecked():
91 tagType = GitTagDialog.AnnotatedTag
92 elif self.signedTagButton.isChecked():
93 tagType = GitTagDialog.SignedTag
94 else:
95 tagType = GitTagDialog.LocalTag
96
97 return (tag, self.revisionEdit.text(), tagOp, tagType,
98 self.forceCheckBox.isChecked())

eric ide

mercurial