summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2016-10-27 08:58:41 (GMT)
committerRalf Habacker <ralf.habacker@freenet.de>2016-11-08 07:33:52 (GMT)
commitd4dfde3d75047a8e3db1878200cf1ae8e35888b6 (patch)
tree5f74e3b72f32e725139cf53577ce806dff5f1ef7
parenta7bda8a813aa23fe9d3299a1d76105806553a778 (diff)
Add type wrapper for uml widget classes.
Cherry picked from commit c18413815334ccaebf28ae2e90b215377b34b84e.
-rw-r--r--umbrello/assocrules.cpp20
-rw-r--r--umbrello/clipboard/umlclipboard.cpp4
-rw-r--r--umbrello/clipboard/umldragdata.cpp18
-rw-r--r--umbrello/cmds/widget/cmd_baseWidgetCommand.cpp6
-rw-r--r--umbrello/cmds/widget/cmd_changeVisualProperty.cpp4
-rw-r--r--umbrello/dialogs/classpropertiesdialog.cpp15
-rw-r--r--umbrello/dotgenerator.cpp2
-rw-r--r--umbrello/listpopupmenu.cpp8
-rw-r--r--umbrello/model_utils.cpp2
-rw-r--r--umbrello/toolbarstate.cpp6
-rw-r--r--umbrello/toolbarstateassociation.cpp2
-rw-r--r--umbrello/toolbarstatemessages.cpp2
-rw-r--r--umbrello/toolbarstateother.cpp6
-rw-r--r--umbrello/umlscene.cpp50
-rw-r--r--umbrello/umlwidgets/associationline.cpp2
-rw-r--r--umbrello/umlwidgets/associationwidget.cpp12
-rw-r--r--umbrello/umlwidgets/combinedfragmentwidget.cpp2
-rw-r--r--umbrello/umlwidgets/messagewidget.cpp4
-rw-r--r--umbrello/umlwidgets/notewidget.cpp2
-rw-r--r--umbrello/umlwidgets/objectnodewidget.cpp2
-rw-r--r--umbrello/umlwidgets/toolbarstateonewidget.cpp12
-rw-r--r--umbrello/umlwidgets/widget_utils.cpp2
-rw-r--r--umbrello/umlwidgets/widgetbase.cpp66
-rw-r--r--umbrello/umlwidgets/widgetbase.h94
24 files changed, 248 insertions, 95 deletions
diff --git a/umbrello/assocrules.cpp b/umbrello/assocrules.cpp
index abee46e..650ee03 100644
--- a/umbrello/assocrules.cpp
+++ b/umbrello/assocrules.cpp
@@ -102,7 +102,7 @@ bool AssocRules::allowAssociation(Uml::AssociationType::Enum assocType, UMLWidge
case Uml::AssociationType::State:
{
- StateWidget *pState = dynamic_cast<StateWidget*>(widget);
+ StateWidget *pState = widget->asStateWidget();
return (pState == NULL || pState->stateType() != StateWidget::End);
}
break;
@@ -110,7 +110,7 @@ bool AssocRules::allowAssociation(Uml::AssociationType::Enum assocType, UMLWidge
case Uml::AssociationType::Activity:
case Uml::AssociationType::Exception:
{
- ActivityWidget *pActivity = dynamic_cast<ActivityWidget*>(widget);
+ ActivityWidget *pActivity = widget->asActivityWidget();
return (pActivity == NULL || pActivity->activityType() != ActivityWidget::End);
}
break;
@@ -224,18 +224,18 @@ bool AssocRules::allowAssociation(Uml::AssociationType::Enum assocType,
return false;
}
}
- if (widgetB->baseType() == WidgetBase::wt_Class) {
+ if (widgetB->isClassWidget()) {
return widgetB->umlObject()->isAbstract();
- } else if (widgetB->baseType() == WidgetBase::wt_Interface ||
- widgetB->baseType() == WidgetBase::wt_Package) {
+ } else if (widgetB->isInterfaceWidget() ||
+ widgetB->isPackageWidget()) {
return true;
}
break;
case Uml::AssociationType::State:
{
- StateWidget *stateA = dynamic_cast<StateWidget*>(widgetA);
- StateWidget *stateB = dynamic_cast<StateWidget*>(widgetB);
+ StateWidget *stateA = widgetA->asStateWidget();
+ StateWidget *stateB = widgetB->asStateWidget();
if (stateA && stateB) {
if (stateB->stateType() == StateWidget::Initial)
return false;
@@ -251,8 +251,8 @@ bool AssocRules::allowAssociation(Uml::AssociationType::Enum assocType,
case Uml::AssociationType::Exception:
{
- ActivityWidget *actA = dynamic_cast<ActivityWidget*>(widgetA);
- ActivityWidget *actB = dynamic_cast<ActivityWidget*>(widgetB);
+ ActivityWidget *actA = widgetA->asActivityWidget();
+ ActivityWidget *actB = widgetB->asActivityWidget();
bool isSignal = false;
bool isObjectNode = false;
@@ -277,7 +277,7 @@ bool AssocRules::allowAssociation(Uml::AssociationType::Enum assocType,
if ((actTypeB == ActivityWidget::End || actTypeB == ActivityWidget::Final) &&
actTypeA != ActivityWidget::Normal &&
actTypeA != ActivityWidget::Branch &&
- dynamic_cast<ForkJoinWidget*>(widgetA) == NULL && !isSignal &&!isObjectNode) {
+ widgetA->asForkJoinWidget() == NULL && !isSignal &&!isObjectNode) {
return false;
}
// only Forks and Branches can have more than one "outgoing" transition
diff --git a/umbrello/clipboard/umlclipboard.cpp b/umbrello/clipboard/umlclipboard.cpp
index 066e10a..cea3da3 100644
--- a/umbrello/clipboard/umlclipboard.cpp
+++ b/umbrello/clipboard/umlclipboard.cpp
@@ -236,8 +236,8 @@ void UMLClipboard::addRelatedWidgets()
UMLWidget *pWA =0, *pWB = 0;
foreach (UMLWidget* widget, m_WidgetList) {
- if (widget->baseType() == WidgetBase::wt_Message) {
- MessageWidget * pMessage = static_cast<MessageWidget *>(widget);
+ if (widget->isMessageWidget()) {
+ MessageWidget * pMessage = widget->asMessageWidget();
pWA = (UMLWidget*)pMessage->objectWidget(Uml::RoleType::A);
pWB = (UMLWidget*)pMessage->objectWidget(Uml::RoleType::B);
if (!relatedWidgets.contains(pWA))
diff --git a/umbrello/clipboard/umldragdata.cpp b/umbrello/clipboard/umldragdata.cpp
index cd4ce4f..4f00aed 100644
--- a/umbrello/clipboard/umldragdata.cpp
+++ b/umbrello/clipboard/umldragdata.cpp
@@ -541,7 +541,7 @@ bool UMLDragData::decodeClip4(const QMimeData* mimeData, UMLObjectList& objects,
UMLWidget* widget = scene->loadWidgetFromXMI(widgetElement);
if (widget) {
- if (pasteToDiagramCopiedFrom && widget->baseType() == WidgetBase::wt_Object) {
+ if (pasteToDiagramCopiedFrom && widget->isObjectWidget()) {
delete widget;
widgetNode = widgetNode.nextSibling();
widgetElement = widgetNode.toElement();
@@ -571,8 +571,8 @@ bool UMLDragData::decodeClip4(const QMimeData* mimeData, UMLObjectList& objects,
// UMLObject can be distinguished from the first widget
widget->setLocalID(doc->assignNewID(widget->localID()));
- if (widget->baseType() == WidgetBase::wt_Message) {
- MessageWidget *w = static_cast<MessageWidget*>(widget);
+ if (widget->isMessageWidget()) {
+ MessageWidget *w = widget->asMessageWidget();
if (w && w->floatingTextWidget()) {
w->floatingTextWidget()->setLocalID(doc->assignNewID(w->floatingTextWidget()->localID()));
w->floatingTextWidget()->setID(doc->assignNewID(w->floatingTextWidget()->id()));
@@ -598,7 +598,7 @@ bool UMLDragData::decodeClip4(const QMimeData* mimeData, UMLObjectList& objects,
// preconditions
if (!pasteToDiagramCopiedFrom) {
foreach (UMLWidget* widget, widgets) {
- if (widget->baseType() == WidgetBase::wt_Object) {
+ if (widget->isObjectWidget()) {
executeCreateWidgetCommand(widget);
}
}
@@ -606,17 +606,17 @@ bool UMLDragData::decodeClip4(const QMimeData* mimeData, UMLObjectList& objects,
// Now add all remaining widgets
foreach (UMLWidget* widget, widgets) {
- if (!pasteToDiagramCopiedFrom && widget->baseType() == WidgetBase::wt_Message) {
- MessageWidget* message = dynamic_cast<MessageWidget*>(widget);
+ if (!pasteToDiagramCopiedFrom && widget->isMessageWidget()) {
+ MessageWidget* message = widget->asMessageWidget();
message->resolveObjectWidget(log);
}
- if (widget->baseType() == WidgetBase::wt_Precondition) {
- PreconditionWidget* precondition = dynamic_cast<PreconditionWidget*>(widget);
+ if (widget->isPreconditionWidget()) {
+ PreconditionWidget* precondition = widget->asPreconditionWidget();
precondition->resolveObjectWidget(log);
}
- if (widget->baseType() != WidgetBase::wt_Object) {
+ if (!widget->isObjectWidget()) {
executeCreateWidgetCommand(widget);
}
}
diff --git a/umbrello/cmds/widget/cmd_baseWidgetCommand.cpp b/umbrello/cmds/widget/cmd_baseWidgetCommand.cpp
index ae33fca..591e462 100644
--- a/umbrello/cmds/widget/cmd_baseWidgetCommand.cpp
+++ b/umbrello/cmds/widget/cmd_baseWidgetCommand.cpp
@@ -71,10 +71,8 @@ namespace Uml
*/
void CmdBaseWidgetCommand::addWidgetToScene(UMLWidget* umlWidget)
{
- if (umlWidget->baseType() == WidgetBase::wt_Message) {
- scene()->messageList().append(
- dynamic_cast<MessageWidget*>(umlWidget)
- );
+ if (umlWidget->isMessageWidget()) {
+ scene()->messageList().append(umlWidget->asMessageWidget());
} else {
scene()->widgetList().append(umlWidget);
}
diff --git a/umbrello/cmds/widget/cmd_changeVisualProperty.cpp b/umbrello/cmds/widget/cmd_changeVisualProperty.cpp
index 7f26b7d..58efddf 100644
--- a/umbrello/cmds/widget/cmd_changeVisualProperty.cpp
+++ b/umbrello/cmds/widget/cmd_changeVisualProperty.cpp
@@ -40,7 +40,7 @@ namespace Uml
void CmdChangeVisualProperty::redo()
{
- ClassifierWidget* classifier = dynamic_cast<ClassifierWidget*>(widget());
+ ClassifierWidget* classifier = widget()->asClassifierWidget();
if (classifier)
classifier->setVisualPropertyCmd(m_property, m_newValue);
else
@@ -49,7 +49,7 @@ namespace Uml
void CmdChangeVisualProperty::undo()
{
- ClassifierWidget* classifier = dynamic_cast<ClassifierWidget*>(widget());
+ ClassifierWidget* classifier = widget()->asClassifierWidget();
if (classifier)
classifier->setVisualPropertyCmd(m_property, m_oldValue);
else
diff --git a/umbrello/dialogs/classpropertiesdialog.cpp b/umbrello/dialogs/classpropertiesdialog.cpp
index 820a3c5..75884da 100644
--- a/umbrello/dialogs/classpropertiesdialog.cpp
+++ b/umbrello/dialogs/classpropertiesdialog.cpp
@@ -92,26 +92,25 @@ ClassPropertiesDialog::ClassPropertiesDialog(QWidget *parent, UMLWidget *w)
m_pWidget = w;
m_pObject = w->umlObject();
- if (w->baseType() == WidgetBase::wt_Class
- || w->baseType() == WidgetBase::wt_Interface
- || w->baseType() == WidgetBase::wt_Enum
- || w->baseType() == WidgetBase::wt_Package) {
+ if (w->isClassWidget()
+ || w->isInterfaceWidget()
+ || w->isEnumWidget()
+ || w->isPackageWidget()) {
setupPages(true);
- } else if (w->baseType() == WidgetBase::wt_Component) {
+ } else if (w->isComponentWidget()) {
if (w->isInstance()) {
setupInstancePages();
} else {
setupPages();
}
- } else if (w->baseType() == WidgetBase::wt_Node) {
+ } else if (w->isNodeWidget()) {
setupInstancePages();
} else {
setupPages();
}
// now setup the options page for classes
- if (w->baseType() == WidgetBase::wt_Class ||
- w->baseType() == WidgetBase::wt_Interface) {
+ if (w->isClassWidget() || w->isInterfaceWidget()) {
setupDisplayPage();
}
setupStylePage(m_pWidget);
diff --git a/umbrello/dotgenerator.cpp b/umbrello/dotgenerator.cpp
index 5ec6a4f..fd1e643 100644
--- a/umbrello/dotgenerator.cpp
+++ b/umbrello/dotgenerator.cpp
@@ -379,7 +379,7 @@ bool DotGenerator::createDotFile(UMLScene *scene, const QString &fileName, const
uDebug() << type << params;
#endif
QString id = fixID(Uml::ID::toString(widget->localID()));
- if (widget->baseType() != WidgetBase::wt_Text)
+ if (!widget->isTextWidget())
out << "\"" << id << "\""
<< " [" << params.join(QLatin1String(",")) << "];\n";
}
diff --git a/umbrello/listpopupmenu.cpp b/umbrello/listpopupmenu.cpp
index d87b2e3..3c233e8 100644
--- a/umbrello/listpopupmenu.cpp
+++ b/umbrello/listpopupmenu.cpp
@@ -364,9 +364,9 @@ ListPopupMenu::ListPopupMenu(QWidget * parent, WidgetBase * object, bool multi,
setActionEnabled(mt_Cut, bCutState);
setActionEnabled(mt_Copy, bCutState);
bool pasteAvailable = false;
- if (object->baseType() == WidgetBase::wt_Note &&
+ if (object->isNoteWidget() &&
UMLApp::app()->listView()->startedCopy()) {
- NoteWidget::s_pCurrentNote = static_cast<NoteWidget*>(object);
+ NoteWidget::s_pCurrentNote = object->asNoteWidget();
pasteAvailable = true;
}
setActionEnabled(mt_Paste, pasteAvailable);
@@ -1038,8 +1038,8 @@ void ListPopupMenu::insertAssociationItem(MenuType mt)
}
if (m_TriggerObjectType == tot_Widget
- && m_TriggerObject.m_Widget->baseType() == WidgetBase::wt_Association) {
- AssociationWidget *w = static_cast<AssociationWidget*>(m_TriggerObject.m_Widget);
+ && m_TriggerObject.m_Widget->isAssociationWidget()) {
+ AssociationWidget *w = m_TriggerObject.m_Widget->asAssociationWidget();
if (w->isPointAddable())
insert(mt_Add_Point, Icon_Utils::SmallIcon(Icon_Utils::it_Add_Point), i18n("Add Point"));
if (w->isPointRemovable())
diff --git a/umbrello/model_utils.cpp b/umbrello/model_utils.cpp
index 11abfc8..d9df240 100644
--- a/umbrello/model_utils.cpp
+++ b/umbrello/model_utils.cpp
@@ -1996,7 +1996,7 @@ bool typeIsAllowedInDiagram(UMLWidget* w, UMLScene *scene)
break;
case WidgetBase::wt_Text:
{
- FloatingTextWidget *ft = dynamic_cast<FloatingTextWidget*>(w);
+ FloatingTextWidget *ft = w->asFloatingTextWidget();
if (ft && ft->textRole() != Uml::TextRole::Floating) {
bAccept = false;
}
diff --git a/umbrello/toolbarstate.cpp b/umbrello/toolbarstate.cpp
index 702b07a..3a4c368 100644
--- a/umbrello/toolbarstate.cpp
+++ b/umbrello/toolbarstate.cpp
@@ -546,9 +546,9 @@ FloatingDashLineWidget* ToolBarState::floatingLineAt(const QPointF& pos)
FloatingDashLineWidget* floatingline = 0;
foreach (UMLWidget* widget, m_pUMLScene->widgetList()) {
- if (widget->baseType() == WidgetBase::wt_FloatingDashLine){
- if (dynamic_cast<FloatingDashLineWidget*>(widget)->onLine(pos)) {
- floatingline = dynamic_cast<FloatingDashLineWidget*>(widget);
+ if (widget->isFloatingDashLineWidget()){
+ if (widget->asFloatingDashLineWidget()->onLine(pos)) {
+ floatingline = widget->asFloatingDashLineWidget();
}
}
}
diff --git a/umbrello/toolbarstateassociation.cpp b/umbrello/toolbarstateassociation.cpp
index 2c5dd21..c272db7 100644
--- a/umbrello/toolbarstateassociation.cpp
+++ b/umbrello/toolbarstateassociation.cpp
@@ -112,7 +112,7 @@ void ToolBarStateAssociation::slotWidgetRemoved(UMLWidget* widget)
void ToolBarStateAssociation::mouseReleaseAssociation()
{
if (m_pMouseEvent->button() != Qt::LeftButton ||
- !m_firstWidget || m_firstWidget->baseType() != WidgetBase::wt_Class) {
+ !m_firstWidget || !m_firstWidget->isClassWidget()) {
cleanAssociation();
return;
}
diff --git a/umbrello/toolbarstatemessages.cpp b/umbrello/toolbarstatemessages.cpp
index 3a4823d..a3aac17 100644
--- a/umbrello/toolbarstatemessages.cpp
+++ b/umbrello/toolbarstatemessages.cpp
@@ -145,7 +145,7 @@ void ToolBarStateMessages::mouseReleaseWidget()
//TODO When an association between UMLObjects of invalid types is made, an error message
//is shown. Shouldn't also a message be used here?
if (m_pMouseEvent->button() != Qt::LeftButton ||
- currentWidget()->baseType() != WidgetBase::wt_Object) {
+ !currentWidget()->isObjectWidget()) {
cleanMessage();
return;
}
diff --git a/umbrello/toolbarstateother.cpp b/umbrello/toolbarstateother.cpp
index 499c235..c57f1de 100644
--- a/umbrello/toolbarstateother.cpp
+++ b/umbrello/toolbarstateother.cpp
@@ -270,7 +270,7 @@ bool ToolBarStateOther::newWidget()
break;
case WorkToolBar::tbb_Seq_Combined_Fragment:
{
- dynamic_cast<CombinedFragmentWidget*>(umlWidget)->askNameForWidgetType(
+ umlWidget->asCombinedFragmentWidget()->askNameForWidgetType(
umlWidget, i18n("Enter Combined Fragment Name"),
i18n("Enter the Combined Fragment"), i18n("new Combined Fragment"));
}
@@ -291,12 +291,12 @@ bool ToolBarStateOther::newWidget()
break;
case WorkToolBar::tbb_Object_Node:
{
- dynamic_cast<ObjectNodeWidget*>(umlWidget)->askForObjectNodeType(umlWidget);
+ umlWidget->asObjectNodeWidget()->askForObjectNodeType(umlWidget);
}
break;
case WorkToolBar::tbb_PrePostCondition:
{
- dynamic_cast<NoteWidget*>(umlWidget)->askForNoteType(umlWidget);
+ umlWidget->asNoteWidget()->askForNoteType(umlWidget);
}
break;
default:
diff --git a/umbrello/umlscene.cpp b/umbrello/umlscene.cpp
index 01cbe14..b5acdc6 100644
--- a/umbrello/umlscene.cpp
+++ b/umbrello/umlscene.cpp
@@ -551,11 +551,11 @@ void UMLScene::print(QPrinter *pPrinter, QPainter & pPainter)
void UMLScene::setupNewWidget(UMLWidget *w, bool setPosition)
{
if (setPosition) {
- if (w->baseType() == WidgetBase::wt_Pin ||
- w->baseType() == WidgetBase::wt_Port) {
- PinPortBase *pw = static_cast<PinPortBase*>(w);
+ if (w->isPinWidget() ||
+ w->isPortWidget()) {
+ PinPortBase *pw = w->asPinPortBase();
pw->attachToOwner();
- } else if (w->baseType() != WidgetBase::wt_Object) {
+ } else if (!w->isObjectWidget()) {
// ObjectWidget's position is handled by the widget
w->setX(m_Pos.x());
w->setY(m_Pos.y());
@@ -778,7 +778,7 @@ void UMLScene::dropEvent(QGraphicsSceneDragDropEvent *e)
bool breakFlag = false;
UMLWidget* w = 0;
foreach(w, m_WidgetList) {
- if (w->baseType() == WidgetBase::wt_Note && w->onWidget(e->scenePos())) {
+ if (w->isNoteWidget() && w->onWidget(e->scenePos())) {
breakFlag = true;
break;
}
@@ -894,7 +894,7 @@ void UMLScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* ome)
ObjectWidget * UMLScene::onWidgetLine(const QPointF &point) const
{
foreach(UMLWidget* obj, m_WidgetList) {
- ObjectWidget *ow = dynamic_cast<ObjectWidget*>(obj);
+ ObjectWidget *ow = obj->asObjectWidget();
if (ow == NULL)
continue;
SeqLineWidget *pLine = ow->sequentialLine();
@@ -919,7 +919,7 @@ ObjectWidget * UMLScene::onWidgetLine(const QPointF &point) const
ObjectWidget * UMLScene::onWidgetDestructionBox(const QPointF &point) const
{
foreach(UMLWidget* obj, m_WidgetList) {
- ObjectWidget *ow = dynamic_cast<ObjectWidget*>(obj);
+ ObjectWidget *ow = obj->asObjectWidget();
if (ow == NULL)
continue;
SeqLineWidget *pLine = ow->sequentialLine();
@@ -1369,7 +1369,7 @@ void UMLScene::selectionSetVisualProperty(ClassifierWidget::VisualProperty prope
UMLApp::app()->beginMacro(i18n("Change visual property"));
foreach(UMLWidget *temp, selectedWidgets()) {
- ClassifierWidget *cw = dynamic_cast<ClassifierWidget*>(temp);
+ ClassifierWidget *cw = temp->asClassifierWidget();
cw->setVisualProperty(property, value);
}
@@ -1392,8 +1392,8 @@ void UMLScene::deleteSelection()
foreach(UMLWidget* widget, selectedWidgets()) {
// Don't delete text widget that are connect to associations as these will
// be cleaned up by the associations.
- if (widget->baseType() == WidgetBase::wt_Text &&
- static_cast<FloatingTextWidget*>(widget)->textRole() != Uml::TextRole::Floating) {
+ if (widget->isTextWidget() &&
+ widget->asFloatingTextWidget()->textRole() != Uml::TextRole::Floating) {
widget->setSelectedFlag(false);
widget->hide();
} else {
@@ -1568,7 +1568,7 @@ void UMLScene::selectWidgets(qreal px, qreal py, qreal qx, qreal qy)
// Select messages that fall within the selection rectangle
foreach(MessageWidget* temp, m_MessageList) {
- selectWidget(dynamic_cast<UMLWidget*>(temp), &rect);
+ selectWidget(temp->asUMLWidget(), &rect);
}
// Select associations of selected widgets
@@ -1609,8 +1609,8 @@ void UMLScene::selectWidget(UMLWidget* widget, QRectF* rect)
//if it is text that is part of an association then select the association
//and the objects that are connected to it.
- if (widget->baseType() == WidgetBase::wt_Text) {
- FloatingTextWidget *ft = static_cast<FloatingTextWidget*>(widget);
+ if (widget->isTextWidget()) {
+ FloatingTextWidget *ft = widget->asFloatingTextWidget();
Uml::TextRole::Enum t = ft->textRole();
LinkWidget *lw = ft->link();
MessageWidget * mw = dynamic_cast<MessageWidget*>(lw);
@@ -1621,8 +1621,8 @@ void UMLScene::selectWidget(UMLWidget* widget, QRectF* rect)
if (a)
selectWidgetsOfAssoc(a);
}
- } else if (widget->baseType() == WidgetBase::wt_Message) {
- MessageWidget *mw = static_cast<MessageWidget*>(widget);
+ } else if (widget->isMessageWidget()) {
+ MessageWidget *mw = widget->asMessageWidget();
makeSelected(mw);
}
if (widget->isVisible()) {
@@ -1725,7 +1725,7 @@ void UMLScene::activate()
//Activate Regular widgets then activate messages
foreach(UMLWidget* obj, m_WidgetList) {
//If this UMLWidget is already activated or is a MessageWidget then skip it
- if (obj->isActivated() || obj->baseType() == WidgetBase::wt_Message) {
+ if (obj->isActivated() || obj->isMessageWidget()) {
continue;
}
@@ -1778,7 +1778,7 @@ int UMLScene::selectedCount(bool filterText) const
return selectedWidgets().count();
int counter = 0;
foreach(UMLWidget* temp, selectedWidgets()) {
- if (temp->baseType() == WidgetBase::wt_Text) {
+ if (temp->isTextWidget()) {
const FloatingTextWidget *ft = static_cast<const FloatingTextWidget*>(temp);
if (ft->textRole() == TextRole::Floating)
counter++;
@@ -1802,8 +1802,8 @@ UMLWidgetList UMLScene::selectedWidgetsExt(bool filterText /*= true*/)
UMLWidgetList widgetList;
foreach(UMLWidget* widgt, selectedWidgets()) {
- if (filterText && widgt->baseType() == WidgetBase::wt_Text) {
- const FloatingTextWidget *ft = static_cast<const FloatingTextWidget*>(widgt);
+ if (filterText && widgt->isTextWidget()) {
+ FloatingTextWidget *ft = widgt->asFloatingTextWidget();
if (ft->textRole() == Uml::TextRole::Floating)
widgetList.append(widgt);
} else {
@@ -1839,7 +1839,7 @@ void UMLScene::addFloatingTextWidget(FloatingTextWidget* pWidget)
if (xIsOutOfRange || yIsOutOfRange) {
QString name = pWidget->name();
if (name.isEmpty()) {
- FloatingTextWidget *ft = dynamic_cast<FloatingTextWidget*>(pWidget);
+ FloatingTextWidget *ft = pWidget->asFloatingTextWidget();
if (ft)
name = ft->displayText();
}
@@ -2114,8 +2114,8 @@ void UMLScene::removeAllWidgets()
foreach(UMLWidget* temp, m_WidgetList) {
// I had to take this condition back in, else umbrello
// crashes on exit. Still to be analyzed. --okellogg
- if (!(temp->baseType() == WidgetBase::wt_Text &&
- ((FloatingTextWidget *)temp)->textRole() != TextRole::Floating)) {
+ if (!(temp->isTextWidget() &&
+ temp->asFloatingTextWidget()->textRole() != TextRole::Floating)) {
removeWidgetCmd(temp);
}
}
@@ -3527,9 +3527,9 @@ void UMLScene::saveToXMI(QDomDocument & qDoc, QDomElement & qElement)
// We DON'T want to record any text widgets which are belonging
// to associations as they are recorded later in the "associations"
// section when each owning association is dumped. -b.t.
- if ((widget->baseType() != WidgetBase::wt_Text &&
- widget->baseType() != WidgetBase::wt_FloatingDashLine) ||
- static_cast<FloatingTextWidget*>(widget)->link() == NULL)
+ if ((!widget->isTextWidget() &&
+ !widget->isFloatingDashLineWidget()) ||
+ widget->asFloatingTextWidget()->link() == NULL)
widget->saveToXMI(qDoc, widgetElement);
}
viewElement.appendChild(widgetElement);
diff --git a/umbrello/umlwidgets/associationline.cpp b/umbrello/umlwidgets/associationline.cpp
index 318b198..dc8c2f0 100644
--- a/umbrello/umlwidgets/associationline.cpp
+++ b/umbrello/umlwidgets/associationline.cpp
@@ -1067,7 +1067,7 @@ void AssociationLine::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
// Prevent the moving vertex from disappearing underneath a widget
// (else there's no way to get it back.)
UMLWidget *onW = scene->widgetAt(newPos);
- if (onW && onW->baseType() != WidgetBase::wt_Box) { // boxes are transparent
+ if (onW && !onW->isBoxWidget()) { // boxes are transparent
const qreal pX = newPos.x();
const qreal pY = newPos.y();
const qreal wX = onW->x();
diff --git a/umbrello/umlwidgets/associationwidget.cpp b/umbrello/umlwidgets/associationwidget.cpp
index 7132de8..6614c1a 100644
--- a/umbrello/umlwidgets/associationwidget.cpp
+++ b/umbrello/umlwidgets/associationwidget.cpp
@@ -672,16 +672,16 @@ bool AssociationWidget::operator==(const AssociationWidget& other) const
if (widgetIDForRole(RoleType::B) != other.widgetIDForRole(RoleType::B))
return false;
- if (widgetForRole(RoleType::A)->baseType() == WidgetBase::wt_Object &&
- other.widgetForRole(RoleType::A)->baseType() == WidgetBase::wt_Object) {
+ if (widgetForRole(RoleType::A)->isObjectWidget() &&
+ other.widgetForRole(RoleType::A)->isObjectWidget()) {
ObjectWidget *ownA = static_cast<ObjectWidget*>(widgetForRole(RoleType::A));
ObjectWidget *otherA = static_cast<ObjectWidget*>(other.widgetForRole(RoleType::A));
if (ownA->localID() != otherA->localID())
return false;
}
- if (widgetForRole(RoleType::B)->baseType() == WidgetBase::wt_Object &&
- other.widgetForRole(RoleType::B)->baseType() == WidgetBase::wt_Object) {
+ if (widgetForRole(RoleType::B)->isObjectWidget() &&
+ other.widgetForRole(RoleType::B)->isObjectWidget()) {
ObjectWidget *ownB = static_cast<ObjectWidget*>(widgetForRole(RoleType::B));
ObjectWidget *otherB = static_cast<ObjectWidget*>(other.widgetForRole(RoleType::B));
if (ownB->localID() != otherB->localID())
@@ -1517,7 +1517,7 @@ Uml::ID::Type AssociationWidget::widgetIDForRole(Uml::RoleType::Enum role) const
uError() << "umlWidget is NULL";
return Uml::ID::None;
}
- if (m_role[role].umlWidget->baseType() == WidgetBase::wt_Object)
+ if (m_role[role].umlWidget->isObjectWidget())
return static_cast<ObjectWidget*>(m_role[role].umlWidget)->localID();
Uml::ID::Type id = m_role[role].umlWidget->id();
return id;
@@ -1536,7 +1536,7 @@ Uml::ID::Type AssociationWidget::widgetLocalIDForRole(Uml::RoleType::Enum role)
uError() << "umlWidget is NULL";
return Uml::ID::None;
}
- if (m_role[role].umlWidget->baseType() == WidgetBase::wt_Object)
+ if (m_role[role].umlWidget->isObjectWidget())
return static_cast<ObjectWidget*>(m_role[role].umlWidget)->localID();
Uml::ID::Type id = m_role[role].umlWidget->localID();
return id;
diff --git a/umbrello/umlwidgets/combinedfragmentwidget.cpp b/umbrello/umlwidgets/combinedfragmentwidget.cpp
index 424bc8c..dd821aa 100644
--- a/umbrello/umlwidgets/combinedfragmentwidget.cpp
+++ b/umbrello/umlwidgets/combinedfragmentwidget.cpp
@@ -310,7 +310,7 @@ void CombinedFragmentWidget::askNameForWidgetType(UMLWidget* &targetWidget, cons
#endif
if (pressedOK) {
QString type = result.join(QString());
- dynamic_cast<CombinedFragmentWidget*>(targetWidget)->setCombinedFragmentType(type);
+ targetWidget->asCombinedFragmentWidget()->setCombinedFragmentType(type);
if (type == QLatin1String("Reference"))
Dialog_Utils::askNameForWidget(targetWidget, i18n("Enter the name of the diagram referenced"), i18n("Enter the name of the diagram referenced"), i18n("Diagram name"));
else if (type == QLatin1String(QLatin1String("Loop")))
diff --git a/umbrello/umlwidgets/messagewidget.cpp b/umbrello/umlwidgets/messagewidget.cpp
index b325140..9ce6f59 100644
--- a/umbrello/umlwidgets/messagewidget.cpp
+++ b/umbrello/umlwidgets/messagewidget.cpp
@@ -790,7 +790,7 @@ bool MessageWidget::activate(IDChangeLog * /*Log = 0*/)
DEBUG(DBG_SRC) << "role A object " << Uml::ID::toString(m_widgetAId) << " not found";
return false;
}
- m_pOw[Uml::RoleType::A] = dynamic_cast<ObjectWidget*>(pWA);
+ m_pOw[Uml::RoleType::A] = pWA->asObjectWidget();
if (m_pOw[Uml::RoleType::A] == NULL) {
DEBUG(DBG_SRC) << "role A widget " << Uml::ID::toString(m_widgetAId)
<< " is not an ObjectWidget";
@@ -803,7 +803,7 @@ bool MessageWidget::activate(IDChangeLog * /*Log = 0*/)
DEBUG(DBG_SRC) << "role B object " << Uml::ID::toString(m_widgetBId) << " not found";
return false;
}
- m_pOw[Uml::RoleType::B] = dynamic_cast<ObjectWidget*>(pWB);
+ m_pOw[Uml::RoleType::B] = pWB->asObjectWidget();
if (m_pOw[Uml::RoleType::B] == NULL) {
DEBUG(DBG_SRC) << "role B widget " << Uml::ID::toString(m_widgetBId)
<< " is not an ObjectWidget";
diff --git a/umbrello/umlwidgets/notewidget.cpp b/umbrello/umlwidgets/notewidget.cpp
index dd92ca1..88c33ad 100644
--- a/umbrello/umlwidgets/notewidget.cpp
+++ b/umbrello/umlwidgets/notewidget.cpp
@@ -202,7 +202,7 @@ void NoteWidget::askForNoteType(UMLWidget* &targetWidget)
#endif
if (pressedOK) {
- dynamic_cast<NoteWidget*>(targetWidget)->setNoteType(type);
+ targetWidget->asNoteWidget()->setNoteType(type);
} else {
targetWidget->cleanup();
delete targetWidget;
diff --git a/umbrello/umlwidgets/objectnodewidget.cpp b/umbrello/umlwidgets/objectnodewidget.cpp
index 167a42a..56455f0 100644
--- a/umbrello/umlwidgets/objectnodewidget.cpp
+++ b/umbrello/umlwidgets/objectnodewidget.cpp
@@ -330,7 +330,7 @@ void ObjectNodeWidget::askForObjectNodeType(UMLWidget* &targetWidget)
#endif
if (pressedOK) {
- dynamic_cast<ObjectNodeWidget*>(targetWidget)->setObjectNodeType(type);
+ targetWidget->asObjectNodeWidget()->setObjectNodeType(type);
if (type == QLatin1String("Data store"))
Dialog_Utils::askNameForWidget(targetWidget, i18n("Enter the name of the data store node"), i18n("Enter the name of the data store node"), i18n("data store name"));
if (type == QLatin1String("Central buffer"))
diff --git a/umbrello/umlwidgets/toolbarstateonewidget.cpp b/umbrello/umlwidgets/toolbarstateonewidget.cpp
index d70bf86..c41e249 100644
--- a/umbrello/umlwidgets/toolbarstateonewidget.cpp
+++ b/umbrello/umlwidgets/toolbarstateonewidget.cpp
@@ -139,10 +139,10 @@ void ToolBarStateOneWidget::mouseReleaseWidget()
}
if (m_pMouseEvent->button() != Qt::LeftButton ||
- (currentWidget()->baseType() != WidgetBase::wt_Object &&
- currentWidget()->baseType() != WidgetBase::wt_Activity &&
- currentWidget()->baseType() != WidgetBase::wt_Component &&
- currentWidget()->baseType() != WidgetBase::wt_Region)) {
+ (!currentWidget()->isObjectWidget() &&
+ !currentWidget()->isActivityWidget() &&
+ !currentWidget()->isComponentWidget() &&
+ !currentWidget()->isRegionWidget())) {
return;
}
@@ -191,10 +191,10 @@ void ToolBarStateOneWidget::setWidget(UMLWidget* firstObject)
}
if (widgetType() == WidgetBase::wt_Pin) {
- if (m_firstObject->baseType() == WidgetBase::wt_Activity) {
+ if (m_firstObject->isActivityWidget()) {
umlwidget = new PinWidget(m_pUMLScene, m_firstObject);
// Create the widget. Some setup functions can remove the widget.
- } else if (m_firstObject->baseType() == WidgetBase::wt_Component) {
+ } else if (m_firstObject->isComponentWidget()) {
bool pressedOK = false;
#if QT_VERSION >= 0x050000
QString name = QInputDialog::getText(UMLApp::app(),
diff --git a/umbrello/umlwidgets/widget_utils.cpp b/umbrello/umlwidgets/widget_utils.cpp
index 052c0f5..f0d6292 100644
--- a/umbrello/umlwidgets/widget_utils.cpp
+++ b/umbrello/umlwidgets/widget_utils.cpp
@@ -43,7 +43,7 @@ namespace Widget_Utils
const MessageWidgetList* messages /* = 0 */)
{
foreach (UMLWidget* obj, widgets) {
- if (obj->baseType() == WidgetBase::wt_Object) {
+ if (obj->isObjectWidget()) {
if (static_cast<ObjectWidget *>(obj)->localID() == id)
return obj;
} else if (obj->id() == id) {
diff --git a/umbrello/umlwidgets/widgetbase.cpp b/umbrello/umlwidgets/widgetbase.cpp
index 0eb383f..4f24b6e 100644
--- a/umbrello/umlwidgets/widgetbase.cpp
+++ b/umbrello/umlwidgets/widgetbase.cpp
@@ -675,7 +675,7 @@ QRectF WidgetBase::boundingRect() const
*/
UMLWidget* WidgetBase::onWidget(const QPointF &p)
{
- UMLWidget *uw = dynamic_cast<UMLWidget*>(this);
+ UMLWidget *uw = this->asUMLWidget();
if (uw == NULL)
return NULL;
const qreal w = m_rect.width();
@@ -731,7 +731,7 @@ void WidgetBase::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
}
if (umlObject() != 0) {
- scene->selectWidget(dynamic_cast<UMLWidget*>(this));
+ scene->selectWidget(this->asUMLWidget());
} else {
setSelected(true);
}
@@ -1131,3 +1131,65 @@ QString WidgetBase::toI18nString(WidgetType wt)
return name;
}
+#include "activitywidget.h"
+#include "actorwidget.h"
+#include "artifactwidget.h"
+#include "associationwidget.h"
+#include "boxwidget.h"
+#include "categorywidget.h"
+//#include "classwidget.h"
+#include "combinedfragmentwidget.h"
+#include "componentwidget.h"
+#include "datatypewidget.h"
+#include "entitywidget.h"
+#include "enumwidget.h"
+#include "floatingdashlinewidget.h"
+#include "forkjoinwidget.h"
+//#include "interfacewidget.h"
+#include "messagewidget.h"
+#include "nodewidget.h"
+#include "notewidget.h"
+#include "objectnodewidget.h"
+#include "objectwidget.h"
+#include "packagewidget.h"
+#include "pinwidget.h"
+#include "portwidget.h"
+#include "preconditionwidget.h"
+#include "regionwidget.h"
+#include "signalwidget.h"
+#include "statewidget.h"
+#include "floatingtextwidget.h"
+#include "usecasewidget.h"
+
+ActivityWidget* WidgetBase::asActivityWidget() { return dynamic_cast<ActivityWidget* >(this); }
+ActorWidget* WidgetBase::asActorWidget() { return dynamic_cast<ActorWidget* >(this); }
+ArtifactWidget* WidgetBase::asArtifactWidget() { return dynamic_cast<ArtifactWidget* >(this); }
+AssociationWidget* WidgetBase::asAssociationWidget() { return dynamic_cast<AssociationWidget* >(this); }
+BoxWidget* WidgetBase::asBoxWidget() { return dynamic_cast<BoxWidget* >(this); }
+CategoryWidget* WidgetBase::asCategoryWidget() { return dynamic_cast<CategoryWidget* >(this); }
+ClassifierWidget* WidgetBase::asClassifierWidget() { return dynamic_cast<ClassifierWidget* >(this); }
+CombinedFragmentWidget* WidgetBase::asCombinedFragmentWidget() { return dynamic_cast<CombinedFragmentWidget*>(this); }
+ComponentWidget* WidgetBase::asComponentWidget() { return dynamic_cast<ComponentWidget* >(this); }
+DatatypeWidget* WidgetBase::asDatatypeWidget() { return dynamic_cast<DatatypeWidget* >(this); }
+EntityWidget* WidgetBase::asEntityWidget() { return dynamic_cast<EntityWidget* >(this); }
+EnumWidget* WidgetBase::asEnumWidget() { return dynamic_cast<EnumWidget* >(this); }
+FloatingDashLineWidget* WidgetBase::asFloatingDashLineWidget() { return dynamic_cast<FloatingDashLineWidget*>(this); }
+ForkJoinWidget* WidgetBase::asForkJoinWidget() { return dynamic_cast<ForkJoinWidget* >(this); }
+//InterfaceWidget* WidgetBase::asInterfaceWidget() { return dynamic_cast<InterfaceWidget* >(this); }
+MessageWidget* WidgetBase::asMessageWidget() { return dynamic_cast<MessageWidget* >(this); }
+NodeWidget* WidgetBase::asNodeWidget() { return dynamic_cast<NodeWidget* >(this); }
+NoteWidget* WidgetBase::asNoteWidget() { return dynamic_cast<NoteWidget* >(this); }
+ObjectNodeWidget* WidgetBase::asObjectNodeWidget() { return dynamic_cast<ObjectNodeWidget* >(this); }
+ObjectWidget* WidgetBase::asObjectWidget() { return dynamic_cast<ObjectWidget* >(this); }
+PackageWidget* WidgetBase::asPackageWidget() { return dynamic_cast<PackageWidget* >(this); }
+PinWidget* WidgetBase::asPinWidget() { return dynamic_cast<PinWidget* >(this); }
+PinPortBase *WidgetBase::asPinPortBase() { return dynamic_cast<PinPortBase*>(this); }
+PortWidget* WidgetBase::asPortWidget() { return dynamic_cast<PortWidget* >(this); }
+PreconditionWidget* WidgetBase::asPreconditionWidget() { return dynamic_cast<PreconditionWidget* >(this); }
+RegionWidget* WidgetBase::asRegionWidget() { return dynamic_cast<RegionWidget* >(this); }
+SignalWidget* WidgetBase::asSignalWidget() { return dynamic_cast<SignalWidget* >(this); }
+StateWidget* WidgetBase::asStateWidget() { return dynamic_cast<StateWidget* >(this); }
+FloatingTextWidget* WidgetBase::asFloatingTextWidget() { return dynamic_cast<FloatingTextWidget* >(this); }
+//TextWidget* WidgetBase::asTextWidget() { return dynamic_cast<TextWidget* >(this); }
+UseCaseWidget* WidgetBase::asUseCaseWidget() { return dynamic_cast<UseCaseWidget* >(this); }
+UMLWidget *WidgetBase::asUMLWidget() { return dynamic_cast<UMLWidget*>(this); }
diff --git a/umbrello/umlwidgets/widgetbase.h b/umbrello/umlwidgets/widgetbase.h
index 9bb8d22..c236ed0 100644
--- a/umbrello/umlwidgets/widgetbase.h
+++ b/umbrello/umlwidgets/widgetbase.h
@@ -23,6 +23,37 @@
// forward declarations
class QAction;
+class ActivityWidget;
+class ActorWidget;
+class ArtifactWidget;
+class AssociationWidget;
+class BoxWidget;
+class CategoryWidget;
+class ClassifierWidget;
+class CombinedFragmentWidget;
+class ComponentWidget;
+class DatatypeWidget;
+class EntityWidget;
+class EnumWidget;
+class FloatingDashLineWidget;
+class FloatingTextWidget;
+class ForkJoinWidget;
+//class InterfaceWidget;
+class MessageWidget;
+class NodeWidget;
+class NoteWidget;
+class ObjectNodeWidget;
+class ObjectWidget;
+class PackageWidget;
+class PinWidget;
+class PortWidget;
+class PinPortBase;
+class PreconditionWidget;
+class RegionWidget;
+class SignalWidget;
+class StateWidget;
+//class TextWidget;
+class UseCaseWidget;
class UMLDoc;
class UMLObject;
class UMLScene;
@@ -153,6 +184,69 @@ public:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+ bool isActivityWidget() { return baseType() == wt_Activity; }
+ bool isActorWidget() { return baseType() == wt_Actor; }
+ bool isArtifactWidget() { return baseType() == wt_Artifact; }
+ bool isAssociationWidget() { return baseType() == wt_Association; }
+ bool isBoxWidget() { return baseType() == wt_Box; }
+ bool isCategoryWidget() { return baseType() == wt_Category; }
+ bool isClassWidget() { return baseType() == wt_Class; }
+ bool isCombinedFragmentWidget() { return baseType() == wt_CombinedFragment; }
+ bool isComponentWidget() { return baseType() == wt_Component; }
+ bool isDatatypeWidget() { return baseType() == wt_Datatype; }
+ bool isEntityWidget() { return baseType() == wt_Entity; }
+ bool isEnumWidget() { return baseType() == wt_Enum; }
+ bool isFloatingDashLineWidget() { return baseType() == wt_FloatingDashLine; }
+ bool isForkJoinWidget() { return baseType() == wt_ForkJoin; }
+ bool isInterfaceWidget() { return baseType() == wt_Interface; }
+ bool isMessageWidget() { return baseType() == wt_Message; }
+ bool isNodeWidget() { return baseType() == wt_Node; }
+ bool isNoteWidget() { return baseType() == wt_Note; }
+ bool isObjectNodeWidget() { return baseType() == wt_ObjectNode; }
+ bool isObjectWidget() { return baseType() == wt_Object; }
+ bool isPackageWidget() { return baseType() == wt_Package; }
+ bool isPinWidget() { return baseType() == wt_Pin; }
+ bool isPortWidget() { return baseType() == wt_Port; }
+ bool isPreconditionWidget() { return baseType() == wt_Precondition; }
+ bool isRegionWidget() { return baseType() == wt_Region; }
+ bool isSignalWidget() { return baseType() == wt_Signal; }
+ bool isStateWidget() { return baseType() == wt_State; }
+ bool isTextWidget() { return baseType() == wt_Text; }
+ bool isUseCaseWidget() { return baseType() == wt_UseCase; }
+
+ ActivityWidget* asActivityWidget();
+ ActorWidget* asActorWidget();
+ ArtifactWidget* asArtifactWidget();
+ AssociationWidget* asAssociationWidget();
+ BoxWidget* asBoxWidget();
+ CategoryWidget* asCategoryWidget();
+ ClassifierWidget* asClassifierWidget();
+ CombinedFragmentWidget* asCombinedFragmentWidget();
+ ComponentWidget* asComponentWidget();
+ DatatypeWidget* asDatatypeWidget();
+ EntityWidget* asEntityWidget();
+ EnumWidget* asEnumWidget();
+ FloatingDashLineWidget* asFloatingDashLineWidget();
+ ForkJoinWidget* asForkJoinWidget();
+ //InterfaceWidget* asInterfaceWidget();
+ MessageWidget* asMessageWidget();
+ NodeWidget* asNodeWidget();
+ NoteWidget* asNoteWidget();
+ ObjectNodeWidget* asObjectNodeWidget();
+ ObjectWidget* asObjectWidget();
+ PackageWidget* asPackageWidget();
+ PinWidget* asPinWidget();
+ PinPortBase* asPinPortBase();
+ PortWidget* asPortWidget();
+ PreconditionWidget* asPreconditionWidget();
+ RegionWidget* asRegionWidget();
+ SignalWidget* asSignalWidget();
+ StateWidget* asStateWidget();
+ FloatingTextWidget* asFloatingTextWidget();
+// TextWidget* asTextWidget();
+ UseCaseWidget* asUseCaseWidget();
+ UMLWidget* asUMLWidget();
+
public Q_SLOTS:
virtual void slotMenuSelection(QAction *trigger);