[Kst] branches/work/kst/portto4/kst/src/libkstapp

Adam Treat treat at kde.org
Thu Jun 7 21:20:58 CEST 2007


SVN commit 672653 by treat:

* Resizing of items via mouse grab now works.
Need to figure out how were' going to do this
for lines and labels though.


 M  +55 -0     viewitem.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #672652:672653
@@ -109,6 +109,61 @@
 
 
 void ViewItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
+
+  if (scene()->mouseGrabberItem() != this)
+    return;
+
+  //We have the mouse grab...
+  switch(cursor().shape()) {
+  case Qt::SizeFDiagCursor:
+    {
+      QRectF transformed = rect();
+      if (event->pos().x() < rect().center().x()) {
+        transformed.setTopLeft(event->pos());
+      } else {
+        transformed.setBottomRight(event->pos());
+      }
+      setRect(transformed);
+      return;
+    }
+  case Qt::SizeBDiagCursor:
+    {
+      QRectF transformed = rect();
+      if (event->pos().x() < rect().center().x()) {
+        transformed.setBottomLeft(event->pos());
+      } else {
+        transformed.setTopRight(event->pos());
+      }
+      setRect(transformed);
+      return;
+    }
+  case Qt::SizeVerCursor:
+    {
+      QRectF transformed = rect();
+      if (event->pos().y() < rect().center().y()) {
+        transformed.setTop(event->pos().y());
+      } else {
+        transformed.setBottom(event->pos().y());
+      }
+      setRect(transformed);
+      return;
+    }
+  case Qt::SizeHorCursor:
+    {
+      QRectF transformed = rect();
+      if (event->pos().x() < rect().center().x()) {
+        transformed.setLeft(event->pos().x());
+      } else {
+        transformed.setRight(event->pos().x());
+      }
+      setRect(transformed);
+      return;
+    }
+  case Qt::ArrowCursor:
+  default:
+    break;
+  }
+
   QGraphicsRectItem::mouseMoveEvent(event);
 }
 


More information about the Kst mailing list