mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 08:22:15 -07:00
refactor
This commit is contained in:
parent
4d8f4afd9c
commit
3c7d1922c5
2 changed files with 30 additions and 32 deletions
|
|
@ -63,10 +63,24 @@ void VisualDeckStorageFolderDisplayWidget::refreshUi()
|
|||
header->setText(bannerText);
|
||||
}
|
||||
|
||||
static QStringList getAllFiles(const QString &filePath)
|
||||
{
|
||||
QStringList allFiles;
|
||||
|
||||
// QDirIterator with QDir::Files ensures only files are listed (no directories)
|
||||
QDirIterator it(filePath, QDir::Files);
|
||||
|
||||
while (it.hasNext()) {
|
||||
allFiles << it.next(); // Add each file path to the list
|
||||
}
|
||||
|
||||
return allFiles;
|
||||
}
|
||||
|
||||
void VisualDeckStorageFolderDisplayWidget::createWidgetsForFiles()
|
||||
{
|
||||
QList<DeckPreviewWidget *> allDecks;
|
||||
for (const QString &file : getAllFiles()) {
|
||||
for (const QString &file : getAllFiles(filePath)) {
|
||||
auto *display = new DeckPreviewWidget(flowWidget, visualDeckStorageWidget, file);
|
||||
|
||||
connect(display, &DeckPreviewWidget::deckPreviewClicked, visualDeckStorageWidget,
|
||||
|
|
@ -121,9 +135,23 @@ bool VisualDeckStorageFolderDisplayWidget::checkVisibility()
|
|||
return atLeastOneWidgetVisible;
|
||||
}
|
||||
|
||||
static QStringList getAllSubFolders(const QString &filePath)
|
||||
{
|
||||
QStringList allFolders;
|
||||
|
||||
// QDirIterator with QDir::Files ensures only files are listed (no directories)
|
||||
QDirIterator it(filePath, QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
|
||||
while (it.hasNext()) {
|
||||
allFolders << it.next(); // Add each file path to the list
|
||||
}
|
||||
|
||||
return allFolders;
|
||||
}
|
||||
|
||||
void VisualDeckStorageFolderDisplayWidget::createWidgetsForFolders()
|
||||
{
|
||||
for (const QString &dir : getAllSubFolders()) {
|
||||
for (const QString &dir : getAllSubFolders(filePath)) {
|
||||
auto *display = new VisualDeckStorageFolderDisplayWidget(this, visualDeckStorageWidget, dir, true);
|
||||
containerLayout->addWidget(display);
|
||||
}
|
||||
|
|
@ -148,32 +176,4 @@ QStringList VisualDeckStorageFolderDisplayWidget::gatherAllTagsFromFlowWidget()
|
|||
allTags.removeDuplicates();
|
||||
|
||||
return allTags;
|
||||
}
|
||||
|
||||
QStringList VisualDeckStorageFolderDisplayWidget::getAllFiles() const
|
||||
{
|
||||
QStringList allFiles;
|
||||
|
||||
// QDirIterator with QDir::Files ensures only files are listed (no directories)
|
||||
QDirIterator it(filePath, QDir::Files);
|
||||
|
||||
while (it.hasNext()) {
|
||||
allFiles << it.next(); // Add each file path to the list
|
||||
}
|
||||
|
||||
return allFiles;
|
||||
}
|
||||
|
||||
QStringList VisualDeckStorageFolderDisplayWidget::getAllSubFolders() const
|
||||
{
|
||||
QStringList allFolders;
|
||||
|
||||
// QDirIterator with QDir::Files ensures only files are listed (no directories)
|
||||
QDirIterator it(filePath, QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
|
||||
while (it.hasNext()) {
|
||||
allFolders << it.next(); // Add each file path to the list
|
||||
}
|
||||
|
||||
return allFolders;
|
||||
}
|
||||
|
|
@ -20,8 +20,6 @@ public:
|
|||
void createWidgetsForFiles();
|
||||
void createWidgetsForFolders();
|
||||
QStringList gatherAllTagsFromFlowWidget() const;
|
||||
[[nodiscard]] QStringList getAllFiles() const;
|
||||
[[nodiscard]] QStringList getAllSubFolders() const;
|
||||
FlowWidget *getFlowWidget() const
|
||||
{
|
||||
return flowWidget;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue