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

Andi Fischer andi.fischer at hispeed.ch
Sun Apr 1 08:29:46 UTC 2012


SVN commit 1287797 by fischer:

Differences to trunk reduced.

 M  +3 -1      layoutgenerator.h  
 M  +22 -5     listpopupmenu.cpp  
 M  +8 -12     umlscene.cpp  
 M  +0 -4      umlscene.h  
 M  +30 -14    widgets/forkjoinwidget.cpp  
 M  +5 -10     widgets/forkjoinwidget.h  
 M  +46 -13    widgets/statewidget.cpp  
 M  +5 -5      widgets/statewidget.h  


--- branches/work/soc-umbrello/umbrello/layoutgenerator.h #1287796:1287797
@@ -122,8 +122,10 @@
         QTemporaryFile in;
         QTemporaryFile out;
         QTemporaryFile xdotOut;
-        if (!isEnabled())
+        if (!isEnabled()) {
+            uWarning() << "Could not apply autolayout because graphviz installation has not been found.";
             return false;
+        }
 
 #ifdef LAYOUTGENERATOR_DEBUG
         in.setAutoRemove(false);
--- branches/work/soc-umbrello/umbrello/listpopupmenu.cpp #1287796:1287797
@@ -4,7 +4,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2002-2011                                               *
+ *   copyright (C) 2002-2012                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
@@ -435,10 +435,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;
@@ -1726,20 +1737,26 @@
     insert(mt_Clear, Icon_Utils::SmallIcon(Icon_Utils::it_Clear), i18n("Clear Diagram"));
     insert(mt_Export_Image);
     addSeparator();
-    QHash<QString, QString> configFiles;
     QList<MenuType> types;
     types << mt_Apply_Layout << mt_Apply_Layout1 << mt_Apply_Layout2 << mt_Apply_Layout3 << mt_Apply_Layout4 << mt_Apply_Layout5 << mt_Apply_Layout6 << mt_Apply_Layout7 << mt_Apply_Layout8 << mt_Apply_Layout9;
+    LayoutGenerator generator;
+    if (generator.isEnabled()) {
+        QHash<QString, QString> configFiles;
     if (LayoutGenerator::availableConfigFiles(view->umlScene(), configFiles)) {
         int i = 0;
         foreach(const QString &key, configFiles.keys()) {
             if (i >= types.size())
                 break;
-            insert(types[i], QPixmap(), i18n("apply '%1'").arg(configFiles[key]));
+                insert(types[i], QPixmap(), i18n("apply '%1'",configFiles[key]));
             getAction(types[i])->setData(QVariant(key));
             i++;
         }
+            addSeparator();
     }
-    addSeparator();
+    }
+    else {
+        uWarning() << "Could not add autolayout entries because graphviz installation has not been found.";
+    }
     insert(mt_SnapToGrid, i18n("Snap to Grid"), CHECKABLE);
     setActionChecked(mt_SnapToGrid, view->umlScene()->getSnapToGrid() );
     insert(mt_ShowSnapGrid, i18n("Show Grid"), CHECKABLE);
--- branches/work/soc-umbrello/umbrello/umlscene.cpp #1287796:1287797
@@ -1067,14 +1067,9 @@
 }
 
 /**
- * Finds an association widget with the given widgets and the given role B name.
- * Considers the following association types:
- *  at_Association, at_UniAssociation, at_Composition, at_Aggregation
- * This is used for seeking an attribute association.
+ * Finds an association widget with the given ID.
  *
- * @param pWidgetA  Pointer to the UMLWidget of role A.
- * @param pWidgetB  Pointer to the UMLWidget of role B.
- * @param roleNameB Name at the B side of the association (the attribute name)
+ * @param id The ID of the widget to find.
  *
  * @return Returns the widget found, returns 0 if no widget found.
  */
@@ -1644,6 +1639,7 @@
  */
 void  UMLScene::getDiagram(const QRectF &area, QPainter & painter)
 {
+    DEBUG(DBG_SRC) << "area=" << area << ", painter=" << painter.window();
     //TODO unselecting and selecting later doesn't work now as the selection is
     //cleared in UMLViewImageExporter. Check if the anything else than the
     //following is needed and, if it works, remove the clearSelected in
@@ -2320,8 +2316,6 @@
         removeAssoc(assocwidget);
     }
 
-    // Porting to QList from QPtrList which doesn't support autodelete
-    //m_AssociationList.clear();
     qDeleteAll(m_AssociationList);
     m_AssociationList.clear();
 }
@@ -2811,7 +2805,6 @@
         }
 
         createAutoConstraintAssociation(refEntity , fkc , widget);
-
     }
 }
 
@@ -3074,8 +3067,8 @@
 /**
  * This slot is entered when an event has occurred on the views display,
  * most likely a mouse event.  Before it sends out that mouse event everyone
- * that displays a menu on the views surface (widgets and this) thould remove any
- * menu.  This stops more than one menu bieing displayed.
+ * that displays a menu on the views surface (widgets and this) should remove any
+ * menu.  This stops more than one menu being displayed.
  */
 void UMLScene::slotRemovePopupMenu()
 {
@@ -3469,6 +3462,9 @@
     return m_Options.uiState.font;
 }
 
+/**
+ * Sets the font for the view and optionally all the widgets on the view.
+ */
 void UMLScene::setFont(QFont font, bool changeAllWidgets /* = false */)
 {
     m_Options.uiState.font = font;
--- branches/work/soc-umbrello/umbrello/umlscene.h #1287796:1287797
@@ -228,9 +228,7 @@
     void beginPartialWidgetPaste();
 
     void removeAssoc(AssociationWidget* pAssoc);
-
     void removeAssociations(UMLWidget* pWidget);
-
     void selectAssociations(bool bSelect);
 
     void getWidgetAssocs(UMLObject* Obj, AssociationWidgetList & Associations);
@@ -295,7 +293,6 @@
     virtual bool loadFromXMI(QDomElement & qElement);
 
     bool loadUISDiagram(QDomElement & qElement);
-
     UMLWidget* loadWidgetFromXMI(QDomElement& widgetElement);
 
     void addObject(UMLObject *object);
@@ -427,7 +424,6 @@
     void createAutoAttributeAssociation(UMLClassifier *type,
                                         UMLAttribute *attr,
                                         UMLWidget *widget);
-
     void createAutoConstraintAssociation(UMLEntity* refEntity,
                                          UMLForeignKeyConstraint* fkConstraint,
                                          UMLWidget* widget);
--- branches/work/soc-umbrello/umbrello/widgets/forkjoinwidget.cpp #1287796:1287797
@@ -4,7 +4,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2005-2011                                               *
+ *   copyright (C) 2005-2012                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
@@ -15,15 +15,14 @@
 #include "debug_utils.h"
 #include "listpopupmenu.h"
 
-
 /**
  * Constructs a ForkJoinWidget.
- * @param o The orientation of ForkJoinWidget.
+ * @param ori   The orientation of ForkJoinWidget.
  * @param id ID of the widget. (-1 for new id)
  */
-ForkJoinWidget::ForkJoinWidget(Qt::Orientation o, Uml::IDType id)
+ForkJoinWidget::ForkJoinWidget(Qt::Orientation ori, Uml::IDType id)
   : BoxWidget(id, WidgetBase::wt_ForkJoin),
-    m_orientation(o)
+    m_orientation(ori)
 {
     setMargin(0);
     setBrush(QBrush(Qt::black));
@@ -37,11 +36,19 @@
 }
 
 /**
- * Sets the orientation of this widget to \a o.
+ * Get whether to draw the plate vertically or horizontally.
  */
-void ForkJoinWidget::setOrientation(Qt::Orientation o)
+Qt::Orientation ForkJoinWidget::orientation() const
 {
-    m_orientation = o;
+    return m_orientation;
+}
+
+/**
+ * Set whether to draw the plate vertically or horizontally.
+ */
+void ForkJoinWidget::setOrientation(Qt::Orientation ori)
+{
+    m_orientation = ori;
     updateGeometry();
 }
 
@@ -63,10 +70,16 @@
     if ( !UMLWidget::loadFromXMI(qElement) ) {
         return false;
     }
-    // FIXME: This attribute is incompatible with trunk xmi format !!!
-    QString orientation = qElement.attribute("orientation",
-                                             QString::number(Qt::Horizontal));
-    setOrientation( (Qt::Orientation)orientation.toInt() );
+
+    QString drawVerticalStr = qElement.attribute("drawvertical", "0");
+    bool drawVertical = (bool)drawVerticalStr.toInt();
+    if (drawVertical) {
+        setOrientation(Qt::Vertical);
+    }
+    else {
+        setOrientation(Qt::Horizontal);
+    }
+
     return true;
 }
 
@@ -78,8 +91,11 @@
 {
     QDomElement fjElement = qDoc.createElement("forkjoin");
     UMLWidget::saveToXMI(qDoc, fjElement);
-    // FIXME: This creates an incompatible xmi format !!!
-    fjElement.setAttribute("orientation", m_orientation);
+    bool drawVertical = true;
+    if (m_orientation == Qt::Horizontal) {
+        drawVertical = false;
+    }
+    fjElement.setAttribute("drawvertical", drawVertical);
     qElement.appendChild(fjElement);
 }
 
--- branches/work/soc-umbrello/umbrello/widgets/forkjoinwidget.h #1287796:1287797
@@ -4,7 +4,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2005-2009                                               *
+ *   copyright (C) 2005-2012                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
@@ -28,15 +28,11 @@
     Q_OBJECT
     Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
 public:
-
-    explicit ForkJoinWidget(Qt::Orientation o = Qt::Horizontal, Uml::IDType id = Uml::id_None);
+    explicit ForkJoinWidget(Qt::Orientation ori = Qt::Horizontal, Uml::IDType id = Uml::id_None);
     virtual ~ForkJoinWidget();
 
-    /// @return Whether to draw plate vertically or not.
-    Qt::Orientation orientation() const {
-        return m_orientation;
-    }
-    void setOrientation(Qt::Orientation o);
+    Qt::Orientation orientation() const;
+    void setOrientation(Qt::Orientation ori);
 
     virtual void paint(QPainter *p, const QStyleOptionGraphicsItem *item, QWidget *w);
 
@@ -50,8 +46,7 @@
     virtual void updateGeometry();
 
 private:
-    /// whether to draw the plate horizontally or vertically
-    Qt::Orientation m_orientation;
+    Qt::Orientation m_orientation;   ///< whether to draw the plate horizontally or vertically
 };
 
 #endif
--- branches/work/soc-umbrello/umbrello/widgets/statewidget.cpp #1287796:1287797
@@ -41,6 +41,7 @@
   : UMLWidget(WidgetBase::wt_State, id)
 {
     m_stateType = stateType;
+    m_drawVertical = true;
     createTextItemGroup();
 
     const qreal radius = 18.0;
@@ -70,9 +71,10 @@
         break;
     case StateWidget::Fork:
     case StateWidget::Join:
-        {
-            const QSizeF sz = QSizeF(8, 60);
-            setSize(sz);
+        if (m_drawVertical) {
+            setSize(QSizeF(8, 60));
+        } else {
+            setSize(QSize(60, 8));
         }
         break;
     case StateWidget::Junction:
@@ -201,7 +203,8 @@
 }
 
 /**
- * @return Type of state.
+ * Returns the type of state.
+ * @return StateType
  */
 StateWidget::StateType StateWidget::stateType() const
 {
@@ -209,8 +212,16 @@
 }
 
 /**
- * Sets the StateType of this widget to \a stateType.
+ * Returns the type string of state.
  */
+QString StateWidget::stateTypeStr() const
+{
+    return QLatin1String(ENUM_NAME(StateWidget, StateType, m_stateType));
+}
+
+/**
+ * Sets the type of state.
+ */
 void StateWidget::setStateType(StateType stateType)
 {
     m_stateType = stateType;
@@ -317,6 +328,23 @@
 }
 
 /**
+ * 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;
+    UMLWidget::updateGeometry();
+}
+
+/**
  * Reimplemented from WidgetBase::showPropertiesDialog to show
  * appropriate dialog for this widget.
  */
@@ -330,6 +358,7 @@
         docwindow->showDocumentation(this, true);
         UMLApp::app()->document()->setModified(true);
     }
+    delete dialog;
 }
 
 /**
@@ -400,14 +429,14 @@
     switch (m_stateType) {
     case StateWidget::Fork:
     case StateWidget::Join:
-/*        if (m_orientation == Qt::Horizontal) {
+        if (m_drawVertical) {
+            setMinimumSize(QSizeF(4, 40));
+            setMaximumSize(QSizeF(10, 100));
+        }
+        else {
             setMinimumSize(QSizeF(40, 4));
             setMaximumSize(QSizeF(100, 10));
         }
-        else {*/
-            setMinimumSize(QSizeF(4, 40));
-            setMaximumSize(QSizeF(10, 100));
-//        }
         break;
     case StateWidget::Normal:
         {
@@ -491,8 +520,8 @@
         uError() << "Action's data field does not contain ListPopupMenu pointer";
         return;
     }
+
     ListPopupMenu::MenuType sel = menu->getMenuType(action);
-
     switch( sel ) {
     case ListPopupMenu::mt_Rename:
         text = KInputDialog::getText( i18n("Enter State Name"),
@@ -503,6 +532,10 @@
         }
         break;
 
+    case ListPopupMenu::mt_Properties:
+        showPropertiesDialog();
+        break;
+
     case ListPopupMenu::mt_New_Activity:
         text = KInputDialog::getText( i18n("Enter Activity"),
                                       i18n("Enter the name of the new activity:"),
@@ -512,8 +545,8 @@
         }
         break;
 
-    case ListPopupMenu::mt_Properties:
-        showPropertiesDialog();
+    case ListPopupMenu::mt_Flip:
+        setDrawVertical(!m_drawVertical);
         break;
 
     default:
--- branches/work/soc-umbrello/umbrello/widgets/statewidget.h #1287796:1287797
@@ -55,11 +55,7 @@
     virtual void paint(QPainter *p, const QStyleOptionGraphicsItem *item, QWidget *w);
 
     StateType stateType() const;
-    QString stateTypeStr() const
-    {
-        return QLatin1String(ENUM_NAME(StateWidget, StateType, m_stateType));
-    }
-
+    QString stateTypeStr() const;
     void setStateType(StateType stateType);
 
     bool addActivity(const QString &activity);
@@ -69,6 +65,9 @@
     QStringList activities() const;
     void setActivities(const QStringList &list);
 
+    bool drawVertical() const;
+    void setDrawVertical(bool to = true);
+
     virtual void showPropertiesDialog();
 
     virtual bool loadFromXMI(QDomElement & qElement);
@@ -86,6 +85,7 @@
     static const QSizeF MinimumEllipseSize;
 
     StateType m_stateType;   ///< Type of state.
+    bool      m_drawVertical; ///< whether to draw the fork/join horizontally or vertically
 
     enum {
         GroupIndex




More information about the umbrello-devel mailing list