changeset 24658:e014e08f939f

variable editor: display values for types that can't be edited * variable-editor-model.cc (variable_editor_model::type_is_editable): If value is defined but not editable, display formatted output in the variable editor tab.
author John W. Eaton <jwe@octave.org>
date Wed, 31 Jan 2018 01:14:18 -0500
parents dd19b0b9a9a1
children 13d7fdaad391
files libgui/src/variable-editor-model.cc
diffstat 1 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/variable-editor-model.cc	Tue Jan 30 22:50:09 2018 -0500
+++ b/libgui/src/variable-editor-model.cc	Wed Jan 31 01:14:18 2018 -0500
@@ -853,9 +853,28 @@
       dim_vector dv = val.dims ();
       QString dimstr = QString::fromStdString (dv.str ());
 
-      emit data_error_signal (QString ("unable to edit [%1] '%2' objects")
+      // FIXME: we will probably want to impose a limit on the size of
+      // the output here...
+
+      // FIXME: shouldn't octave_value::print be a constant method?
+      QString sep;
+      QString output;
+
+      if (val.is_defined ())
+        {
+          std::ostringstream buf;
+          octave_value tval = val;
+          tval.print (buf);
+          output = QString::fromStdString (buf.str ());
+          if (! output.isEmpty ())
+            sep = "\n\n";
+        }
+
+      emit data_error_signal (QString ("unable to edit [%1] '%2' objects%3%4")
                               .arg (dimstr)
-                              .arg (tname));
+                              .arg (tname)
+                              .arg (sep)
+                              .arg (output));
     }
 
   return false;