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

Method dropEvent

launcher/ui/instanceview/InstanceView.cpp:641–690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639}
640
641void InstanceView::dropEvent(QDropEvent *event)
642{
643 executeDelayedItemsLayout();
644
645 m_lastDragPosition = QPoint();
646
647 stopAutoScroll();
648 setState(NoState);
649
650 auto mimedata = event->mimeData();
651
652 if (event->source() == this)
653 {
654 if(event->possibleActions() & Qt::MoveAction)
655 {
656 std::pair<VisualGroup *, VisualGroup::HitResults> dropPos = rowDropPos(event->pos());
657 const VisualGroup *group = dropPos.first;
658 auto hitresult = dropPos.second;
659
660 if (hitresult == VisualGroup::HitResult::NoHit)
661 {
662 viewport()->update();
663 return;
664 }
665 auto instanceId = QString::fromUtf8(mimedata->data("application/x-instanceid"));
666 auto instanceList = APPLICATION->instances().get();
667 instanceList->setInstanceGroup(instanceId, group->text);
668 event->setDropAction(Qt::MoveAction);
669 event->accept();
670
671 updateGeometries();
672 viewport()->update();
673 }
674 return;
675 }
676
677 // check if the action is supported
678 if (!mimedata)
679 {
680 return;
681 }
682
683 // files dropped from outside?
684 if (mimedata->hasUrls())
685 {
686 auto urls = mimedata->urls();
687 event->accept();
688 emit droppedURLs(urls);
689 }
690}
691
692void InstanceView::startDrag(Qt::DropActions supportedActions)
693{

Callers

nothing calls this directly

Calls 7

instancesMethod · 0.80
setInstanceGroupMethod · 0.80
mimeDataMethod · 0.45
updateMethod · 0.45
dataMethod · 0.45
getMethod · 0.45
acceptMethod · 0.45

Tested by

no test coverage detected