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

Gopala Krishna A krishna.ggk at gmail.com
Tue Aug 18 07:23:53 UTC 2009


SVN commit 1012828 by gopala:

Important changes to WidgetBase:

* Black is default color for font, which was lineColor() before.

* Assert for umlScene() to be valid in loadFromXMI and saveToXMI methods
  as mapping of coordinates has to work appropriately.

* Save the position of widget in terms of scene coordinates rather than that
  of parent item coordinates. This fixes ability to load soc branch generated
  files in trunk version of umbrello.



 M  +13 -8     widgetbase.cpp  


--- branches/work/soc-umbrello/umbrello/widgets/widgetbase.cpp #1012827:1012828
@@ -378,7 +378,7 @@
 
 /**
  * Sets the color of the font to \a color.
- * If \a color is invalid, line color is used for font color.
+ * If \a color is invalid, black is used instead.
  *
  * This method issues @ref FontColorHasChanged notification after
  * setting the new font color.
@@ -389,7 +389,7 @@
     const QColor oldColor = fontColor();
     m_fontColor = color;
     if(!m_fontColor.isValid()) {
-        m_fontColor = m_lineColor;
+        m_fontColor = Qt::black;
     }
 
     attributeChange(FontColorHasChanged, oldColor);
@@ -495,6 +495,7 @@
  */
 bool WidgetBase::loadFromXMI(QDomElement &qElement)
 {
+    Q_ASSERT(umlScene());
     // NOTE:
     // The "none" is used by kde3 version of umbrello. The current
     // technique to determine whether a property is being used from
@@ -526,7 +527,7 @@
         setLineWidth(umlScene()->getLineWidth());
     }
 
-    // Load the font color, if invalid line color is automatically used.
+    // Load the font color, if invalid black is used.
     QString fontColor = qElement.attribute("fontcolor");
     setFontColor(QColor(fontColor));
 
@@ -582,9 +583,11 @@
         setID(STR2ID(id));
     }
 
-    qreal x = qElement.attribute("x", "0").toDouble();
-    qreal y = qElement.attribute("y", "0").toDouble();
-    setPos(x, y);
+    QPointF pos;
+    pos.setX(qElement.attribute("x", "0").toDouble());
+    pos.setY(qElement.attribute("y", "0").toDouble());
+    pos = mapToParent(mapFromScene(pos));
+    setPos(pos);
 
     return true;
 }
@@ -602,6 +605,7 @@
  */
 void WidgetBase::saveToXMI(QDomDocument &qDoc, QDomElement &qElement)
 {
+    Q_ASSERT(umlScene());
     qElement.setAttribute("linecolor", m_lineColor.name());
     qElement.setAttribute("linewidth", m_lineWidth);
     qElement.setAttribute("fontcolor", m_fontColor.name());
@@ -610,8 +614,9 @@
     Widget_Utils::saveBrushToXMI(qDoc, qElement, m_brush);
 
     qElement.setAttribute("xmi.id", ID2STR(id()));
-    qElement.setAttribute("x", pos().x());
-    qElement.setAttribute("y", pos().y());
+    const QPointF pos = scenePos();
+    qElement.setAttribute("x", pos.x());
+    qElement.setAttribute("y", pos.y());
 }
 
 /**




More information about the umbrello-devel mailing list