[Uml-devel] branches/KDE/3.5/kdesdk/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Sat Apr 14 13:56:58 UTC 2007


SVN commit 653888 by okellogg:

m_widgetAId,m_widgetBId,m_textId: Temporary store for loadFromXMI().
Move widget resolution from loadFromXMI() to activate().
Sequence diagrams can now be copied but the placement of the widgets
in the target diagram is not yet correct.  While that is not fixed,
the widgets can anyway be rearranged manually.
BUG:139856


 M  +1 -1      ChangeLog  
 M  +44 -66    umbrello/messagewidget.cpp  
 M  +7 -0      umbrello/messagewidget.h  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #653887:653888
@@ -27,7 +27,7 @@
 * Ada code generator always generates methods abstract even if abstract box not checked (142093)
 * Missing "with" on Ada code generation for aggregation (142392)
 * Operation Properties "Type" combo box too small (143319)
-* Support duplication of diagrams (143581)
+* Support duplication of diagrams (139856, 143581)
 * Crash on changing multiplicity in an association in ERD (143909)
 * Class diagram in folder not loaded correctly from xmi (144119)
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/messagewidget.cpp #653887:653888
@@ -406,11 +406,45 @@
 
 bool MessageWidget::activate(IDChangeLog * Log /*= 0*/) {
     m_pView->resetPastePoint();
-    UMLWidget::activate(Log);
-    if (m_pOw[Uml::A] == NULL || m_pOw[Uml::B] == NULL) {
-        kDebug() << "MessageWidget::activate: can't make message" << endl;
+    // UMLWidget::activate(Log);   CHECK: I don't think we need this ?
+    UMLWidget *pWA = m_pView->findWidget(m_widgetAId);
+    if (pWA == NULL) {
+        kDebug() << "MessageWidget::activate: role A object "
+            << ID2STR(m_widgetAId) << " not found" << endl;
         return false;
     }
+    UMLWidget *pWB = m_pView->findWidget(m_widgetBId);
+    if (pWB == NULL) {
+        kDebug() << "MessageWidget::activate: role B object "
+            << ID2STR(m_widgetBId) << " not found" << endl;
+        return false;
+    }
+    m_pOw[Uml::A] = dynamic_cast<ObjectWidget*>(pWA);
+    if (m_pOw[Uml::A] == NULL) {
+        kDebug() << "MessageWidget::activate: role A widget "
+            << ID2STR(m_widgetAId) << " is not an ObjectWidget" << endl;
+        return false;
+    }
+    m_pOw[Uml::B] = dynamic_cast<ObjectWidget*>(pWB);
+    if (m_pOw[Uml::B] == NULL) {
+        kDebug() << "MessageWidget::activate: role B widget "
+            << ID2STR(m_widgetBId) << " is not an ObjectWidget" << endl;
+        return false;
+    }
+    updateResizability();
+
+    UMLClassifier *c = dynamic_cast<UMLClassifier*>(pWB->getUMLObject());
+    UMLOperation *op = NULL;
+    if (c) {
+        Uml::IDType opId = STR2ID(m_CustomOp);
+        op = dynamic_cast<UMLOperation*>( c->findChildObjectById(opId, true) );
+        if (op) {
+            // If the UMLOperation is set, m_CustomOp isn't used anyway.
+            // Just setting it empty for the sake of sanity.
+            m_CustomOp = QString::null;
+        }
+    }
+
     if( !m_pFText ) {
         Uml::Text_Role tr = Uml::tr_Seq_Message;
         if (m_pOw[Uml::A] == m_pOw[Uml::B])
@@ -418,6 +452,8 @@
         m_pFText = new FloatingTextWidget( m_pView, tr, "" );
         m_pFText->setFont(UMLWidget::getFont());
     }
+    if (op)
+        setOperation(op);  // This requires a valid m_pFText.
     setLinkAndTextPos();
     m_pFText -> setText("");
     m_pFText->setActivated();
@@ -719,64 +755,12 @@
     QString sequenceMessageType = qElement.attribute( "sequencemessagetype", "1001" );
     m_sequenceMessageType = (Uml::Sequence_Message_Type)sequenceMessageType.toInt();
 
-    Uml::IDType aId = STR2ID(widgetaid);
-    Uml::IDType bId = STR2ID(widgetbid);
+    m_widgetAId = STR2ID(widgetaid);
+    m_widgetBId = STR2ID(widgetbid);
+    m_textId = STR2ID(textid);
 
-    UMLWidget *pWA = m_pView -> findWidget( aId );
-    if (pWA == NULL) {
-        kDebug() << "MessageWidget::loadFromXMI: role A object "
-        << ID2STR(aId) << " not found" << endl;
-        return false;
-    }
-    UMLWidget *pWB = m_pView -> findWidget( bId );
-    if (pWB == NULL) {
-        kDebug() << "MessageWidget::loadFromXMI: role B object "
-        << ID2STR(bId) << " not found" << endl;
-        return false;
-    }
-    m_pOw[Uml::A] = dynamic_cast<ObjectWidget*>(pWA);
-    if (m_pOw[Uml::A] == NULL) {
-        kDebug() << "MessageWidget::loadFromXMI: role A widget "
-        << ID2STR(aId) << " is not an ObjectWidget" << endl;
-        return false;
-    }
-    m_pOw[Uml::B] = dynamic_cast<ObjectWidget*>(pWB);
-    if (m_pOw[Uml::B] == NULL) {
-        kDebug() << "MessageWidget::loadFromXMI: role B widget "
-        << ID2STR(bId) << " is not an ObjectWidget" << endl;
-        return false;
-    }
-    updateResizability();
-
-    UMLClassifier *c = dynamic_cast<UMLClassifier*>( pWB->getUMLObject() );
-    UMLOperation *op = NULL;
-    if (c) {
-        Uml::IDType opId = STR2ID(m_CustomOp);
-        op = dynamic_cast<UMLOperation*>( c->findChildObjectById(opId, true) );
-        if (op) {
-            // If the UMLOperation is set, m_CustomOp isn't used anyway.
-            // Just setting it empty for the sake of sanity.
-            m_CustomOp = QString::null;
-        }
-    }
-
-    Uml::IDType textId = STR2ID(textid);
-    if (textId != Uml::id_None) {
-        UMLWidget *flotext = m_pView -> findWidget( textId );
-        if (flotext != NULL) {
-            // This only happens when loading files produced by
-            // umbrello-1.3-beta2.
-            m_pFText = static_cast<FloatingTextWidget*>(flotext);
-            setLinkAndTextPos();
-            return true;
-        }
-    } else {
-        // no textid stored -> get unique new one
-        textId = UniqueID::gen();
-    }
-
     Uml::Text_Role tr = Uml::tr_Seq_Message;
-    if (m_pOw[Uml::A] == m_pOw[Uml::B])
+    if (m_widgetAId == m_widgetBId)
         tr = Uml::tr_Seq_Message_Self;
 
     //now load child elements
@@ -785,7 +769,7 @@
     if ( !element.isNull() ) {
         QString tag = element.tagName();
         if (tag == "floatingtext") {
-            m_pFText = new FloatingTextWidget( m_pView, tr, getOperationText(m_pView), textId );
+            m_pFText = new FloatingTextWidget( m_pView, tr, getOperationText(m_pView), m_textId );
             if( ! m_pFText->loadFromXMI(element) ) {
                 // Most likely cause: The FloatingTextWidget is empty.
                 delete m_pFText;
@@ -796,12 +780,6 @@
             << tag << endl;
         }
     }
-    if (op)                // Do it here and not earlier because now we have the
-        setOperation(op);  // m_pFText and setOperation() can make connections.
-
-    // always need this
-    setLinkAndTextPos();
-
     return true;
 }
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/messagewidget.h #653887:653888
@@ -378,6 +378,13 @@
     ObjectWidget * m_pOw[2];
     FloatingTextWidget * m_pFText;
     int m_nY;
+    /**
+     * The following variables are used by loadFromXMI() as an intermediate
+     * store. activate() resolves the IDs, i.e. after activate() the variables
+     * m_pOw[] and m_pFText can be used.
+     */
+    Uml::IDType m_widgetAId, m_widgetBId, m_textId;
+
 public slots:
     void slotWidgetMoved(Uml::IDType id);
     void slotMenuSelection(int sel);




More information about the umbrello-devel mailing list