From: Joel Holdsworth Date: Mon, 7 Sep 2015 00:39:29 +0000 (-0600) Subject: ViewWidget: Added drag-handling support for non-TraceTreeItems X-Git-Tag: pulseview-0.3.0~70 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=453b6d63444bf7fb03242761653fd18e9cde7443;p=pulseview.git ViewWidget: Added drag-handling support for non-TraceTreeItems --- diff --git a/pv/view/viewwidget.cpp b/pv/view/viewwidget.cpp index 38732046..2a97eefc 100644 --- a/pv/view/viewwidget.cpp +++ b/pv/view/viewwidget.cpp @@ -107,23 +107,30 @@ void ViewWidget::drag_items(const QPoint &delta) bool item_dragged = false; // Drag the row items - TraceTreeItemOwner *item_owner = nullptr; - const vector< shared_ptr > trace_tree_items( - view_.list_by_type()); - for (shared_ptr r : trace_tree_items) + const vector< shared_ptr > row_items( + view_.list_by_type()); + for (shared_ptr r : row_items) if (r->dragging()) { - item_owner = r->owner(); r->drag_by(delta); // Ensure the trace is selected r->select(); + + item_dragged = true; } + // If an item is being dragged, update the stacking + TraceTreeItemOwner *item_owner = nullptr; + const vector< shared_ptr > trace_tree_items( + view_.list_by_type()); + for (shared_ptr i : trace_tree_items) + if (i->dragging()) + item_owner = i->owner(); + if (item_owner) { - item_dragged = true; item_owner->restack_items(); - for (shared_ptr r : trace_tree_items) - r->animate_to_layout_v_offset(); + for (shared_ptr i : trace_tree_items) + i->animate_to_layout_v_offset(); } // Drag the time items