Commit 2fe1bbce authored by Ralf Habacker's avatar Ralf Habacker
Browse files

On loading port widgets from xmi file setup connected state

This fixes the issue that the port jumps to the top edge of
the component on movement.

CCBUG:403622
parent 1c9882e7
......@@ -28,12 +28,15 @@ class ChildWidgetPlacement
public:
ChildWidgetPlacement(PinPortBase* widget);
virtual ~ChildWidgetPlacement() {}
virtual void detectConnectedSide() = 0;
virtual void setInitialPosition() = 0;
virtual void setNewPositionWhenMoved(qreal diffX, qreal diffY) = 0;
virtual void setNewPositionOnParentResize() = 0;
protected:
enum ConnectedSide {
Undefined,
Top,
Right,
Bottom,
......
......@@ -21,6 +21,11 @@ ChildWidgetPlacementPin::~ChildWidgetPlacementPin()
{
}
void ChildWidgetPlacementPin::detectConnectedSide()
{
}
void ChildWidgetPlacementPin::setInitialPosition()
{
m_connectedSide = Top;
......
......@@ -25,6 +25,7 @@ public:
ChildWidgetPlacementPin(PinPortBase* widget);
virtual ~ChildWidgetPlacementPin();
virtual void detectConnectedSide();
virtual void setInitialPosition();
virtual void setNewPositionWhenMoved(qreal diffX, qreal diffY);
virtual void setNewPositionOnParentResize();
......
......@@ -11,6 +11,7 @@
#include "umlwidgets/childwidgetplacementport.h"
#include "umlwidgets/umlwidget.h"
#include "pinportbase.h"
ChildWidgetPlacementPort::ChildWidgetPlacementPort(PinPortBase* widget)
: ChildWidgetPlacement(widget)
......@@ -148,6 +149,34 @@ void ChildWidgetPlacementPort::setNewPositionWhenMoved(qreal diffX, qreal diffY)
setPos(newX, newY);
}
void ChildWidgetPlacementPort::detectConnectedSide()
{
if (m_widget->x() < 0) {
if (m_widget->y() < 0)
m_connectedSide = TopLeft;
else if (m_widget->y() < maxY())
m_connectedSide = Left;
else
m_connectedSide =BottomLeft;
} else if (m_widget->x() < maxX()) {
if (m_widget->y() < 0)
m_connectedSide = Top;
else if (m_widget->y() < maxY())
m_connectedSide = Undefined;
else
m_connectedSide = Bottom;
} else if (m_widget->x() >= maxX()) {
if (m_widget->y() < 0)
m_connectedSide = TopRight;
else if (m_widget->y() < maxY())
m_connectedSide = Right;
else
m_connectedSide =BottomRight;
} else {
m_connectedSide = TopLeft;
}
}
void ChildWidgetPlacementPort::setNewPositionOnParentResize()
{
switch (m_connectedSide)
......
......@@ -24,6 +24,7 @@ public:
ChildWidgetPlacementPort(PinPortBase* widget);
virtual ~ChildWidgetPlacementPort();
virtual void detectConnectedSide();
virtual void setInitialPosition();
virtual void setNewPositionWhenMoved(qreal diffX, qreal diffY);
virtual void setNewPositionOnParentResize();
......
......@@ -316,3 +316,9 @@ bool PinPortBase::loadFromXMI1(QDomElement & qElement)
return true;
}
bool PinPortBase::activate(IDChangeLog* ChangeLog)
{
m_childPlacement->detectConnectedSide();
return true;
}
......@@ -56,6 +56,7 @@ public slots:
protected:
void init(UMLWidget *owner = 0);
bool activate(IDChangeLog* ChangeLog = 0);
private:
ChildWidgetPlacement* createPlacement(WidgetBase::WidgetType type);
......
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