MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / mousePressEvent

Method mousePressEvent

pj_widgets/src/CurveTreeView.cpp:768–806  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

766}
767
768void CurveTreeView::mousePressEvent(QMouseEvent* event) {
769 drag_curve_names_.clear();
770 drag_catalog_keys_.clear();
771 suppress_next_release_ = false;
772 drag_button_ = Qt::NoButton;
773 if (event->button() == Qt::LeftButton || event->button() == Qt::RightButton) {
774 QTreeWidgetItem* item = itemAt(event->pos());
775 // Only draggable rows (curve leaves / object topics) initiate a drag or the
776 // drag-the-whole-selection gesture. Non-draggable rows — notably the selectable
777 // dataset groups — fall straight through to the base handler, so plain/Ctrl/Shift
778 // selection and expand/collapse behave normally and a dataset never starts a drag.
779 const bool draggable = item != nullptr && (item->flags() & Qt::ItemIsDragEnabled);
780 if (draggable) {
781 drag_start_pos_ = event->pos();
782 drag_button_ = event->button();
783
784 const Qt::KeyboardModifiers selection_modifiers = Qt::ControlModifier | Qt::ShiftModifier | Qt::MetaModifier;
785 const QString item_catalog_key = catalogKeyForItem(item);
786 if (!item_catalog_key.isEmpty()) {
787 drag_catalog_keys_.push_back(item_catalog_key);
788 }
789 if (item->isSelected() && !(event->modifiers() & selection_modifiers)) {
790 drag_curve_names_ = selectedCurveNamesForDrag();
791 // A plain press on an already-selected row drags the WHOLE selection.
792 // Preserve it (suppress the release that would otherwise collapse it to
793 // the clicked row) whenever more than one row is selected — counting
794 // object/image topics too, which contribute catalog keys but no scalar
795 // curve names. The payload itself is read back from the live selection in
796 // createDragMimeData(), so it stays correct as long as we keep it intact.
797 if (drag_curve_names_.size() > 1 || selectedCatalogKeysRecursive().size() > 1) {
798 suppress_next_release_ = true;
799 event->accept();
800 return;
801 }
802 }
803 }
804 }
805 QTreeWidget::mousePressEvent(event);
806}
807
808void CurveTreeView::mouseMoveEvent(QMouseEvent* event) {
809 if (drag_button_ == Qt::NoButton) {

Callers

nothing calls this directly

Calls 8

catalogKeyForItemFunction · 0.85
flagsMethod · 0.80
isSelectedMethod · 0.80
clearMethod · 0.45
posMethod · 0.45
isEmptyMethod · 0.45
sizeMethod · 0.45
acceptMethod · 0.45

Tested by

no test coverage detected