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

Gopala Krishna A krishna.ggk at gmail.com
Fri Aug 1 16:37:27 UTC 2008


SVN commit 840729 by gopala:

Documented SeqLineWidget code. (had forgotten previously)



 M  +26 -3     seqlinewidget.cpp  
 M  +16 -11    seqlinewidget.h  


--- branches/work/soc-umbrello/umbrello/seqlinewidget.cpp #840728:840729
@@ -15,8 +15,10 @@
 //app includes
 #include "objectwidget.h"
 
+/// The width and height of the destruction box.
 const qreal SeqLineWidget::DestructionBoxSize = 14;
 
+/// @internal Utility method to add line to path if line is non null.
 static void addLineToPath(const QLineF& line, QPainterPath &path)
 {
     if (!line.isNull()) {
@@ -25,8 +27,13 @@
     }
 }
 
+/**
+ * Constructs a Sequential line widget.
+ *
+ * @param pObject The ObjectWidget to which this widget belongs to.
+ */
 SeqLineWidget::SeqLineWidget( ObjectWidget * pObject ) :
-    QGraphicsItem(pObject),
+    QGraphicsItem(pObject), // also make object widget as parent
     m_objectWidget(pObject),
     m_length(250),
     m_lineColor(pObject->lineColor()),
@@ -39,18 +46,24 @@
 {
 }
 
+/// Sets the color of lines drawn.
 void SeqLineWidget::setLineColor(const QColor& col)
 {
     m_lineColor = col;
     update();
 }
 
-void SeqLineWidget::setLineWidth(qreal w)
+/// Sets the width of the lines drawn.
+void SeqLineWidget::setLineWidth(int w)
 {
     m_lineWidth = w;
     updateGeometry();
 }
 
+/**
+ * Creates/destroyes the lines corresponding to destruction box based
+ * on whether it should be shown or not.
+ */
 void SeqLineWidget::updateDestructionBoxVisibility()
 {
     m_destructionBoxLines[0] = m_destructionBoxLines[1] = QLineF();
@@ -67,6 +80,7 @@
     updateGeometry();
 }
 
+/// @retval true If \a localPos is inside destruction box.
 bool SeqLineWidget::onDestructionBox(const QPointF& localPos)
 {
     QRectF rect(0, 0,
@@ -76,6 +90,7 @@
     return m_objectWidget->getShowDestruction() && rect.contains(localPos);
 }
 
+/// Sets the length of the sequential line of this widget to \a len.
 void SeqLineWidget::setLength(qreal len)
 {
     m_length = len;
@@ -86,11 +101,14 @@
     updateDestructionBoxVisibility();
 }
 
+/**
+ * Reimplemented from QGraphicsItem::paint to draw the sequential line
+ * and also the destruction box if it is shown.
+ */
 void SeqLineWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*)
 {
     QPen pen(m_lineColor, m_lineWidth, Qt::DashLine);
     painter->setPen(pen);
-
     painter->drawLine(m_sequentialLine);
 
     if (!m_destructionBoxLines[0].isNull() && !m_destructionBoxLines[1].isNull()) {
@@ -102,6 +120,11 @@
     }
 }
 
+/**
+ * Calculates the new shape and new bounding rect for this widget
+ * based on current values of m_sequentialLine and
+ * m_destructionBoxLines.
+ */
 void SeqLineWidget::updateGeometry()
 {
     QPainterPath linePath;
--- branches/work/soc-umbrello/umbrello/seqlinewidget.h #840728:840729
@@ -33,43 +33,48 @@
     SeqLineWidget( ObjectWidget * pObject );
     virtual ~SeqLineWidget();
 
+    /// @return The color of the lines drawn
     QColor lineColor() const {
         return m_lineColor;
     }
     void setLineColor(const QColor & col);
 
-    qreal lineWidth() const {
+    /// @return Width of the line drawn
+    int lineWidth() const {
         return m_lineWidth;
     }
-    void setLineWidth(qreal w);
+    void setLineWidth(int w);
 
     void updateDestructionBoxVisibility();
     bool onDestructionBox(const QPointF& localPos);
 
+    /// @return Length of the sequential line.
     qreal length() const {
         return m_length;
     }
     void setLength(qreal length);
 
-    /**
-     * Sets the y position of the bottom of the vertical line.
-     *
-     * @param yPosition The y coordinate for the bottom of the line.
-     */
+    /// Sets 'y' coordinate of end of line.
     void setEndOfLine(qreal yPosition) {
-        setLength(yPosition - pos().y());
+        setLength(yPosition);
     }
 
-    /**
-     * @return  Pointer to the associated ObjectWidget.
-     */
+    /// @return  Pointer to the associated ObjectWidget.
     ObjectWidget * objectWidget() const{
         return m_objectWidget;
     }
 
+    /**
+     * Reimplemented form QGraphicsItem::boundingRect to return the
+     * bounds of this widget stored in m_boundingRect.
+     */
     virtual QRectF boundingRect() const {
         return m_boundingRect;
     }
+    /**
+     * Reimplemented form QGraphicsItem::shape to return the shape of
+     * this widget stored in m_shape.
+     */
     virtual QPainterPath shape() const {
         return m_shape;
     }




More information about the umbrello-devel mailing list