-void MarginWidget::mouse_left_press_event(QMouseEvent *event)
-{
- (void)event;
-
- const bool ctrl_pressed =
- QApplication::keyboardModifiers() & Qt::ControlModifier;
-
- // Clear selection if control is not pressed and this item is unselected
- if ((!mouse_down_item_ || !mouse_down_item_->selected()) &&
- !ctrl_pressed)
- clear_selection();
-
- // Set the signal selection state if the item has been clicked
- if (mouse_down_item_) {
- if (ctrl_pressed)
- mouse_down_item_->select(!mouse_down_item_->selected());
- else
- mouse_down_item_->select(true);
- }
-
- // Save the offsets of any signals which will be dragged
- const auto items = this->items();
- for (auto &i : items)
- if (i->selected())
- i->drag();
-
- selection_changed();
- update();
-}
-
-void MarginWidget::mouse_left_release_event(QMouseEvent *event)
-{
- assert(event);
-
- auto items = this->items();
- const bool ctrl_pressed =
- QApplication::keyboardModifiers() & Qt::ControlModifier;
-
- // Unselect everything if control is not pressed
- const shared_ptr<ViewItem> mouse_over =
- get_mouse_over_item(event->pos());
-
- for (auto &i : items)
- i->drag_release();
-
- if (dragging_)
- view_.restack_all_row_items();
- else
- {
- if (!ctrl_pressed) {
- for (shared_ptr<ViewItem> i : items)
- if (mouse_down_item_ != i)
- i->select(false);
-
- if (mouse_down_item_)
- show_popup(mouse_down_item_);
- }
- }
-
- dragging_ = false;
-}
-
-void MarginWidget::mousePressEvent(QMouseEvent *event)
-{
- assert(event);
-
- mouse_down_point_ = event->pos();
- mouse_down_item_ = get_mouse_over_item(event->pos());
-
- if (event->button() & Qt::LeftButton)
- mouse_left_press_event(event);
-}
-
-void MarginWidget::mouseReleaseEvent(QMouseEvent *event)
-{
- assert(event);
- if (event->button() & Qt::LeftButton)
- mouse_left_release_event(event);
-
- mouse_down_item_ = nullptr;
-}
-
-void MarginWidget::leaveEvent(QEvent*)
-{
- mouse_point_ = QPoint(-1, -1);
- update();
-}
-