Mercurial > hg > octave-terminal
changeset 14881:4daed35ff776 gui
Added dimension column to workspace view. Using octave print-function to retrieve a value string for a variable.
* octave-main-thread.cc: Changed argv[0] to "octave".
* symbol-information.h: Added _dimension attribute and code to generate dimensions.
* workspace-model: Added a new dimensioncolumn to the model.
author | Jacob Dawid <jacob.dawid@gmail.com> |
---|---|
date | Thu, 19 Jul 2012 10:13:40 -0400 |
parents | a6c44c28dabe |
children | a31a090c1628 6c40719cd9e2 |
files | gui/src/octave-adapter/octave-main-thread.cc gui/src/symbol-information.h gui/src/workspace-model.cc gui/src/workspace-model.h |
diffstat | 4 files changed, 26 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/octave-adapter/octave-main-thread.cc +++ b/gui/src/octave-adapter/octave-main-thread.cc @@ -27,7 +27,7 @@ { setlocale(LC_ALL, "en_US.UTF-8"); int argc = 1; - const char *argv[] = { "" }; + const char *argv[] = { "octave" }; emit ready(); octave_main (argc, (char **) argv, 0); }
--- a/gui/src/symbol-information.h +++ b/gui/src/symbol-information.h @@ -21,6 +21,8 @@ #include <QString> #include <QHash> +#include <sstream> + // Octave includes #undef PACKAGE_BUGREPORT #undef PACKAGE_NAME @@ -79,13 +81,14 @@ QString _symbol; QString _type; QString _value; + QString _dimension; Scope _scope; /** Hashes the symbol information for quickly comparing it. */ int hash () const { - return qHash (_symbol) + qHash (_type) + qHash (_value) + (int)_scope; + return qHash (_symbol) + qHash (_type) + qHash (_value) + qHash (_dimension) + (int)_scope; } /** Compares two symbol information objects. */ @@ -97,7 +100,8 @@ return _symbol == other._symbol && _type == other._type && _value == other._value - && _scope == other._scope; + && _scope == other._scope + && _dimension == other._dimension; } } @@ -117,37 +121,27 @@ _symbol = QString (symbol_record.name ().c_str ()); _type = QString (symbol_record.varval ().type_name ().c_str ()); octave_value ov = symbol_record.varval (); + std::stringstream buffer; + ov.print (buffer, true); + _value = QString::fromStdString (buffer.str ()); + _value.replace("\n", " "); - // For every type, convert to a human readable string. - if (ov.is_sq_string ()) - _value = QString ("\'%1\'").arg (ov.string_value ().c_str ()); - else if (ov.is_dq_string ()) - _value = QString ("\"%1\"").arg (ov.string_value ().c_str ()); - else if (ov.is_real_scalar () && ! ov.is_bool_type ()) - _value = QString ("%1").arg (ov.scalar_value ()); - else if (ov.is_complex_scalar ()) - _value = QString ("%1 + %2i").arg (ov.scalar_value ()) - .arg (ov.complex_value ().imag ()); + if (ov.is_string ()) + _dimension = QString ("%1").arg (ov.string_value ().length ()); else if (ov.is_range ()) - _value = QString ("%1 : %2 : %3").arg (ov.range_value ().base ()) - .arg (ov.range_value ().inc ()) - .arg (ov.range_value ().limit ()); - else if (ov.is_matrix_type ()) - _value = QString ("%1x%2").arg (ov.rows ()) - .arg (ov.columns ()); - else if (ov.is_cell ()) - _value = QString ("%1x%2").arg (ov.rows ()) - .arg (ov.columns ()); - else if (ov.is_bool_type ()) - _value = ov.bool_value () ? QString ("true") : QString ("false"); + _dimension = QString ("%1 : %2 : %3").arg (ov.range_value ().base ()) + .arg (ov.range_value ().inc ()) + .arg (ov.range_value ().limit ()); + else if (ov.is_matrix_type () || ov.is_cell ()) + _dimension = QString ("%1x%2").arg (ov.rows ()) + .arg (ov.columns ()); else if (ov.is_function_handle ()) - _value = QString ("FIXME: function handle found"); // See code for func2str for a possible solution + _dimension = QString ("func handle"); // See code for func2str for a possible solution else if (ov.is_inline_function ()) - _value = QString ("FIXME: inline function found"); // See code for formula for a possible solution + _dimension = QString ("inline func"); // See code for formula for a possible solution else - _value = QString ("<Type not recognized>"); + _dimension = "1"; - _value.replace("\n", "\\n"); return true; } } symbol_information;
--- a/gui/src/workspace-model.cc +++ b/gui/src/workspace-model.cc @@ -24,7 +24,7 @@ : QAbstractItemModel(parent), octave_event_observer () { QList<QVariant> rootData; - rootData << tr ("Name") << tr ("Type") << tr ("Value"); + rootData << tr ("Name") << tr ("Type") << tr("Dimension") << tr ("Value"); _rootItem = new tree_item(rootData); insert_top_level_item(0, new tree_item ("Local")); @@ -82,7 +82,8 @@ child->set_data (0, s._symbol); child->set_data (1, s._type); - child->set_data (2, s._value); + child->set_data (2, s._dimension); + child->set_data (3, s._value); switch (s._scope) {
--- a/gui/src/workspace-model.h +++ b/gui/src/workspace-model.h @@ -37,7 +37,7 @@ tree_item(QVariant data = QVariant(), tree_item *parent = 0) { QList<QVariant> variantList; - variantList << data << QVariant() << QVariant(); + variantList << data << QVariant () << QVariant () << QVariant (); _parent_item = parent; _item_data = variantList; }