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

Caroline Bourdeu d'Aguerre cbda at free.fr
Wed Feb 14 17:46:10 UTC 2007


SVN commit 633650 by bourdeu:

Add the possibility to save and load from the XMI for the signals.


 M  +32 -10    signalwidget.cpp  
 M  +4 -1      signalwidget.h  
 M  +4 -0      toolbarstateother.cpp  
 M  +6 -4      widget_factory.cpp  


--- branches/work/isi-umbrello/umbrello/umbrello/signalwidget.cpp #633649:633650
@@ -27,6 +27,8 @@
 #include "docwindow.h"
 #include "umlwidget.h"
 #include "umlview.h"
+#include "floatingtextwidget.h"
+
 // #include "dialogs/signaldialog.h"
 #include "listpopupmenu.h"
 
@@ -34,7 +36,6 @@
         : UMLWidget(view, id) {
     UMLWidget::setBaseType(Uml::wt_Signal);
     m_SignalType = signalType;
-    m_Text = "Signal";
     updateComponentSize();
 }
 
@@ -92,13 +93,13 @@
             font.setBold( false );
             p.setFont( font );
             p.drawText(offsetX + SIGNAL_MARGIN, offsetY + textStartY,
-                           w - SIGNAL_MARGIN * 2, fontHeight,
+                           w - SIGNAL_MARGIN * 2 + (w/3), fontHeight,
                            Qt::AlignCenter, getName());
             UMLWidget::setPen(p);
         }
         break;
     case Time :
- if(UMLWidget::getUseFillColour())
+        if(UMLWidget::getUseFillColour())
             p.setBrush(UMLWidget::getFillColour());
         {
             a.setPoints( 4, offsetX ,    offsetY,
@@ -107,6 +108,19 @@
                             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 + h,
+//                            w - SIGNAL_MARGIN * 2, fontHeight,
+//                            Qt::AlignCenter, getName());
+            m_pName->setVisible( getName().length() > 1 );
+            //m_pName->draw(p, offsetX, offsetY);
+            UMLWidget::setPen(p);
         }
         break;
     default:
@@ -118,14 +132,19 @@
 }
 
 QSize SignalWidget::calculateSize() {
-    int width = 10, height = 10;
+        int width = SIGNAL_WIDTH, height = SIGNAL_HEIGHT;
         const QFontMetrics &fm = getFontMetrics(FT_BOLD);
         const int fontHeight  = fm.lineSpacing();
         int textWidth = fm.width(getName());
 
+        if (m_SignalType == Accept)
+             textWidth *= 1.3;
         height  = fontHeight;
-        width   = textWidth > SIGNAL_WIDTH?textWidth:SIGNAL_WIDTH;
-        height  = height > SIGNAL_HEIGHT?height:SIGNAL_HEIGHT;
+        if (m_SignalType != Time)
+        {
+              width   = textWidth > SIGNAL_WIDTH?textWidth:SIGNAL_WIDTH;
+              height  = height > SIGNAL_HEIGHT?height:SIGNAL_HEIGHT;
+        }
         width  += SIGNAL_MARGIN * 2;
         height += SIGNAL_MARGIN * 2;
 
@@ -136,6 +155,8 @@
     m_Text = strName;
     updateComponentSize();
     adjustAssocs( getX(), getY() );
+    if ( getSignalType() == Time)
+         m_pName = new FloatingTextWidget(m_pView, Uml::tr_Floating, getName());
 }
 
 QString SignalWidget::getName() const {
@@ -153,7 +174,7 @@
 bool SignalWidget::showProperties() {
 //     DocWindow *docwindow = UMLApp::app()->getDocWindow();
 //     docwindow->updateDocumentation(false);
-// 
+//
 //     SignalDialog dialog(m_pView, this);
 //     bool modified = false;
 //     if (dialog.exec() && dialog.getChangesMade()) {
@@ -161,7 +182,7 @@
 //         UMLApp::app()->getDocument()->setModified(true);
 //         modified = true;
 //     }
-// 
+//
     return true;
 }
 
@@ -172,6 +193,7 @@
     signalElement.setAttribute( "documentation", m_Doc );
     signalElement.setAttribute( "signaltype", m_SignalType );
 
+    qElement.appendChild( signalElement );
 }
 
 bool SignalWidget::loadFromXMI( QDomElement & qElement ) {
@@ -179,8 +201,8 @@
         return false;
     m_Text = qElement.attribute( "signalname", "" );
     m_Doc = qElement.attribute( "documentation", "" );
-    QString type = qElement.attribute( "signaltype", "1" );
-    m_SignalType = (SignalType)type.toInt();
+    QString type = qElement.attribute( "signaltype", "" );
+    setSignalType((SignalType)type.toInt());
     return true;
 }
 
--- branches/work/isi-umbrello/umbrello/umbrello/signalwidget.h #633649:633650
@@ -15,12 +15,12 @@
 #include <qstringlist.h>
 #include "umlwidget.h"
 #include "worktoolbar.h"
+#include "floatingtextwidget.h"
 
 #define SIGNAL_MARGIN 5
 #define SIGNAL_WIDTH 45
 #define SIGNAL_HEIGHT 15
 
-
 class SignalWidget : public UMLWidget {
     Q_OBJECT
 public:
@@ -100,6 +100,9 @@
      */
     SignalType m_SignalType;
 
+    // Only for the time event
+    FloatingTextWidget* m_pName;
+
 };
 
 #endif
--- branches/work/isi-umbrello/umbrello/umbrello/toolbarstateother.cpp #633649:633650
@@ -167,6 +167,10 @@
         Dialog_Utils::askNameForWidget(
             umlWidget, i18n("Enter Signal Name"),
             i18n("Enter Signal"), i18n("new Signal"));
+    } else if (getButton() == WorkToolBar::tbb_Accept_Time_Event) {
+        Dialog_Utils::askNameForWidget(
+            umlWidget, i18n("Enter Time Event Name"),
+            i18n("Enter Time Event"), i18n("new time event"));
     } else if (getButton() == WorkToolBar::tbb_Seq_Combined_Fragment) {
         Dialog_Utils::askNameForWidgetType(
             umlWidget, i18n("Enter Combined Fragment Name"),
--- branches/work/isi-umbrello/umbrello/umbrello/widget_factory.cpp #633649:633650
@@ -53,9 +53,9 @@
 #include "seqlinewidget.h"
 #include "preconditionwidget.h"
 #include "endoflifewidget.h"
+#include "signalwidget.h"
 #include "cmds.h"
 
-
 namespace Widget_Factory {
 
 UMLWidget *createWidget(UMLView *view, UMLObject *o) {
@@ -163,10 +163,10 @@
     UMLWidget *widget = NULL;
     if (tag == "statewidget" || tag == "notewidget" || tag == "boxwidget" ||
         tag == "floatingtext" || tag == "activitywidget" || tag == "forkjoin" || tag == "preconditionwidget" || tag == "endoflifewidget" ||
-        tag == "combinedFragmentwidget"  ||
+        tag == "combinedFragmentwidget"  || tag == "signalwidget"  ||
             // tests for backward compatibility:
             tag == "UML:StateWidget" || tag == "UML:NoteWidget" ||
-            tag=="UML:CombinedFragmentWidget" || tag == "UML:FloatingTextWidget" || tag == "UML:ActivityWidget") {
+            tag=="UML:CombinedFragmentWidget" || tag == "UML:FloatingTextWidget" || tag == "UML:SignalWidget" || tag == "UML:ActivityWidget") {
         // Loading of widgets which do NOT represent any UMLObject, 
         // just graphic stuff with no real model information
         //FIXME while boxes and texts are just diagram objects, activities and
@@ -193,7 +193,9 @@
             widget = new EndOfLifeWidget(view, NULL, Uml::id_Reserved);
 	} else if (tag == "combinedFragmentwidget") {
             widget = new CombinedFragmentWidget(view, CombinedFragmentWidget::Ref, Uml::id_Reserved);
-	}
+        } else if (tag == "signalwidget ") {
+            widget = new SignalWidget(view, SignalWidget::Send,  Uml::id_Reserved);
+        }
     } else {
         // Find the UMLObject and create the Widget to represent it
         Uml::IDType id = STR2ID(idStr);




More information about the umbrello-devel mailing list