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

Oliver Kellogg okellogg at users.sourceforge.net
Sat Jul 14 02:51:54 UTC 2007


SVN commit 687614 by okellogg:

mouseMoveEvent(): UMLWidget::adjustUnselectedAssocs() expects absolute coordinate.
getPosition(): New method, factored from getPositionDifference(), returns the
 absolute coordinate.
getPositionDifference(): Use getPosition().
CCBUG:147810


 M  +18 -18    umlwidgetcontroller.cpp  
 M  +12 -1     umlwidgetcontroller.h  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlwidgetcontroller.cpp #687613:687614
@@ -134,9 +134,9 @@
         setSelectionBounds();
     }
 
-    QPoint positionDifference = getPositionDifference(me);
-    int diffX = positionDifference.x();
-    int diffY = positionDifference.y();
+    QPoint position = getPosition(me);
+    int diffX = position.x() - m_widget->getX();
+    int diffY = position.y() - m_widget->getY();
 
     if ((me->state() & Qt::ShiftButton) && (me->state() & Qt::ControlButton)) {
         //Move in Y axis
@@ -166,10 +166,7 @@
         update = true;
         lastUpdate.restart();
 
-        // CHECK: UMLWidget::adjustUnselectedAssocs(x,y) appears to take absolute
-        //      values for x and y. Surprisingly, supplying diffX and diffY seems
-        //      to work all the same ?!?
-        m_widget->adjustUnselectedAssocs(diffX, diffY);
+        m_widget->adjustUnselectedAssocs(position.x(), position.y());
     }
 
     while ((widget = it.current()) != 0) {
@@ -481,12 +478,12 @@
     return biggestY;
 }
 
-QPoint UMLWidgetController::getPositionDifference(QMouseEvent* me) {
+QPoint UMLWidgetController::getPosition(QMouseEvent* me) {
     /*
-    kDebug() << "UMLWidgetController::getPositionDifference: me->x=" << me->x()
+    kDebug() << "UMLWidgetController::getPosition: me->x=" << me->x()
         << " m_widget->getX=" << m_widget->getX() << ", m_oldX=" << m_oldX
         << ", m_pressOffsetX=" << m_pressOffsetX << endl;
-    kDebug() << "UMLWidgetController::getPositionDifference: me->y=" << me->y()
+    kDebug() << "UMLWidgetController::getPosition: me->y=" << me->y()
         << " m_widget->getY=" << m_widget->getY() << ", m_oldY=" << m_oldY
         << ", m_pressOffsetY=" << m_pressOffsetY << endl;
      */
@@ -499,28 +496,31 @@
     m_oldY = newY;
 
     if (newX + (m_minSelectedX - m_widget->getX()) < 0) {
-        //kDebug() << "UMLWidgetController::getPositionDifference: got into cond.1" << endl;
+        //kDebug() << "UMLWidgetController::getPosition: got into cond.1" << endl;
         newX = m_widget->getX() - m_minSelectedX;
     }
     if (newY + (m_minSelectedY - m_widget->getY()) < 0) {
-        //kDebug() << "UMLWidgetController::getPositionDifference: got into cond.2" << endl;
+        //kDebug() << "UMLWidgetController::getPosition: got into cond.2" << endl;
         newY = m_widget->getY() - m_minSelectedY;
     }
     if (newX + (m_maxSelectedX - m_widget->getX()) > maxX) {
-        //kDebug() << "UMLWidgetController::getPositionDifference: got into cond.3" << endl;
+        //kDebug() << "UMLWidgetController::getPosition: got into cond.3" << endl;
         newX = maxX - (m_maxSelectedX - m_widget->getX());
     }
     if (newY + (m_maxSelectedY - m_widget->getY()) > maxY) {
-        //kDebug() << "UMLWidgetController::getPositionDifference: got into cond.4" << endl;
+        //kDebug() << "UMLWidgetController::getPosition: got into cond.4" << endl;
         newY = maxY - (m_maxSelectedY - m_widget->getY());
     }
-
-    newX -= m_widget->getX();
-    newY -= m_widget->getY();
-
     return QPoint(newX, newY);
 }
 
+QPoint UMLWidgetController::getPositionDifference(QMouseEvent* me) {
+    QPoint newPoint = getPosition(me);
+    const int diffX = newPoint.x() - m_widget->getX();
+    const int diffY = newPoint.y() - m_widget->getY();
+    return QPoint(diffX, diffY);
+}
+
 void UMLWidgetController::showPopupMenu(QMouseEvent *me) {
     //TODO why this condition?
     if (m_widget->m_pMenu) {
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlwidgetcontroller.h #687613:687614
@@ -362,10 +362,21 @@
     int getBiggestY(const UMLWidgetList &widgetList);
 
     /**
+     * Returns the adjusted position for the given mouse event.
+     * The adjusted position is computed using the current widget position
+     * m_widget->get{X,Y}(), the previous position m_old{X,Y}, and the
+     * mouse press offset m_pressOffset{X,Y}.
+     *
+     * @param me The QMouseEvent for which to get the adjusted position.
+     * @return A QPoint with the adjusted position.
+     */
+    QPoint getPosition(QMouseEvent *me);
+
+    /**
      * Returns a QPoint with the new X and Y position difference of the mouse event
      * respect to the position of the widget.
      *
-     * @param me The QMouseEVent to get the position to compare.
+     * @param me The QMouseEvent to get the position to compare.
      * @return A QPoint with the position difference.
      */
     QPoint getPositionDifference(QMouseEvent *me);




More information about the umbrello-devel mailing list