Mercurial > octave
changeset 31699:ca3e6e324d54
use signal/slot connection for debugging tooltips in editor
* octave-qscintilla.h, octave-qscintilla.cc
(octave_qscintalla::show_symbol_tooltip_signal): New signal.
(octave_qscintalla::event): Emit show_symbol_tooltip_signal instead of
accessing workspace model through octave_qobject.
* file-editor.h, file-editor.cc
(file_editor::show_symbol_tooltip_signal): New signal.
(file_editor::make_file_editor_tab):
Forward show_symbol_tooltip_signal from octave_qscintalla to file_editor.
* workspace-model.h, workspace-model.cc
(workspace_model::show_symbol_tooltip): New function.
* main-window.cc (main_window::adopt_editor_widget):
Connect file_editor::show_symbol_tooltip_signal to
workspace_model::show_symbol_tooltip slot.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 02 Jan 2023 12:25:42 -0500 |
parents | 276a992d0c08 |
children | 14084c7a32ed |
files | libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h libgui/src/m-editor/octave-qscintilla.cc libgui/src/m-editor/octave-qscintilla.h libgui/src/main-window.cc libgui/src/workspace-model.cc libgui/src/workspace-model.h |
diffstat | 7 files changed, 29 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc Fri Dec 30 23:18:49 2022 -0500 +++ b/libgui/src/m-editor/file-editor.cc Mon Jan 02 12:25:42 2023 -0500 @@ -2444,6 +2444,9 @@ file_editor_tab *f = new file_editor_tab (m_octave_qobj, directory); // signals from the qscintilla edit area + connect (f->qsci_edit_area (), &octave_qscintilla::show_symbol_tooltip_signal, + this, &file_editor::show_symbol_tooltip_signal); + connect (f->qsci_edit_area (), &octave_qscintilla::status_update, this, &file_editor::edit_status_update);
--- a/libgui/src/m-editor/file-editor.h Fri Dec 30 23:18:49 2022 -0500 +++ b/libgui/src/m-editor/file-editor.h Mon Jan 02 12:25:42 2023 -0500 @@ -192,6 +192,8 @@ void edit_mfile_request (const QString&, const QString&, const QString&, int); void debug_quit_signal (void); + void show_symbol_tooltip_signal (const QPoint&, const QString&); + public slots: void activate (void);
--- a/libgui/src/m-editor/octave-qscintilla.cc Fri Dec 30 23:18:49 2022 -0500 +++ b/libgui/src/m-editor/octave-qscintilla.cc Mon Jan 02 12:25:42 2023 -0500 @@ -1187,23 +1187,10 @@ // FIXME: can we handle display of a tooltip using an // interpreter event or a custom signal/slot connection? - QHelpEvent *help_e = static_cast<QHelpEvent *>(e); - QString variable = wordAtPoint (help_e->pos()); - QStringList symbol_names - = m_octave_qobj.get_workspace_model ()->get_symbol_names (); - int symbol_idx = symbol_names.indexOf (variable); - if (symbol_idx > -1) - { - QStringList symbol_values - = m_octave_qobj.get_workspace_model ()->get_symbol_values (); - QToolTip::showText (help_e->globalPos(), variable - + " = " + symbol_values.at (symbol_idx)); - } - else - { - QToolTip::hideText(); - e->ignore(); - } + QHelpEvent *help_e = static_cast<QHelpEvent *> (e); + QString symbol = wordAtPoint (help_e->pos()); + + emit show_symbol_tooltip_signal (help_e->globalPos (), symbol); return true; }
--- a/libgui/src/m-editor/octave-qscintilla.h Fri Dec 30 23:18:49 2022 -0500 +++ b/libgui/src/m-editor/octave-qscintilla.h Mon Jan 02 12:25:42 2023 -0500 @@ -95,6 +95,7 @@ void qsci_has_focus_signal (bool); void status_update (bool, bool); void show_doc_signal (const QString&); + void show_symbol_tooltip_signal (const QPoint&, const QString&); void context_menu_break_condition_signal (int); void context_menu_break_once (int); void ctx_menu_run_finished_signal (bool, int, QPointer<QTemporaryFile>,
--- a/libgui/src/main-window.cc Fri Dec 30 23:18:49 2022 -0500 +++ b/libgui/src/main-window.cc Mon Jan 02 12:25:42 2023 -0500 @@ -348,6 +348,10 @@ // connections here instead of in base_qobject::editor_widget. m_octave_qobj.connect_interpreter_events (editor); + connect (editor, &file_editor::show_symbol_tooltip_signal, + m_octave_qobj.get_workspace_model (), + &workspace_model::show_symbol_tooltip); + connect (editor, &file_editor::request_settings_dialog, this, QOverload<const QString&>::of (&main_window::process_settings_dialog_request));
--- a/libgui/src/workspace-model.cc Fri Dec 30 23:18:49 2022 -0500 +++ b/libgui/src/workspace-model.cc Mon Jan 02 12:25:42 2023 -0500 @@ -30,6 +30,7 @@ #include <iostream> #include <QTreeWidget> +#include <QToolTip> #include "gui-preferences-ws.h" #include "gui-settings.h" @@ -219,6 +220,18 @@ } void + workspace_model::show_symbol_tooltip (const QPoint& pos, + const QString& symbol) + { + int symbol_idx = m_symbols.indexOf (symbol); + + if (symbol_idx > -1) + QToolTip::showText (pos, symbol + " = " + m_values.at (symbol_idx)); + else + QToolTip::hideText (); + } + + void workspace_model::clear_data (void) { m_top_level = false;