Mercurial > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
16501:3781abc74540 | 16502:45ae1038ee89 |
---|---|
22 */ | 22 */ |
23 | 23 |
24 #if !defined (workspace_view_h) | 24 #if !defined (workspace_view_h) |
25 #define workspace_view_h 1 | 25 #define workspace_view_h 1 |
26 | 26 |
27 #include <QItemDelegate> | |
27 #include <QTableView> | 28 #include <QTableView> |
28 #include <QSemaphore> | 29 #include <QSemaphore> |
29 | 30 |
30 #include "octave-dock-widget.h" | 31 #include "octave-dock-widget.h" |
31 #include "workspace-model.h" | 32 #include "workspace-model.h" |
33 | |
34 class variable_name_editor : public QItemDelegate | |
35 { | |
36 Q_OBJECT | |
37 | |
38 public: | |
39 | |
40 variable_name_editor (QObject *p = 0) : QItemDelegate (p) { } | |
41 | |
42 QWidget *createEditor (QWidget *p, const QStyleOptionViewItem& option, | |
43 const QModelIndex& index) const; | |
44 | |
45 void setEditorData (QWidget *editor, const QModelIndex& index) const; | |
46 | |
47 void setModelData (QWidget *editor, QAbstractItemModel *model, | |
48 const QModelIndex& index) const; | |
49 | |
50 void updateEditorGeometry (QWidget *editor, | |
51 const QStyleOptionViewItem& option, | |
52 const QModelIndex&) const; | |
53 }; | |
32 | 54 |
33 class workspace_view : public octave_dock_widget | 55 class workspace_view : public octave_dock_widget |
34 { | 56 { |
35 Q_OBJECT | 57 Q_OBJECT |
36 | 58 |
42 | 64 |
43 public: | 65 public: |
44 | 66 |
45 void setModel (workspace_model *model) { view->setModel (model); } | 67 void setModel (workspace_model *model) { view->setModel (model); } |
46 | 68 |
47 | |
48 signals: | 69 signals: |
49 | 70 |
50 /** signal that user had requested a command on a variable */ | 71 /** signal that user had requested a command on a variable */ |
51 void command_requested (const QString& cmd); | 72 void command_requested (const QString& cmd); |
52 | 73 |
54 | 75 |
55 void closeEvent (QCloseEvent *event); | 76 void closeEvent (QCloseEvent *event); |
56 | 77 |
57 protected slots: | 78 protected slots: |
58 | 79 |
59 void item_double_clicked (QModelIndex index); | |
60 void contextmenu_requested (const QPoint& pos); | 80 void contextmenu_requested (const QPoint& pos); |
61 | 81 |
62 // context menu slots | 82 // context menu slots |
63 void handle_contextmenu_disp (void); | 83 void handle_contextmenu_disp (void); |
64 void handle_contextmenu_plot (void); | 84 void handle_contextmenu_plot (void); |
66 | 86 |
67 private: | 87 private: |
68 | 88 |
69 void relay_contextmenu_command (const QString& cmdname); | 89 void relay_contextmenu_command (const QString& cmdname); |
70 | 90 |
71 QTableView * view; | 91 QTableView *view; |
92 | |
93 variable_name_editor *var_name_editor; | |
72 }; | 94 }; |
73 | 95 |
74 #endif | 96 #endif |