Commit 8e90c658 authored by Ralf Habacker's avatar Ralf Habacker

Move corresponding code in saveToXMI1() and loadFromXMI1() to the AssociationWidgetRole class

CCBUG:53369
parent 2ba73e22
......@@ -4001,39 +4001,14 @@ void AssociationWidget::saveToXMI1(QDomDocument &qDoc, QDomElement &qElement)
}
assocElement.setAttribute(QLatin1String("widgetaid"), Uml::ID::toString(widgetIDForRole(RoleType::A)));
assocElement.setAttribute(QLatin1String("widgetbid"), Uml::ID::toString(widgetIDForRole(RoleType::B)));
assocElement.setAttribute(QLatin1String("indexa"), m_role[RoleType::A].m_nIndex);
assocElement.setAttribute(QLatin1String("indexb"), m_role[RoleType::B].m_nIndex);
assocElement.setAttribute(QLatin1String("totalcounta"), m_role[RoleType::A].m_nTotalCount);
assocElement.setAttribute(QLatin1String("totalcountb"), m_role[RoleType::B].m_nTotalCount);
m_associationLine->saveToXMI1(qDoc, assocElement);
if (m_nameWidget) {
m_nameWidget->saveToXMI1(qDoc, assocElement);
}
if (multiplicityWidget(RoleType::A)) {
multiplicityWidget(RoleType::A)->saveToXMI1(qDoc, assocElement);
}
if (multiplicityWidget(RoleType::B)) {
multiplicityWidget(RoleType::B)->saveToXMI1(qDoc, assocElement);
}
if (roleWidget(RoleType::A)) {
roleWidget(RoleType::A)->saveToXMI1(qDoc, assocElement);
}
if (roleWidget(RoleType::B)) {
roleWidget(RoleType::B)->saveToXMI1(qDoc, assocElement);
}
if (changeabilityWidget(RoleType::A)) {
changeabilityWidget(RoleType::A)->saveToXMI1(qDoc, assocElement);
}
if (changeabilityWidget(RoleType::B)) {
changeabilityWidget(RoleType::B)->saveToXMI1(qDoc, assocElement);
}
m_role[RoleType::A].saveToXMI1(qDoc, assocElement, QLatin1String("a"));
m_role[RoleType::B].saveToXMI1(qDoc, assocElement, QLatin1String("b"));
if (m_associationClass) {
QString acid = Uml::ID::toString(m_associationClass->id());
......@@ -4186,14 +4161,8 @@ bool AssociationWidget::loadFromXMI1(QDomElement& qElement,
setAssociationType(aType);
QString indexa = qElement.attribute(QLatin1String("indexa"), QLatin1String("0"));
QString indexb = qElement.attribute(QLatin1String("indexb"), QLatin1String("0"));
QString totalcounta = qElement.attribute(QLatin1String("totalcounta"), QLatin1String("0"));
QString totalcountb = qElement.attribute(QLatin1String("totalcountb"), QLatin1String("0"));
m_role[RoleType::A].m_nIndex = indexa.toInt();
m_role[RoleType::B].m_nIndex = indexb.toInt();
m_role[RoleType::A].m_nTotalCount = totalcounta.toInt();
m_role[RoleType::B].m_nTotalCount = totalcountb.toInt();
m_role[RoleType::A].loadFromXMI1(qElement, QLatin1String("a"));
m_role[RoleType::B].loadFromXMI1(qElement, QLatin1String("b"));
QString assocclassid = qElement.attribute(QLatin1String("assocclass"));
if (! assocclassid.isEmpty()) {
......
......@@ -103,3 +103,26 @@ void AssociationWidgetRole::clipSize()
if (changeabilityWidget)
changeabilityWidget->clipSize();
}
void AssociationWidgetRole::saveToXMI1(QDomDocument &qDoc, QDomElement &qElement, const QString &suffix)
{
qElement.setAttribute(QString(QLatin1String("index%1")).arg(suffix), m_nIndex);
qElement.setAttribute(QString(QLatin1String("totalcount%1")).arg(suffix), m_nTotalCount);
if (multiplicityWidget)
multiplicityWidget->saveToXMI1(qDoc, qElement);
if (roleWidget)
roleWidget->saveToXMI1(qDoc, qElement);
if (changeabilityWidget)
changeabilityWidget->saveToXMI1(qDoc, qElement);
}
bool AssociationWidgetRole::loadFromXMI1(QDomElement &qElement, const QString &suffix)
{
QString index = qElement.attribute(QString(QLatin1String("index%1")).arg(suffix), QLatin1String("0"));
QString totalcount = qElement.attribute(QString(QLatin1String("totalcount%1")).arg(suffix), QLatin1String("0"));
m_nIndex = index.toInt();
m_nTotalCount = totalcount.toInt();
// for remaining see AssociationWidget::loadFromXMI
return true;
}
......@@ -20,6 +20,8 @@ class FloatingTextWidget;
class UMLWidget;
class QPointF;
class QDomDocument;
class QDomElement;
/**
* The AssociationWidgetRole struct gathers all information pertaining to the role.
......@@ -55,6 +57,8 @@ public:
void setSelected(bool select);
void clipSize();
void saveToXMI1(QDomDocument &qDoc, QDomElement &qElement, const QString &suffix);
bool loadFromXMI1(QDomElement &qElement, const QString &suffix);
private:
AssociationWidget *m_q;
};
......
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