Commit 4cd475f3 authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Add missing port widgets when loading component diagrams

The open question is why portwidgets get lost.

CCBUG:403515
FIXED-IN:18.12.2
parent 91a3f119
......@@ -23,6 +23,7 @@
#include "classifier.h"
#include "classifierwidget.h"
#include "classoptionspage.h"
#include "component.h"
#include "cmds.h"
#include "componentwidget.h"
#include "datatype.h"
......@@ -52,6 +53,7 @@
#include "package.h"
#include "packagewidget.h"
#include "pinwidget.h"
#include "portwidget.h"
#include "seqlinewidget.h"
#include "signalwidget.h"
#include "statewidget.h"
......@@ -111,7 +113,50 @@ DEBUG_REGISTER(UMLScene)
*/
class UMLScenePrivate {
public:
UMLScenePrivate() {}
UMLScenePrivate(UMLScene *parent)
: p(parent)
{
}
/**
* Check if there is a corresponding port widget
* for all UMLPort instances and add if not.
*/
void fixupPorts()
{
UMLWidgetList ports;
UMLWidgetList components;
foreach(UMLWidget *w, p->widgetList()) {
if (w->isPortWidget())
ports.append(w);
else if (w->isComponentWidget())
components.append(w);
}
foreach(UMLWidget *cw, components) {
UMLComponent *c = cw->umlObject()->asUMLComponent();
if (!c)
continue;
// iterate through related ports for this component widget
foreach(UMLObject *o, c->containedObjects()) {
UMLPort *up = o->asUMLPort();
if (!up)
continue;
Uml::ID::Type id = o->id();
bool found = false;
foreach(UMLWidget *p, ports) {
if (p->id() == id) {
found = true;
break;
}
}
if (!found)
new PortWidget(p, up, cw);
}
}
}
UMLScene *p;
};
/**
......@@ -133,7 +178,7 @@ UMLScene::UMLScene(UMLFolder *parentFolder, UMLView *view)
m_bDrawSelectedOnly(false),
m_bPaste(false),
m_bStartedCut(false),
m_d(new UMLScenePrivate),
m_d(new UMLScenePrivate(this)),
m_view(view),
m_pFolder(parentFolder),
m_pIDChangesLog(0),
......@@ -3696,6 +3741,9 @@ bool UMLScene::loadFromXMI1(QDomElement & qElement)
uWarning() << "failed UMLScene load on associations";
return false;
}
if (this->type() == Uml::DiagramType::Component)
m_d->fixupPorts();
return true;
}
......
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