Mercurial > octave
changeset 24649:456b486ae5e6
respect autofit setting in variable edtior update (bug #52988)
* variable-editor.h, variable-editor.cc
(variable_editor::maybe_resize_columns): New function.
(variable_editor::edit_variable, variable_editor::callUpdate):
Call maybe_resize_columns to avoid duplicated code.
* variable-editor-model.h, variable-editor-model.cc
(variable_editor_model::maybe_resize_columns_signal): Rename form
resize_columns_signal.
(variable_editor_model::variable_editor_model): Connect
maybe_resize_columns_signal to variable_editor::maybe_resize_columns.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 29 Jan 2018 13:10:10 -0500 |
parents | 1f1ac73910ab |
children | 2ab1154f2c7d |
files | libgui/src/variable-editor-model.cc libgui/src/variable-editor-model.h libgui/src/variable-editor.cc libgui/src/variable-editor.h |
diffstat | 4 files changed, 34 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/variable-editor-model.cc Mon Jan 29 08:51:47 2018 -0500 +++ b/libgui/src/variable-editor-model.cc Mon Jan 29 13:10:10 2018 -0500 @@ -317,8 +317,8 @@ connect (this, SIGNAL (clear_data_cell_signal (int, int)), this, SLOT (clear_data_cell (int, int))); - connect (this, SIGNAL (resize_columns_signal (void)), - parent, SLOT (resizeColumnsToContents (void))); + connect (this, SIGNAL (maybe_resize_columns_signal (void)), + parent, SLOT (maybe_resize_columns (void))); if (! type_is_editable (val)) return; @@ -599,7 +599,7 @@ emit dataChanged (QAbstractTableModel::index (0, 0), QAbstractTableModel::index (new_rows-1, new_cols-1)); - emit resize_columns_signal (); + emit maybe_resize_columns_signal (); } // Private.
--- a/libgui/src/variable-editor-model.h Mon Jan 29 08:51:47 2018 -0500 +++ b/libgui/src/variable-editor-model.h Mon Jan 29 13:10:10 2018 -0500 @@ -107,7 +107,7 @@ void user_error_signal (const QString& title, const QString& msg) const; - void resize_columns_signal (void); + void maybe_resize_columns_signal (void); private slots:
--- a/libgui/src/variable-editor.cc Mon Jan 29 08:51:47 2018 -0500 +++ b/libgui/src/variable-editor.cc Mon Jan 29 13:10:10 2018 -0500 @@ -205,25 +205,7 @@ if (m_tab_widget->count () == 1) m_tool_bar->setEnabled (true); - if (m_autofit) - { - table->resizeColumnsToContents (); - - if (m_autofit_max) - { - int mx = 0; - - for (int i = 0; i < table->model ()->columnCount (); i++) - { - if (table->columnWidth (i) > mx) - mx = table->columnWidth (i); - } - - table->horizontalHeader ()->setDefaultSectionSize (mx); - } - } - else - table->horizontalHeader ()->setDefaultSectionSize (m_default_width); + maybe_resize_columns (); table->setFont (m_font); table->setStyleSheet (m_stylesheet); @@ -305,25 +287,7 @@ void variable_editor::callUpdate (const QModelIndex&, const QModelIndex&) { - if (m_autofit) - { - QTableView *view = get_table_data (m_tab_widget).m_table; - - view->resizeColumnsToContents (); - - if (m_autofit_max) - { - int mx = 0; - - for (int i = 0; i < view->model ()->columnCount (); i++) - { - if (view->columnWidth (i) > mx) - mx = view->columnWidth (i); - } - - view->horizontalHeader ()->setDefaultSectionSize (mx); - } - } + maybe_resize_columns (); emit updated (); } @@ -442,6 +406,32 @@ } void +variable_editor::maybe_resize_columns (void) +{ + QTableView *table = get_table_data (m_tab_widget).m_table; + + if (m_autofit) + { + table->resizeColumnsToContents (); + + if (m_autofit_max) + { + int mx = 0; + + for (int i = 0; i < table->model ()->columnCount (); i++) + { + if (table->columnWidth (i) > mx) + mx = table->columnWidth (i); + } + + table->horizontalHeader ()->setDefaultSectionSize (mx); + } + } + else + table->horizontalHeader ()->setDefaultSectionSize (m_default_width); +} + +void variable_editor::contextmenu_requested (const QPoint& qpos) { QTableView *view = get_table_data (m_tab_widget).m_table;