15 |
15 |
16 class RefactoringDialogBase(QDialog): |
16 class RefactoringDialogBase(QDialog): |
17 """ |
17 """ |
18 Class implementing the Refactoring dialog base class. |
18 Class implementing the Refactoring dialog base class. |
19 """ |
19 """ |
|
20 |
20 def __init__(self, refactoring, title, parent=None): |
21 def __init__(self, refactoring, title, parent=None): |
21 """ |
22 """ |
22 Constructor |
23 Constructor |
23 |
24 |
24 @param refactoring reference to the main refactoring object |
25 @param refactoring reference to the main refactoring object |
25 @type RefactoringServer |
26 @type RefactoringServer |
26 @param title title of the dialog |
27 @param title title of the dialog |
27 @type str |
28 @type str |
28 @param parent reference to the parent widget |
29 @param parent reference to the parent widget |
29 @type QWidget |
30 @type QWidget |
30 """ |
31 """ |
31 QDialog.__init__(self, parent) |
32 QDialog.__init__(self, parent) |
32 self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) |
33 self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) |
33 self.setWindowTitle(title) |
34 self.setWindowTitle(title) |
34 |
35 |
35 self._ui = parent |
36 self._ui = parent |
36 self._refactoring = refactoring |
37 self._refactoring = refactoring |
37 self._title = title |
38 self._title = title |
38 |
39 |
39 self._changesCalculated = False |
40 self._changesCalculated = False |
40 |
41 |
41 self.__queue = [] |
42 self.__queue = [] |
42 |
43 |
43 def getChangeGroupName(self): |
44 def getChangeGroupName(self): |
44 """ |
45 """ |
45 Public method to get the name of the change group. |
46 Public method to get the name of the change group. |
46 |
47 |
47 @return name of the associated change group |
48 @return name of the associated change group |
48 @rtype str |
49 @rtype str |
49 """ |
50 """ |
50 return self._changeGroupName |
51 return self._changeGroupName |
51 |
52 |
52 def _calculateChanges(self): |
53 def _calculateChanges(self): |
53 """ |
54 """ |
54 Protected method to initiate the calculation of changes. |
55 Protected method to initiate the calculation of changes. |
55 |
56 |
56 @exception NotImplementedError raised to indicate that this method must |
57 @exception NotImplementedError raised to indicate that this method must |
57 be overridden by subclasses |
58 be overridden by subclasses |
58 """ |
59 """ |
59 raise NotImplementedError("_calculateChanges must be overridden.") |
60 raise NotImplementedError("_calculateChanges must be overridden.") |
60 |
61 |
61 def requestPreview(self): |
62 def requestPreview(self): |
62 """ |
63 """ |
63 Public method to request a preview of the calculated changes. |
64 Public method to request a preview of the calculated changes. |
64 """ |
65 """ |
65 self.__queue.append(("PreviewChanges", { |
66 self.__queue.append( |
66 "ChangeGroup": self._changeGroupName, |
67 ( |
67 })) |
68 "PreviewChanges", |
68 |
69 { |
|
70 "ChangeGroup": self._changeGroupName, |
|
71 }, |
|
72 ) |
|
73 ) |
|
74 |
69 self._calculateChanges() |
75 self._calculateChanges() |
70 |
76 |
71 def previewChanges(self, data): |
77 def previewChanges(self, data): |
72 """ |
78 """ |
73 Public method to preview the changes. |
79 Public method to preview the changes. |
74 |
80 |
75 @param data dictionary containing the change data |
81 @param data dictionary containing the change data |
76 @type dict |
82 @type dict |
77 """ |
83 """ |
78 from .ChangesPreviewDialog import ChangesPreviewDialog |
84 from .ChangesPreviewDialog import ChangesPreviewDialog |
79 dlg = ChangesPreviewDialog( |
85 |
80 data["Description"], data["Changes"], self) |
86 dlg = ChangesPreviewDialog(data["Description"], data["Changes"], self) |
81 if dlg.exec() == QDialog.DialogCode.Accepted: |
87 if dlg.exec() == QDialog.DialogCode.Accepted: |
82 self.applyChanges() |
88 self.applyChanges() |
83 |
89 |
84 def applyChanges(self): |
90 def applyChanges(self): |
85 """ |
91 """ |
86 Public method to apply the changes. |
92 Public method to apply the changes. |
87 """ |
93 """ |
88 if not self._changesCalculated: |
94 if not self._changesCalculated: |
89 self.__queue.append(("ApplyChanges", { |
95 self.__queue.append( |
90 "ChangeGroup": self._changeGroupName, |
96 ( |
91 "Title": self._title, |
97 "ApplyChanges", |
92 })) |
98 { |
|
99 "ChangeGroup": self._changeGroupName, |
|
100 "Title": self._title, |
|
101 }, |
|
102 ) |
|
103 ) |
93 self._calculateChanges() |
104 self._calculateChanges() |
94 else: |
105 else: |
95 self._refactoring.sendJson("ApplyChanges", { |
106 self._refactoring.sendJson( |
96 "ChangeGroup": self._changeGroupName, |
107 "ApplyChanges", |
97 "Title": self._title, |
108 { |
98 }) |
109 "ChangeGroup": self._changeGroupName, |
99 |
110 "Title": self._title, |
|
111 }, |
|
112 ) |
|
113 |
100 def processChangeData(self, data): |
114 def processChangeData(self, data): |
101 """ |
115 """ |
102 Public method to process the change data sent by the refactoring |
116 Public method to process the change data sent by the refactoring |
103 client. |
117 client. |
104 |
118 |
105 @param data dictionary containing the change data |
119 @param data dictionary containing the change data |
106 @type dict |
120 @type dict |
107 """ |
121 """ |
108 subcommand = data["Subcommand"] |
122 subcommand = data["Subcommand"] |
109 if subcommand == "PreviewChanges": |
123 if subcommand == "PreviewChanges": |