2 * This file is part of the PulseView project.
4 * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "rowitem.hpp"
24 #include "timeitem.hpp"
26 #include "viewwidget.hpp"
29 using std::shared_ptr;
35 ViewWidget::ViewWidget(View &parent) :
41 bool ViewWidget::accept_drag() const
43 const vector< shared_ptr<TimeItem> > items(view_.time_items());
45 const bool any_row_items_selected = any_of(view_.begin(), view_.end(),
46 [](const shared_ptr<RowItem> &r) { return r->selected(); });
48 const bool any_time_items_selected = any_of(items.begin(), items.end(),
49 [](const shared_ptr<TimeItem> &i) { return i->selected(); });
51 if (any_row_items_selected && !any_time_items_selected)
53 // Check all the drag items share a common owner
54 RowItemOwner *item_owner = nullptr;
55 for (shared_ptr<RowItem> r : view_)
58 item_owner = r->owner();
59 else if(item_owner != r->owner())
65 else if (any_time_items_selected && !any_row_items_selected)
73 void ViewWidget::drag_items(const QPoint &delta)
76 RowItemOwner *item_owner = nullptr;
77 for (std::shared_ptr<RowItem> r : view_)
79 item_owner = r->owner();
82 // Ensure the trace is selected
87 item_owner->restack_items();
88 for (const auto &r : *item_owner)
89 r->animate_to_layout_v_offset();
92 // Drag the time items
93 const vector< shared_ptr<TimeItem> > items(view_.time_items());