@@ -657,7 +657,7 @@ void EntryTree::extractEntries(const QStringList& paths, const QString& destinat
657657 extractRecurse (model->getNodePath (child.get ()));
658658 }
659659 } else {
660- const QString itemPath = saveDir + QDir::separator () + path.sliced (rootDirLen);
660+ const QString itemPath = saveDir + QDir::separator () + (rootDirLen > 0 ? path.sliced (rootDirLen) : path );
661661 const std::string itemPathStr = itemPath.toLocal8Bit ().constData ();
662662 const std::filesystem::path itemPathDir (itemPathStr);
663663 std::ignore = QDir (saveDir).mkpath (itemPathDir.parent_path ().string ().c_str ());
@@ -671,6 +671,22 @@ void EntryTree::extractEntries(const QStringList& paths, const QString& destinat
671671}
672672
673673void EntryTree::createDrag (const QStringList& paths) {
674+ const bool allowDirDrag = Options::get<bool >(OPT_ENTRY_TREE_ALLOW_DIR_DRAG );
675+ const bool allowFileDrag = Options::get<bool >(OPT_ENTRY_TREE_ALLOW_FILE_DRAG );
676+ if (!allowDirDrag && !allowFileDrag) {
677+ return ;
678+ }
679+ if (!allowDirDrag || !allowFileDrag) {
680+ for (const auto & path : paths) {
681+ if (
682+ const bool isDir = this ->model ->getNodeAtPath (path)->isDirectory ();
683+ (!allowDirDrag && isDir) || (!allowFileDrag && !isDir)
684+ ) {
685+ return ;
686+ }
687+ }
688+ }
689+
674690 const TempDir tempDir;
675691
676692 auto * drag = new QDrag (this );
@@ -679,9 +695,8 @@ void EntryTree::createDrag(const QStringList& paths) {
679695 this ->extractEntries (paths, tempDir.path ());
680696
681697 QList<QUrl> extractedPaths;
682- QStringList extractedRawPaths = tempDir.dir ().entryList (QDir::AllEntries | QDir::NoDotAndDotDot);
683- for (const auto & rawPath : extractedRawPaths) {
684- extractedPaths.push_back (QUrl::fromLocalFile (tempDir.path () + QDir::separator () + rawPath));
698+ for (const auto & entryName : tempDir.dir ().entryList (QDir::AllEntries | QDir::NoDotAndDotDot)) {
699+ extractedPaths.push_back (QUrl::fromLocalFile (tempDir.path () + QDir::separator () + entryName));
685700 }
686701
687702 // Set up drag
0 commit comments