Commit fa3f51e7 authored by Ralf Habacker's avatar Ralf Habacker

Fix QPointer related dynamic_casts to use asUML... wrapper().

CCBUG:368282
Reviewed-by: aaron.nottbeck at sag.eu
parent a5f92b67
......@@ -1211,7 +1211,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break;
}
case UMLObject::ot_Attribute: {
UMLAttribute *retval = dynamic_cast<UMLAttribute*>(m_List.takeAt(index).data());
UMLAttribute *retval = m_List.takeAt(index)->asUMLAttribute();
if (retval) {
emit attributeRemoved(retval);
UMLObject::emitModified();
......@@ -1221,7 +1221,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break;
}
case UMLObject::ot_Template: {
UMLTemplate *templt = dynamic_cast<UMLTemplate*>(m_List.takeAt(index).data());
UMLTemplate *templt = m_List.takeAt(index)->asUMLTemplate();
if (templt) {
emit templateRemoved(templt);
UMLObject::emitModified();
......@@ -1231,7 +1231,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break;
}
case UMLObject::ot_EnumLiteral: {
UMLEnumLiteral *el = dynamic_cast<UMLEnumLiteral*>(m_List.takeAt(index).data());
UMLEnumLiteral *el = m_List.takeAt(index)->asUMLEnumLiteral();
if (el) {
UMLEnum *e = this->asUMLEnum();
e->signalEnumLiteralRemoved(el);
......@@ -1242,7 +1242,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
break;
}
case UMLObject::ot_EntityAttribute: {
UMLEntityAttribute* el = dynamic_cast<UMLEntityAttribute*>(m_List.takeAt(index).data());
UMLEntityAttribute* el = m_List.takeAt(index)->asUMLEntityAttribute();
if (el) {
UMLEntity *e = this->asUMLEntity();
e->signalEntityAttributeRemoved(el);
......@@ -1274,7 +1274,7 @@ void UMLClassifier::setOriginType(UMLClassifier *origType)
*/
UMLClassifier * UMLClassifier::originType() const
{
return dynamic_cast<UMLClassifier*>(m_pSecondary.data());
return m_pSecondary->asUMLClassifier();
}
/**
......
......@@ -99,7 +99,7 @@ QString UMLClassifierListItem::toString(Uml::SignatureType::Enum sig)
*/
UMLClassifier * UMLClassifierListItem::getType() const
{
return dynamic_cast<UMLClassifier*>(m_pSecondary.data());
return m_pSecondary->asUMLClassifier();
}
/**
......
......@@ -53,7 +53,7 @@ void ArtifactWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
}
if (umlObject()) {
UMLArtifact *umlart = dynamic_cast<UMLArtifact*>(m_umlObject.data());
UMLArtifact *umlart = m_umlObject->asUMLArtifact();
UMLArtifact::Draw_Type drawType = umlart->getDrawAsType();
switch (drawType) {
case UMLArtifact::defaultDraw:
......@@ -97,7 +97,7 @@ QSizeF ArtifactWidget::minimumSize() const
if (!m_umlObject) {
return UMLWidget::minimumSize();
}
UMLArtifact *umlart = dynamic_cast<UMLArtifact*>(m_umlObject.data());
UMLArtifact *umlart = m_umlObject->asUMLArtifact();
if (umlart->getDrawAsType() == UMLArtifact::defaultDraw) {
return calculateNormalSize();
} else {
......
......@@ -324,7 +324,7 @@ UMLClassifier *AssociationWidget::operationOwner()
*/
UMLOperation *AssociationWidget::operation()
{
return dynamic_cast<UMLOperation*>(m_umlObject.data());
return m_umlObject->asUMLOperation();
}
/**
......@@ -567,7 +567,7 @@ UMLAssociation* AssociationWidget::association() const
{
if (m_umlObject == NULL || m_umlObject->baseType() != UMLObject::ot_Association)
return NULL;
return dynamic_cast<UMLAssociation*>(m_umlObject.data());
return m_umlObject->asUMLAssociation();
}
/**
......@@ -583,7 +583,7 @@ UMLAttribute* AssociationWidget::attribute() const
UMLObject::ObjectType ot = m_umlObject->baseType();
if (ot != UMLObject::ot_Attribute && ot != UMLObject::ot_EntityAttribute)
return NULL;
return dynamic_cast<UMLAttribute*>(m_umlObject.data());
return m_umlObject->asUMLAttribute();
}
#if 0 //:TODO:
......@@ -1039,7 +1039,7 @@ QString AssociationWidget::roleDocumentation(Uml::RoleType::Enum role) const
{
if (m_umlObject == NULL || m_umlObject->baseType() != UMLObject::ot_Association)
return QString();
UMLAssociation *umla = dynamic_cast<UMLAssociation*>(m_umlObject.data());
UMLAssociation *umla = m_umlObject->asUMLAssociation();
return umla->getRoleDoc(role);
}
......@@ -1157,7 +1157,7 @@ Uml::Changeability::Enum AssociationWidget::changeability(Uml::RoleType::Enum ro
{
if (m_umlObject == NULL || m_umlObject->baseType() != UMLObject::ot_Association)
return m_role[role].changeability;
UMLAssociation *umla = dynamic_cast<UMLAssociation*>(m_umlObject.data());
UMLAssociation *umla = m_umlObject->asUMLAssociation();
return umla->changeability(role);
}
......@@ -1462,7 +1462,7 @@ Uml::AssociationType::Enum AssociationWidget::associationType() const
{
if (m_umlObject == NULL || m_umlObject->baseType() != UMLObject::ot_Association)
return m_associationType;
UMLAssociation *umla = dynamic_cast<UMLAssociation*>(m_umlObject.data());
UMLAssociation *umla = m_umlObject->asUMLAssociation();
return umla->getAssocType();
}
......@@ -1511,7 +1511,7 @@ Uml::ID::Type AssociationWidget::widgetIDForRole(Uml::RoleType::Enum role) const
{
if (m_role[role].umlWidget == NULL) {
if (m_umlObject && m_umlObject->baseType() == UMLObject::ot_Association) {
UMLAssociation *umla = dynamic_cast<UMLAssociation*>(m_umlObject.data());
UMLAssociation *umla = m_umlObject->asUMLAssociation();
return umla->getObjectId(role);
}
uError() << "umlWidget is NULL";
......@@ -1530,7 +1530,7 @@ Uml::ID::Type AssociationWidget::widgetLocalIDForRole(Uml::RoleType::Enum role)
{
if (m_role[role].umlWidget == NULL) {
if (m_umlObject && m_umlObject->baseType() == UMLObject::ot_Association) {
UMLAssociation *umla = dynamic_cast<UMLAssociation*>(m_umlObject.data());
UMLAssociation *umla = m_umlObject->asUMLAssociation();
return umla->getObjectId(role);
}
uError() << "umlWidget is NULL";
......
......@@ -70,7 +70,7 @@ void CategoryWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
painter->setPen(textColor());
QString letterType(QLatin1Char('D'));
switch(dynamic_cast<UMLCategory*>(m_umlObject.data())->getType()) {
switch(m_umlObject->asUMLCategory()->getType()) {
case UMLCategory::ct_Disjoint_Specialisation:
letterType = QLatin1Char('D');
break;
......
......@@ -137,7 +137,7 @@ ClassifierWidget::~ClassifierWidget()
*/
UMLClassifier *ClassifierWidget::classifier() const
{
return dynamic_cast<UMLClassifier*>(m_umlObject.data());
return m_umlObject->asUMLClassifier();
}
/**
......
......@@ -55,7 +55,7 @@ void ComponentWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
Q_UNUSED(option);
Q_UNUSED(widget);
UMLComponent *umlcomp = dynamic_cast<UMLComponent*>(m_umlObject.data());
UMLComponent *umlcomp = m_umlObject->asUMLComponent();
if (umlcomp == NULL)
return;
setPenFromSettings(painter);
......@@ -146,7 +146,7 @@ void ComponentWidget::adjustAssocs(qreal dx, qreal dy)
return;
}
UMLWidget::adjustAssocs(dx, dy);
UMLPackage *comp = dynamic_cast<UMLPackage*>(m_umlObject.data());
UMLPackage *comp = m_umlObject->asUMLPackage();
foreach (UMLObject *o, comp->containedObjects()) {
uIgnoreZeroPointer(o);
if (o->baseType() != UMLObject::ot_Port)
......@@ -196,7 +196,7 @@ QSizeF ComponentWidget::minimumSize() const
int height = (2*fontHeight) + (COMPONENT_MARGIN * 3);
UMLComponent *umlcomp = dynamic_cast<UMLComponent*>(m_umlObject.data());
UMLComponent *umlcomp = m_umlObject->asUMLComponent();
if (umlcomp && umlcomp->getExecutable()) {
width += 2;
height += 2;
......
......@@ -103,7 +103,7 @@ void EntityWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
painter->drawLine(0, y, w, y);
QFontMetrics fontMetrics(font);
UMLClassifier *classifier = dynamic_cast<UMLClassifier*>(m_umlObject.data());
UMLClassifier *classifier = m_umlObject->asUMLClassifier();
UMLClassifierListItem* entityattribute = 0;
UMLClassifierListItemList list = classifier->getFilteredList(UMLObject::ot_EntityAttribute);
foreach (entityattribute, list) {
......@@ -146,7 +146,7 @@ void EntityWidget::slotMenuSelection(QAction* action)
ListPopupMenu::MenuType sel = ListPopupMenu::typeFromAction(action);
switch(sel) {
case ListPopupMenu::mt_EntityAttribute:
if (Object_Factory::createChildObject(dynamic_cast<UMLClassifier*>(m_umlObject.data()),
if (Object_Factory::createChildObject(m_umlObject->asUMLClassifier(),
UMLObject::ot_EntityAttribute)) {
UMLApp::app()->document()->setModified();
}
......@@ -154,19 +154,19 @@ void EntityWidget::slotMenuSelection(QAction* action)
case ListPopupMenu::mt_PrimaryKeyConstraint:
case ListPopupMenu::mt_UniqueConstraint:
if (UMLObject* obj = Object_Factory::createChildObject(dynamic_cast<UMLEntity*>(m_umlObject.data()),
if (UMLObject* obj = Object_Factory::createChildObject(m_umlObject->asUMLEntity(),
UMLObject::ot_UniqueConstraint)) {
UMLApp::app()->document()->setModified();
if (sel == ListPopupMenu::mt_PrimaryKeyConstraint) {
UMLUniqueConstraint* uc = obj->asUMLUniqueConstraint();
dynamic_cast<UMLEntity*>(m_umlObject.data())->setAsPrimaryKey(uc);
m_umlObject->asUMLEntity()->setAsPrimaryKey(uc);
}
}
break;
case ListPopupMenu::mt_ForeignKeyConstraint:
if (Object_Factory::createChildObject(dynamic_cast<UMLEntity*>(m_umlObject.data()),
if (Object_Factory::createChildObject(m_umlObject->asUMLEntity(),
UMLObject::ot_ForeignKeyConstraint)) {
UMLApp::app()->document()->setModified();
......@@ -174,7 +174,7 @@ void EntityWidget::slotMenuSelection(QAction* action)
break;
case ListPopupMenu::mt_CheckConstraint:
if (Object_Factory::createChildObject(dynamic_cast<UMLEntity*>(m_umlObject.data()),
if (Object_Factory::createChildObject(m_umlObject->asUMLEntity(),
UMLObject::ot_CheckConstraint)) {
UMLApp::app()->document()->setModified();
......@@ -209,7 +209,7 @@ QSizeF EntityWidget::minimumSize() const
lines++;
}
const int numberOfEntityAttributes = dynamic_cast<UMLEntity*>(m_umlObject.data())->entityAttributes();
const int numberOfEntityAttributes = m_umlObject->asUMLEntity()->entityAttributes();
height = width = 0;
//set the height of the entity
......@@ -231,7 +231,7 @@ QSizeF EntityWidget::minimumSize() const
width = w > width ? w : width;
UMLClassifier* classifier = dynamic_cast<UMLClassifier*>(m_umlObject.data());
UMLClassifier* classifier = m_umlObject->asUMLClassifier();
UMLClassifierListItemList list = classifier->getFilteredList(UMLObject::ot_EntityAttribute);
UMLClassifierListItem* listItem = 0;
foreach (listItem, list) {
......
......@@ -138,7 +138,7 @@ void EnumWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
painter->drawLine(0, y, w, y);
QFontMetrics fontMetrics(font);
UMLClassifier *classifier = dynamic_cast<UMLClassifier*>(m_umlObject.data());
UMLClassifier *classifier = m_umlObject->asUMLClassifier();
UMLClassifierListItem* enumLiteral = 0;
UMLClassifierListItemList list = classifier->getFilteredList(UMLObject::ot_EnumLiteral);
foreach (enumLiteral, list) {
......@@ -189,7 +189,7 @@ void EnumWidget::slotMenuSelection(QAction* action)
{
ListPopupMenu::MenuType sel = ListPopupMenu::typeFromAction(action);
if (sel == ListPopupMenu::mt_EnumLiteral) {
if (Object_Factory::createChildObject(dynamic_cast<UMLClassifier*>(m_umlObject.data()),
if (Object_Factory::createChildObject(m_umlObject->asUMLClassifier(),
UMLObject::ot_EnumLiteral)) {
/* I don't know why it works without these calls:
updateComponentSize();
......@@ -223,7 +223,7 @@ QSizeF EnumWidget::minimumSize() const
int lines = 1;//always have one line - for name
lines++; //for the stereotype
const int numberOfEnumLiterals = dynamic_cast<UMLEnum*>(m_umlObject.data())->enumLiterals();
const int numberOfEnumLiterals = m_umlObject->asUMLEnum()->enumLiterals();
height = width = 0;
//set the height of the enum
......@@ -247,7 +247,7 @@ QSizeF EnumWidget::minimumSize() const
width = w > width?w:width;
UMLClassifier *classifier = dynamic_cast<UMLClassifier*>(m_umlObject.data());
UMLClassifier *classifier = m_umlObject->asUMLClassifier();
UMLClassifierListItemList list = classifier->getFilteredList(UMLObject::ot_EnumLiteral);
UMLClassifierListItem* listItem = 0;
foreach (listItem, list) {
......
......@@ -936,7 +936,7 @@ UMLClassifier *MessageWidget::operationOwner()
*/
UMLOperation *MessageWidget::operation()
{
return dynamic_cast<UMLOperation*>(m_umlObject.data());
return m_umlObject->asUMLOperation();
}
/**
......
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