Commit fdaa4321 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

When dropping a folder from a file manager to bin, don't create folders that contain no valid clip

parent 304e5a09
Pipeline #26839 passed with stage
in 10 minutes and 18 seconds
...@@ -236,11 +236,6 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che ...@@ -236,11 +236,6 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che
QString folderId; QString folderId;
Fun local_undo = []() { return true; }; Fun local_undo = []() { return true; };
Fun local_redo = []() { return true; }; Fun local_redo = []() { return true; };
bool folderCreated = pCore->projectItemModel()->requestAddFolder(folderId, dir.dirName(), parentFolder, local_undo, local_redo);
if (!folderCreated) {
continue;
}
createdItem = folderId;
QStringList result = dir.entryList(QDir::Files); QStringList result = dir.entryList(QDir::Files);
QStringList subfolders = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); QStringList subfolders = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
QList<QUrl> folderFiles; QList<QUrl> folderFiles;
...@@ -272,6 +267,12 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che ...@@ -272,6 +267,12 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che
} }
} }
if (!sublist.isEmpty()) { if (!sublist.isEmpty()) {
// Create main folder
bool folderCreated = pCore->projectItemModel()->requestAddFolder(folderId, dir.dirName(), parentFolder, local_undo, local_redo);
if (!folderCreated) {
continue;
}
createdItem = folderId;
// load subfolders // load subfolders
const QString clipId = createClipsFromList(sublist, checkRemovable, folderId, model, undo, redo, false); const QString clipId = createClipsFromList(sublist, checkRemovable, folderId, model, undo, redo, false);
if (createdItem.isEmpty() && clipId != QLatin1String("-1")) { if (createdItem.isEmpty() && clipId != QLatin1String("-1")) {
...@@ -279,6 +280,12 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che ...@@ -279,6 +280,12 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che
} }
} }
} else { } else {
// Create main folder
bool folderCreated = pCore->projectItemModel()->requestAddFolder(folderId, dir.dirName(), parentFolder, local_undo, local_redo);
if (!folderCreated) {
continue;
}
createdItem = folderId;
const QString clipId = createClipsFromList(folderFiles, checkRemovable, folderId, model, local_undo, local_redo, false); const QString clipId = createClipsFromList(folderFiles, checkRemovable, folderId, model, local_undo, local_redo, false);
if (clipId.isEmpty() || clipId == QLatin1String("-1")) { if (clipId.isEmpty() || clipId == QLatin1String("-1")) {
local_undo(); local_undo();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment