26 #if defined (HAVE_CONFIG_H)
30 #include <QApplication>
33 #include <QHBoxLayout>
34 #include <QHeaderView>
35 #include <QInputDialog>
39 #include <QMessageBox>
40 #include <QPushButton>
41 #include <QSignalMapper>
42 #include <QVBoxLayout>
54 m_filter_checkbox (new QCheckBox ()),
55 m_filter (new QComboBox (this)),
56 m_filter_widget (new
QWidget (this))
58 set_title (tr (
"Workspace"));
59 setStatusTip (tr (
"View the variables in the active workspace."));
61 m_filter->setToolTip (tr (
"Enter text to filter the workspace"));
62 m_filter->setEditable (
true);
64 m_filter->setInsertPolicy (QComboBox::NoInsert);
65 m_filter->setSizeAdjustPolicy (QComboBox::AdjustToMinimumContentsLengthWithIcon);
66 QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred);
67 m_filter->setSizePolicy (sizePol);
68 m_filter->completer ()->setCaseSensitivity (Qt::CaseSensitive);
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);
77 m_view_previous_row_count = 0;
83 QHBoxLayout *filter_layout =
new QHBoxLayout ();
85 filter_layout->addWidget (filter_label);
86 filter_layout->addWidget (m_filter_checkbox);
87 filter_layout->addWidget (m_filter);
88 filter_layout->setMargin (0);
90 m_filter_widget->setLayout (filter_layout);
92 QVBoxLayout *ws_layout =
new QVBoxLayout ();
93 ws_layout->addWidget (m_filter_widget);
94 ws_layout->addWidget (m_view);
95 ws_layout->setSpacing (0);
103 m_filter_widget->setVisible (m_filter_shown);
105 ws_layout->setMargin (2);
108 widget ()->setLayout (ws_layout);
113 m_view->setSortingEnabled (
true);
115 m_view->horizontalHeader ()->restoreState
119 m_view->horizontalHeader ()->setSectionsClickable (
true);
120 m_view->horizontalHeader ()->setSectionsMovable (
true);
121 m_view->horizontalHeader ()->setSortIndicator (
127 m_view->horizontalHeader ()->setSortIndicatorShown (
true);
129 m_view->horizontalHeader ()->setContextMenuPolicy (Qt::CustomContextMenu);
130 connect (m_view->horizontalHeader (),
131 &QTableView::customContextMenuRequested,
139 m_filter_checkbox->setChecked (filter_state);
140 filter_activate (filter_state);
145 connect (m_filter, &QComboBox::editTextChanged,
147 connect (m_filter_checkbox, &QCheckBox::toggled,
149 connect (m_filter->lineEdit (), &QLineEdit::editingFinished,
152 connect (m_view, &QTableView::customContextMenuRequested,
155 connect (m_view, &QTableView::activated,
194 tool_tip = QString (tr (
"View the variables in the active workspace.<br>"));
195 tool_tip += QString (tr (
"Colors for variable attributes:"));
200 QString (R
"(<div style="background-color:%1;color:%2">%3</div>)")
208 setToolTip (tool_tip);
221 m_view->horizontalHeader ()->saveState ());
223 int sort_column =
m_view->horizontalHeader ()->sortIndicatorSection ();
224 Qt::SortOrder sort_order =
m_view->horizontalHeader ()->sortIndicatorOrder ();
232 for (
int i = 0; i <
m_filter->count (); i++)
233 mru.append (
m_filter->itemText (i));
279 QString text =
m_filter->currentText ();
280 int index =
m_filter->findText (text);
293 QSignalMapper sig_mapper (
this);
302 &sig_mapper, SLOT (map ()));
303 sig_mapper.setMapping (action, i);
304 action->setCheckable (
true);
322 connect (&sig_mapper, SIGNAL (mapped (
int)),
325 menu.exec (
m_view->mapToGlobal (mpos));
335 bool shown =
settings->value (key,
true).toBool ();
337 m_view->setColumnHidden (col + 1, shown);
350 QModelIndex index =
m_view->indexAt (qpos);
353 if (index.isValid () && index.column () == 0)
357 menu.addAction (tr (
"Open in Variable Editor"),
this,
360 menu.addAction (tr (
"Copy name"),
this,
363 menu.addAction (tr (
"Copy value"),
this,
367 = menu.addAction (tr (
"Rename"),
this,
374 rename->setDisabled (
true);
375 rename->setToolTip (tr (
"Only top-level symbols may be renamed"));
378 menu.addAction (
"Clear " + var_name,
this,
381 menu.addSeparator ();
383 menu.addAction (
"disp (" + var_name +
')',
this,
386 menu.addAction (
"plot (" + var_name +
')',
this,
389 menu.addAction (
"stem (" + var_name +
')',
this,
392 menu.addSeparator ();
397 menu.addAction (tr (
"Hide filter"),
this,
400 menu.addAction (tr (
"Show filter"),
this,
403 menu.exec (
m_view->mapToGlobal (qpos));
409 QModelIndex index =
m_view->currentIndex ();
411 if (index.isValid ())
415 QClipboard *clipboard = QApplication::clipboard ();
417 clipboard->setText (var_name);
424 QModelIndex index =
m_view->currentIndex ();
426 if (index.isValid ())
433 QModelIndex index =
m_view->currentIndex ();
435 if (index.isValid ())
439 QInputDialog *inputDialog =
new QInputDialog ();
441 inputDialog->setOptions (QInputDialog::NoButtons);
446 = inputDialog->getText (
nullptr,
"Rename Variable",
"New name:",
447 QLineEdit::Normal, var_name, &ok);
449 if (ok && ! new_name.isEmpty ())
457 QModelIndex index =
m_view->currentIndex ();
459 if (index.isValid ())
502 QFontMetrics fm =
m_view->fontMetrics ();
503 int row_height = fm.height ();
506 m_view->setRowHeight (i, row_height);
527 QModelIndex index =
m_view->currentIndex ();
529 if (index.isValid ())
548 QAbstractItemModel *
m =
m_view->model ();
551 =
m->itemData (index.sibling (index.row (), 0));
553 return item_data[0].toString ();
Base class for Octave interfaces that use Qt.
resource_manager & get_resource_manager(void)
gui_settings * get_settings(void) const
QColor storage_class_color(int s_class)
bool is_top_level(void) const
void notice_settings(const gui_settings *)
void rename_variable_signal(const QString &, const QString &)
Signal that user wants to rename a variable.
void handle_contextmenu_edit(void)
void filter_activate(bool enable)
void update_filter_history(void)
QCheckBox * m_filter_checkbox
void command_requested(const QString &cmd)
Signal that user had requested a command on a variable.
void handle_contextmenu_disp(void)
void handle_contextmenu_filter(void)
void edit_variable_signal(const QString &)
Signal that user wants to edit a variable.
void relay_contextmenu_command(const QString &cmdname, bool str=false)
int m_view_previous_row_count
void handle_contextmenu_clear(void)
void notice_settings(const gui_settings *)
QString get_var_name(const QModelIndex &index)
QSortFilterProxyModel m_filter_model
void handle_contextmenu_copy_value(void)
void handle_contextmenu_stem(void)
void setModel(workspace_model *model)
QWidget * m_filter_widget
void handle_contextmenu_plot(void)
void toggle_header(int column)
void handle_contextmenu_copy(void)
workspace_model * m_model
void copy_variable_value_to_clipboard(const QString &)
Signal that user wnats to copy a variable value to the clipboard.
void set_filter_focus(bool focus)
void handle_contextmenu_rename(void)
void contextmenu_requested(const QPoint &pos)
void filter_update(const QString &expression)
void handle_model_changed(void)
void header_contextmenu_requested(const QPoint &mpos)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
int rename(const std::string &from, const std::string &to)
void translate(Matrix &m, double x, double y, double z)
const gui_pref ws_column_state("workspaceview/column_state", QVariant())
const gui_pref ws_sort_order("workspaceview/sort_order", QVariant(Qt::AscendingOrder))
const gui_pref ws_filter_shown("workspaceview/filter_shown", QVariant(true))
const gui_pref ws_mru_list("workspaceview/mru_list", QVariant())
const gui_pref ws_sort_column("workspaceview/sort_by_column", QVariant(0))
const gui_pref ws_enable_colors("workspaceview/enable_colors", QVariant(false))
const QStringList ws_color_names
const QStringList ws_columns_shown_keys
const gui_pref ws_max_filter_history("workspaceview/max_filter_history", QVariant(10))
const gui_pref ws_filter_active("workspaceview/filter_active", QVariant(false))
const gui_pref ws_hide_tool_tips("workspaceview/hide_tools_tips", QVariant(false))
const int ws_colors_count
const QStringList ws_columns_shown
static uint32_t state[624]