Commit 0648bc9f authored by Ralf Habacker's avatar Ralf Habacker

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.
parent 1f118cb4
...@@ -68,12 +68,7 @@ namespace Uml ...@@ -68,12 +68,7 @@ namespace Uml
*/ */
void CmdBaseWidgetCommand::addWidgetToScene(UMLWidget* umlWidget) void CmdBaseWidgetCommand::addWidgetToScene(UMLWidget* umlWidget)
{ {
if (umlWidget->isMessageWidget()) { scene()->addWidgetCmd(umlWidget);
scene()->messageList().append(umlWidget->asMessageWidget());
} else {
scene()->addWidget(umlWidget);
}
umlWidget->activate(); umlWidget->activate();
} }
} }
...@@ -204,7 +204,7 @@ bool importSequences(const QStringList &lines, UMLScene *scene) ...@@ -204,7 +204,7 @@ bool importSequences(const QStringList &lines, UMLScene *scene)
ObjectWidget *leftWidget = (ObjectWidget *)Widget_Factory::createWidget(scene, left); ObjectWidget *leftWidget = (ObjectWidget *)Widget_Factory::createWidget(scene, left);
leftWidget->activate(); leftWidget->activate();
// required to be savable // required to be savable
scene->addWidget(leftWidget); scene->addWidgetCmd(leftWidget);
objectsMap[name] = leftWidget; objectsMap[name] = leftWidget;
ObjectWidget *rightWidget = 0; ObjectWidget *rightWidget = 0;
...@@ -251,7 +251,7 @@ bool importSequences(const QStringList &lines, UMLScene *scene) ...@@ -251,7 +251,7 @@ bool importSequences(const QStringList &lines, UMLScene *scene)
rightWidget->setX(mostRightWidget->x() + mostRightWidget->width() + 10); rightWidget->setX(mostRightWidget->x() + mostRightWidget->width() + 10);
rightWidget->activate(); rightWidget->activate();
objectsMap[package] = rightWidget; objectsMap[package] = rightWidget;
scene->addWidget(rightWidget); scene->addWidgetCmd(rightWidget);
mostRightWidget = rightWidget; mostRightWidget = rightWidget;
} }
...@@ -265,7 +265,7 @@ bool importSequences(const QStringList &lines, UMLScene *scene) ...@@ -265,7 +265,7 @@ bool importSequences(const QStringList &lines, UMLScene *scene)
messageWidget->activate(); messageWidget->activate();
messageWidget->setY(y); messageWidget->setY(y);
// to make it savable // to make it savable
scene->messageList().append(messageWidget); scene->addWidgetCmd(messageWidget);
messages.insert(0, messageWidget); messages.insert(0, messageWidget);
leftWidget = rightWidget; leftWidget = rightWidget;
......
...@@ -13,10 +13,11 @@ ...@@ -13,10 +13,11 @@
#define MESSAGEWIDGETLIST_H #define MESSAGEWIDGETLIST_H
#include <QList> #include <QList>
#include <QPointer>
class MessageWidget; class MessageWidget;
typedef QList<MessageWidget*> MessageWidgetList; typedef QList<QPointer<MessageWidget>> MessageWidgetList;
typedef QListIterator<MessageWidget*> MessageWidgetListIt; typedef QListIterator<QPointer<MessageWidget>> MessageWidgetListIt;
#endif #endif
...@@ -304,8 +304,7 @@ void ToolBarStateMessages::cleanMessage() ...@@ -304,8 +304,7 @@ void ToolBarStateMessages::cleanMessage()
void ToolBarStateMessages::setupMessageWidget(MessageWidget *message) void ToolBarStateMessages::setupMessageWidget(MessageWidget *message)
{ {
m_pUMLScene->messageList().append(message); m_pUMLScene->addWidgetCmd(message);
m_pUMLScene->addItem(message);
message->activate(); message->activate();
FloatingTextWidget *ft = message->floatingTextWidget(); FloatingTextWidget *ft = message->floatingTextWidget();
...@@ -313,7 +312,7 @@ void ToolBarStateMessages::setupMessageWidget(MessageWidget *message) ...@@ -313,7 +312,7 @@ void ToolBarStateMessages::setupMessageWidget(MessageWidget *message)
//Shouldn't it cancel also the whole creation? //Shouldn't it cancel also the whole creation?
ft->showOperationDialog(); ft->showOperationDialog();
message->setTextPosition(); message->setTextPosition();
m_pUMLScene->addWidget(ft); m_pUMLScene->addWidgetCmd(ft);
UMLApp::app()->document()->setModified(); UMLApp::app()->document()->setModified();
} }
......
This diff is collapsed.
...@@ -148,10 +148,11 @@ public: ...@@ -148,10 +148,11 @@ public:
Settings::OptionState& optionState(); Settings::OptionState& optionState();
void setOptionState(const Settings::OptionState& options); void setOptionState(const Settings::OptionState& options);
AssociationWidgetList& associationList(); const AssociationWidgetList associationList() const;
const UMLWidgetList& widgetList() const; const MessageWidgetList messageList() const;
void addWidget(UMLWidget* widget); const UMLWidgetList widgetList() const;
MessageWidgetList& messageList(); void addWidgetCmd(UMLWidget* widget);
void addWidgetCmd(AssociationWidget *widget);
bool isOpen() const; bool isOpen() const;
void setIsOpen(bool isOpen); void setIsOpen(bool isOpen);
...@@ -223,7 +224,7 @@ public: ...@@ -223,7 +224,7 @@ public:
void endPartialWidgetPaste(); void endPartialWidgetPaste();
void beginPartialWidgetPaste(); void beginPartialWidgetPaste();
void removeAssoc(AssociationWidget* pAssoc); void removeWidgetCmd(AssociationWidget* pAssoc);
void removeAssociations(UMLWidget* pWidget); void removeAssociations(UMLWidget* pWidget);
void selectAssociations(bool bSelect); void selectAssociations(bool bSelect);
...@@ -327,12 +328,6 @@ protected: ...@@ -327,12 +328,6 @@ protected:
QString m_Documentation; ///< The documentation of the diagram. QString m_Documentation; ///< The documentation of the diagram.
Settings::OptionState m_Options; ///< Options used by view. 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_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_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. bool m_isOpen; ///< Flag is set to true when diagram is open, i.e. shown to the user.
......
...@@ -3037,7 +3037,7 @@ void AssociationWidget::slotMenuSelection(QAction* action) ...@@ -3037,7 +3037,7 @@ void AssociationWidget::slotMenuSelection(QAction* action)
else if (association()) else if (association())
m_scene->removeAssocInViewAndDoc(this); m_scene->removeAssocInViewAndDoc(this);
else else
m_scene->removeAssoc(this); m_scene->removeWidgetCmd(this);
break; break;
case ListPopupMenu::mt_Rename_MultiA: case ListPopupMenu::mt_Rename_MultiA:
...@@ -3948,7 +3948,7 @@ void AssociationWidget::slotClassifierListItemRemoved(UMLClassifierListItem* obj ...@@ -3948,7 +3948,7 @@ void AssociationWidget::slotClassifierListItemRemoved(UMLClassifierListItem* obj
return; return;
} }
m_umlObject = 0; m_umlObject = 0;
m_scene->removeAssoc(this); m_scene->removeWidgetCmd(this);
} }
/** /**
......
...@@ -230,7 +230,7 @@ void CombinedFragmentWidget::setCombinedFragmentType(CombinedFragmentType combin ...@@ -230,7 +230,7 @@ void CombinedFragmentWidget::setCombinedFragmentType(CombinedFragmentType combin
m_dashLines.back()->setYMax(y() + height()); m_dashLines.back()->setYMax(y() + height());
m_dashLines.back()->setY(y() + height()/2); m_dashLines.back()->setY(y() + height()/2);
m_dashLines.back()->setSize(width(), m_dashLines.back()->height()); 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) ...@@ -362,7 +362,7 @@ bool CombinedFragmentWidget::loadFromXMI1(QDomElement & qElement)
return false; return false;
} }
else { else {
m_scene->addWidget(fdlwidget); m_scene->addWidgetCmd(fdlwidget);
fdlwidget->clipSize(); fdlwidget->clipSize();
} }
} else { } else {
......
...@@ -59,7 +59,6 @@ WidgetBase::WidgetBase(UMLScene *scene, WidgetType type) ...@@ -59,7 +59,6 @@ WidgetBase::WidgetBase(UMLScene *scene, WidgetType type)
// this operation need to be finished in derived class constructor. // this operation need to be finished in derived class constructor.
setLineColor(QColor("black")); setLineColor(QColor("black"));
setSelected(false); setSelected(false);
scene->addItem(this);
// TODO 310283 // TODO 310283
setFlags(ItemIsSelectable); setFlags(ItemIsSelectable);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment