Skip to content
Snippets Groups Projects
Commit 1a6f4ca5 authored by Martyn Gigg's avatar Martyn Gigg
Browse files

Wire up progress reporting and error markers to code editor.

Refs #21251
parent f4258a0e
No related branches found
No related tags found
No related merge requests found
...@@ -70,6 +70,7 @@ class PythonFileInterpreterPresenter(QObject): ...@@ -70,6 +70,7 @@ class PythonFileInterpreterPresenter(QObject):
# connect signals # connect signals
self.model.sig_exec_success.connect(self.on_exec_success) self.model.sig_exec_success.connect(self.on_exec_success)
self.model.sig_exec_error.connect(self.on_exec_error) self.model.sig_exec_error.connect(self.on_exec_error)
self.model.sig_exec_progress.connect(self.view.editor.updateProgressMarker)
# starts idle # starts idle
self.view.set_status_message(IDLE_STATUS_MSG) self.view.set_status_message(IDLE_STATUS_MSG)
...@@ -83,7 +84,14 @@ class PythonFileInterpreterPresenter(QObject): ...@@ -83,7 +84,14 @@ class PythonFileInterpreterPresenter(QObject):
return self.model.execute_async(text) return self.model.execute_async(text)
def on_exec_success(self): def on_exec_success(self):
self.view.set_editor_readonly(False)
self.view.set_status_message(IDLE_STATUS_MSG) self.view.set_status_message(IDLE_STATUS_MSG)
def on_exec_error(self): def on_exec_error(self, task_error):
if isinstance(task_error.exception, SyntaxError):
lineno = task_error.exception.lineno
else:
lineno = task_error.stack_entries[-1][1]
self.view.editor.updateProgressMarker(lineno, True)
self.view.set_editor_readonly(False)
self.view.set_status_message(IDLE_STATUS_MSG) self.view.set_status_message(IDLE_STATUS_MSG)
...@@ -30,10 +30,10 @@ class MultiPythonFileInterpreter(QWidget): ...@@ -30,10 +30,10 @@ class MultiPythonFileInterpreter(QWidget):
super(MultiPythonFileInterpreter, self).__init__(parent) super(MultiPythonFileInterpreter, self).__init__(parent)
# layout # layout
self.editors = QTabWidget(self) self._editors = QTabWidget(self)
self.editors.setMovable(True) self._editors.setMovable(True)
layout = QVBoxLayout() layout = QVBoxLayout()
layout.addWidget(self.editors) layout.addWidget(self._editors)
self.setLayout(layout) self.setLayout(layout)
layout.setContentsMargins(0, 0, 0, 0) layout.setContentsMargins(0, 0, 0, 0)
...@@ -42,8 +42,16 @@ class MultiPythonFileInterpreter(QWidget): ...@@ -42,8 +42,16 @@ class MultiPythonFileInterpreter(QWidget):
@property @property
def editor_count(self): def editor_count(self):
return self.editors.count() return self._editors.count()
def current_editor(self):
return self._editors.currentWidget()
def execute_current(self):
self.current_editor().execute_all_async()
def append_new_editor(self): def append_new_editor(self):
title = "New" title = "New"
self.editors.addTab(PythonFileInterpreter(self.editors), title) self._editors.addTab(PythonFileInterpreter(self._editors),
title)
...@@ -29,11 +29,15 @@ from mantidqt.widgets.codeeditor.multifileinterpreter import MultiPythonFileInte ...@@ -29,11 +29,15 @@ from mantidqt.widgets.codeeditor.multifileinterpreter import MultiPythonFileInte
@requires_qapp @requires_qapp
class MultiPythonFileInterpreterTest(unittest.TestCase): class MultiPythonFileInterpreterTest(unittest.TestCase):
# Success tests def test_default_contains_single_editor(self):
widget = MultiPythonFileInterpreter()
self.assertEqual(1, widget.editor_count)
def test_default_contains_single_tab(self): def test_add_editor(self):
widget = MultiPythonFileInterpreter() widget = MultiPythonFileInterpreter()
self.assertEqual(1, widget.editor_count) self.assertEqual(1, widget.editor_count)
widget.append_new_editor()
self.assertEqual(2, widget.editor_count)
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -72,6 +72,9 @@ public: ...@@ -72,6 +72,9 @@ public:
void setReadOnly(bool ro); void setReadOnly(bool ro);
void setText(const QString &text); void setText(const QString &text);
public slots:
void updateProgressMarker(int lineno, bool error);
private: private:
ScriptEditor(const ScriptEditor&); ScriptEditor(const ScriptEditor&);
}; };
...@@ -127,7 +127,7 @@ public slots: ...@@ -127,7 +127,7 @@ public slots:
/// Set the marker state /// Set the marker state
void setMarkerState(bool enabled); void setMarkerState(bool enabled);
/// Update the progress marker /// Update the progress marker
void updateProgressMarker(int lineno, bool error); void updateProgressMarker(int lineno, bool error=false);
/// Mark the progress arrow as an error /// Mark the progress arrow as an error
void markExecutingLineAsError(); void markExecutingLineAsError();
/// Refresh the autocomplete information base on a new set of keywords /// Refresh the autocomplete information base on a new set of keywords
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment