+ // Select the signal if it has been clicked
+ const shared_ptr<Trace> mouse_over_trace =
+ get_mouse_over_trace(event->pos());
+ if (mouse_over_trace) {
+ if (mouse_over_trace->selected())
+ mouse_over_trace->select(false);
+ else {
+ mouse_over_trace->select(true);
+
+ if (~QApplication::keyboardModifiers() &
+ Qt::ControlModifier)
+ _drag_traces.clear();
+
+ // Add the signal to the drag list
+ if (event->button() & Qt::LeftButton)
+ _drag_traces.push_back(
+ make_pair(mouse_over_trace,
+ mouse_over_trace->get_v_offset()));
+ }
+ }
+
+ if (~QApplication::keyboardModifiers() & Qt::ControlModifier) {
+ // Unselect all other signals because the Ctrl is not
+ // pressed
+ for (const shared_ptr<Trace> t : traces)
+ if (t != mouse_over_trace)
+ t->select(false);
+ }
+
+ selection_changed();
+ update();
+}
+
+void Header::mouseReleaseEvent(QMouseEvent *event)
+{
+ using pv::widgets::Popup;
+
+ assert(event);
+ if (event->button() == Qt::LeftButton) {
+ if (_dragging)
+ _view.normalize_layout();
+ else
+ {
+ const shared_ptr<Trace> mouse_over_trace =
+ get_mouse_over_trace(event->pos());
+ if (mouse_over_trace) {
+ const int w = width() - BaselineOffset;
+ Popup *const p =
+ mouse_over_trace->create_popup(&_view);
+ p->set_position(mapToGlobal(QPoint(w,
+ mouse_over_trace->get_y())),
+ Popup::Right);
+ p->show();
+ }
+ }
+
+ _dragging = false;
+ _drag_traces.clear();
+ }