diff libgui/src/workspace-model.cc @ 16521:dbc7018be4be

use context menu for workspace viewer rename and copy to clipboard operations * workspace-model.cc (workspace_model::data): Handle Qt::ToolTipRole for first column. * workspace-view.h, workspace-view.cc (variable_name): Delete class. (workspace_view::var_name_editor): Delete data member and all uses. (workspace_view::contextmenu_requested): New menu items for rename and copy. (workspace_view::handle_contextmenu_rename, workspace_view::handle_contextmenu_copy): New functions.
author John W. Eaton <jwe@octave.org>
date Tue, 16 Apr 2013 01:49:20 -0400
parents 45ae1038ee89
children 8701792e16ec
line wrap: on
line diff
--- a/libgui/src/workspace-model.cc	Mon Apr 15 21:48:27 2013 +0200
+++ b/libgui/src/workspace-model.cc	Tue Apr 16 01:49:20 2013 -0400
@@ -58,10 +58,12 @@
   Qt::ItemFlags retval = 0;
 
   if (idx.isValid ())
-    retval |= Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+    {
+      retval |= Qt::ItemIsEnabled;
 
-  if (idx.column () == 0)
-    retval |= Qt::ItemIsEditable;
+      if (_top_level && idx.column () == 0)
+        retval |= Qt::ItemIsSelectable;
+    }
 
   return retval;
 }
@@ -83,12 +85,16 @@
 
   if (idx.isValid ()
       && (role == Qt::DisplayRole
-          || (idx.column () == 0 && role == Qt::EditRole)))
+          || (idx.column () == 0 && (role == Qt::EditRole
+                                     || role == Qt::ToolTipRole))))
     {
       switch (idx.column ())
         {
         case 0:
-          retval = QVariant (_symbols[idx.row()]);
+          if (role == Qt::ToolTipRole)
+            retval = QVariant (tr ("Right click to copy, rename, or display"));
+          else
+            retval = QVariant (_symbols[idx.row()]);
           break;
 
         case 1: