- const vector< shared_ptr<Signal> > sigs(_view.session().get_signals());
- BOOST_FOREACH(shared_ptr<Signal> s, sigs) {
- assert(s);
- connect(s.get(), SIGNAL(text_changed()), this, SLOT(update()));
+ vector< shared_ptr<RowItem> > selected_items(
+ make_filter_iterator(item_selected, view_.begin(), view_.end()),
+ make_filter_iterator(item_selected, view_.end(), view_.end()));
+ stable_sort(selected_items.begin(), selected_items.end(),
+ [](const shared_ptr<RowItem> &a, const shared_ptr<RowItem> &b) {
+ return a->visual_v_offset() < b->visual_v_offset(); });
+
+ shared_ptr<TraceGroup> group(new TraceGroup());
+ shared_ptr<RowItem> focus_item(
+ mouse_down_item_ ? mouse_down_item_ : selected_items.front());
+
+ assert(focus_item);
+ assert(focus_item->owner());
+ focus_item->owner()->add_child_item(group);
+
+ // Set the group v_offset here before reparenting
+ group->force_to_v_offset(focus_item->layout_v_offset() +
+ focus_item->v_extents().first);
+
+ for (size_t i = 0; i < selected_items.size(); i++) {
+ const shared_ptr<RowItem> &r = selected_items[i];
+ assert(r->owner());
+ r->owner()->remove_child_item(r);
+ group->add_child_item(r);
+
+ // Put the items at 1-pixel offsets, so that restack will
+ // stack them in the right order
+ r->set_layout_v_offset(i);