changeset 24627:a79f782653ce

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.
author John W. Eaton <jwe@octave.org>
date Sat, 20 Jan 2018 16:00:01 -0500
parents 58dd3c2d5db8
children 55da6c4f1382
files libgui/src/variable-editor-model.cc libgui/src/variable-editor-model.h libgui/src/variable-editor.cc
diffstat 3 files changed, 9 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- 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
 
--- 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<variable_editor_model *> (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