ProjectDjangoTagsMenu/IeCommentDialog.py

branch
eric7
changeset 63
85418cf03fdb
parent 60
85d3931419d3
child 69
9acb6987ce60
equal deleted inserted replaced
62:dba433b4f3d6 63:85418cf03fdb
14 14
15 class IeCommentDialog(QDialog, Ui_IeCommentDialog): 15 class IeCommentDialog(QDialog, Ui_IeCommentDialog):
16 """ 16 """
17 Class implementing a dialog to enter data for an IE comment. 17 Class implementing a dialog to enter data for an IE comment.
18 """ 18 """
19
19 def __init__(self, parent=None): 20 def __init__(self, parent=None):
20 """ 21 """
21 Constructor 22 Constructor
22 23
23 @param parent reference to the parent widget 24 @param parent reference to the parent widget
24 @type QWidget 25 @type QWidget
25 """ 26 """
26 super().__init__(parent) 27 super().__init__(parent)
27 self.setupUi(self) 28 self.setupUi(self)
28 29
29 for condStr, condData in [("==", ""), ("<=", " lte"), ("<", " lt"), 30 for condStr, condData in [
30 (">", " gt"), (">=", " gte")]: 31 ("==", ""),
32 ("<=", " lte"),
33 ("<", " lt"),
34 (">", " gt"),
35 (">=", " gte"),
36 ]:
31 self.conditionalComboBox.addItem(condStr, condData) 37 self.conditionalComboBox.addItem(condStr, condData)
32 38
33 msh = self.minimumSizeHint() 39 msh = self.minimumSizeHint()
34 self.resize(max(self.width(), msh.width()), msh.height()) 40 self.resize(max(self.width(), msh.width()), msh.height())
35 41
36 def getData(self): 42 def getData(self):
37 """ 43 """
38 Public method to retrieve the entered data. 44 Public method to retrieve the entered data.
39 45
40 @return tuple of condition and version 46 @return tuple of condition and version
41 @rtype tuple of (str, int) 47 @rtype tuple of (str, int)
42 """ 48 """
43 return (self.conditionalComboBox.itemData( 49 return (
44 self.conditionalComboBox.currentIndex()), 50 self.conditionalComboBox.itemData(self.conditionalComboBox.currentIndex()),
45 self.versionSpinBox.value()) 51 self.versionSpinBox.value(),
46 52 )
53
47 @staticmethod 54 @staticmethod
48 def getTag(selectedText): 55 def getTag(selectedText):
49 """ 56 """
50 Public static method to get the formatted tag. 57 Public static method to get the formatted tag.
51 58
52 @param selectedText selected text to embed 59 @param selectedText selected text to embed
53 @type str 60 @type str
54 @return formatted tag and a flag indicating the acceptance state 61 @return formatted tag and a flag indicating the acceptance state
55 @rtype tuple of (str, bool) 62 @rtype tuple of (str, bool)
56 """ 63 """
57 dlg = IeCommentDialog() 64 dlg = IeCommentDialog()
58 if dlg.exec() == QDialog.DialogCode.Accepted: 65 if dlg.exec() == QDialog.DialogCode.Accepted:
59 condition, version = dlg.getData() 66 condition, version = dlg.getData()
60 tag = '[if{0} IE {1}]> {2} <![endif]'.format( 67 tag = "[if{0} IE {1}]> {2} <![endif]".format(
61 condition, version, selectedText) 68 condition, version, selectedText
69 )
62 return tag, True 70 return tag, True
63 else: 71 else:
64 return "", False 72 return "", False

eric ide

mercurial