mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 08:22:15 -07:00
remove recursion from flattenFolderStructure
findChildren is already recursive by default
This commit is contained in:
parent
6df97a156f
commit
e2990c9dff
1 changed files with 4 additions and 23 deletions
|
|
@ -181,32 +181,13 @@ void VisualDeckStorageFolderDisplayWidget::updateShowFolders(bool enabled)
|
|||
}
|
||||
|
||||
/**
|
||||
* Recursively gets all DeckPreviewWidgets in this folder and its subfolders
|
||||
*/
|
||||
static QList<DeckPreviewWidget *> getAllDecksRecursive(VisualDeckStorageFolderDisplayWidget *folder)
|
||||
{
|
||||
QList<DeckPreviewWidget *> allDecks;
|
||||
|
||||
if (auto *flowWidget = folder->getFlowWidget()) {
|
||||
// Iterate through all DeckPreviewWidgets in this folder
|
||||
allDecks << flowWidget->findChildren<DeckPreviewWidget *>();
|
||||
}
|
||||
|
||||
for (auto *subFolder : folder->findChildren<VisualDeckStorageFolderDisplayWidget *>()) {
|
||||
allDecks << getAllDecksRecursive(subFolder);
|
||||
}
|
||||
|
||||
return allDecks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively steals all DeckPreviewWidgets from this widget's subfolders, and deletes all subfolders
|
||||
* Steals all DeckPreviewWidgets from this widget's nested subfolders, and deletes those subfolders
|
||||
*/
|
||||
void VisualDeckStorageFolderDisplayWidget::flattenFolderStructure()
|
||||
{
|
||||
for (VisualDeckStorageFolderDisplayWidget *subFolder : findChildren<VisualDeckStorageFolderDisplayWidget *>()) {
|
||||
// steal all DeckPreviewWidgets from the subfolder and all its subfolders
|
||||
for (auto *deck : getAllDecksRecursive(subFolder)) {
|
||||
for (auto *subFolder : findChildren<VisualDeckStorageFolderDisplayWidget *>()) {
|
||||
// steal all DeckPreviewWidgets from the subfolder
|
||||
for (auto *deck : subFolder->getFlowWidget()->findChildren<DeckPreviewWidget *>()) {
|
||||
flowWidget->addWidget(deck);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue