From: Joel Holdsworth Date: Sat, 1 Nov 2014 10:56:42 +0000 (+0000) Subject: Header: Only allow dragging if all traces share a common ancestor X-Git-Tag: pulseview-0.3.0~461 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ee5f2a5445a6cdda7e764ab5fb1defe7fd1bbb9c;p=pulseview.git Header: Only allow dragging if all traces share a common ancestor --- diff --git a/pv/view/header.cpp b/pv/view/header.cpp index ffe05a1c..202ae101 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -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 first_row_item( + _drag_row_items.front().first); + for (const auto &r : _drag_row_items) { + const shared_ptr row_item(r.first); + assert(row_item); - for (auto i = _drag_row_items.begin(); - i != _drag_row_items.end(); i++) { - const std::shared_ptr 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 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(); }