Mercurial > octave
diff liboctave/util/action-container.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 | 0b4d1575a2e2 |
children | 08f19fd144f4 |
line wrap: on
line diff
--- a/liboctave/util/action-container.h Mon Aug 21 17:22:28 2017 +0200 +++ b/liboctave/util/action-container.h Fri May 19 18:15:48 2017 +0200 @@ -213,6 +213,91 @@ A e_arg; }; + /// An element for calling a member function with two arguments + template <class T, class A, class B> + class method_arg2_elem : public elem + { + public: + method_arg2_elem (T *obj, void (T::*method) (A, B), + A arg_a, B arg_b) + : e_obj (obj), e_method (method), + e_arg_a (arg_a), e_arg_b (arg_b) { } + + void run (void) { (e_obj->*e_method) (e_arg_a, e_arg_b); } + + private: + + T *e_obj; + void (T::*e_method) (A, B); + A e_arg_a; + B e_arg_b; + + // No copying! + + method_arg2_elem (const method_arg2_elem&); + + method_arg2_elem operator = (const method_arg2_elem&); + }; + + /// An element for calling a member function with three arguments + template <class T, class A, class B, class C> + class method_arg3_elem : public elem + { + public: + method_arg3_elem (T *obj, void (T::*method) (A, B, C), + A arg_a, B arg_b, C arg_c) + : e_obj (obj), e_method (method), + e_arg_a (arg_a), e_arg_b (arg_b), e_arg_c (arg_c) + { } + + void run (void) { (e_obj->*e_method) (e_arg_a, e_arg_b, e_arg_c); } + + private: + + T *e_obj; + void (T::*e_method) (A, B, C); + A e_arg_a; + B e_arg_b; + C e_arg_c; + + // No copying! + + method_arg3_elem (const method_arg3_elem&); + + method_arg3_elem operator = (const method_arg3_elem&); + }; + + /// An element for calling a member function with three arguments + template <class T, class A, class B, class C, class D> + class method_arg4_elem : public elem + { + public: + method_arg4_elem (T *obj, void (T::*method) (A, B, C, D), + A arg_a, B arg_b, C arg_c, D arg_d) + : e_obj (obj), e_method (method), + e_arg_a (arg_a), e_arg_b (arg_b), e_arg_c (arg_c), e_arg_d (arg_d) + { } + + void run (void) { + (e_obj->*e_method) (e_arg_a, e_arg_b, e_arg_c, e_arg_d); + } + + private: + + T *e_obj; + void (T::*e_method) (A, B, C, D); + A e_arg_a; + B e_arg_b; + C e_arg_c; + D e_arg_d; + + // No copying! + + method_arg4_elem (const method_arg4_elem&); + + method_arg4_elem operator = (const method_arg4_elem&); + }; + // An element that stores arbitrary variable, and restores it. template <typename T> @@ -330,6 +415,33 @@ add (new method_crefarg_elem<T, A> (obj, method, arg)); } + // Call to T::method (A, B). + template <class T, class A, class B> + void add_method (T *obj, void (T::*method) (A, B), + A arg_a, B arg_b) + { + add (new method_arg2_elem<T, A, B> (obj, method, arg_a, arg_b)); + } + + // Call to T::method (A, B, C). + template <class T, class A, class B, class C> + void add_method (T *obj, void (T::*method) (A, B, C), + A arg_a, B arg_b, C arg_c) + { + add (new method_arg3_elem<T, A, B, C> (obj, method, arg_a, + arg_b, arg_c)); + } + + // Call to T::method (A, B, C, D). + template <class T, class A, class B, class C, class D> + void add_method (T *obj, void (T::*method) (A, B, C, D), + A arg_a, B arg_b, + C arg_c, D arg_d) + { + add (new method_arg4_elem<T, A, B, C, D> (obj, method, arg_a, + arg_b, arg_c, arg_d)); + } + // Call to delete (T*). template <typename T>