RefactoringRope/InlineDialog.py

branch
eric7
changeset 389
4f53795beff0
parent 374
958f34e97952
child 409
65153bf17e8d
equal deleted inserted replaced
388:cb044ec27c24 389:4f53795beff0
16 16
17 class InlineDialog(RefactoringDialogBase, Ui_InlineDialog): 17 class InlineDialog(RefactoringDialogBase, Ui_InlineDialog):
18 """ 18 """
19 Class implementing the Inline dialog. 19 Class implementing the Inline dialog.
20 """ 20 """
21
21 def __init__(self, refactoring, title, filename, offset, parent=None): 22 def __init__(self, refactoring, title, filename, offset, parent=None):
22 """ 23 """
23 Constructor 24 Constructor
24 25
25 @param refactoring reference to the main refactoring object 26 @param refactoring reference to the main refactoring object
26 @type RefactoringServer 27 @type RefactoringServer
27 @param title title of the dialog 28 @param title title of the dialog
28 @type str 29 @type str
29 @param filename file name to be worked on 30 @param filename file name to be worked on
33 @param parent reference to the parent widget 34 @param parent reference to the parent widget
34 @type QWidget 35 @type QWidget
35 """ 36 """
36 RefactoringDialogBase.__init__(self, refactoring, title, parent) 37 RefactoringDialogBase.__init__(self, refactoring, title, parent)
37 self.setupUi(self) 38 self.setupUi(self)
38 39
39 self._changeGroupName = "Inline" 40 self._changeGroupName = "Inline"
40 41
41 self.__filename = filename 42 self.__filename = filename
42 self.__offset = offset 43 self.__offset = offset
43 44
44 self.__okButton = self.buttonBox.button( 45 self.__okButton = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok)
45 QDialogButtonBox.StandardButton.Ok)
46 self.__previewButton = self.buttonBox.addButton( 46 self.__previewButton = self.buttonBox.addButton(
47 self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole) 47 self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole
48 )
48 self.__previewButton.setDefault(True) 49 self.__previewButton.setDefault(True)
49 50
50 self.__inlinerKind = "" 51 self.__inlinerKind = ""
51 52
52 self._refactoring.sendJson("RequestInlineType", { 53 self._refactoring.sendJson(
53 "ChangeGroup": self._changeGroupName, 54 "RequestInlineType",
54 "Title": self._title, 55 {
55 "FileName": self.__filename, 56 "ChangeGroup": self._changeGroupName,
56 "Offset": self.__offset, 57 "Title": self._title,
57 }) 58 "FileName": self.__filename,
58 59 "Offset": self.__offset,
60 },
61 )
62
59 def __processInlineType(self, data): 63 def __processInlineType(self, data):
60 """ 64 """
61 Private method to process the inline type data sent by the refactoring 65 Private method to process the inline type data sent by the refactoring
62 client in order to polish the dialog. 66 client in order to polish the dialog.
63 67
64 @param data dictionary containing the inline type data 68 @param data dictionary containing the inline type data
65 @type dict 69 @type dict
66 """ 70 """
67 self.__inlinerKind = data["Kind"] 71 self.__inlinerKind = data["Kind"]
68 72
69 if data["Kind"] == "parameter": 73 if data["Kind"] == "parameter":
70 self.removeCheckBox.setVisible(False) 74 self.removeCheckBox.setVisible(False)
71 self.currentCheckBox.setVisible(False) 75 self.currentCheckBox.setVisible(False)
72 self.hierarchyCheckBox.setVisible(True) 76 self.hierarchyCheckBox.setVisible(True)
73 else: 77 else:
75 self.currentCheckBox.setVisible(True) 79 self.currentCheckBox.setVisible(True)
76 self.hierarchyCheckBox.setVisible(False) 80 self.hierarchyCheckBox.setVisible(False)
77 self.resize(500, 20) 81 self.resize(500, 20)
78 82
79 self.description.setText( 83 self.description.setText(
80 self.tr("Inlining occurrences of <b>{0}</b> (type '<i>{1}</i>').") 84 self.tr("Inlining occurrences of <b>{0}</b> (type '<i>{1}</i>').").format(
81 .format(data["Name"], data["Kind"])) 85 data["Name"], data["Kind"]
82 86 )
87 )
88
83 msh = self.minimumSizeHint() 89 msh = self.minimumSizeHint()
84 self.resize(max(self.width(), msh.width()), msh.height()) 90 self.resize(max(self.width(), msh.width()), msh.height())
85 91
86 @pyqtSlot(QAbstractButton) 92 @pyqtSlot(QAbstractButton)
87 def on_buttonBox_clicked(self, button): 93 def on_buttonBox_clicked(self, button):
88 """ 94 """
89 Private slot to act on the button pressed. 95 Private slot to act on the button pressed.
90 96
91 @param button reference to the button pressed 97 @param button reference to the button pressed
92 @type QAbstractButton 98 @type QAbstractButton
93 """ 99 """
94 if button == self.__previewButton: 100 if button == self.__previewButton:
95 self.requestPreview() 101 self.requestPreview()
96 elif button == self.__okButton: 102 elif button == self.__okButton:
97 self.applyChanges() 103 self.applyChanges()
98 104
99 def _calculateChanges(self): 105 def _calculateChanges(self):
100 """ 106 """
101 Protected method to initiate the calculation of the changes. 107 Protected method to initiate the calculation of the changes.
102 """ 108 """
103 self._refactoring.sendJson("CalculateInlineChanges", { 109 self._refactoring.sendJson(
104 "ChangeGroup": self._changeGroupName, 110 "CalculateInlineChanges",
105 "Title": self._title, 111 {
106 "FileName": self.__filename, 112 "ChangeGroup": self._changeGroupName,
107 "Offset": self.__offset, 113 "Title": self._title,
108 "Kind": self.__inlinerKind, 114 "FileName": self.__filename,
109 "Hierarchy": self.hierarchyCheckBox.isChecked(), 115 "Offset": self.__offset,
110 "Remove": self.removeCheckBox.isChecked(), 116 "Kind": self.__inlinerKind,
111 "OnlyCurrent": self.currentCheckBox.isChecked(), 117 "Hierarchy": self.hierarchyCheckBox.isChecked(),
112 }) 118 "Remove": self.removeCheckBox.isChecked(),
113 119 "OnlyCurrent": self.currentCheckBox.isChecked(),
120 },
121 )
122
114 def processChangeData(self, data): 123 def processChangeData(self, data):
115 """ 124 """
116 Public method to process the change data sent by the refactoring 125 Public method to process the change data sent by the refactoring
117 client. 126 client.
118 127
119 @param data dictionary containing the change data 128 @param data dictionary containing the change data
120 @type dict 129 @type dict
121 """ 130 """
122 subcommand = data["Subcommand"] 131 subcommand = data["Subcommand"]
123 if subcommand == "InlineType": 132 if subcommand == "InlineType":

eric ide

mercurial