summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <[email protected]>2017-03-07 14:00:18 +0100
committerRalf Habacker <[email protected]>2017-05-08 10:53:50 +0200
commit0648bc9f33d1e9a448b2b183d1bc89e0c6c62a74 (patch)
tree6bcf7ad9c1ce4cb5778f09341f3c7a84a31b0dca
parent1f118cb43752f075634741fd19eb872c4658ea3c (diff)
Remove obsolate double book keeping of widgets in class UMLScene.
QGraphicsScene already holds all widgets; there is no need to maintain additional lists, which may go out of sync and are therefore unreliable.
-rw-r--r--umbrello/cmds/widget/cmdbasewidgetcommand.cpp7
-rw-r--r--umbrello/diagram_utils.cpp6
-rw-r--r--umbrello/messagewidgetlist.h5
-rw-r--r--umbrello/toolbarstatemessages.cpp5
-rw-r--r--umbrello/umlscene.cpp184
-rw-r--r--umbrello/umlscene.h17
-rw-r--r--umbrello/umlwidgets/associationwidget.cpp4
-rw-r--r--umbrello/umlwidgets/combinedfragmentwidget.cpp4
-rw-r--r--umbrello/umlwidgets/widgetbase.cpp1
9 files changed, 117 insertions, 116 deletions
diff --git a/umbrello/cmds/widget/cmdbasewidgetcommand.cpp b/umbrello/cmds/widget/cmdbasewidgetcommand.cpp
index c5d73db..b197af3 100644
--- a/umbrello/cmds/widget/cmdbasewidgetcommand.cpp
+++ b/umbrello/cmds/widget/cmdbasewidgetcommand.cpp
@@ -68,12 +68,7 @@ namespace Uml
*/
void CmdBaseWidgetCommand::addWidgetToScene(UMLWidget* umlWidget)
{
- if (umlWidget->isMessageWidget()) {
- scene()->messageList().append(umlWidget->asMessageWidget());
- } else {
- scene()->addWidget(umlWidget);
- }
-
+ scene()->addWidgetCmd(umlWidget);
umlWidget->activate();
}
}
diff --git a/umbrello/diagram_utils.cpp b/umbrello/diagram_utils.cpp
index ef9593e..85d48aa 100644
--- a/umbrello/diagram_utils.cpp
+++ b/umbrello/diagram_utils.cpp
@@ -204,7 +204,7 @@ bool importSequences(const QStringList &lines, UMLScene *scene)
ObjectWidget *leftWidget = (ObjectWidget *)Widget_Factory::createWidget(scene, left);
leftWidget->activate();
// required to be savable
- scene->addWidget(leftWidget);
+ scene->addWidgetCmd(leftWidget);
objectsMap[name] = leftWidget;
ObjectWidget *rightWidget = 0;
@@ -251,7 +251,7 @@ bool importSequences(const QStringList &lines, UMLScene *scene)
rightWidget->setX(mostRightWidget->x() + mostRightWidget->width() + 10);
rightWidget->activate();
objectsMap[package] = rightWidget;
- scene->addWidget(rightWidget);
+ scene->addWidgetCmd(rightWidget);
mostRightWidget = rightWidget;
}
@@ -265,7 +265,7 @@ bool importSequences(const QStringList &lines, UMLScene *scene)
messageWidget->activate();
messageWidget->setY(y);
// to make it savable
- scene->messageList().append(messageWidget);
+ scene->addWidgetCmd(messageWidget);
messages.insert(0, messageWidget);
leftWidget = rightWidget;
diff --git a/umbrello/messagewidgetlist.h b/umbrello/messagewidgetlist.h
index e5e0afa..a09a694 100644
--- a/umbrello/messagewidgetlist.h
+++ b/umbrello/messagewidgetlist.h
@@ -13,10 +13,11 @@
#define MESSAGEWIDGETLIST_H
#include <QList>
+#include <QPointer>
class MessageWidget;
-typedef QList<MessageWidget*> MessageWidgetList;
-typedef QListIterator<MessageWidget*> MessageWidgetListIt;
+typedef QList<QPointer<MessageWidget>> MessageWidgetList;
+typedef QListIterator<QPointer<MessageWidget>> MessageWidgetListIt;
#endif
diff --git a/umbrello/toolbarstatemessages.cpp b/umbrello/toolbarstatemessages.cpp
index 13774dc..69b67d4 100644
--- a/umbrello/toolbarstatemessages.cpp
+++ b/umbrello/toolbarstatemessages.cpp
@@ -304,8 +304,7 @@ void ToolBarStateMessages::cleanMessage()
void ToolBarStateMessages::setupMessageWidget(MessageWidget *message)
{
- m_pUMLScene->messageList().append(message);
- m_pUMLScene->addItem(message);
+ m_pUMLScene->addWidgetCmd(message);
message->activate();
FloatingTextWidget *ft = message->floatingTextWidget();
@@ -313,7 +312,7 @@ void ToolBarStateMessages::setupMessageWidget(MessageWidget *message)
//Shouldn't it cancel also the whole creation?
ft->showOperationDialog();
message->setTextPosition();
- m_pUMLScene->addWidget(ft);
+ m_pUMLScene->addWidgetCmd(ft);
UMLApp::app()->document()->setModified();
}
diff --git a/umbrello/umlscene.cpp b/umbrello/umlscene.cpp
index f38e30c..c8c182d 100644
--- a/umbrello/umlscene.cpp
+++ b/umbrello/umlscene.cpp
@@ -141,10 +141,6 @@ UMLScene::UMLScene(UMLFolder *parentFolder, UMLView *view)
m_bPopupShowing(false),
m_autoIncrementSequence(false)
{
- //m_AssociationList.setAutoDelete(true);
- //m_WidgetList.setAutoDelete(true);
- //m_MessageList.setAutoDelete(true);
-
m_PastePoint = QPointF(0, 0);
m_pImageExporter = new UMLViewImageExporter(this);
@@ -450,31 +446,55 @@ void UMLScene::setOptionState(const Settings::OptionState& options)
/**
* Returns a reference to the association list.
*/
-AssociationWidgetList& UMLScene::associationList()
+const AssociationWidgetList UMLScene::associationList() const
{
- return m_AssociationList;
+ AssociationWidgetList result;
+ foreach(QGraphicsItem *item, items()) {
+ AssociationWidget *w = dynamic_cast<AssociationWidget*>(item);
+ if (w)
+ result.append(w);
+ }
+ return result;
}
/**
* Returns a reference to the widget list.
*/
-const UMLWidgetList& UMLScene::widgetList() const
+const UMLWidgetList UMLScene::widgetList() const
{
- return m_WidgetList;
+ UMLWidgetList result;
+ foreach(QGraphicsItem *item, items()) {
+ UMLWidget *w = dynamic_cast<UMLWidget*>(item);
+ if (w && !w->isMessageWidget() && !w->isAssociationWidget())
+ result.append(w);
+ }
+ return result;
+}
+
+void UMLScene::addWidgetCmd(UMLWidget* widget)
+{
+ Q_ASSERT(0 != widget);
+ addItem(widget);
}
-void UMLScene::addWidget(UMLWidget* widget)
+void UMLScene::addWidgetCmd(AssociationWidget* widget)
{
Q_ASSERT(0 != widget);
- m_WidgetList.append(widget);
+ addItem(widget);
}
/**
* Returns a reference to the message list.
*/
-MessageWidgetList& UMLScene::messageList()
+const MessageWidgetList UMLScene::messageList() const
{
- return m_MessageList;
+ MessageWidgetList result;
+ foreach(QGraphicsItem *item, items()) {
+ MessageWidget *w = dynamic_cast<MessageWidget*>(item);
+ if (w)
+ result.append(w);
+ }
+ return result;
}
/**
@@ -572,7 +592,7 @@ void UMLScene::setupNewWidget(UMLWidget *w, bool setPosition)
m_doc->setModified();
if (m_doc->loading()) { // do not emit signals while loading
- addWidget(w);
+ addWidgetCmd(w);
// w->activate(); // will be done by UMLDoc::activateAllViews() after loading
} else {
UMLApp::app()->executeCommand(new CmdCreateWidget(w));
@@ -693,7 +713,7 @@ void UMLScene::slotObjectRemoved(UMLObject * o)
m_bPaste = false;
Uml::ID::Type id = o->id();
- foreach(UMLWidget* obj, m_WidgetList) {
+ foreach(UMLWidget* obj, widgetList()) {
if (obj->id() != id)
continue;
removeWidget(obj);
@@ -779,7 +799,7 @@ void UMLScene::dropEvent(QGraphicsSceneDragDropEvent *e)
if (Model_Utils::typeIsDiagram(lvtype)) {
bool breakFlag = false;
UMLWidget* w = 0;
- foreach(w, m_WidgetList) {
+ foreach(w, widgetList()) {
if (w->isNoteWidget() && w->onWidget(e->scenePos())) {
breakFlag = true;
break;
@@ -895,7 +915,7 @@ void UMLScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* ome)
*/
ObjectWidget * UMLScene::onWidgetLine(const QPointF &point) const
{
- foreach(UMLWidget* obj, m_WidgetList) {
+ foreach(UMLWidget* obj, widgetList()) {
ObjectWidget *ow = obj->asObjectWidget();
if (ow == 0)
continue;
@@ -920,7 +940,7 @@ ObjectWidget * UMLScene::onWidgetLine(const QPointF &point) const
*/
ObjectWidget * UMLScene::onWidgetDestructionBox(const QPointF &point) const
{
- foreach(UMLWidget* obj, m_WidgetList) {
+ foreach(UMLWidget* obj, widgetList()) {
ObjectWidget *ow = obj->asObjectWidget();
if (ow == 0)
continue;
@@ -999,7 +1019,7 @@ void UMLScene::checkMessages(ObjectWidget * w)
return;
}
- foreach(MessageWidget *obj, m_MessageList) {
+ foreach(MessageWidget *obj, messageList()) {
if (obj->hasObjectWidget(w)) {
removeWidgetCmd(obj);
}
@@ -1015,7 +1035,7 @@ void UMLScene::checkMessages(ObjectWidget * w)
*/
UMLWidget* UMLScene::widgetOnDiagram(Uml::ID::Type id)
{
- foreach(UMLWidget *obj, m_WidgetList) {
+ foreach(UMLWidget *obj, widgetList()) {
if (!obj)
continue;
UMLWidget* w = obj->widgetWithID(id);
@@ -1023,7 +1043,7 @@ UMLWidget* UMLScene::widgetOnDiagram(Uml::ID::Type id)
return w;
}
- foreach(UMLWidget *obj, m_MessageList) {
+ foreach(UMLWidget *obj, messageList()) {
// CHECK: Should MessageWidget reimplement widgetWithID() ?
// If yes then we should use obj->widgetWithID(id) here too.
if (id == obj->id())
@@ -1042,7 +1062,7 @@ UMLWidget* UMLScene::widgetOnDiagram(Uml::ID::Type id)
*/
UMLWidget * UMLScene::findWidget(Uml::ID::Type id)
{
- foreach(UMLWidget* obj, m_WidgetList) {
+ foreach(UMLWidget* obj, widgetList()) {
if (!obj)
continue;
UMLWidget* w = obj->widgetWithID(id);
@@ -1051,7 +1071,7 @@ UMLWidget * UMLScene::findWidget(Uml::ID::Type id)
}
}
- foreach(UMLWidget* obj, m_MessageList) {
+ foreach(UMLWidget* obj, messageList()) {
// CHECK: Should MessageWidget reimplement widgetWithID() ?
// If yes then we should use obj->widgetWithID(id) here too.
if (obj->localID() == id ||
@@ -1071,7 +1091,7 @@ UMLWidget * UMLScene::findWidget(Uml::ID::Type id)
*/
AssociationWidget * UMLScene::findAssocWidget(Uml::ID::Type id)
{
- foreach(AssociationWidget* obj, m_AssociationList) {
+ foreach(AssociationWidget* obj, associationList()) {
UMLAssociation* umlassoc = obj->association();
if (umlassoc && umlassoc->id() == id) {
return obj;
@@ -1095,7 +1115,7 @@ AssociationWidget * UMLScene::findAssocWidget(Uml::ID::Type id)
AssociationWidget * UMLScene::findAssocWidget(UMLWidget *pWidgetA,
UMLWidget *pWidgetB, const QString& roleNameB)
{
- foreach(AssociationWidget* assoc, m_AssociationList) {
+ foreach(AssociationWidget* assoc, associationList()) {
const Uml::AssociationType::Enum testType = assoc->associationType();
if (testType != Uml::AssociationType::Association &&
testType != Uml::AssociationType::UniAssociation &&
@@ -1126,7 +1146,7 @@ AssociationWidget * UMLScene::findAssocWidget(UMLWidget *pWidgetA,
AssociationWidget * UMLScene::findAssocWidget(AssociationType::Enum at,
UMLWidget *pWidgetA, UMLWidget *pWidgetB)
{
- foreach(AssociationWidget* assoc, m_AssociationList) {
+ foreach(AssociationWidget* assoc, associationList()) {
Uml::AssociationType::Enum testType = assoc->associationType();
if (testType != at) {
continue;
@@ -1176,11 +1196,7 @@ void UMLScene::removeWidgetCmd(UMLWidget * o)
disconnect(this, SIGNAL(sigFillColorChanged(Uml::ID::Type)), o, SLOT(slotFillColorChanged(Uml::ID::Type)));
disconnect(this, SIGNAL(sigLineColorChanged(Uml::ID::Type)), o, SLOT(slotLineColorChanged(Uml::ID::Type)));
disconnect(this, SIGNAL(sigTextColorChanged(Uml::ID::Type)), o, SLOT(slotTextColorChanged(Uml::ID::Type)));
- if (t == WidgetBase::wt_Message) {
- m_MessageList.removeAll(static_cast<MessageWidget*>(o));
- } else {
- m_WidgetList.removeAll(o);
- }
+ removeItem(o);
o->deleteLater();
m_doc->setModified(true);
}
@@ -1402,8 +1418,8 @@ void UMLScene::unselectChildrenOfSelectedWidgets()
void UMLScene::deleteSelection()
{
int selectionCount = (selectedWidgets().count()
- + m_AssociationList.count()
- + m_MessageList.count());
+ + associationList().count()
+ + messageList().count());
if (selectionCount > 1) {
UMLApp::app()->beginMacro(i18n("Delete widgets"));
@@ -1424,16 +1440,16 @@ void UMLScene::deleteSelection()
}
// Delete any selected associations.
- foreach(AssociationWidget* assocwidget, m_AssociationList) {
+ foreach(AssociationWidget* assocwidget, associationList()) {
if (assocwidget->isSelected()) {
- removeAssoc(assocwidget);
+ removeWidgetCmd(assocwidget);
}
}
// we also have to remove selected messages from sequence diagrams
// loop through all messages and check the selection state
- foreach(MessageWidget* cur_msgWgt, m_MessageList) {
+ foreach(MessageWidget* cur_msgWgt, messageList()) {
if (cur_msgWgt->isSelected()) {
removeWidget(cur_msgWgt); // Remove message - it is selected.
}
@@ -1584,12 +1600,13 @@ void UMLScene::selectWidgets(qreal px, qreal py, qreal qx, qreal qy)
}
// Select UMLWidgets that fall within the selection rectangle
- foreach(UMLWidget* temp, m_WidgetList) {
+ foreach(UMLWidget* temp, widgetList()) {
+ uIgnoreZeroPointer(temp);
selectWidget(temp, &rect);
}
// Select messages that fall within the selection rectangle
- foreach(MessageWidget* temp, m_MessageList) {
+ foreach(MessageWidget* temp, messageList()) {
selectWidget(temp->asUMLWidget(), &rect);
}
@@ -1597,7 +1614,7 @@ void UMLScene::selectWidgets(qreal px, qreal py, qreal qx, qreal qy)
selectAssociations(true);
// Automatically select all messages if two object widgets are selected
- foreach(MessageWidget *w, m_MessageList) {
+ foreach(MessageWidget *w, messageList()) {
if (w->objectWidget(Uml::RoleType::A)->isSelected() &&
w->objectWidget(Uml::RoleType::B)->isSelected()) {
makeSelected(w);
@@ -1745,7 +1762,8 @@ void UMLScene::slotActivate()
void UMLScene::activate()
{
//Activate Regular widgets then activate messages
- foreach(UMLWidget* obj, m_WidgetList) {
+ foreach(UMLWidget* obj, widgetList()) {
+ uIgnoreZeroPointer(obj);
//If this UMLWidget is already activated or is a MessageWidget then skip it
if (obj->isActivated() || obj->isMessageWidget()) {
continue;
@@ -1754,13 +1772,13 @@ void UMLScene::activate()
if (obj->activate()) {
obj->setVisible(true);
} else {
- m_WidgetList.removeAll(obj);
+ removeItem(obj);
delete obj;
}
}//end foreach
//Activate Message widgets
- foreach(UMLWidget* obj, m_MessageList) {
+ foreach(UMLWidget* obj, messageList()) {
//If this MessageWidget is already activated then skip it
if (obj->isActivated())
continue;
@@ -1772,7 +1790,7 @@ void UMLScene::activate()
// Activate all association widgets
- foreach(AssociationWidget* aw, m_AssociationList) {
+ foreach(AssociationWidget* aw, associationList()) {
if (aw->activate()) {
if (m_PastePoint.x() != 0) {
int x = m_PastePoint.x() - m_Pos.x();
@@ -1780,7 +1798,7 @@ void UMLScene::activate()
aw->moveEntireAssoc(x, y);
}
} else {
- m_AssociationList.removeAll(aw);
+ removeWidgetCmd(aw);
delete aw;
}
}
@@ -1842,7 +1860,7 @@ AssociationWidgetList UMLScene::selectedAssocs()
{
AssociationWidgetList assocWidgetList;
- foreach(AssociationWidget* assocwidget, m_AssociationList) {
+ foreach(AssociationWidget* assocwidget, associationList()) {
if (assocwidget->isSelected())
assocWidgetList.append(assocwidget);
}
@@ -1877,7 +1895,7 @@ void UMLScene::addFloatingTextWidget(FloatingTextWidget* pWidget)
}
}
- addWidget(pWidget);
+ addWidgetCmd(pWidget);
}
/**
@@ -1946,14 +1964,14 @@ bool UMLScene::addAssociation(AssociationWidget* pAssoc, bool isPasteOperation)
//make sure there isn't already the same assoc
- foreach(AssociationWidget* assocwidget, m_AssociationList) {
+ foreach(AssociationWidget* assocwidget, associationList()) {
if (*pAssoc == *assocwidget)
// this is nuts. Paste operation wants to know if 'true'
// for duplicate, but loadFromXMI1 needs 'false' value
return (isPasteOperation ? true : false);
}
- m_AssociationList.append(pAssoc);
+ addWidgetCmd(pAssoc);
FloatingTextWidget *ft[5] = { pAssoc->nameWidget(),
pAssoc->roleWidget(Uml::RoleType::A),
@@ -2017,7 +2035,7 @@ void UMLScene::endPartialWidgetPaste()
*
* @param pAssoc Pointer to the AssociationWidget.
*/
-void UMLScene::removeAssoc(AssociationWidget* pAssoc)
+void UMLScene::removeWidgetCmd(AssociationWidget* pAssoc)
{
if (!pAssoc)
return;
@@ -2025,7 +2043,7 @@ void UMLScene::removeAssoc(AssociationWidget* pAssoc)
emit sigAssociationRemoved(pAssoc);
pAssoc->cleanup();
- m_AssociationList.removeAll(pAssoc);
+ removeItem(pAssoc);
pAssoc->deleteLater();
m_doc->setModified();
}
@@ -2059,7 +2077,7 @@ void UMLScene::removeAssocInViewAndDoc(AssociationWidget* a)
// Remove assoc in doc.
m_doc->removeAssociation(a->association());
// Remove assoc in view.
- removeAssoc(a);
+ removeWidgetCmd(a);
}
}
@@ -2070,9 +2088,9 @@ void UMLScene::removeAssocInViewAndDoc(AssociationWidget* a)
*/
void UMLScene::removeAssociations(UMLWidget* widget)
{
- foreach(AssociationWidget* assocwidget, m_AssociationList) {
+ foreach(AssociationWidget* assocwidget, associationList()) {
if (assocwidget->containsAsEndpoint(widget)) {
- removeAssoc(assocwidget);
+ removeWidgetCmd(assocwidget);
}
}
}
@@ -2084,7 +2102,7 @@ void UMLScene::removeAssociations(UMLWidget* widget)
*/
void UMLScene::selectAssociations(bool bSelect)
{
- foreach(AssociationWidget* assocwidget, m_AssociationList) {
+ foreach(AssociationWidget* assocwidget, associationList()) {
UMLWidget *widA = assocwidget->widgetForRole(Uml::RoleType::A);
UMLWidget *widB = assocwidget->widgetForRole(Uml::RoleType::B);
if (bSelect &&
@@ -2105,7 +2123,7 @@ void UMLScene::getWidgetAssocs(UMLObject* Obj, AssociationWidgetList & Associati
if (! Obj)
return;
- foreach(AssociationWidget* assocwidget, m_AssociationList) {
+ foreach(AssociationWidget* assocwidget, associationList()) {
if (assocwidget->widgetForRole(Uml::RoleType::A)->umlObject() == Obj ||
assocwidget->widgetForRole(Uml::RoleType::B)->umlObject() == Obj)
Associations.append(assocwidget);
@@ -2119,12 +2137,9 @@ void UMLScene::getWidgetAssocs(UMLObject* Obj, AssociationWidgetList & Associati
void UMLScene::removeAllAssociations()
{
//Remove All association widgets
- foreach(AssociationWidget* assocwidget, m_AssociationList) {
- removeAssoc(assocwidget);
+ foreach(AssociationWidget* assocwidget, associationList()) {
+ removeWidgetCmd(assocwidget);
}
-
- qDeleteAll(m_AssociationList);
- m_AssociationList.clear();
}
/**
@@ -2133,7 +2148,7 @@ void UMLScene::removeAllAssociations()
void UMLScene::removeAllWidgets()
{
// Remove widgets.
- foreach(UMLWidget* temp, m_WidgetList) {
+ foreach(UMLWidget* temp, widgetList()) {
uIgnoreZeroPointer(temp);
// I had to take this condition back in, else umbrello
// crashes on exit. Still to be analyzed. --okellogg
@@ -2142,9 +2157,6 @@ void UMLScene::removeAllWidgets()
removeWidgetCmd(temp);
}
}
-
- qDeleteAll(m_WidgetList);
- m_WidgetList.clear();
}
/**
@@ -2163,7 +2175,7 @@ void UMLScene::updateContainment(UMLCanvasObject *self)
// While we're at it, also see if the new parent has a widget here.
UMLWidget *selfWidget = 0, *newParentWidget = 0;
UMLPackage *newParent = self->umlPackage();
- foreach(UMLWidget* w, m_WidgetList) {
+ foreach(UMLWidget* w, widgetList()) {
UMLObject *o = w->umlObject();
if (o == self)
selfWidget = w;
@@ -2173,7 +2185,7 @@ void UMLScene::updateContainment(UMLCanvasObject *self)
if (selfWidget == 0)
return;
// Remove possibly obsoleted containment association.
- foreach(AssociationWidget* a, m_AssociationList) {
+ foreach(AssociationWidget* a, associationList()) {
if (a->associationType() != Uml::AssociationType::Containment)
continue;
// Container is at role A, containee at B.
@@ -2188,7 +2200,7 @@ void UMLScene::updateContainment(UMLCanvasObject *self)
// Wow, all done. Great!
return;
}
- removeAssoc(a); // AutoDelete is true
+ removeWidgetCmd(a);
// It's okay to break out because there can only be a single
// containing object.
break;
@@ -2199,7 +2211,7 @@ void UMLScene::updateContainment(UMLCanvasObject *self)
AssociationWidget *a = AssociationWidget::create
(this, newParentWidget,
Uml::AssociationType::Containment, selfWidget);
- m_AssociationList.append(a);
+ addWidgetCmd(a);
}
/**
@@ -2285,7 +2297,7 @@ void UMLScene::createAutoAssociations(UMLWidget * widget)
bool breakFlag = false;
UMLWidget* pOtherWidget = 0;
- foreach(pOtherWidget, m_WidgetList) {
+ foreach(pOtherWidget, widgetList()) {
if (pOtherWidget->id() == otherID) {
breakFlag = true;
break;
@@ -2350,7 +2362,7 @@ void UMLScene::createAutoAssociations(UMLWidget * widget)
uIgnoreZeroPointer(obj);
// if the containedObject has a widget representation on this view then
Uml::ID::Type id = obj->id();
- foreach(UMLWidget *w, m_WidgetList) {
+ foreach(UMLWidget *w, widgetList()) {
uIgnoreZeroPointer(w);
if (w->id() != id)
continue;
@@ -2376,7 +2388,7 @@ void UMLScene::createAutoAssociations(UMLWidget * widget)
bool breakFlag = false;
UMLWidget* pWidget = 0;
- foreach(pWidget, m_WidgetList) {
+ foreach(pWidget, widgetList()) {
uIgnoreZeroPointer(pWidget);
if (pWidget->id() == pkgID) {
breakFlag = true;
@@ -2609,7 +2621,7 @@ void UMLScene::createAutoConstraintAssociation(UMLEntity* refEntity, UMLForeignK
void UMLScene::createAutoAttributeAssociations2(UMLWidget *widget)
{
- foreach(UMLWidget* w, m_WidgetList) {
+ foreach(UMLWidget* w, widgetList()) {
uIgnoreZeroPointer(w);
if (w != widget) {
createAutoAttributeAssociations(w);
@@ -2700,7 +2712,7 @@ void UMLScene::copyAsImage(QPixmap*& pix)
//get each type of associations
//This needs to be reimplemented to increase the rectangle
//if a part of any association is not included
- foreach(AssociationWidget *a, m_AssociationList) {
+ foreach(AssociationWidget *a, associationList()) {
if (! a->isSelected())
continue;
const FloatingTextWidget* multiA = a->multiplicityWidget(Uml::RoleType::A);
@@ -3205,7 +3217,7 @@ void UMLScene::setFont(QFont font, bool changeAllWidgets /* = false */)
m_Options.uiState.font = font;
if (!changeAllWidgets)
return;
- foreach(UMLWidget* w, m_WidgetList) {
+ foreach(UMLWidget* w, widgetList()) {
uIgnoreZeroPointer(w);
w->setFont(font);
}
@@ -3216,7 +3228,7 @@ void UMLScene::setFont(QFont font, bool changeAllWidgets /* = false */)
*/
void UMLScene::setClassWidgetOptions(ClassOptionsPage * page)
{
- foreach(UMLWidget* pWidget, m_WidgetList) {
+ foreach(UMLWidget* pWidget, widgetList()) {
uIgnoreZeroPointer(pWidget);
WidgetBase::WidgetType wt = pWidget->baseType();
if (wt == WidgetBase::wt_Class || wt == WidgetBase::wt_Interface) {
@@ -3474,7 +3486,7 @@ void UMLScene::resizeSceneToItems()
void UMLScene::updateComponentSizes()
{
// update sizes of all components
- foreach(UMLWidget *obj, m_WidgetList) {
+ foreach(UMLWidget *obj, widgetList()) {
uIgnoreZeroPointer(obj);
obj->updateGeometry();
}
@@ -3491,7 +3503,7 @@ void UMLScene::updateComponentSizes()
*/
void UMLScene::forceUpdateWidgetFontMetrics(QPainter * painter)
{
- foreach(UMLWidget *obj, m_WidgetList) {
+ foreach(UMLWidget *obj, widgetList()) {
uIgnoreZeroPointer(obj);
obj->forceUpdateFontMetrics(painter);
}
@@ -3537,7 +3549,7 @@ void UMLScene::saveToXMI1(QDomDocument & qDoc, QDomElement & qElement)
//now save all the widgets
QDomElement widgetElement = qDoc.createElement(QLatin1String("widgets"));
- foreach(UMLWidget *widget, m_WidgetList) {
+ foreach(UMLWidget *widget, widgetList()) {
uIgnoreZeroPointer(widget);
// Having an exception is bad I know, but gotta work with
// system we are given.
@@ -3552,14 +3564,14 @@ void UMLScene::saveToXMI1(QDomDocument & qDoc, QDomElement & qElement)
viewElement.appendChild(widgetElement);
//now save the message widgets
QDomElement messageElement = qDoc.createElement(QLatin1String("messages"));
- foreach(UMLWidget* widget, m_MessageList) {
+ foreach(UMLWidget* widget, messageList()) {
widget->saveToXMI1(qDoc, messageElement);
}
viewElement.appendChild(messageElement);
//now save the associations
QDomElement assocElement = qDoc.createElement(QLatin1String("associations"));
- if (m_AssociationList.count()) {
- // We guard against (m_AssociationList.count() == 0) because
+ if (associationList().count()) {
+ // We guard against (associationList().count() == 0) because
// this code could be reached as follows:
// ^ UMLScene::saveToXMI1()
// ^ UMLDoc::saveToXMI1()
@@ -3571,7 +3583,7 @@ void UMLScene::saveToXMI1(QDomDocument & qDoc, QDomElement & qElement)
// ^ main()
//
AssociationWidget * assoc = 0;
- foreach(assoc, m_AssociationList) {
+ foreach(assoc, associationList()) {
assoc->saveToXMI1(qDoc, assocElement);
}
}
@@ -3706,7 +3718,7 @@ bool UMLScene::loadWidgetsFromXMI(QDomElement & qElement)
while (!widgetElement.isNull()) {
widget = loadWidgetFromXMI(widgetElement);
if (widget) {
- addWidget(widget);
+ addWidgetCmd(widget);
widget->clipSize();
// In the interest of best-effort loading, in case of a
// (widget == 0) we still go on.
@@ -3761,10 +3773,10 @@ bool UMLScene::loadMessagesFromXMI(QDomElement & qElement)
delete message;
return false;
}
- m_MessageList.append(message);
+ addWidgetCmd(message);
FloatingTextWidget *ft = message->floatingTextWidget();
if (ft)
- addWidget(ft);
+ addWidgetCmd(ft);
else if (message->sequenceMessageType() != SequenceMessage::Creation)
DEBUG(DBG_SRC) << "floating text is NULL for message " << Uml::ID::toString(message->id());
}
@@ -3884,7 +3896,7 @@ bool UMLScene::loadUisDiagramPresentation(QDomElement & qElement)
AssociationWidget *aw =
AssociationWidget::create(this, wA, at, wB, umla);
aw->syncToModel();
- m_AssociationList.append(aw);
+ addWidgetCmd(aw);
} else {
uError() << "cannot create assocwidget from (" ; //<< wA << ", " << wB << ")";
}
@@ -3908,7 +3920,7 @@ bool UMLScene::loadUisDiagramPresentation(QDomElement & qElement)
widget->setX(x);
widget->setY(y);
widget->setSize(w, h);
- addWidget(widget);
+ addWidgetCmd(widget);
}
}
}
diff --git a/umbrello/umlscene.h b/umbrello/umlscene.h
index e39f177..d8f1ffc 100644
--- a/umbrello/umlscene.h
+++ b/umbrello/umlscene.h
@@ -148,10 +148,11 @@ public:
Settings::OptionState& optionState();
void setOptionState(const Settings::OptionState& options);
- AssociationWidgetList& associationList();
- const UMLWidgetList& widgetList() const;
- void addWidget(UMLWidget* widget);
- MessageWidgetList& messageList();
+ const AssociationWidgetList associationList() const;
+ const MessageWidgetList messageList() const;
+ const UMLWidgetList widgetList() const;
+ void addWidgetCmd(UMLWidget* widget);
+ void addWidgetCmd(AssociationWidget *widget);
bool isOpen() const;
void setIsOpen(bool isOpen);
@@ -223,7 +224,7 @@ public:
void endPartialWidgetPaste();
void beginPartialWidgetPaste();
- void removeAssoc(AssociationWidget* pAssoc);
+ void removeWidgetCmd(AssociationWidget* pAssoc);
void removeAssociations(UMLWidget* pWidget);
void selectAssociations(bool bSelect);
@@ -327,12 +328,6 @@ protected:
QString m_Documentation; ///< The documentation of the diagram.
Settings::OptionState m_Options; ///< Options used by view.
- MessageWidgetList m_MessageList; ///< All the message widgets on the diagram.
-private:
- UMLWidgetList m_WidgetList; ///< All the UMLWidgets on the diagram.
-protected:
- AssociationWidgetList m_AssociationList; ///< All the AssociationWidgets on the diagram.
-
bool m_bUseSnapToGrid; ///< Flag to use snap to grid. The default is off.
bool m_bUseSnapComponentSizeToGrid; ///< Flag to use snap to grid for component size. The default is off.
bool m_isOpen; ///< Flag is set to true when diagram is open, i.e. shown to the user.
diff --git a/umbrello/umlwidgets/associationwidget.cpp b/umbrello/umlwidgets/associationwidget.cpp
index 0320d0a..df3aaef 100644
--- a/umbrello/umlwidgets/associationwidget.cpp
+++ b/umbrello/umlwidgets/associationwidget.cpp
@@ -3037,7 +3037,7 @@ void AssociationWidget::slotMenuSelection(QAction* action)
else if (association())
m_scene->removeAssocInViewAndDoc(this);
else
- m_scene->removeAssoc(this);
+ m_scene->removeWidgetCmd(this);
break;
case ListPopupMenu::mt_Rename_MultiA:
@@ -3948,7 +3948,7 @@ void AssociationWidget::slotClassifierListItemRemoved(UMLClassifierListItem* obj
return;
}
m_umlObject = 0;
- m_scene->removeAssoc(this);
+ m_scene->removeWidgetCmd(this);
}
/**
diff --git a/umbrello/umlwidgets/combinedfragmentwidget.cpp b/umbrello/umlwidgets/combinedfragmentwidget.cpp
index 2f58b7c..25efa67 100644
--- a/umbrello/umlwidgets/combinedfragmentwidget.cpp
+++ b/umbrello/umlwidgets/combinedfragmentwidget.cpp
@@ -230,7 +230,7 @@ void CombinedFragmentWidget::setCombinedFragmentType(CombinedFragmentType combin
m_dashLines.back()->setYMax(y() + height());
m_dashLines.back()->setY(y() + height()/2);
m_dashLines.back()->setSize(width(), m_dashLines.back()->height());
- m_scene->addWidget(m_dashLines.back());
+ m_scene->addWidgetCmd(m_dashLines.back());
}
}
@@ -362,7 +362,7 @@ bool CombinedFragmentWidget::loadFromXMI1(QDomElement & qElement)
return false;
}
else {
- m_scene->addWidget(fdlwidget);
+ m_scene->addWidgetCmd(fdlwidget);
fdlwidget->clipSize();
}
} else {
diff --git a/umbrello/umlwidgets/widgetbase.cpp b/umbrello/umlwidgets/widgetbase.cpp
index 15fce2c..62b3ca0 100644
--- a/umbrello/umlwidgets/widgetbase.cpp
+++ b/umbrello/umlwidgets/widgetbase.cpp
@@ -59,7 +59,6 @@ WidgetBase::WidgetBase(UMLScene *scene, WidgetType type)
// this operation need to be finished in derived class constructor.
setLineColor(QColor("black"));
setSelected(false);
- scene->addItem(this);
// TODO 310283
setFlags(ItemIsSelectable);