changeset 20427:a8cc8318da8c stable

show history context menu only for clicks on entries * history-dock-widget.cc(ctxMenu): get index of mouse click position and check whether it is valid before creating and showing the context menu
author Torsten <ttl@justmail.de>
date Sat, 25 Jul 2015 22:17:57 +0200
parents 2b28f509b645
children fc23fbe05f3a
files libgui/src/history-dock-widget.cc
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/history-dock-widget.cc	Fri Jul 24 14:23:28 2015 +0200
+++ b/libgui/src/history-dock-widget.cc	Sat Jul 25 22:17:57 2015 +0200
@@ -179,14 +179,20 @@
 void history_dock_widget::ctxMenu (const QPoint &xpos)
 {
   QMenu menu (this);
-  menu.addAction (resource_manager::icon ("edit-copy"),
+
+  QModelIndex index = _history_list_view->indexAt (xpos);
+
+  if (index.isValid () && index.column () == 0)
+    {
+      menu.addAction (resource_manager::icon ("edit-copy"),
                   tr ("Copy"), this, SLOT (handle_contextmenu_copy (bool)));
-  menu.addAction (tr ("Evaluate"), this,
+      menu.addAction (tr ("Evaluate"), this,
                   SLOT (handle_contextmenu_evaluate (bool)));
-  menu.addAction (resource_manager::icon ("document-new"),
+      menu.addAction (resource_manager::icon ("document-new"),
                   tr ("Create script"), this,
                   SLOT (handle_contextmenu_create_script (bool)));
-  menu.exec (_history_list_view->mapToGlobal (xpos));
+      menu.exec (_history_list_view->mapToGlobal (xpos));
+    }
 }
 
 void history_dock_widget::handle_contextmenu_copy (bool)