-void Header::mouseLeftPressEvent(QMouseEvent *event)
-{
- const bool ctrl_pressed =
- QApplication::keyboardModifiers() & Qt::ControlModifier;
-
- // Clear selection if control is not pressed and this item is unselected
- const shared_ptr<RowItem> mouse_over =
- get_mouse_over_row_item(event->pos());
- if (!ctrl_pressed && (!mouse_over || !mouse_over->selected()))
- for (shared_ptr<RowItem> r : _view)
- r->select(false);
-
- // Set the signal selection state if the item has been clicked
- if (mouse_over) {
- if (ctrl_pressed)
- mouse_over->select(!mouse_over->selected());
- else
- mouse_over->select(true);
- }
-
- // Save the offsets of any signals which will be dragged
- _mouse_down_point = event->pos();
- for (const shared_ptr<RowItem> r : _view)
- if (r->selected())
- _drag_row_items.push_back(
- make_pair(r, r->v_offset()));
-
- selection_changed();
- update();
-}
-
-void Header::mousePressEvent(QMouseEvent *event)
-{
- assert(event);
- if (event->button() & Qt::LeftButton)
- mouseLeftPressEvent(event);
-}
-
-void Header::mouseLeftReleaseEvent(QMouseEvent *event)
-{
- assert(event);
-
- const bool ctrl_pressed =
- QApplication::keyboardModifiers() & Qt::ControlModifier;
-
- // Unselect everything if control is not pressed
- const shared_ptr<RowItem> mouse_over =
- get_mouse_over_row_item(event->pos());
-
- if (_dragging)
- _view.normalize_layout();
- else
- {
- if (!ctrl_pressed) {
- for (shared_ptr<RowItem> r : _view)
- if (mouse_over != r)
- r->select(false);
-
- if (mouse_over)
- show_popup(mouse_over);
- }
- }
-
- _dragging = false;
- _drag_row_items.clear();
-}
-
-void Header::mouseReleaseEvent(QMouseEvent *event)
-{
- assert(event);
- if (event->button() & Qt::LeftButton)
- mouseLeftReleaseEvent(event);
-}
-
-void Header::mouseMoveEvent(QMouseEvent *event)
-{
- assert(event);
- _mouse_point = event->pos();
-
- if (!(event->buttons() & Qt::LeftButton))
- return;
-
- if ((event->pos() - _mouse_down_point).manhattanLength() <
- QApplication::startDragDistance())
- return;
-
- // Check the list of dragging items is not empty
- if (_drag_row_items.empty())
- return;
-
- // Check all the drag items share a common owner
- const shared_ptr<RowItem> first_row_item(
- _drag_row_items.front().first);
- for (const auto &r : _drag_row_items) {
- const shared_ptr<RowItem> row_item(r.first);
- assert(row_item);
-
- if (row_item->owner() != first_row_item->owner())
- return;
- }
-
- // Do the drag
- _dragging = true;
-
- const int delta = event->pos().y() - _mouse_down_point.y();
-
- for (auto i = _drag_row_items.begin();
- i != _drag_row_items.end(); i++) {
- const std::shared_ptr<RowItem> row_item((*i).first);
- if (row_item) {
- const int y = (*i).second + delta;
- row_item->set_v_offset(y);
-
- // Ensure the trace is selected
- row_item->select();
- }
- }
-
- signals_moved();
-
- update();
-}
-
-void Header::leaveEvent(QEvent*)
-{
- _mouse_point = QPoint(-1, -1);
- update();
-}
-