Commit e191ce93 authored by Ralf Habacker's avatar Ralf Habacker

Move class WidgetRole into separate file and rename it to AssociationWidgetRole

This is a preparation for further refactoring.

CCBUG:53369
parent 4652ae3a
......@@ -413,6 +413,7 @@ set(libumlwidgets_SRCS
umlwidgets/activitywidget.cpp
umlwidgets/actorwidget.cpp
umlwidgets/artifactwidget.cpp
umlwidgets/associationwidgetrole.cpp
umlwidgets/associationline.cpp
umlwidgets/associationwidget.cpp
umlwidgets/boxwidget.cpp
......
......@@ -716,7 +716,7 @@ bool AssociationWidget::activate()
if (AssocRules::allowRole(type)) {
for (unsigned r = RoleType::A; r <= RoleType::B; ++r) {
WidgetRole& robj = m_role[r];
AssociationWidgetRole& robj = m_role[r];
if (robj.roleWidget == 0)
continue;
robj.roleWidget->setLink(this);
......@@ -749,7 +749,7 @@ bool AssociationWidget::activate()
}
for (unsigned r = RoleType::A; r <= RoleType::B; ++r) {
WidgetRole& robj = m_role[r];
AssociationWidgetRole& robj = m_role[r];
FloatingTextWidget* pMulti = robj.multiplicityWidget;
if (pMulti != 0 &&
......@@ -1256,7 +1256,7 @@ void AssociationWidget::cleanup()
updateAssociations(m_role[RoleType::B].m_nTotalCount - 1, m_role[RoleType::B].m_WidgetRegion, RoleType::B);
for (unsigned r = RoleType::A; r <= RoleType::B; ++r) {
WidgetRole& robj = m_role[r];
AssociationWidgetRole& robj = m_role[r];
if (robj.umlWidget) {
robj.umlWidget->removeAssoc(this);
......@@ -3354,8 +3354,8 @@ int AssociationWidget::getRegionCount(Uml::Region::Enum region, Uml::RoleType::E
//don't count this association
if (assocwidget == this)
continue;
const WidgetRole& otherA = assocwidget->m_role[RoleType::A];
const WidgetRole& otherB = assocwidget->m_role[RoleType::B];
const AssociationWidgetRole& otherA = assocwidget->m_role[RoleType::A];
const AssociationWidgetRole& otherB = assocwidget->m_role[RoleType::B];
const UMLWidget *a = otherA.umlWidget;
const UMLWidget *b = otherB.umlWidget;
/*
......@@ -3518,8 +3518,8 @@ void AssociationWidget::updateAssociations(int totalCount,
m_ordered.clear();
// we order the AssociationWidget list by region and x/y value
foreach (AssociationWidget* assocwidget, list) {
WidgetRole *roleA = &assocwidget->m_role[RoleType::A];
WidgetRole *roleB = &assocwidget->m_role[RoleType::B];
AssociationWidgetRole *roleA = &assocwidget->m_role[RoleType::A];
AssociationWidgetRole *roleB = &assocwidget->m_role[RoleType::B];
UMLWidget *wA = roleA->umlWidget;
UMLWidget *wB = roleB->umlWidget;
// Skip self associations.
......@@ -3625,7 +3625,7 @@ void AssociationWidget::updateRegionLineCount(int index, int totalCount,
return;
}
WidgetRole& robj = m_role[role];
AssociationWidgetRole& robj = m_role[role];
UMLWidget * pWidget = robj.umlWidget;
robj.m_nIndex = index;
......@@ -3785,7 +3785,7 @@ UMLWidget* AssociationWidget::onWidget(const QPointF &p)
return m_nameWidget;
}
for (int i = 0; i <= 1; i++) {
const WidgetRole& r = m_role[i];
const AssociationWidgetRole& r = m_role[i];
if (r.multiplicityWidget && r.multiplicityWidget->onWidget(p))
return r.multiplicityWidget;
if (r.changeabilityWidget && r.changeabilityWidget->onWidget(p))
......@@ -4373,16 +4373,3 @@ bool AssociationWidget::loadFromXMI1(QDomElement& qElement)
return false;
}
}
AssociationWidget::WidgetRole::WidgetRole()
: multiplicityWidget(nullptr)
, changeabilityWidget(nullptr)
, roleWidget(nullptr)
, umlWidget(nullptr)
, m_WidgetRegion(Uml::Region::Error)
, m_nIndex(0)
, m_nTotalCount(0)
, visibility(Uml::Visibility::Public)
, changeability(Uml::Changeability::Changeable)
{
}
......@@ -12,6 +12,7 @@
#define ASSOCIATIONWIDGET_H
#include "associationwidgetlist.h"
#include "associationwidgetrole.h"
#include "linkwidget.h"
#include "messagewidgetlist.h"
#include "umlwidgetlist.h"
......@@ -247,32 +248,6 @@ private:
void createPointsException();
void updatePointsException();
/**
* The WidgetRole struct gathers all information pertaining to the role.
* The AssociationWidget class contains two WidgetRole objects, one for each
* side of the association (A and B).
*/
struct WidgetRole {
FloatingTextWidget* multiplicityWidget; ///< information regarding multiplicity
FloatingTextWidget* changeabilityWidget; ///< information regarding changeability
FloatingTextWidget* roleWidget; ///< role's label of this association
QPointer<UMLWidget> umlWidget; ///< UMLWidget at this role's side of this association
Uml::Region::Enum m_WidgetRegion; ///< region of this role's widget
int m_nIndex; ///< the index of where the line is on the region for this role
int m_nTotalCount; ///< total amount of associations on the region this role's line is on
// The following items are only used if m_pObject is not set.
Uml::Visibility::Enum visibility;
Uml::Changeability::Enum changeability;
QString roleDocumentation;
WidgetRole();
};
void updateRegionLineCount(int index, int totalCount,
Uml::Region::Enum region, Uml::RoleType::Enum role);
......@@ -323,7 +298,7 @@ private:
AssociationLine *m_associationLine; ///< the definition points for the association line
ClassifierWidget *m_associationClass; ///< used if we have an assoc. class
Uml::AssociationType::Enum m_associationType; ///< is only used if m_pObject is not set
WidgetRole m_role[2];
AssociationWidgetRole m_role[2];
FloatingTextWidget* m_nameWidget; ///< displays the name of this association
QPointF m_eventScenePos; ///< holds scene pos of contextMenuEvent()
......
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2002-2019 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
#include "associationwidgetrole.h"
#include "umlwidget.h"
AssociationWidgetRole::AssociationWidgetRole()
: multiplicityWidget(nullptr)
, changeabilityWidget(nullptr)
, roleWidget(nullptr)
, umlWidget(nullptr)
, m_WidgetRegion(Uml::Region::Error)
, m_nIndex(0)
, m_nTotalCount(0)
, visibility(Uml::Visibility::Public)
, changeability(Uml::Changeability::Changeable)
{
}
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2002-2019 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
#ifndef ASSOCIATIONWIDGETROLE_H
#define ASSOCIATIONWIDGETROLE_H
#include "basictypes.h"
#include <QPointer>
class FloatingTextWidget;
class UMLWidget;
/**
* The AssociationWidgetRole struct gathers all information pertaining to the role.
* The AssociationWidget class contains two AssociationWidgetRole objects, one for
* each side of the association (A and B).
*/
class AssociationWidgetRole {
public:
FloatingTextWidget* multiplicityWidget; ///< information regarding multiplicity
FloatingTextWidget* changeabilityWidget; ///< information regarding changeability
FloatingTextWidget* roleWidget; ///< role's label of this association
QPointer<UMLWidget> umlWidget; ///< UMLWidget at this role's side of this association
Uml::Region::Enum m_WidgetRegion; ///< region of this role's widget
int m_nIndex; ///< the index of where the line is on the region for this role
int m_nTotalCount; ///< total amount of associations on the region this role's line is on
// The following items are only used if m_pObject is not set.
Uml::Visibility::Enum visibility;
Uml::Changeability::Enum changeability;
QString roleDocumentation;
AssociationWidgetRole();
};
#endif // ASSOCIATIONWIDGETROLE_H
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