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> 53 setObjectName (
"WorkspaceView");
54 setWindowIcon (QIcon (
":/actions/icons/logo.png"));
56 setStatusTip (tr (
"View the variables in the active workspace."));
59 m_filter->setToolTip (tr (
"Enter text to filter the workspace"));
62 m_filter->setInsertPolicy (QComboBox::NoInsert);
63 m_filter->setSizeAdjustPolicy (QComboBox::AdjustToMinimumContentsLengthWithIcon);
64 QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred);
66 m_filter->completer ()->setCaseSensitivity (Qt::CaseSensitive);
68 QLabel *filter_label =
new QLabel (tr (
"Filter"));
72 m_view->setWordWrap (
false);
73 m_view->setContextMenuPolicy (Qt::CustomContextMenu);
74 m_view->setShowGrid (
false);
75 (
m_view->verticalHeader) ()->hide ();
76 m_view->setAlternatingRowColors (
true);
84 QHBoxLayout *filter_layout =
new QHBoxLayout ();
86 filter_layout->addWidget (filter_label);
89 filter_layout->setMargin(0);
92 QVBoxLayout *ws_layout =
new QVBoxLayout ();
94 ws_layout->addWidget (
m_view);
100 m_filter_shown = settings->value (
"workspaceview/filter_shown",
true).toBool ();
103 ws_layout->setMargin (2);
106 widget ()->setLayout (ws_layout);
111 m_view->setSortingEnabled (
true);
113 m_view->horizontalHeader ()->restoreState (
114 settings->value (
"workspaceview/column_state").toByteArray ());
117 #if defined (HAVE_QHEADERVIEW_SETSECTIONSCLICKABLE) 118 m_view->horizontalHeader ()->setSectionsClickable (
true);
120 m_view->horizontalHeader ()->setClickable (
true);
122 #if defined (HAVE_QHEADERVIEW_SETSECTIONSMOVABLE) 123 m_view->horizontalHeader ()->setSectionsMovable (
true);
125 m_view->horizontalHeader ()->setMovable (
true);
127 m_view->horizontalHeader ()->setSortIndicator (settings->value (
"workspaceview/sort_by_column",0).toInt (),
128 static_cast<Qt::SortOrder
> 129 (settings->value (
"workspaceview/sort_order", Qt::AscendingOrder).toUInt ()));
130 m_view->horizontalHeader ()->setSortIndicatorShown (
true);
132 m_view->horizontalHeader ()->setContextMenuPolicy (Qt::CustomContextMenu);
133 connect (
m_view->horizontalHeader (),
134 SIGNAL (customContextMenuRequested (
const QPoint &)),
138 m_filter->addItems (settings->value (
"workspaceview/mru_list").toStringList ());
141 settings->value (
"workspaceview/filter_active",
false).toBool ();
148 connect (
m_filter, SIGNAL (editTextChanged (
const QString&)),
152 connect (
m_filter->lineEdit (), SIGNAL (editingFinished ()),
155 connect (
m_view, SIGNAL (customContextMenuRequested (
const QPoint&)),
158 connect (
m_view, SIGNAL (activated (QModelIndex)),
162 p, SLOT (execute_command_in_terminal (
const QString&)));
166 p, SLOT (edit_variable (
const QString&,
const octave_value&)));
178 m_view->sortByColumn (settings->value (
"workspaceview/sort_by_column",0).toInt (),
179 static_cast<Qt::SortOrder
> (settings->value (
"workspaceview/sort_order", Qt::AscendingOrder).toUInt ()));
196 if (! settings->value (
"workspaceview/hide_tool_tips",
false).toBool ())
198 tool_tip = QString (tr (
"View the variables in the active workspace.<br>"));
199 tool_tip += QString (tr (
"Colors for variable attributes:"));
203 QString (R
"(<div style="background-color:%1;color:#000000">%2</div>)") 209 setToolTip (tool_tip); 234 settings->setValue (
"workspaceview/column_state",
235 m_view->horizontalHeader ()->saveState ());
237 int sort_column =
m_view->horizontalHeader ()->sortIndicatorSection ();
238 Qt::SortOrder sort_order =
m_view->horizontalHeader ()->sortIndicatorOrder ();
239 settings->setValue (
"workspaceview/sort_by_column", sort_column);
240 settings->setValue (
"workspaceview/sort_order", sort_order);
242 settings->setValue (
"workspaceview/filter_active",
244 settings->setValue (
"workspaceview/filter_shown",
m_filter_shown);
249 settings->setValue (
"workspaceview/mru_list", mru);
263 QDockWidget::closeEvent (
e);
314 action->setCheckable (
true);
320 menu.exec (
m_view->mapToGlobal (mpos));
329 bool shown = settings->value (key,
true).toBool ();
331 m_view->setColumnHidden (col + 1, shown);
333 settings->setValue (key, ! shown);
344 QModelIndex index =
m_view->indexAt (qpos);
347 if (index.isValid () && index.column () == 0)
351 menu.addAction (tr (
"Open in Variable Editor"),
this,
354 menu.addAction (tr (
"Copy name"),
this,
357 menu.addAction (tr (
"Copy value"),
this,
360 QAction *
rename = menu.addAction (tr (
"Rename"),
this,
363 QAbstractItemModel *m =
m_view->model ();
368 rename->setDisabled (
true);
369 rename->setToolTip (tr (
"Only top-level symbols may be renamed"));
372 menu.addAction (
"Clear " + var_name,
this,
375 menu.addSeparator ();
377 menu.addAction (
"disp (" + var_name +
')',
this,
380 menu.addAction (
"plot (" + var_name +
')',
this,
383 menu.addAction (
"stem (" + var_name +
')',
this,
386 menu.addSeparator ();
391 menu.addAction (tr (
"Hide filter"),
this,
394 menu.addAction (tr (
"Show filter"),
this,
397 menu.exec (
m_view->mapToGlobal (qpos));
403 QModelIndex index =
m_view->currentIndex ();
405 if (index.isValid ())
409 QClipboard *clipboard = QApplication::clipboard ();
411 clipboard->setText (var_name);
418 QModelIndex index =
m_view->currentIndex ();
420 if (index.isValid ())
428 std::ostringstream buf;
429 val.print_raw (buf,
true);
431 QClipboard *clipboard = QApplication::clipboard ();
439 QModelIndex index =
m_view->currentIndex ();
441 if (index.isValid ())
445 QInputDialog *inputDialog =
new QInputDialog ();
447 inputDialog->setOptions (QInputDialog::NoButtons);
452 = inputDialog->getText (
nullptr,
"Rename Variable",
"New name:",
453 QLineEdit::Normal, var_name, &ok);
455 if (ok && ! new_name.isEmpty ())
457 QAbstractItemModel *m =
m_view->model ();
458 m->setData (index, new_name, Qt::EditRole);
466 QModelIndex index =
m_view->currentIndex ();
468 if (index.isValid ())
476 val = scope.
varval (var_name.toStdString ());
519 QFontMetrics fm =
m_view->fontMetrics ();
520 int row_height = fm.height ();
523 m_view->setRowHeight (
i, row_height);
544 QModelIndex index =
m_view->currentIndex ();
546 if (index.isValid ())
565 QAbstractItemModel *m =
m_view->model ();
568 = m->itemData (index.sibling (index.row (), 0));
570 return item_data[0].toString ();
void relay_contextmenu_command(const QString &cmdname, bool str=false)
void toggle_header(int column)
workspace_model * m_model
identity matrix If supplied two scalar respectively For allows like xample val
void closeEvent(QCloseEvent *event)
symbol_scope scope(void) const
QString fromStdString(const std::string &s)
void header_contextmenu_requested(const QPoint &mpos)
QSortFilterProxyModel m_filter_model
symbol_scope __get_current_scope__(const std::string &who)
QStringList m_columns_shown_keys
void handle_contextmenu_disp(void)
void handle_contextmenu_copy_value(void)
int rename(const std::string &from, const std::string &to)
workspace_view(QWidget *parent=nullptr)
void command_requested(const QString &cmd)
Signal that user had requested a command on a variable.
QColor storage_class_color(int s_class)
void handle_contextmenu_rename(void)
void handle_model_changed(void)
static QString storage_class_chars(void)
QString get_var_name(const QModelIndex &index)
void handle_contextmenu_edit(void)
int m_view_previous_row_count
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
bool is_top_level(void) const
void update_filter_history(void)
static QStringList storage_class_names(void)
void handle_contextmenu_plot(void)
void filter_update(const QString &expression)
octave_value varval(const std::string &name) const
QWidget * m_filter_widget
static uint32_t state[624]
void handle_contextmenu_stem(void)
void handle_contextmenu_filter(void)
QStringList m_columns_shown
void handle_contextmenu_copy(void)
static QSettings * get_settings(void)
void filter_activate(bool enable)
QSignalMapper * m_sig_mapper
void setModel(workspace_model *model)
void handle_contextmenu_clear(void)
void contextmenu_requested(const QPoint &pos)
void edit_variable_signal(const QString &, const octave_value &)
Signal that user wants to edit a variable.
void notice_settings(const QSettings *)
QCheckBox * m_filter_checkbox
void notice_settings(const QSettings *)