[Uml-devel] KDE/kdesdk/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Wed Mar 21 07:09:37 UTC 2012


SVN commit 1286480 by okellogg:

StateWidget:
- Copy m_drawVertical and its accessors and load/save code from
  ForkJoinWidget to allow flipping fork/join horizontal.
- maximumSize(): Reimplement from UMLWidget.

ListPopupMenu::ListPopupMenu(parent, object, multi, unique):
- At case WidgetBase::wt_State, add mt_Flip for pState->stateType()
  StateWidget::Fork and StateWidget::Join.

BUG: 296331


 M  +1 -0      ChangeLog  
 M  +12 -1     umbrello/listpopupmenu.cpp  
 M  +50 -0     umbrello/widgets/statewidget.cpp  
 M  +5 -0      umbrello/widgets/statewidget.h  


--- trunk/KDE/kdesdk/umbrello/ChangeLog #1286479:1286480
@@ -5,6 +5,7 @@
 * Color of role text on diagram (e.g. Role B) nearly invisible (291401)
 * Junk residual UMLAssociations saved to XMI (293042)
 * Problems with widget moving/resizing in state diagrams (295605)
+* State diagram deep/shallow history widget resizing problem (296331)
 
 Version 2.8.1
 
--- trunk/KDE/kdesdk/umbrello/umbrello/listpopupmenu.cpp #1286479:1286480
@@ -416,10 +416,21 @@
             }
             insertSubMenuColor( object->useFillColor() );
             insertStdItems(false, type);
-            if (pState->stateType() == StateWidget::Normal) {
+            switch (pState->stateType()) {
+	        case StateWidget::Normal:
                 insert(mt_Rename, i18n("Change State Name..."));
                 insert(mt_Change_Font);
                 insert(mt_Properties);
+		    break;
+	        case StateWidget::Fork:
+	        case StateWidget::Join:
+                    if (pState->drawVertical())
+                        insert(mt_Flip, i18n("Flip Horizontal"));
+                    else
+                        insert(mt_Flip, i18n("Flip Vertical"));
+		    break;
+		default:
+		    break;
             }
         }
         break;
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/statewidget.cpp #1286479:1286480
@@ -40,6 +40,7 @@
   : UMLWidget(scene, WidgetBase::wt_State, id)
 {
     m_stateType = stateType;
+    m_drawVertical = true;
     setAspectRatioMode();
     m_Text = "State";
 }
@@ -204,8 +205,13 @@
         }
         case StateWidget::Fork:
         case StateWidget::Join:
+            if (m_drawVertical) {
             width = 8;
             height = 60;
+            } else {
+                width = 60;
+                height = 8;
+            }
             break;
         case StateWidget::Junction:
         case StateWidget::DeepHistory:
@@ -225,6 +231,26 @@
 }
 
 /**
+ * Overrides method from UMLWidget
+ */
+UMLSceneSize StateWidget::maximumSize()
+{
+    switch (m_stateType) {
+        case StateWidget::Initial:
+        case StateWidget::End:
+        case StateWidget::Junction:
+        case StateWidget::DeepHistory:
+        case StateWidget::ShallowHistory:
+        case StateWidget::Choice:
+            return UMLSceneSize(35, 35);
+            break;
+        default:
+            break;
+    }
+    return UMLWidget::maximumSize();
+}
+
+/**
  * Set the aspect ratio mode.
  * Some state types have a fixed aspect ratio
  */
@@ -316,6 +342,10 @@
             addActivity( nameNew );
         break;
 
+    case ListPopupMenu::mt_Flip:
+        setDrawVertical(!m_drawVertical);
+        break;
+
     default:
         UMLWidget::slotMenuSelection(action);
     }
@@ -372,6 +402,22 @@
 }
 
 /**
+ * Get whether to draw a fork or join vertically.
+ */
+bool StateWidget::drawVertical() const {
+    return m_drawVertical;
+}
+
+/**
+ * Set whether to draw a fork or join vertically.
+ */
+void StateWidget::setDrawVertical(bool to) {
+    m_drawVertical = to;
+    updateComponentSize();
+    UMLWidget::adjustAssocs( getX(), getY() );
+}
+
+/**
  * Show a properties dialog for a StateWidget.
  */
 void StateWidget::showPropertiesDialog()
@@ -424,6 +470,8 @@
     stateElement.setAttribute( "statename", m_Text );
     stateElement.setAttribute( "documentation", m_Doc );
     stateElement.setAttribute( "statetype", m_stateType );
+    if (m_stateType == Fork || m_stateType == Join)
+        stateElement.setAttribute("drawvertical", m_drawVertical);
     //save states activities
     QDomElement activitiesElement = qDoc.createElement( "Activities" );
 
@@ -449,6 +497,8 @@
     QString type = qElement.attribute( "statetype", "1" );
     m_stateType = (StateType)type.toInt();
     setAspectRatioMode();
+    QString drawVertical = qElement.attribute("drawvertical", "1");
+    m_drawVertical = (bool)drawVertical.toInt();
     //load states activities
     QDomNode node = qElement.firstChild();
     QDomElement tempElement = node.toElement();
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/statewidget.h #1286479:1286480
@@ -78,6 +78,9 @@
     QStringList activities() const;
     void setActivities(const QStringList &list);
 
+    bool drawVertical() const;
+    void setDrawVertical(bool to = true);
+
     virtual void showPropertiesDialog();
 
     static bool isState(WorkToolBar::ToolBar_Buttons tbb,
@@ -88,6 +91,7 @@
 
 protected:
     UMLSceneSize minimumSize();
+    UMLSceneSize maximumSize();
     void setAspectRatioMode();
 
 public slots:
@@ -95,6 +99,7 @@
 
 private:
     StateType   m_stateType;   ///< Type of state.
+    bool m_drawVertical;   ///< whether to draw the fork/join horizontally or vertically
     QStringList m_Activities;  ///< List of activities for the state.
 
 };




More information about the umbrello-devel mailing list