mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 14:32:15 -07:00
reduce redundant recursion
This commit is contained in:
parent
d987664fea
commit
a4e2692244
2 changed files with 10 additions and 6 deletions
|
|
@ -181,12 +181,14 @@ void VisualDeckStorageFolderDisplayWidget::updateShowFolders(bool enabled)
|
|||
}
|
||||
|
||||
/**
|
||||
* Sorts the DeckPreviewWidgets in this folder and all subfolders
|
||||
* Sorts the DeckPreviewWidgets in this folder
|
||||
*
|
||||
* @param comparator The comparator to use for sorting
|
||||
* @param recursive Also sort all nested subfolders
|
||||
*/
|
||||
void VisualDeckStorageFolderDisplayWidget::sortBy(
|
||||
const std::function<bool(DeckPreviewWidget *, DeckPreviewWidget *)> &comparator)
|
||||
const std::function<bool(DeckPreviewWidget *, DeckPreviewWidget *)> &comparator,
|
||||
bool recursive)
|
||||
{
|
||||
auto deckPreviewWidgets = flowWidget->findChildren<DeckPreviewWidget *>();
|
||||
|
||||
|
|
@ -200,9 +202,11 @@ void VisualDeckStorageFolderDisplayWidget::sortBy(
|
|||
flowWidget->addWidget(previewWidget);
|
||||
}
|
||||
|
||||
// also sort all subfolders
|
||||
for (auto *subFolder : findChildren<VisualDeckStorageFolderDisplayWidget *>()) {
|
||||
subFolder->sortBy(comparator);
|
||||
if (recursive) {
|
||||
// also sort all subfolders
|
||||
for (auto *subFolder : findChildren<VisualDeckStorageFolderDisplayWidget *>()) {
|
||||
subFolder->sortBy(comparator, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public:
|
|||
void refreshUi();
|
||||
void createWidgetsForFiles();
|
||||
void createWidgetsForFolders();
|
||||
void sortBy(const std::function<bool(DeckPreviewWidget *, DeckPreviewWidget *)> &comparator);
|
||||
void sortBy(const std::function<bool(DeckPreviewWidget *, DeckPreviewWidget *)> &comparator, bool recursive = true);
|
||||
void flattenFolderStructure();
|
||||
QStringList gatherAllTagsFromFlowWidget() const;
|
||||
FlowWidget *getFlowWidget() const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue