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

Ralf Habacker ralf.habacker at gmail.com
Fri Jan 13 07:30:59 UTC 2012


SVN commit 1273377 by habacker:

Reduced difference to soc-umbrello branch by moving color and line width related attributes and methods to class WidgetBase.

 M  +3 -39     umlwidget.cpp  
 M  +0 -53     umlwidget.h  
 M  +154 -17   widgetbase.cpp  
 M  +27 -3     widgetbase.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/umlwidget.cpp #1273376:1273377
@@ -546,8 +546,7 @@
  */
 void UMLWidget::setUseFillColor(bool fc)
 {
-    m_useFillColor = fc;
-    m_usesDiagramUseFillColor = false;
+    WidgetBase::setUseFillColor(fc);
     update();
 }
 
@@ -612,20 +611,11 @@
  */
 void UMLWidget::setFillColorcmd(const QColor &color)
 {
-    m_FillColor = color;
-    m_usesDiagramFillColor = false;
+    WidgetBase::setFillColor(color);
     update();
 }
 
 /**
- * Read property m_FillColor.
- */
-QColor UMLWidget::fillColor() const
-{
-    return  m_FillColor;
-}
-
-/**
  * Draws that the widget is selected.
  *
  * @param p Device on which is the selection is to be drawn.
@@ -1351,19 +1341,10 @@
     WidgetBase::saveToXMI(qDoc, qElement);
     qElement.setAttribute("xmi.id", ID2STR(id()));
     qElement.setAttribute("font", m_Font.toString());
-    qElement.setAttribute("usefillcolor", m_useFillColor);
     qElement.setAttribute("x", getX());
     qElement.setAttribute("y", getY());
     qElement.setAttribute("width", getWidth());
     qElement.setAttribute("height", getHeight());
-    // for consistency the following attributes now use american spelling for "color"
-    qElement.setAttribute("usesdiagramfillcolor", m_usesDiagramFillColor);
-    qElement.setAttribute("usesdiagramusefillcolor", m_usesDiagramUseFillColor);
-    if (m_usesDiagramFillColor) {
-        qElement.setAttribute("fillcolor", "none");
-    } else {
-        qElement.setAttribute("fillcolor", m_FillColor.name());
-    }
     qElement.setAttribute("isinstance", m_isInstance);
     if (!m_instanceName.isEmpty())
         qElement.setAttribute("instancename", m_instanceName);
@@ -1376,22 +1357,10 @@
     WidgetBase::loadFromXMI(qElement);
     QString id = qElement.attribute("xmi.id", "-1");
     QString font = qElement.attribute("font", "");
-    QString usefillcolor = qElement.attribute("usefillcolor", "1");
     QString x = qElement.attribute("x", "0");
     QString y = qElement.attribute("y", "0");
     QString h = qElement.attribute("height", "0");
     QString w = qElement.attribute("width", "0");
-    /*
-      For the next three *color attributes, there was a mixup of american and english spelling for "color".
-      So first we need to keep backward compatibility and try to retrieve the *colour attribute.
-      Next we overwrite this value if we find a *color, otherwise the former *colour is kept.
-    */
-    QString fillColor = qElement.attribute("fillcolour", "none");
-    fillColor = qElement.attribute("fillcolor", fillColor);
-    QString usesDiagramFillColor = qElement.attribute("usesdiagramfillcolour", "1");
-    usesDiagramFillColor = qElement.attribute("usesdiagramfillcolor", usesDiagramFillColor);
-    QString usesDiagramUseFillColor = qElement.attribute("usesdiagramusefillcolour", "1");
-    usesDiagramUseFillColor = qElement.attribute("usesdiagramusefillcolor", usesDiagramUseFillColor);
 
     m_nId = STR2ID(id);
 
@@ -1404,15 +1373,10 @@
         << " for widget with xmi.id " << ID2STR(m_nId) << endl;
         //setFont( m_Font );
     }
-    m_useFillColor = (bool)usefillcolor.toInt();
-    m_usesDiagramFillColor = (bool)usesDiagramFillColor.toInt();
-    m_usesDiagramUseFillColor = (bool)usesDiagramUseFillColor.toInt();
+
     setSize(w.toInt(), h.toInt());
     setX(x.toInt());
     setY(y.toInt());
-    if (fillColor != "none") {
-        m_FillColor = QColor(fillColor);
-    }
     QString isinstance = qElement.attribute("isinstance", "0");
     m_isInstance = (bool)isinstance.toInt();
     m_instanceName = qElement.attribute("instancename", "");
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/umlwidget.h #1273376:1273377
@@ -58,13 +58,6 @@
 
     void setUseFillColor(bool fc);
 
-    /**
-     * Read property of bool m_useFillColor.
-     */
-    bool useFillColor() const {
-        return m_useFillColor;
-    }
-
     void setTextColor(const QColor &color);
     void setTextColorcmd(const QColor &color);
 
@@ -73,7 +66,6 @@
 
     void setLineWidth(uint width);
 
-    QColor fillColor() const;
     void setFillColor(const QColor &color);
     void setFillColorcmd(const QColor &color);
 
@@ -190,34 +182,6 @@
     }
 
     /**
-     * Returns m_usesDiagramFillColor
-     */
-    bool getUsesDiagramFillColor() const {
-        return m_usesDiagramFillColor;
-    }
-
-    /**
-     * Returns m_usesDiagramUseFillColor
-     */
-    bool getUsesDiagramUseFillColor() const {
-        return m_usesDiagramUseFillColor;
-    }
-
-    /**
-     * Sets m_usesDiagramFillColor
-     */
-    void setUsesDiagramFillColor(bool usesDiagramFillColor) {
-        m_usesDiagramFillColor = usesDiagramFillColor;
-    }
-
-    /**
-     * Sets m_usesDiagramUseFillColor
-     */
-    void setUsesDiagramUseFillColor(bool usesDiagramUseFillColor) {
-        m_usesDiagramUseFillColor = usesDiagramUseFillColor;
-    }
-
-    /**
      * Write property of bool m_isInstance
      */
     void setIsInstance(bool isInstance) {
@@ -320,23 +284,6 @@
     ///////////////// Data Loaded/Saved /////////////////////////////////
 
     /**
-     * This flag indicates if the UMLWidget uses the Diagram FillColor
-     */
-    bool m_useFillColor;
-
-    /**
-     *  true by default, false if the colors have
-     *  been explicitly set for this widget
-     */
-    bool m_usesDiagramFillColor;
-    bool m_usesDiagramUseFillColor;
-
-    /**
-     * Color of the background of the widget
-     */
-    QColor m_FillColor;
-
-    /**
      * A list of AssociationWidgets between the UMLWidget and other UMLWidgets in the diagram
      */
     AssociationWidgetList m_Assocs;
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/widgetbase.cpp #1273376:1273377
@@ -175,7 +175,9 @@
 }
 
 /**
- * Read property of m_textColor.
+ * Returns text color
+ *
+ * @return currently used text color
  */
 QColor WidgetBase::textColor() const
 {
@@ -194,7 +196,9 @@
 }
 
 /**
- * Read property of m_LineColor.
+ * Returns line color
+ *
+ * @return currently used line color
  */
 QColor WidgetBase::lineColor() const
 {
@@ -204,7 +208,7 @@
 /**
  * Sets the line color
  *
- * @param color the new line color
+ * @param color   The new line color
  */
 void WidgetBase::setLineColor(const QColor &color)
 {
@@ -213,8 +217,31 @@
 }
 
 /**
- * Read property of m_LineWidth.
+ * Returns fill color
+ *
+ * @return currently used fill color
  */
+QColor WidgetBase::fillColor() const
+{
+    return m_FillColor;
+}
+
+/**
+ * Sets the fill color
+ *
+ * @param colour   The new fill color
+ */
+void WidgetBase::setFillColor(const QColor &color)
+{
+    m_FillColor = color;
+    m_usesDiagramFillColor = false;
+}
+
+/**
+ * Returns line width
+ *
+ * @return currently used line with
+ */
 uint WidgetBase::lineWidth() const
 {
     return m_LineWidth;
@@ -223,7 +250,7 @@
 /**
  * Sets the line width
  *
- * @param width the new line width
+ * @param width  The new line width
  */
 void WidgetBase::setLineWidth(uint width)
 {
@@ -231,22 +258,55 @@
     m_usesDiagramLineWidth = false;
 }
 
+/**
+ * Return state of fill color usage
+ *
+ * @return True if fill color is used
+ */
+bool WidgetBase::useFillColor()
+{
+    return m_useFillColor;
+}
+
+/**
+ * Set state if fill color is used
+ *
+ * @param state  The state to set
+ */
+void WidgetBase::setUseFillColor(bool state)
+{
+    m_useFillColor = state;
+    m_usesDiagramUseFillColor = false;
+}
+
+/**
+ * Returns state if diagram text color is used
+ *
+ * @return True means diagram text color is used
+ */
 bool WidgetBase::usesDiagramTextColor() const
 {
     return m_usesDiagramTextColor;
 }
 
-void WidgetBase::setUsesDiagramTextColor(bool status)
+/**
+ * Set state if diagram text color is used
+ *
+ * @param state  The state to set
+ */
+void WidgetBase::setUsesDiagramTextColor(bool state)
 {
-    if (m_usesDiagramTextColor == status) {
+    if (m_usesDiagramTextColor == state) {
         return;
     }
-    m_usesDiagramTextColor = status;
+    m_usesDiagramTextColor = state;
     setTextColor(m_textColor);
 }
 
 /**
- * Returns m_usesDiagramLineColor
+ * Returns state of diagram line color is used
+ *
+ * @return True means diagrams line color is used
  */
 bool WidgetBase::usesDiagramLineColor() const
 {
@@ -254,26 +314,73 @@
 }
 
 /**
- * Sets m_usesDiagramLineColor
+ * Set state of diagram line color is used
+ *
+ * @param state  The state to set
  */
-void WidgetBase::setUsesDiagramLineColor(bool usesDiagramLineColor)
+void WidgetBase::setUsesDiagramLineColor(bool state)
 {
-    m_usesDiagramLineColor = usesDiagramLineColor;
+    m_usesDiagramLineColor = state;
 }
 
 /**
- * Returns m_usesDiagramLineWidth
+ * Returns state of diagram fill color is used
+ *
+ * @return True means diagrams fill color is used
  */
-bool WidgetBase::usesDiagramLineWidth() const {
+bool WidgetBase::usesDiagramFillColor() const
+{
+    return m_usesDiagramFillColor;
+}
+
+/**
+ * Set state if diagram fill color is used
+ *
+ * @param state  The state to set
+ */
+void WidgetBase::setUsesDiagramFillColor(bool state)
+{
+    m_usesDiagramFillColor = state;
+}
+
+/**
+ * Returns state of diagram use fill color is used
+ *
+ * @return True means diagrams fill color is used
+*/
+bool WidgetBase::usesDiagramUseFillColor() const
+{
+    return m_usesDiagramUseFillColor;
+}
+
+/**
+ * Set state of diagram use fill color is used
+ *
+ * @param state  The state to set
+ */
+void WidgetBase::setUsesDiagramUseFillColor(bool state)
+{
+    m_usesDiagramUseFillColor = state;
+}
+
+/**
+ * Returns state of diagram line width is used
+ *
+ * @return True means diagrams line width is used
+ */
+bool WidgetBase::usesDiagramLineWidth() const
+{
     return m_usesDiagramLineWidth;
 }
 
 /**
- * Sets m_usesDiagramLineWidth
+ * Set state of diagram line width is used
+ *
+ * @param state  The state to set
  */
-void WidgetBase::setUsesDiagramLineWidth(bool usesDiagramLineWidth)
+void WidgetBase::setUsesDiagramLineWidth(bool state)
 {
-    m_usesDiagramLineWidth = usesDiagramLineWidth;
+    m_usesDiagramLineWidth = state;
 }
 
 void WidgetBase::saveToXMI( QDomDocument & /*qDoc*/, QDomElement & qElement )
@@ -290,7 +397,16 @@
     } else {
         qElement.setAttribute( "linewidth", m_LineWidth );
     }
+    qElement.setAttribute("usefillcolor", m_useFillColor);
+    // for consistency the following attributes now use american spelling for "color"
+    qElement.setAttribute("usesdiagramfillcolor", m_usesDiagramFillColor);
+    qElement.setAttribute("usesdiagramusefillcolor", m_usesDiagramUseFillColor);
+    if (m_usesDiagramFillColor) {
+        qElement.setAttribute("fillcolor", "none");
+    } else {
+        qElement.setAttribute("fillcolor", m_FillColor.name());
 }
+}
 
 bool WidgetBase::loadFromXMI( QDomElement & qElement )
 {
@@ -322,6 +438,27 @@
         setTextColor( m_scene->textColor() );
         m_usesDiagramTextColor = true;
     }
+    QString usefillcolor = qElement.attribute("usefillcolor", "1");
+    m_useFillColor = (bool)usefillcolor.toInt();
+    /*
+      For the next three *color attributes, there was a mixup of american and english spelling for "color".
+      So first we need to keep backward compatibility and try to retrieve the *colour attribute.
+      Next we overwrite this value if we find a *color, otherwise the former *colour is kept.
+    */
+    QString fillColor = qElement.attribute("fillcolour", "none");
+    fillColor = qElement.attribute("fillcolor", fillColor);
+    if (fillColor != "none") {
+        m_FillColor = QColor(fillColor);
+    }
+
+    QString usesDiagramFillColor = qElement.attribute("usesdiagramfillcolour", "1");
+    usesDiagramFillColor = qElement.attribute("usesdiagramfillcolor", usesDiagramFillColor);
+    m_usesDiagramFillColor = (bool)usesDiagramFillColor.toInt();
+
+    QString usesDiagramUseFillColor = qElement.attribute("usesdiagramusefillcolour", "1");
+    usesDiagramUseFillColor = qElement.attribute("usesdiagramusefillcolor", usesDiagramUseFillColor);
+    m_usesDiagramUseFillColor = (bool)usesDiagramUseFillColor.toInt();
+
     return true;
 }
 
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/widgetbase.h #1273376:1273377
@@ -94,17 +94,29 @@
     QColor lineColor() const;
     void setLineColor(const QColor &color);
 
+    QColor fillColor() const;
+    void setFillColor(const QColor &color);
+
     uint lineWidth() const;
     void setLineWidth(uint width);
 
+    bool useFillColor();
+    void setUseFillColor(bool state);
+
     bool usesDiagramTextColor() const;
-    void setUsesDiagramTextColor(bool usesDiagramTextColor);
+    void setUsesDiagramTextColor(bool state);
 
     bool usesDiagramLineColor() const;
-    void setUsesDiagramLineColor(bool usesDiagramLineColor);
+    void setUsesDiagramLineColor(bool state);
 
+    bool usesDiagramFillColor() const;
+    void setUsesDiagramFillColor(bool state);
+
+    bool usesDiagramUseFillColor() const;
+    void setUsesDiagramUseFillColor(bool state);
+
     bool usesDiagramLineWidth() const;
-    void setUsesDiagramLineWidth(bool usesDiagramLineWidth);
+    void setUsesDiagramLineWidth(bool state);
 
     virtual bool loadFromXMI( QDomElement & qElement );
     virtual void saveToXMI( QDomDocument & qDoc, QDomElement & qElement );
@@ -137,17 +149,29 @@
     QColor m_LineColor;
 
     /**
+     * Color of the background of the widget
+     */
+    QColor m_FillColor;
+
+    /**
      * Width of the lines of the widget. Is saved to XMI.
      */
     uint m_LineWidth;
 
     /**
+     * This flag indicates if the UMLWidget uses the Diagram FillColour
+     */
+    bool m_useFillColor;
+
+    /**
      * true by default, false if the colors have
      * been explicitly set for this widget.
      * These are saved to XMI.
      */
     bool m_usesDiagramTextColor;
     bool m_usesDiagramLineColor;
+    bool m_usesDiagramFillColor;
+    bool m_usesDiagramUseFillColor;
     bool m_usesDiagramLineWidth;
 
 




More information about the umbrello-devel mailing list