[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Thu Oct 6 22:30:03 UTC 2005
SVN commit 468001 by okellogg:
calculateTextPosition(): Apply improve_multiplicity.patch from Peter Soetens,
http://www.geeksoc.org/~jr/umbrello/uml-devel/8974.html
M +17 -24 associationwidget.cpp
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/associationwidget.cpp #468000:468001
@@ -1703,19 +1703,30 @@
QPoint AssociationWidget::calculateTextPosition(Text_Role role) {
const int SPACE = 2;
QPoint p(-1, -1), q(-1, -1);
+
+ // used to find out if association end point (p)
+ // is at top or bottom edge of widget.
+ bool is_top_or_bottom(false);
+ UMLWidget *pWidget(0);
+
if (role == tr_MultiA || role == tr_ChangeA || role == tr_RoleAName) {
p = m_LinePath.getPoint( 0 );
q = m_LinePath.getPoint( 1 );
+ pWidget = m_role[A].m_pWidget;
} else if (role == tr_MultiB || role == tr_ChangeB || role == tr_RoleBName) {
const uint lastSegment = m_LinePath.count() - 1;
p = m_LinePath.getPoint(lastSegment);
q = m_LinePath.getPoint(lastSegment - 1);
+ pWidget = m_role[B].m_pWidget;
} else if (role != tr_Name) {
kdError() << "AssociationWidget::calculateTextPosition called with unsupported Text_Role "
<< role << endl;
return QPoint(-1, -1);
}
+ if ( pWidget && ( pWidget->getY() == p.y() || pWidget->getY() + pWidget->height() == p.y() ))
+ is_top_or_bottom = true;
+
FloatingText *text = getTextWidgetByRole(role);
int textW = 0, textH = 0;
if (text) {
@@ -1727,34 +1738,16 @@
if (role == tr_MultiA || role == tr_MultiB) {
- int slope, divisor = p.x() - q.x();
- if (divisor != 0)
- slope = (p.y() - q.y()) / divisor;
+ if( (p.y() > q.y()) != is_top_or_bottom )
+ y = p.y() + SPACE;
else
- slope = 10000;
+ y = p.y() - SPACE - textH;
- if( p.y() > q.y() )
- if(slope == 0)
- y = p.y() + SPACE;
- else
- y = p.y() - SPACE - textH;
+ if( p.x() < q.x() != is_top_or_bottom )
+ x = p.x() + SPACE;
else
- if(slope == 0)
- y = p.y() - SPACE - textH;
- else
- y = p.y() + SPACE;
+ x = p.x() - SPACE - textW;
- if( p.x() < q.x() )
- if(slope == 0)
- x = p.x() + SPACE;
- else
- x = p.x() - SPACE - textW;
- else
- if(slope == 0)
- x = p.x() - SPACE - textW;
- else
- x = p.x() + SPACE;
-
} else if (role == tr_ChangeA || role == tr_ChangeB) {
if( p.y() > q.y() )
More information about the umbrello-devel
mailing list