[Uml-devel] kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Tue Feb 22 15:23:55 UTC 2005
CVS commit by okellogg:
Permit more than one message from one collaborating object to another.
BUG:83834
M +14 -8 associationwidget.cpp 1.140
M +5 -0 umlview.cpp 1.207
M +10 -0 umlview.h 1.72
--- kdesdk/umbrello/umbrello/associationwidget.cpp #1.139:1.140
@@ -106,16 +106,18 @@ AssociationWidget::AssociationWidget(UML
mergeAssociationDataIntoUMLRepresentation();
- //collaboration messages need a name label because it's that
- //which handles the right click menu options
+ // Collaboration messages need a name label because it's that
+ // which lets operator== distinguish them, which in turn
+ // permits us to have more than one message between two objects.
if (getAssocType() == at_Coll_Message) {
// Create a temporary name to bring on setName()
- ObjectWidget *ow = static_cast<ObjectWidget*>(m_role[B].m_pWidget);
- QString localIdStr = ID2STR(ow->getLocalID());
- setName("m" + localIdStr);
- if (m_pObject)
+ int collabID = m_pView->generateCollaborationId();
+ setName("m" + QString::number(collabID));
+ if (m_pObject) {
m_pName->setUMLObject( m_pObject );
- else
+ } else {
+ ObjectWidget *ow = static_cast<ObjectWidget*>(m_role[B].m_pWidget);
m_pName->setUMLObject( ow->getUMLObject() );
}
+ }
}
@@ -216,5 +218,9 @@ bool AssociationWidget::operator==(Assoc
}
- return true;
+ // Two objects in a collaboration can have multiple messages between each other.
+ // Here we depend on the messages having names, and the names must be different.
+ // That is the reason why collaboration messages have strange initial names like
+ // "m29997" or similar.
+ return (getName() == Other.getName());
}
--- kdesdk/umbrello/umbrello/umlview.cpp #1.206:1.207
@@ -130,4 +130,5 @@ void UMLView::init() {
m_nCanvasWidth = UMLView::defaultCanvasSize;
m_nCanvasHeight = UMLView::defaultCanvasSize;
+ m_nCollaborationId = 0;
// Initialize other data
@@ -221,4 +222,8 @@ void UMLView::setName(const QString &nam
}
+int UMLView::generateCollaborationId() {
+ return ++m_nCollaborationId;
+}
+
void UMLView::print(KPrinter *pPrinter, QPainter & pPainter) {
int height, width;
--- kdesdk/umbrello/umbrello/umlview.h #1.71:1.72
@@ -948,4 +948,9 @@ public:
}
+ /**
+ * Used for creating unique name of collaboration messages.
+ */
+ int generateCollaborationId();
+
protected:
@@ -1148,4 +1153,9 @@ protected:
void forceUpdateWidgetFontMetrics(QPainter *painter);
+ /**
+ * Used for creating unique name of collaboration messages.
+ */
+ int m_nCollaborationId;
+
QPoint m_Pos, m_LineToPos;
bool m_bCreateObject, m_bDrawRect, m_bDrawSelectedOnly, m_bPaste;
More information about the umbrello-devel
mailing list