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

Andi Fischer andi.fischer at hispeed.ch
Sat May 12 14:22:48 UTC 2012


SVN commit 1294391 by fischer:

Differences to gsoc-branch reduced.

 M  +21 -45    umlscene.cpp  
 M  +2 -16     umlscene.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/umlscene.cpp #1294390:1294391
@@ -1423,8 +1423,7 @@
 void UMLScene::selectionSetLineColor(const QColor &color)
 {
     UMLApp::app()->beginMacro(i18n("Change Line Color"));
-    UMLWidget * temp = 0;
-    foreach(temp,  m_selectedList) {
+    foreach(UMLWidget *temp,  m_selectedList) {
         temp->setLineColor(color);
         temp->setUsesDiagramLineColor(false);
     }
@@ -1532,7 +1531,7 @@
 
     foreach(UMLWidget* widget, m_selectedList) {
         if (widget->baseType() == WidgetBase::wt_Text &&
-                ((FloatingTextWidget *)widget)->textRole() != Uml::TextRole::Floating) {
+                static_cast<FloatingTextWidget*>(widget)->textRole() != Uml::TextRole::Floating) {
             m_selectedList.removeAt(m_selectedList.indexOf(widget));
             widget->hide();
 
@@ -1738,11 +1737,10 @@
 
 /**
  * Returns the PNG picture of the paste operation.
- *
  * @param rect the area of the diagram to copy
  * @param diagram the class to store PNG picture of the paste operation.
  */
-void  UMLScene::getDiagram(const QRect &rect, QPixmap &diagram)
+void  UMLScene::getDiagram(const UMLSceneRect &rect, QPixmap &diagram)
 {
     DEBUG(DBG_SRC) << "rect=" << rect << ", pixmap=" << diagram.rect();
     const int width  = rect.x() + rect.width();
@@ -1898,8 +1896,7 @@
     if (!filterText)
         return m_selectedList.count();
     int counter = 0;
-    const UMLWidget * temp = 0;
-    foreach(temp, m_selectedList) {
+    foreach(UMLWidget* temp, m_selectedList) {
         if (temp->baseType() == WidgetBase::wt_Text) {
             const FloatingTextWidget *ft = static_cast<const FloatingTextWidget*>(temp);
             if (ft->textRole() == TextRole::Floating)
@@ -2616,6 +2613,7 @@
                            << "of type " << assocType;
             continue;
         }
+
         // Create the AssociationWidget.
         assocwidget = AssociationWidget::create(this);
         assocwidget->setWidgetForRole(widgetA, A);
@@ -2991,12 +2989,18 @@
     foreach(AssociationWidget *a , m_AssociationList) {
         if (! a->isSelected())
             continue;
-        const FloatingTextWidget* multiA = const_cast<FloatingTextWidget*>(a->multiplicityWidget(A));
-        const FloatingTextWidget* multiB = const_cast<FloatingTextWidget*>(a->multiplicityWidget(B));
-        const FloatingTextWidget* roleA = const_cast<FloatingTextWidget*>(a->roleWidget(A));
-        const FloatingTextWidget* roleB = const_cast<FloatingTextWidget*>(a->roleWidget(B));
-        const FloatingTextWidget* changeA = const_cast<FloatingTextWidget*>(a->changeabilityWidget(A));
-        const FloatingTextWidget* changeB = const_cast<FloatingTextWidget*>(a->changeabilityWidget(B));
+        const FloatingTextWidget* multiA =
+            const_cast<FloatingTextWidget*>(a->multiplicityWidget(Uml::A));
+        const FloatingTextWidget* multiB =
+            const_cast<FloatingTextWidget*>(a->multiplicityWidget(Uml::B));
+        const FloatingTextWidget* roleA =
+            const_cast<FloatingTextWidget*>(a->roleWidget(Uml::A));
+        const FloatingTextWidget* roleB =
+            const_cast<FloatingTextWidget*>(a->roleWidget(Uml::B));
+        const FloatingTextWidget* changeA =
+            const_cast<FloatingTextWidget*>(a->changeabilityWidget(Uml::A));
+        const FloatingTextWidget* changeB =
+            const_cast<FloatingTextWidget*>(a->changeabilityWidget(Uml::B));
         findMaxBoundingRectangle(multiA, px, py, qx, qy);
         findMaxBoundingRectangle(multiB, px, py, qx, qy);
         findMaxBoundingRectangle(roleA, px, py, qx, qy);
@@ -4287,7 +4291,8 @@
                 uError() << "Cannot create widget of type " << ot;
             }
             if (widget) {
-                DEBUG(DBG_SRC) << "Widget: x=" << x << ", y=" << y << ", w=" << w << ", h=" << h;
+                DEBUG(DBG_SRC) << "Widget: x=" << x << ", y=" << y
+                               << ", w=" << w << ", h=" << h;
                 widget->setX(x);
                 widget->setY(y);
                 widget->setSize(w, h);
@@ -4455,7 +4460,7 @@
     qreal heightsSum = WidgetList_Utils::getHeightsSum(widgetList);
     qreal distance = int(((biggestY - smallestY) - heightsSum) / (widgetList.count() - 1.0) + 0.5);
 
-    sortWidgetList(widgetList, Widget_Utils::hasSmallerY);
+    qSort(widgetList.begin(), widgetList.end(), Widget_Utils::hasSmallerY);
 
     int i = 1;
     UMLWidget* widgetPrev = NULL;
@@ -4485,7 +4490,7 @@
     qreal widthsSum = WidgetList_Utils::getWidthsSum(widgetList);
     qreal distance = int(((biggestX - smallestX) - widthsSum) / (widgetList.count() - 1.0) + 0.5);
 
-    sortWidgetList(widgetList, Widget_Utils::hasSmallerX);
+    qSort(widgetList.begin(), widgetList.end(), Widget_Utils::hasSmallerX);
 
     int i = 1;
     UMLWidget* widgetPrev = NULL;
@@ -4502,37 +4507,8 @@
 
 }
 
-/**
- * Sorts the given UMLWidgetList based on the Compare function.
- * The list is cleared and all the widgets are added again in order.
- *
- * The comp function gets two const UMLWidget* params and returns
- * a boolean telling if the first widget was smaller than the second,
- * whatever the "smaller" concept is depending on the sorting to do.
- *
- * @param widgetList The list with the widgets to order.
- * @param comp The comp function to compare the widgets.
- */
-template<typename Compare>
-void UMLScene::sortWidgetList(UMLWidgetList &widgetList, Compare comp)
-{
-    QVector<UMLWidget*> widgetVector;
-
-    for (UMLWidgetList::iterator it = widgetList.begin(); it != widgetList.end(); ++it) {
-        widgetVector.push_back(*it);
-    }
-    qSort(widgetVector.begin(), widgetVector.end(), comp);
-
-    widgetList.clear();
-
-    for (QVector<UMLWidget*>::iterator it = widgetVector.begin(); it != widgetVector.end(); ++it) {
-        widgetList.append(*it);
-    }
-}
-
 QDebug operator<<(QDebug out, UMLScene *item)
 {
     out.nospace() << "UMLScene: " << static_cast<UMLScene *>(item);
     return out;
 }
-
--- trunk/KDE/kdesdk/umbrello/umbrello/umlscene.h #1294390:1294391
@@ -4,9 +4,10 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2002-2011                                               *
+ *   copyright (C) 2002-2012                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
+
 #ifndef UMLSCENE_H
 #define UMLSCENE_H
 
@@ -400,21 +401,6 @@
                                          UMLForeignKeyConstraint* fkConstraint,
                                          UMLWidget* widget);
 
-    static bool hasWidgetSmallerX(const UMLWidget* widget1, const UMLWidget* widget2);
-    static bool hasWidgetSmallerY(const UMLWidget* widget1, const UMLWidget* widget2);
-
-    int getSmallestX(const UMLWidgetList &widgetList);
-    int getSmallestY(const UMLWidgetList &widgetList);
-
-    int getBiggestX(const UMLWidgetList &widgetList);
-    int getBiggestY(const UMLWidgetList &widgetList);
-
-    int getHeightsSum(const UMLWidgetList &widgetList);
-    int getWidthsSum(const UMLWidgetList &widgetList);
-
-    template<typename Compare>
-    void sortWidgetList(UMLWidgetList &widgetList, Compare comp);
-
 public slots:
     void show();
 




More information about the umbrello-devel mailing list