-void Header::mousePressEvent(QMouseEvent *event)
-{
- assert(event);
-
- const vector< shared_ptr<RowItem> > row_items(_view.child_items());
-
- if (event->button() & Qt::LeftButton) {
- _mouse_down_point = event->pos();
-
- // Save the offsets of any signals which will be dragged
- for (const shared_ptr<RowItem> r : row_items)
- if (r->selected())
- _drag_row_items.push_back(
- make_pair(r, r->v_offset()));
- }
-
- // Select the signal if it has been clicked
- const shared_ptr<RowItem> mouse_over_row_item =
- get_mouse_over_row_item(event->pos());
- if (mouse_over_row_item) {
- if (mouse_over_row_item->selected())
- mouse_over_row_item->select(false);
- else {
- mouse_over_row_item->select(true);
-
- if (~QApplication::keyboardModifiers() &
- Qt::ControlModifier)
- _drag_row_items.clear();
-
- // Add the signal to the drag list
- if (event->button() & Qt::LeftButton)
- _drag_row_items.push_back(
- make_pair(mouse_over_row_item,
- mouse_over_row_item->v_offset()));
- }
- }
-
- if (~QApplication::keyboardModifiers() & Qt::ControlModifier) {
- // Unselect all other signals because the Ctrl is not
- // pressed
- for (const shared_ptr<RowItem> r : row_items)
- if (r != mouse_over_row_item)
- r->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<RowItem> mouse_over_row_item =
- get_mouse_over_row_item(event->pos());
- if (mouse_over_row_item) {
- const int w = width() - BaselineOffset;
- Popup *const p =
- mouse_over_row_item->create_popup(&_view);
- p->set_position(mapToGlobal(QPoint(w,
- mouse_over_row_item->get_y())),
- Popup::Right);
- p->show();
- }
- }
-
- _dragging = false;
- _drag_row_items.clear();
- }
-}
-
-void Header::mouseMoveEvent(QMouseEvent *event)