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

Andi Fischer andi.fischer at hispeed.ch
Sat Nov 10 07:50:42 UTC 2012


SVN commit 1324705 by fischer:

UMLSceneRectItem removed and using QGraphicsRectItem directly.

 M  +1 -40     umlscene.h  
 M  +5 -5      widgets/associationline.cpp  
 M  +1 -1      widgets/associationline.h  
 M  +2 -2      widgets/associationwidget.h  
 M  +9 -9      widgets/umlwidget.cpp  
 M  +3 -3      widgets/umlwidget.h  
 M  +3 -3      widgets/widget_utils.cpp  
 M  +1 -1      widgets/widget_utils.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/umlscene.h #1324704:1324705
@@ -76,49 +76,10 @@
 typedef QGraphicsSceneDragDropEvent UMLSceneDragEnterEvent;
 typedef QGraphicsSceneDragDropEvent UMLSceneDragMoveEvent;
 
-// Qt3 migration wrapper for QGraphicsScene items 
+// migration wrapper for QGraphicsScene items
 typedef QGraphicsItem UMLSceneItem;
 typedef QList<QGraphicsItem*> UMLSceneItemList;
 
-class UMLSceneRectItem : public QGraphicsRectItem
-{
-public:
-    UMLSceneRectItem()
-    : QGraphicsRectItem(0)
-    {
-    }
-    
-    UMLSceneRectItem(int x, int y, int w, int h)
-    : QGraphicsRectItem(x, y, w, h, 0)
-    {
-    }
-
-    UMLSceneValue z() const
-    {
-        return zValue();
-    }
-
-    void setZ(UMLSceneValue z)
-    {
-        setZValue(z);
-    }
-
-    UMLSceneSize size() const
-    {
-        return rect().size();
-    }
-
-    void setSize(UMLSceneValue w, UMLSceneValue h)
-    {
-        setRect(rect().x(), rect().y(), w, h);
-    }
-
-    void setCanvas(QGraphicsScene *scene)
-    {
-        scene->addItem(this);
-    }
-};
-
 class UMLSceneEllipseItem : public QGraphicsEllipseItem
 {
 public:
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/associationline.cpp #1324704:1324705
@@ -844,7 +844,7 @@
     }
     if( (int)m_RectList.count() + 1 != lineCount )
         setupSelected();
-    UMLSceneRectItem * rect = 0;
+    QGraphicsRectItem* rect = 0;
     QGraphicsLineItem * line = 0;
     if( pointIndex == lineCount || lineCount == 1) {
         line = m_LineList.last();
@@ -852,7 +852,7 @@
         rect = m_RectList.last();
         rect->setX( p.x() );
         rect->setY( p.y() );
-        rect->setZ( 4 );
+        rect->setZValue( 4 );
         return;
     }
     line = m_LineList.at( pointIndex );
@@ -860,7 +860,7 @@
     rect = m_RectList.at( pointIndex );
     rect->setX( p.x() );
     rect->setY( p.y() );
-    rect->setZ( 4 );
+    rect->setZValue( 4 );
 }
 
 /**
@@ -874,13 +874,13 @@
 
     Q_FOREACH( line, m_LineList ) {
         UMLScenePoint sp = line->line().p1();
-        UMLSceneRectItem *rect = Widget_Utils::decoratePoint(sp);
+        QGraphicsRectItem *rect = Widget_Utils::decoratePoint(sp);
         m_RectList.append( rect );
     }
     //special case for last point
     line = m_LineList.last();
     UMLScenePoint p = line->line().p2();
-    UMLSceneRectItem *rect = Widget_Utils::decoratePoint(p);
+    QGraphicsRectItem *rect = Widget_Utils::decoratePoint(p);
     m_RectList.append( rect );
     update();
 }
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/associationline.h #1324704:1324705
@@ -38,7 +38,7 @@
 public:
     // typedefs
     typedef QList<QGraphicsLineItem*> LineList;
-    typedef QList<UMLSceneRectItem*> RectList;
+    typedef QList<QGraphicsRectItem*> RectList;
 
     AssociationLine();
     ~AssociationLine();
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/associationwidget.h #1324704:1324705
@@ -328,8 +328,8 @@
     int m_nLinePathSegmentIndex; ///< anchor for m_pAssocClassLine
     QGraphicsLineItem *m_pAssocClassLine;  ///< used for connecting assoc. class
     /// selection adornment for the endpoints of the assoc. class connecting line
-    UMLSceneRectItem *m_pAssocClassLineSel0;
-    UMLSceneRectItem *m_pAssocClassLineSel1;
+    QGraphicsRectItem *m_pAssocClassLineSel0;
+    QGraphicsRectItem *m_pAssocClassLineSel1;
 
     AssociationLine *m_associationLine;      ///< the definition points for the association line
     ClassifierWidget *m_associationClass;    ///< used if we have an assoc. class
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/umlwidget.cpp #1324704:1324705
@@ -127,7 +127,7 @@
     m_showStereotype = other.m_showStereotype;
     setX(other.x());
     setY(other.y());
-    UMLSceneRectItem::setSize(other.width(), other.height());
+    QGraphicsRectItem::setRect(rect().x(), rect().y(), other.width(), other.height());
 
     // assign volatile (non-saved) members
     m_selected = other.m_selected;
@@ -307,7 +307,7 @@
         height = maxSize.height();
 
     if (fixedAspectRatio()) {
-        UMLSceneSize size = UMLSceneRectItem::size();
+        UMLSceneSize size = QGraphicsRectItem::rect().size();
         float aspectRatio = size.width() > 0 ? (float)size.height()/size.width() : 1;
         height = width * aspectRatio;
     }
@@ -1133,19 +1133,19 @@
  * Gets the x-coordinate.
  */
 UMLSceneValue UMLWidget::x() const {
-    return UMLSceneRectItem::x();
+    return QGraphicsRectItem::x();
 }
 /**
  * Gets the y-coordinate.
  */
 UMLSceneValue UMLWidget::y() const {
-    return UMLSceneRectItem::y();
+    return QGraphicsRectItem::y();
 }
 /**
  * Gets the z-coordinate.
  */
 UMLSceneValue UMLWidget::z() const {
-    return UMLSceneRectItem::z();
+    return QGraphicsRectItem::zValue();
 }
 
 /**
@@ -1160,7 +1160,7 @@
     if (!m_ignoreSnapToGrid) {
         x = m_scene->snappedX(x);
     }
-    UMLSceneRectItem::setX(x);
+    QGraphicsRectItem::setX(x);
 }
 
 /**
@@ -1175,7 +1175,7 @@
     if (!m_ignoreSnapToGrid) {
         y = m_scene->snappedX(y);
     }
-    UMLSceneRectItem::setY(y);
+    QGraphicsRectItem::setY(y);
 }
 
 /**
@@ -1186,7 +1186,7 @@
 void UMLWidget::setZ(UMLSceneValue z)
 {
     m_origZ = this->z();
-    UMLSceneRectItem::setZ(z);
+    QGraphicsRectItem::setZValue(z);
 }
 
 /**
@@ -1293,7 +1293,7 @@
             height = (numY + 1) * m_scene->snapY();
     }
 
-    UMLSceneRectItem::setSize(width, height);
+    QGraphicsRectItem::setRect(rect().x(), rect().y(), width, height);
 }
 
 /**
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/umlwidget.h #1324704:1324705
@@ -39,7 +39,7 @@
  * @author  Paul Hensgen <phensgen at techie.com>
  * Bugs and comments to uml-devel at lists.sf.net or http://bugs.kde.org
  */
-class UMLWidget : public WidgetBase, public UMLSceneRectItem
+class UMLWidget : public WidgetBase, public QGraphicsRectItem
 {
     Q_OBJECT
 public:
@@ -137,14 +137,14 @@
      * Returns the height of widget.
      */
     int height() const {
-        return UMLSceneRectItem::rect().height();
+        return QGraphicsRectItem::rect().height();
     }
 
     /**
      * Returns the width of the widget.
      */
     UMLSceneValue width() const {
-        return UMLSceneRectItem::rect().width();
+        return QGraphicsRectItem::rect().width();
     }
 
     void setSize(UMLSceneValue width,UMLSceneValue height);
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/widget_utils.cpp #1324704:1324705
@@ -66,14 +66,14 @@
      * @param p   the base point
      * @return    the decoration point
      */
-    UMLSceneRectItem* decoratePoint(const UMLScenePoint& p)
+    QGraphicsRectItem* decoratePoint(const UMLScenePoint& p)
     {
         const int SIZE = 4;
         UMLView *currentView = UMLApp::app()->currentView();
-        UMLSceneRectItem *rect = new UMLSceneRectItem(p.x() - SIZE / 2,
+        QGraphicsRectItem *rect = new QGraphicsRectItem(p.x() - SIZE / 2,
                                                       p.y() - SIZE / 2,
                                                       SIZE, SIZE);
-        rect->setCanvas(currentView->umlScene()->canvas());
+        currentView->umlScene()->addItem(rect);
         rect->setBrush( QBrush(Qt::blue) );
         rect->setPen( QPen(Qt::blue) );
         rect->setVisible(true);
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/widget_utils.h #1324704:1324705
@@ -32,7 +32,7 @@
                           const UMLWidgetList& widgets,
                           const MessageWidgetList* messages = 0);
 
-    UMLSceneRectItem* decoratePoint(const UMLScenePoint& p);
+    QGraphicsRectItem* decoratePoint(const UMLScenePoint& p);
 
     void drawCrossInEllipse(QPainter *p, const QRectF& ellipse);
     void drawTriangledRect(QPainter *painter, const UMLSceneRect& rect, const UMLSceneSize& triSize);




More information about the umbrello-devel mailing list