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
*/
void CmdBaseWidgetCommand::addWidgetToScene(UMLWidget* umlWidget)
{
if (umlWidget->isMessageWidget()) {
scene()->messageList().append(umlWidget->asMessageWidget());
} else {
scene()->addWidget(umlWidget);
}
scene()->addWidgetCmd(umlWidget);
umlWidget->activate();
}
}
......@@ -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;
......
......@@ -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
......@@ -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();
}
......
This diff is collapsed.
......@@ -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.
......
......@@ -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);
}
/**
......
......@@ -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 {
......
......@@ -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);
......
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