summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2016-09-05 10:59:43 (GMT)
committerRalf Habacker <ralf.habacker@freenet.de>2016-09-06 14:59:15 (GMT)
commita5f92b67494666e4e6779b1f2443b1a1df2b031d (patch)
tree9c6bd102ce28b7669fe9eebd6c37457076476535
parent668c6ad4e493b80d1a8537a840632f98368ba579 (diff)
Convert casts in UML model classes to use related casting methods.
CCBUG:368282 Reviewed-by: aaron.nottbeck at sag.eu
-rw-r--r--umbrello/clipboard/umlclipboard.cpp14
-rw-r--r--umbrello/clipboard/umldragdata.cpp2
-rw-r--r--umbrello/codegenerators/ada/adawriter.cpp4
-rw-r--r--umbrello/codegenerators/advancedcodegenerator.cpp4
-rw-r--r--umbrello/codegenerators/classifiercodedocument.cpp2
-rw-r--r--umbrello/codegenerators/codeclassfield.cpp14
-rw-r--r--umbrello/codegenerators/codeclassfielddeclarationblock.cpp2
-rw-r--r--umbrello/codegenerators/codedocument.cpp4
-rw-r--r--umbrello/codegenerators/codegenerator.cpp6
-rw-r--r--umbrello/codegenerators/codegenobjectwithtextblocks.cpp2
-rw-r--r--umbrello/codegenerators/codeoperation.cpp4
-rw-r--r--umbrello/codegenerators/codeparameter.cpp6
-rw-r--r--umbrello/codegenerators/cpp/cppcodeclassfield.cpp2
-rw-r--r--umbrello/codegenerators/cpp/cppcodegenerator.cpp4
-rw-r--r--umbrello/codegenerators/cpp/cppheadercodedocument.cpp4
-rw-r--r--umbrello/codegenerators/csharp/csharpwriter.cpp2
-rw-r--r--umbrello/codegenerators/d/dclassifiercodedocument.cpp2
-rw-r--r--umbrello/codegenerators/d/dcodeclassfield.cpp2
-rw-r--r--umbrello/codegenerators/java/javaantcodedocument.cpp2
-rw-r--r--umbrello/codegenerators/java/javaclassifiercodedocument.cpp2
-rw-r--r--umbrello/codegenerators/java/javacodeclassfield.cpp2
-rw-r--r--umbrello/codegenerators/ownedcodeblock.cpp4
-rw-r--r--umbrello/codegenerators/ownedhierarchicalcodeblock.cpp2
-rw-r--r--umbrello/codegenerators/pascal/pascalwriter.cpp4
-rw-r--r--umbrello/codegenerators/ruby/rubyclassifiercodedocument.cpp2
-rw-r--r--umbrello/codegenerators/ruby/rubycodeclassfield.cpp2
-rw-r--r--umbrello/codegenerators/sql/mysqlwriter.cpp2
-rw-r--r--umbrello/codegenerators/sql/sqlwriter.cpp8
-rw-r--r--umbrello/codegenerators/vala/valawriter.cpp2
-rw-r--r--umbrello/codegenerators/xml/xmlschemawriter.cpp2
-rw-r--r--umbrello/codeimport/adaimport.cpp20
-rw-r--r--umbrello/codeimport/csharp/csharpimport.cpp14
-rw-r--r--umbrello/codeimport/idlimport.cpp14
-rw-r--r--umbrello/codeimport/import_utils.cpp16
-rw-r--r--umbrello/codeimport/javaimport.cpp18
-rw-r--r--umbrello/codeimport/kdevcppparser/cpptree2uml.cpp10
-rw-r--r--umbrello/codeimport/pascalimport.cpp12
-rw-r--r--umbrello/codeimport/pythonimport.cpp6
-rw-r--r--umbrello/codeimport/sqlimport.cpp12
-rw-r--r--umbrello/dialogs/codeeditor.cpp14
-rw-r--r--umbrello/dialogs/pages/classgeneralpage.cpp8
-rw-r--r--umbrello/dialogs/pages/classifierlistpage.cpp22
-rw-r--r--umbrello/dialogs/pages/constraintlistpage.cpp4
-rw-r--r--umbrello/dialogs/umlattributedialog.cpp2
-rw-r--r--umbrello/dialogs/umlforeignkeyconstraintdialog.cpp8
-rw-r--r--umbrello/dialogs/umloperationdialog.cpp2
-rw-r--r--umbrello/dialogs/umluniqueconstraintdialog.cpp2
-rw-r--r--umbrello/dialogs/widgets/umldatatypewidget.cpp12
-rw-r--r--umbrello/dialogs/widgets/umlpackagewidget.cpp2
-rw-r--r--umbrello/docwindow.cpp2
-rw-r--r--umbrello/finder/umllistviewfinder.cpp2
-rw-r--r--umbrello/listpopupmenu.cpp11
-rw-r--r--umbrello/model_utils.cpp28
-rw-r--r--umbrello/object_factory.cpp18
-rw-r--r--umbrello/petaltree2uml.cpp24
-rw-r--r--umbrello/refactoring/refactoringassistant.cpp50
-rw-r--r--umbrello/stereotypeswindow.cpp2
-rw-r--r--umbrello/umldoc.cpp40
-rw-r--r--umbrello/umllistview.cpp63
-rw-r--r--umbrello/umllistviewitem.cpp24
-rw-r--r--umbrello/umlmodel/association.cpp2
-rw-r--r--umbrello/umlmodel/attribute.cpp16
-rw-r--r--umbrello/umlmodel/category.cpp2
-rw-r--r--umbrello/umlmodel/checkconstraint.cpp4
-rw-r--r--umbrello/umlmodel/classifier.cpp34
-rw-r--r--umbrello/umlmodel/classifierlistitem.cpp4
-rw-r--r--umbrello/umlmodel/entity.cpp10
-rw-r--r--umbrello/umlmodel/entityattribute.cpp2
-rw-r--r--umbrello/umlmodel/enumliteral.cpp2
-rw-r--r--umbrello/umlmodel/folder.cpp10
-rw-r--r--umbrello/umlmodel/foreignkeyconstraint.cpp18
-rw-r--r--umbrello/umlmodel/operation.cpp6
-rw-r--r--umbrello/umlmodel/package.cpp30
-rw-r--r--umbrello/umlmodel/umlcanvasobject.cpp10
-rw-r--r--umbrello/umlmodel/umlobject.cpp1
-rw-r--r--umbrello/umlmodel/umlobject.h2
-rw-r--r--umbrello/umlmodel/umlrole.cpp2
-rw-r--r--umbrello/umlmodel/uniqueconstraint.cpp12
-rw-r--r--umbrello/umlscene.cpp30
-rw-r--r--umbrello/umlwidgets/associationwidget.cpp14
-rw-r--r--umbrello/umlwidgets/categorywidget.cpp2
-rw-r--r--umbrello/umlwidgets/entitywidget.cpp4
-rw-r--r--umbrello/umlwidgets/floatingtextwidget.cpp4
-rw-r--r--umbrello/umlwidgets/messagewidget.cpp4
-rw-r--r--umbrello/umlwidgets/toolbarstateonewidget.cpp2
-rw-r--r--umbrello/umlwidgets/widget_factory.cpp54
-rw-r--r--umbrello/umlwidgets/widgetbase.cpp6
87 files changed, 437 insertions, 426 deletions
diff --git a/umbrello/clipboard/umlclipboard.cpp b/umbrello/clipboard/umlclipboard.cpp
index 066e10a..9dafe14 100644
--- a/umbrello/clipboard/umlclipboard.cpp
+++ b/umbrello/clipboard/umlclipboard.cpp
@@ -637,7 +637,7 @@ bool UMLClipboard::pasteClip5(const QMimeData* data)
QString newName = parent->uniqChildName(UMLObject::ot_Attribute, obj->name());
obj->setName(newName);
}
- UMLAttribute *att = static_cast<UMLAttribute*>(obj);
+ UMLAttribute *att = obj->asUMLAttribute();
if (parent->addAttribute(att, idchanges)) {
result = true;
} else {
@@ -648,7 +648,7 @@ bool UMLClipboard::pasteClip5(const QMimeData* data)
}
case UMLObject::ot_Operation :
{
- UMLOperation *op = static_cast<UMLOperation*>(obj);
+ UMLOperation *op = obj->asUMLOperation();
UMLOperation *exist = parent->checkOperationSignature(op->name(), op->getParmList());
if (exist) {
QString newName = parent->uniqChildName(UMLObject::ot_Operation, obj->name());
@@ -664,7 +664,7 @@ bool UMLClipboard::pasteClip5(const QMimeData* data)
}
case UMLObject::ot_Template:
{
- UMLTemplate* tp = static_cast<UMLTemplate*>(obj);
+ UMLTemplate* tp = obj->asUMLTemplate();
UMLTemplate* exist = parent->findTemplate(tp->name());
if (exist) {
QString newName = parent->uniqChildName(UMLObject::ot_Template, obj->name());
@@ -680,7 +680,7 @@ bool UMLClipboard::pasteClip5(const QMimeData* data)
}
case UMLObject::ot_EnumLiteral:
{
- UMLEnum* enumParent = dynamic_cast<UMLEnum*>(parent);
+ UMLEnum* enumParent = parent->asUMLEnum();
// if parent is not a UMLEnum, bail out immediately;
if (!enumParent) {
result = false;
@@ -693,7 +693,7 @@ bool UMLClipboard::pasteClip5(const QMimeData* data)
QString newName = enumParent->uniqChildName(UMLObject::ot_EnumLiteral, obj->name());
obj->setName(newName);
}
- UMLEnumLiteral* enl = static_cast<UMLEnumLiteral*>(obj);
+ UMLEnumLiteral* enl = obj->asUMLEnumLiteral();
if (enumParent->addEnumLiteral(enl, idchanges)) {
result = true;
@@ -705,7 +705,7 @@ bool UMLClipboard::pasteClip5(const QMimeData* data)
}
case UMLObject::ot_EntityAttribute :
{
- UMLEntity* entityParent = dynamic_cast<UMLEntity*>(parent);
+ UMLEntity* entityParent = parent->asUMLEntity();
// if parent is not a UMLEntity, bail out immediately;
if (!entityParent) {
result = false;
@@ -717,7 +717,7 @@ bool UMLClipboard::pasteClip5(const QMimeData* data)
QString newName = entityParent->uniqChildName(UMLObject::ot_EntityAttribute, obj->name());
obj->setName(newName);
}
- UMLEntityAttribute *att = static_cast<UMLEntityAttribute*>(obj);
+ UMLEntityAttribute *att = obj->asUMLEntityAttribute();
if (entityParent->addEntityAttribute(att, idchanges)) {
result = true;
diff --git a/umbrello/clipboard/umldragdata.cpp b/umbrello/clipboard/umldragdata.cpp
index cd4ce4f..f51054f 100644
--- a/umbrello/clipboard/umldragdata.cpp
+++ b/umbrello/clipboard/umldragdata.cpp
@@ -846,7 +846,7 @@ bool UMLDragData::decodeViews(QDomNode& umlviewsNode, UMLViewList& diagrams)
uError() << "Bad parent for view.";
return false;
}
- UMLFolder *f = static_cast<UMLFolder*>(po);
+ UMLFolder *f = po->asUMLFolder();
UMLView* view = new UMLView(f);
view->umlScene()->loadFromXMI(diagramElement);
diagrams.append(view);
diff --git a/umbrello/codegenerators/ada/adawriter.cpp b/umbrello/codegenerators/ada/adawriter.cpp
index ea3dffa..28e6355 100644
--- a/umbrello/codegenerators/ada/adawriter.cpp
+++ b/umbrello/codegenerators/ada/adawriter.cpp
@@ -122,7 +122,7 @@ QString AdaWriter::packageName(UMLPackage *p)
if (umlPkg == UMLApp::app()->document()->rootFolder(Uml::ModelType::Logical))
umlPkg = NULL;
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(p);
+ UMLClassifier *c = p->asUMLClassifier();
if (umlPkg == NULL) {
retval = className;
if (c == NULL || !isOOClass(c))
@@ -309,7 +309,7 @@ void AdaWriter::writeClass(UMLClassifier *c)
}
if (c->baseType() == UMLObject::ot_Enum) {
- UMLEnum *ue = static_cast<UMLEnum*>(c);
+ UMLEnum *ue = c->asUMLEnum();
UMLClassifierListItemList litList = ue->getFilteredList(UMLObject::ot_EnumLiteral);
uint i = 0;
ada << indent() << "type " << classname << " is (" << m_endl;
diff --git a/umbrello/codegenerators/advancedcodegenerator.cpp b/umbrello/codegenerators/advancedcodegenerator.cpp
index 87121f8..ab78313 100644
--- a/umbrello/codegenerators/advancedcodegenerator.cpp
+++ b/umbrello/codegenerators/advancedcodegenerator.cpp
@@ -49,7 +49,7 @@ void AdvancedCodeGenerator::checkAddUMLObject(UMLObject * obj)
return;
}
- UMLClassifier * c = dynamic_cast<UMLClassifier*>(obj);
+ UMLClassifier * c = obj->asUMLClassifier();
if (c) {
CodeDocument * cDoc = newClassifierCodeDocument(c);
addCodeDocument(cDoc);
@@ -65,7 +65,7 @@ void AdvancedCodeGenerator::checkRemoveUMLObject(UMLObject * obj)
return;
}
- UMLClassifier * c = dynamic_cast<UMLClassifier*>(obj);
+ UMLClassifier * c = obj->asUMLClassifier();
if (c) {
ClassifierCodeDocument * cDoc = (ClassifierCodeDocument*) findCodeDocumentByClassifier(c);
if (cDoc) {
diff --git a/umbrello/codegenerators/classifiercodedocument.cpp b/umbrello/codegenerators/classifiercodedocument.cpp
index 173d208..28ee42d 100644
--- a/umbrello/codegenerators/classifiercodedocument.cpp
+++ b/umbrello/codegenerators/classifiercodedocument.cpp
@@ -301,7 +301,7 @@ QList<CodeOperation*> ClassifierCodeDocument::getCodeOperations ()
*/
void ClassifierCodeDocument::addOperation (UMLClassifierListItem * o)
{
- UMLOperation *op = dynamic_cast<UMLOperation*>(o);
+ UMLOperation *op = o->asUMLOperation();
if (op == NULL) {
uError() << "arg is not a UMLOperation";
return;
diff --git a/umbrello/codegenerators/codeclassfield.cpp b/umbrello/codegenerators/codeclassfield.cpp
index 77287ff..48a2a8f 100644
--- a/umbrello/codegenerators/codeclassfield.cpp
+++ b/umbrello/codegenerators/codeclassfield.cpp
@@ -73,7 +73,7 @@ CodeClassField::~CodeClassField ()
*/
void CodeClassField::setParentUMLObject (UMLObject * obj)
{
- UMLRole *role = dynamic_cast<UMLRole*>(obj);
+ UMLRole *role = obj->asUMLRole();
if(role) {
UMLAssociation * parentAssoc = role->parentAssociation();
Uml::AssociationType::Enum atype = parentAssoc->getAssocType();
@@ -113,7 +113,7 @@ QString CodeClassField::getListObjectType()
{
if (!parentIsAttribute())
{
- UMLRole * role = dynamic_cast<UMLRole*>(getParentObject());
+ UMLRole * role = getParentObject()->asUMLRole();
if (role)
return getUMLObjectName(role->object());
}
@@ -330,7 +330,7 @@ int CodeClassField::minimumListOccurances()
{
if (!parentIsAttribute())
{
- UMLRole * role = dynamic_cast<UMLRole*>(getParentObject());
+ UMLRole * role = getParentObject()->asUMLRole();
if (!role) {
uError() << "no valid parent object";
return -1;
@@ -358,7 +358,7 @@ int CodeClassField::maximumListOccurances()
{
if (!parentIsAttribute())
{
- UMLRole * role = dynamic_cast<UMLRole*>(getParentObject());
+ UMLRole * role = getParentObject()->asUMLRole();
if (!role) {
uError() << "no valid parent object";
return -1;
@@ -527,7 +527,9 @@ void CodeClassField::updateContent()
method->setWriteOutText(m_writeOutMethods);
return;
}
- UMLRole * role = dynamic_cast<UMLRole*>(getParentObject());
+ UMLRole * role = getParentObject()->asUMLRole();
+ if (!role)
+ return;
Uml::Changeability::Enum changeType = role->changeability();
bool isSingleValue = fieldIsSingleValue();
bool isEmptyRole = role->name().isEmpty() ? true : false;
@@ -620,7 +622,7 @@ bool CodeClassField::fieldIsSingleValue ()
if(parentIsAttribute())
return true;
- UMLRole * role = dynamic_cast<UMLRole*>(getParentObject());
+ UMLRole * role = getParentObject()->asUMLRole();
if(!role)
return true; // it is really an attribute
diff --git a/umbrello/codegenerators/codeclassfielddeclarationblock.cpp b/umbrello/codegenerators/codeclassfielddeclarationblock.cpp
index ac7cc08..28c5eb6 100644
--- a/umbrello/codegenerators/codeclassfielddeclarationblock.cpp
+++ b/umbrello/codegenerators/codeclassfielddeclarationblock.cpp
@@ -139,7 +139,7 @@ void CodeClassFieldDeclarationBlock::syncToParent ()
// the name of the role is not defined.
if (!(getParentClassField()->parentIsAttribute()))
{
- UMLRole * parent = dynamic_cast<UMLRole*>(getParentObject());
+ UMLRole * parent = getParentObject()->asUMLRole();
if (parent == NULL)
return;
if (parent->name().isEmpty())
diff --git a/umbrello/codegenerators/codedocument.cpp b/umbrello/codegenerators/codedocument.cpp
index 52124ed..833860f 100644
--- a/umbrello/codegenerators/codedocument.cpp
+++ b/umbrello/codegenerators/codedocument.cpp
@@ -397,11 +397,11 @@ void CodeDocument::setAttributesFromNode (QDomElement & root)
// suspecting pre-1.5.3 file format where the package name was
// saved instead of the package ID.
UMLObject *o = umldoc->findUMLObject(pkgStr);
- m_package = dynamic_cast<UMLPackage*>(o);
+ m_package = o->asUMLPackage();
}
if (m_package == NULL) {
UMLObject *o = umldoc->findObjectById(Uml::ID::fromString(pkgStr));
- m_package = dynamic_cast<UMLPackage*>(o);
+ m_package = o->asUMLPackage();
}
}
const QString trueStr = QLatin1String("true");
diff --git a/umbrello/codegenerators/codegenerator.cpp b/umbrello/codegenerators/codegenerator.cpp
index 7592b9d..9414a6e 100644
--- a/umbrello/codegenerators/codegenerator.cpp
+++ b/umbrello/codegenerators/codegenerator.cpp
@@ -227,7 +227,7 @@ void CodeGenerator::loadCodeForOperation(const QString& idStr, const QDomElement
UMLObject::ObjectType t = obj->baseType();
if (t == UMLObject::ot_Operation) {
- UMLOperation *op = static_cast<UMLOperation*>(obj);
+ UMLOperation *op = obj->asUMLOperation();
op->setSourceCode(value);
}
else {
@@ -642,7 +642,7 @@ void CodeGenerator::findObjectsRelated(UMLClassifier *c, UMLPackageList &cList)
UMLObject *objA = a->getObject(Uml::RoleType::A);
UMLObject *objB = a->getObject(Uml::RoleType::B);
if (objA == c) {
- temp = static_cast<UMLPackage*>(objB);
+ temp = objB->asUMLPackage();
}
}
break;
@@ -653,7 +653,7 @@ void CodeGenerator::findObjectsRelated(UMLClassifier *c, UMLPackageList &cList)
UMLObject *objA = a->getObject(Uml::RoleType::A);
UMLObject *objB = a->getObject(Uml::RoleType::B);
if (objA == c && objB->baseType() != UMLObject::ot_Datatype) {
- temp = static_cast<UMLPackage*>(objB);
+ temp = objB->asUMLPackage();
}
}
break;
diff --git a/umbrello/codegenerators/codegenobjectwithtextblocks.cpp b/umbrello/codegenerators/codegenobjectwithtextblocks.cpp
index 6c12d84..6e163a9 100644
--- a/umbrello/codegenerators/codegenobjectwithtextblocks.cpp
+++ b/umbrello/codegenerators/codegenobjectwithtextblocks.cpp
@@ -465,7 +465,7 @@ void CodeGenObjectWithTextBlocks::loadChildTextBlocksFromNode (QDomElement & roo
// find the code operation by id
QString id = element.attribute(QLatin1String("parent_id"), QLatin1String("-1"));
UMLObject * obj = UMLApp::app()->document()->findObjectById(Uml::ID::fromString(id));
- UMLOperation * op = dynamic_cast<UMLOperation*>(obj);
+ UMLOperation * op = obj->asUMLOperation();
if (op) {
CodeOperation * block = CodeGenFactory::newCodeOperation(dynamic_cast<ClassifierCodeDocument*>(m_pCodeDoc), op);
block->loadFromXMI(element);
diff --git a/umbrello/codegenerators/codeoperation.cpp b/umbrello/codegenerators/codeoperation.cpp
index dccf2f1..c391d70 100644
--- a/umbrello/codegenerators/codeoperation.cpp
+++ b/umbrello/codegenerators/codeoperation.cpp
@@ -63,7 +63,7 @@ QList<CodeParameter*> CodeOperation::getParameterList ()
UMLOperation * CodeOperation::getParentOperation()
{
- return dynamic_cast<UMLOperation*>(getParentObject());
+ return getParentObject()->asUMLOperation();
}
/**
@@ -119,7 +119,7 @@ void CodeOperation::setAttributesFromNode (QDomElement & element)
QString idStr = element.attribute(QLatin1String("parent_id"), QLatin1String("-1"));
Uml::ID::Type id = Uml::ID::fromString(idStr);
UMLObject * obj = UMLApp::app()->document()->findObjectById(id);
- UMLOperation * op = dynamic_cast<UMLOperation*>(obj);
+ UMLOperation * op = obj->asUMLOperation();
if (op)
init(op);
diff --git a/umbrello/codegenerators/codeparameter.cpp b/umbrello/codegenerators/codeparameter.cpp
index 565dadc..c4cdec3 100644
--- a/umbrello/codegenerators/codeparameter.cpp
+++ b/umbrello/codegenerators/codeparameter.cpp
@@ -147,7 +147,7 @@ UMLObject * CodeParameter::getParentObject()
// this is kind of broken for UMLRoles.
QString CodeParameter::ID()
{
- UMLRole * role = dynamic_cast<UMLRole*>(m_parentObject);
+ UMLRole * role = m_parentObject->asUMLRole();
if (role)
{
// cant use Role "ID" as that is used to distinquish if its
@@ -171,7 +171,7 @@ void CodeParameter::setAttributesOnNode(QDomDocument & doc, QDomElement & blockE
// setting ID's takes special treatment
// as UMLRoles arent properly stored in the XMI right now.
// (change would break the XMI format..save for big version change)
- UMLRole * role = dynamic_cast<UMLRole*>(m_parentObject);
+ UMLRole * role = m_parentObject->asUMLRole();
if (role)
blockElement.setAttribute(QLatin1String("role_id"), role->role());
else
@@ -212,7 +212,7 @@ void CodeParameter::setAttributesFromNode(QDomElement & root)
// might ripple throughout the code and cause problems. Thus, since the
// change appears to be needed for only this part, I'll do this crappy
// change instead. -b.t.
- UMLAssociation * assoc = dynamic_cast<UMLAssociation*>(obj);
+ UMLAssociation * assoc = obj->asUMLAssociation();
if (assoc) {
// In this case we init with indicated role child obj.
UMLRole * role = 0;
diff --git a/umbrello/codegenerators/cpp/cppcodeclassfield.cpp b/umbrello/codegenerators/cpp/cppcodeclassfield.cpp
index 61d457e..46b9cf4 100644
--- a/umbrello/codegenerators/cpp/cppcodeclassfield.cpp
+++ b/umbrello/codegenerators/cpp/cppcodeclassfield.cpp
@@ -66,7 +66,7 @@ QString CPPCodeClassField::getInitialValue()
{
if (parentIsAttribute())
{
- UMLAttribute * at = dynamic_cast<UMLAttribute*>(getParentObject());
+ UMLAttribute * at = getParentObject()->asUMLAttribute();
if (at) {
return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
} else {
diff --git a/umbrello/codegenerators/cpp/cppcodegenerator.cpp b/umbrello/codegenerators/cpp/cppcodegenerator.cpp
index f618bc7..d8b8173 100644
--- a/umbrello/codegenerators/cpp/cppcodegenerator.cpp
+++ b/umbrello/codegenerators/cpp/cppcodegenerator.cpp
@@ -348,7 +348,7 @@ void CPPCodeGenerator::checkAddUMLObject(UMLObject * obj)
if (isReservedKeyword(obj->name()))
return;
- UMLClassifier * c = dynamic_cast<UMLClassifier*>(obj);
+ UMLClassifier * c = obj->asUMLClassifier();
if(c) {
CodeDocument * cDoc = newClassifierCodeDocument(c);
CPPHeaderCodeDocument * hcodeDoc = newHeaderClassifierCodeDocument(c);
@@ -370,7 +370,7 @@ void CPPCodeGenerator::checkRemoveUMLObject(UMLObject * obj)
if (!obj)
return;
- UMLClassifier * c = dynamic_cast<UMLClassifier*>(obj);
+ UMLClassifier * c = obj->asUMLClassifier();
if(c) {
// source
ClassifierCodeDocument * cDoc = (ClassifierCodeDocument*) findCodeDocumentByClassifier(c);
diff --git a/umbrello/codegenerators/cpp/cppheadercodedocument.cpp b/umbrello/codegenerators/cpp/cppheadercodedocument.cpp
index b3fa6d0..58b1e35 100644
--- a/umbrello/codegenerators/cpp/cppheadercodedocument.cpp
+++ b/umbrello/codegenerators/cpp/cppheadercodedocument.cpp
@@ -160,7 +160,7 @@ void CPPHeaderCodeDocument::loadChildTextBlocksFromNode (QDomElement & root)
// find the code operation by id
QString id = element.attribute(QLatin1String("parent_id"),QLatin1String("-1"));
UMLObject * obj = UMLApp::app()->document()->findObjectById(Uml::ID::fromString(id));
- UMLOperation * op = dynamic_cast<UMLOperation*>(obj);
+ UMLOperation * op = obj->asUMLOperation();
if(op) {
CodeOperation * block = new CPPHeaderCodeOperation(this, op);
block->updateMethodDeclaration();
@@ -481,7 +481,7 @@ void CPPHeaderCodeDocument::updateContent()
if (!isInterface) {
QString enumStatement;
QString indent = UMLApp::app()->commonPolicy()->getIndentation();
- UMLEnum* e = dynamic_cast<UMLEnum*>(c);
+ UMLEnum* e = c->asUMLEnum();
if (e) {
enumStatement.append(indent + QLatin1String("enum ") + cppClassName + QLatin1String(" {") + endLine);
diff --git a/umbrello/codegenerators/csharp/csharpwriter.cpp b/umbrello/codegenerators/csharp/csharpwriter.cpp
index 83e1a96..b26d8a8 100644
--- a/umbrello/codegenerators/csharp/csharpwriter.cpp
+++ b/umbrello/codegenerators/csharp/csharpwriter.cpp
@@ -200,7 +200,7 @@ void CSharpWriter::writeClass(UMLClassifier *c)
if (includes.count()) {
foreach (UMLPackage* p, includes) {
- UMLClassifier *cl = dynamic_cast<UMLClassifier*>(p);
+ UMLClassifier *cl = p->asUMLClassifier();
if (cl)
p = cl->umlPackage();
if (p != logicalView && m_seenIncludes.indexOf(p) == -1 && p != container) {
diff --git a/umbrello/codegenerators/d/dclassifiercodedocument.cpp b/umbrello/codegenerators/d/dclassifiercodedocument.cpp
index 76302d5..fd8af7c 100644
--- a/umbrello/codegenerators/d/dclassifiercodedocument.cpp
+++ b/umbrello/codegenerators/d/dclassifiercodedocument.cpp
@@ -202,7 +202,7 @@ void DClassifierCodeDocument::loadChildTextBlocksFromNode(QDomElement & root)
// find the code operation by id
QString id = element.attribute(QLatin1String("parent_id"), QLatin1String("-1"));
UMLObject * obj = UMLApp::app()->document()->findObjectById(Uml::ID::fromString(id));
- UMLOperation * op = dynamic_cast<UMLOperation*>(obj);
+ UMLOperation * op = obj->asUMLOperation();
if (op) {
CodeOperation * block = new DCodeOperation(this, op);
block->loadFromXMI(element);
diff --git a/umbrello/codegenerators/d/dcodeclassfield.cpp b/umbrello/codegenerators/d/dcodeclassfield.cpp
index d6e2e57..81c7185 100644
--- a/umbrello/codegenerators/d/dcodeclassfield.cpp
+++ b/umbrello/codegenerators/d/dcodeclassfield.cpp
@@ -66,7 +66,7 @@ QString DCodeClassField::getInitialValue()
{
if (parentIsAttribute())
{
- UMLAttribute * at = dynamic_cast<UMLAttribute*>(getParentObject());
+ UMLAttribute * at = getParentObject()->asUMLAttribute();
if (at) {
return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
} else {
diff --git a/umbrello/codegenerators/java/javaantcodedocument.cpp b/umbrello/codegenerators/java/javaantcodedocument.cpp
index 2ddc635..1f69b1d 100644
--- a/umbrello/codegenerators/java/javaantcodedocument.cpp
+++ b/umbrello/codegenerators/java/javaantcodedocument.cpp
@@ -127,7 +127,7 @@ void JavaANTCodeDocument::loadChildTextBlocksFromNode (QDomElement & root)
// find the code operation by id
QString id = element.attribute(QLatin1String("parent_id"),QLatin1String("-1"));
UMLObject * obj = UMLApp::app()->document()->findObjectById(Uml::ID::fromString(id));
- UMLOperation * op = dynamic_cast<UMLOperation*>(obj);
+ UMLOperation * op = obj->asUMLOperation();
if (op) {
CodeOperation * block = 0;
uError() << "TODO: implement CodeGenFactory::newCodeOperation() for JavaANTCodeDocument";
diff --git a/umbrello/codegenerators/java/javaclassifiercodedocument.cpp b/umbrello/codegenerators/java/javaclassifiercodedocument.cpp
index 75c5a07..27a168c 100644
--- a/umbrello/codegenerators/java/javaclassifiercodedocument.cpp
+++ b/umbrello/codegenerators/java/javaclassifiercodedocument.cpp
@@ -199,7 +199,7 @@ void JavaClassifierCodeDocument::loadChildTextBlocksFromNode (QDomElement & root
// find the code operation by id
QString id = element.attribute(QLatin1String("parent_id"), QLatin1String("-1"));
UMLObject * obj = UMLApp::app()->document()->findObjectById(Uml::ID::fromString(id));
- UMLOperation * op = dynamic_cast<UMLOperation*>(obj);
+ UMLOperation * op = obj->asUMLOperation();
if (op) {
CodeOperation * block = new JavaCodeOperation(this, op);
block->loadFromXMI(element);
diff --git a/umbrello/codegenerators/java/javacodeclassfield.cpp b/umbrello/codegenerators/java/javacodeclassfield.cpp
index 0db5f74..1cf4802 100644
--- a/umbrello/codegenerators/java/javacodeclassfield.cpp
+++ b/umbrello/codegenerators/java/javacodeclassfield.cpp
@@ -60,7 +60,7 @@ QString JavaCodeClassField::getInitialValue()
{
if (parentIsAttribute())
{
- UMLAttribute * at = dynamic_cast<UMLAttribute*>(getParentObject());
+ UMLAttribute * at = getParentObject()->asUMLAttribute();
if (at) {
return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
} else {
diff --git a/umbrello/codegenerators/ownedcodeblock.cpp b/umbrello/codegenerators/ownedcodeblock.cpp
index ac003e4..1e5ef53 100644
--- a/umbrello/codegenerators/ownedcodeblock.cpp
+++ b/umbrello/codegenerators/ownedcodeblock.cpp
@@ -84,7 +84,7 @@ void OwnedCodeBlock::setAttributesOnNode(QDomDocument& /*doc*/, QDomElement& ele
// setting ID's takes special treatment
// as UMLRoles arent properly stored in the XMI right now.
// (change would break the XMI format..save for big version change)
- UMLRole * role = dynamic_cast<UMLRole*>(m_parentObject);
+ UMLRole * role = m_parentObject->asUMLRole();
if (role) {
elem.setAttribute(QLatin1String("parent_id"), Uml::ID::toString(role->parentAssociation()->id()));
// CAUTION: role_id here is numerically inverted wrt Uml::Role_Type,
@@ -125,7 +125,7 @@ void OwnedCodeBlock::setAttributesFromNode (QDomElement & elem)
// might ripple throughout the code and cause problems. Thus, since the
// change appears to be needed for only this part, I'll do this crappy
// change instead. -b.t.
- UMLAssociation * assoc = dynamic_cast<UMLAssociation*>(obj);
+ UMLAssociation * assoc = obj->asUMLAssociation();
if (assoc) {
// In this case we init with indicated role child obj.
UMLRole * role = 0;
diff --git a/umbrello/codegenerators/ownedhierarchicalcodeblock.cpp b/umbrello/codegenerators/ownedhierarchicalcodeblock.cpp
index d14e82f..6204f83 100644
--- a/umbrello/codegenerators/ownedhierarchicalcodeblock.cpp
+++ b/umbrello/codegenerators/ownedhierarchicalcodeblock.cpp
@@ -66,7 +66,7 @@ void OwnedHierarchicalCodeBlock::setAttributesOnNode(QDomDocument & doc, QDomEle
// setting ID's takes special treatment
// as UMLRoles arent properly stored in the XMI right now.
// (change would break the XMI format..save for big version change)
- UMLRole * role = dynamic_cast<UMLRole*>(getParentObject());
+ UMLRole * role = getParentObject()->asUMLRole();
if(role) {
// see comment on role_id at OwnedCodeBlock::setAttributesOnNode()
elem.setAttribute(QLatin1String("role_id"), (role->role() == Uml::RoleType::A));
diff --git a/umbrello/codegenerators/pascal/pascalwriter.cpp b/umbrello/codegenerators/pascal/pascalwriter.cpp
index 748a46c..08be6ef 100644
--- a/umbrello/codegenerators/pascal/pascalwriter.cpp
+++ b/umbrello/codegenerators/pascal/pascalwriter.cpp
@@ -89,7 +89,7 @@ QString PascalWriter::qualifiedName(UMLPackage *p, bool withType, bool byValue)
if (umlPkg == UMLApp::app()->document()->rootFolder(Uml::ModelType::Logical))
umlPkg = NULL;
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(p);
+ UMLClassifier *c = p->asUMLClassifier();
if (umlPkg == NULL) {
retval = className;
if (c == NULL || !isOOClass(c))
@@ -200,7 +200,7 @@ void PascalWriter::writeClass(UMLClassifier *c)
pas << "type" << m_endl;
m_indentLevel++;
if (c->baseType() == UMLObject::ot_Enum) {
- UMLEnum *ue = static_cast<UMLEnum*>(c);
+ UMLEnum *ue = c->asUMLEnum();
UMLClassifierListItemList litList = ue->getFilteredList(UMLObject::ot_EnumLiteral);
uint i = 0;
pas << indent() << classname << " = (" << m_endl;
diff --git a/umbrello/codegenerators/ruby/rubyclassifiercodedocument.cpp b/umbrello/codegenerators/ruby/rubyclassifiercodedocument.cpp
index 8572753..7e0e012 100644
--- a/umbrello/codegenerators/ruby/rubyclassifiercodedocument.cpp
+++ b/umbrello/codegenerators/ruby/rubyclassifiercodedocument.cpp
@@ -235,7 +235,7 @@ void RubyClassifierCodeDocument::loadChildTextBlocksFromNode(QDomElement & root)
// find the code operation by id
QString id = element.attribute(QLatin1String("parent_id"), QLatin1String("-1"));
UMLObject * obj = UMLApp::app()->document()->findObjectById(Uml::ID::fromString(id));
- UMLOperation * op = dynamic_cast<UMLOperation*>(obj);
+ UMLOperation * op = obj->asUMLOperation();
if (op) {
CodeOperation * block = new RubyCodeOperation(this, op);
block->loadFromXMI(element);
diff --git a/umbrello/codegenerators/ruby/rubycodeclassfield.cpp b/umbrello/codegenerators/ruby/rubycodeclassfield.cpp
index 8846b1e..b2990b6 100644
--- a/umbrello/codegenerators/ruby/rubycodeclassfield.cpp
+++ b/umbrello/codegenerators/ruby/rubycodeclassfield.cpp
@@ -64,7 +64,7 @@ QString RubyCodeClassField::getInitialValue()
{
if (parentIsAttribute())
{
- UMLAttribute * at = dynamic_cast<UMLAttribute*>(getParentObject());
+ UMLAttribute * at = getParentObject()->asUMLAttribute();
if (at) {
return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
} else {
diff --git a/umbrello/codegenerators/sql/mysqlwriter.cpp b/umbrello/codegenerators/sql/mysqlwriter.cpp
index ed9d619..2341971 100644
--- a/umbrello/codegenerators/sql/mysqlwriter.cpp
+++ b/umbrello/codegenerators/sql/mysqlwriter.cpp
@@ -88,7 +88,7 @@ void MySQLWriter::printForeignKeyConstraints(QTextStream& sql, UMLClassifierList
// we need to create an index on the referenced attributes before we can create a foreign key constraint in MySQL
foreach(UMLClassifierListItem* cli, constrList) {
- UMLForeignKeyConstraint* fkc = static_cast<UMLForeignKeyConstraint*>(cli);
+ UMLForeignKeyConstraint* fkc = cli->asUMLForeignKeyConstraint();
QMap<UMLEntityAttribute*, UMLEntityAttribute*> attributeMap = fkc->getEntityAttributePairs();
diff --git a/umbrello/codegenerators/sql/sqlwriter.cpp b/umbrello/codegenerators/sql/sqlwriter.cpp
index db836fa..4baf471 100644
--- a/umbrello/codegenerators/sql/sqlwriter.cpp
+++ b/umbrello/codegenerators/sql/sqlwriter.cpp
@@ -188,7 +188,7 @@ SQLWriter::~SQLWriter()
*/
void SQLWriter::writeClass(UMLClassifier *c)
{
- UMLEntity* e = dynamic_cast<UMLEntity*>(c);
+ UMLEntity* e = c->asUMLEntity();
if (!e) {
uError() << "Invalid cast from" << c->baseTypeStr() << "'" << c->name() << "' to UMLEntity*";
@@ -424,7 +424,7 @@ void SQLWriter::printEntityAttributes(QTextStream& sql, UMLEntityAttributeList e
void SQLWriter::printUniqueConstraints(QTextStream& sql, UMLClassifierListItemList constrList)
{
foreach(UMLClassifierListItem* cli, constrList) {
- UMLUniqueConstraint* uuc = dynamic_cast<UMLUniqueConstraint*>(cli);
+ UMLUniqueConstraint* uuc = cli->asUMLUniqueConstraint();
if (!uuc) {
uError() << "Invalid cast from" << cli->baseTypeStr() << "'" << cli->name() << "' to UMLUniqueConstraint*";
return;
@@ -471,7 +471,7 @@ void SQLWriter::printUniqueConstraints(QTextStream& sql, UMLClassifierListItemLi
void SQLWriter::printForeignKeyConstraints(QTextStream& sql, UMLClassifierListItemList constrList)
{
foreach(UMLClassifierListItem* cli, constrList) {
- UMLForeignKeyConstraint* fkc = dynamic_cast<UMLForeignKeyConstraint*>(cli);
+ UMLForeignKeyConstraint* fkc = cli->asUMLForeignKeyConstraint();
if (!fkc) {
uError() << "Invalid cast from" << cli->baseTypeStr() << "'" << cli->name() << "' to UMLForeignKeyConstraint*";
return;
@@ -598,7 +598,7 @@ void SQLWriter::printAutoIncrements(QTextStream& sql, UMLEntityAttributeList ent
void SQLWriter::printCheckConstraints(QTextStream& sql, UMLClassifierListItemList constrList)
{
foreach(UMLClassifierListItem* cli, constrList) {
- UMLCheckConstraint* chConstr = dynamic_cast<UMLCheckConstraint*>(cli);
+ UMLCheckConstraint* chConstr = cli->asUMLCheckConstraint();
if (!chConstr) {
uError() << "Invalid cast from" << cli->baseTypeStr() << "'" << cli->name() << "' to UMLCheckConstraint*";
return;
diff --git a/umbrello/codegenerators/vala/valawriter.cpp b/umbrello/codegenerators/vala/valawriter.cpp
index 22a48b6..bc8c86a 100644
--- a/umbrello/codegenerators/vala/valawriter.cpp
+++ b/umbrello/codegenerators/vala/valawriter.cpp
@@ -237,7 +237,7 @@ void ValaWriter::writeClass(UMLClassifier *c)
//m_seenIncludes.append(logicalView);
if (includes.count()) {
foreach (UMLPackage* p, includes) {
- UMLClassifier *cl = dynamic_cast<UMLClassifier*>(p);
+ UMLClassifier *cl = p->asUMLClassifier();
if (cl) {
p = cl->umlPackage();
}
diff --git a/umbrello/codegenerators/xml/xmlschemawriter.cpp b/umbrello/codegenerators/xml/xmlschemawriter.cpp
index b4eaa8b..44a8a26 100644
--- a/umbrello/codegenerators/xml/xmlschemawriter.cpp
+++ b/umbrello/codegenerators/xml/xmlschemawriter.cpp
@@ -454,7 +454,7 @@ void XMLSchemaWriter::writeChildObjsInAssociation (UMLClassifier *c,
{
UMLObjectList list = findChildObjsInAssociations (c, assoc);
foreach(UMLObject* obj, list) {
- UMLClassifier * thisClassifier = dynamic_cast<UMLClassifier*>(obj);
+ UMLClassifier * thisClassifier = obj->asUMLClassifier();
if (thisClassifier)
writeClassifier(thisClassifier, xs);
}
diff --git a/umbrello/codeimport/adaimport.cpp b/umbrello/codeimport/adaimport.cpp
index fffe28d..2a064c3 100644
--- a/umbrello/codeimport/adaimport.cpp
+++ b/umbrello/codeimport/adaimport.cpp
@@ -261,7 +261,7 @@ bool AdaImport::parseStmt()
umldoc->addAssociation(assoc);
skipStmt();
} else {
- pushScope(static_cast<UMLPackage*>(ns));
+ pushScope(ns->asUMLPackage());
}
} else if (m_source[m_srcIndex] == QLatin1String("renames")) {
m_renaming[name] = advance();
@@ -328,7 +328,7 @@ bool AdaImport::parseStmt()
// enum type
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Enum,
name, currentScope(), m_comment);
- UMLEnum *enumType = static_cast<UMLEnum*>(ns);
+ UMLEnum *enumType = ns->asUMLEnum();
while ((next = advance()) != QLatin1String(")")) {
Import_Utils::addEnumLiteral(enumType, next, m_comment);
m_comment.clear();
@@ -363,10 +363,10 @@ bool AdaImport::parseStmt()
UMLObject *ns = Import_Utils::createUMLObject(t, name, currentScope(), m_comment);
if (t == UMLObject::ot_Interface) {
while ((next = advance()) == QLatin1String("and")) {
- UMLClassifier *klass = static_cast<UMLClassifier*>(ns);
+ UMLClassifier *klass = ns->asUMLClassifier();
QString base = expand(advance());
UMLObject *p = Import_Utils::createUMLObject(UMLObject::ot_Interface, base, currentScope());
- UMLClassifier *parent = static_cast<UMLClassifier*>(p);
+ UMLClassifier *parent = p->asUMLClassifier();
Import_Utils::createGeneralization(klass, parent);
}
} else {
@@ -380,7 +380,7 @@ bool AdaImport::parseStmt()
ns->setStereotype(QLatin1String("record"));
}
if (next == QLatin1String("record"))
- m_klass = static_cast<UMLClassifier*>(ns);
+ m_klass = ns->asUMLClassifier();
else
skipStmt();
return true;
@@ -401,12 +401,12 @@ bool AdaImport::parseStmt()
t = (known ? known->baseType() : UMLObject::ot_Datatype);
}
UMLObject *ns = Import_Utils::createUMLObject(t, base, NULL);
- UMLClassifier *parent = static_cast<UMLClassifier*>(ns);
+ UMLClassifier *parent = ns->asUMLClassifier();
ns = Import_Utils::createUMLObject(t, name, currentScope(), m_comment);
if (isExtension) {
next = advance();
if (next == QLatin1String("null") || next == QLatin1String("record")) {
- UMLClassifier *klass = static_cast<UMLClassifier*>(ns);
+ UMLClassifier *klass = ns->asUMLClassifier();
Import_Utils::createGeneralization(klass, parent);
if (next == QLatin1String("record")) {
// Set the m_klass for attributes.
@@ -417,7 +417,7 @@ bool AdaImport::parseStmt()
QStringList::Iterator end(baseInterfaces.end());
for (QStringList::Iterator bi(baseInterfaces.begin()); bi != end; ++bi) {
ns = Import_Utils::createUMLObject(t, *bi, currentScope());
- parent = static_cast<UMLClassifier*>(ns);
+ parent = ns->asUMLClassifier();
Import_Utils::createGeneralization(klass, parent);
}
}
@@ -525,7 +525,7 @@ bool AdaImport::parseStmt()
skipStmt(QLatin1String(")"));
break;
}
- klass = static_cast<UMLClassifier*>(type);
+ klass = type->asUMLClassifier();
op = Import_Utils::makeOperation(klass, name);
// The controlling parameter is suppressed.
parNameCount--;
@@ -621,7 +621,7 @@ bool AdaImport::parseStmt()
UMLObject *o = Import_Utils::insertAttribute(m_klass, m_currentAccess, name,
typeName, m_comment);
if (o) {
- UMLAttribute *attr = static_cast<UMLAttribute*>(o);
+ UMLAttribute *attr = o->asUMLAttribute();
attr->setInitialValue(initialValue);
}
skipStmt();
diff --git a/umbrello/codeimport/csharp/csharpimport.cpp b/umbrello/codeimport/csharp/csharpimport.cpp
index 9e70580..5b5e117 100644
--- a/umbrello/codeimport/csharp/csharpimport.cpp
+++ b/umbrello/codeimport/csharp/csharpimport.cpp
@@ -210,7 +210,7 @@ UMLObject* CSharpImport::resolveClass(const QString& className)
QString name = (*it);
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Package,
name, parent);
- current = static_cast<UMLPackage*>(ns);
+ current = ns->asUMLPackage();
parent = current;
} // for
if (isArray) {
@@ -347,7 +347,7 @@ bool CSharpImport::parseStmt()
if (keyword == QLatin1String("}")) {
if (scopeIndex())
- m_klass = dynamic_cast<UMLClassifier*>(popScope());
+ m_klass = popScope()->asUMLClassifier();
else
uError() << "too many }";
return true;
@@ -465,13 +465,13 @@ bool CSharpImport::parseStmt()
if (type) {
Import_Utils::insertAttribute(
m_klass, m_currentAccess, name,
- static_cast<UMLClassifier*>(type), m_comment, m_isStatic);
+ type->asUMLClassifier(), m_comment, m_isStatic);
} else {
Import_Utils::insertAttribute(
m_klass, m_currentAccess, name,
typeName, m_comment, m_isStatic);
}
- // UMLAttribute *attr = static_cast<UMLAttribute*>(o);
+ // UMLAttribute *attr = o->asUMLAttribute();
if (nextToken != QLatin1String(",")) {
// reset the modifiers
m_isStatic = m_isAbstract = false;
@@ -625,7 +625,7 @@ bool CSharpImport::parseEnumDeclaration()
log(QLatin1String("enum ") + name);
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Enum,
name, currentScope(), m_comment);
- UMLEnum *enumType = static_cast<UMLEnum*>(ns);
+ UMLEnum *enumType = ns->asUMLEnum();
skipStmt(QLatin1String("{"));
while (m_srcIndex < m_source.count() - 1 && advance() != QLatin1String("}")) {
QString next = advance();
@@ -691,7 +691,7 @@ bool CSharpImport::parseClassDeclaration(const QString& keyword)
: UMLObject::ot_Interface);
log(keyword + QLatin1Char(' ') + name);
UMLObject *ns = Import_Utils::createUMLObject(ot, name, currentScope(), m_comment);
- pushScope(m_klass = static_cast<UMLClassifier*>(ns));
+ pushScope(m_klass = ns->asUMLClassifier());
m_klass->setStatic(m_isStatic);
m_klass->setVisibilityCmd(m_currentAccess);
// The UMLObject found by createUMLObject might originally have been created as a
@@ -744,7 +744,7 @@ bool CSharpImport::parseClassDeclaration(const QString& keyword)
// create a placeholder
UMLObject *interface = resolveClass(baseName);
if (interface) {
- Import_Utils::createGeneralization(m_klass, static_cast<UMLClassifier*>(interface));
+ Import_Utils::createGeneralization(m_klass, interface->asUMLClassifier());
} else {
uDebug() << "implementing interface " << baseName
<< " is not resolvable. Creating placeholder";
diff --git a/umbrello/codeimport/idlimport.cpp b/umbrello/codeimport/idlimport.cpp
index e9e138d..728ec58 100644
--- a/umbrello/codeimport/idlimport.cpp
+++ b/umbrello/codeimport/idlimport.cpp
@@ -242,7 +242,7 @@ bool IDLImport::parseStmt()
const QString& name = advance();
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Package,
name, currentScope(), m_comment);
- pushScope(static_cast<UMLPackage*>(ns));
+ pushScope(ns->asUMLPackage());
currentScope()->setStereotype(QLatin1String("CORBAModule"));
if (advance() != QLatin1String("{")) {
uError() << "importIDL: unexpected: " << m_source[m_srcIndex];
@@ -254,7 +254,7 @@ bool IDLImport::parseStmt()
const QString& name = advance();
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Class,
name, currentScope(), m_comment);
- m_klass = static_cast<UMLClassifier*>(ns);
+ m_klass = ns->asUMLClassifier();
m_klass->setStereotype(QLatin1String("CORBAInterface"));
m_klass->setAbstract(m_isAbstract);
m_isAbstract = false;
@@ -280,7 +280,7 @@ bool IDLImport::parseStmt()
const QString& name = advance();
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Class,
name, currentScope(), m_comment);
- m_klass = static_cast<UMLClassifier*>(ns);
+ m_klass = ns->asUMLClassifier();
pushScope(m_klass);
if (keyword == QLatin1String("struct"))
m_klass->setStereotype(QLatin1String("CORBAStruct"));
@@ -305,7 +305,7 @@ bool IDLImport::parseStmt()
const QString& name = advance();
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Enum,
name, currentScope(), m_comment);
- UMLEnum *enumType = static_cast<UMLEnum*>(ns);
+ UMLEnum *enumType = ns->asUMLEnum();
m_srcIndex++; // skip name
while (++m_srcIndex < srcLength && m_source[m_srcIndex] != QLatin1String("}")) {
Import_Utils::addEnumLiteral(enumType, m_source[m_srcIndex]);
@@ -342,7 +342,7 @@ bool IDLImport::parseStmt()
const QString& name = advance();
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Class,
name, currentScope(), m_comment);
- m_klass = static_cast<UMLClassifier*>(ns);
+ m_klass = ns->asUMLClassifier();
m_klass->setAbstract(m_isAbstract);
m_isAbstract = false;
if (advance() == QLatin1String(";")) // forward declaration
@@ -387,7 +387,7 @@ bool IDLImport::parseStmt()
}
if (keyword == QLatin1String("}")) {
if (scopeIndex())
- m_klass = dynamic_cast<UMLClassifier*>(popScope());
+ m_klass = popScope()->asUMLClassifier();
else
uError() << "importIDL: too many }";
m_srcIndex++; // skip ';'
@@ -450,7 +450,7 @@ bool IDLImport::parseStmt()
nextToken = advance();
}
UMLObject *o = Import_Utils::insertAttribute(m_klass, m_currentAccess, name, typeName, m_comment);
- UMLAttribute *attr = static_cast<UMLAttribute*>(o);
+ UMLAttribute *attr = o->asUMLAttribute();
if (m_isReadonly) {
attr->setStereotype(QLatin1String("readonly"));
m_isReadonly = false;
diff --git a/umbrello/codeimport/import_utils.cpp b/umbrello/codeimport/import_utils.cpp
index 94b4dff..558adf1 100644
--- a/umbrello/codeimport/import_utils.cpp
+++ b/umbrello/codeimport/import_utils.cpp
@@ -247,7 +247,7 @@ UMLObject *createUMLObject(UMLObject::ObjectType type,
components.pop_front();
o = umldoc->findUMLObject(scopeName, UMLObject::ot_UMLObject, parentPkg);
if (o) {
- parentPkg = static_cast<UMLPackage*>(o);
+ parentPkg = o->asUMLPackage();
continue;
}
o = Object_Factory::createUMLObject(UMLObject::ot_Class, scopeName, parentPkg);
@@ -255,7 +255,7 @@ UMLObject *createUMLObject(UMLObject::ObjectType type,
UMLListViewItem *item = UMLApp::app()->listView()->findUMLObject(o);
if (item)
item->updateObject();
- parentPkg = static_cast<UMLPackage*>(o);
+ parentPkg = o->asUMLPackage();
Model_Utils::treeViewSetCurrentItem(o);
}
// All scope qualified datatypes live in the global scope.
@@ -275,8 +275,8 @@ UMLObject *createUMLObject(UMLObject::ObjectType type,
o = Object_Factory::createUMLObject(UMLObject::ot_Datatype, name,
umldoc->datatypeFolder(),
false); //solicitNewName
- UMLClassifier *dt = static_cast<UMLClassifier*>(o);
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(origType);
+ UMLClassifier *dt = o->asUMLClassifier();
+ UMLClassifier *c = origType->asUMLClassifier();
if (c)
dt->setOriginType(c);
else
@@ -287,7 +287,7 @@ UMLObject *createUMLObject(UMLObject::ObjectType type,
/*
if (isPointer) {
UMLObject *pointerDecl = Object_Factory::createUMLObject(UMLObject::ot_Datatype, type);
- UMLClassifier *dt = static_cast<UMLClassifier*>(pointerDecl);
+ UMLClassifier *dt = pointerDecl->asUMLClassifier();
dt->setOriginType(classifier);
dt->setIsReference();
classifier = dt;
@@ -412,7 +412,7 @@ UMLObject* insertAttribute(UMLClassifier *owner, Uml::Visibility::Enum scope,
bPutAtGlobalScope = false;
}
return insertAttribute (owner, scope, name,
- static_cast<UMLClassifier*>(attrType),
+ attrType->asUMLClassifier(),
comment, isStatic);
}
@@ -575,7 +575,7 @@ UMLObject *createArtifact(const QString& name,
if (o)
return o;
o = Object_Factory::createUMLObject(type, fi.fileName(), componentView, false);
- UMLArtifact *a = static_cast<UMLArtifact*>(o);
+ UMLArtifact *a = o->asUMLArtifact();
a->setDrawAsType(UMLArtifact::file);
a->setDoc(comment);
DEBUG(DBG_SRC) << name << comment;
@@ -593,7 +593,7 @@ UMLObject *createArtifact(const QString& name,
void createGeneralization(UMLClassifier *child, const QString &parentName)
{
UMLObject *parentObj = createUMLObject(UMLObject::ot_Class, parentName);
- UMLClassifier *parent = static_cast<UMLClassifier*>(parentObj);
+ UMLClassifier *parent = parentObj->asUMLClassifier();
createGeneralization(child, parent);
}
diff --git a/umbrello/codeimport/javaimport.cpp b/umbrello/codeimport/javaimport.cpp
index 7367e81..5cd8fa0 100644
--- a/umbrello/codeimport/javaimport.cpp
+++ b/umbrello/codeimport/javaimport.cpp
@@ -224,7 +224,7 @@ UMLObject* JavaImport::resolveClass (const QString& className)
QString name = (*it);
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Package,
name, parent);
- current = static_cast<UMLPackage*>(ns);
+ current = ns->asUMLPackage();
parent = current;
} // for
if (isArray) {
@@ -285,7 +285,7 @@ bool JavaImport::parseStmt()
log(keyword + QLatin1Char(' ') + name);
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Package,
name, currentScope(), m_comment);
- pushScope(static_cast<UMLPackage*>(ns));
+ pushScope(ns->asUMLPackage());
}
if (advance() != QLatin1String(";")) {
uError() << "importJava: unexpected: " << m_source[m_srcIndex];
@@ -299,7 +299,7 @@ bool JavaImport::parseStmt()
: UMLObject::ot_Interface);
log(keyword + QLatin1Char(' ') + name);
UMLObject *ns = Import_Utils::createUMLObject(ot, name, currentScope(), m_comment);
- m_klass = static_cast<UMLClassifier*>(ns);
+ m_klass = ns->asUMLClassifier();
pushScope(m_klass);
m_klass->setStatic(m_isStatic);
m_klass->setVisibilityCmd(m_currentAccess);
@@ -349,7 +349,7 @@ bool JavaImport::parseStmt()
// create a placeholder
UMLObject *parent = resolveClass(baseName);
if (parent) {
- Import_Utils::createGeneralization(m_klass, static_cast<UMLClassifier*>(parent));
+ Import_Utils::createGeneralization(m_klass, parent->asUMLClassifier());
} else {
uDebug() << "importJava parentClass " << baseName
<< " is not resolveable. Creating placeholder";
@@ -364,7 +364,7 @@ bool JavaImport::parseStmt()
// create a placeholder
UMLObject *interface = resolveClass(baseName);
if (interface) {
- Import_Utils::createGeneralization(m_klass, static_cast<UMLClassifier*>(interface));
+ Import_Utils::createGeneralization(m_klass, interface->asUMLClassifier());
} else {
uDebug() << "importJava implementing interface "<< baseName
<<" is not resolvable. Creating placeholder";
@@ -386,7 +386,7 @@ bool JavaImport::parseStmt()
log(keyword + QLatin1Char(' ') + name);
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Enum,
name, currentScope(), m_comment);
- UMLEnum *enumType = static_cast<UMLEnum*>(ns);
+ UMLEnum *enumType = ns->asUMLEnum();
skipStmt(QLatin1String("{"));
while (m_srcIndex < srcLength - 1 && advance() != QLatin1String("}")) {
Import_Utils::addEnumLiteral(enumType, m_source[m_srcIndex]);
@@ -467,7 +467,7 @@ bool JavaImport::parseStmt()
}
if (keyword == QLatin1String("}")) {
if (scopeIndex()) {
- m_klass = dynamic_cast<UMLClassifier*>(popScope());
+ m_klass = popScope()->asUMLClassifier();
}
else
uError() << "importJava: too many }";
@@ -599,13 +599,13 @@ bool JavaImport::parseStmt()
if (type) {
Import_Utils::insertAttribute(
m_klass, m_currentAccess, name,
- static_cast<UMLClassifier*>(type), m_comment, m_isStatic);
+ type->asUMLClassifier(), m_comment, m_isStatic);
} else {
Import_Utils::insertAttribute(
m_klass, m_currentAccess, name,
typeName, m_comment, m_isStatic);
}
- // UMLAttribute *attr = static_cast<UMLAttribute*>(o);
+ // UMLAttribute *attr = o->asUMLAttribute();
if (nextToken != QLatin1String(",")) {
// reset the modifiers
m_isStatic = m_isAbstract = false;
diff --git a/umbrello/codeimport/kdevcppparser/cpptree2uml.cpp b/umbrello/codeimport/kdevcppparser/cpptree2uml.cpp
index 3716bf5..662f1ef 100644
--- a/umbrello/codeimport/kdevcppparser/cpptree2uml.cpp
+++ b/umbrello/codeimport/kdevcppparser/cpptree2uml.cpp
@@ -168,9 +168,9 @@ void CppTree2Uml::parseTypedef(TypedefAST* ast)
UMLObject *typedefObj =
Import_Utils::createUMLObject(UMLObject::ot_Datatype, id,
m_currentNamespace[m_nsCnt]);
- UMLClassifier *dt = static_cast<UMLClassifier*>(typedefObj);
+ UMLClassifier *dt = typedefObj->asUMLClassifier();
dt->setIsReference();
- dt->setOriginType(static_cast<UMLClassifier*>(inner));
+ dt->setOriginType(inner->asUMLClassifier());
} else {
Import_Utils::createUMLObject(UMLObject::ot_Class, id,
m_currentNamespace[m_nsCnt],
@@ -377,7 +377,7 @@ void CppTree2Uml::parseClassSpecifier(ClassSpecifierAST* ast)
m_currentNamespace[m_nsCnt],
ast->comment(), QString(), true);
- UMLClassifier *klass = static_cast<UMLClassifier*>(o);
+ UMLClassifier *klass = o->asUMLClassifier();
flushTemplateParams(klass);
if (ast->baseClause())
parseBaseClause(ast->baseClause(), klass);
@@ -469,7 +469,7 @@ void CppTree2Uml::parseElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST* typeS
m_thread->emitAskQuestion("Soll nach CppTree2Uml::parseElaboratedTypeSpecifier weiter gemacht werden?");
}
#endif
- flushTemplateParams(static_cast<UMLClassifier*>(o));
+ flushTemplateParams(o->asUMLClassifier());
}
void CppTree2Uml::parseDeclaration2(GroupAST* funSpec, GroupAST* storageSpec,
@@ -653,7 +653,7 @@ void CppTree2Uml::parseBaseClause(BaseClauseAST * baseClause, UMLClassifier* kla
m_currentNamespace[m_nsCnt],
baseSpecifier->comment());
Import_Utils::putAtGlobalScope(false);
- Import_Utils::createGeneralization(klass, static_cast<UMLClassifier*>(c));
+ Import_Utils::createGeneralization(klass, c->asUMLClassifier());
}
}
diff --git a/umbrello/codeimport/pascalimport.cpp b/umbrello/codeimport/pascalimport.cpp
index 4f17c61..376df57 100644
--- a/umbrello/codeimport/pascalimport.cpp
+++ b/umbrello/codeimport/pascalimport.cpp
@@ -155,7 +155,7 @@ bool PascalImport::parseStmt()
const QString& name = advance();
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Package, name,
currentScope(), m_comment);
- pushScope(static_cast<UMLPackage*>(ns));
+ pushScope(ns->asUMLPackage());
skipStmt();
return true;
}
@@ -323,7 +323,7 @@ bool PascalImport::parseStmt()
// enum type
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Enum,
name, currentScope(), m_comment);
- UMLEnum *enumType = static_cast<UMLEnum*>(ns);
+ UMLEnum *enumType = ns->asUMLEnum();
while (++m_srcIndex < srcLength && m_source[m_srcIndex] != QLatin1String(")")) {
Import_Utils::addEnumLiteral(enumType, m_source[m_srcIndex]);
if (advance() != QLatin1String(","))
@@ -353,7 +353,7 @@ bool PascalImport::parseStmt()
: UMLObject::ot_Interface);
UMLObject *ns = Import_Utils::createUMLObject(t, name,
currentScope(), m_comment);
- UMLClassifier *klass = static_cast<UMLClassifier*>(ns);
+ UMLClassifier *klass = ns->asUMLClassifier();
m_comment.clear();
QString lookAhead = m_source[m_srcIndex + 1];
if (lookAhead == QLatin1String("(")) {
@@ -361,7 +361,7 @@ bool PascalImport::parseStmt()
do {
QString base = advance();
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Class, base, NULL);
- UMLClassifier *parent = static_cast<UMLClassifier*>(ns);
+ UMLClassifier *parent = ns->asUMLClassifier();
m_comment.clear();
Import_Utils::createGeneralization(klass, parent);
} while (advance() == QLatin1String(","));
@@ -388,7 +388,7 @@ bool PascalImport::parseStmt()
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Class, name,
currentScope(), m_comment);
ns->setStereotype(QLatin1String("record"));
- m_klass = static_cast<UMLClassifier*>(ns);
+ m_klass = ns->asUMLClassifier();
return true;
}
if (keyword == QLatin1String("function") || keyword == QLatin1String("procedure")) {
@@ -432,7 +432,7 @@ bool PascalImport::parseStmt()
}
UMLObject *o = Import_Utils::insertAttribute(m_klass, m_currentAccess, name,
typeName, m_comment);
- UMLAttribute *attr = static_cast<UMLAttribute*>(o);
+ UMLAttribute *attr = o->asUMLAttribute();
attr->setStereotype(stereotype);
attr->setInitialValue(initialValue);
skipStmt();
diff --git a/umbrello/codeimport/pythonimport.cpp b/umbrello/codeimport/pythonimport.cpp
index 03970cf..773df92 100644
--- a/umbrello/codeimport/pythonimport.cpp
+++ b/umbrello/codeimport/pythonimport.cpp
@@ -255,7 +255,7 @@ bool PythonImport::parseAssignmentStmt(const QString keyword)
UMLObject* o = Import_Utils::insertAttribute(m_klass, visibility, variable,
type, m_comment, false);
- UMLAttribute* a = dynamic_cast<UMLAttribute*>(o);
+ UMLAttribute* a = o->asUMLAttribute();
a->setInitialValue(value);
a->setStatic(isStatic);
return true;
@@ -273,7 +273,7 @@ bool PythonImport::parseStmt()
const QString& name = advance();
UMLObject *ns = Import_Utils::createUMLObject(UMLObject::ot_Class, name,
currentScope(), m_comment);
- pushScope(m_klass = static_cast<UMLClassifier*>(ns));
+ pushScope(m_klass = ns->asUMLClassifier());
m_comment.clear();
if (advance() == QLatin1String("(")) {
while (m_srcIndex < srcLength - 1 && advance() != QLatin1String(")")) {
@@ -378,7 +378,7 @@ bool PythonImport::parseStmt()
if (keyword == QLatin1String("}")) {
if (scopeIndex()) {
- m_klass = dynamic_cast<UMLClassifier*>(popScope());
+ m_klass = popScope()->asUMLClassifier();
}
else
uError() << "parsing: too many }";
diff --git a/umbrello/codeimport/sqlimport.cpp b/umbrello/codeimport/sqlimport.cpp
index 8fc76f9..dab146a 100644
--- a/umbrello/codeimport/sqlimport.cpp
+++ b/umbrello/codeimport/sqlimport.cpp
@@ -659,7 +659,7 @@ bool SQLImport::parseCreateTable(QString &token)
UMLFolder *folder = UMLApp::app()->document()->rootFolder(Uml::ModelType::EntityRelationship);
UMLObject *o = Import_Utils::createUMLObject(UMLObject::ot_Entity,
tableName, folder, m_comment);
- UMLEntity *entity = dynamic_cast<UMLEntity*>(o);
+ UMLEntity *entity = o->asUMLEntity();
m_comment.clear();
if (token.toLower() == QLatin1String("as")) {
skipStmt(QLatin1String(";"));
@@ -727,7 +727,7 @@ bool SQLImport::parseAlterTable(QString &token)
if (!o) {
// report error
}
- UMLEntity *entity = dynamic_cast<UMLEntity*>(o);
+ UMLEntity *entity = o->asUMLEntity();
if (!addPrimaryKey(entity, constraintName, fieldNames)) {
; // reporter error
}
@@ -738,7 +738,7 @@ bool SQLImport::parseAlterTable(QString &token)
if (!o) {
// report error
}
- UMLEntity *entity = dynamic_cast<UMLEntity*>(o);
+ UMLEntity *entity = o->asUMLEntity();
if (!addUniqueConstraint(entity, constraintName, fieldNames)) {
; // report error
}
@@ -767,7 +767,7 @@ bool SQLImport::parseAlterTable(QString &token)
if (!o) {
// report error
}
- UMLEntity *entity = dynamic_cast<UMLEntity*>(o);
+ UMLEntity *entity = o->asUMLEntity();
if (!addForeignConstraint(entity, constraintName, localFieldNames, referencedTableName, referencedFieldNames)) {
; // report error
}
@@ -852,7 +852,7 @@ UMLObject *SQLImport::addDatatype(const QStringList &type)
if (type.at(0).toLower() == QLatin1String("enum")) {
QString name = Model_Utils::uniqObjectName(UMLObject::ot_Enum, parent, type.at(0));
datatype = Import_Utils::createUMLObject(UMLObject::ot_Enum, name, parent);
- UMLEnum *enumType = dynamic_cast<UMLEnum*>(datatype);
+ UMLEnum *enumType = datatype->asUMLEnum();
if (enumType) {
for (int i = 2; i < type.size(); i++) {
Import_Utils::addEnumLiteral(enumType, type.at(i));
@@ -969,7 +969,7 @@ bool SQLImport::addForeignConstraint(UMLEntity *entityA, const QString &_name, c
UMLFolder *root = UMLApp::app()->document()->rootFolder(Uml::ModelType::EntityRelationship);
UMLObject *o = UMLApp::app()->document()->findUMLObject(referencedTable, UMLObject::ot_Entity, root);
- UMLEntity *entityB = dynamic_cast<UMLEntity*>(o);
+ UMLEntity *entityB = o->asUMLEntity();
if (!entityB)
return false;
diff --git a/umbrello/dialogs/codeeditor.cpp b/umbrello/dialogs/codeeditor.cpp
index cdab65d..0ec9645 100644
--- a/umbrello/dialogs/codeeditor.cpp
+++ b/umbrello/dialogs/codeeditor.cpp
@@ -468,7 +468,7 @@ void CodeEditor::appendText(CodeClassFieldDeclarationBlock * db)
componentName = m_parentDocName + QString::fromLatin1("::attribute_field(") + parentObj->name() + QChar::fromLatin1(')');
}
else {
- UMLRole * role = dynamic_cast<UMLRole*>(parentObj);
+ UMLRole * role = parentObj->asUMLRole();
componentName = m_parentDocName + QString::fromLatin1("::association_field(") + role->name() + QChar::fromLatin1(')');
}
bgcolor = state().umlObjectColor;
@@ -531,7 +531,7 @@ void CodeEditor::appendText(CodeMethodBlock * mb)
componentName = m_parentDocName + QString::fromLatin1("::attribute_field(") + parentObj->name() + QString::fromLatin1(") accessor method");
}
else {
- UMLRole * role = dynamic_cast<UMLRole*>(parentObj);
+ UMLRole * role = parentObj->asUMLRole();
componentName = m_parentDocName + QString::fromLatin1("::association_field(") + role->name() + QString::fromLatin1(") accessor method");
}
}
@@ -582,7 +582,7 @@ void CodeEditor::appendText(HierarchicalCodeBlock * hblock)
QColor paperColor = state().nonEditBlockColor;
if (test) {
parentObj = test->getParentObject();
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(parentObj);
+ UMLClassifier *c = parentObj->asUMLClassifier();
if (c) {
QString typeStr;
if (c->isInterface())
@@ -643,13 +643,13 @@ void CodeEditor::removeParagraph(int para)
*/
bool CodeEditor::textBlockIsClickable(UMLObject * obj)
{
- if (dynamic_cast<UMLAttribute*>(obj))
+ if (obj->asUMLAttribute())
return true;
- else if (dynamic_cast<UMLClassifier*>(obj))
+ else if (obj->asUMLClassifier())
return true;
- else if (dynamic_cast<UMLRole*>(obj))
+ else if (obj->asUMLRole())
return true;
- else if (dynamic_cast<UMLOperation*>(obj))
+ else if (obj->asUMLOperation())
return true;
return false;
diff --git a/umbrello/dialogs/pages/classgeneralpage.cpp b/umbrello/dialogs/pages/classgeneralpage.cpp
index ec8bfcb..8d4e4b1 100644
--- a/umbrello/dialogs/pages/classgeneralpage.cpp
+++ b/umbrello/dialogs/pages/classgeneralpage.cpp
@@ -101,7 +101,7 @@ ClassGeneralPage::ClassGeneralPage(UMLDoc* d, QWidget* parent, UMLObject* o)
}
int row = 2;
- UMLClassifier *c = static_cast<UMLClassifier*>(m_pObject);
+ UMLClassifier *c = m_pObject->asUMLClassifier();
if (c->isReference() && c->originType()) {
QLabel *label = new QLabel(i18n("Reference:"), this);
m_pNameLayout->addWidget(label, row, 0);
@@ -131,13 +131,13 @@ ClassGeneralPage::ClassGeneralPage(UMLDoc* d, QWidget* parent, UMLObject* o)
if (t == UMLObject::ot_Component) {
m_pExecutableCB = new QCheckBox(i18nc("component is executable", "&Executable"), this);
- m_pExecutableCB->setChecked((static_cast<UMLComponent*>(o))->getExecutable());
+ m_pExecutableCB->setChecked((o->asUMLComponent())->getExecutable());
m_pNameLayout->addWidget(m_pExecutableCB, row, 0);
++row;
}
if (t == UMLObject::ot_Artifact) {
- m_artifactTypeWidget = new UMLArtifactTypeWidget(static_cast<UMLArtifact*>(o));
+ m_artifactTypeWidget = new UMLArtifactTypeWidget(o->asUMLArtifact());
m_artifactTypeWidget->addToLayout(topLayout);
}
@@ -306,7 +306,7 @@ void ClassGeneralPage::apply()
}
if (m_pObject->baseType() == UMLObject::ot_Component) {
- (static_cast<UMLComponent*>(m_pObject))->setExecutable(m_pExecutableCB->isChecked());
+ (m_pObject->asUMLComponent())->setExecutable(m_pExecutableCB->isChecked());
}
if (m_pObject->baseType() == UMLObject::ot_Artifact) {
diff --git a/umbrello/dialogs/pages/classifierlistpage.cpp b/umbrello/dialogs/pages/classifierlistpage.cpp
index e933ff1..162174a 100644
--- a/umbrello/dialogs/pages/classifierlistpage.cpp
+++ b/umbrello/dialogs/pages/classifierlistpage.cpp
@@ -337,7 +337,7 @@ void ClassifierListPage::slotActivateItem(QListWidgetItem* item)
if (m_pOldListItem) {
m_pOldListItem->setDoc(m_docTE->toPlainText());
if (m_itemType == UMLObject::ot_Operation) {
- UMLOperation* op = dynamic_cast<UMLOperation*>(m_pOldListItem);
+ UMLOperation* op = m_pOldListItem->asUMLOperation();
op->setSourceCode(m_pCodeTE->toPlainText());
}
}
@@ -371,7 +371,7 @@ void ClassifierListPage::slotActivateItem(QListWidgetItem* item)
// now update screen
m_docTE->setText(listItem->doc());
if (m_itemType == UMLObject::ot_Operation) {
- UMLOperation* o = dynamic_cast<UMLOperation*>(listItem);
+ UMLOperation* o = listItem->asUMLOperation();
if (!o) {
uError() << "Dynamic cast to UMLOperation failed for" << listItem->name();
return;
@@ -401,7 +401,7 @@ void ClassifierListPage::slotListItemCreated(UMLObject* object)
if (!m_bSigWaiting) {
return;
}
- UMLClassifierListItem *listItem = dynamic_cast<UMLClassifierListItem*>(object);
+ UMLClassifierListItem *listItem = object->asUMLClassifierListItem();
if (listItem == NULL) {
return;
}
@@ -767,7 +767,7 @@ void ClassifierListPage::saveCurrentItemDocumentation()
if (selectedItem) {
selectedItem->setDoc(m_docTE->toPlainText());
if (m_itemType == UMLObject::ot_Operation) {
- dynamic_cast<UMLOperation*>(selectedItem)->setSourceCode(m_pCodeTE->toPlainText());
+ selectedItem->asUMLOperation()->setSourceCode(m_pCodeTE->toPlainText());
}
}
}
@@ -791,7 +791,7 @@ bool ClassifierListPage::addClassifier(UMLClassifierListItem* listitem, int posi
{
switch (m_itemType) {
case UMLObject::ot_Attribute: {
- UMLAttribute *att = dynamic_cast<UMLAttribute*>(listitem);
+ UMLAttribute *att = listitem->asUMLAttribute();
if (!att) {
uError() << "Dynamic cast to UMLAttribute failed for" << listitem->name();
return false;
@@ -799,7 +799,7 @@ bool ClassifierListPage::addClassifier(UMLClassifierListItem* listitem, int posi
return m_pClassifier->addAttribute(att, NULL, position);
}
case UMLObject::ot_Operation: {
- UMLOperation *op = dynamic_cast<UMLOperation*>(listitem);
+ UMLOperation *op = listitem->asUMLOperation();
if (!op) {
uError() << "Dynamic cast to UMLOperation failed for" << listitem->name();
return false;
@@ -807,7 +807,7 @@ bool ClassifierListPage::addClassifier(UMLClassifierListItem* listitem, int posi
return m_pClassifier->addOperation(op, position);
}
case UMLObject::ot_Template: {
- UMLTemplate* t = dynamic_cast<UMLTemplate*>(listitem);
+ UMLTemplate* t = listitem->asUMLTemplate();
if (!t) {
uError() << "Dynamic cast to UMLTemplate failed for" << listitem->name();
return false;
@@ -815,12 +815,12 @@ bool ClassifierListPage::addClassifier(UMLClassifierListItem* listitem, int posi
return m_pClassifier->addTemplate(t, position);
}
case UMLObject::ot_EnumLiteral: {
- UMLEnum* c = dynamic_cast<UMLEnum*>(m_pClassifier);
+ UMLEnum* c = m_pClassifier->asUMLEnum();
if (!c) {
uError() << "Dynamic cast to UMLEnum failed for" << m_pClassifier->name();
return false;
}
- UMLEnumLiteral *l = dynamic_cast<UMLEnumLiteral*>(listitem);
+ UMLEnumLiteral *l = listitem->asUMLEnumLiteral();
if (!l) {
uError() << "Dynamic cast to UMLEnumLiteral failed for" << listitem->name();
return false;
@@ -829,12 +829,12 @@ bool ClassifierListPage::addClassifier(UMLClassifierListItem* listitem, int posi
break;
}
case UMLObject::ot_EntityAttribute: {
- UMLEntity* c = dynamic_cast<UMLEntity*>(m_pClassifier);
+ UMLEntity* c = m_pClassifier->asUMLEntity();
if (!c) {
uError() << "Dynamic cast to UMLEntity failed for" << m_pClassifier->name();
return false;
}
- UMLEntityAttribute *a = dynamic_cast<UMLEntityAttribute*>(listitem);
+ UMLEntityAttribute *a = listitem->asUMLEntityAttribute();
if (!a) {
uError() << "Dynamic cast to UMLEntityAttribute failed for" << listitem->name();
return false;
diff --git a/umbrello/dialogs/pages/constraintlistpage.cpp b/umbrello/dialogs/pages/constraintlistpage.cpp
index f2aa031..6f9cb08 100644
--- a/umbrello/dialogs/pages/constraintlistpage.cpp
+++ b/umbrello/dialogs/pages/constraintlistpage.cpp
@@ -128,7 +128,7 @@ void ConstraintListPage::slotNewPrimaryKeyConstraint()
ClassifierListPage::slotNewListItem();
// set the last object created as Primary Key
- UMLEntity* ent = static_cast<UMLEntity*>(m_pClassifier);
+ UMLEntity* ent = m_pClassifier->asUMLEntity();
if (ent == NULL) {
uError() << "Could not set Primary Key. Entity Value is Null";
@@ -137,7 +137,7 @@ void ConstraintListPage::slotNewPrimaryKeyConstraint()
if (m_pLastObjectCreated!=NULL) {
m_bSigWaiting = true;
- ent->setAsPrimaryKey(static_cast<UMLUniqueConstraint*>(m_pLastObjectCreated));
+ ent->setAsPrimaryKey(m_pLastObjectCreated->asUMLUniqueConstraint());
m_itemType = UMLObject::ot_EntityConstraint;
reloadItemListBox();
}
diff --git a/umbrello/dialogs/umlattributedialog.cpp b/umbrello/dialogs/umlattributedialog.cpp
index cb16c94..fea3432 100644
--- a/umbrello/dialogs/umlattributedialog.cpp
+++ b/umbrello/dialogs/umlattributedialog.cpp
@@ -70,7 +70,7 @@ void UMLAttributeDialog::setupDialog()
valuesLayout->setMargin(margin);
valuesLayout->setSpacing(10);
- m_datatypeWidget = new UMLDatatypeWidget(dynamic_cast<UMLClassifierListItem*>(m_pAttribute));
+ m_datatypeWidget = new UMLDatatypeWidget(m_pAttribute->asUMLClassifierListItem());
m_datatypeWidget->addToLayout(valuesLayout, 0);
Dialog_Utils::makeLabeledEditField(valuesLayout, 1,
diff --git a/umbrello/dialogs/umlforeignkeyconstraintdialog.cpp b/umbrello/dialogs/umlforeignkeyconstraintdialog.cpp
index 7864943..d0e5b5c 100644
--- a/umbrello/dialogs/umlforeignkeyconstraintdialog.cpp
+++ b/umbrello/dialogs/umlforeignkeyconstraintdialog.cpp
@@ -160,7 +160,7 @@ bool UMLForeignKeyConstraintDialog::apply()
QString entityName = m_GeneralWidgets.referencedEntityCB->currentText();
UMLObject* uo = m_doc->findUMLObject(entityName, UMLObject::ot_Entity);
- UMLEntity* ue = static_cast<UMLEntity*>(uo);
+ UMLEntity* ue = uo->asUMLEntity();
if (ue == NULL) {
uDebug() << " Could not find UML Entity with name " << entityName;
@@ -425,12 +425,12 @@ void UMLForeignKeyConstraintDialog::refillReferencedAttributeCB()
UMLObject* uo = m_doc->findUMLObject(m_GeneralWidgets.referencedEntityCB->currentText(),
UMLObject::ot_Entity);
- UMLEntity* ue = static_cast<UMLEntity*>(uo);
+ UMLEntity* ue = uo->asUMLEntity();
if (ue) {
UMLClassifierListItemList ual = ue->getFilteredList(UMLObject::ot_EntityAttribute);
foreach(UMLClassifierListItem* att, ual) {
- m_pReferencedAttributeList.append(static_cast<UMLEntityAttribute*>(att));
+ m_pReferencedAttributeList.append(att->asUMLEntityAttribute());
m_ColumnWidgets.referencedColumnCB->addItem(att->toString(Uml::SignatureType::SigNoVis));
}
}
@@ -446,7 +446,7 @@ void UMLForeignKeyConstraintDialog::refillLocalAttributeCB()
if (ue) {
UMLClassifierListItemList ual = ue->getFilteredList(UMLObject::ot_EntityAttribute);
foreach(UMLClassifierListItem* att, ual) {
- m_pLocalAttributeList.append(static_cast<UMLEntityAttribute*>(att));
+ m_pLocalAttributeList.append(att->asUMLEntityAttribute());
m_ColumnWidgets.localColumnCB->addItem(att->toString(Uml::SignatureType::SigNoVis));
}
}
diff --git a/umbrello/dialogs/umloperationdialog.cpp b/umbrello/dialogs/umloperationdialog.cpp
index 685fa30..e953cfa 100644
--- a/umbrello/dialogs/umloperationdialog.cpp
+++ b/umbrello/dialogs/umloperationdialog.cpp
@@ -300,7 +300,7 @@ void UMLOperationDialog::slotParameterProperties()
} // should never occur
QString oldAttName = pOldAtt->name();
- UMLAttribute* tempAttribute = static_cast<UMLAttribute*>(pOldAtt->clone()); // create a clone of the parameter
+ UMLAttribute* tempAttribute = pOldAtt->clone()->asUMLAttribute(); // create a clone of the parameter
// send the clone to the properties dialog box. it will fill in the new parameters.
QPointer<ParameterPropertiesDialog> dlg = new ParameterPropertiesDialog(this, m_doc, tempAttribute);
diff --git a/umbrello/dialogs/umluniqueconstraintdialog.cpp b/umbrello/dialogs/umluniqueconstraintdialog.cpp
index 2f51c63..2a4addc 100644
--- a/umbrello/dialogs/umluniqueconstraintdialog.cpp
+++ b/umbrello/dialogs/umluniqueconstraintdialog.cpp
@@ -132,7 +132,7 @@ void UMLUniqueConstraintDialog::setupDialog()
if (ue) {
UMLClassifierListItemList ual = ue->getFilteredList(UMLObject::ot_EntityAttribute);
foreach(UMLClassifierListItem* att, ual) {
- m_pEntityAttributeList.append(static_cast<UMLEntityAttribute*>(att));
+ m_pEntityAttributeList.append(att->asUMLEntityAttribute());
m_pAttributeCB->addItem(att->toString(Uml::SignatureType::SigNoVis));
}
}
diff --git a/umbrello/dialogs/widgets/umldatatypewidget.cpp b/umbrello/dialogs/widgets/umldatatypewidget.cpp
index 5cd1fba..3fcf32d 100644
--- a/umbrello/dialogs/widgets/umldatatypewidget.cpp
+++ b/umbrello/dialogs/widgets/umldatatypewidget.cpp
@@ -149,7 +149,7 @@ bool UMLDatatypeWidget::applyAttribute()
obj = pDoc->findUMLObject(typeName);
}
- UMLClassifier *classifier = dynamic_cast<UMLClassifier*>(obj);
+ UMLClassifier *classifier = obj->asUMLClassifier();
if (classifier == NULL) {
Uml::ProgrammingLanguage::Enum pl = UMLApp::app()->activeLanguage();
// Import_Utils does not handle creating a new object with empty name
@@ -174,7 +174,7 @@ bool UMLDatatypeWidget::applyAttribute()
}
if (obj == NULL)
return false;
- classifier = static_cast<UMLClassifier*>(obj);
+ classifier = obj->asUMLClassifier();
}
m_datatype->setType(classifier);
return true;
@@ -192,7 +192,7 @@ bool UMLDatatypeWidget::applyEntityAttribute()
}
}
UMLObject *obj = pDoc->findUMLObject(typeName);
- UMLClassifier *classifier = dynamic_cast<UMLClassifier*>(obj);
+ UMLClassifier *classifier = obj->asUMLClassifier();
if (classifier == NULL) {
// If it's obviously a pointer type (C++) then create a datatype.
// Else we don't know what it is so as a compromise create a class.
@@ -202,7 +202,7 @@ bool UMLDatatypeWidget::applyEntityAttribute()
obj = Object_Factory::createUMLObject(ot, typeName);
if (obj == NULL)
return false;
- classifier = static_cast<UMLClassifier*>(obj);
+ classifier = obj->asUMLClassifier();
}
m_entityAttribute->setType(classifier);
return true;
@@ -370,7 +370,7 @@ void UMLDatatypeWidget::insertTypesSortedOperation(const QString& type)
// function.
types << QLatin1String("void");
// add template parameters
- UMLClassifier *classifier = dynamic_cast<UMLClassifier*>(m_parent);
+ UMLClassifier *classifier = m_parent->asUMLClassifier();
if (classifier) {
UMLClassifierListItemList tmplParams(classifier->getFilteredList(UMLOperation::ot_Template));
foreach (UMLClassifierListItem* li, tmplParams) {
@@ -391,7 +391,7 @@ void UMLDatatypeWidget::insertTypesSortedParameter(const QString& type)
{
QStringList types;
// add template parameters
- UMLClassifier *pConcept = dynamic_cast<UMLClassifier*>(m_parent);
+ UMLClassifier *pConcept = m_parent->asUMLClassifier();
if (pConcept == NULL) {
uError() << "ParameterPropertiesDialog: grandparent of " << m_attribute->name()
<< " is not a UMLClassifier";
diff --git a/umbrello/dialogs/widgets/umlpackagewidget.cpp b/umbrello/dialogs/widgets/umlpackagewidget.cpp
index 3d2066e..bc24c12 100644
--- a/umbrello/dialogs/widgets/umlpackagewidget.cpp
+++ b/umbrello/dialogs/widgets/umlpackagewidget.cpp
@@ -52,7 +52,7 @@ UMLPackageWidget::UMLPackageWidget(UMLObject *o, QWidget *parent) :
UMLPackage* parentPackage = o->umlPackage();
UMLPackage* folderLogicalView =
- static_cast<UMLPackage*>(UMLApp::app()->document()->rootFolder(Uml::ModelType::Logical));
+ UMLApp::app()->document()->rootFolder(Uml::ModelType::Logical)->asUMLPackage();
if (parentPackage == NULL ||
parentPackage == folderLogicalView) {
m_editField->setEditText(QString());
diff --git a/umbrello/docwindow.cpp b/umbrello/docwindow.cpp
index 2b73002..30154ca 100644
--- a/umbrello/docwindow.cpp
+++ b/umbrello/docwindow.cpp
@@ -152,7 +152,7 @@ void DocWindow::showDocumentation(UMLObject * object, bool overwrite)
m_pUMLObject = object;
m_docTE->setText(m_pUMLObject->doc());
if (m_pUMLObject->baseType() == UMLObject::ot_Folder) {
- UMLFolder *folder = dynamic_cast<UMLFolder*>(m_pUMLObject);
+ UMLFolder *folder = m_pUMLObject->asUMLFolder();
updateLabel(folder->localName());
}
else
diff --git a/umbrello/finder/umllistviewfinder.cpp b/umbrello/finder/umllistviewfinder.cpp
index 81757b1..0c0d0d3 100644
--- a/umbrello/finder/umllistviewfinder.cpp
+++ b/umbrello/finder/umllistviewfinder.cpp
@@ -30,7 +30,7 @@ int UMLListViewFinder::collect(Category category, const QString &text)
QList<QTreeWidgetItem*> items = UMLApp::app()->listView()->findItems(text, Qt::MatchContains | Qt::MatchRecursive);
m_items.clear();
foreach(QTreeWidgetItem *item, items) {
- UMLListViewItem *ui = dynamic_cast<UMLListViewItem*>(item);
+ UMLListViewItem *ui = dynamic_cast<UMLListViewItem *>(item);
if (!ui)
continue;
UMLObject *o = ui->umlObject();
diff --git a/umbrello/listpopupmenu.cpp b/umbrello/listpopupmenu.cpp
index d87b2e3..b05e498 100644
--- a/umbrello/listpopupmenu.cpp
+++ b/umbrello/listpopupmenu.cpp
@@ -405,11 +405,10 @@ void ListPopupMenu::insertSingleSelectionMenu(WidgetBase* object)
case WidgetBase::wt_Category:
{
#if QT_VERSION >= 0x050000
- QMenu* m = makeCategoryTypeMenu(
+ QMenu* m = makeCategoryTypeMenu(object->umlObject()->asUMLCategory());
#else
- KMenu* m = makeCategoryTypeMenu(
+ KMenu* m = makeCategoryTypeMenu(object->umlObject()->asUMLCategory());
#endif
- static_cast<UMLCategory*>(object->umlObject()));
m->setTitle(i18n("Category Type"));
addMenu(m);
insertSubMenuColor(object->useFillColor());
@@ -1138,7 +1137,7 @@ void ListPopupMenu::insertSubmodelAction()
uError() << " Model_Utils::treeViewGetCurrentObject() returns NULL";
return;
}
- UMLFolder *f = dynamic_cast<UMLFolder*>(o);
+ UMLFolder *f = o->asUMLFolder();
if (f == NULL) {
uError() << o->name() << " is not a Folder";
return;
@@ -1910,9 +1909,9 @@ void ListPopupMenu::setupMenu(MenuType type)
return;
}
#if QT_VERSION >= 0x050000
- QMenu* menu = makeCategoryTypeMenu(static_cast<UMLCategory*>(m_TriggerObject.m_Object));
+ QMenu* menu = makeCategoryTypeMenu(m_TriggerObject.m_Object->asUMLCategory());
#else
- KMenu* menu = makeCategoryTypeMenu(static_cast<UMLCategory*>(m_TriggerObject.m_Object));
+ KMenu* menu = makeCategoryTypeMenu(m_TriggerObject.m_Object->asUMLCategory());
#endif
menu->setTitle(i18n("Category Type"));
addMenu(menu);
diff --git a/umbrello/model_utils.cpp b/umbrello/model_utils.cpp
index 11abfc8..3a1f396 100644
--- a/umbrello/model_utils.cpp
+++ b/umbrello/model_utils.cpp
@@ -91,7 +91,7 @@ UMLObject* findObjectInList(Uml::ID::Type id, const UMLObjectList& inList)
case UMLObject::ot_Folder:
case UMLObject::ot_Package:
case UMLObject::ot_Component:
- o = static_cast<UMLPackage*>(obj)->findObjectById(id);
+ o = obj->asUMLPackage()->findObjectById(id);
if (o)
return o;
break;
@@ -99,7 +99,7 @@ UMLObject* findObjectInList(Uml::ID::Type id, const UMLObjectList& inList)
case UMLObject::ot_Class:
case UMLObject::ot_Enum:
case UMLObject::ot_Entity:
- o = static_cast<UMLClassifier*>(obj)->findChildObjectById(id);
+ o = obj->asUMLClassifier()->findChildObjectById(id);
if (o == NULL &&
(t == UMLObject::ot_Interface || t == UMLObject::ot_Class))
o = ((UMLPackage*)obj)->findObjectById(id);
@@ -108,7 +108,7 @@ UMLObject* findObjectInList(Uml::ID::Type id, const UMLObjectList& inList)
break;
case UMLObject::ot_Association:
{
- UMLAssociation *assoc = static_cast<UMLAssociation*>(obj);
+ UMLAssociation *assoc = obj->asUMLAssociation();
UMLRole *rA = assoc->getUMLRole(Uml::RoleType::A);
if (rA->id() == id)
return rA;
@@ -173,10 +173,10 @@ UMLObject* findUMLObject(const UMLObjectList& inList,
}
if (currentObj) {
UMLPackage *pkg = NULL;
- if (dynamic_cast<UMLClassifierListItem*>(currentObj)) {
+ if (currentObj->asUMLClassifierListItem()) {
currentObj = static_cast<UMLObject*>(currentObj->parent());
}
- pkg = dynamic_cast<UMLPackage*>(currentObj);
+ pkg = currentObj->asUMLPackage();
if (pkg == NULL || pkg->baseType() == UMLObject::ot_Association)
pkg = currentObj->umlPackage();
// Remember packages that we've seen - for avoiding cycles.
@@ -202,7 +202,7 @@ UMLObject* findUMLObject(const UMLObjectList& inList,
seenPkgs.append(pkg);
// exclude non package type
- // dynamic_cast<UMLPackage*>(pg) fails for unknown reason
+ // pg->asUMLPackage() fails for unknown reason
// see https://bugs.kde.org/show_bug.cgi?id=341709
UMLObject::ObjectType foundType = pkg->baseType();
if (foundType != UMLObject::ot_Package &&
@@ -253,7 +253,7 @@ UMLObject* findUMLObject(const UMLObjectList& inList,
<< " is not a package (?)";
continue;
}
- UMLPackage *pkg = static_cast<UMLPackage*>(obj);
+ UMLPackage *pkg = obj->asUMLPackage();
return findUMLObject(pkg->containedObjects(),
nameWithoutFirstPrefix, type);
}
@@ -289,7 +289,7 @@ UMLObject* findUMLObject(const UMLObjectList& inList,
<< " is not a package (?)";
continue;
}
- UMLPackage *pkg = static_cast<UMLPackage*>(obj);
+ UMLPackage *pkg = obj->asUMLPackage();
return findUMLObject(pkg->containedObjects(),
nameWithoutFirstPrefix, type);
}
@@ -334,7 +334,7 @@ UMLPackage* rootPackage(UMLObject* obj)
return NULL;
UMLPackage* root = obj->umlPackage();
if (root == NULL) {
- root = dynamic_cast<UMLPackage*>(obj);
+ root = obj->asUMLPackage();
} else {
while (root->umlPackage() != NULL) {
root = root->umlPackage();
@@ -420,7 +420,7 @@ UMLPackage* treeViewGetPackageFromCurrent()
UMLListViewItem::ListViewType lvt = parentItem->type();
if (Model_Utils::typeIsContainer(lvt)) {
UMLObject *o = parentItem->umlObject();
- return static_cast<UMLPackage*>(o);
+ return o->asUMLPackage();
}
// selected item is not a container, try to find the
@@ -647,7 +647,7 @@ Uml::ModelType::Enum guessContainer(UMLObject *o)
break;
case UMLObject::ot_Association:
{
- UMLAssociation *assoc = static_cast<UMLAssociation*>(o);
+ UMLAssociation *assoc = o->asUMLAssociation();
UMLDoc *umldoc = UMLApp::app()->document();
for (int r = Uml::RoleType::A; r <= Uml::RoleType::B; ++r) {
UMLObject *roleObj = assoc->getObject(Uml::RoleType::fromInt(r));
@@ -1353,7 +1353,7 @@ UMLListViewItem::ListViewType convert_OT_LVT(UMLObject *o)
case UMLObject::ot_Folder:
{
UMLDoc *umldoc = UMLApp::app()->document();
- UMLFolder *f = static_cast<UMLFolder*>(o);
+ UMLFolder *f = o->asUMLFolder();
do {
const Uml::ModelType::Enum mt = umldoc->rootFolderType(f);
if (mt != Uml::ModelType::N_MODELTYPES) {
@@ -1378,7 +1378,7 @@ UMLListViewItem::ListViewType convert_OT_LVT(UMLObject *o)
}
return type;
}
- } while ((f = static_cast<UMLFolder*>(f->umlPackage())) != NULL);
+ } while ((f = f->umlPackage()->asUMLFolder()) != NULL);
uError() << "convert_OT_LVT(" << o->name()
<< "): internal error - object is not properly nested in folder";
}
@@ -1430,7 +1430,7 @@ UMLListViewItem::ListViewType convert_OT_LVT(UMLObject *o)
case UMLObject::ot_UniqueConstraint: {
UMLEntity* ent = static_cast<UMLEntity*>(o->parent());
- UMLUniqueConstraint* uc = static_cast<UMLUniqueConstraint*>(o);
+ UMLUniqueConstraint* uc = o->asUMLUniqueConstraint();
if (ent->isPrimaryKey(uc)) {
type = UMLListViewItem::lvt_PrimaryKeyConstraint;
} else {
diff --git a/umbrello/object_factory.cpp b/umbrello/object_factory.cpp
index e7590e8..8f2d810 100644
--- a/umbrello/object_factory.cpp
+++ b/umbrello/object_factory.cpp
@@ -304,53 +304,53 @@ UMLClassifierListItem* createChildObject(UMLClassifier* parent, UMLObject::Objec
UMLObject* returnObject = NULL;
switch (type) {
case UMLObject::ot_Attribute: {
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(parent);
+ UMLClassifier *c = parent->asUMLClassifier();
if (c && !c->isInterface())
returnObject = c->createAttribute(name);
break;
}
case UMLObject::ot_EntityAttribute: {
- UMLEntity *e = dynamic_cast<UMLEntity*>(parent);
+ UMLEntity *e = parent->asUMLEntity();
if (e) {
returnObject = e->createAttribute(name);
}
break;
}
case UMLObject::ot_Operation: {
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(parent);
+ UMLClassifier *c = parent->asUMLClassifier();
if (c)
returnObject = c->createOperation(name);
break;
}
case UMLObject::ot_Template: {
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(parent);
+ UMLClassifier *c = parent->asUMLClassifier();
if (c)
returnObject = c->createTemplate(name);
break;
}
case UMLObject::ot_EnumLiteral: {
- UMLEnum* umlenum = dynamic_cast<UMLEnum*>(parent);
+ UMLEnum* umlenum = parent->asUMLEnum();
if (umlenum) {
returnObject = umlenum->createEnumLiteral(name);
}
break;
}
case UMLObject::ot_UniqueConstraint: {
- UMLEntity* umlentity = dynamic_cast<UMLEntity*>(parent);
+ UMLEntity* umlentity = parent->asUMLEntity();
if (umlentity) {
returnObject = umlentity->createUniqueConstraint(name);
}
break;
}
case UMLObject::ot_ForeignKeyConstraint: {
- UMLEntity* umlentity = dynamic_cast<UMLEntity*>(parent);
+ UMLEntity* umlentity = parent->asUMLEntity();
if (umlentity) {
returnObject = umlentity->createForeignKeyConstraint(name);
}
break;
}
case UMLObject::ot_CheckConstraint: {
- UMLEntity* umlentity = dynamic_cast<UMLEntity*>(parent);
+ UMLEntity* umlentity = parent->asUMLEntity();
if (umlentity) {
returnObject = umlentity->createCheckConstraint(name);
}
@@ -359,7 +359,7 @@ UMLClassifierListItem* createChildObject(UMLClassifier* parent, UMLObject::Objec
default:
uDebug() << "ERROR UMLDoc::createChildObject type:" << UMLObject::toString(type);
}
- return static_cast<UMLClassifierListItem*>(returnObject);
+ return returnObject->asUMLClassifierListItem();
}
/**
diff --git a/umbrello/petaltree2uml.cpp b/umbrello/petaltree2uml.cpp
index 9d21e1c..b525b1d 100644
--- a/umbrello/petaltree2uml.cpp
+++ b/umbrello/petaltree2uml.cpp
@@ -269,7 +269,7 @@ public:
return new UMLAttribute(m_classifier);
}
void insertAtParent(const PetalNode *, UMLObject *item) {
- m_classifier->addAttribute(static_cast<UMLAttribute*>(item));
+ m_classifier->addAttribute(item->asUMLAttribute());
}
protected:
UMLClassifier *m_classifier;
@@ -289,7 +289,7 @@ public:
void insertAtParent(const PetalNode *, UMLObject *item) {
if (item->id() == Uml::ID::None)
item->setID(UniqueID::gen());
- m_operation->addParm(static_cast<UMLAttribute*>(item));
+ m_operation->addParm(item->asUMLAttribute());
}
protected:
UMLOperation *m_operation;
@@ -307,7 +307,7 @@ public:
return new UMLOperation(m_classifier);
}
void insertAtParent(const PetalNode *node, UMLObject *item) {
- UMLOperation *op = static_cast<UMLOperation*>(item);
+ UMLOperation *op = item->asUMLOperation();
ParametersReader parmReader(op);
parmReader.read(node, m_classifier->name());
m_classifier->addOperation(op);
@@ -333,7 +333,7 @@ public:
*/
void setTypeReferences(UMLObject *item,
const QString& quid, const QString& type) {
- UMLAssociation *assoc = static_cast<UMLAssociation*>(item);
+ UMLAssociation *assoc = item->asUMLAssociation();
if (!quid.isEmpty()) {
assoc->getUMLRole(Uml::RoleType::B)->setSecondaryId(quid);
}
@@ -342,7 +342,7 @@ public:
}
}
void insertAtParent(const PetalNode *, UMLObject *item) {
- UMLAssociation *assoc = static_cast<UMLAssociation*>(item);
+ UMLAssociation *assoc = item->asUMLAssociation();
assoc->setObject(m_classifier, Uml::RoleType::A);
assoc->setUMLPackage(m_classifier->umlPackage());
UMLApp::app()->document()->addAssociation(assoc);
@@ -368,7 +368,7 @@ public:
*/
void setTypeReferences(UMLObject *item,
const QString& quid, const QString& type) {
- UMLAssociation *assoc = static_cast<UMLAssociation*>(item);
+ UMLAssociation *assoc = item->asUMLAssociation();
if (!quid.isEmpty()) {
assoc->getUMLRole(Uml::RoleType::B)->setSecondaryId(quid);
}
@@ -377,7 +377,7 @@ public:
}
}
void insertAtParent(const PetalNode *, UMLObject *item) {
- UMLAssociation *assoc = static_cast<UMLAssociation*>(item);
+ UMLAssociation *assoc = item->asUMLAssociation();
assoc->setObject(m_classifier, Uml::RoleType::A);
assoc->setUMLPackage(m_classifier->umlPackage());
UMLApp::app()->document()->addAssociation(assoc);
@@ -525,7 +525,7 @@ void handleAssocView(PetalNode *attr,
uError() << assocStr << " client widget " << clIdStr
<< " is not on diagram (?)";
} else {
- // UMLAssociation *a = static_cast<UMLAssociation*>(o);
+ // UMLAssociation *a = o->asUMLAssociation();
AssociationWidget *aw = AssociationWidget::create
(view->umlScene(), cliW, assocType,
supW, umlAssoc);
@@ -591,7 +591,7 @@ bool umbrellify(PetalNode *node, UMLPackage *parentPkg)
else
o = Object_Factory::createUMLObject(UMLObject::ot_Folder, name, parentPkg);
o->setID(id);
- UMLPackage *localParent = static_cast<UMLPackage*>(o);
+ UMLPackage *localParent = o->asUMLPackage();
for (int i = 0; i < atts.count(); ++i) {
umbrellify(atts[i].second.node, localParent);
}
@@ -618,7 +618,7 @@ bool umbrellify(PetalNode *node, UMLPackage *parentPkg)
} else {
o = Object_Factory::createUMLObject(UMLObject::ot_Class, name, parentPkg, false);
o->setID(id);
- UMLClassifier *c = static_cast<UMLClassifier*>(o);
+ UMLClassifier *c = o->asUMLClassifier();
// set stereotype
if (!stereotype.isEmpty()) {
if (stereotype.toLower() == QLatin1String("interface")) {
@@ -725,7 +725,7 @@ bool umbrellify(PetalNode *node, UMLPackage *parentPkg)
return false;
}
UMLDoc *umlDoc = UMLApp::app()->document();
- UMLFolder *rootFolder = static_cast<UMLFolder*>(parentPkg);
+ UMLFolder *rootFolder = parentPkg->asUMLFolder();
UMLView *view = umlDoc->createDiagram(rootFolder, dt, name, id);
PetalNode *items = node->findAttribute(QLatin1String("items")).node;
if (items == NULL) {
@@ -956,7 +956,7 @@ UMLPackage * petalTree2Uml(PetalNode *root, UMLPackage *parentPkg)
const Uml::ID::Type id = quid(root);
UMLObject *o = Object_Factory::createUMLObject(UMLObject::ot_Folder, name, parentPkg, false);
o->setID(id);
- parentPkg = static_cast<UMLPackage*>(o);
+ parentPkg = o->asUMLPackage();
PetalNode::NameValueList atts = models->attributes();
for (int i = 0; i < atts.count(); ++i) {
if (!umbrellify(atts[i].second.node, parentPkg)) {
diff --git a/umbrello/refactoring/refactoringassistant.cpp b/umbrello/refactoring/refactoringassistant.cpp
index 127bd93..faa466d 100644
--- a/umbrello/refactoring/refactoringassistant.cpp
+++ b/umbrello/refactoring/refactoringassistant.cpp
@@ -217,7 +217,7 @@ void RefactoringAssistant::objectModified()
*/
void RefactoringAssistant::operationAdded(UMLClassifierListItem *listItem)
{
- UMLOperation *op = static_cast<UMLOperation*>(listItem);
+ UMLOperation *op = listItem->asUMLOperation();
DEBUG(DBG_SRC) << "operation = " << op->name(); //:TODO:
UMLClassifier *parent = dynamic_cast<UMLClassifier*>(op->parent());
if (!parent) {
@@ -247,7 +247,7 @@ void RefactoringAssistant::operationAdded(UMLClassifierListItem *listItem)
*/
void RefactoringAssistant::operationRemoved(UMLClassifierListItem *listItem)
{
- UMLOperation *op = static_cast<UMLOperation*>(listItem);
+ UMLOperation *op = listItem->asUMLOperation();
QTreeWidgetItem *item = findListViewItem(op);
if (!item) {
return;
@@ -263,7 +263,7 @@ void RefactoringAssistant::operationRemoved(UMLClassifierListItem *listItem)
*/
void RefactoringAssistant::attributeAdded(UMLClassifierListItem *listItem)
{
- UMLAttribute *att = static_cast<UMLAttribute*>(listItem);
+ UMLAttribute *att = listItem->asUMLAttribute();
DEBUG(DBG_SRC) << "attribute = " << att->name(); //:TODO:
UMLClassifier *parent = dynamic_cast<UMLClassifier*>(att->parent());
if (!parent) {
@@ -294,7 +294,7 @@ void RefactoringAssistant::attributeAdded(UMLClassifierListItem *listItem)
*/
void RefactoringAssistant::attributeRemoved(UMLClassifierListItem *listItem)
{
- UMLAttribute *att = static_cast<UMLAttribute*>(listItem);
+ UMLAttribute *att = listItem->asUMLAttribute();
DEBUG(DBG_SRC) << "attribute = " << att->name(); //:TODO:
QTreeWidgetItem *item = findListViewItem(att);
if (!item) {
@@ -341,10 +341,10 @@ void RefactoringAssistant::editProperties(UMLObject *obj)
delete dialog;
}
else if (t == UMLObject::ot_Operation) {
- dia = new UMLOperationDialog(this, static_cast<UMLOperation*>(obj));
+ dia = new UMLOperationDialog(this, obj->asUMLOperation());
}
else if (t == UMLObject::ot_Attribute) {
- dia = new UMLAttributeDialog(this, static_cast<UMLAttribute*>(obj));
+ dia = new UMLAttributeDialog(this, obj->asUMLAttribute());
}
else {
uWarning() << "Called for unknown type " << typeid(*obj).name();
@@ -385,12 +385,12 @@ void RefactoringAssistant::deleteItem(QTreeWidgetItem *item, UMLObject *obj)
QTreeWidgetItem *opNode = item->parent();
if (opNode) {
QTreeWidgetItem *parent = opNode->parent();
- UMLClassifier* c = static_cast<UMLClassifier*>(findUMLObject(parent));
+ UMLClassifier* c = findUMLObject(parent)->asUMLClassifier();
if (!c) {
uWarning() << "No classifier - cannot delete!";
return;
}
- UMLOperation* op = static_cast<UMLOperation*>(obj);
+ UMLOperation* op = obj->asUMLOperation();
c->removeOperation(op);
}
}
@@ -398,12 +398,12 @@ void RefactoringAssistant::deleteItem(QTreeWidgetItem *item, UMLObject *obj)
QTreeWidgetItem *attrNode = item->parent();
if (attrNode) {
QTreeWidgetItem *parent = attrNode->parent();
- UMLClassifier* c = static_cast<UMLClassifier*>(findUMLObject(parent));
+ UMLClassifier* c = findUMLObject(parent)->asUMLClassifier();
if (!c) {
uWarning() << "No classifier - cannot delete!";
return;
}
- UMLAttribute* attr = static_cast<UMLAttribute*>(obj);
+ UMLAttribute* attr = obj->asUMLAttribute();
c->removeAttribute(attr);
}
}
@@ -490,14 +490,14 @@ void RefactoringAssistant::addBaseClassifier()
return;
}
UMLObject *obj = findUMLObject(item);
- if (!dynamic_cast<UMLClassifier*>(obj)) {
+ if (!obj->asUMLClassifier()) {
uWarning() << "Called for a non-classifier object.";
return;
}
//classes have classes and interfaces interfaces as super/derived classifiers
UMLObject::ObjectType t = obj->baseType();
- UMLClassifier *super = static_cast<UMLClassifier*>(Object_Factory::createUMLObject(t));
+ UMLClassifier *super = Object_Factory::createUMLObject(t)->asUMLClassifier();
if (!super) {
return;
}
@@ -535,14 +535,14 @@ void RefactoringAssistant::addDerivedClassifier()
return;
}
UMLObject *obj = findUMLObject(item);
- if (!dynamic_cast<UMLClassifier*>(obj)) {
+ if (!obj->asUMLClassifier()) {
uWarning() << "Called for a non-classifier object.";
return;
}
//classes have classes and interfaces have interfaces as super/derived classifiers
UMLObject::ObjectType t = obj->baseType();
- UMLClassifier *derived = static_cast<UMLClassifier*>(Object_Factory::createUMLObject(t));
+ UMLClassifier *derived = Object_Factory::createUMLObject(t)->asUMLClassifier();
if (!derived) {
return;
}
@@ -578,7 +578,7 @@ void RefactoringAssistant::addInterfaceImplementation()
return;
// QTreeWidgetItem *item = selectedListViewItem();
// UMLObject *obj = findUMLObject(item);
- // if(!dynamic_cast<UMLClassifier*>(obj))
+ // if(!obj->asUMLClassifier())
// return;
// UMLObject *n = Object_Factory::createUMLObject(UMLObject::ot_Interface));
// if (!n) {
@@ -598,10 +598,10 @@ void RefactoringAssistant::createOperation()
uWarning() << "Called with no item selected.";
return;
}
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(findUMLObject(item));
+ UMLClassifier *c = findUMLObject(item)->asUMLClassifier();
if (!c) { // find parent
QTreeWidgetItem *parent = item->parent();
- c = dynamic_cast<UMLClassifier*>(findUMLObject(parent));
+ c = findUMLObject(parent)->asUMLClassifier();
if (!c) {
uWarning() << "No classifier - cannot create!";
return;
@@ -620,10 +620,10 @@ void RefactoringAssistant::createAttribute()
uWarning() << "Called with no item selected.";
return;
}
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(findUMLObject(item));
+ UMLClassifier *c = findUMLObject(item)->asUMLClassifier();
if (!c) { // find parent
QTreeWidgetItem *parent = item->parent();
- c = dynamic_cast<UMLClassifier*>(findUMLObject(parent));
+ c = findUMLObject(parent)->asUMLClassifier;
if (!c) {
uWarning() << "No classifier - cannot create!";
return;
@@ -807,12 +807,12 @@ DEBUG(DBG_SRC) << "acceptProposedAction"; //:TODO:fischer
}
QTreeWidgetItem* parentItem = afterme->parent();
UMLObject::ObjectType t = movingObject->baseType();
- newClassifier = dynamic_cast<UMLClassifier*>(findUMLObject(parentItem));
+ newClassifier = findUMLObject(parentItem)->asUMLClassifier();
if (!newClassifier) {
const QString parentText = parentItem->text(1);
if ((parentText == QLatin1String("operations") && t == UMLObject::ot_Operation) ||
(parentText == QLatin1String("attributes") && t == UMLObject::ot_Attribute)) {
- newClassifier = dynamic_cast<UMLClassifier*>(findUMLObject(parentItem->parent()));
+ newClassifier = findUMLObject(parentItem->parent())->asUMLClassifier();
}
if (!newClassifier) {
uWarning() << "New parent of object is not a Classifier - Drop had already been accepted - check!";
@@ -821,7 +821,7 @@ DEBUG(DBG_SRC) << "acceptProposedAction"; //:TODO:fischer
}
if (t == UMLObject::ot_Operation) {
DEBUG(DBG_SRC) << "Moving operation";
- UMLOperation *op = static_cast<UMLOperation*>(movingObject);
+ UMLOperation *op = movingObject->asUMLOperation();
if (newClassifier->checkOperationSignature(op->name(), op->getParmList())) {
QString msg = i18n("An operation with that signature already exists in %1.\n", newClassifier->name())
+
@@ -829,7 +829,7 @@ DEBUG(DBG_SRC) << "acceptProposedAction"; //:TODO:fischer
KMessageBox::error(this, msg, i18n("Operation Name Invalid"), 0);
return;
}
- UMLOperation* newOp = static_cast<UMLOperation*>(op->clone());
+ UMLOperation* newOp = op->clone()->asUMLOperation();
UMLClassifier *oldClassifier = dynamic_cast<UMLClassifier*>(op->parent());
if (oldClassifier) {
@@ -842,7 +842,7 @@ DEBUG(DBG_SRC) << "acceptProposedAction"; //:TODO:fischer
}
else if (t == UMLObject::ot_Attribute) {
DEBUG(DBG_SRC) << "Moving attribute";
- UMLAttribute *att = static_cast<UMLAttribute*>(movingObject);
+ UMLAttribute *att = movingObject->asUMLAttribute();
if (newClassifier->getAttributeList().contains(att)) {
QString msg = i18n("An attribute with that name already exists in %1.\n", newClassifier->name())
+
@@ -850,7 +850,7 @@ DEBUG(DBG_SRC) << "acceptProposedAction"; //:TODO:fischer
KMessageBox::error(this, msg, i18n("Attribute Name Invalid"), 0);
return;
}
- UMLAttribute* newAtt = static_cast<UMLAttribute*>(att->clone());
+ UMLAttribute* newAtt = att->clone()->asUMLAttribute();
UMLClassifier *oldClassifier = dynamic_cast<UMLClassifier*>(att->parent());
if (oldClassifier) {
diff --git a/umbrello/stereotypeswindow.cpp b/umbrello/stereotypeswindow.cpp
index 8035477..c974fae 100644
--- a/umbrello/stereotypeswindow.cpp
+++ b/umbrello/stereotypeswindow.cpp
@@ -55,7 +55,7 @@ StereotypesWindow::~StereotypesWindow()
void StereotypesWindow::modified()
{
- UMLStereotype *o = static_cast<UMLStereotype*>(QObject::sender());
+ UMLStereotype *o = dynamic_cast<UMLStereotype*>(QObject::sender());
if (!o)
return;
int index = UMLApp::app()->document()->stereotypes().indexOf(o);
diff --git a/umbrello/umldoc.cpp b/umbrello/umldoc.cpp
index 2ef4773..77afc14 100644
--- a/umbrello/umldoc.cpp
+++ b/umbrello/umldoc.cpp
@@ -1097,7 +1097,7 @@ UMLClassifier* UMLDoc::findUMLClassifier(const QString &name)
{
//this is used only by code generator so we don't need to look at Datatypes
UMLObject * obj = findUMLObject(name);
- return dynamic_cast<UMLClassifier*>(obj);
+ return obj->asUMLClassifier();
}
/**
@@ -1176,7 +1176,7 @@ bool UMLDoc::isUnique(const QString &name)
// item is in a package so do check only in that
if (parentItem != 0 && Model_Utils::typeIsContainer(parentItem->type())) {
- UMLPackage *parentPkg = static_cast<UMLPackage*>(parentItem->umlObject());
+ UMLPackage *parentPkg = parentItem->umlObject()->asUMLPackage();
return isUnique(name, parentPkg);
}
@@ -1842,39 +1842,39 @@ void UMLDoc::removeUMLObject(UMLObject* umlobject, bool deleteObject)
UMLObject::ObjectType type = umlobject->baseType();
umlobject->setUMLStereotype(0); // triggers possible cleanup of UMLStereotype
- if (dynamic_cast<UMLClassifierListItem*>(umlobject)) {
+ if (umlobject->asUMLClassifierListItem()) {
UMLClassifier* parent = dynamic_cast<UMLClassifier*>(umlobject->parent());
if (parent == 0) {
uError() << "parent of umlobject is NULL";
return;
}
if (type == UMLObject::ot_Operation) {
- parent->removeOperation(static_cast<UMLOperation*>(umlobject));
+ parent->removeOperation(umlobject->asUMLOperation());
if (deleteObject)
- delete static_cast<UMLOperation*>(umlobject);
+ delete umlobject->asUMLOperation();
} else if (type == UMLObject::ot_EnumLiteral) {
- UMLEnum *e = static_cast<UMLEnum*>(parent);
- e->removeEnumLiteral(static_cast<UMLEnumLiteral*>(umlobject));
+ UMLEnum *e = parent->asUMLEnum();
+ e->removeEnumLiteral(umlobject->asUMLEnumLiteral());
} else if (type == UMLObject::ot_EntityAttribute) {
- UMLEntity *ent = static_cast<UMLEntity*>(parent);
- ent->removeEntityAttribute(static_cast<UMLClassifierListItem*>(umlobject));
+ UMLEntity *ent = parent->asUMLEntity();
+ ent->removeEntityAttribute(umlobject->asUMLClassifierListItem());
} else if (type == UMLObject::ot_UniqueConstraint || type == UMLObject::ot_ForeignKeyConstraint ||
type == UMLObject::ot_CheckConstraint) {
- UMLEntity* ent = static_cast<UMLEntity*>(parent);
- ent->removeConstraint(static_cast<UMLEntityConstraint*>(umlobject));
+ UMLEntity* ent = parent->asUMLEntity();
+ ent->removeConstraint(umlobject->asUMLEntityConstraint());
} else {
- UMLClassifier* pClass = dynamic_cast<UMLClassifier*>(parent);
+ UMLClassifier* pClass = parent->asUMLClassifier();
if (pClass == 0) {
uError() << "parent of umlobject has unexpected type "
<< parent->baseType();
return;
}
if (type == UMLObject::ot_Attribute) {
- pClass->removeAttribute(static_cast<UMLAttribute*>(umlobject));
+ pClass->removeAttribute(umlobject->asUMLAttribute());
} else if (type == UMLObject::ot_Template) {
- pClass->removeTemplate(static_cast<UMLTemplate*>(umlobject));
+ pClass->removeTemplate(umlobject->asUMLTemplate());
if (deleteObject)
- delete static_cast<UMLTemplate*>(umlobject);
+ delete umlobject->asUMLTemplate();
} else {
uError() << "umlobject has unexpected type " << type;
}
@@ -1889,7 +1889,7 @@ void UMLDoc::removeUMLObject(UMLObject* umlobject, bool deleteObject)
UMLPackage* pkg = umlobject->umlPackage();
if (pkg) {
// Remove associations that this object may participate in.
- UMLCanvasObject *c = dynamic_cast<UMLCanvasObject*>(umlobject);
+ UMLCanvasObject *c = umlobject->asUMLCanvasObject();
if (c) {
// In the current implementation, all associations live in the
// root folder.
@@ -1906,7 +1906,7 @@ void UMLDoc::removeUMLObject(UMLObject* umlobject, bool deleteObject)
foreach (UMLObject *obj, rootObjects) {
uIgnoreZeroPointer(obj);
if (obj->baseType() == UMLObject::ot_Association) {
- UMLAssociation *assoc = static_cast<UMLAssociation*>(obj);
+ UMLAssociation *assoc = obj->asUMLAssociation();
if (c->hasAssociation(assoc)) {
assocsToRemove.append(assoc);
}
@@ -2614,7 +2614,7 @@ bool UMLDoc::loadUMLObjectsFromXMI(QDomElement& element)
}
pkg = pObject->umlPackage();
if (ot == UMLObject::ot_Stereotype) {
- UMLStereotype *s = static_cast<UMLStereotype*>(pObject);
+ UMLStereotype *s = pObject->asUMLStereotype();
UMLStereotype *exist = findStereotype(pObject->name());
if (exist) {
if (exist->id() == pObject->id()) {
@@ -2878,7 +2878,7 @@ UMLClassifierList UMLDoc::datatypes()
foreach (UMLObject *obj, objects) {
uIgnoreZeroPointer(obj);
if (obj->baseType() == UMLObject::ot_Datatype) {
- datatypeList.append(static_cast<UMLClassifier*>(obj));
+ datatypeList.append(obj->asUMLClassifier());
}
}
return datatypeList;
@@ -2988,7 +2988,7 @@ bool UMLDoc::assignNewIDs(UMLObject* obj)
//If it is a CONCEPT then change the ids of all its operations and attributes
if (obj->baseType() == UMLObject::ot_Class) {
- UMLClassifier *c = static_cast<UMLClassifier*>(obj);
+ UMLClassifier *c = obj->asUMLClassifier();
UMLClassifierListItemList attributes = c->getFilteredList(UMLObject::ot_Attribute);
foreach (UMLObject* listItem, attributes) {
result = assignNewID(listItem->id());
diff --git a/umbrello/umllistview.cpp b/umbrello/umllistview.cpp
index 9e866f4..4d60914 100644
--- a/umbrello/umllistview.cpp
+++ b/umbrello/umllistview.cpp
@@ -427,21 +427,21 @@ void UMLListView::slotMenuSelection(QAction* action, const QPoint &position)
case ListPopupMenu::mt_DisjointSpecialisation:
{
- UMLCategory* catObj = static_cast<UMLCategory*>(currItem->umlObject());
+ UMLCategory* catObj = currItem->umlObject()->asUMLCategory();
catObj->setType(UMLCategory::ct_Disjoint_Specialisation);
}
break;
case ListPopupMenu::mt_OverlappingSpecialisation:
{
- UMLCategory* catObj = static_cast<UMLCategory*>(currItem->umlObject());
+ UMLCategory* catObj = currItem->umlObject()->asUMLCategory();
catObj->setType(UMLCategory::ct_Overlapping_Specialisation);
}
break;
case ListPopupMenu::mt_Union:
{
- UMLCategory* catObj = static_cast<UMLCategory*>(currItem->umlObject());
+ UMLCategory* catObj = currItem->umlObject()->asUMLCategory();
catObj->setType(UMLCategory::ct_Union);
}
break;
@@ -602,7 +602,7 @@ void UMLListView::slotMenuSelection(QAction* action, const QPoint &position)
case ListPopupMenu::mt_Internalize_Folder:
{
UMLListViewItem *current = static_cast<UMLListViewItem*>(currentItem());
- UMLFolder *modelFolder = dynamic_cast<UMLFolder*>(current->umlObject());
+ UMLFolder *modelFolder = current->umlObject()->asUMLFolder();
if (modelFolder == 0) {
uError() << "modelFolder is 0";
return;
@@ -769,14 +769,14 @@ void UMLListView::slotMenuSelection(QAction* action, const QPoint &position)
case ListPopupMenu::mt_ChangeToClass:
{
- UMLClassifier* o = static_cast<UMLClassifier*>(currItem->umlObject());
+ UMLClassifier* o = currItem->umlObject()->asUMLClassifier();
o->setStereotypeCmd(QString());
currItem->updateObject();
}
break;
case ListPopupMenu::mt_ChangeToPackage:
{
- UMLClassifier* o = static_cast<UMLClassifier*>(currItem->umlObject());
+ UMLClassifier* o = currItem->umlObject()->asUMLClassifier();
o->setStereotypeCmd(QString());
o->setBaseType(UMLObject::ot_Package);
currItem->updateObject();
@@ -986,14 +986,14 @@ void UMLListView::slotObjectCreated(UMLObject* object)
const UMLListViewItem::ListViewType lvt = Model_Utils::convert_OT_LVT(object);
QString name = object->name();
if (type == UMLObject::ot_Folder) {
- UMLFolder *f = static_cast<UMLFolder*>(object);
+ UMLFolder *f = object->asUMLFolder();
QString folderFile = f->folderFile();
if (!folderFile.isEmpty())
name.append(QLatin1String(" (") + folderFile + QLatin1Char(')'));
}
newItem = new UMLListViewItem(parentItem, name, lvt, object);
if (mayHaveChildItems(type)) {
- UMLClassifier *c = static_cast<UMLClassifier*>(object);
+ UMLClassifier *c = object->asUMLClassifier();
UMLClassifierListItemList cListItems = c->getFilteredList(UMLObject::ot_UMLObject);
foreach(UMLClassifierListItem *cli, cListItems)
childObjectAdded(cli, c);
@@ -1016,7 +1016,7 @@ void UMLListView::connectNewObjectsSlots(UMLObject* object)
switch (type) {
case UMLObject::ot_Class:
case UMLObject::ot_Interface: {
- UMLClassifier *c = static_cast<UMLClassifier*>(object);
+ UMLClassifier *c = object->asUMLClassifier();
connect(c, SIGNAL(attributeAdded(UMLClassifierListItem*)),
this, SLOT(childObjectAdded(UMLClassifierListItem*)));
connect(c, SIGNAL(attributeRemoved(UMLClassifierListItem*)),
@@ -1033,7 +1033,7 @@ void UMLListView::connectNewObjectsSlots(UMLObject* object)
}
break;
case UMLObject::ot_Enum: {
- UMLEnum *e = static_cast<UMLEnum*>(object);
+ UMLEnum *e = object->asUMLEnum();
connect(e, SIGNAL(enumLiteralAdded(UMLClassifierListItem*)),
this, SLOT(childObjectAdded(UMLClassifierListItem*)));
connect(e, SIGNAL(enumLiteralRemoved(UMLClassifierListItem*)),
@@ -1042,7 +1042,7 @@ void UMLListView::connectNewObjectsSlots(UMLObject* object)
connect(object, SIGNAL(modified()), this, SLOT(slotObjectChanged()));
break;
case UMLObject::ot_Entity: {
- UMLEntity *ent = static_cast<UMLEntity*>(object);
+ UMLEntity *ent = object->asUMLEntity();
connect(ent, SIGNAL(entityAttributeAdded(UMLClassifierListItem*)),
this, SLOT(childObjectAdded(UMLClassifierListItem*)));
connect(ent, SIGNAL(entityAttributeRemoved(UMLClassifierListItem*)),
@@ -1583,7 +1583,7 @@ bool UMLListView::acceptDrag(QDropEvent* event) const
*/
void UMLListView::addAtContainer(UMLListViewItem *item, UMLListViewItem *parent)
{
- UMLCanvasObject *o = static_cast<UMLCanvasObject*>(item->umlObject());
+ UMLCanvasObject *o = item->umlObject()->asUMLCanvasObject();
if (o == 0) {
DEBUG(DBG_SRC) << item->text(0) << ": item's UMLObject is 0";
} else if (Model_Utils::typeIsContainer(parent->type())) {
@@ -1594,7 +1594,7 @@ void UMLListView::addAtContainer(UMLListViewItem *item, UMLListViewItem *parent)
if (oldPkg)
oldPkg->removeObject(o);
*********/
- UMLPackage *pkg = static_cast<UMLPackage*>(parent->umlObject());
+ UMLPackage *pkg = parent->umlObject()->asUMLPackage();
o->setUMLPackage(pkg);
pkg->addObject(o);
} else {
@@ -1782,13 +1782,13 @@ UMLListViewItem * UMLListView::moveObject(Uml::ID::Type srcId, UMLListViewItem::
move->setVisible(false); // (the <listview> XMI may be corrupted)
else
delete move;
- UMLCanvasObject *o = static_cast<UMLCanvasObject*>(newItem->umlObject());
+ UMLCanvasObject *o = newItem->umlObject()->asUMLCanvasObject();
if (o == 0) {
DEBUG(DBG_SRC) << "moveObject: newItem's UMLObject is 0";
} else if (newParentObj == 0) {
uError() << o->name() << ": newParentObj is 0";
} else {
- UMLPackage *pkg = static_cast<UMLPackage*>(newParentObj);
+ UMLPackage *pkg = newParentObj->asUMLPackage();
o->setUMLPackage(pkg);
pkg->addObject(o);
}
@@ -1817,9 +1817,9 @@ UMLListViewItem * UMLListView::moveObject(Uml::ID::Type srcId, UMLListViewItem::
}
UMLClassifier *oldParentClassifier = dynamic_cast<UMLClassifier*>(srcObj->parent());
- UMLClassifier *newParentClassifier = dynamic_cast<UMLClassifier*>(newParentObj);
+ UMLClassifier *newParentClassifier = newParentObj->asUMLClassifier();
if (srcType == UMLListViewItem::lvt_Attribute) {
- UMLAttribute *att = dynamic_cast<UMLAttribute*>(srcObj);
+ UMLAttribute *att = srcObj->asUMLAttribute();
// We can't use the existing 'att' directly
// because its parent is fixed to the old classifier
// and we have no way of changing that:
@@ -1846,7 +1846,7 @@ UMLListViewItem * UMLListView::moveObject(Uml::ID::Type srcId, UMLListViewItem::
delete att;
}
} else {
- UMLOperation *op = dynamic_cast<UMLOperation*>(srcObj);
+ UMLOperation *op = srcObj->asUMLOperation();
// We can't use the existing 'op' directly
// because its parent is fixed to the old classifier
// and we have no way of changing that:
@@ -2144,7 +2144,7 @@ bool UMLListView::isExpandable(UMLListViewItem::ListViewType lvt)
*/
void UMLListView::slotExpanded(QTreeWidgetItem * item)
{
- UMLListViewItem * myItem = static_cast<UMLListViewItem*>(item);
+ UMLListViewItem * myItem = dynamic_cast<UMLListViewItem*>(item);
if (isExpandable(myItem->type())) {
myItem->updateFolder();
}
@@ -2155,7 +2155,7 @@ void UMLListView::slotExpanded(QTreeWidgetItem * item)
*/
void UMLListView::slotCollapsed(QTreeWidgetItem * item)
{
- UMLListViewItem * myItem = static_cast<UMLListViewItem*>(item);
+ UMLListViewItem * myItem = dynamic_cast<UMLListViewItem*>(item);
if (isExpandable(myItem->type())) {
myItem->updateFolder();
}
@@ -2227,7 +2227,7 @@ void UMLListView::addNewItem(UMLListViewItem *parentItem, UMLListViewItem::ListV
}
if (Model_Utils::typeIsClassifierList(type)) {
- UMLClassifier* classifier = dynamic_cast<UMLClassifier*>(parent);
+ UMLClassifier* classifier = parent->asUMLClassifier();
QString name = classifier->uniqChildName(objectType);
UMLObject* object = Object_Factory::createChildObject(classifier, objectType, name);
@@ -2239,14 +2239,14 @@ void UMLListView::addNewItem(UMLListViewItem *parentItem, UMLListViewItem::ListV
// Handle primary key constraints (mark the unique constraint as PK on
// the parent entity)
if (type == UMLListViewItem::lvt_PrimaryKeyConstraint) {
- UMLUniqueConstraint* uuc = static_cast<UMLUniqueConstraint*>(object);
+ UMLUniqueConstraint* uuc = object->asUMLUniqueConstraint();
UMLEntity* ent = static_cast<UMLEntity*>(uuc->parent());
if (ent) {
ent->setAsPrimaryKey(uuc);
}
}
} else {
- UMLPackage* package = dynamic_cast<UMLPackage*>(parent);
+ UMLPackage* package = parent->asUMLPackage();
QString name = Model_Utils::uniqObjectName(objectType, package);
UMLObject* object = Object_Factory::createUMLObject(objectType, name, package);
@@ -2332,7 +2332,7 @@ bool UMLListView::isUnique(UMLListViewItem * item, const QString &name)
UMLListViewItem::ListViewType lvt = parentItem->type();
if (!Model_Utils::typeIsContainer(lvt))
return (m_doc->findUMLObject(name) == 0);
- UMLPackage *pkg = static_cast<UMLPackage*>(parentItem->umlObject());
+ UMLPackage *pkg = parentItem->umlObject()->asUMLPackage();
if (pkg == 0) {
uError() << "internal error - "
<< "parent listviewitem is package but has no UMLObject";
@@ -2351,7 +2351,12 @@ bool UMLListView::isUnique(UMLListViewItem * item, const QString &name)
case UMLListViewItem::lvt_PrimaryKeyConstraint:
case UMLListViewItem::lvt_ForeignKeyConstraint:
case UMLListViewItem::lvt_CheckConstraint: {
- UMLClassifier *parent = static_cast<UMLClassifier*>(parentItem->umlObject());
+ UMLClassifier *parent = parentItem->umlObject()->asUMLClassifier();
+ if (parent == 0) {
+ uError() << "internal error - "
+ << "parent listviewitem is package but has no UMLObject";
+ return true;
+ }
return (parent->findChildObject(name) == 0);
break;
}
@@ -2448,7 +2453,7 @@ bool UMLListView::loadChildrenFromXMI(UMLListViewItem * parent, QDomElement & el
} else if (Model_Utils::typeIsFolder(lvType)) {
// Synthesize the UMLFolder here
UMLObject *umlParent = parent->umlObject();
- UMLPackage *parentPkg = dynamic_cast<UMLPackage*>(umlParent);
+ UMLPackage *parentPkg = umlParent->asUMLPackage();
if (parentPkg == 0) {
uError() << "umlParent(" << umlParent << ") is not a UMLPackage";
domElement = node.toElement();
@@ -2550,7 +2555,7 @@ bool UMLListView::loadChildrenFromXMI(UMLListViewItem * parent, QDomElement & el
if (nID == Uml::ID::None) {
uWarning() << "lvtype " << UMLListViewItem::toString(lvType) << " has id -1";
} else {
- UMLClassifier *classifier = dynamic_cast<UMLClassifier*>(umlObject);
+ UMLClassifier *classifier = umlObject->asUMLClassifier();
if (classifier) {
umlObject = classifier->findChildObjectById(nID);
if (umlObject) {
@@ -2738,7 +2743,7 @@ bool UMLListView::deleteItem(UMLListViewItem *temp)
// we can't delete the datatypeFolder because umbrello will crash without a special handling
return false;
} else if (Model_Utils::typeIsCanvasWidget(lvt) || Model_Utils::typeIsClassifierList(lvt)) {
- UMLPackage *nmSpc = dynamic_cast<UMLPackage*>(object);
+ UMLPackage *nmSpc = object->asUMLPackage();
if (nmSpc) {
UMLObjectList contained = nmSpc->containedObjects();
if (contained.count()) {
@@ -2749,7 +2754,7 @@ bool UMLListView::deleteItem(UMLListViewItem *temp)
return false;
}
}
- UMLCanvasObject *canvasObj = dynamic_cast<UMLCanvasObject*>(object);
+ UMLCanvasObject *canvasObj = object->asUMLCanvasObject();
if (canvasObj) {
// We cannot just delete canvasObj here: What if the object
// is still being used by others (for example, as a parameter
diff --git a/umbrello/umllistviewitem.cpp b/umbrello/umllistviewitem.cpp
index 61b8d4d..edb007e 100644
--- a/umbrello/umllistviewitem.cpp
+++ b/umbrello/umllistviewitem.cpp
@@ -115,7 +115,7 @@ UMLListViewItem::UMLListViewItem(UMLListViewItem * parent, const QString &name,
m_id = Uml::ID::None;
updateFolder();
} else {
- UMLClassifierListItem *umlchild = dynamic_cast<UMLClassifierListItem*>(o);
+ UMLClassifierListItem *umlchild = o->asUMLClassifierListItem();
if (umlchild)
parent->addClassifierListItem(umlchild, this);
updateObject();
@@ -206,12 +206,12 @@ QString UMLListViewItem::toolTip()
return obj->doc();
case UMLObject::ot_Operation:
{
- UMLOperation *op = static_cast<UMLOperation*>(obj);
+ UMLOperation *op = obj->asUMLOperation();
return op->toString(Uml::SignatureType::ShowSig);
}
case UMLObject::ot_Attribute:
{
- UMLAttribute *at = static_cast<UMLAttribute*>(obj);
+ UMLAttribute *at = obj->asUMLAttribute();
return at->toString(Uml::SignatureType::ShowSig);
}
default:
@@ -342,7 +342,7 @@ void UMLListViewItem::updateObject()
UMLObject::ObjectType ot = m_object->baseType();
QString modelObjText = m_object->name();
if (Model_Utils::isClassifierListitem(ot)) {
- UMLClassifierListItem *pNarrowed = static_cast<UMLClassifierListItem*>(m_object);
+ UMLClassifierListItem *pNarrowed = m_object->asUMLClassifierListItem();
modelObjText = pNarrowed->toString(Uml::SignatureType::SigNoVis);
}
setText(modelObjText);
@@ -509,7 +509,7 @@ void UMLListViewItem::slotEditFinished(const QString &newText)
cancelRenameWithMsg();
return;
}
- UMLOperation *op = static_cast<UMLOperation*>(m_object);
+ UMLOperation *op = m_object->asUMLOperation();
UMLClassifier *parent = static_cast<UMLClassifier *>(op->parent());
Model_Utils::OpDescriptor od;
Model_Utils::Parse_Status st = Model_Utils::parseOperation(newText, od, parent);
@@ -572,7 +572,7 @@ void UMLListViewItem::slotEditFinished(const QString &newText)
return;
}
UMLApp::app()->executeCommand(new Uml::CmdRenameUMLObject(m_object, nt.m_name));
- UMLAttribute *pAtt = static_cast<UMLAttribute*>(m_object);
+ UMLAttribute *pAtt = m_object->asUMLAttribute();
pAtt->setType(nt.m_type);
pAtt->setVisibility(vis);
pAtt->setParmKind(nt.m_direction);
@@ -607,7 +607,7 @@ void UMLListViewItem::slotEditFinished(const QString &newText)
}
UMLApp::app()->executeCommand(new Uml::CmdRenameUMLObject(m_object, name));
- UMLEntityConstraint* uec = static_cast<UMLEntityConstraint*>(m_object);
+ UMLEntityConstraint* uec = m_object->asUMLEntityConstraint();
m_label = uec->toString(Uml::SignatureType::SigNoVis);
} else {
KMessageBox::error(0,
@@ -633,7 +633,7 @@ void UMLListViewItem::slotEditFinished(const QString &newText)
return;
}
UMLApp::app()->executeCommand(new Uml::CmdRenameUMLObject(m_object, nt.m_name));
- UMLTemplate *tmpl = static_cast<UMLTemplate*>(m_object);
+ UMLTemplate *tmpl = m_object->asUMLTemplate();
tmpl->setType(nt.m_type);
m_label = tmpl->toString(Uml::SignatureType::SigNoVis);
} else {
@@ -701,7 +701,7 @@ void UMLListViewItem::cancelRenameWithMsg()
#if 0
int UMLListViewItem::compare(QTreeWidgetItem *other, int col, bool ascending) const
{
- UMLListViewItem *ulvi = static_cast<UMLListViewItem*>(other);
+ UMLListViewItem *ulvi = other->asUMLListViewItem();
ListViewType ourType = type();
ListViewType otherType = ulvi->type();
@@ -754,8 +754,8 @@ int UMLListViewItem::compare(QTreeWidgetItem *other, int col, bool ascending) co
#endif
return retval;
}
- UMLClassifierListItem *thisUmlItem = dynamic_cast<UMLClassifierListItem*>(m_object);
- UMLClassifierListItem *otherUmlItem = dynamic_cast<UMLClassifierListItem*>(otherObj);
+ UMLClassifierListItem *thisUmlItem = m_object->asUMLClassifierListItem();
+ UMLClassifierListItem *otherUmlItem = otherObj->asUMLClassifierListItem();
if (thisUmlItem == 0) {
retval = (subItem ? 1 : alphaOrder);
#ifdef DEBUG_LVITEM_INSERTION_ORDER
@@ -892,7 +892,7 @@ void UMLListViewItem::saveToXMI(QDomDocument & qDoc, QDomElement & qElement)
if (m_type != lvt_View)
itemElement.setAttribute(QLatin1String("label"), text(0));
} else if (m_object->baseType() == UMLObject::ot_Folder) {
- extFolder = static_cast<UMLFolder*>(m_object);
+ extFolder = m_object->asUMLFolder();
if (!extFolder->folderFile().isEmpty()) {
itemElement.setAttribute(QLatin1String("open"), QLatin1String("0"));
qElement.appendChild(itemElement);
diff --git a/umbrello/umlmodel/association.cpp b/umbrello/umlmodel/association.cpp
index 9379cc9..9901026 100644
--- a/umbrello/umlmodel/association.cpp
+++ b/umbrello/umlmodel/association.cpp
@@ -238,7 +238,7 @@ bool UMLAssociation::load(QDomElement & element)
m_AssocType == Uml::AssociationType::Category2Parent) {
QString general = element.attribute(QLatin1String("general"));
if (!general.isEmpty()) {
- UMLClassifier *owningClassifier = dynamic_cast<UMLClassifier*>(m_pUMLPackage);
+ UMLClassifier *owningClassifier = m_pUMLPackage->asUMLClassifier();
if (owningClassifier == NULL){
uWarning() << "Cannot load UML2 generalization: m_pUMLPackage is expected "
<< "to be the owning classifier (=client)";
diff --git a/umbrello/umlmodel/attribute.cpp b/umbrello/umlmodel/attribute.cpp
index 76fd426..863b7f9 100644
--- a/umbrello/umlmodel/attribute.cpp
+++ b/umbrello/umlmodel/attribute.cpp
@@ -140,13 +140,13 @@ QString UMLAttribute::toString(Uml::SignatureType::Enum sig)
if (sig == Uml::SignatureType::ShowSig || sig == Uml::SignatureType::SigNoVis) {
// Determine whether the type name needs to be scoped.
- UMLObject *owningObject = static_cast<UMLObject*>(parent());
+ UMLObject *owningObject = parent()->asUMLObject();
if (owningObject->baseType() == UMLObject::ot_Operation) {
// The immediate parent() is the UMLOperation but we want
// the UMLClassifier:
owningObject = static_cast<UMLObject*>(owningObject->parent());
}
- UMLClassifier *ownParent = dynamic_cast<UMLClassifier*>(owningObject);
+ UMLClassifier *ownParent = owningObject->asUMLClassifier();
if (ownParent == NULL) {
uError() << "parent " << owningObject->name()
<< " is not a UMLClassifier";
@@ -184,12 +184,12 @@ QString UMLAttribute::getFullyQualifiedName(const QString& separator,
bool includeRoot /* = false */) const
{
UMLOperation *op = NULL;
- UMLObject *owningObject = static_cast<UMLObject*>(parent());
+ UMLObject *owningObject = parent()->asUMLObject();
if (owningObject->baseType() == UMLObject::ot_Operation) {
- op = static_cast<UMLOperation*>(owningObject);
+ op = owningObject->asUMLOperation();
owningObject = static_cast<UMLObject*>(owningObject->parent());
}
- UMLClassifier *ownParent = dynamic_cast<UMLClassifier*>(owningObject);
+ UMLClassifier *ownParent = owningObject->asUMLClassifier();
if (ownParent == NULL) {
uError() << name() << ": parent " << owningObject->name()
<< " is not a UMLClassifier";
@@ -230,7 +230,7 @@ bool UMLAttribute::operator==(const UMLAttribute &rhs) const
*/
void UMLAttribute::copyInto(UMLObject *lhs) const
{
- UMLAttribute *target = static_cast<UMLAttribute*>(lhs);
+ UMLAttribute *target = lhs->asUMLAttribute();
// call the parent first.
UMLClassifierListItem::copyInto(target);
@@ -247,7 +247,7 @@ void UMLAttribute::copyInto(UMLObject *lhs) const
UMLObject* UMLAttribute::clone() const
{
//FIXME: The new attribute should be slaved to the NEW parent not the old.
- UMLAttribute *clone = new UMLAttribute(static_cast<UMLObject*>(parent()));
+ UMLAttribute *clone = new UMLAttribute(parent()->asUMLObject());
copyInto(clone);
return clone;
@@ -388,7 +388,7 @@ void UMLAttribute::setTemplateParams(const QString& templateParam, UMLClassifier
if (obj != NULL) {
//We want to list only the params that already exist in this document
//If the param doesnt't already exist, we couldn't draw an association anyway
- UMLClassifier* tmpClassifier = static_cast<UMLClassifier*>(obj);
+ UMLClassifier* tmpClassifier = obj->asUMLClassifier();
if (templateParamList.indexOf(tmpClassifier) == -1) {
templateParamList.append(tmpClassifier);
}
diff --git a/umbrello/umlmodel/category.cpp b/umbrello/umlmodel/category.cpp
index 6944036..77bc281 100644
--- a/umbrello/umlmodel/category.cpp
+++ b/umbrello/umlmodel/category.cpp
@@ -44,7 +44,7 @@ void UMLCategory::init()
*/
void UMLCategory::copyInto(UMLObject *lhs) const
{
- UMLCategory *target = static_cast<UMLCategory*>(lhs);
+ UMLCategory *target = lhs->asUMLCategory();
// call the parent first
UMLCanvasObject::copyInto(target);
diff --git a/umbrello/umlmodel/checkconstraint.cpp b/umbrello/umlmodel/checkconstraint.cpp
index dbaab25..b394433 100644
--- a/umbrello/umlmodel/checkconstraint.cpp
+++ b/umbrello/umlmodel/checkconstraint.cpp
@@ -67,7 +67,7 @@ UMLCheckConstraint::~UMLCheckConstraint()
*/
void UMLCheckConstraint::copyInto(UMLObject *lhs) const
{
- UMLCheckConstraint *target = static_cast<UMLCheckConstraint*>(lhs);
+ UMLCheckConstraint *target = lhs->asUMLCheckConstraint();
// call the parent first.
UMLEntityConstraint::copyInto(target);
@@ -82,7 +82,7 @@ void UMLCheckConstraint::copyInto(UMLObject *lhs) const
UMLObject* UMLCheckConstraint::clone() const
{
//FIXME: The new attribute should be slaved to the NEW parent not the old.
- UMLCheckConstraint *clone = new UMLCheckConstraint(static_cast<UMLObject*>(parent()));
+ UMLCheckConstraint *clone = new UMLCheckConstraint(parent()->asUMLObject());
copyInto(clone);
return clone;
}
diff --git a/umbrello/umlmodel/classifier.cpp b/umbrello/umlmodel/classifier.cpp
index 07a7fb6..1400f4d 100644
--- a/umbrello/umlmodel/classifier.cpp
+++ b/umbrello/umlmodel/classifier.cpp
@@ -452,7 +452,7 @@ UMLAttributeList UMLClassifier::getAttributeList() const
foreach (UMLObject* listItem, m_List) {
uIgnoreZeroPointer(listItem);
if (listItem->baseType() == UMLObject::ot_Attribute) {
- attributeList.append(static_cast<UMLAttribute*>(listItem));
+ attributeList.append(listItem->asUMLAttribute());
}
}
return attributeList;
@@ -541,7 +541,7 @@ UMLOperationList UMLClassifier::findOperations(const QString &n)
uIgnoreZeroPointer(obj);
if (obj->baseType() != UMLObject::ot_Operation)
continue;
- UMLOperation *op = static_cast<UMLOperation*>(obj);
+ UMLOperation *op = obj->asUMLOperation();
if (caseSensitive) {
if (obj->name() == n)
list.append(op);
@@ -602,7 +602,7 @@ UMLClassifierList UMLClassifier::findSubClassConcepts (ClassifierType type)
if (a->getObjectId(RoleType::A) != myID)
{
UMLObject* obj = a->getObject(RoleType::A);
- UMLClassifier *concept = dynamic_cast<UMLClassifier*>(obj);
+ UMLClassifier *concept = obj->asUMLClassifier();
if (concept && (type == ALL || (!concept->isInterface() && type == CLASS)
|| (concept->isInterface() && type == INTERFACE))
&& (inheritingConcepts.indexOf(concept) == -1))
@@ -639,7 +639,7 @@ UMLClassifierList UMLClassifier::findSuperClassConcepts (ClassifierType type)
if (a->getObjectId(RoleType::A) == myID)
{
UMLObject* obj = a->getObject(RoleType::B);
- UMLClassifier *concept = dynamic_cast<UMLClassifier*>(obj);
+ UMLClassifier *concept = obj->asUMLClassifier();
if (concept && (type == ALL || (!concept->isInterface() && type == CLASS)
|| (concept->isInterface() && type == INTERFACE))
&& (parentConcepts.indexOf(concept) == -1))
@@ -664,7 +664,7 @@ bool UMLClassifier::operator==(const UMLClassifier & rhs) const
*/
void UMLClassifier::copyInto(UMLObject *lhs) const
{
- UMLClassifier *target = static_cast<UMLClassifier*>(lhs);
+ UMLClassifier *target = lhs->asUMLClassifier();
UMLCanvasObject::copyInto(target);
target->setBaseType(m_BaseType);
// CHECK: association property m_pClassAssoc is not copied
@@ -701,7 +701,9 @@ bool UMLClassifier::resolveRef()
{ .... }
****/
if (obj->resolveRef()) {
- UMLClassifierListItem *cli = static_cast<UMLClassifierListItem*>(obj);
+ UMLClassifierListItem *cli = obj->asUMLClassifierListItem();
+ if (!cli)
+ return false;
switch (cli->baseType()) {
case UMLObject::ot_Attribute:
emit attributeAdded(cli);
@@ -812,7 +814,7 @@ UMLAttribute* UMLClassifier::addAttribute(const QString &name, Uml::ID::Type id
foreach (UMLObject* obj, m_List) {
uIgnoreZeroPointer(obj);
if (obj->baseType() == UMLObject::ot_Attribute && obj->name() == name)
- return static_cast<UMLAttribute*>(obj);
+ return obj->asUMLAttribute();
}
Uml::Visibility::Enum scope = Settings::optionState().classState.defaultAttributeScope;
UMLAttribute *a = new UMLAttribute(this, name, id, scope);
@@ -963,7 +965,7 @@ UMLOperationList UMLClassifier::getOpList(bool includeInherited, UMLClassifierSe
foreach (UMLObject* li, m_List) {
uIgnoreZeroPointer(li);
if (li->baseType() == ot_Operation) {
- ops.append(static_cast<UMLOperation*>(li));
+ ops.append(li->asUMLOperation());
}
}
if (includeInherited) {
@@ -1024,7 +1026,7 @@ UMLClassifierListItemList UMLClassifier::getFilteredList(UMLObject::ObjectType o
if (!o || o->baseType() == UMLObject::ot_Association) {
continue;
}
- UMLClassifierListItem *listItem = static_cast<UMLClassifierListItem*>(o);
+ UMLClassifierListItem *listItem = o->asUMLClassifierListItem();
if (ot == UMLObject::ot_UMLObject || listItem->baseType() == ot) {
resultList.append(listItem);
}
@@ -1170,7 +1172,7 @@ UMLTemplateList UMLClassifier::getTemplateList() const
foreach (UMLObject* listItem, m_List) {
uIgnoreZeroPointer(listItem);
if (listItem->baseType() == UMLObject::ot_Template) {
- templateList.append(static_cast<UMLTemplate*>(listItem));
+ templateList.append(listItem->asUMLTemplate());
}
}
return templateList;
@@ -1203,7 +1205,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
}
switch (item->baseType()) {
case UMLObject::ot_Operation: {
- if (removeOperation(dynamic_cast<UMLOperation*>(item)) < 0) {
+ if (removeOperation(item->asUMLOperation()) < 0) {
index = -1;
}
break;
@@ -1231,7 +1233,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
case UMLObject::ot_EnumLiteral: {
UMLEnumLiteral *el = dynamic_cast<UMLEnumLiteral*>(m_List.takeAt(index).data());
if (el) {
- UMLEnum *e = static_cast<UMLEnum*>(this);
+ UMLEnum *e = this->asUMLEnum();
e->signalEnumLiteralRemoved(el);
UMLObject::emitModified();
} else {
@@ -1242,7 +1244,7 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
case UMLObject::ot_EntityAttribute: {
UMLEntityAttribute* el = dynamic_cast<UMLEntityAttribute*>(m_List.takeAt(index).data());
if (el) {
- UMLEntity *e = static_cast<UMLEntity*>(this);
+ UMLEntity *e = this->asUMLEntity();
e->signalEntityAttributeRemoved(el);
UMLObject::emitModified();
} else {
@@ -1545,17 +1547,17 @@ bool UMLClassifier::load(QDomElement& element)
if (child->loadFromXMI(element)) {
switch (child->baseType()) {
case UMLObject::ot_Template:
- addTemplate(static_cast<UMLTemplate*>(child));
+ addTemplate(child->asUMLTemplate());
break;
case UMLObject::ot_Operation:
- if (! addOperation(static_cast<UMLOperation*>(child))) {
+ if (! addOperation(child->asUMLOperation())) {
uError() << "error from addOperation(op)";
delete child;
totalSuccess = false;
}
break;
case UMLObject::ot_Attribute:
- addAttribute(static_cast<UMLAttribute*>(child));
+ addAttribute(child->asUMLAttribute());
break;
default:
break;
diff --git a/umbrello/umlmodel/classifierlistitem.cpp b/umbrello/umlmodel/classifierlistitem.cpp
index 5c997e3..89cd61e 100644
--- a/umbrello/umlmodel/classifierlistitem.cpp
+++ b/umbrello/umlmodel/classifierlistitem.cpp
@@ -39,7 +39,7 @@ UMLClassifierListItem::UMLClassifierListItem(UMLObject *parent,
: UMLObject(parent, name, id)
{
UMLObject *parentObj = const_cast<UMLObject*>(parent);
- UMLClassifier *pc = dynamic_cast<UMLClassifier*>(parentObj);
+ UMLClassifier *pc = parentObj->asUMLClassifier();
if (pc)
UMLObject::setUMLPackage(pc);
}
@@ -58,7 +58,7 @@ UMLClassifierListItem::UMLClassifierListItem(UMLObject *parent)
: UMLObject(parent)
{
UMLObject *parentObj = const_cast<UMLObject*>(parent);
- UMLClassifier *pc = dynamic_cast<UMLClassifier*>(parentObj);
+ UMLClassifier *pc = parentObj->asUMLClassifier();
if (pc)
UMLObject::setUMLPackage(pc);
}
diff --git a/umbrello/umlmodel/entity.cpp b/umbrello/umlmodel/entity.cpp
index 08e641d..84fd046 100644
--- a/umbrello/umlmodel/entity.cpp
+++ b/umbrello/umlmodel/entity.cpp
@@ -69,7 +69,7 @@ bool UMLEntity::operator==(const UMLEntity& rhs) const
*/
void UMLEntity::copyInto(UMLObject *lhs) const
{
- UMLEntity *target = static_cast<UMLEntity*>(lhs);
+ UMLEntity *target = lhs->asUMLEntity();
// call base class copy function
UMLClassifier::copyInto(target);
@@ -413,7 +413,7 @@ bool UMLEntity::resolveRef()
for (UMLObjectListIt oit(m_List); oit.hasNext();) {
UMLObject* obj = oit.next();
if (obj->resolveRef()) {
- UMLClassifierListItem *cli = static_cast<UMLClassifierListItem*>(obj);
+ UMLClassifierListItem *cli = obj->asUMLClassifierListItem();
switch (cli->baseType()) {
case UMLObject::ot_EntityAttribute:
emit entityAttributeAdded(cli);
@@ -623,12 +623,12 @@ void UMLEntity::slotEntityAttributeRemoved(UMLClassifierListItem* cli)
// this function does some cleanjobs related to this entity when the attribute is
// removed, like, removing the attribute from all constraints
- UMLEntityAttribute* entAtt = static_cast<UMLEntityAttribute*>(cli);
+ UMLEntityAttribute* entAtt = cli->asUMLEntityAttribute();
if (cli) {
UMLClassifierListItemList ual = this->getFilteredList(UMLObject::ot_UniqueConstraint);
foreach(UMLClassifierListItem* ucli, ual) {
- UMLUniqueConstraint* uuc = static_cast<UMLUniqueConstraint*>(ucli);
+ UMLUniqueConstraint* uuc = ucli->asUMLUniqueConstraint();
if (uuc->hasEntityAttribute(entAtt)) {
uuc->removeEntityAttribute(entAtt);
}
@@ -693,7 +693,7 @@ UMLEntityAttributeList UMLEntity::getEntityAttributes() const
for (UMLObjectListIt lit(m_List); lit.hasNext();) {
UMLObject *listItem = lit.next();
if (listItem->baseType() == UMLObject::ot_EntityAttribute) {
- entityAttributeList.append(static_cast<UMLEntityAttribute*>(listItem));
+ entityAttributeList.append(listItem->asUMLEntityAttribute());
}
}
return entityAttributeList;
diff --git a/umbrello/umlmodel/entityattribute.cpp b/umbrello/umlmodel/entityattribute.cpp
index 94640fa..a41f604 100644
--- a/umbrello/umlmodel/entityattribute.cpp
+++ b/umbrello/umlmodel/entityattribute.cpp
@@ -209,7 +209,7 @@ bool UMLEntityAttribute::operator==(const UMLEntityAttribute &rhs) const
*/
void UMLEntityAttribute::copyInto(UMLObject *lhs) const
{
- UMLEntityAttribute *target = static_cast<UMLEntityAttribute*>(lhs);
+ UMLEntityAttribute *target = lhs->asUMLEntityAttribute();
// call the parent first.
UMLClassifierListItem::copyInto(target);
diff --git a/umbrello/umlmodel/enumliteral.cpp b/umbrello/umlmodel/enumliteral.cpp
index b2966f7..2f558a3 100644
--- a/umbrello/umlmodel/enumliteral.cpp
+++ b/umbrello/umlmodel/enumliteral.cpp
@@ -115,7 +115,7 @@ bool UMLEnumLiteral::operator==(const UMLEnumLiteral& rhs) const
*/
void UMLEnumLiteral::copyInto(UMLObject *lhs) const
{
- UMLEnumLiteral *target = static_cast<UMLEnumLiteral*>(lhs);
+ UMLEnumLiteral *target = lhs->asUMLEnumLiteral();
UMLClassifierListItem::copyInto(lhs);
target->m_Value = m_Value;
diff --git a/umbrello/umlmodel/folder.cpp b/umbrello/umlmodel/folder.cpp
index 5456b92..b32110a 100644
--- a/umbrello/umlmodel/folder.cpp
+++ b/umbrello/umlmodel/folder.cpp
@@ -108,7 +108,7 @@ void UMLFolder::appendViews(UMLViewList& viewList, bool includeNested)
foreach (UMLObject* o, m_objects) {
uIgnoreZeroPointer(o);
if (o->baseType() == UMLObject::ot_Folder) {
- UMLFolder *f = static_cast<UMLFolder*>(o);
+ UMLFolder *f = o->asUMLFolder();
f->appendViews(viewList);
}
}
@@ -128,7 +128,7 @@ void UMLFolder::activateViews()
foreach (UMLObject* o, m_objects) {
uIgnoreZeroPointer(o);
if (o->baseType() == UMLObject::ot_Folder) {
- UMLFolder *f = static_cast<UMLFolder*>(o);
+ UMLFolder *f = o->asUMLFolder();
f->activateViews();
}
}
@@ -165,7 +165,7 @@ UMLView *UMLFolder::findView(Uml::ID::Type id)
if (o->baseType() != UMLObject::ot_Folder) {
continue;
}
- UMLFolder *f = static_cast<UMLFolder*>(o);
+ UMLFolder *f = o->asUMLFolder();
v = f->findView(id);
if (v) {
break;
@@ -196,7 +196,7 @@ UMLView *UMLFolder::findView(Uml::DiagramType::Enum type, const QString &name, b
if (o->baseType() != UMLObject::ot_Folder) {
continue;
}
- UMLFolder *f = static_cast<UMLFolder*>(o);
+ UMLFolder *f = o->asUMLFolder();
v = f->findView(type, name, searchAllScopes);
if (v) {
break;
@@ -226,7 +226,7 @@ void UMLFolder::removeAllViews()
uIgnoreZeroPointer(o);
if (o->baseType() != UMLObject::ot_Folder)
continue;
- UMLFolder *f = static_cast<UMLFolder*>(o);
+ UMLFolder *f = o->asUMLFolder();
f->removeAllViews();
}
diff --git a/umbrello/umlmodel/foreignkeyconstraint.cpp b/umbrello/umlmodel/foreignkeyconstraint.cpp
index 992c8ac..36a766c 100644
--- a/umbrello/umlmodel/foreignkeyconstraint.cpp
+++ b/umbrello/umlmodel/foreignkeyconstraint.cpp
@@ -54,7 +54,7 @@ void UMLForeignKeyConstraint::init()
// should be NULL actually
// self referencing assigned to protect default behaviour
- m_ReferencedEntity = static_cast<UMLEntity*>(parent());
+ m_ReferencedEntity = parent()->asUMLEntity();
m_UpdateAction = uda_NoAction;
m_DeleteAction = uda_NoAction;
@@ -90,7 +90,7 @@ UMLForeignKeyConstraint::~UMLForeignKeyConstraint()
*/
void UMLForeignKeyConstraint::copyInto(UMLObject *lhs) const
{
- UMLForeignKeyConstraint *target = static_cast<UMLForeignKeyConstraint*>(lhs);
+ UMLForeignKeyConstraint *target = lhs->asUMLForeignKeyConstraint();
// call the parent first.
UMLEntityConstraint::copyInto(target);
@@ -108,7 +108,7 @@ void UMLForeignKeyConstraint::copyInto(UMLObject *lhs) const
UMLObject* UMLForeignKeyConstraint::clone() const
{
//FIXME: The new attribute should be slaved to the NEW parent not the old.
- UMLForeignKeyConstraint *clone = new UMLForeignKeyConstraint(static_cast<UMLObject*>(parent()));
+ UMLForeignKeyConstraint *clone = new UMLForeignKeyConstraint(parent()->asUMLObject());
copyInto(clone);
return clone;
}
@@ -274,7 +274,7 @@ bool UMLForeignKeyConstraint::load(QDomElement & element)
Uml::ID::Type referencedEntityId = Uml::ID::fromString(element.attribute(QLatin1String("referencedEntity")));
UMLObject* obj = doc->findObjectById(referencedEntityId);
- m_ReferencedEntity = static_cast<UMLEntity*>(obj);
+ m_ReferencedEntity = obj->asUMLEntity();
if (m_ReferencedEntity == NULL) {
// save for resolving later
@@ -299,9 +299,9 @@ bool UMLForeignKeyConstraint::load(QDomElement & element)
Uml::ID::Type keyId = Uml::ID::fromString(xmiKey);
Uml::ID::Type valueId = Uml::ID::fromString(xmiValue);
- UMLEntity* parentEntity = static_cast<UMLEntity*>(parent());
+ UMLEntity* parentEntity = parent()->asUMLEntity();
UMLObject* keyObj = parentEntity->findChildObjectById(keyId);
- UMLEntityAttribute* key = static_cast<UMLEntityAttribute*>(keyObj);
+ UMLEntityAttribute* key = keyObj->asUMLEntityAttribute();
if (keyObj == NULL) {
uWarning() << "unable to resolve foreign key referencing attribute " << xmiKey;
@@ -314,7 +314,7 @@ bool UMLForeignKeyConstraint::load(QDomElement & element)
if (valueObj == NULL) {
uWarning() << "unable to resolve foreign key referenced attribute" << xmiValue;
} else {
- m_AttributeMap[key] = static_cast<UMLEntityAttribute*>(valueObj);
+ m_AttributeMap[key] = valueObj->asUMLEntityAttribute();
}
}
@@ -382,7 +382,7 @@ bool UMLForeignKeyConstraint::resolveRef()
//resolve the referenced entity
if (!Uml::ID::toString(m_pReferencedEntityID).isEmpty()) {
UMLObject* obj = doc->findObjectById(m_pReferencedEntityID);
- m_ReferencedEntity = static_cast<UMLEntity*>(obj);
+ m_ReferencedEntity = obj->asUMLEntity();
if (m_ReferencedEntity == NULL) {
success = false;
}
@@ -392,7 +392,7 @@ bool UMLForeignKeyConstraint::resolveRef()
for (i = m_pEntityAttributeIDMap.begin(); i!= m_pEntityAttributeIDMap.end() ; ++i) {
if (!Uml::ID::toString(i.value()).isEmpty()) {
UMLObject* obj = doc->findObjectById(i.value());
- m_AttributeMap[i.key()] = static_cast<UMLEntityAttribute*>(obj);
+ m_AttributeMap[i.key()] = obj->asUMLEntityAttribute();
if (m_AttributeMap[i.key()] == NULL) {
success = false;
}
diff --git a/umbrello/umlmodel/operation.cpp b/umbrello/umlmodel/operation.cpp
index 6803eda..d43f170 100644
--- a/umbrello/umlmodel/operation.cpp
+++ b/umbrello/umlmodel/operation.cpp
@@ -227,7 +227,7 @@ QString UMLOperation::toString(Uml::SignatureType::Enum sig)
} else if (parameterlessOpNeedsParentheses) {
s.append(QLatin1String("()"));
}
- UMLClassifier *ownParent = static_cast<UMLClassifier*>(parent());
+ UMLClassifier *ownParent = parent()->asUMLClassifier();
QString returnType;
UMLClassifier *retType = UMLClassifierListItem::getType();
if (retType) {
@@ -309,7 +309,7 @@ bool UMLOperation::operator==(const UMLOperation & rhs) const
*/
void UMLOperation::copyInto(UMLObject *lhs) const
{
- UMLOperation *target = static_cast<UMLOperation*>(lhs);
+ UMLOperation *target = lhs->asUMLOperation();
UMLClassifierListItem::copyInto(target);
@@ -322,7 +322,7 @@ void UMLOperation::copyInto(UMLObject *lhs) const
UMLObject* UMLOperation::clone() const
{
//FIXME: The new operation should be slaved to the NEW parent not the old.
- UMLOperation *clone = new UMLOperation(static_cast<UMLClassifier*>(parent()));
+ UMLOperation *clone = new UMLOperation(parent()->asUMLClassifier());
copyInto(clone);
return clone;
diff --git a/umbrello/umlmodel/package.cpp b/umbrello/umlmodel/package.cpp
index 42577ac..b3ca58f 100644
--- a/umbrello/umlmodel/package.cpp
+++ b/umbrello/umlmodel/package.cpp
@@ -59,7 +59,7 @@ UMLPackage::~UMLPackage()
*/
void UMLPackage::copyInto(UMLObject *lhs) const
{
- UMLPackage *target = static_cast<UMLPackage*>(lhs);
+ UMLPackage *target = lhs->asUMLPackage();
UMLCanvasObject::copyInto(target);
@@ -94,7 +94,7 @@ void UMLPackage::addAssocToConcepts(UMLAssociation* assoc)
UMLObject *o = NULL;
for (UMLObjectListIt oit(m_objects); oit.hasNext();) {
o = oit.next();
- UMLCanvasObject *c = dynamic_cast<UMLCanvasObject*>(o);
+ UMLCanvasObject *c = o->asUMLCanvasObject();
if (c == NULL)
continue;
if (AId == c->id() || (BId == c->id())) {
@@ -103,7 +103,7 @@ void UMLPackage::addAssocToConcepts(UMLAssociation* assoc)
else
c->addAssociationEnd(assoc);
}
- UMLPackage *pkg = dynamic_cast<UMLPackage*>(c);
+ UMLPackage *pkg = c->asUMLPackage();
if (pkg)
pkg->addAssocToConcepts(assoc);
}
@@ -118,11 +118,11 @@ void UMLPackage::removeAssocFromConcepts(UMLAssociation *assoc)
UMLObject *o = 0;
for (UMLObjectListIt oit(m_objects); oit.hasNext();) {
o = oit.next();
- UMLCanvasObject *c = dynamic_cast<UMLCanvasObject*>(o);
+ UMLCanvasObject *c = o->asUMLCanvasObject();
if (c) {
if (c->hasAssociation(assoc))
c->removeAssociationEnd(assoc);
- UMLPackage *pkg = dynamic_cast<UMLPackage*>(c);
+ UMLPackage *pkg = c->asUMLPackage();
if (pkg)
pkg->removeAssocFromConcepts(assoc);
}
@@ -151,7 +151,7 @@ bool UMLPackage::addObject(UMLObject *pObject)
return false;
}
if (pObject->baseType() == UMLObject::ot_Association) {
- UMLAssociation *assoc = static_cast<UMLAssociation*>(pObject);
+ UMLAssociation *assoc = pObject->asUMLAssociation();
// Adding the UMLAssociation at the participating concepts is done
// again later (in UMLAssociation::resolveRef()) if they are not yet
// known right here.
@@ -201,7 +201,7 @@ void UMLPackage::removeObject(UMLObject *pObject)
{
if (pObject->baseType() == UMLObject::ot_Association) {
UMLObject *o = const_cast<UMLObject*>(pObject);
- UMLAssociation *assoc = static_cast<UMLAssociation*>(o);
+ UMLAssociation *assoc = o->asUMLAssociation();
removeAssocFromConcepts(assoc);
}
if (m_objects.indexOf(pObject) == -1)
@@ -221,7 +221,7 @@ void UMLPackage::removeAllObjects()
UMLObject *o = NULL;
while (!m_objects.isEmpty() && (o = m_objects.first()) != NULL) {
- UMLPackage *pkg = dynamic_cast<UMLPackage*>(o);
+ UMLPackage *pkg = o->asUMLPackage();
if (pkg)
pkg->removeAllObjects();
removeObject(o);
@@ -286,9 +286,9 @@ void UMLPackage::appendPackages(UMLPackageList& packages, bool includeNested)
uIgnoreZeroPointer(o);
ObjectType ot = o->baseType();
if (ot == ot_Package || ot == ot_Folder) {
- packages.append(static_cast<UMLPackage*>(o));
+ packages.append(o->asUMLPackage());
if (includeNested) {
- UMLPackage *inner = static_cast<UMLPackage*>(o);
+ UMLPackage *inner = o->asUMLPackage();
inner->appendPackages(packages);
}
}
@@ -314,7 +314,7 @@ void UMLPackage::appendClassifiers(UMLClassifierList& classifiers,
ot == ot_Datatype || ot == ot_Enum || ot == ot_Entity) {
classifiers.append((UMLClassifier *)o);
} else if (includeNested && (ot == ot_Package || ot == ot_Folder)) {
- UMLPackage *inner = static_cast<UMLPackage *>(o);
+ UMLPackage *inner = o->asUMLPackage ();
inner->appendClassifiers(classifiers);
}
}
@@ -336,10 +336,10 @@ void UMLPackage::appendEntities(UMLEntityList& entities,
uIgnoreZeroPointer(o);
ObjectType ot = o->baseType();
if (ot == ot_Entity) {
- UMLEntity *c = static_cast<UMLEntity*>(o);
+ UMLEntity *c = o->asUMLEntity();
entities.append(c);
} else if (includeNested && (ot == ot_Package || ot == ot_Folder)) {
- UMLPackage *inner = static_cast<UMLPackage *>(o);
+ UMLPackage *inner = o->asUMLPackage ();
inner->appendEntities(entities);
}
}
@@ -361,10 +361,10 @@ void UMLPackage::appendClassesAndInterfaces(UMLClassifierList& classifiers,
uIgnoreZeroPointer(o);
ObjectType ot = o->baseType();
if (ot == ot_Class || ot == ot_Interface) {
- UMLClassifier *c = static_cast<UMLClassifier*>(o);
+ UMLClassifier *c = o->asUMLClassifier();
classifiers.append(c);
} else if (includeNested && (ot == ot_Package || ot == ot_Folder)) {
- UMLPackage *inner = static_cast<UMLPackage *>(o);
+ UMLPackage *inner = o->asUMLPackage ();
inner->appendClassesAndInterfaces(classifiers);
}
}
diff --git a/umbrello/umlmodel/umlcanvasobject.cpp b/umbrello/umlmodel/umlcanvasobject.cpp
index 58b91a7..87f9997 100644
--- a/umbrello/umlmodel/umlcanvasobject.cpp
+++ b/umbrello/umlmodel/umlcanvasobject.cpp
@@ -67,7 +67,7 @@ UMLAssociationList UMLCanvasObject::getSpecificAssocs(Uml::AssociationType::Enum
uIgnoreZeroPointer(o);
if (o->baseType() != UMLObject::ot_Association)
continue;
- UMLAssociation *a = static_cast<UMLAssociation*>(o);
+ UMLAssociation *a = o->asUMLAssociation();
if (a->getAssocType() == assocType)
list.append(a);
}
@@ -137,18 +137,18 @@ void UMLCanvasObject::removeAllAssociationEnds()
if (o->baseType() != UMLObject::ot_Association) {
continue;
}
- UMLAssociation *assoc = static_cast<UMLAssociation*>(o);
+ UMLAssociation *assoc = o->asUMLAssociation();
//umldoc->slotRemoveUMLObject(assoc);
UMLObject* objA = assoc->getObject(Uml::RoleType::A);
UMLObject* objB = assoc->getObject(Uml::RoleType::B);
- UMLCanvasObject *roleAObj = dynamic_cast<UMLCanvasObject*>(objA);
+ UMLCanvasObject *roleAObj = objA->asUMLCanvasObject();
if (roleAObj) {
roleAObj->removeAssociationEnd(assoc);
} else if (objA) {
DEBUG(DBG_SRC) << name() << ": objA " << objA->name() << " is not a UMLCanvasObject";
} else
DEBUG(DBG_SRC) << name() << "): objA is NULL";
- UMLCanvasObject *roleBObj = dynamic_cast<UMLCanvasObject*>(objB);
+ UMLCanvasObject *roleBObj = objB->asUMLCanvasObject();
if (roleBObj) {
roleBObj->removeAssociationEnd(assoc);
} else if (objB) {
@@ -343,7 +343,7 @@ UMLAssociationList UMLCanvasObject::getAssociations()
uIgnoreZeroPointer(o);
if (o->baseType() != UMLObject::ot_Association)
continue;
- UMLAssociation *assoc = static_cast<UMLAssociation*>(o);
+ UMLAssociation *assoc = o->asUMLAssociation();
assocs.append(assoc);
}
return assocs;
diff --git a/umbrello/umlmodel/umlobject.cpp b/umbrello/umlmodel/umlobject.cpp
index 288ae47..2c30b03 100644
--- a/umbrello/umlmodel/umlobject.cpp
+++ b/umbrello/umlmodel/umlobject.cpp
@@ -1193,6 +1193,7 @@ UMLCanvasObject* UMLObject::asUMLCanvasObject() { return dynamic_cast<UMLCanvasO
UMLCategory* UMLObject::asUMLCategory() { return dynamic_cast<UMLCategory*>(this); }
UMLCheckConstraint* UMLObject::asUMLCheckConstraint() { return dynamic_cast<UMLCheckConstraint*>(this); }
UMLClassifier* UMLObject::asUMLClassifier() { return dynamic_cast<UMLClassifier*>(this); }
+UMLClassifierListItem *UMLObject::asUMLClassifierListItem() { return dynamic_cast<UMLClassifierListItem*>(this); }
UMLComponent* UMLObject::asUMLComponent() { return dynamic_cast<UMLComponent*>(this); }
UMLEntity* UMLObject::asUMLEntity() { return dynamic_cast<UMLEntity*>(this); }
UMLEntityAttribute* UMLObject::asUMLEntityAttribute() { return dynamic_cast<UMLEntityAttribute*>(this); }
diff --git a/umbrello/umlmodel/umlobject.h b/umbrello/umlmodel/umlobject.h
index fac1780..ff5cb3f 100644
--- a/umbrello/umlmodel/umlobject.h
+++ b/umbrello/umlmodel/umlobject.h
@@ -29,6 +29,7 @@ class UMLCanvasObject;
class UMLCategory;
class UMLCheckConstraint;
class UMLClassifier;
+class UMLClassifierListItem;
class UMLClassifierSet;
class UMLComponent;
class UMLEntity;
@@ -216,6 +217,7 @@ public:
UMLCategory* asUMLCategory();
UMLCheckConstraint* asUMLCheckConstraint();
UMLClassifier* asUMLClassifier();
+ UMLClassifierListItem* asUMLClassifierListItem();
UMLClassifierSet* asUMLClassifierSet();
UMLComponent* asUMLComponent();
UMLEntity* asUMLEntity();
diff --git a/umbrello/umlmodel/umlrole.cpp b/umbrello/umlmodel/umlrole.cpp
index 266798d..6a6aad6 100644
--- a/umbrello/umlmodel/umlrole.cpp
+++ b/umbrello/umlmodel/umlrole.cpp
@@ -112,7 +112,7 @@ void UMLRole::setObject(UMLObject *obj)
// parent objects. In fact, there is probably good reason
// to only take UMLClassifiers here, but I'll leave it more open
// for the time being. -b.t.
- if (obj && dynamic_cast<UMLRole*>(obj)) {
+ if (obj && obj->asUMLRole()) {
uError() << "UMLRole(" << Uml::ID::toString(m_nId) << ") cannot setObject() to another UMLRole("
<< Uml::ID::toString(obj->id()) << ")";
return;
diff --git a/umbrello/umlmodel/uniqueconstraint.cpp b/umbrello/umlmodel/uniqueconstraint.cpp
index 1abf4a9..c04f06e 100644
--- a/umbrello/umlmodel/uniqueconstraint.cpp
+++ b/umbrello/umlmodel/uniqueconstraint.cpp
@@ -72,7 +72,7 @@ UMLUniqueConstraint::~UMLUniqueConstraint()
*/
void UMLUniqueConstraint::copyInto(UMLObject *lhs) const
{
- UMLUniqueConstraint *target = static_cast<UMLUniqueConstraint*>(lhs);
+ UMLUniqueConstraint *target = lhs->asUMLUniqueConstraint();
// call the parent first.
UMLEntityConstraint::copyInto(target);
@@ -98,7 +98,7 @@ void UMLUniqueConstraint::copyInto(UMLObject *lhs) const
UMLObject* UMLUniqueConstraint::clone() const
{
//FIXME: The new attribute should be slaved to the NEW parent not the old.
- UMLUniqueConstraint *clone = new UMLUniqueConstraint(static_cast<UMLObject*>(parent()));
+ UMLUniqueConstraint *clone = new UMLUniqueConstraint(parent()->asUMLObject());
copyInto(clone);
return clone;
}
@@ -116,7 +116,7 @@ QString UMLUniqueConstraint::toString(Uml::SignatureType::Enum sig)
if (sig == Uml::SignatureType::ShowSig || sig == Uml::SignatureType::SigNoVis) {
s = name() + QLatin1Char(':');
- if (static_cast<UMLEntity*>(parent())->isPrimaryKey(this)) {
+ if (parent()->asUMLEntity()->isPrimaryKey(this)) {
s += QLatin1String("Primary Key (");
} else {
s += QLatin1String("Unique (");
@@ -150,7 +150,7 @@ void UMLUniqueConstraint::saveToXMI(QDomDocument & qDoc, QDomElement & qElement)
{
QDomElement uniqueConstraintElement = UMLObject::save(QLatin1String("UML:UniqueConstraint"), qDoc);
- UMLEntity* parentEnt = static_cast<UMLEntity*>(parent());
+ UMLEntity* parentEnt = parent()->asUMLEntity();
if (parentEnt->isPrimaryKey(this)) {
uniqueConstraintElement.setAttribute(QLatin1String("isPrimary"), QLatin1String("1"));
} else {
@@ -179,7 +179,7 @@ bool UMLUniqueConstraint::showPropertiesDialog(QWidget* parent)
bool UMLUniqueConstraint::load(QDomElement & element)
{
int isPrimary = element.attribute(QLatin1String("isPrimary"), QLatin1String("0")).toInt();
- UMLEntity* parentEnt = static_cast<UMLEntity*>(parent());
+ UMLEntity* parentEnt = parent()->asUMLEntity();
if (isPrimary == 1) {
parentEnt->setAsPrimaryKey(this);
@@ -198,7 +198,7 @@ bool UMLUniqueConstraint::load(QDomElement & element)
QString attName = tempElement.attribute(QLatin1String("name"));
UMLObject* obj = parentEnt->findChildObject(attName);
- UMLEntityAttribute* entAtt = static_cast<UMLEntityAttribute*>(obj);
+ UMLEntityAttribute* entAtt = obj->asUMLEntityAttribute();
if (entAtt == NULL)
continue;
diff --git a/umbrello/umlscene.cpp b/umbrello/umlscene.cpp
index 01cbe14..0295abe 100644
--- a/umbrello/umlscene.cpp
+++ b/umbrello/umlscene.cpp
@@ -2222,7 +2222,7 @@ void UMLScene::createAutoAssociations(UMLWidget * widget)
UMLObject *tmpUmlObj = widget->umlObject();
if (tmpUmlObj == NULL)
return;
- UMLCanvasObject *umlObj = dynamic_cast<UMLCanvasObject*>(tmpUmlObj);
+ UMLCanvasObject *umlObj = tmpUmlObj->asUMLCanvasObject();
if (umlObj == NULL)
return;
const UMLAssociationList& umlAssocs = umlObj->getAssociations();
@@ -2243,9 +2243,9 @@ void UMLScene::createAutoAssociations(UMLWidget * widget)
continue;
}
if (roleAObj->id() == myID) {
- other = static_cast<UMLCanvasObject*>(roleBObj);
+ other = roleBObj->asUMLCanvasObject();
} else if (roleBObj->id() == myID) {
- other = static_cast<UMLCanvasObject*>(roleAObj);
+ other = roleAObj->asUMLCanvasObject();
} else {
DEBUG(DBG_SRC) << "Cannot find own object "
<< Uml::ID::toString(myID) << " in UMLAssoc "
@@ -2317,7 +2317,7 @@ void UMLScene::createAutoAssociations(UMLWidget * widget)
if (t == UMLObject::ot_Package || t == UMLObject::ot_Class ||
t == UMLObject::ot_Interface || t == UMLObject::ot_Component) {
// for each of the object's containedObjects
- UMLPackage *umlPkg = static_cast<UMLPackage*>(umlObj);
+ UMLPackage *umlPkg = umlObj->asUMLPackage();
UMLObjectList lst = umlPkg->containedObjects();
foreach(UMLObject* obj, lst) {
uIgnoreZeroPointer(obj);
@@ -2404,17 +2404,17 @@ void UMLScene::createAutoAttributeAssociations(UMLWidget *widget)
return;
// if the underlying model object is really a UMLClassifier then
if (tmpUmlObj->baseType() == UMLObject::ot_Datatype) {
- UMLClassifier *dt = static_cast<UMLClassifier*>(tmpUmlObj);
+ UMLClassifier *dt = tmpUmlObj->asUMLClassifier();
while (dt->originType() != NULL) {
tmpUmlObj = dt->originType();
if (tmpUmlObj->baseType() != UMLObject::ot_Datatype)
break;
- dt = static_cast<UMLClassifier*>(tmpUmlObj);
+ dt = tmpUmlObj->asUMLClassifier();
}
}
if (tmpUmlObj->baseType() != UMLObject::ot_Class)
return;
- UMLClassifier * klass = static_cast<UMLClassifier*>(tmpUmlObj);
+ UMLClassifier * klass = tmpUmlObj->asUMLClassifier();
// for each of the UMLClassifier's UMLAttributes
UMLAttributeList attrList = klass->getAttributeList();
foreach(UMLAttribute* attr, attrList) {
@@ -2470,7 +2470,7 @@ void UMLScene::createAutoAttributeAssociation(UMLClassifier *type, UMLAttribute
}
// if the attribute type is a Datatype then
if (type->baseType() == UMLObject::ot_Datatype) {
- UMLClassifier *dt = static_cast<UMLClassifier*>(type);
+ UMLClassifier *dt = type->asUMLClassifier();
// if the Datatype is a reference (pointer) type
if (dt->isReference()) {
//Uml::AssociationType::Enum assocType = Uml::AssociationType::Composition;
@@ -2519,22 +2519,22 @@ void UMLScene::createAutoConstraintAssociations(UMLWidget *widget)
if (tmpUmlObj == NULL)
return;
// check if the underlying model object is really a UMLEntity
- UMLCanvasObject *umlObj = dynamic_cast<UMLCanvasObject*>(tmpUmlObj);
+ UMLCanvasObject *umlObj = tmpUmlObj->asUMLCanvasObject();
if (umlObj == NULL)
return;
// finished checking whether this widget has a UMLCanvas Object
if (tmpUmlObj->baseType() != UMLObject::ot_Entity)
return;
- UMLEntity *entity = static_cast<UMLEntity*>(tmpUmlObj);
+ UMLEntity *entity = tmpUmlObj->asUMLEntity();
// for each of the UMLEntity's UMLForeignKeyConstraints
UMLClassifierListItemList constrList = entity->getFilteredList(UMLObject::ot_ForeignKeyConstraint);
foreach(UMLClassifierListItem* cli, constrList) {
- UMLEntityConstraint *eConstr = static_cast<UMLEntityConstraint*>(cli);
+ UMLEntityConstraint *eConstr = cli->asUMLEntityConstraint();
- UMLForeignKeyConstraint* fkc = static_cast<UMLForeignKeyConstraint*>(eConstr);
+ UMLForeignKeyConstraint* fkc = eConstr->asUMLForeignKeyConstraint();
if (fkc == NULL) {
return;
}
@@ -3847,10 +3847,10 @@ bool UMLScene::loadUisDiagramPresentation(QDomElement & qElement)
UMLWidget *widget = NULL;
switch (ot) {
case UMLObject::ot_Class:
- widget = new ClassifierWidget(this, static_cast<UMLClassifier*>(o));
+ widget = new ClassifierWidget(this, o->asUMLClassifier());
break;
case UMLObject::ot_Association: {
- UMLAssociation *umla = static_cast<UMLAssociation*>(o);
+ UMLAssociation *umla = o->asUMLAssociation();
Uml::AssociationType::Enum at = umla->getAssocType();
UMLObject* objA = umla->getObject(Uml::RoleType::A);
UMLObject* objB = umla->getObject(Uml::RoleType::B);
@@ -3871,7 +3871,7 @@ bool UMLScene::loadUisDiagramPresentation(QDomElement & qElement)
break;
}
case UMLObject::ot_Role: {
- //UMLRole *robj = static_cast<UMLRole*>(o);
+ //UMLRole *robj = o->asUMLRole();
//UMLAssociation *umla = robj->getParentAssociation();
// @todo properly display role names.
// For now, in order to get the role names displayed
diff --git a/umbrello/umlwidgets/associationwidget.cpp b/umbrello/umlwidgets/associationwidget.cpp
index d9ee763..40ee1f2 100644
--- a/umbrello/umlwidgets/associationwidget.cpp
+++ b/umbrello/umlwidgets/associationwidget.cpp
@@ -245,16 +245,16 @@ void AssociationWidget::setUMLObject(UMLObject *obj)
const UMLObject::ObjectType ot = obj->baseType();
switch (ot) {
case UMLObject::ot_Association:
- setUMLAssociation(dynamic_cast<UMLAssociation*>(obj));
+ setUMLAssociation(obj->asUMLAssociation());
break;
case UMLObject::ot_Operation:
- setOperation(dynamic_cast<UMLOperation*>(obj));
+ setOperation(obj->asUMLOperation());
break;
case UMLObject::ot_Attribute:
klass = static_cast<UMLClassifier*>(obj->parent());
connect(klass, SIGNAL(attributeRemoved(UMLClassifierListItem*)),
this, SLOT(slotClassifierListItemRemoved(UMLClassifierListItem*)));
- attr = static_cast<UMLAttribute*>(obj);
+ attr = obj->asUMLAttribute();
connect(attr, SIGNAL(attributeChanged()), this, SLOT(slotAttributeChanged()));
break;
case UMLObject::ot_EntityAttribute:
@@ -311,7 +311,7 @@ UMLClassifier *AssociationWidget::operationOwner()
if (!o) {
return 0;
}
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(o);
+ UMLClassifier *c = o->asUMLClassifier();
if (!c) {
uError() << "widgetForRole(" << role << ") is not a classifier";
}
@@ -493,7 +493,7 @@ QString AssociationWidget::lwOperationText()
UMLClassifier* AssociationWidget::lwClassifier()
{
UMLObject *o = widgetForRole(RoleType::B)->umlObject();
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(o);
+ UMLClassifier *c = o->asUMLClassifier();
return c;
}
@@ -727,7 +727,7 @@ bool AssociationWidget::activate()
} else {
const UMLObject::ObjectType ot = myObj->baseType();
if (ot == UMLObject::ot_Association) {
- UMLAssociation * myAssoc = static_cast<UMLAssociation*>(myObj);
+ UMLAssociation * myAssoc = myObj->asUMLAssociation();
setUMLAssociation(myAssoc);
} else {
setUMLObject(myObj);
@@ -4288,7 +4288,7 @@ bool AssociationWidget::loadFromXMI(QDomElement& qElement,
if (ot != UMLObject::ot_Association) {
setUMLObject(myObj);
} else {
- UMLAssociation * myAssoc = static_cast<UMLAssociation*>(myObj);
+ UMLAssociation * myAssoc = myObj->asUMLAssociation();
setUMLAssociation(myAssoc);
if (type == QLatin1String("-1"))
aType = myAssoc->getAssocType();
diff --git a/umbrello/umlwidgets/categorywidget.cpp b/umbrello/umlwidgets/categorywidget.cpp
index 434837d..2033b13 100644
--- a/umbrello/umlwidgets/categorywidget.cpp
+++ b/umbrello/umlwidgets/categorywidget.cpp
@@ -121,7 +121,7 @@ void CategoryWidget::saveToXMI(QDomDocument & qDoc, QDomElement & qElement)
*/
void CategoryWidget::slotMenuSelection(QAction* action)
{
- UMLCategory* catObj = static_cast<UMLCategory*>(umlObject());
+ UMLCategory* catObj = umlObject()->asUMLCategory();
if (!catObj) {
uWarning() << "No UMLCategory for this widget.";
return;
diff --git a/umbrello/umlwidgets/entitywidget.cpp b/umbrello/umlwidgets/entitywidget.cpp
index 0c0ed9d..c272e5d 100644
--- a/umbrello/umlwidgets/entitywidget.cpp
+++ b/umbrello/umlwidgets/entitywidget.cpp
@@ -109,7 +109,7 @@ void EntityWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
foreach (entityattribute, list) {
QString text = entityattribute->name();
painter->setPen(textColor());
- UMLEntityAttribute* casted = dynamic_cast<UMLEntityAttribute*>(entityattribute);
+ UMLEntityAttribute* casted = entityattribute->asUMLEntityAttribute();
if(casted && casted->indexType() == UMLEntityAttribute::Primary)
{
font.setUnderline(true);
@@ -159,7 +159,7 @@ void EntityWidget::slotMenuSelection(QAction* action)
UMLApp::app()->document()->setModified();
if (sel == ListPopupMenu::mt_PrimaryKeyConstraint) {
- UMLUniqueConstraint* uc = static_cast<UMLUniqueConstraint*>(obj);
+ UMLUniqueConstraint* uc = obj->asUMLUniqueConstraint();
dynamic_cast<UMLEntity*>(m_umlObject.data())->setAsPrimaryKey(uc);
}
}
diff --git a/umbrello/umlwidgets/floatingtextwidget.cpp b/umbrello/umlwidgets/floatingtextwidget.cpp
index e71cd63..ebbcf34 100644
--- a/umbrello/umlwidgets/floatingtextwidget.cpp
+++ b/umbrello/umlwidgets/floatingtextwidget.cpp
@@ -275,7 +275,7 @@ void FloatingTextWidget::showOperationDialog(bool enableAutoIncrement)
if (!op) {
// The op does not yet exist. Create a new one.
UMLObject *o = c->createOperation(od.m_name, 0, &od.m_args);
- op = static_cast<UMLOperation*>(o);
+ op = o->asUMLOperation();
}
if (od.m_pReturnType) {
op->setType(od.m_pReturnType);
@@ -793,7 +793,7 @@ void FloatingTextWidget::slotMenuSelection(QAction* action)
}
UMLClassifierListItem* umlObj = Object_Factory::createChildObject(c, UMLObject::ot_Operation);
if (umlObj) {
- UMLOperation* newOperation = static_cast<UMLOperation*>(umlObj);
+ UMLOperation* newOperation = umlObj->asUMLOperation();
m_linkWidget->setOperation(newOperation);
}
}
diff --git a/umbrello/umlwidgets/messagewidget.cpp b/umbrello/umlwidgets/messagewidget.cpp
index b325140..7f4c18c 100644
--- a/umbrello/umlwidgets/messagewidget.cpp
+++ b/umbrello/umlwidgets/messagewidget.cpp
@@ -926,7 +926,7 @@ UMLClassifier *MessageWidget::operationOwner()
UMLObject *pObject = m_pOw[Uml::RoleType::B]->umlObject();
if (pObject == NULL)
return NULL;
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(pObject);
+ UMLClassifier *c = pObject->asUMLClassifier();
return c;
}
@@ -994,7 +994,7 @@ QString MessageWidget::lwOperationText()
UMLClassifier *MessageWidget::lwClassifier()
{
UMLObject *o = m_pOw[Uml::RoleType::B]->umlObject();
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(o);
+ UMLClassifier *c = o->asUMLClassifier();
return c;
}
diff --git a/umbrello/umlwidgets/toolbarstateonewidget.cpp b/umbrello/umlwidgets/toolbarstateonewidget.cpp
index d70bf86..397148c 100644
--- a/umbrello/umlwidgets/toolbarstateonewidget.cpp
+++ b/umbrello/umlwidgets/toolbarstateonewidget.cpp
@@ -207,7 +207,7 @@ void ToolBarStateOneWidget::setWidget(UMLWidget* firstObject)
&pressedOK, UMLApp::app());
#endif
if (pressedOK) {
- UMLPackage* component = static_cast<UMLPackage*>(m_firstObject->umlObject());
+ UMLPackage* component = m_firstObject->umlObject()->asUMLPackage();
UMLObject *port = Object_Factory::createUMLObject(UMLObject::ot_Port, name, component);
umlwidget = Widget_Factory::createWidget(m_pUMLScene, port);
}
diff --git a/umbrello/umlwidgets/widget_factory.cpp b/umbrello/umlwidgets/widget_factory.cpp
index 621926d..b58d33d 100644
--- a/umbrello/umlwidgets/widget_factory.cpp
+++ b/umbrello/umlwidgets/widget_factory.cpp
@@ -80,44 +80,44 @@ UMLWidget *createWidget(UMLScene *scene, UMLObject *o)
y = ow->topMargin();
newWidget = ow;
} else
- newWidget = new ActorWidget(scene, static_cast<UMLActor*>(o));
+ newWidget = new ActorWidget(scene, o->asUMLActor());
break;
case UMLObject::ot_UseCase:
- newWidget = new UseCaseWidget(scene, static_cast<UMLUseCase*>(o));
+ newWidget = new UseCaseWidget(scene, o->asUMLUseCase());
break;
case UMLObject::ot_Folder:
- newWidget = new PackageWidget(scene, static_cast<UMLPackage*>(o));
+ newWidget = new PackageWidget(scene, o->asUMLPackage());
break;
case UMLObject::ot_Package:
- newWidget = new ClassifierWidget(scene, static_cast<UMLPackage*>(o));
+ newWidget = new ClassifierWidget(scene, o->asUMLPackage());
break;
case UMLObject::ot_Component:
- newWidget = new ComponentWidget(scene, static_cast<UMLComponent*>(o));
+ newWidget = new ComponentWidget(scene, o->asUMLComponent());
if (diagramType == Uml::DiagramType::Deployment) {
newWidget->setIsInstance(true);
}
break;
case UMLObject::ot_Port:
{
- PinPortBase *pw = new PortWidget(scene, static_cast<UMLPort*>(o));
+ PinPortBase *pw = new PortWidget(scene, o->asUMLPort());
pw->attachToOwner();
newWidget = pw;
}
break;
case UMLObject::ot_Node:
- newWidget = new NodeWidget(scene, static_cast<UMLNode*>(o));
+ newWidget = new NodeWidget(scene, o->asUMLNode());
break;
case UMLObject::ot_Artifact:
- newWidget = new ArtifactWidget(scene, static_cast<UMLArtifact*>(o));
+ newWidget = new ArtifactWidget(scene, o->asUMLArtifact());
break;
case UMLObject::ot_Datatype:
- newWidget = new DatatypeWidget(scene, static_cast<UMLClassifier*>(o));
+ newWidget = new DatatypeWidget(scene, o->asUMLClassifier());
break;
case UMLObject::ot_Enum:
- newWidget = new EnumWidget(scene, static_cast<UMLEnum*>(o));
+ newWidget = new EnumWidget(scene, o->asUMLEnum());
break;
case UMLObject::ot_Entity:
- newWidget = new EntityWidget(scene, static_cast<UMLEntity*>(o));
+ newWidget = new EntityWidget(scene, o->asUMLEntity());
break;
case UMLObject::ot_Interface:
if (diagramType == Uml::DiagramType::Sequence || diagramType == Uml::DiagramType::Collaboration) {
@@ -127,7 +127,7 @@ UMLWidget *createWidget(UMLScene *scene, UMLObject *o)
}
newWidget = ow;
} else {
- UMLClassifier *c = static_cast<UMLClassifier*>(o);
+ UMLClassifier *c = o->asUMLClassifier();
ClassifierWidget* interfaceWidget = new ClassifierWidget(scene, c);
if (diagramType == Uml::DiagramType::Component || diagramType == Uml::DiagramType::Deployment) {
interfaceWidget->setDrawAsCircle(true);
@@ -138,7 +138,7 @@ UMLWidget *createWidget(UMLScene *scene, UMLObject *o)
case UMLObject::ot_Class:
//see if we really want an object widget or class widget
if (diagramType == Uml::DiagramType::Class || diagramType == Uml::DiagramType::Component) {
- UMLClassifier *c = static_cast<UMLClassifier*>(o);
+ UMLClassifier *c = o->asUMLClassifier();
ClassifierWidget *cw = new ClassifierWidget(scene, c);
if (diagramType == Uml::DiagramType::Component)
cw->setDrawAsCircle(true);
@@ -152,7 +152,7 @@ UMLWidget *createWidget(UMLScene *scene, UMLObject *o)
}
break;
case UMLObject::ot_Category:
- newWidget = new CategoryWidget(scene, static_cast<UMLCategory*>(o));
+ newWidget = new CategoryWidget(scene, o->asUMLCategory());
break;
default:
uWarning() << "trying to create an invalid widget (" << UMLObject::toString(type) << ")";
@@ -247,44 +247,44 @@ UMLWidget* makeWidgetFromXMI(const QString& tag,
if (tag == QLatin1String("actorwidget") || tag == QLatin1String("UML:ActorWidget")) {
if (validateObjType(UMLObject::ot_Actor, o, id))
- widget = new ActorWidget(scene, static_cast<UMLActor*>(o));
+ widget = new ActorWidget(scene, o->asUMLActor());
} else if (tag == QLatin1String("usecasewidget") || tag == QLatin1String("UML:UseCaseWidget")) {
if (validateObjType(UMLObject::ot_UseCase, o, id))
- widget = new UseCaseWidget(scene, static_cast<UMLUseCase*>(o));
+ widget = new UseCaseWidget(scene, o->asUMLUseCase());
} else if (tag == QLatin1String("classwidget") ||
tag == QLatin1String("UML:ClassWidget") || tag == QLatin1String("UML:ConceptWidget")) {
if (validateObjType(UMLObject::ot_Class, o, id) || validateObjType(UMLObject::ot_Package, o, id))
- widget = new ClassifierWidget(scene, static_cast<UMLClassifier*>(o));
+ widget = new ClassifierWidget(scene, o->asUMLClassifier());
} else if (tag == QLatin1String("packagewidget")) {
if (validateObjType(UMLObject::ot_Package, o, id))
- widget = new ClassifierWidget(scene, static_cast<UMLPackage*>(o));
+ widget = new ClassifierWidget(scene, o->asUMLPackage());
} else if (tag == QLatin1String("componentwidget")) {
if (validateObjType(UMLObject::ot_Component, o, id))
- widget = new ComponentWidget(scene, static_cast<UMLComponent*>(o));
+ widget = new ComponentWidget(scene, o->asUMLComponent());
} else if (tag == QLatin1String("portwidget")) {
if (validateObjType(UMLObject::ot_Port, o, id))
- widget = new PortWidget(scene, static_cast<UMLPort*>(o));
+ widget = new PortWidget(scene, o->asUMLPort());
} else if (tag == QLatin1String("nodewidget")) {
if (validateObjType(UMLObject::ot_Node, o, id))
- widget = new NodeWidget(scene, static_cast<UMLNode*>(o));
+ widget = new NodeWidget(scene, o->asUMLNode());
} else if (tag == QLatin1String("artifactwidget")) {
if (validateObjType(UMLObject::ot_Artifact, o, id))
- widget = new ArtifactWidget(scene, static_cast<UMLArtifact*>(o));
+ widget = new ArtifactWidget(scene, o->asUMLArtifact());
} else if (tag == QLatin1String("interfacewidget")) {
if (validateObjType(UMLObject::ot_Interface, o, id))
- widget = new ClassifierWidget(scene, static_cast<UMLClassifier*>(o));
+ widget = new ClassifierWidget(scene, o->asUMLClassifier());
} else if (tag == QLatin1String("datatypewidget")) {
if (validateObjType(UMLObject::ot_Datatype, o, id))
- widget = new DatatypeWidget(scene, static_cast<UMLClassifier*>(o));
+ widget = new DatatypeWidget(scene, o->asUMLClassifier());
} else if (tag == QLatin1String("enumwidget")) {
if (validateObjType(UMLObject::ot_Enum, o, id))
- widget = new EnumWidget(scene, static_cast<UMLEnum*>(o));
+ widget = new EnumWidget(scene, o->asUMLEnum());
} else if (tag == QLatin1String("entitywidget")) {
if (validateObjType(UMLObject::ot_Entity, o, id))
- widget = new EntityWidget(scene, static_cast<UMLEntity*>(o));
+ widget = new EntityWidget(scene, o->asUMLEntity());
} else if (tag == QLatin1String("categorywidget")) {
if (validateObjType(UMLObject::ot_Category, o, id))
- widget = new CategoryWidget(scene, static_cast<UMLCategory*>(o));
+ widget = new CategoryWidget(scene, o->asUMLCategory());
} else if (tag == QLatin1String("objectwidget") || tag == QLatin1String("UML:ObjectWidget")) {
widget = new ObjectWidget(scene, o);
} else {
diff --git a/umbrello/umlwidgets/widgetbase.cpp b/umbrello/umlwidgets/widgetbase.cpp
index 2394386..3a8100d 100644
--- a/umbrello/umlwidgets/widgetbase.cpp
+++ b/umbrello/umlwidgets/widgetbase.cpp
@@ -903,7 +903,7 @@ void WidgetBase::slotMenuSelection(QAction *trigger)
case ListPopupMenu::mt_ViewCode: {
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(umlObject());
+ UMLClassifier *c = umlObject()->asUMLClassifier();
if (c) {
UMLApp::app()->viewCodeDocument(c);
}
@@ -948,8 +948,8 @@ void WidgetBase::slotMenuSelection(QAction *trigger)
case ListPopupMenu::mt_Refactoring:
//check if we are operating on a classifier, or some other kind of UMLObject
- if (dynamic_cast<UMLClassifier*>(umlObject())) {
- UMLApp::app()->refactor(static_cast<UMLClassifier*>(umlObject()));
+ if (umlObject()->asUMLClassifier()) {
+ UMLApp::app()->refactor(umlObject()->asUMLClassifier());
}
break;