[Uml-devel] KDE/kdesdk/umbrello/umbrello/widgets

Ralf Habacker ralf.habacker at gmail.com
Sun Jan 8 13:26:15 UTC 2012


SVN commit 1272517 by habacker:

reordered methods to reduce difference to umbrello-soc branch

 M  +64 -69    forkjoinwidget.cpp  
 M  +8 -22     forkjoinwidget.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/forkjoinwidget.cpp #1272516:1272517
@@ -11,10 +11,6 @@
 // own header
 #include "forkjoinwidget.h"
 
-//qt includes
-#include <qdom.h>
-//kde includes
-#include <kcursor.h>
 //app includes
 #include "debug_utils.h"
 #include "umlview.h"
@@ -31,38 +27,35 @@
   : BoxWidget(scene, id, WidgetBase::wt_ForkJoin),
     m_drawVertical(drawVertical)
 {
-    init();
+    UMLWidget::updateComponentSize();
 }
 
 /**
- * Initializes key variables for the class.
+ * Destructor.
  */
-void ForkJoinWidget::init()
+ForkJoinWidget::~ForkJoinWidget()
 {
-    UMLWidget::updateComponentSize();
 }
 
 /**
- * Destructor.
+ * Get whether to draw the plate vertically.
  */
-ForkJoinWidget::~ForkJoinWidget()
-{
+bool ForkJoinWidget::getDrawVertical() const {
+    return m_drawVertical;
 }
 
 /**
- * Overrides the function from UMLWidget.
+ * Set whether to draw the plate vertically.
  */
-QSize ForkJoinWidget::calculateSize()
-{
-    if (m_drawVertical) {
-        return QSize(4, 40);
-    } else {
-        return QSize(40, 4);
+void ForkJoinWidget::setDrawVertical(bool to) {
+    m_drawVertical = to;
+    updateComponentSize();
+    UMLWidget::adjustAssocs( getX(), getY() );
     }
-}
 
 /**
- * Draws a slim solid black rectangle.
+ * Reimplemented from UMLWidget::paint to draw the plate of
+ * fork join.
  */
 void ForkJoinWidget::paint(QPainter& p, int offsetX, int offsetY)
 {
@@ -74,44 +67,34 @@
 }
 
 /**
- * Reimplement method from UMLWidget to suppress the resize corner.
- * Although the ForkJoinWidget supports resizing, we suppress the
- * resize corner because it is too large for this very slim widget.
+ * Reimplemented from UMLWidget::loadFromXMI to load widget
+ * info from XMI element - 'forkjoin'.
  */
-void ForkJoinWidget::drawSelected(QPainter *, int /*offsetX*/, int /*offsetY*/)
+bool ForkJoinWidget::loadFromXMI(QDomElement& qElement)
 {
+    if ( !UMLWidget::loadFromXMI(qElement) ) {
+        return false;
 }
+    QString drawVertical = qElement.attribute("drawvertical", "0");
+    setDrawVertical( (bool)drawVertical.toInt() );
+    return true;
+}
 
 /**
- * Reimplement method from UMLWidget.
+ * Reimplemented from UMLWidget::saveToXMI to save widget info
+ * into XMI element - 'forkjoin'.
  */
-void ForkJoinWidget::constrain(int& width, int& height)
+void ForkJoinWidget::saveToXMI(QDomDocument& qDoc, QDomElement& qElement)
 {
-    if (m_drawVertical) {
-        if (width < 4)
-            width = 4;
-        else if (width > 10)
-            width = 10;
-        if (height < 40)
-            height = 40;
-        else if (height > 100)
-            height = 100;
-    } else {
-        if (height < 4)
-            height = 4;
-        else if (height > 10)
-            height = 10;
-        if (width < 40)
-            width = 40;
-        else if (width > 100)
-            width = 100;
+    QDomElement fjElement = qDoc.createElement("forkjoin");
+    UMLWidget::saveToXMI(qDoc, fjElement);
+    fjElement.  ("drawvertical", m_drawVertical);
+    qElement.appendChild(fjElement);
     }
-}
 
 /**
- * Overrides the function from UMLWidget.
- *
- * @param action  The action to be executed.
+ * Reimplemented form UMLWidget::slotMenuSelection to handle
+ * Flip action.
  */
 void ForkJoinWidget::slotMenuSelection(QAction* action)
 {
@@ -125,37 +108,49 @@
     }
 }
 
-void ForkJoinWidget::setDrawVertical(bool to) {
-    m_drawVertical = to;
-    updateComponentSize();
-    UMLWidget::adjustAssocs( getX(), getY() );
+/**
+ * Overrides the function from UMLWidget.
+ */
+QSize ForkJoinWidget::calculateSize()
+{
+    if (m_drawVertical) {
+        return QSize(4, 40);
+    } else {
+        return QSize(40, 4);
 }
-
-bool ForkJoinWidget::getDrawVertical() const {
-    return m_drawVertical;
 }
 
 /**
- * Saves the widget to the "forkjoinwidget" XMI element.
+ * Reimplement method from UMLWidget to suppress the resize corner.
+ * Although the ForkJoinWidget supports resizing, we suppress the
+ * resize corner because it is too large for this very slim widget.
  */
-void ForkJoinWidget::saveToXMI(QDomDocument& qDoc, QDomElement& qElement)
+void ForkJoinWidget::drawSelected(QPainter *, int /*offsetX*/, int /*offsetY*/)
 {
-    QDomElement fjElement = qDoc.createElement("forkjoin");
-    UMLWidget::saveToXMI(qDoc, fjElement);
-    fjElement.setAttribute("drawvertical", m_drawVertical);
-    qElement.appendChild(fjElement);
 }
 
 /**
- * Loads the widget from the "forkjoinwidget" XMI element.
+ * Reimplement method from UMLWidget.
  */
-bool ForkJoinWidget::loadFromXMI(QDomElement& qElement)
+void ForkJoinWidget::constrain(int& width, int& height)
 {
-    if ( !UMLWidget::loadFromXMI(qElement) ) {
-        return false;
+    if (m_drawVertical) {
+        if (width < 4)
+            width = 4;
+        else if (width > 10)
+            width = 10;
+        if (height < 40)
+            height = 40;
+        else if (height > 100)
+            height = 100;
+    } else {
+        if (height < 4)
+            height = 4;
+        else if (height > 10)
+            height = 10;
+        if (width < 40)
+            width = 40;
+        else if (width > 100)
+            width = 100;
     }
-    QString drawVertical = qElement.attribute("drawvertical", "0");
-    setDrawVertical( (bool)drawVertical.toInt() );
-    return true;
 }
-
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/forkjoinwidget.h #1272516:1272517
@@ -14,12 +14,6 @@
 //app includes
 #include "boxwidget.h"
 
-//qt includes
-#include <QtGui/QPainter>
-
-// fwd decl.
-class UMLScene;
-
 /**
  * @short Displays a fork/join plate in a state diagram.
  * @author Oliver Kellogg  <okellogg at users.sourceforge.net>
@@ -29,36 +23,28 @@
 class ForkJoinWidget : public BoxWidget
 {
 public:
-
     explicit ForkJoinWidget(UMLScene * scene, bool drawVertical = false, Uml::IDType id = Uml::id_None);
     virtual ~ForkJoinWidget();
 
-    /**
-     * Set whether to draw the plate vertically.
-     */
-    void setDrawVertical(bool to);
-    /**
-     * Get whether to draw the plate vertically.
-     */
     bool getDrawVertical() const;
+    void setDrawVertical(bool to);
 
-    void slotMenuSelection(QAction* action);
+    virtual void paint(QPainter & p, int offsetX, int offsetY);
 
-    void paint(QPainter & p, int offsetX, int offsetY);
+    virtual bool loadFromXMI(QDomElement & qElement);
+    virtual void saveToXMI(QDomDocument& qDoc, QDomElement& qElement);
 
-    bool loadFromXMI(QDomElement & qElement);
-    void saveToXMI(QDomDocument& qDoc, QDomElement& qElement);
+public Q_SLOTS:
+    virtual void slotMenuSelection(QAction* action);
 
 protected:
-    void drawSelected(QPainter * p, int offsetX, int offsetY);
-
     QSize calculateSize();
 
+    void drawSelected(QPainter * p, int offsetX, int offsetY);
+
     void constrain(int& width, int& height);
 
 private:
-    void init();
-
     bool m_drawVertical;   ///< whether to draw the plate horizontally or vertically
 };
 




More information about the umbrello-devel mailing list