diff libgui/src/workspace-model.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 a1f613e5066d
line wrap: on
line diff
--- a/libgui/src/workspace-model.h	Fri Apr 12 19:10:32 2013 +0200
+++ b/libgui/src/workspace-model.h	Fri Apr 12 14:50:56 2013 -0400
@@ -42,6 +42,9 @@
 
   QVariant data (const QModelIndex& index, int role) const;
 
+  bool setData (const QModelIndex& index, const QVariant& value,
+                int role = Qt::EditRole);
+
   Qt::ItemFlags flags (const QModelIndex& index) const;
 
   QVariant headerData (int section, Qt::Orientation orientation,
@@ -51,9 +54,12 @@
 
   int columnCount (const QModelIndex& parent = QModelIndex ()) const;
 
+  bool is_top_level (void) const { return _top_level; }
+
 public slots:
 
-  void set_workspace (const QString& scopes,
+  void set_workspace (bool top_level,
+                      const QString& scopes,
                       const QStringList& symbols,
                       const QStringList& class_names,
                       const QStringList& dimensions,
@@ -65,11 +71,14 @@
 
   void model_changed (void);
 
+  void rename_variable (const QString& old_name, const QString& new_name);
+
 private:
 
   void clear_data (void);
   void update_table (void);
 
+  bool _top_level;
   QString _scopes;
   QStringList _symbols;
   QStringList _class_names;