From: Joel Holdsworth Date: Tue, 23 Dec 2014 19:24:47 +0000 (+0000) Subject: ViewWidget: Moved in drag_items X-Git-Tag: pulseview-0.3.0~303 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1dffa582704bb6acb144a3e89bd6eb0e2ccf4f25;p=pulseview.git ViewWidget: Moved in drag_items --- diff --git a/pv/view/header.cpp b/pv/view/header.cpp index cb6f0658..e3ad9d38 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -92,23 +92,6 @@ shared_ptr Header::get_mouse_over_item(const QPoint &pt) return shared_ptr(); } -void Header::drag_items(const QPoint &delta) -{ - RowItemOwner *item_owner = nullptr; - for (std::shared_ptr r : view_) - if (r->dragging()) { - item_owner = r->owner(); - r->drag_by(delta); - - // Ensure the trace is selected - r->select(); - } - - item_owner->restack_items(); - for (const auto &r : *item_owner) - r->animate_to_layout_v_offset(); -} - void Header::paintEvent(QPaintEvent*) { // The trace labels are not drawn with the arrows exactly on the diff --git a/pv/view/header.hpp b/pv/view/header.hpp index 9bca88ce..ac8f792f 100644 --- a/pv/view/header.hpp +++ b/pv/view/header.hpp @@ -74,12 +74,6 @@ private: std::shared_ptr get_mouse_over_item( const QPoint &pt); - /** - * Drag the dragging items by the delta offset. - * @param delta the drag offset in pixels. - */ - void drag_items(const QPoint &delta); - private: void paintEvent(QPaintEvent *event); diff --git a/pv/view/marginwidget.hpp b/pv/view/marginwidget.hpp index 2178003f..029d68e5 100644 --- a/pv/view/marginwidget.hpp +++ b/pv/view/marginwidget.hpp @@ -67,12 +67,6 @@ protected: */ void show_popup(const std::shared_ptr &item); - /** - * Drag the dragging items by the delta offset. - * @param delta the drag offset in pixels. - */ - virtual void drag_items(const QPoint &delta) = 0; - /** * Handles left mouse button press events. * @param event the mouse event that triggered this handler. diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index 0149155d..bd106b97 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -83,14 +83,6 @@ shared_ptr Ruler::get_mouse_over_item(const QPoint &pt) return nullptr; } -void Ruler::drag_items(const QPoint &delta) -{ - const vector< shared_ptr > items(view_.time_items()); - for (auto &i : items) - if (i->dragging()) - i->drag_by(delta); -} - void Ruler::paintEvent(QPaintEvent*) { const int ValueMargin = 3; diff --git a/pv/view/ruler.hpp b/pv/view/ruler.hpp index c93586e1..a2b80ab9 100644 --- a/pv/view/ruler.hpp +++ b/pv/view/ruler.hpp @@ -73,12 +73,6 @@ private: std::shared_ptr get_mouse_over_item( const QPoint &pt); - /** - * Drag the dragging items by the delta offset. - * @param delta the drag offset in pixels. - */ - void drag_items(const QPoint &delta); - private: void paintEvent(QPaintEvent *event); diff --git a/pv/view/viewwidget.cpp b/pv/view/viewwidget.cpp index 9408a2de..9c4c56ff 100644 --- a/pv/view/viewwidget.cpp +++ b/pv/view/viewwidget.cpp @@ -70,5 +70,31 @@ bool ViewWidget::accept_drag() const return false; } +void ViewWidget::drag_items(const QPoint &delta) +{ + // Drag the row items + RowItemOwner *item_owner = nullptr; + for (std::shared_ptr r : view_) + if (r->dragging()) { + item_owner = r->owner(); + r->drag_by(delta); + + // Ensure the trace is selected + r->select(); + } + + if (item_owner) { + item_owner->restack_items(); + for (const auto &r : *item_owner) + r->animate_to_layout_v_offset(); + } + + // Drag the time items + const vector< shared_ptr > items(view_.time_items()); + for (auto &i : items) + if (i->dragging()) + i->drag_by(delta); +} + } // namespace view } // namespace pv diff --git a/pv/view/viewwidget.hpp b/pv/view/viewwidget.hpp index 1989fe13..3b22441a 100644 --- a/pv/view/viewwidget.hpp +++ b/pv/view/viewwidget.hpp @@ -41,6 +41,12 @@ protected: */ bool accept_drag() const; + /** + * Drag the dragging items by the delta offset. + * @param delta the drag offset in pixels. + */ + void drag_items(const QPoint &delta); + protected: pv::view::View &view_; };