Mercurial > octave
diff libgui/src/octave-dock-widget.h @ 24812:ed9ba20d6ed3
Make the variable editor multi-panel via a QMainWindow layout (bug #53046)
* main-window.h: Remove <QMdiArea> and <QMdiSubWindow> from header list.
* octave-dock-widget.h (label_dock_widget): Added. New intermediate class
that contains the features related only to the thin header for dock/undock
and close. Namely m_icon_size, m_title_widget, m_dock_button,
m_close_button, m_dock_action and m_close_action and member function
set_title().
(octave_dock_widget): Removed some elements for label_dock_widget class and
inherit that object.
* octave-dock-widget.cc (label_dock_widget::label_dock_widget): Constructor
of new class selecting a few initialization from octave_dock_widget related
to thin header and no settings code and no connections at this level. Set
the style sheet of the m_dock_button and m_close_button to transparent.
(label_dock_widget::set_title): Moved from octave_dock_widget without
modification.
(octave_dock_widget::octave_dock_widget): Select code moved to
label_dock_widget constructor.
(octave_dock_widget::set_title): Moved to label_dock_widget class.
* variable-editor-model.h:
(variable_editor_model::edit_variable_signal): New signal for a model to
launch a new variable_dock_widget if a sub-element needs it.
(variable_editor_model::update_data): Changed from private to public.
(variable_editor_model::update_data_cache): Ditto.
(variable_editor_model::double_click): Moved here from variable_editor to
make more modular.
* variable-editor-model.cc (variable_editor_model::setData): Change the test
on input variable for QString to be anything that can be converted to a
QString, e.g., numbers.
(variable_editor_model::update_data): Remove obsolete emitted signal
maybe_resize_columns_signal().
(variable_editor_model::double_click): Moved from variable_editor. Remove
the indirect reference to table then model.
* variable-editor.h (var_editor_tab): Remove. A tab widget is no longer used.
(variable_dock_widget): Added. A new class inherting label_dock_widget that
is merely a container, holding the stack of editable (QTableView) and
non-editable (QTextEdit) of variable views.
(variable_dock_widget::variable_focused_signal): Added. New signal to let
variable_editor know an object or its proxy has come into focus.
(variable_dock_widget::handle_focus_change): Added. Slot to connect to
QApplication::focusChanged().
(variable_dock_widget::closeEvent): Added. Override any intermediate class
and go back to the base QDockWidget behavior.
(variable_dock_widget::change_floating): Simple private routine changing the
toggling the float state.
(variable_dock_widget::change_existence): Simple private routine calling base
routine close().
(variable_dock_widget::toplevel_change): Added. Private slot to respond
to dock/undock signal. Changes the icon, restores focus, and also makes
the first floated display magnified for fast viewing.
(variable_editor_stack::variable_editor_stack): New class that holds and
manages a variable_editor_model, variable_editor_view (QTableView) and
a display view (QTextEdit).
(variable_editor_stack::edit_view): Inline function that returns pointer
to a variable_editor_view.
(variable_editor_stack::disp_view): Inline function that returns pointer
to a QTableView.
(variable_editor_stack::set_editable): Moved here from var_editor_tab class.
Set the view according to whether the variable can be put into table form.
(variable_editor_stack::levelUp (void); Moved here from variable_editor
class, where it was called up(). Open one higher level of octave value,
e.g., cell array, structure.
(variable_editor_stack::save (void): Moved here from variable_editor class.
General save of variable not related to how it is viewed.
(variable_editor_stack::make_disp_view): Moved here from variable_editor
class. Only a few small configurations with no model input. (Done later.)
(variable_edit_view::variable_edit_view): Added. New class derived from
QTableView that holds the majority of functionality moved from the
variable_editor class related to table copy, paste, etc. In the constructor
is about half of what used to be in variable_editor::make_edit_view().
(variable_edit_view::setModel): Added. Override of the virtual function
holding about half of what used to be in variable_editor::make_edit_view().
(variable_edit_view::command_signal): Added. Signal to connect to the
variable_editor's mechanism for sending Octave command back to core.
(variable_editor_view::range_selected): New method that provides a list of
range values for the table used for constructing commands elsewhere.
(variable_editor_view::selected_to_octave): Moved from variable_editor class
and simplify by calling range_selected().
(variable_editor_view::selected_command_requested): Added. Like function
command_requested(), but chooses just the selected data in the table.
(variable_editor_view::delete_selected): Moved from variable_editor. Removes
a level of indirection, but otherwise pretty much the same.
(variable_editor_view::clearContent): Ditto.
(variable_editor_view::cutClipboard): Ditto.
(variable_editor_view::copyClipboard): Ditto.
(variable_editor_view::pasteClipboard): Ditto.
(variable_editor_view::pasteTableClipboard): Ditto.
(variable_editor_view::handle_horizontal_scroll_action): Ditto.
(variable_editor_view::handle_vertical_scroll_action): Ditto.
(variable_editor_view::createContextMenu): Ditto.
(variable_editor_view::createColumnMenu): Ditto.
(variable_editor_view::createRowMenu): Ditto.
(variable_editor_view::): Ditto.
(variable_editor_view::): Ditto.
(variable_editor_view::): Ditto.
(variable_editor_view::): Ditto.
(variable_editor_view::add_edit_actions): The similar portions of the
various context menus that can be reused.
(HoverToolButton): Very short class derived from QToolButton whose added
feature is to capture the focused variable_dock_widget when the mouse is
hovered over the button.
(ReturnFocusToolButton): Similarly short class inherting HoverToolButton that
adds the feature of restoring the focus before activating its associated
action.
(ReturnFocusMenu): Analogous to ReturnFocusToolButton, but based on QMenu.
This is placed on a HoverToolButton.
(variable_editor): Added QStrings m_current_focus_vname and
m_hovered_focus_vname to keep track of variable that most recently focused.
Removed m_close_action, m_close_others_action and m_close_all_action QActions
since tab widget no longer used. Same for m_tab_widget, m_tab_bar. Change
QWidget pointer m_container to QMainWindow pointer m_main.
(variable_editor::has_focus): Removed. Using a proxy obviates this function.
(variable_editor::edit_variable): Change from private to public.
(variable_editor::variable_destroyed): New slot. Connect to
variable_dock_widget to keep track of when to check if toolbar still valid.
(variable_editor::variable_focused): New slot. Connect to
variable_dock_widget() to keep track of most recent focused variable window.
(variable_editor::record_hovered_focus_variable): New slot. Connect to
variable_dock_widget toolbar's ReturnFocusToolButton and ReturnFocusMenu for
when mouse cursor hovers.
(variable_editor::restore_hovered_focus_variable): New slot. Connect to
variable_dock_widget toolbar's ReturnFocusToolButton and ReturnFocusMenu for
prior to acting in order to return to active window/focus when hovered.
(variable_editor::request_close_tab): Removed. No longer needed.
(variable_editor::request_close_other_tabs): Ditto.
(variable_editor::request_close_all_tabs): Ditto.
(variable_editor::close_tab): Ditto.
(variable_editor::contextmenu_requested): Ditto.
(variable_editor::columnmenu_requested): Ditto.
(variable_editor::rowmenu_requested): Ditto.
(variable_editor::double_click): Moved to variable_editor_model class.
(variable_editor::up): Renamed levelUp and moved to variable_editor_view
class.
(variable_editor::clearContent): Moved to variable_dock_view class.
(variable_editor::transposeContent): Ditto.
(variable_editor::delete_selected): Ditto.
(variable_editor::relay_command): Renamed to relay_selected_command() for
clarity.
(variable_editor::clear_content_signal): Added. New signal to broadcast
to the variable_dock_widgets' associated slot.
(variable_editor::copy_clipboard_signal): Ditto.
(variable_editor::paste_clipboard_signal): Ditto.
(variable_editor::paste_table_clipboard_signal): Ditto.
(variable_editor::context_menu_signal): Ditto.
(variable_editor::column_menu_signal): Ditto.
(variable_editor::row_menu_signal): Ditto.
(variable_editor::save_signal): Ditto.
(variable_editor::delete_selected_signal): Ditto.
(variable_editor::selected_command_signal): Ditto.
(variable_editor::enable_actions): Removed. Too short of function otherwise.
(variable_editor::octave_to_coords): Removed, no longer needed.
(variable_editor::real_var_name): Removed, no more KDE problem in tab names
because tab widget no longer used. Names stored in most QObject's
objectName.
(variable_editor::selected_to_octave): Moved to variable_editor_view class.
(variable_editor::add_tool_bar_button): Convenience function for repetitive
tool bar button construction.
* variable-editor.cc: Add <QMdiArea> and <QScreen> to list of headers. Remove
<QStackedWidget> from list.
(make_plot_mapper): Added. Reusable, list-based convenience function. Adds
a plot title that also uses the %1 argument.
(variable_dock_widget::variable_dock_widget): Added. Constructor that
sets a couple attributes and connects the header dock actions inherited from
label_dock_widget to appropriate slots.
(variable_dock_widget::handle_focus_change): Added. Connected to
QApplication's focusChanged() to set/clear the blue background of the
name label and keep track of most recent focused variable_dock_widget.
(variable_dock_widget::change_floating): Added. New slot one line long.
(variable_dock_widget::change_existence): Added. New slot that calls close()
which is configurable by Qt::WA_DeleteOnClose parameter. For now, "close"
means "hide".
(variable_dock_widget::toplevel_change): Added. Changes the dock/undock
icon, but also its tooltip. Also changes the focus to the new window. First
time enlarged is very big to simulate "maximize", i.e., better temporary view
of this variable.
(variable_editor_stack::set_editable): Moved from var_editor_tab object and
made more generic so that it can be put in any container. Ensure that
the container has the active widget as its focus proxy.
(variable_editor_view::closeEvent, etc.): See variable-editor.h for list of
functions that are moved from variable_editor, often using findChild() or
findChildren() for convenience rather than m_widget_stack or m_table_widget.
(variable_editor::variable_editor): Call initializer QMainWindow() and
QToolBar() similar to what it was once like. Also initialize
m_current_focus_vname and m_hovered_focus_vname to "". Add toolbar to
m_main. Use an MDI area for central widget of m_main. Remove all tab bar
layout. Set the window's options to QMainWindow::AllowNestedDocks and
QMainWindow::VerticalTabs.
(variable_editor::edit_variable): Use findChild() to look for
variable_dock_widget of requested name. If so, bring into focus and return.
If continue, create new variable_dock_widget "page" and place in m_main.
Set page's objectName to the variable name. Connect signals/slots to "page"
for controlling the blue background of variable name. Remove extra layer of
QVBoxLayout container, now replaced by creation of a variable_editor_stack
object. Set stack widget's objectName to variable name. Get edit_view
from variable_editor_stack's edit_view() method. Set edit_view's objectName
to variable name. Make myriad connections to edit_view and variable_editor.
Create a variable_edit_model and pass that on to variable_editor_view via
setModel(). Make all the various connections amongst these objects. Supply
a title to the label_dock_widget and set the text of that title to the
variable's name. Use findChildren to enable the toolbar on the first
variable, similar to the way it was previous. After creating
variable_dock_widget, set its allowed areas to Qt::LeftDockWidgetArea and
Qt::RightDockWidgetArea then place it in the main window's left dock area.
(variable_editor::make_disp_view): Moved to variable_editor_stack class.
(variable_editor::make_edit_view): Absorbed in variable_editor_view
constructor and setModel() methods.
(variable_editor::has_focus): Removed. Not needed, setting focus proxy
appears to obviate this.
(variable_editor::notice_settings): Took out shortcut_manager shortcuts
because these tab actions no longer needed. Also, these shortcuts can
possibly be handled via the QAction shortcut key.
(variable_editor::add_tool_bar_button): Added. Mimic the
m_tool_bar->addAction() construct used in construct_tool_bar().
(variable_editor::construct_tool_bar): Utilize make_plot_mapper(). Utilize
add_tool_bar_button() to place ReturnFocusToolButton objects in the QToolbar.
Give an example of adding a short-cut key to the Save QAction. Use a
HoverToolButton with a ReturnFocusMenu object similar to existing
construction. At the end, utilize findChildren() to loop through all the
objects needing connections to slots rather than program individually.
author | Daniel J Sebald <daniel.sebald@ieee.org> |
---|---|
date | Mon, 19 Feb 2018 20:13:15 -0600 |
parents | 194eb4bd202b |
children | 0f6a261ab144 |
line wrap: on
line diff
--- a/libgui/src/octave-dock-widget.h Thu Mar 01 11:18:44 2018 -0500 +++ b/libgui/src/octave-dock-widget.h Mon Feb 19 20:13:15 2018 -0600 @@ -30,7 +30,41 @@ #include <QToolButton> #include <QMouseEvent> -class octave_dock_widget : public QDockWidget +// The few decoration items common to both main window and variable editor. +class label_dock_widget : public QDockWidget +{ + Q_OBJECT + +public: + + label_dock_widget (QWidget *p = nullptr); + + void set_title (const QString&); + +protected slots: + + //! Slots to handle copy & paste. + //!@{ + virtual void copyClipboard (void) { } + virtual void pasteClipboard (void) { } + virtual void selectAll (void) { } + //!@} + + //! Slot to handle undo. + + virtual void do_undo (void) { } + +protected: + + int m_icon_size; + QWidget *m_title_widget; + QToolButton *m_dock_button; + QToolButton *m_close_button; + QAction *m_dock_action; + QAction *m_close_action; +}; + +class octave_dock_widget : public label_dock_widget { Q_OBJECT @@ -44,7 +78,6 @@ void make_window (void); void make_widget (bool dock=true); - void set_title (const QString&); void set_predecessor_widget (octave_dock_widget *prev_widget); signals: @@ -98,17 +131,6 @@ emit active_changed (true); } - //! Slots to handle copy & paste. - //!@{ - virtual void copyClipboard (void) { } - virtual void pasteClipboard (void) { } - virtual void selectAll (void) { } - //!@} - - //! Slot to handle undo. - - virtual void do_undo (void) { } - //! Event filter for double clicks into the window decoration elements. bool eventFilter (QObject *obj, QEvent *e); @@ -130,7 +152,6 @@ bool m_floating; bool m_custom_style; int m_title_3d; - int m_icon_size; QColor m_bg_color; QColor m_bg_color_active; QColor m_fg_color; @@ -139,11 +160,6 @@ QString m_icon_color_active; octave_dock_widget *m_predecessor_widget; - QWidget *m_title_widget; - QToolButton *m_dock_button; - QToolButton *m_close_button; - QAction *m_dock_action; - QAction *m_close_action; }; #endif