50 self._changeGroupName = "Rename" |
50 self._changeGroupName = "Rename" |
51 |
51 |
52 self.__filename = filename |
52 self.__filename = filename |
53 self.__offset = offset |
53 self.__offset = offset |
54 self.__local = isLocal |
54 self.__local = isLocal |
55 ## self.__renamer = renamer |
55 |
56 ## if resource is not None: |
|
57 ## self.__resources = [resource] |
|
58 ## else: |
|
59 ## self.__resources = None |
|
60 ## |
|
61 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) |
56 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) |
62 self.__okButton.setEnabled(False) |
57 self.__okButton.setEnabled(False) |
63 self.__previewButton = self.buttonBox.addButton( |
58 self.__previewButton = self.buttonBox.addButton( |
64 self.tr("Preview"), QDialogButtonBox.ActionRole) |
59 self.tr("Preview"), QDialogButtonBox.ActionRole) |
65 self.__previewButton.setDefault(True) |
60 self.__previewButton.setDefault(True) |
96 Private method to confirm unsure occurrences. |
91 Private method to confirm unsure occurrences. |
97 |
92 |
98 @param data dictionary containing the change data |
93 @param data dictionary containing the change data |
99 @type dict |
94 @type dict |
100 """ |
95 """ |
101 # TODO: change this to the distributed version |
|
102 if self.ignoreButton.isChecked(): |
96 if self.ignoreButton.isChecked(): |
103 answer = False |
97 answer = False |
104 elif self.matchButton.isChecked(): |
98 elif self.matchButton.isChecked(): |
105 answer = True |
99 answer = True |
106 else: |
100 else: |
107 filename = occurrence.resource.real_path |
101 filename = data["FileName"] |
108 start, end = occurrence.get_primary_range() |
102 start = data["StartOffset"] |
|
103 end = data["EndOffset"] |
109 |
104 |
110 vm = e5App().getObject("ViewManager") |
105 vm = e5App().getObject("ViewManager") |
111 |
106 |
112 # display the file and select the match |
107 # display the file and select the match |
113 vm.openSourceFile(filename) |
108 vm.openSourceFile(filename) |
116 sline, sindex = aw.lineIndexFromPosition(start) |
111 sline, sindex = aw.lineIndexFromPosition(start) |
117 eline, eindex = aw.lineIndexFromPosition(end) |
112 eline, eindex = aw.lineIndexFromPosition(end) |
118 aw.ensureLineVisible(sline) |
113 aw.ensureLineVisible(sline) |
119 aw.gotoLine(sline) |
114 aw.gotoLine(sline) |
120 aw.setSelection(sline, sindex, eline, eindex) |
115 aw.setSelection(sline, sindex, eline, eindex) |
|
116 |
121 answer = E5MessageBox.yesNo( |
117 answer = E5MessageBox.yesNo( |
122 self, |
118 self._ui, |
123 self.tr("Rename"), |
119 self.tr("Rename"), |
124 self.tr("""<p>Is the highlighted code a match?</p>"""), |
120 self.tr("""<p>Is the highlighted code a match?</p>"""), |
125 yesDefault=True) |
121 yesDefault=True) |
|
122 |
126 aw.setCursorPosition(cline, cindex) |
123 aw.setCursorPosition(cline, cindex) |
127 aw.ensureCursorVisible() |
124 aw.ensureCursorVisible() |
128 |
125 |
129 return answer |
126 self._refactoring.sendJson("ConfirmUnsure", { |
|
127 "Answer": answer, |
|
128 }) |
130 |
129 |
131 def _calculateChanges(self): |
130 def _calculateChanges(self): |
132 """ |
131 """ |
133 Protected method to initiate the calculation of the changes. |
132 Protected method to initiate the calculation of the changes. |
134 """ |
133 """ |
|
134 if self.askButton.isChecked(): |
|
135 self.hide() |
|
136 |
135 self._refactoring.sendJson("CalculateRenameChanges", { |
137 self._refactoring.sendJson("CalculateRenameChanges", { |
|
138 "ChangeGroup": self._changeGroupName, |
136 "Title": self._title, |
139 "Title": self._title, |
137 "FileName": self.__filename, |
140 "FileName": self.__filename, |
138 "Offset": self.__offset, |
141 "Offset": self.__offset, |
139 "LocalRename": self.__local, |
142 "LocalRename": self.__local, |
140 "NewName": self.newNameEdit.text(), |
143 "NewName": self.newNameEdit.text(), |
141 "RenameHierarchy": self.allCheckBox.isChecked(), |
144 "RenameHierarchy": self.allCheckBox.isChecked(), |
142 "RenameInStrings": self.stringsCheckBox.isChecked(), |
145 "RenameInStrings": self.stringsCheckBox.isChecked(), |
143 }) |
146 }) |
144 ## try: |
|
145 ## changes = self.__renamer.get_changes( |
|
146 ## self.newNameEdit.text(), |
|
147 ## resources=self.__resources, |
|
148 ## in_hierarchy=self.allCheckBox.isChecked(), |
|
149 ## unsure=self.__confirmUnsure, |
|
150 ## docs=self.stringsCheckBox.isChecked(), |
|
151 ## task_handle=handle) |
|
152 ## return changes |
|
153 ## except Exception as err: |
|
154 ## self._refactoring.handleRopeError(err, self._title, handle) |
|
155 ## return None |
|
156 |
147 |
157 def processChangeData(self, data): |
148 def processChangeData(self, data): |
158 """ |
149 """ |
159 Public method to process the change data sent by the refactoring |
150 Public method to process the change data sent by the refactoring |
160 client. |
151 client. |