Mercurial > octave-nkf
diff libgui/src/workspace-view.h @ 16502:45ae1038ee89
allow renaming of variables in workspace viewer
* main-window.h, main-window.cc
(main_window::handle_rename_variable_request): New function.
(main_window::construct_octave_qt_link): Connect
_workspace_model::rename_variable to
main_window::handle_rename_variable_request.
(main_window::rename_variable_callback): New function.
* octave-qt-link.h, octave-qt-link.cc
(octave_qt_link::do_set_workspace,
octave_qt_link::set_workspace_signal): New argument, top_level.
Change all uses.
* octave-link.h, octave-link.cc (octave_link::post_event):
Provide two-argument version.
(octave_link::set_workspace, octave_link::do_set_workspace):
New argument, top_level. Change all uses.
* workspace-model.h, workspace-model.cc (workspace_model::flags):
Conditionally add Qt::ItemIsEditable to flags.
(workspace_model::data): Also return value for column 0 if it is
editable.
(workspace_model::setData): Handle setting new values.
(workspace_model::_top_level): New data member.
(workspace_model::set_workspace): New argument, top_level.
(workspace_model::rename_variable): New signal.
* workspace-view.h, workspace-view.cc (variable_name_editor):
New class.
(workspace_view::var_name_editor): New data member.
(workspace_view::workspace_view): Initialize it. Set var_name_editor
as delegate for column 0.
(workspace_view::~workspace_view): Delete var_name_editor.
(workspace_view::item_double_clicked): Delete.
* symtab.h (symbol_table::rename, symbol_table::do_rename,
symbol_table::symbol_record::rename): New functions.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 12 Apr 2013 14:50:56 -0400 |
parents | 079ec7ce60e0 |
children | dbc7018be4be |
line wrap: on
line diff
--- a/libgui/src/workspace-view.h Fri Apr 12 19:10:32 2013 +0200 +++ b/libgui/src/workspace-view.h Fri Apr 12 14:50:56 2013 -0400 @@ -24,12 +24,34 @@ #if !defined (workspace_view_h) #define workspace_view_h 1 +#include <QItemDelegate> #include <QTableView> #include <QSemaphore> #include "octave-dock-widget.h" #include "workspace-model.h" +class variable_name_editor : public QItemDelegate +{ + Q_OBJECT + +public: + + variable_name_editor (QObject *p = 0) : QItemDelegate (p) { } + + QWidget *createEditor (QWidget *p, const QStyleOptionViewItem& option, + const QModelIndex& index) const; + + void setEditorData (QWidget *editor, const QModelIndex& index) const; + + void setModelData (QWidget *editor, QAbstractItemModel *model, + const QModelIndex& index) const; + + void updateEditorGeometry (QWidget *editor, + const QStyleOptionViewItem& option, + const QModelIndex&) const; +}; + class workspace_view : public octave_dock_widget { Q_OBJECT @@ -44,7 +66,6 @@ void setModel (workspace_model *model) { view->setModel (model); } - signals: /** signal that user had requested a command on a variable */ @@ -56,7 +77,6 @@ protected slots: - void item_double_clicked (QModelIndex index); void contextmenu_requested (const QPoint& pos); // context menu slots @@ -68,7 +88,9 @@ void relay_contextmenu_command (const QString& cmdname); - QTableView * view; + QTableView *view; + + variable_name_editor *var_name_editor; }; #endif