mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 08:22:15 -07:00
reduce redundant recursion in updateVisibility
findChildren is recursive by default, so only the top-level updateVisibility needs to loop through the found children
This commit is contained in:
parent
2da0deff62
commit
49c884f8da
2 changed files with 9 additions and 6 deletions
|
|
@ -98,10 +98,11 @@ void VisualDeckStorageFolderDisplayWidget::createWidgetsForFiles()
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates the visibility of this folder and all its DeckPreviewWidgets, as well as all its subfolders and their
|
||||
* DeckPreviewWidgets.
|
||||
* Updates the visibility of this folder and all its DeckPreviewWidgets
|
||||
*
|
||||
* @param recursive Also update the visibility of all subfolders and their DeckPreviewWidgets.
|
||||
*/
|
||||
void VisualDeckStorageFolderDisplayWidget::updateVisibility()
|
||||
void VisualDeckStorageFolderDisplayWidget::updateVisibility(bool recursive)
|
||||
{
|
||||
bool atLeastOneWidgetVisible = checkVisibility();
|
||||
if (atLeastOneWidgetVisible) {
|
||||
|
|
@ -109,8 +110,10 @@ void VisualDeckStorageFolderDisplayWidget::updateVisibility()
|
|||
for (DeckPreviewWidget *display : flowWidget->findChildren<DeckPreviewWidget *>()) {
|
||||
display->updateVisibility();
|
||||
}
|
||||
for (VisualDeckStorageFolderDisplayWidget *subFolder : findChildren<VisualDeckStorageFolderDisplayWidget *>()) {
|
||||
subFolder->updateVisibility();
|
||||
if (recursive) {
|
||||
for (auto *subFolder : findChildren<VisualDeckStorageFolderDisplayWidget *>()) {
|
||||
subFolder->updateVisibility(false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setVisible(false);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public:
|
|||
};
|
||||
|
||||
public slots:
|
||||
void updateVisibility();
|
||||
void updateVisibility(bool recursive = true);
|
||||
bool checkVisibility();
|
||||
void updateShowFolders(bool enabled);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue