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

Gopala Krishna A krishna.ggk at gmail.com
Tue Jan 6 06:52:46 UTC 2009


SVN commit 906397 by gopala:

Disallow end segments of a AssociationWidget(new) to be moved by
mouse.



 M  +13 -1     newlinepath.cpp  
 M  +2 -0      newlinepath.h  
 M  +1 -1      test.cpp  


--- branches/work/soc-umbrello/umbrello/newlinepath.cpp #906396:906397
@@ -408,6 +408,18 @@
     }
 
     /**
+     * retval True If segment at \a index is start or end.
+     */
+    bool AssociationLine::isEndSegmentIndex(int index) const
+    {
+        // num of seg = num of points - 1
+        const int sz = m_points.size() - 1;
+        Q_ASSERT(index >= 0 && index < sz);
+
+        return (index == 0 || index == (sz - 1));
+    }
+
+    /**
      * Sets the start and end points to passed parameters.
      */
     void AssociationLine::setEndPoints(const QPointF& start, const QPointF& end)
@@ -676,7 +688,7 @@
         if (m_activePointIndex != -1) {
             setPoint(m_activePointIndex, event->pos());
         }
-        else if (m_activeSegmentIndex != -1) {
+        else if (m_activeSegmentIndex != -1 && !isEndSegmentIndex(m_activeSegmentIndex)) {
             QPointF delta = event->scenePos() - event->lastScenePos();
             setPoint(m_activeSegmentIndex, m_points[m_activeSegmentIndex] + delta);
             setPoint(m_activeSegmentIndex + 1, m_points[m_activeSegmentIndex + 1] + delta);
--- branches/work/soc-umbrello/umbrello/newlinepath.h #906396:906397
@@ -112,6 +112,8 @@
         int segmentIndex(const QPointF& point, qreal delta = AssociationLine::Delta) const;
 
         bool isEndPointIndex(int index) const;
+        bool isEndSegmentIndex(int index) const;
+
         void setEndPoints(const QPointF &start, const QPointF &end);
 
         void setStartHeadSymbol(HeadSymbol::Symbol symbol);
--- branches/work/soc-umbrello/umbrello/test.cpp #906396:906397
@@ -94,7 +94,7 @@
     path1->insertPoint(1, QPointF(200, 50));
     path1->insertPoint(2, QPointF(700, 300));
     wid->setLineColor(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
-    wid->setLineWidth(4);
+    wid->setLineWidth(0);
 
     path1->setStartHeadSymbol(New::HeadSymbol::Arrow);
     // path1->setEndHeadSymbol(New::HeadSymbol::Circle);




More information about the umbrello-devel mailing list