changeset 20044:f2dea119369e

Qt Canvas: set selection type to 'open' on double click (Bug #44669) * libgui/graphics/Canvas.cc (canvasMouseDoubleClickEvent): move autoscale if left mouse and zoom,pan.rotate mode call to canvasMousePressEvent and call canvasMousePressEvent on double click. (canvasMousePressEvent) set isdlbclick flag if even type was MouseDlbClickEvent, pass doubleclick to figureSelectionType calls, and if double click on left mouse occured in zoom,rotate,pan mode, then autoscale.
author John Donoghue
date Wed, 01 Apr 2015 15:16:12 -0400
parents bd97c41cce06
children b08c13ed4a8c
files libgui/graphics/Canvas.cc
diffstat 1 files changed, 21 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/Canvas.cc	Wed Apr 01 11:52:16 2015 -0700
+++ b/libgui/graphics/Canvas.cc	Wed Apr 01 15:16:12 2015 -0400
@@ -414,60 +414,8 @@
 void
 Canvas::canvasMouseDoubleClickEvent (QMouseEvent* event)
 {
-  if (event->buttons () != Qt::LeftButton)
-    return;
-
-  gh_manager::auto_lock lock;
-  graphics_object obj = gh_manager::get_object (m_handle);
-
-  if (obj.valid_object ())
-    {
-      graphics_object axesObj;
-
-      Matrix children = obj.get_properties ().get_children ();
-      octave_idx_type num_children = children.numel ();
-
-      for (int i = 0; i < num_children; i++)
-        {
-          graphics_object childObj (gh_manager::get_object (children(i)));
-
-          if (childObj.isa ("axes"))
-            {
-              graphics_object go = selectFromAxes (childObj, event->pos ());
-
-              if (go)
-                {
-                  axesObj = childObj;
-                  break;
-                }
-            }
-        }
-
-      bool redrawFigure = true;
-
-      if (axesObj)
-        {
-          graphics_object figObj (obj.get_ancestor ("figure"));
-
-          if (axesObj.get_properties ().handlevisibility_is ("on"))
-            {
-              Utils::properties<figure> (figObj)
-                .set_currentaxes (axesObj.get_handle ().as_octave_value ());
-
-              if (pan_enabled (figObj) || rotate_enabled (figObj)
-                  || zoom_enabled (figObj))
-                {
-                  axes::properties& ap =
-                    Utils::properties<axes> (axesObj);
-
-                  autoscale_axes (ap);
-                }
-            }
-
-          if (redrawFigure)
-            redraw (false);
-        }
-    }
+  // same processing as nornal click, but event type is MouseButtonDblClick
+  canvasMousePressEvent (event);
 }
 
 static double
@@ -502,6 +450,8 @@
   gh_manager::auto_lock lock;
   graphics_object obj = gh_manager::get_object (m_handle);
 
+  bool isdblclick = (event->type () == QEvent::MouseButtonDblClick);
+
   if (obj.valid_object ())
     {
       graphics_object figObj (obj.get_ancestor ("figure"));
@@ -588,7 +538,7 @@
         {
         case NoMode:
           gh_manager::post_set (figObj.get_handle (), "selectiontype",
-                                Utils::figureSelectionType (event), false);
+                                Utils::figureSelectionType (event, isdblclick), false);
 
           updateCurrentPoint (figObj, obj, event);
 
@@ -617,7 +567,21 @@
             {
               bool redraw_figure = true;
 
-              if (event->modifiers () == Qt::NoModifier)
+              if (isdblclick)
+                {
+                  if (event->button () == Qt::LeftButton)
+                    {
+                      axes::properties& ap =
+                        Utils::properties<axes> (axesObj);
+
+                      autoscale_axes (ap);
+                    }
+                  else
+                    {
+                      redraw_figure = false;
+                    }
+                }
+              else if (event->modifiers () == Qt::NoModifier)
                 {
                   switch (event->buttons ())
                     {
@@ -668,6 +632,7 @@
           break;
         }
     }
+
 }
 
 void