MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / mouseMoveEvent

Method mouseMoveEvent

launcher/ui/instanceview/InstanceView.cpp:339–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337}
338
339void InstanceView::mouseMoveEvent(QMouseEvent *event)
340{
341 executeDelayedItemsLayout();
342
343 QPoint topLeft;
344 QPoint visualPos = event->pos();
345 QPoint geometryPos = event->pos() + offset();
346
347 if (state() == ExpandingState || state() == CollapsingState)
348 {
349 return;
350 }
351
352 if (state() == DraggingState)
353 {
354 topLeft = m_pressedPosition - offset();
355 if ((topLeft - event->pos()).manhattanLength() > QApplication::startDragDistance())
356 {
357 m_pressedIndex = QModelIndex();
358 startDrag(model()->supportedDragActions());
359 setState(NoState);
360 stopAutoScroll();
361 }
362 return;
363 }
364
365 if (selectionMode() != SingleSelection)
366 {
367 topLeft = m_pressedPosition - offset();
368 }
369 else
370 {
371 topLeft = geometryPos;
372 }
373
374 if (m_pressedIndex.isValid() && (state() != DragSelectingState) &&
375 (event->buttons() != Qt::NoButton) && !selectedIndexes().isEmpty())
376 {
377 setState(DraggingState);
378 return;
379 }
380
381 if ((event->buttons() & Qt::LeftButton) && selectionModel())
382 {
383 setState(DragSelectingState);
384
385 setSelection(QRect(visualPos, visualPos), QItemSelectionModel::ClearAndSelect);
386 QModelIndex index = indexAt(visualPos);
387
388 // set at the end because it might scroll the view
389 if (index.isValid() && (index != selectionModel()->currentIndex()) &&
390 (index.flags() & Qt::ItemIsEnabled))
391 {
392 selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
393 }
394 }
395}
396

Callers

nothing calls this directly

Calls 5

QModelIndexClass · 0.85
isEmptyMethod · 0.80
supportedDragActionsMethod · 0.45
isValidMethod · 0.45
flagsMethod · 0.45

Tested by

no test coverage detected