MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / OnBrowserDrop

Method OnBrowserDrop

src/gui/browserpanel.cc:604–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602 }
603
604 void OnBrowserDrop(wxDataViewEvent& event) override
605 {
606 try
607 {
608 if (event.GetDataFormat() != _dndFormat)
609 throw CancelException();
610
611#if defined __WXGTK__
612 /* wxWidgets 3.0 data view DnD on GTK is borked. See
613 * https://forums.wxwidgets.org/viewtopic.php?t=44752. The hit
614 * detection is done against the wrong object, resulting in the
615 * header size not being taken into account, so we have to
616 * manually do hit detection correctly. */
617
618 auto* window = browserTree->GetMainWindow();
619 auto screenPos = wxGetMousePosition();
620 auto relPos = screenPos - window->GetScreenPosition();
621
622 wxDataViewItem item;
623 wxDataViewColumn* column;
624 browserTree->HitTest(relPos, item, column);
625 if (!item.IsOk())
626 throw CancelException();
627#else
628 auto item = event.GetItem();
629#endif
630
631 auto destDirNode = GetTargetDirectoryNode(item);
632 if (!destDirNode)
633 throw CancelException();
634 auto destDirPath = destDirNode->dirent->path;
635
636 wxTextDataObject obj;
637 obj.SetData(_dndFormat, event.GetDataSize(), event.GetDataBuffer());
638 auto srcPath = Path(obj.GetText().ToStdString());
639 if (srcPath.empty())
640 throw CancelException();
641
642 ActuallyMoveFile(srcPath, destDirPath.concat(srcPath.back()));
643 }
644 catch (const CancelException& e)
645 {
646 event.Veto();
647 }
648 }
649
650 void OnBrowserCommitButton(wxCommandEvent&) override
651 {

Callers

nothing calls this directly

Calls 4

CancelExceptionClass · 0.85
concatMethod · 0.80
PathClass · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected