[Uml-devel] KDE/kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Thu Oct 6 22:30:53 UTC 2005
SVN commit 468002 by okellogg:
apply commit 468001 form branches/KDE/3.5
M +17 -24 associationwidget.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/associationwidget.cpp #468001:468002
@@ -1706,19 +1706,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) {
@@ -1730,34 +1741,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