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

Peter Kümmel syntheticpp at gmx.net
Thu Sep 2 20:13:00 CEST 2010


SVN commit 1171103 by kuemmel:

d&d only in layout mode.
Currently plots are only movable within the view.
To make the plot movable in the new view, d&d within the view must be implemented.

 M  +1 -0      plotitem.cpp  
 M  +19 -17    viewitem.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1171102:1171103
@@ -2628,6 +2628,7 @@
   if (event->button() == Qt::LeftButton) {
     if (checkBox().contains(event->pos())) {
       setTiedZoom(!isTiedZoom(), !isTiedZoom());
+      ViewItem::mousePressEvent(event);
     } else if (parentView()->viewMode() == View::Data) {
       edit();
     } else {
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #1171102:1171103
@@ -947,9 +947,13 @@
 
 
 void ViewItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
+  if (parentView()->viewMode() == View::Data) {
+    event->ignore();
+    return;
+  }
 
-  if (event->buttons() & Qt::LeftButton && parentView()->viewMode() == View::Data &&
-      (event->pos() - dragStartPosition).toPoint().manhattanLength() > QApplication::startDragDistance()) {
+  if (!dragStartPosition.isNull() && event->buttons() & Qt::LeftButton)
+    if ((event->pos() - dragStartPosition).toPoint().manhattanLength() > QApplication::startDragDistance()) {
 
     // UNDO tied zoom settings done in PlotItem::mousePressEvent
     setTiedZoom(false, false);
@@ -967,20 +971,15 @@
     pixmap.setMask(pixmap.createHeuristicMask());
     drag->setPixmap(pixmap.scaled(pixmap.size()/1.5));
 
-    
     Qt::DropActions dact = Qt::MoveAction;
     Qt::DropAction dropAction = drag->exec(dact);
     if (dropAction == Qt::MoveAction) {
-      _autoLayoutAction->trigger();
+    } else {
+      // we are starting drag$drop
+      return;
     }
   }
 
-
-  if (parentView()->viewMode() == View::Data) {
-    event->ignore();
-    return;
-  }
-
   if (parentView()->mouseMode() == View::Default) {
     if (gripMode() == ViewItem::Move || activeGrip() == NoGrip) {
       parentView()->setMouseMode(View::Move);
@@ -1641,19 +1640,20 @@
 
 
 void ViewItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
+  if (parentView()->viewMode() == View::Data) {
+    event->ignore();
+    return;
+  }
 
-  QPointF p = event->pos();
-  if (checkBox().contains(p) && parentView()->viewMode() == View::Data) {
+  const QPointF p = event->pos();
+
+  dragStartPosition = QPointF(0, 0);
+  if (checkBox().contains(p)) {
     if (event->buttons() & Qt::LeftButton) {
        dragStartPosition = p;
     }
   }
 
-  if (parentView()->viewMode() == View::Data) {
-    event->ignore();
-    return;
-  }
-  
   if (isAllowed(TopLeftGrip) && topLeftGrip().contains(p)) {
     setActiveGrip(TopLeftGrip);
   } else if (isAllowed(TopRightGrip) && topRightGrip().contains(p)) {
@@ -1725,6 +1725,8 @@
     return;
   }
 
+  dragStartPosition = QPointF(0, 0);
+
   if (parentView()->mouseMode() != View::Default) {
     parentView()->setMouseMode(View::Default);
     parentView()->undoStack()->endMacro();


More information about the Kst mailing list