Commit d5cb5adb authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Fix 'incorrect display of interface widgets in the component diagram when...

Fix 'incorrect display of interface widgets in the component diagram when adding a second connection'

With this commit a new class member WidgetBase::m_changesShape is
introduced to track widgets that changes it shape when the number of
connections or their positions are changed.

BUG:403761
FIXED-IN:2.27.2 (KDE Applications 18.12.2)
parent c995f32e
......@@ -230,6 +230,10 @@ void ToolBarStateAssociation::setSecondWidget()
}
if (valid) {
AssociationWidget *temp = AssociationWidget::create(m_pUMLScene, widgetA, type, widgetB);
if (widgetA->changesShape())
widgetA->updateGeometry();
if (widgetB->changesShape())
widgetB->updateGeometry();
FloatingTextWidget *wt = temp->textWidgetByRole(Uml::TextRole::Coll_Message);
if (wt)
wt->showOperationDialog();
......
......@@ -1966,6 +1966,8 @@ void AssociationWidget::widgetMoved(UMLWidget* widget, qreal dx, qreal dy)
//only calculate position and move text if the segment it is on is moving
setTextPositionRelatively(TextRole::Name, m_oldNamePoint);
}
if (m_role[RoleType::B].umlWidget->changesShape())
m_role[RoleType::B].umlWidget->updateGeometry();
}//end if widgetA moved
else if (m_role[RoleType::B].umlWidget == widget) {
const int size = m_associationLine->count();
......@@ -1973,6 +1975,8 @@ void AssociationWidget::widgetMoved(UMLWidget* widget, qreal dx, qreal dy)
//only calculate position and move text if the segment it is on is moving
setTextPositionRelatively(TextRole::Name, m_oldNamePoint);
}
if (m_role[RoleType::A].umlWidget->changesShape())
m_role[RoleType::A].umlWidget->updateGeometry();
}//end if widgetB moved
if (m_role[RoleType::A].roleWidget && !m_role[RoleType::A].roleWidget->isSelected()) {
......
......@@ -884,7 +884,7 @@ QPainterPath ClassifierWidget::shape() const
{
QPainterPath path;
if (classifier() && classifier()->isInterface() && visualProperty(DrawAsCircle)) {
path.addEllipse(rect());
path.addEllipse(QRectF(QPointF(), calculateAsCircleSize()));
return path;
}
QSizeF mainSize = rect().size();
......@@ -1157,6 +1157,7 @@ void ClassifierWidget::setDrawAsCircle(bool drawAsCircle)
m_pInterfaceName->hide();
m_resizable = true;
}
setChangesShape(drawAsCircle);
updateGeometry();
update();
}
......
......@@ -1681,6 +1681,7 @@ void UMLWidget::updateGeometry()
setSize(clipWidth, clipHeight);
slotSnapToGrid();
adjustAssocs(size.width()-oldW, size.height()-oldH);
update();
}
/**
......
......@@ -56,7 +56,8 @@ WidgetBase::WidgetBase(UMLScene *scene, WidgetType type)
m_usesDiagramLineWidth(true),
m_usesDiagramTextColor(true),
m_usesDiagramUseFillColor(true),
m_autoResize(true)
m_autoResize(true),
m_changesShape(false)
{
Q_ASSERT(m_baseType > wt_Min && m_baseType < wt_Max);
// Note: no virtual methods from derived classes available,
......@@ -498,6 +499,24 @@ void WidgetBase::setAutoResize(bool state)
m_autoResize = state;
}
/**
* Return changes state property
* @return the changes shape state
*/
bool WidgetBase::changesShape()
{
return m_changesShape;
}
/**
* set changes shape property
* @param state
*/
void WidgetBase::setChangesShape(bool state)
{
m_changesShape = state;
}
/**
* A virtual method for the widget to display a property dialog box.
* Subclasses should reimplment this appropriately.
......
......@@ -173,6 +173,9 @@ public:
bool autoResize();
void setAutoResize(bool state);
bool changesShape();
void setChangesShape(bool state);
virtual bool showPropertiesDialog();
virtual bool loadFromXMI1(QDomElement &qElement);
......@@ -294,6 +297,7 @@ protected:
bool m_usesDiagramTextColor;
bool m_usesDiagramUseFillColor;
bool m_autoResize;
bool m_changesShape; ///< The widget changes its shape when the number of connections or their positions are changed
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment