Mercurial > octave
view libgui/src/documentation-dock-widget.cc @ 27302:5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
* interpreter-qobject.h, interpreter-qobject.cc
(interpreter_qobject::m_interpreter): New data member.
(interpreter_qobject::execute): Cache pointer to interpreter after it
is created. Set it to nullptr before exiting to disable interpreter
events.
(interpreter_qobject::interpreter_event): New functions.
* octave-qobject.h, octave-qobject.cc
(octave_qapplication::interpreter_event): New signals.
(base_qobject::interpreter_event): New slots. Forward action to
m_interpreter object interpreter_event functions.
(base_qobject::base_qobject): Connect interpreter_event
signals for octave_qapplication to the base_qobject::interpreter_event
slots.
(octave_qapplication::notify): Emit interpreter_event signal instead
of using event_manager::post_exception.
* qt-interpreter-events.cc: Declare and register octave::fcn_callback
and octave::meth_callback as Qt meta types.
* event-manager.h, event-manager.cc (event_manager::m_interpreter):
New data member. Update constructor, change all uses.
(octave::fcn_callback, octave::meth_callback): New typedefs.
(event_manager::post_event): Limit allowable callback function
signatures. For meth_callback functions, arrange for a reference to
the interpreter object to be passed as the first argument.
(event_manager::post_exception): Delete.
(event_manager::rethrow_exception_callback): Delete.
* GLCanvas.cc (GLCanvas::do_print): Use event_manager::post_event
instead of event_manager::post_exception.
* file-editor-tab.h (file_eitor_tab::interpreter_event): New signals.
* file-editor.cc (file_editor::add_file_editor_tab): Forward
interpreter_event signal from newly constructed file_editor_tab object
to the interpreter_event signal of the file_editor object.
* main-window.h, main-window.cc (main_window::construct):
Connect the interpreter_event signal from the main_window object to
the parent octave_qobject object.
(main_window::interpreter_event): New signals.
* octave-dock-widget.h, octave-dock-widget.cc
(octave_dock_widget::octave_dock_widget) Forward the interpreter_event
signal from the octave_dock_widget object to the interpreter_event
signal for parent main_window object.
(octave_dock_widget::interpreter_event): New signals.
* variable-editor-model.h, variable-editor-model.cc
(variable_editor_model::init_from_oct,
variable_editor_model::retrieve_variable): Accept reference to
interpreter object as an argument. Change all uses.
(variable_editor_model::interpreter_event): New signals.
* variable-editor.cc (variable_editor::edit_variable):
Forward interpreter_event signal from newly constructed
variable_editor_model to interpreter_event signal fro variable_editor
object.
* files-dock-widget.cc, file-editor-tab.cc, main-window.cc,
variable-editor-model.cc: In all functions that need to perform
interpreter actions, emit an interpreter_event signal instead of
accessing the interprter event_manager and calling
post_interpreter_event directly.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 29 Jul 2019 10:43:04 -0400 |
parents | 00f796120a6d |
children | 0495b64288f7 |
line wrap: on
line source
/* Copyright (C) 2011-2019 Jacob Dawid This file is part of Octave. Octave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Octave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Octave; see the file COPYING. If not, see <https://www.gnu.org/licenses/>. */ #if defined (HAVE_CONFIG_H) # include "config.h" #endif #include "documentation-dock-widget.h" #include "help.h" namespace octave { documentation_dock_widget::documentation_dock_widget (QWidget *p) : octave_dock_widget ("DocumentationDockWidget", p) { setWindowIcon (QIcon (":/actions/icons/logo.png")); set_title (tr ("Documentation")); setStatusTip (tr ("See the documentation for help.")); m_docs = new documentation (this); setWidget (m_docs); connect (p, SIGNAL (show_doc_signal (const QString&)), this, SLOT (showDoc (const QString&))); connect (p, SIGNAL (register_doc_signal (const QString&)), this, SLOT (registerDoc (const QString&))); connect (p, SIGNAL (unregister_doc_signal (const QString&)), this, SLOT (unregisterDoc (const QString&))); } documentation_dock_widget::~documentation_dock_widget (void) { if (m_docs) delete m_docs; } void documentation_dock_widget::notice_settings (const QSettings *settings) { m_docs->notice_settings (settings); } void documentation_dock_widget::copyClipboard (void) { m_docs->copyClipboard (); } void documentation_dock_widget::pasteClipboard (void) { m_docs->pasteClipboard (); } void documentation_dock_widget::selectAll (void) { m_docs->selectAll (); } void documentation_dock_widget::showDoc (const QString& name) { // show the doc pane without focus for carrying on typing in the console if (! isVisible ()) setVisible (true); raise (); m_docs->load_ref (name); } void documentation_dock_widget::registerDoc (const QString& name) { m_docs->registerDoc (name); } void documentation_dock_widget::unregisterDoc (const QString& name) { m_docs->unregisterDoc (name); } }