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

Caroline Bourdeu d'Aguerre cbda at free.fr
Sun Mar 4 17:58:15 UTC 2007


SVN commit 639230 by bourdeu:

Add a nem type of activity: parameter activity node.


 M  +54 -32    activitywidget.cpp  
 M  +2 -10     activitywidget.h  
 M  +27 -6     dialogs/activitydialog.cpp  
 M  +2 -1      dialogs/activitydialog.h  
 M  +6 -2      listpopupmenu.cpp  


--- branches/work/isi-umbrello/umbrello/umbrello/activitywidget.cpp #639229:639230
@@ -40,7 +40,6 @@
     UMLWidget::setBaseType( Uml::wt_Activity );
     setActivityType( activityType );
     updateComponentSize();
-    setShowInvok( false );
 }
 
 ActivityWidget::~ActivityWidget() {}
@@ -48,7 +47,7 @@
 void ActivityWidget::draw(QPainter & p, int offsetX, int offsetY) {
     int w = width();
     int h = height();
-kDebug ()<<"tata!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!le draw"<<endl;
+
     // Only for the final activity
     float x;
     float y;
@@ -56,6 +55,7 @@
 
     switch ( m_ActivityType )
     {
+
     case Normal :
         UMLWidget::setPen(p);
         if ( UMLWidget::getUseFillColour() ) {
@@ -64,7 +64,6 @@
         {
             const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
             const int fontHeight  = fm.lineSpacing();
-            //int middleX = w / 2;
             int textStartY = (h / 2) - (fontHeight / 2);
             p.drawRoundRect(offsetX, offsetY, w, h, (h * 60) / w, 60);
             p.setPen(Qt::black);
@@ -72,25 +71,15 @@
             p.drawText(offsetX + ACTIVITY_MARGIN, offsetY + textStartY,
                        w - ACTIVITY_MARGIN * 2, fontHeight, Qt::AlignCenter, getName());
 
-            // if the activity is an invok activity
-            if ( m_NormalActivityType )
-            {
-                 x = offsetX + w - (w/5);
-                 y = offsetY + h - (h/3);
-
-                 p.drawLine(x,      y,      x,      y + 20);
-                 p.drawLine(x - 10, y + 10, x + 10, y + 10);
-                 p.drawLine(x - 10, y + 10, x - 10, y + 20);
-                 p.drawLine(x + 10, y + 10, x + 10, y + 20);
-            }
         }
-        UMLWidget::setPen(p);
         break;
+
     case Initial :
         UMLWidget::setPen(p);
         p.setBrush( WidgetBase::getLineColor() );
         p.drawEllipse( offsetX, offsetY, w, h );
         break;
+
     case Final :
 
         UMLWidget::setPen(p);
@@ -107,9 +96,8 @@
                    x + (sqrt(2)/2) * (w/2), y + (sqrt(2)/2) * (w/2));
         p.drawLine(x + (sqrt(2)/2) * (w/2) - 1, y - (sqrt(2)/2) * (w/2) + 1,
                    x - (sqrt(2)/2) * (w/2), y + (sqrt(2)/2) * (w/2));
+        break;
 
-
-        break;
     case End :
         UMLWidget::setPen(p);
         p.setBrush( WidgetBase::getLineColor() );
@@ -119,6 +107,7 @@
         p.setBrush( WidgetBase::getLineColor() );
         p.drawEllipse( offsetX + 3, offsetY + 3, w - 6, h - 6 );
         break;
+
     case Branch :
         UMLWidget::setPen(p);
         p.setBrush( UMLWidget::getFillColour() );
@@ -132,6 +121,50 @@
             p.drawPolyline( array );
         }
         break;
+
+    case Invok :
+        UMLWidget::setPen(p);
+        if ( UMLWidget::getUseFillColour() ) {
+            p.setBrush( UMLWidget::getFillColour() );
+        }
+        {
+            const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
+            const int fontHeight  = fm.lineSpacing();
+            int textStartY = (h / 2) - (fontHeight / 2);
+            p.drawRoundRect(offsetX, offsetY, w, h, (h * 60) / w, 60);
+            p.setPen(Qt::black);
+            p.setFont( UMLWidget::getFont() );
+            p.drawText(offsetX + ACTIVITY_MARGIN, offsetY + textStartY,
+                       w - ACTIVITY_MARGIN * 2, fontHeight, Qt::AlignCenter, getName());
+
+        }
+        x = offsetX + w - (w/5);
+        y = offsetY + h - (h/3);
+
+        p.drawLine(x,      y,      x,      y + 20);
+        p.drawLine(x - 10, y + 10, x + 10, y + 10);
+        p.drawLine(x - 10, y + 10, x - 10, y + 20);
+        p.drawLine(x + 10, y + 10, x + 10, y + 20);
+        break;
+
+    case Param :
+        UMLWidget::setPen(p);
+        if ( UMLWidget::getUseFillColour() ) {
+            p.setBrush( UMLWidget::getFillColour() );
+        }
+        {
+            const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
+            const int fontHeight  = fm.lineSpacing();
+            int textStartY = (h / 2) - (fontHeight / 2);
+            p.drawRoundRect(offsetX, offsetY, w, h, (h * 60) / w, 60);
+            p.setPen(Qt::black);
+            p.setFont( UMLWidget::getFont() );
+            p.drawText(offsetX + ACTIVITY_MARGIN, offsetY + (fontHeight / 2),
+                       w - ACTIVITY_MARGIN * 2, fontHeight, Qt::AlignCenter, getName());
+
+        }
+        break;
+
     case Fork_DEPRECATED :  // to be removed
         p.fillRect( offsetX, offsetY, width(), height(), QBrush( Qt::darkYellow ));
         break;
@@ -142,7 +175,7 @@
 
 QSize ActivityWidget::calculateSize() {
     int width = 10, height = 10;
-    if ( m_ActivityType == Normal ) {
+    if ( m_ActivityType == Normal || m_ActivityType == Invok || m_ActivityType == Param ) {
         const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
         const int fontHeight  = fm.lineSpacing();
         const int textWidth = fm.width(getName());
@@ -152,7 +185,7 @@
         width += ACTIVITY_MARGIN * 2;
         height += ACTIVITY_MARGIN * 2;
 
-        if (m_NormalActivityType)
+        if (m_ActivityType == Invok || m_ActivityType == Param)
         {
              height += 40;
         }
@@ -169,19 +202,10 @@
 
 void ActivityWidget::setActivityType( ActivityType activityType ) {
     m_ActivityType = activityType;
-    UMLWidget::m_bResizable = (m_ActivityType == Normal);
-}
-
-void ActivityWidget::setShowInvok(bool invok)
-{
-    m_NormalActivityType = invok;
     updateComponentSize();
+    UMLWidget::m_bResizable = (m_ActivityType == Normal || m_ActivityType == Invok || m_ActivityType == Param );
 }
 
-bool ActivityWidget::getShowInvok()
-{
-     return ( m_NormalActivityType);
-}
 void ActivityWidget::slotMenuSelection(int sel) {
     bool done = false;
 
@@ -258,7 +282,6 @@
     activityElement.setAttribute( "activityname", m_Text );
     activityElement.setAttribute( "documentation", m_Doc );
     activityElement.setAttribute( "activitytype", m_ActivityType );
-    activityElement.setAttribute( "normalactivitytype", m_NormalActivityType );
     qElement.appendChild( activityElement );
 }
 
@@ -269,8 +292,7 @@
     m_Doc = qElement.attribute( "documentation", "" );
     QString type = qElement.attribute( "activitytype", "1" );
     setActivityType( (ActivityType)type.toInt() );
-    type = qElement.attribute( "normalactivitytype");
-    setShowInvok( (bool)type.toInt() );
+
     return true;
 }
 
--- branches/work/isi-umbrello/umbrello/umbrello/activitywidget.h #639229:639230
@@ -42,6 +42,8 @@
         End,
         Final,
         Branch,
+        Invok,
+        Param,
         Fork_DEPRECATED  // use ForkJoinWidget instead
     };
 
@@ -95,16 +97,6 @@
                             ActivityType& resultType );
 
     /**
-     * Sets the type of a normal activity: invok or not.
-     */
-    void setShowInvok(bool invok);
-
-    /**
-     * Return the type of a normal activity: invok or not.
-     */
-    bool getShowInvok();
-
-    /**
      * Saves the widget to the <activitywidget> XMI element.
      */
     void saveToXMI( QDomDocument & qDoc, QDomElement & qElement );
--- branches/work/isi-umbrello/umbrello/umbrello/dialogs/activitydialog.cpp #639229:639230
@@ -20,6 +20,7 @@
 #include <QHBoxLayout>
 #include <QGridLayout>
 #include <QCheckBox>
+#include <QRadioButton>
 #include <kvbox.h>
 //kde includes
 #include <kiconloader.h>
@@ -29,6 +30,7 @@
 #include "../umlview.h"
 #include "../activitywidget.h"
 #include "../dialog_utils.h"
+#include "../activitywidget.h"
 
 ActivityDialog::ActivityDialog( UMLView * pView, ActivityWidget * pWidget )
         : KPageDialog(pView) {
@@ -69,7 +71,14 @@
     {
         m_pActivityWidget -> setName( m_GenPageWidgets.nameLE -> text() );
         m_pActivityWidget -> setDoc( m_GenPageWidgets.docMLE -> text() );
-        m_pActivityWidget -> setShowInvok (m_GenPageWidgets.InvokCB->isChecked() );
+
+        ActivityWidget::ActivityType newType = ActivityWidget::Normal;
+        if ( m_GenPageWidgets.InvokRB->isOn() )
+              newType = ActivityWidget::Invok;
+        else if ( m_GenPageWidgets.ParamRB->isOn() )
+              newType = ActivityWidget::Param;
+        m_pActivityWidget->setActivityType (newType);
+
     }
     else if ( item == pageItemFont )
     {
@@ -85,7 +94,6 @@
     QString types[ ] = { i18n("Initial activity"), i18n("Activity"), i18n("End activity"), i18n( "Branch/Merge"), i18n( "Fork/Join" ) };
     ActivityWidget::ActivityType type = m_pActivityWidget -> getActivityType();
 
-
     KVBox *page = new KVBox();
     pageItemGeneral = new KPageWidgetItem( page, i18n("General") );
     pageItemGeneral->setHeader(i18n("General Properties"));
@@ -108,10 +116,23 @@
                                     m_GenPageWidgets.nameL, i18n("Activity name:"),
                                     m_GenPageWidgets.nameLE );
 
-    m_GenPageWidgets.InvokCB = new QCheckBox( i18n("&Invoke action "),(QWidget *)page);
-    generalLayout -> addWidget( m_GenPageWidgets.InvokCB );
-    m_GenPageWidgets.InvokCB->setChecked(m_pActivityWidget -> getShowInvok() );
+    m_GenPageWidgets.NormalRB = new QRadioButton( i18n("&Normal activity"),(QWidget *)page);
+    generalLayout -> addWidget( m_GenPageWidgets.NormalRB );
 
+    m_GenPageWidgets.InvokRB = new QRadioButton( i18n("&Invoke action "),(QWidget *)page);
+    generalLayout -> addWidget( m_GenPageWidgets.InvokRB );
+
+    m_GenPageWidgets.ParamRB = new QRadioButton( i18n("&Parameter activity node"),(QWidget *)page);
+    generalLayout -> addWidget( m_GenPageWidgets.ParamRB );
+
+    ActivityWidget::ActivityType newType = m_pActivityWidget -> getActivityType() ;
+
+    m_GenPageWidgets.NormalRB->setChecked(newType == ActivityWidget::Normal);
+
+    m_GenPageWidgets.InvokRB->setChecked (newType == ActivityWidget::Invok);
+
+    m_GenPageWidgets.ParamRB->setChecked (newType == ActivityWidget::Param);
+
     m_GenPageWidgets.docGB = new Q3GroupBox( i18n( "Documentation"), (QWidget *)page );
 
     QHBoxLayout * docLayout = new QHBoxLayout( m_GenPageWidgets.docGB );
@@ -122,7 +143,7 @@
     m_GenPageWidgets.docMLE -> setText( m_pActivityWidget -> getDoc() );
     docLayout -> addWidget( m_GenPageWidgets.docMLE );
 
-    if( type != ActivityWidget::Normal ) {
+    if( type != ActivityWidget::Normal && type != ActivityWidget::Invok && type != ActivityWidget::Param) {
         m_GenPageWidgets.nameLE -> setEnabled( false );
         m_GenPageWidgets.nameLE -> setText( "" );
     } else
--- branches/work/isi-umbrello/umbrello/umbrello/dialogs/activitydialog.h #639229:639230
@@ -17,6 +17,7 @@
 #include <qlineedit.h>
 #include <q3multilineedit.h>
 #include <q3groupbox.h>
+#include <qradiobutton.h>
 
 //kde class includes
 #include <kpagedialog.h>
@@ -119,7 +120,7 @@
         QLabel * nameL, * typeL;
         QLineEdit * nameLE, * typeLE;
         Q3MultiLineEdit * docMLE;
-        QCheckBox * InvokCB;
+        QRadioButton * NormalRB, * ParamRB, * InvokRB; // this is to implement the parameter node activity or an invok action
         Q3GroupBox * docGB, * generalGB;
     }
     m_GenPageWidgets;
--- branches/work/isi-umbrello/umbrello/umbrello/listpopupmenu.cpp #639229:639230
@@ -400,10 +400,14 @@
 
     case Uml::wt_Activity:
         pActivity = static_cast<ActivityWidget *>( object );
-        if( pActivity -> getActivityType() == ActivityWidget::Normal )
+        if( pActivity -> getActivityType() == ActivityWidget::Normal
+         || pActivity -> getActivityType() == ActivityWidget::Invok
+         || pActivity -> getActivityType() == ActivityWidget::Param)
             setupColor( object -> getUseFillColour() );
         insertStdItems(false, type);
-        if( pActivity -> getActivityType() == ActivityWidget::Normal ) {
+        if( pActivity -> getActivityType() == ActivityWidget::Normal 
+         || pActivity -> getActivityType() == ActivityWidget::Invok
+         || pActivity -> getActivityType() == ActivityWidget::Param) {
             insertItem(i18n("Change Activity Name..."), mt_Rename);
             insertStdItem(mt_Change_Font);
             insertStdItem(mt_Properties);




More information about the umbrello-devel mailing list