10 import re |
10 import re |
11 |
11 |
12 from PyQt6.QtCore import pyqtSlot, pyqtSignal, Qt, QFileInfo |
12 from PyQt6.QtCore import pyqtSlot, pyqtSignal, Qt, QFileInfo |
13 from PyQt6.QtWidgets import QWidget, QTreeWidgetItem |
13 from PyQt6.QtWidgets import QWidget, QTreeWidgetItem |
14 |
14 |
15 from E5Gui.E5Application import e5App |
15 from E5Gui.EricApplication import ericApp |
16 from E5Gui import E5FileDialog, E5MessageBox |
16 from E5Gui import EricFileDialog, EricMessageBox |
17 |
17 |
18 from .Ui_CallTraceViewer import Ui_CallTraceViewer |
18 from .Ui_CallTraceViewer import Ui_CallTraceViewer |
19 |
19 |
20 import UI.PixmapCache |
20 import UI.PixmapCache |
21 import Preferences |
21 import Preferences |
150 def on_saveButton_clicked(self): |
150 def on_saveButton_clicked(self): |
151 """ |
151 """ |
152 Private slot to save the call trace info to a file. |
152 Private slot to save the call trace info to a file. |
153 """ |
153 """ |
154 if self.callTrace.topLevelItemCount() > 0: |
154 if self.callTrace.topLevelItemCount() > 0: |
155 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
155 fname, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( |
156 self, |
156 self, |
157 self.tr("Save Call Trace Info"), |
157 self.tr("Save Call Trace Info"), |
158 "", |
158 "", |
159 self.tr("Text Files (*.txt);;All Files (*)"), |
159 self.tr("Text Files (*.txt);;All Files (*)"), |
160 None, |
160 None, |
161 E5FileDialog.DontConfirmOverwrite) |
161 EricFileDialog.DontConfirmOverwrite) |
162 if fname: |
162 if fname: |
163 ext = QFileInfo(fname).suffix() |
163 ext = QFileInfo(fname).suffix() |
164 if not ext: |
164 if not ext: |
165 ex = selectedFilter.split("(*")[1].split(")")[0] |
165 ex = selectedFilter.split("(*")[1].split(")")[0] |
166 if ex: |
166 if ex: |
167 fname += ex |
167 fname += ex |
168 if QFileInfo(fname).exists(): |
168 if QFileInfo(fname).exists(): |
169 res = E5MessageBox.yesNo( |
169 res = EricMessageBox.yesNo( |
170 self, |
170 self, |
171 self.tr("Save Call Trace Info"), |
171 self.tr("Save Call Trace Info"), |
172 self.tr("<p>The file <b>{0}</b> already exists." |
172 self.tr("<p>The file <b>{0}</b> already exists." |
173 " Overwrite it?</p>").format(fname), |
173 " Overwrite it?</p>").format(fname), |
174 icon=E5MessageBox.Warning) |
174 icon=EricMessageBox.Warning) |
175 if not res: |
175 if not res: |
176 return |
176 return |
177 fname = Utilities.toNativeSeparators(fname) |
177 fname = Utilities.toNativeSeparators(fname) |
178 |
178 |
179 try: |
179 try: |
189 f.write("{0} {1} || {2}\n".format( |
189 f.write("{0} {1} || {2}\n".format( |
190 call, |
190 call, |
191 itm.text(1), itm.text(2))) |
191 itm.text(1), itm.text(2))) |
192 itm = self.callTrace.itemBelow(itm) |
192 itm = self.callTrace.itemBelow(itm) |
193 except OSError as err: |
193 except OSError as err: |
194 E5MessageBox.critical( |
194 EricMessageBox.critical( |
195 self, |
195 self, |
196 self.tr("Error saving Call Trace Info"), |
196 self.tr("Error saving Call Trace Info"), |
197 self.tr("""<p>The call trace info could not""" |
197 self.tr("""<p>The call trace info could not""" |
198 """ be written to <b>{0}</b></p>""" |
198 """ be written to <b>{0}</b></p>""" |
199 """<p>Reason: {1}</p>""") |
199 """<p>Reason: {1}</p>""") |
240 @param enabled flag indicating to enable the project mode |
240 @param enabled flag indicating to enable the project mode |
241 @type bool |
241 @type bool |
242 """ |
242 """ |
243 self.__projectMode = enabled |
243 self.__projectMode = enabled |
244 if enabled and self.__project is None: |
244 if enabled and self.__project is None: |
245 self.__project = e5App().getObject("Project") |
245 self.__project = ericApp().getObject("Project") |
246 |
246 |
247 def __addCallTraceInfo(self, isCall, fromFile, fromLine, fromFunction, |
247 def __addCallTraceInfo(self, isCall, fromFile, fromLine, fromFunction, |
248 toFile, toLine, toFunction, debuggerId): |
248 toFile, toLine, toFunction, debuggerId): |
249 """ |
249 """ |
250 Private method to add an entry to the call trace viewer. |
250 Private method to add an entry to the call trace viewer. |