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 comparator The comparator to use for sorting
|
||||||
|
* @param recursive Also sort all nested subfolders
|
||||||
*/
|
*/
|
||||||
void VisualDeckStorageFolderDisplayWidget::sortBy(
|
void VisualDeckStorageFolderDisplayWidget::sortBy(
|
||||||
const std::function<bool(DeckPreviewWidget *, DeckPreviewWidget *)> &comparator)
|
const std::function<bool(DeckPreviewWidget *, DeckPreviewWidget *)> &comparator,
|
||||||
|
bool recursive)
|
||||||
{
|
{
|
||||||
auto deckPreviewWidgets = flowWidget->findChildren<DeckPreviewWidget *>();
|
auto deckPreviewWidgets = flowWidget->findChildren<DeckPreviewWidget *>();
|
||||||
|
|
||||||
|
|
@ -200,9 +202,11 @@ void VisualDeckStorageFolderDisplayWidget::sortBy(
|
||||||
flowWidget->addWidget(previewWidget);
|
flowWidget->addWidget(previewWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (recursive) {
|
||||||
// also sort all subfolders
|
// also sort all subfolders
|
||||||
for (auto *subFolder : findChildren<VisualDeckStorageFolderDisplayWidget *>()) {
|
for (auto *subFolder : findChildren<VisualDeckStorageFolderDisplayWidget *>()) {
|
||||||
subFolder->sortBy(comparator);
|
subFolder->sortBy(comparator, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ public:
|
||||||
void refreshUi();
|
void refreshUi();
|
||||||
void createWidgetsForFiles();
|
void createWidgetsForFiles();
|
||||||
void createWidgetsForFolders();
|
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();
|
void flattenFolderStructure();
|
||||||
QStringList gatherAllTagsFromFlowWidget() const;
|
QStringList gatherAllTagsFromFlowWidget() const;
|
||||||
FlowWidget *getFlowWidget() const
|
FlowWidget *getFlowWidget() const
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue