[Uml-devel] branches/work/isi-umbrello/umbrello/umbrello

Florence Mattler florence.mattler at libertysurf.fr
Thu Mar 22 22:49:44 UTC 2007


SVN commit 645568 by mattler:

allow activity transition between pin and activity
+ allow to create a pin in a region


 M  +3 -0      assocrules.cpp  
 M  +2 -14     listpopupmenu.cpp  
 M  +59 -33    pinwidget.cpp  
 M  +20 -12    pinwidget.h  
 M  +19 -19    preconditionwidget.cpp  
 M  +1 -1      preconditionwidget.h  
 M  +1 -0      regionwidget.cpp  
 M  +4 -2      toolbarstateonewidget.cpp  
 M  +2 -1      umlnamespace.h  


--- branches/work/isi-umbrello/umbrello/umbrello/assocrules.cpp #645567:645568
@@ -374,6 +374,9 @@
     { at_Activity,      wt_ForkJoin,    wt_Signal,      true,   false,  true,   true  },
     { at_Activity,      wt_ForkJoin,    wt_ObjectNode,  true,   false,  true,   true  },
     { at_Activity,      wt_ObjectNode,  wt_ForkJoin,    true,   false,  true,   true  },
+    { at_Activity,      wt_Pin,         wt_Activity,    true,   false,  true,   true  },
+    { at_Activity,      wt_Pin,         wt_Pin,         true,   false,  true,   true  },
+    { at_Activity,      wt_Activity,    wt_Pin,         true,   false,  true,   true  },
     { at_Anchor,        wt_Class,       wt_Note,        false,  false,  false,  false },
     { at_Anchor,        wt_Package,     wt_Note,        false,  false,  false,  false },
     { at_Anchor,        wt_Interface,   wt_Note,        false,  false,  false,  false },
--- branches/work/isi-umbrello/umbrello/umbrello/listpopupmenu.cpp #645567:645568
@@ -359,19 +359,6 @@
         insertStdItem(mt_Line_Color);
         break;
 
-    case Uml::wt_Pin:
-	setupColor( object -> getUseFillColour() );
-        insertSeparator();
-        insertStdItem(mt_Cut);
-        insertStdItem(mt_Copy);
-        insertStdItem(mt_Paste);
-        insertItem(SmallIcon( "editdelete"), i18n("Clear"), mt_Clear);
-        insertSeparator();
-        insertItem(i18n("Change Text..."), mt_Rename);
-        insertStdItem(mt_Delete);
-        insertStdItem(mt_Change_Font);
-        break;
-
     case Uml::wt_State:
         pState = static_cast< StateWidget *>( object );
         if( pState -> getStateType() == StateWidget::Normal ) {
@@ -429,7 +416,8 @@
             insertStdItem(mt_Properties);
         }
         break;
-
+    
+    case Uml::wt_Pin:
     case Uml::wt_Signal:
     case Uml::wt_FloatingDashLine:
     case Uml::wt_Precondition:
--- branches/work/isi-umbrello/umbrello/umbrello/pinwidget.cpp #645567:645568
@@ -26,20 +26,21 @@
 #include "docwindow.h"
 #include "umlview.h"
 #include "listpopupmenu.h"
+#include "floatingtextwidget.h"
 
 //Added by qt3to4:
 #include <QMouseEvent>
 #include <QPolygon>
 
-PinWidget::PinWidget(UMLView * view, ActivityWidget* a, Uml::IDType id ): UMLWidget(view, id){
+PinWidget::PinWidget(UMLView * view, UMLWidget* a, Uml::IDType id ): UMLWidget(view, id){
     
     init();
-    setZ(50);
-    m_pOw[Uml::A] = a;
+    m_pOw = a;
     int y = getY();
     m_nY = y;
     y = y < getMinY() ? getMinY() : y;
     m_nY = y;
+
     this->activate();
 } 
 
@@ -50,7 +51,7 @@
     m_bIgnoreSnapToGrid = true;
     m_bIgnoreSnapComponentSizeToGrid = true;
     m_bResizable =  false ;
-    m_pOw[Uml::A] = NULL;
+    m_pOw = NULL;
     m_nY = 0;
     setVisible(true);
 }
@@ -58,33 +59,30 @@
 void PinWidget::draw(QPainter & p, int offsetX, int offsetY) { 
     int w = 10;
     int h = 10;
-    int width_Activity = m_pOw[Uml::A]->getWidth();
-    int height_Activity = m_pOw[Uml::A]->getHeight();
+    int width_Activity = m_pOw->getWidth();
+    int height_Activity = m_pOw->getHeight();
     int y;
+    int x = m_pOw->getX() + (width_Activity/2);
 
-    int x = m_pOw[Uml::A]->getX() + (width_Activity/2);
-   
-
-    if ( (offsetY + height_Activity/2) <= m_pOw[Uml::A]->getY() + height_Activity){
-       y = m_pOw[Uml::A]->getY()-5;
-    } else if((offsetY + height_Activity/2) > m_pOw[Uml::A]->getY() + height_Activity){
-       y = (m_pOw[Uml::A]->getY() + height_Activity)-5;
+    if ( (offsetY + height_Activity/2) <= m_pOw->getY() + height_Activity){
+        y = m_pOw->getY()-5;
+    } else if((offsetY + height_Activity/2) > m_pOw->getY() + height_Activity){
+       y = (m_pOw->getY() + height_Activity)-5;
     }
 
-    if (offsetX + width_Activity/4 <= m_pOw[Uml::A]->getX() + width_Activity/2 
-         && (offsetY > m_pOw[Uml::A]->getY() +5 && offsetY < m_pOw[Uml::A]->getY() + height_Activity - 5) ){
-        x = m_pOw[Uml::A]->getX() -5;
-        y = m_pOw[Uml::A]->getY() + (height_Activity/2) -5;
-    } else if (offsetX + width_Activity/4 > m_pOw[Uml::A]->getX() + width_Activity/2
-         && (offsetY > m_pOw[Uml::A]->getY() +5 && offsetY < m_pOw[Uml::A]->getY() + height_Activity - 5) ){
-        x = m_pOw[Uml::A]->getX() + width_Activity -5;
-        y = m_pOw[Uml::A]->getY() + (height_Activity/2) -5;
+    if (offsetX + width_Activity/4 <= m_pOw->getX() + width_Activity/2 
+         && (offsetY > m_pOw->getY() +5 && offsetY < m_pOw->getY() + height_Activity - 5) ){
+        x = m_pOw->getX() -5;
+        y = m_pOw->getY() + (height_Activity/2) -5;
+    } else if (offsetX + width_Activity/4 > m_pOw->getX() + width_Activity/2
+         && (offsetY > m_pOw->getY() +5 && offsetY < m_pOw->getY() + height_Activity - 5) ){
+        x = m_pOw->getX() + width_Activity -5;
+        y = m_pOw->getY() + (height_Activity/2) -5;
     }
 
     setX(x);
     setY(y);
 
-
 //test if y isn't above the object
 //     if ( y <= m_pOw[Uml::A]->getY() + height_Activity-5 && x == m_pOw[Uml::A]->getX() + (width_Activity/2) ) {
 // 	y = m_pOw[Uml::A]->getY() + height_Activity + 15;
@@ -99,22 +97,55 @@
             p.setBrush( UMLWidget::getFillColour() ); 
         }
         p.drawRect(x,y,w, h); 
+        //make sure it's always above the other
+        setZ(20);
         UMLWidget::setPen(p);
         if(m_bSelected)
              drawSelected(&p, offsetX, offsetY);
 }
- 
+
+QSize PinWidget::calculateSize() {
+    setSize(10,10);
+    return QSize(10,10);
+}
+
+void PinWidget::setName(const QString &strName) {
+    m_Text = strName;
+    updateComponentSize();
+    m_pName->setText(m_Text);
+}
+
 int PinWidget::getMinY() {
-    if (!m_pOw[Uml::A]) {
+    if (!m_pOw) {
         return 0;
     }
-    int heightA = m_pOw[Uml::A]->getY() + m_pOw[Uml::A]->getHeight();
+    int heightA = m_pOw->getY() + m_pOw->getHeight();
     return heightA;
 }
 
+
+void PinWidget::slotMenuSelection(int sel) {
+    bool done = false;
+
+    bool ok = false;
+    QString name = m_Text;
+
+    switch( sel ) {
+    case ListPopupMenu::mt_Rename:
+        name = KInputDialog::getText( i18n("Enter Pin Name"), i18n("Enter the pin name :"), m_Text, &ok );
+        if( ok )
+            setName(name);
+        done = true;
+        break;
+    }
+    if( !done )
+        UMLWidget::slotMenuSelection( sel );
+}
+
+
 void PinWidget::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) { 
     QDomElement PinElement = qDoc.createElement( "pinwidget" );
-    PinElement.setAttribute( "widgetaid", ID2STR(m_pOw[Uml::A]->getID()) );
+    PinElement.setAttribute( "widgetaid", ID2STR(m_pOw->getID()) );
     UMLWidget::saveToXMI( qDoc, PinElement ); 
     qElement.appendChild( PinElement ); 
 }
@@ -134,13 +165,8 @@
         return false;
     }
 
-    m_pOw[Uml::A] = dynamic_cast<ActivityWidget*>(pWA);
-    if (m_pOw[Uml::A] == NULL) {
-        kDebug() << "PinWidget::loadFromXMI: role A widget "
-        << ID2STR(aId) << " is not an ActivityWidget" << endl;
-        return false;
-    }
-
+    m_pOw = pWA;
+  
     return true; 
 }
 
--- branches/work/isi-umbrello/umbrello/umbrello/pinwidget.h #645567:645568
@@ -15,6 +15,7 @@
 #include "umlwidget.h"
 #include "worktoolbar.h"
 #include "activitywidget.h"
+#include "floatingtextwidget.h"
 
 #define PIN_MARGIN 5
 #define PIN_WIDTH 1
@@ -46,7 +47,7 @@
      * @param view              The parent of the widget.
      * @param id                The ID to assign (-1 will prompt a new ID.)
      */
-     PinWidget( UMLView * view, ActivityWidget* a, Uml::IDType id = Uml::id_None );
+     PinWidget( UMLView * view, UMLWidget* a, Uml::IDType id = Uml::id_None );
 
     /**
      *  destructor
@@ -63,7 +64,13 @@
      */
     void draw(QPainter & p, int offsetX, int offsetY);
 
+
     /**
+     * Sets the name of the pin.
+     */
+    virtual void setName(const QString &strName);
+
+    /**
      * Returns the minimum height this widget should be set at on
      * a sequence diagrams.  Takes into account the widget positions
      * it is related to.
@@ -88,29 +95,30 @@
      bool loadFromXMI( QDomElement & qElement );
 
 
-
 protected:
     /**
      * Overrides method from UMLWidget
      */
-    //  QSize calculateSize();
+     QSize calculateSize();
 
-    /**
-     * Type of ObjectFlow.
-     */
-  // ObjectFlow m_ObjectFlowType;
+public slots:
 
-//public slots:
-
     /**
      * Captures any popup menu signals for menus it created.
      */
-   // void slotMenuSelection(int sel);
+    void slotMenuSelection(int sel);
 
 
 private:
-    ActivityWidget * m_pOw[1];
-   int m_nY;
+    UMLWidget * m_pOw;
+
+    /**
+     * This is a pointer to the Floating Text widget which displays the
+     * name of the signal widget.
+     */
+    FloatingTextWidget * m_pName;
+    
+    int m_nY;
 };
 
 #endif
--- branches/work/isi-umbrello/umbrello/umbrello/preconditionwidget.cpp #645567:645568
@@ -41,7 +41,7 @@
         : UMLWidget(view, id)
 {
     init();
-    m_pOw[Uml::A] = a;
+    m_pOw = a;
     int y = getY();
     m_nY = y;
     //updateResizability();
@@ -61,7 +61,7 @@
     m_bIgnoreSnapToGrid = true;
     m_bIgnoreSnapComponentSizeToGrid = true;
     m_bResizable =  true ;
-    m_pOw[Uml::A] = NULL;
+    m_pOw = NULL;
     m_nY = 0;
     setVisible(true);
 }
@@ -70,17 +70,17 @@
     int w = width();
     int h = height();
 
-    int x = m_pOw[Uml::A]->getX() + m_pOw[Uml::A]->getWidth() / 2;
+    int x = m_pOw->getX() + m_pOw->getWidth() / 2;
     x -= w/2;
     setX(x);
     int y = offsetY;
     
     //test if y isn't above the object
-    if (y <= m_pOw[Uml::A]->getY() + m_pOw[Uml::A]->getHeight() ) {
-	y = m_pOw[Uml::A]->getY() + m_pOw[Uml::A]->getHeight() + 15;
+    if (y <= m_pOw->getY() + m_pOw->getHeight() ) {
+	y = m_pOw->getY() + m_pOw->getHeight() + 15;
     }
-    if (y + h >= m_pOw[Uml::A]->getEndLineY()) {
-        y = m_pOw[Uml::A]->getEndLineY() - h;
+    if (y + h >= m_pOw->getEndLineY()) {
+        y = m_pOw->getEndLineY() - h;
     }
     setY(y);
     UMLWidget::setPen(p);
@@ -151,12 +151,12 @@
 void PreconditionWidget::activate(IDChangeLog * Log /*= 0*/) {
     m_pView->resetPastePoint();
     UMLWidget::activate(Log);
-    if (m_pOw[Uml::A] == NULL) {
+    if (m_pOw == NULL) {
         kDebug() << "PreconditionWidget::activate: can't make precondition" << endl;
         return;
     }
     
-    connect(m_pOw[Uml::A], SIGNAL(sigWidgetMoved(Uml::IDType)), this, SLOT(slotWidgetMoved(Uml::IDType)));
+    connect(m_pOw, SIGNAL(sigWidgetMoved(Uml::IDType)), this, SLOT(slotWidgetMoved(Uml::IDType)));
     
     calculateDimensions();
 }
@@ -165,8 +165,8 @@
     int x = 0;
     int w = 0;
     int h = 0;
-    int x1 = m_pOw[Uml::A]->getX();
-    int w1 = m_pOw[Uml::A]->getWidth() / 2;
+    int x1 = m_pOw->getX();
+    int w1 = m_pOw->getWidth() / 2;
 
     x1 += w1;
 
@@ -183,7 +183,7 @@
 }
 
 void PreconditionWidget::slotWidgetMoved(Uml::IDType id) {
-    const Uml::IDType idA = m_pOw[Uml::A]->getLocalID();
+    const Uml::IDType idA = m_pOw->getLocalID();
     if (idA != id ) {
         kDebug() << "MessageWidget::slotWidgetMoved(" << ID2STR(id)
             << "): ignoring for idA=" << ID2STR(idA) << endl;
@@ -203,21 +203,21 @@
 
 
 int PreconditionWidget::getMinY() {
-    if (!m_pOw[Uml::A]) {
+    if (!m_pOw) {
         return 0;
     }
 
-    int heightA = m_pOw[Uml::A]->getY() + m_pOw[Uml::A]->getHeight();
+    int heightA = m_pOw->getY() + m_pOw->getHeight();
     int height = heightA;
     return height;
 }
 
 int PreconditionWidget::getMaxY() {
-    if( !m_pOw[Uml::A]) {
+    if( !m_pOw) {
         return 0;
     }
 
-    int heightA = (int)((ObjectWidget*)m_pOw[Uml::A])->getEndLineY();
+    int heightA = (int)m_pOw->getEndLineY();
     int height = heightA;
     return (height - this->height());
 }
@@ -226,7 +226,7 @@
 void PreconditionWidget::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) {
     QDomElement preconditionElement = qDoc.createElement( "preconditionwidget" );
     UMLWidget::saveToXMI( qDoc, preconditionElement );
-    preconditionElement.setAttribute( "widgetaid", ID2STR(m_pOw[Uml::A]->getLocalID()) );
+    preconditionElement.setAttribute( "widgetaid", ID2STR(m_pOw->getLocalID()) );
     preconditionElement.setAttribute( "preconditionname", m_Text );
     preconditionElement.setAttribute( "documentation", m_Doc );
     qElement.appendChild( preconditionElement );
@@ -248,8 +248,8 @@
         return false;
     }
 
-    m_pOw[Uml::A] = dynamic_cast<ObjectWidget*>(pWA);
-    if (m_pOw[Uml::A] == NULL) {
+    m_pOw = dynamic_cast<ObjectWidget*>(pWA);
+    if (m_pOw == NULL) {
         kDebug() << "PreconditionWidget::loadFromXMI: role A widget "
         << ID2STR(aId) << " is not an ObjectWidget" << endl;
         return false;
--- branches/work/isi-umbrello/umbrello/umbrello/preconditionwidget.h #645567:645568
@@ -122,7 +122,7 @@
     void slotWidgetMoved(Uml::IDType id);
 
 private:
-    ObjectWidget * m_pOw[1];
+    ObjectWidget * m_pOw;
     int m_nY;
 };
 
--- branches/work/isi-umbrello/umbrello/umbrello/regionwidget.cpp #645567:645568
@@ -33,6 +33,7 @@
 
 RegionWidget::RegionWidget(UMLView * view, Uml::IDType id)
         : UMLWidget(view, id) {
+     UMLWidget::setBaseType( Uml::wt_Region );
     updateComponentSize();
 }
 
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstateonewidget.cpp #645567:645568
@@ -22,6 +22,7 @@
 #include "messagewidget.h"
 #include "objectwidget.h"
 #include "activitywidget.h"
+#include "regionwidget.h"
 #include "umlwidget.h"
 #include "uml.h"
 #include "umldoc.h"
@@ -87,7 +88,8 @@
   
     if (m_pMouseEvent->button() != Qt::LeftButton ||(
                 getCurrentWidget()->getBaseType() != Uml::wt_Object &&
-                getCurrentWidget()->getBaseType() != Uml::wt_Activity)) {
+                getCurrentWidget()->getBaseType() != Uml::wt_Activity &&
+                getCurrentWidget()->getBaseType() != Uml::wt_Region)) {
         return;
     }
 	
@@ -123,7 +125,7 @@
     }
 
     if (getWidgetType() == Uml::wt_Pin) {
-   	umlwidget = new PinWidget(m_pUMLView, static_cast<ActivityWidget*>(m_firstObject));
+   	umlwidget = new PinWidget(m_pUMLView, m_firstObject);
     	    // Create the widget. Some setup functions can remove the widget.
     	
     }
--- branches/work/isi-umbrello/umbrello/umbrello/umlnamespace.h #645567:645568
@@ -110,7 +110,8 @@
     wt_FloatingDashLine,        // does not have UMLObject representation
     wt_Signal,	                // does not have UMLObject representation
     wt_Pin,
-    wt_ObjectNode	
+    wt_ObjectNode,	
+    wt_Region
 };
 
 enum Diagram_Type




More information about the umbrello-devel mailing list