[Uml-devel] branches/work/soc-umbrello/umbrello

Gopala Krishna A krishna.ggk at gmail.com
Thu Sep 25 16:24:30 UTC 2008


SVN commit 864834 by gopala:

* Do not insert new points on dragging line segement of a New::LinePath
* Double clicking on point (non end points) should remove that point.



 M  +13 -11    newlinepath.cpp  
 M  +0 -3      newlinepath.h  


--- branches/work/soc-umbrello/umbrello/newlinepath.cpp #864833:864834
@@ -49,7 +49,6 @@
     LinePath::LinePath(QGraphicsItem *parent) : QGraphicsItem(parent)
     {
         m_activePointIndex = m_activeSegmentIndex = -1;
-        m_hasSegmentMoved = false;
         setFlags(ItemIsSelectable | ItemIsFocusable);
     }
 
@@ -418,7 +417,6 @@
             m_activePointIndex = closestPointIndex(event->pos());
             // calculate only if active point index is -1
             m_activeSegmentIndex = (m_activePointIndex != -1) ? -1 : segmentIndex(event->pos());
-            m_hasSegmentMoved = false;
         }
         else {
             m_activePointIndex = m_activeSegmentIndex = -1;
@@ -433,12 +431,6 @@
             setPoint(m_activePointIndex, event->pos());
         }
         else if (m_activeSegmentIndex != -1) {
-            if (m_hasSegmentMoved == false) {
-                insertPoint(m_activeSegmentIndex, m_points[m_activeSegmentIndex]);
-                ++m_activeSegmentIndex;
-                insertPoint(m_activeSegmentIndex + 1, m_points[m_activeSegmentIndex + 1]);
-                m_hasSegmentMoved = true;
-            }
             QPointF delta = event->scenePos() - event->lastScenePos();
             setPoint(m_activeSegmentIndex, m_points[m_activeSegmentIndex] + delta);
             setPoint(m_activeSegmentIndex + 1, m_points[m_activeSegmentIndex + 1] + delta);
@@ -450,7 +442,6 @@
     {
         if (event->buttons() & Qt::LeftButton) {
             m_activeSegmentIndex = m_activePointIndex = -1;
-            m_hasSegmentMoved = false;
         }
         QGraphicsItem::mouseReleaseEvent(event);
     }
@@ -458,10 +449,21 @@
     /// Inserts a new point at double click position.
     void LinePath::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
     {
-        int index = insertableLinePathIndex(event->pos());
+        int index = closestPointIndex(event->pos());
+        // First check if double click was on a point
         if (index != -1) {
-            insertPoint(index, event->pos());
+            // If on point but not endpoint, delete the point
+            if (!isEndPointIndex(index)) {
+                removePoint(index);
+            }
         }
+        else {
+            // Else insert a new point on the line segment
+            index = insertableLinePathIndex(event->pos());
+            if (index != -1) {
+                insertPoint(index, event->pos());
+            }
+        }
     }
 
     /**
--- branches/work/soc-umbrello/umbrello/newlinepath.h #864833:864834
@@ -102,9 +102,6 @@
         /// The shape of this linepath.
         QPainterPath m_shape;
 
-        /// State variable to keep track of first move of segment.
-        bool m_hasSegmentMoved;
-
         /// The default delta for fuzzy recognition of points closer to point.
         static const qreal Delta;
         /// The radius of circles drawn to show "selection".




More information about the umbrello-devel mailing list