Mercurial > octave
diff libgui/src/variable-editor.h @ 23927:e3a36f84d01d
provide variable-editor widget for the GUI
This patch is the work of
RĂ¼diger Sonderfeld <ruediger on savannah>
Philip Nienhuis
Michael Barnes <mjbcode@runbox.com>
jwe
* libgui/src/variable-editor.cc, libgui/src/variable-editor.h,
libgui/src/variable-editor-model.cc,
libgui/src/variable-editor-model.h:: New files.
* libgui/src/module.mk: Update.
* main-window.cc, main-window.h (main_window::main_window):
Initialize variable_editor_window.
(main_window::~main_window): Delete variable_editor_window.
(main_window::connect_uiwidget_links): Connect variable window signals
to octave_qt_link slots and callbacks. Add variable editor to menus.
(main_window::variable_editor_callback,
main_window::force_refresh_workspace, main_window::edit_variable,
main_window::clear_variable_editor_cache): New functions.
(main_window::configure_shortcuts): Also configure variable editor
shortcuts.
* resource-manager.cc, resource-manager.h (varedit_color_chars,
varedit_color_names, varedit_default_colors): New functions.
* settings-dialog.ui: New configuration info for variable editor.
* settings-dialog.cc, settings-dialog.h
(settings_dialog::read_varedit_colors,
settings_dialog::write_varedit_colors): New functions.
(settings_dialog::settings_dialog,
settings_dialog::write_changed_settings): Also handle settings for
variable editor.
* workspace-model.h (workspace_model::prompt_variable_editor):
New signal.
* workspace-view.cc, workspace-view.h
(workspace_view::workspace_view): Also connect eidt_variable_signal to
edit_variable slot.
(workspace_view::contextmenu_requested): Handle opening variabl in
variable editor.
(workspace_view::handle_contextmenu_edit): New function.
(workspace_view::edit_variable_signal): New signal.
* octave-link.cc, octave-link.h (Fopenvar): New function.
(octave_link::post_event, octave_link::do_post_event): New variants
for methods with two, three, or four arguments.
(octave_link::set_workspace): New argument, update_variable_editor.
(octave_link::openvar): New function.
(octave_link::do_openvar): New pure virtual.
* octave-qt-link.cc, octave-qt-link.h
(octave_qt_link::do_set_workspace): New argument,
update_variable_editor.
(octave_qt_link::do_set_workspace): Optionally emit
refresh_variable_editor signal
(octave_qt_link::do_openvar): New function.
(octave_qt_link::open_variable,
octave_qt_link::refresh_variable_editor): New signals.
* gui.txi: Document openvar.
* variables.cc, variables.h (symbol_exist): New function.
* action-container.h (action_container::method_arg2_elem,
action_container::method_arg3_elem,
action_container::method_arg4_elem): New classes.
(action_container::add_method): New variants for two, three, or four
arguments.
author | Michael Barnes <mjbcode@runbox.com> |
---|---|
date | Fri, 19 May 2017 18:15:48 +0200 |
parents | |
children | 665507c3c29d |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/src/variable-editor.h Fri May 19 18:15:48 2017 +0200 @@ -0,0 +1,132 @@ +/* + +Copyright (C) 2015 Michael Barnes +Copyright (C) 2013 RĂ¼diger Sonderfeld +Copyright (C) 2013 John W. Eaton + +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 +<http://www.gnu.org/licenses/>. + +*/ + +#ifndef variable_editor_h +#define variable_editor_h + +#include "octave-dock-widget.h" +#include <QHeaderView> +#include <QSettings> + +class QTabWidget; +class QToolBar; +class QMainWindow; +class QTableView; +class QModelIndex; + +class variable_editor : public octave_dock_widget +{ + Q_OBJECT + +public: + + variable_editor (QWidget *parent = nullptr); + + //~variable_editor (); + + void edit_variable (const QString& name); + + /// Clear all the models' data cache + void clear_data_cache (); + + bool has_focus (); + + static QList<QColor> default_colors (); + static QStringList color_names (); + +public slots: + + void callUpdate (const QModelIndex&,const QModelIndex&); + + void notice_settings (const QSettings *); + +protected slots: + + void closeEvent (QCloseEvent *); + + void closeTab (int idx); + + void contextmenu_requested (const QPoint& pt); + void columnmenu_requested (const QPoint& pt); + void rowmenu_requested (const QPoint& pt); + + void double_click (const QModelIndex& idx); + + void save (); + void clearContent (); + void cutClipboard (); + void copyClipboard (); + void pasteClipboard (); + void pasteTableClipboard (); + void createVariable (); + void transposeContent (); + void up (); + + void delete_selected(); + + /** Send command to Octave interpreter. + * %1 in CMD is replaced with the value of selected_to_octave. + */ + void relay_command (const QString& cmd); + +signals: + + void updated (); + void finished (); + void command_requested (const QString& cmd); + +private: + QMainWindow *main; + QToolBar *tool_bar; + QTabWidget *tab_widget; + + int default_width; + int default_height; + int add_font_height; + + bool autofit; + bool autofit_max; + bool use_terminal_font; + bool alternate_rows; + + QString stylesheet; + + QFont font; + + // If use_terminal_font then this will be different since "font" + // will contain the terminal font. + QFont sel_font; + QList<QColor> table_colors; + + void update_colors (); + + void construct_tool_bar (); + + // Convert selection to an Octave expression. + QString selected_to_octave (); + + QList<int> octave_to_coords (QString&); +}; + +#endif //variable_editor_h