# HG changeset patch # User John W. Eaton # Date 1516482001 18000 # Node ID a79f782653ced9948ccf56f5dcf5ca74139889ef # Parent 58dd3c2d5db8c512eac1e30118ec4cae26b6cd76 when editing sub-variables, generate complete subscript, not format string * variable-editor-model.h, variable-editor-model.cc (variable_editor_model::subscript_expression): Rename from variable_editor_model::parens. Generate complete subscript, not just format string. * variable-editor.cc (variable_editor::double_click): Call variable_editor_model::subscript_expression, not variable_editor_model::parens. Don't limit editing of sub-elements to matrix objects. diff -r 58dd3c2d5db8 -r a79f782653ce libgui/src/variable-editor-model.cc --- a/libgui/src/variable-editor-model.cc Sun Jan 21 21:26:21 2018 +0100 +++ b/libgui/src/variable-editor-model.cc Sat Jan 20 16:00:01 2018 -0500 @@ -441,9 +441,11 @@ } QString -variable_editor_model::parens (void) const +variable_editor_model::subscript_expression (const QModelIndex& idx) const { - return m_d->m_type == "{" ? "{%1, %2}" : "(%1, %2)"; + return (QString (m_d->m_type == "{" ? "{%1, %2}" : "(%1, %2)") + .arg (idx.row () + 1) + .arg (idx.column () + 1)); } // Private slots. diff -r 58dd3c2d5db8 -r a79f782653ce libgui/src/variable-editor-model.h --- a/libgui/src/variable-editor-model.h Sun Jan 21 21:26:21 2018 +0100 +++ b/libgui/src/variable-editor-model.h Sat Jan 20 16:00:01 2018 -0500 @@ -90,9 +90,10 @@ bool editor_type_string (const QModelIndex& idx) const; - // Return the proper parens to access the data structure. - // {%1,%2} for cell and (%1,%2) for matrices. - QString parens (void) const; + // Return a subscript expression as a string that can be used to + // access a sub-element of a data structure. For example "{1,3}" + // for cell array element {1,3} or "(2,4)" for array element (2,4). + QString subscript_expression (const QModelIndex& idx) const; signals: // private diff -r 58dd3c2d5db8 -r a79f782653ce libgui/src/variable-editor.cc --- a/libgui/src/variable-editor.cc Sun Jan 21 21:26:21 2018 +0100 +++ b/libgui/src/variable-editor.cc Sat Jan 20 16:00:01 2018 -0500 @@ -764,19 +764,7 @@ = qobject_cast (table->model ()); if (model->requires_sub_editor (idx)) - { - if (model ->editor_type_matrix (idx)) - edit_variable (name + model->parens () .arg (idx.row () + 1) - .arg (idx.column () + 1)); - - // FIXME: What was the intent here? - // emit command_requested ("openvar ('" + name + - // model->parens () - // .arg (idx.row () + 1) - // .arg (idx.column () + 1) - // + "');"); - - } + edit_variable (name + model->subscript_expression (idx)); } void