From 72669761a74c4c4c1ed3a10eb07f73759cbebbdd Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 10 Apr 2021 13:22:42 +1000 Subject: [PATCH] project: fix bug importing folders --- app/task/project/import/import.cpp | 23 ++++++++++++++--------- app/task/project/import/import.h | 2 ++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/task/project/import/import.cpp b/app/task/project/import/import.cpp index d88f1317a..3c317773b 100644 --- a/app/task/project/import/import.cpp +++ b/app/task/project/import/import.cpp @@ -96,13 +96,10 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, int &counte // Create a folder corresponding to the directory Folder* f = new Folder(); - f->moveToThread(folder->thread()); - f->SetLabel(file_info.fileName()); // Create undoable command that adds the items to the model - parent_command->add_child(new NodeAddCommand(folder->parent(), f)); - parent_command->add_child(new FolderAddChild(folder, f)); + AddItemToFolder(folder, f, parent_command); // Recursively follow this path Import(f, entry_list, counter, parent_command); @@ -119,11 +116,7 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, int &counte ValidateImageSequence(footage, import, i); // Create undoable command that adds the items to the model - NodeAddCommand* nac = new NodeAddCommand(folder->parent(), footage); - nac->PushToThread(folder->thread()); - parent_command->add_child(nac); - - parent_command->add_child(new FolderAddChild(folder, footage)); + AddItemToFolder(folder, footage, parent_command); } else { // Add to list so we can tell the user about it later invalid_files_.append(file_info.absoluteFilePath()); @@ -223,6 +216,18 @@ void ProjectImportTask::ValidateImageSequence(Footage *footage, QFileInfoList& i } } +void ProjectImportTask::AddItemToFolder(Folder *folder, Node *item, MultiUndoCommand *command) +{ + // Create undoable command that adds the items to the model + Project* project = model_->project(); + + NodeAddCommand* nac = new NodeAddCommand(project, item); + nac->PushToThread(project->thread()); + command->add_child(nac); + + command->add_child(new FolderAddChild(folder, item)); +} + bool ProjectImportTask::ItemIsStillImageFootageOnly(Footage* footage) { if (footage->GetTotalStreamCount() != 1) { diff --git a/app/task/project/import/import.h b/app/task/project/import/import.h index 6187d585a..7b1a3d6d9 100644 --- a/app/task/project/import/import.h +++ b/app/task/project/import/import.h @@ -61,6 +61,8 @@ private: void ValidateImageSequence(Footage *footage, QFileInfoList &info_list, int index); + void AddItemToFolder(Folder* folder, Node* item, MultiUndoCommand* command); + static bool ItemIsStillImageFootageOnly(Footage *footage); static bool CompareStillImageSize(Footage *footage, const QSize& sz);