[Uml-devel] branches/KDE/3.4/kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Thu Jun 9 10:57:10 UTC 2005


SVN commit 423794 by okellogg:

Backport fix for bug 106356.

 M  +26 -0     associationwidget.cpp  
 M  +10 -0     umlview.cpp  
 M  +8 -0      umlview.h  


--- branches/KDE/3.4/kdesdk/umbrello/umbrello/associationwidget.cpp #423793:423794
@@ -2288,6 +2288,32 @@
 		p.setY(newY);
 	}
 
+	// Prevent the moving vertex from disappearing underneath a widget
+	// (else there's no way to get it back.)
+	UMLWidget *onW = m_pView->testOnWidget(p);
+	if (onW) {
+		const int pX = p.x();
+		const int pY = p.y();
+		const int wX = onW->getX();
+		const int wY = onW->getY();
+		const int wWidth = onW->getWidth();
+		const int wHeight = onW->getHeight();
+		if (pX > wX && pX < wX + wWidth) {
+			const int midX = wX + wWidth / 2;
+			if (pX <= midX)
+				p.setX(wX);
+			else
+				p.setX(wX + wWidth);
+		}
+		if (pY > wY && pY < wY + wHeight) {
+			const int midY = wY + wHeight / 2;
+			if (pY <= midY)
+				p.setY(wY);
+			else
+				p.setY(wY + wHeight);
+		}
+	}
+
 	//move event called now
 	QMoveEvent m(p, oldp);
 	moveEvent(&m);
--- branches/KDE/3.4/kdesdk/umbrello/umbrello/umlview.cpp #423793:423794
@@ -707,6 +707,16 @@
 	return 0;
 }
 
+UMLWidget *UMLView::testOnWidget(QPoint p) {
+	UMLWidget *obj;
+	UMLWidgetListIt it(m_WidgetList);
+	for (UMLWidgetListIt it(m_WidgetList); (obj = it.current()) != NULL; ++it) {
+		if (obj->onWidget(p))
+			return obj;
+	}
+	return NULL;
+}
+
 void UMLView::checkMessages(ObjectWidget * w) {
 	if(getType() != dt_Sequence)
 		return;
--- branches/KDE/3.4/kdesdk/umbrello/umbrello/umlview.h #423793:423794
@@ -907,6 +907,14 @@
 	}
 
 	/**
+	 * Tests the given point against all widgets and returns the
+	 * widget for which the point is within its bounding rectangle.
+	 * Returns NULL if the point is not inside any widget.
+	 * Does not use or modify the m_pOnWidget member.
+	 */
+	UMLWidget *testOnWidget(QPoint p);
+
+	/**
 	 * Initialize and announce a newly created widget.
 	 * Auxiliary to contentsMouseReleaseEvent().
 	 */




More information about the umbrello-devel mailing list