Mercurial > octave
changeset 24755:ef01ca93527c
show row and column numbers for editable data in variable editor
* variable-editor-model.h, variable-editor-model.cc
(scalar_struct_model::header_data, vector_struct_model::header_data):
Limit action to data rows and columns here.
(variable_editor_model::headerData): Not here.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 14 Feb 2018 13:18:35 -0500 |
parents | 2cb75eac8fe6 |
children | ad518267c0fd |
files | libgui/src/variable-editor-model.cc libgui/src/variable-editor-model.h |
diffstat | 2 files changed, 25 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/variable-editor-model.cc Wed Feb 14 11:53:18 2018 -0500 +++ b/libgui/src/variable-editor-model.cc Wed Feb 14 13:18:35 2018 -0500 @@ -565,16 +565,22 @@ switch (orientation) { case Qt::Horizontal: - return QString ("Values"); + if (section < data_columns ()) + return QString ("Values"); + else + break; case Qt::Vertical: - { - octave_scalar_map m = m_value.scalar_map_value (); + if (section < data_rows ()) + { + octave_scalar_map m = m_value.scalar_map_value (); - string_vector fields = m.fieldnames (); + string_vector fields = m.fieldnames (); - return QString::fromStdString (fields(section)); - } + return QString::fromStdString (fields(section)); + } + else + break; default: break; @@ -737,16 +743,22 @@ switch (orientation) { case Qt::Horizontal: - { - octave_map m = m_value.map_value (); + if (section < data_columns ()) + { + octave_map m = m_value.map_value (); - string_vector fields = m.fieldnames (); + string_vector fields = m.fieldnames (); - return QString::fromStdString (fields(section)); - } + return QString::fromStdString (fields(section)); + } + else + break; case Qt::Vertical: - return QString::number (section+1); + if (section < data_rows ()) + return QString::number (section+1); + else + break; default: break;
--- a/libgui/src/variable-editor-model.h Wed Feb 14 11:53:18 2018 -0500 +++ b/libgui/src/variable-editor-model.h Wed Feb 14 13:18:35 2018 -0500 @@ -237,11 +237,7 @@ QVariant headerData (int section, Qt::Orientation orientation, int role) const { - if ((orientation == Qt::Vertical && section < data_rows ()) - || (orientation == Qt::Horizontal && section < data_columns ())) - return rep->header_data (section, orientation, role); - - return QVariant (); + return rep->header_data (section, orientation, role); } // Return a subscript expression as a string that can be used to