5 |
5 |
6 """ |
6 """ |
7 Module implementing a dialog to enter data for an IE comment. |
7 Module implementing a dialog to enter data for an IE comment. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt5.QtWidgets import QDialog |
10 from PyQt6.QtWidgets import QDialog |
11 |
11 |
12 from .Ui_IeCommentDialog import Ui_IeCommentDialog |
12 from .Ui_IeCommentDialog import Ui_IeCommentDialog |
13 |
13 |
14 |
14 |
15 class IeCommentDialog(QDialog, Ui_IeCommentDialog): |
15 class IeCommentDialog(QDialog, Ui_IeCommentDialog): |
18 """ |
18 """ |
19 def __init__(self, parent=None): |
19 def __init__(self, parent=None): |
20 """ |
20 """ |
21 Constructor |
21 Constructor |
22 |
22 |
23 @param parent reference to the parent widget (QWidget) |
23 @param parent reference to the parent widget |
|
24 @type QWidget |
24 """ |
25 """ |
25 super().__init__(parent) |
26 super().__init__(parent) |
26 self.setupUi(self) |
27 self.setupUi(self) |
27 |
28 |
28 for condStr, condData in [("==", ""), ("<=", " lte"), ("<", " lt"), |
29 for condStr, condData in [("==", ""), ("<=", " lte"), ("<", " lt"), |
34 |
35 |
35 def getData(self): |
36 def getData(self): |
36 """ |
37 """ |
37 Public method to retrieve the entered data. |
38 Public method to retrieve the entered data. |
38 |
39 |
39 @return tuple of condition (string) and version (integer) |
40 @return tuple of condition and version |
|
41 @rtype tuple of (str, int) |
40 """ |
42 """ |
41 return (self.conditionalComboBox.itemData( |
43 return (self.conditionalComboBox.itemData( |
42 self.conditionalComboBox.currentIndex()), |
44 self.conditionalComboBox.currentIndex()), |
43 self.versionSpinBox.value()) |
45 self.versionSpinBox.value()) |
44 |
46 |
45 @staticmethod |
47 @staticmethod |
46 def getTag(selectedText): |
48 def getTag(selectedText): |
47 """ |
49 """ |
48 Public static method to get the formatted tag. |
50 Public static method to get the formatted tag. |
49 |
51 |
50 @param selectedText selected text to embed (string) |
52 @param selectedText selected text to embed |
51 @return formatted tag (string) and a flag indicating the acceptance |
53 @type str |
52 state (boolean) |
54 @return formatted tag and a flag indicating the acceptance state |
|
55 @rtype tuple of (str, bool) |
53 """ |
56 """ |
54 dlg = IeCommentDialog() |
57 dlg = IeCommentDialog() |
55 if dlg.exec() == QDialog.Accepted: |
58 if dlg.exec() == QDialog.DialogCode.Accepted: |
56 condition, version = dlg.getData() |
59 condition, version = dlg.getData() |
57 tag = '[if{0} IE {1}]> {2} <![endif]'.format( |
60 tag = '[if{0} IE {1}]> {2} <![endif]'.format( |
58 condition, version, selectedText) |
61 condition, version, selectedText) |
59 return tag, True |
62 return tag, True |
60 else: |
63 else: |