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

Ralf Habacker ralf.habacker at gmail.com
Tue Dec 13 14:09:50 UTC 2011


SVN commit 1268460 by habacker:

fixed method documentation locations and ordering according to class definition

 MM +100 -74   entitywidget.cpp  
 MM +4 -35     entitywidget.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/entitywidget.cpp #1268459:1268460
@@ -1,4 +1,5 @@
 /***************************************************************************
+ *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
@@ -11,30 +12,43 @@
 // own header
 #include "entitywidget.h"
 
-// qt/kde includes
-#include <QtGui/QPainter>
-
 // app includes
+#include "classifier.h"
+#include "classifierlistitem.h"
 #include "debug_utils.h"
 #include "entity.h"
 #include "entityattribute.h"
-#include "uniqueconstraint.h"
 #include "foreignkeyconstraint.h"
-#include "classifier.h"
+#include "listpopupmenu.h"
+#include "object_factory.h"
+#include "uml.h"
 #include "umlclassifierlistitemlist.h"
-#include "classifierlistitem.h"
+#include "umldoc.h"
 #include "umlview.h"
-#include "umldoc.h"
-#include "uml.h"
-#include "listpopupmenu.h"
-#include "object_factory.h"
+#include "uniqueconstraint.h"
 
+/**
+ * Constructs an EntityWidget.
+ *
+ * @param view              The parent of this EntityWidget.
+ * @param o         The UMLObject this will be representing.
+ */
 EntityWidget::EntityWidget(UMLView* view, UMLObject* o)
   : UMLWidget(view, o)
 {
     init();
 }
 
+/**
+ * Standard deconstructor.
+ */
+EntityWidget::~EntityWidget()
+{
+}
+
+/**
+ * Initializes key variables of the class.
+ */
 void EntityWidget::init()
 {
     UMLWidget::setBaseType(WidgetBase::wt_Entity);
@@ -49,10 +63,9 @@
         updateComponentSize();
 }
 
-EntityWidget::~EntityWidget()
-{
-}
-
+/**
+ * Draws the entity as a rectangle with a box underneith with a list of literals
+ */
 void EntityWidget::draw(QPainter& p, int offsetX, int offsetY)
 {
     setPenFromSettings(p);
@@ -128,62 +141,33 @@
     }
 }
 
-QSize EntityWidget::calculateSize()
+/**
+ * Loads from an "entitywidget" XMI element.
+ */
+bool EntityWidget::loadFromXMI( QDomElement & qElement )
 {
-    if (!m_pObject) {
-        return UMLWidget::calculateSize();
+    if ( !UMLWidget::loadFromXMI(qElement) ) {
+        return false;
     }
-
-    int width, height;
-    QFont font = UMLWidget::font();
-    font.setItalic(false);
-    font.setUnderline(false);
-    font.setBold(false);
-    const QFontMetrics fm(font);
-
-    const int fontHeight = fm.lineSpacing();
-
-    int lines = 1;//always have one line - for name
-    if ( !m_pObject->stereotype().isEmpty() ) {
-        lines++;
+    return true;
     }
 
-    const int numberOfEntityAttributes = ((UMLEntity*)m_pObject)->entityAttributes();
-
-    height = width = 0;
-    //set the height of the entity
-
-    lines += numberOfEntityAttributes;
-    if (numberOfEntityAttributes == 0) {
-        height += fontHeight / 2; //no entity literals, so just add a bit of space
+/**
+ * Saves to the "entitywidget" XMI element.
+ */
+void EntityWidget::saveToXMI( QDomDocument& qDoc, QDomElement& qElement )
+{
+    QDomElement conceptElement = qDoc.createElement("entitywidget");
+    UMLWidget::saveToXMI(qDoc, conceptElement);
+    qElement.appendChild(conceptElement);
     }
 
-    height += lines * fontHeight;
-
-    //now set the width of the concept
-    //set width to name to start with
-    // FIXME spaces to get round beastie with font width,
-    // investigate UMLWidget::getFontMetrics()
-    width = getFontMetrics(FT_BOLD_ITALIC).boundingRect(' ' + name() + ' ').width();
-
-    const int w = getFontMetrics(FT_BOLD).boundingRect(m_pObject->stereotype(true)).width();
-
-    width = w > width?w:width;
-
-    UMLClassifier* classifier = (UMLClassifier*)m_pObject;
-    UMLClassifierListItemList list = classifier->getFilteredList(UMLObject::ot_EntityAttribute);
-    UMLClassifierListItem* listItem = 0;
-    foreach (listItem , list ) {
-        int w = fm.width( listItem->name() );
-        width = w > width?w:width;
-    }
-
-    //allow for width margin
-    width += ENTITY_MARGIN * 2;
-
-    return QSize(width, height);
-}
-
+/**
+ * Will be called when a menu selection has been made from the
+ * popup menu.
+ *
+ * @param action       The action that has been selected.
+ */
 void EntityWidget::slotMenuSelection(QAction* action)
 {
     ListPopupMenu::MenuType sel = m_pMenu->getMenuType(action);
@@ -227,21 +211,63 @@
     default:
         UMLWidget::slotMenuSelection(action);
     }
-
 }
 
-void EntityWidget::saveToXMI( QDomDocument& qDoc, QDomElement& qElement )
+/**
+ * Overrides method from UMLWidget.
+ */
+QSize EntityWidget::calculateSize()
 {
-    QDomElement conceptElement = qDoc.createElement("entitywidget");
-    UMLWidget::saveToXMI(qDoc, conceptElement);
-    qElement.appendChild(conceptElement);
+    if (!m_pObject) {
+        return UMLWidget::calculateSize();
 }
 
-bool EntityWidget::loadFromXMI( QDomElement & qElement )
-{
-    if ( !UMLWidget::loadFromXMI(qElement) ) {
-        return false;
+    int width, height;
+    QFont font = UMLWidget::font();
+    font.setItalic(false);
+    font.setUnderline(false);
+    font.setBold(false);
+    const QFontMetrics fm(font);
+
+    const int fontHeight = fm.lineSpacing();
+
+    int lines = 1;//always have one line - for name
+    if ( !m_pObject->stereotype().isEmpty() ) {
+        lines++;
     }
-    return true;
+
+    const int numberOfEntityAttributes = ((UMLEntity*)m_pObject)->entityAttributes();
+
+    height = width = 0;
+    //set the height of the entity
+
+    lines += numberOfEntityAttributes;
+    if (numberOfEntityAttributes == 0) {
+        height += fontHeight / 2; //no entity literals, so just add a bit of space
 }
 
+    height += lines * fontHeight;
+
+    //now set the width of the concept
+    //set width to name to start with
+    // FIXME spaces to get round beastie with font width,
+    // investigate UMLWidget::getFontMetrics()
+    width = getFontMetrics(FT_BOLD_ITALIC).boundingRect(' ' + name() + ' ').width();
+
+    const int w = getFontMetrics(FT_BOLD).boundingRect(m_pObject->stereotype(true)).width();
+
+    width = w > width?w:width;
+
+    UMLClassifier* classifier = (UMLClassifier*)m_pObject;
+    UMLClassifierListItemList list = classifier->getFilteredList(UMLObject::ot_EntityAttribute);
+    UMLClassifierListItem* listItem = 0;
+    foreach (listItem , list ) {
+        int w = fm.width( listItem->name() );
+        width = w > width?w:width;
+    }
+
+    //allow for width margin
+    width += ENTITY_MARGIN * 2;
+
+    return QSize(width, height);
+}
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/entitywidget.h #1268459:1268460
@@ -1,4 +1,5 @@
 /***************************************************************************
+ *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
@@ -29,54 +30,22 @@
 class EntityWidget : public UMLWidget
 {
 public:
-
-    /**
-     * Constructs an EntityWidget.
-     *
-     * @param view              The parent of this EntityWidget.
-     * @param o         The UMLObject this will be representing.
-     */
     EntityWidget(UMLView* view, UMLObject* o);
-
-    /**
-     * Standard deconstructor.
-     */
     ~EntityWidget();
 
-    /**
-     * Initializes key variables of the class.
-     */
     void init();
 
-    /**
-     * Draws the entity as a rectangle with a box underneith with a list of literals
-     */
     void draw(QPainter& p, int offsetX, int offsetY);
 
-    /**
-     * Saves to the "entitywidget" XMI element.
-     */
+    bool loadFromXMI(QDomElement& qElement);
     void saveToXMI(QDomDocument& qDoc, QDomElement& qElement);
 
-    /**
-     * Loads from an "entitywidget" XMI element.
-     */
-    bool loadFromXMI(QDomElement& qElement);
+public slots:
+    void slotMenuSelection(QAction* action);
 
 protected:
-    /**
-     * Overrides method from UMLWidget.
-     */
     QSize calculateSize();
 
-public slots:
-    /**
-     * Will be called when a menu selection has been made from the
-     * popup menu.
-     *
-     * @param action       The action that has been selected.
-     */
-    void slotMenuSelection(QAction* action);
 };
 
 #endif




More information about the umbrello-devel mailing list