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

Caroline Bourdeu d'Aguerre cbda at free.fr
Thu Feb 8 21:57:05 UTC 2007


SVN commit 631735 by bourdeu:

Implementation of the tree widgets: send signal, accept signal, accept time event in the activity diagram.



 M  +47 -15    signalwidget.cpp  
 M  +2 -2      signalwidget.h  
 M  +13 -0     toolbarstateother.cpp  


--- branches/work/isi-umbrello/umbrello/umbrello/signalwidget.cpp #631734:631735
@@ -14,6 +14,7 @@
 
 // qt includes
 #include <qevent.h>
+#include <QPolygon>
 
 // kde includes
 #include <klocale.h>
@@ -43,16 +44,24 @@
     UMLWidget::setPen(p);
     const int w = width();
     const int h = height();
+    QPolygon a;
     switch (m_SignalType)
     {
     case Send :
         if(UMLWidget::getUseFillColour())
             p.setBrush(UMLWidget::getFillColour());
         {
+
+            a.setPoints( 5, offsetX           ,offsetY,
+                            offsetX + (w*2)/3 ,offsetY,
+                            offsetX + w       ,(h/2)+offsetY,
+                            offsetX + (w*2)/3 ,h+offsetY,
+                            offsetX           ,h+offsetY );
+            p.drawPolygon( a );
             const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
             const int fontHeight  = fm.lineSpacing();
             int textStartY = (h / 2) - (fontHeight / 2);
-            p.drawRoundRect(offsetX, offsetY, w, h, (h*40)/w, (w*40)/h);
+
             p.setPen(Qt::black);
             QFont font = UMLWidget::getFont();
             font.setBold( false );
@@ -64,16 +73,41 @@
         }
         break;
     case Accept :
-        p.setBrush( WidgetBase::getLineColor() );
-        p.drawEllipse( offsetX, offsetY, w, h );
+        if(UMLWidget::getUseFillColour())
+            p.setBrush(UMLWidget::getFillColour());
+        {
+            a.setPoints( 5, offsetX ,      offsetY,
+                            offsetX + w/3, (h/2)+offsetY,
+                            offsetX ,      h+offsetY,
+                            offsetX + w,   h+offsetY,
+                            offsetX + w,   offsetY );
+
+            p.drawPolygon( a );
+            const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
+            const int fontHeight  = fm.lineSpacing();
+            int textStartY = (h / 2) - (fontHeight / 2);
+
+            p.setPen(Qt::black);
+            QFont font = UMLWidget::getFont();
+            font.setBold( false );
+            p.setFont( font );
+            p.drawText(offsetX + SIGNAL_MARGIN, offsetY + textStartY,
+                           w - SIGNAL_MARGIN * 2, fontHeight,
+                           Qt::AlignCenter, getName());
+            UMLWidget::setPen(p);
+        }
         break;
     case Time :
-        p.setBrush( WidgetBase::getLineColor() );
-        p.drawEllipse( offsetX, offsetY, w, h );
-        p.setBrush( Qt::white );
-        p.drawEllipse( offsetX + 1, offsetY + 1, w - 2, h - 2 );
-        p.setBrush( WidgetBase::getLineColor() );
-        p.drawEllipse( offsetX + 3, offsetY + 3, w - 6, h - 6 );
+ if(UMLWidget::getUseFillColour())
+            p.setBrush(UMLWidget::getFillColour());
+        {
+            a.setPoints( 4, offsetX ,    offsetY,
+                            offsetX + w, offsetY+h,
+                            offsetX ,    offsetY+h,
+                            offsetX + w, offsetY);
+
+            p.drawPolygon( a );
+        }
         break;
     default:
         kWarning() << "Unknown signal type:" << m_SignalType << endl;
@@ -85,17 +119,15 @@
 
 QSize SignalWidget::calculateSize() {
     int width = 10, height = 10;
-    if ( m_SignalType == Send ) {
         const QFontMetrics &fm = getFontMetrics(FT_BOLD);
         const int fontHeight  = fm.lineSpacing();
         int textWidth = fm.width(getName());
-        height = fontHeight;
 
-        width = textWidth > SIGNAL_WIDTH?textWidth:SIGNAL_WIDTH;
-        height = height > SIGNAL_HEIGHT?height:SIGNAL_HEIGHT;
-        width += SIGNAL_MARGIN * 2;
+        height  = fontHeight;
+        width   = textWidth > SIGNAL_WIDTH?textWidth:SIGNAL_WIDTH;
+        height  = height > SIGNAL_HEIGHT?height:SIGNAL_HEIGHT;
+        width  += SIGNAL_MARGIN * 2;
         height += SIGNAL_MARGIN * 2;
-    }
 
     return QSize(width, height);
 }
--- branches/work/isi-umbrello/umbrello/umbrello/signalwidget.h #631734:631735
@@ -17,8 +17,8 @@
 #include "worktoolbar.h"
 
 #define SIGNAL_MARGIN 5
-#define SIGNAL_WIDTH 30
-#define SIGNAL_HEIGHT 10
+#define SIGNAL_WIDTH 45
+#define SIGNAL_HEIGHT 15
 
 
 class SignalWidget : public UMLWidget {
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstateother.cpp #631734:631735
@@ -136,6 +136,14 @@
             umlWidget = new SignalWidget(m_pUMLView, SignalWidget::Send);
             break;
 
+        case WorkToolBar::tbb_Accept_Signal:
+            umlWidget = new SignalWidget(m_pUMLView, SignalWidget::Accept);
+            break;
+
+        case WorkToolBar::tbb_Accept_Time_Event:
+            umlWidget = new SignalWidget(m_pUMLView, SignalWidget::Time);
+            break;
+
 	case WorkToolBar::tbb_Seq_Combined_Fragment:
             umlWidget = new CombinedFragmentWidget(m_pUMLView);
             break;
@@ -154,6 +162,11 @@
         Dialog_Utils::askNameForWidget(
             umlWidget, i18n("Enter Activity Name"),
             i18n("Enter the name of the new activity:"), i18n("new activity"));
+    } else if (getButton() == WorkToolBar::tbb_Accept_Signal
+            || getButton() == WorkToolBar::tbb_Send_Signal) {
+        Dialog_Utils::askNameForWidget(
+            umlWidget, i18n("Enter Signal Name"),
+            i18n("Enter Signal"), i18n("new Signal"));
     } else if (getButton() == WorkToolBar::tbb_Seq_Combined_Fragment) {
         Dialog_Utils::askNameForWidgetType(
             umlWidget, i18n("Enter Combined Fragment Name"),




More information about the umbrello-devel mailing list