]> sigrok.org Git - pulseview.git/commitdiff
Header: Only allow dragging if all traces share a common ancestor
authorJoel Holdsworth <redacted>
Sat, 1 Nov 2014 10:56:42 +0000 (10:56 +0000)
committerJoel Holdsworth <redacted>
Wed, 19 Nov 2014 10:23:02 +0000 (10:23 +0000)
pv/view/header.cpp

index ffe05a1c674335f92479e85997d69ec0347cc46b..202ae101f76f6ada1fd9d44573cd89b06bafab2b 100644 (file)
@@ -214,29 +214,40 @@ void Header::mouseMoveEvent(QMouseEvent *event)
                QApplication::startDragDistance())
                return;
 
-       // Move the signals if we are dragging
-       if (!_drag_row_items.empty())
-       {
-               _dragging = true;
+       // Check the list of dragging items is not empty
+       if (_drag_row_items.empty())
+               return;
 
-               const int delta = event->pos().y() - _mouse_down_point.y();
+       // Check all the drag items share a common owner
+       const shared_ptr<RowItem> first_row_item(
+               _drag_row_items.front().first);
+       for (const auto &r : _drag_row_items) {
+               const shared_ptr<RowItem> row_item(r.first);
+               assert(row_item);
 
-               for (auto i = _drag_row_items.begin();
-                       i != _drag_row_items.end(); i++) {
-                       const std::shared_ptr<RowItem> row_item((*i).first);
-                       if (row_item) {
-                               const int y = (*i).second + delta;
-                               row_item->set_v_offset(y);
+               if (row_item->owner() != first_row_item->owner())
+                       return;
+       }
 
-                               // Ensure the trace is selected
-                               row_item->select();
-                       }
-                       
-               }
+       // Do the drag
+       _dragging = true;
 
-               signals_moved();
+       const int delta = event->pos().y() - _mouse_down_point.y();
+
+       for (auto i = _drag_row_items.begin();
+               i != _drag_row_items.end(); i++) {
+               const std::shared_ptr<RowItem> row_item((*i).first);
+               if (row_item) {
+                       const int y = (*i).second + delta;
+                       row_item->set_v_offset(y);
+
+                       // Ensure the trace is selected
+                       row_item->select();
+               }
        }
 
+       signals_moved();
+
        update();
 }