QSize Header::sizeHint() const
{
QRectF max_rect(-Padding, 0, Padding, 0);
- for (auto &i : view_)
+ const vector<shared_ptr<TraceTreeItem>> items(
+ view_.list_by_type<TraceTreeItem>());
+ for (auto &i : items)
if (i->enabled())
max_rect = max_rect.united(i->label_rect(QRect()));
return QSize(max_rect.width() + Padding + BaselineOffset, 0);
vector< shared_ptr<ViewItem> > Header::items()
{
- return vector< shared_ptr<ViewItem> >(view_.begin(), view_.end());
+ const vector<shared_ptr<TraceTreeItem>> items(
+ view_.list_by_type<TraceTreeItem>());
+ return vector< shared_ptr<ViewItem> >(items.begin(), items.end());
}
shared_ptr<ViewItem> Header::get_mouse_over_item(const QPoint &pt)
{
const QRect r(0, 0, width() - BaselineOffset, height());
- for (auto &i : view_)
+ const vector<shared_ptr<TraceTreeItem>> items(
+ view_.list_by_type<TraceTreeItem>());
+ for (auto &i : items)
if (i->enabled() && i->label_rect(r).contains(pt))
return i;
return shared_ptr<TraceTreeItem>();
const QRect rect(0, 0, width() - BaselineOffset, height());
vector< shared_ptr<TraceTreeItem> > items(
- view_.begin(), view_.end());
+ view_.list_by_type<TraceTreeItem>());
stable_sort(items.begin(), items.end(),
[](const shared_ptr<TraceTreeItem> &a, const shared_ptr<TraceTreeItem> &b) {
if (!menu)
menu = new QMenu(this);
- if (std::count_if(view_.begin(), view_.end(), item_selected) > 1)
+ const vector< shared_ptr<TraceTreeItem> > items(
+ view_.list_by_type<TraceTreeItem>());
+ if (std::count_if(items.begin(), items.end(), item_selected) > 1)
{
menu->addSeparator();
void Header::on_group()
{
+ const vector< shared_ptr<TraceTreeItem> > items(
+ view_.list_by_type<TraceTreeItem>());
vector< shared_ptr<TraceTreeItem> > selected_items(
- make_filter_iterator(item_selected, view_.begin(), view_.end()),
- make_filter_iterator(item_selected, view_.end(), view_.end()));
+ make_filter_iterator(item_selected, items.begin(), items.end()),
+ make_filter_iterator(item_selected, items.end(), items.end()));
stable_sort(selected_items.begin(), selected_items.end(),
[](const shared_ptr<TraceTreeItem> &a, const shared_ptr<TraceTreeItem> &b) {
return a->visual_v_offset() < b->visual_v_offset(); });
void View::restack_all_trace_tree_items()
{
// Make a list of owners that is sorted from deepest first
+ const vector<shared_ptr<TraceTreeItem>> items(
+ list_by_type<TraceTreeItem>());
set< TraceTreeItemOwner* > owners;
- for (const auto &r : *this)
+ for (const auto &r : items)
owners.insert(r->owner());
vector< TraceTreeItemOwner* > sorted_owners(owners.begin(), owners.end());
sort(sorted_owners.begin(), sorted_owners.end(),
o->restack_items();
// Animate the items to their destination
- const vector< shared_ptr<TraceTreeItem> > items(
- list_by_type<TraceTreeItem>());
for (const auto &i : items)
i->animate_to_layout_v_offset();
}
void View::on_hover_point_changed()
{
- for (shared_ptr<TraceTreeItem> r : *this)
+ const vector<shared_ptr<TraceTreeItem>> trace_tree_items(
+ list_by_type<TraceTreeItem>());
+ for (shared_ptr<TraceTreeItem> r : trace_tree_items)
r->hover_point_changed();
}
vector< shared_ptr<ViewItem> > Viewport::items()
{
- vector< shared_ptr<ViewItem> > items(view_.begin(), view_.end());
+ vector< shared_ptr<ViewItem> > items;
+ const vector< shared_ptr<TraceTreeItem> > trace_tree_items(
+ view_.list_by_type<TraceTreeItem>());
+ copy(trace_tree_items.begin(), trace_tree_items.end(),
+ back_inserter(items));
const vector< shared_ptr<TimeItem> > time_items(view_.time_items());
copy(time_items.begin(), time_items.end(), back_inserter(items));
return items;
void Viewport::paintEvent(QPaintEvent*)
{
- vector< shared_ptr<TraceTreeItem> > row_items(view_.begin(), view_.end());
- assert(none_of(row_items.begin(), row_items.end(),
+ vector< shared_ptr<TraceTreeItem> > trace_tree_items(
+ view_.list_by_type<TraceTreeItem>());
+ assert(none_of(trace_tree_items.begin(), trace_tree_items.end(),
[](const shared_ptr<TraceTreeItem> &r) { return !r; }));
- stable_sort(row_items.begin(), row_items.end(),
+ stable_sort(trace_tree_items.begin(), trace_tree_items.end(),
[](const shared_ptr<TraceTreeItem> &a, const shared_ptr<TraceTreeItem> &b) {
return a->visual_v_offset() < b->visual_v_offset(); });
for (const shared_ptr<TimeItem> t : time_items)
t->paint_back(p, pp);
- for (const shared_ptr<TraceTreeItem> r : row_items)
+ for (const shared_ptr<TraceTreeItem> r : trace_tree_items)
r->paint_back(p, pp);
for (const shared_ptr<TimeItem> t : time_items)
t->paint_mid(p, pp);
- for (const shared_ptr<TraceTreeItem> r : row_items)
+ for (const shared_ptr<TraceTreeItem> r : trace_tree_items)
r->paint_mid(p, pp);
p.setRenderHint(QPainter::Antialiasing, false);
- for (const shared_ptr<TraceTreeItem> r : row_items)
+ for (const shared_ptr<TraceTreeItem> r : trace_tree_items)
r->paint_fore(p, pp);
for (const shared_ptr<TimeItem> t : time_items)
t->paint_fore(p, pp);
bool ViewWidget::accept_drag() const
{
const vector< shared_ptr<TimeItem> > items(view_.time_items());
+ const vector< shared_ptr<TraceTreeItem> > trace_tree_items(
+ view_.list_by_type<TraceTreeItem>());
- const bool any_row_items_selected = any_of(view_.begin(), view_.end(),
+ const bool any_row_items_selected = any_of(
+ trace_tree_items.begin(), trace_tree_items.end(),
[](const shared_ptr<TraceTreeItem> &r) { return r->selected(); });
const bool any_time_items_selected = any_of(items.begin(), items.end(),
{
// Check all the drag items share a common owner
TraceTreeItemOwner *item_owner = nullptr;
- for (shared_ptr<TraceTreeItem> r : view_)
+ for (shared_ptr<TraceTreeItem> r : trace_tree_items)
if (r->dragging()) {
if (!item_owner)
item_owner = r->owner();
// Drag the row items
TraceTreeItemOwner *item_owner = nullptr;
- for (std::shared_ptr<TraceTreeItem> r : view_)
+ const vector< shared_ptr<TraceTreeItem> > trace_tree_items(
+ view_.list_by_type<TraceTreeItem>());
+ for (shared_ptr<TraceTreeItem> r : trace_tree_items)
if (r->dragging()) {
item_owner = r->owner();
r->drag_by(delta);
if (item_owner) {
item_dragged = true;
item_owner->restack_items();
- for (const auto &r : *item_owner)
+ for (shared_ptr<TraceTreeItem> r : trace_tree_items)
r->animate_to_layout_v_offset();
}