24 #if defined (HAVE_CONFIG_H)
28 #include <QInputDialog>
29 #include <QApplication>
31 #include <QMessageBox>
33 #include <QHeaderView>
34 #include <QHBoxLayout>
35 #include <QVBoxLayout>
36 #include <QPushButton>
40 #include <QSignalMapper>
49 setObjectName (
"WorkspaceView");
50 setWindowIcon (QIcon (
":/actions/icons/logo.png"));
52 setStatusTip (tr (
"View the variables in the active workspace."));
55 _filter->setToolTip (tr (
"Enter text to filter the workspace"));
58 _filter->setInsertPolicy (QComboBox::NoInsert);
60 QComboBox::AdjustToMinimumContentsLengthWithIcon);
61 QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred);
62 _filter->setSizePolicy (sizePol);
63 _filter->completer ()->setCaseSensitivity (Qt::CaseSensitive);
65 QLabel *filter_label =
new QLabel (tr (
"Filter"));
69 view->setWordWrap (
false);
70 view->setContextMenuPolicy (Qt::CustomContextMenu);
71 view->setShowGrid (
false);
72 (
view->verticalHeader) ()->hide ();
73 view->setAlternatingRowColors (
true);
81 QHBoxLayout *filter_layout =
new QHBoxLayout ();
83 filter_layout->addWidget (filter_label);
85 filter_layout->addWidget (
_filter);
86 filter_layout->setMargin(0);
89 QVBoxLayout *ws_layout =
new QVBoxLayout ();
91 ws_layout->addWidget (
view);
97 _filter_shown = settings->value (
"workspaceview/filter_shown",
true).toBool();
100 ws_layout->setMargin (2);
103 widget ()->setLayout (ws_layout);
108 view->setSortingEnabled (
true);
110 view->horizontalHeader ()->restoreState (settings->value (
"workspaceview/column_state").toByteArray ());
113 #if defined (HAVE_QT4)
114 view->horizontalHeader ()->setClickable (
true);
115 view->horizontalHeader ()->setMovable (
true);
117 view->horizontalHeader ()->setSectionsClickable (
true);
118 view->horizontalHeader ()->setSectionsMovable (
true);
120 view->horizontalHeader ()->setSortIndicator (settings->value (
"workspaceview/sort_by_column",0).toInt (),
121 static_cast<Qt::SortOrder
>
122 (settings->value (
"workspaceview/sort_order", Qt::AscendingOrder).toUInt ()));
123 view->horizontalHeader ()->setSortIndicatorShown (
true);
125 view->horizontalHeader ()->setContextMenuPolicy (Qt::CustomContextMenu);
126 connect (
view->horizontalHeader (),
127 SIGNAL (customContextMenuRequested (
const QPoint &)),
131 _filter->addItems (settings->value (
"workspaceview/mru_list").toStringList ());
134 settings->value (
"workspaceview/filter_active",
false).toBool ();
141 connect (
_filter, SIGNAL (editTextChanged (
const QString&)),
145 connect (
_filter->lineEdit (), SIGNAL (editingFinished ()),
148 connect (
view, SIGNAL (customContextMenuRequested (
const QPoint&)),
152 p, SLOT (execute_command_in_terminal (
const QString&)));
163 settings->setValue (
"workspaceview/column_state",
164 view->horizontalHeader ()->saveState ());
166 int sort_column =
view->horizontalHeader ()->sortIndicatorSection ();
167 Qt::SortOrder sort_order =
view->horizontalHeader ()->sortIndicatorOrder ();
168 settings->setValue (
"workspaceview/sort_by_column", sort_column);
169 settings->setValue (
"workspaceview/sort_order", sort_order);
171 settings->setValue (
"workspaceview/filter_active",
173 settings->setValue (
"workspaceview/filter_shown",
_filter_shown);
178 settings->setValue (
"workspaceview/mru_list", mru);
196 settings->value (
"workspaceview/sort_by_column",0).toInt (),
197 static_cast<Qt::SortOrder
>
198 (settings->value (
"workspaceview/sort_order", Qt::AscendingOrder).toUInt ())
208 QDockWidget::closeEvent (e);
234 int index =
_filter->findText (text);
246 index = index.sibling (index.row (), 0);
247 QAbstractItemModel *
m =
view->model ();
250 return item_data[0].toString ();
269 action->setCheckable (
true);
276 menu.exec (
view->mapToGlobal (mpos));
285 bool shown = settings->value (key,
true).toBool ();
287 view->setColumnHidden (col + 1, shown);
289 settings->setValue (key, ! shown);
300 QModelIndex index =
view->indexAt (qpos);
303 if (index.isValid () && index.column () == 0)
307 menu.addAction (tr (
"Copy name"),
this,
310 menu.addAction (tr (
"Copy value"),
this,
313 QAction *
rename = menu.addAction (tr (
"Rename"),
this,
316 QAbstractItemModel *
m =
view->model ();
321 rename->setDisabled (
true);
322 rename->setToolTip (tr (
"Only top-level symbols may be renamed"));
325 menu.addSeparator ();
327 menu.addAction (
"disp (" + var_name +
")",
this,
330 menu.addAction (
"plot (" + var_name +
")",
this,
333 menu.addAction (
"stem (" + var_name +
")",
this,
336 menu.addSeparator ();
341 menu.addAction (tr (
"Hide filter"),
this,
344 menu.addAction (tr (
"Show filter"),
this,
347 menu.exec (
view->mapToGlobal (qpos));
353 QModelIndex index =
view->currentIndex ();
355 if (index.isValid ())
359 QClipboard *clipboard = QApplication::clipboard ();
361 clipboard->setText (var_name);
368 QModelIndex index =
view->currentIndex ();
370 if (index.isValid ())
375 std::ostringstream buf;
378 QClipboard *clipboard = QApplication::clipboard ();
386 QModelIndex index =
view->currentIndex ();
388 if (index.isValid ())
392 QInputDialog* inputDialog =
new QInputDialog ();
394 inputDialog->setOptions (QInputDialog::NoButtons);
399 = inputDialog->getText (0,
"Rename Variable",
"New name:",
400 QLineEdit::Normal, var_name, &ok);
402 if (ok && ! new_name.isEmpty ())
404 QAbstractItemModel *
m =
view->model ();
405 m->setData (index, new_name, Qt::EditRole);
431 QModelIndex index =
view->currentIndex ();
433 if (index.isValid ())
454 QFontMetrics fm =
view->fontMetrics ();
455 int row_height = fm.height ();
458 view->setRowHeight (
i, row_height);
471 view->setColumnHidden (i + 1,
477 if (! settings->value (
"workspaceview/hide_tool_tips",
false).toBool ())
479 tool_tip = QString (tr (
"View the variables in the active workspace.<br>"));
480 tool_tip += QString (tr (
"Colors for variable attributes:"));
484 QString (
"<div style=\"background-color:%1;color:#000000\">%2</div>")
490 setToolTip (tool_tip);
510 if (
view->hasFocus ())
517 if (
view->hasFocus ())
void filter_activate(bool enable)
QCheckBox * _filter_checkbox
void closeEvent(QCloseEvent *event)
QStringList _columns_shown
QColor storage_class_color(int s_class)
identity matrix If supplied two scalar respectively For allows like xample val
void handle_contextmenu_stem(void)
void toggle_header(int column)
QString fromStdString(const std::string &s)
void handle_contextmenu_filter(void)
void command_requested(const QString &cmd)
signal that user had requested a command on a variable
void filter_update(const QString &expression)
void header_contextmenu_requested(const QPoint &mpos)
QSortFilterProxyModel _filter_model
static octave_value varval(const std::string &name, scope_id scope=xcurrent_scope, context_id context=xdefault_context)
void handle_contextmenu_rename(void)
int rename(const std::string &from, const std::string &to)
QStringList _columns_shown_keys
workspace_view(QWidget *parent=0)
void setModel(workspace_model *model)
void contextmenu_requested(const QPoint &pos)
nd deftypefn *octave_map m
void update_filter_history()
void notice_settings(const QSettings *)
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
int view_previous_row_count
void handle_model_changed(void)
returns the type of the matrix and caches it for future use Called with more than one the function will not attempt to guess the type if it is still unknown This is useful for debugging purposes The possible matrix types depend on whether the matrix is full or and can be one of the following able sis tem and mark type as unknown tem as the structure of the matrix explicitly gives this(Sparse matrices only) tem code
static QSettings * get_settings(void)
QString get_var_name(QModelIndex index)
static uint32_t state[624]
QSignalMapper * _sig_mapper
void notice_settings(const QSettings *)
void handle_contextmenu_copy(void)
=val(i)}if ode{val(i)}occurs in table i
void handle_contextmenu_disp(void)
static QString storage_class_chars(void)
static QStringList storage_class_names(void)
void relay_contextmenu_command(const QString &cmdname)
void handle_contextmenu_copy_value(void)
void handle_contextmenu_plot(void)
bool is_top_level(void) const