mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Qt: Add "Search subdirectories" checkbox
This commit is contained in:
parent
396204248d
commit
a4526772b9
@ -22,6 +22,8 @@ GameListModel::GameListModel(QObject* parent) : QAbstractTableModel(parent)
|
||||
[this](const QString& path) { RemoveGame(path.toStdString()); });
|
||||
connect(&Settings::Instance(), &Settings::PathAdded, &m_tracker, &GameTracker::AddDirectory);
|
||||
connect(&Settings::Instance(), &Settings::PathRemoved, &m_tracker, &GameTracker::RemoveDirectory);
|
||||
connect(&Settings::Instance(), &Settings::PathReloadRequested, &m_tracker,
|
||||
&GameTracker::ReloadDirectory);
|
||||
|
||||
for (const QString& dir : Settings::Instance().GetPaths())
|
||||
m_tracker.AddDirectory(dir);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "DiscIO/DirectoryBlob.h"
|
||||
#include "DolphinQt2/GameList/GameTracker.h"
|
||||
#include "DolphinQt2/QtUtils/QueueOnObject.h"
|
||||
@ -58,6 +59,12 @@ void GameTracker::RemoveDirectory(const QString& dir)
|
||||
m_load_thread.EmplaceItem(Command{CommandType::RemoveDirectory, dir});
|
||||
}
|
||||
|
||||
void GameTracker::ReloadDirectory(const QString& dir)
|
||||
{
|
||||
m_load_thread.EmplaceItem(Command{CommandType::RemoveDirectory, dir});
|
||||
m_load_thread.EmplaceItem(Command{CommandType::AddDirectory, dir});
|
||||
}
|
||||
|
||||
void GameTracker::UpdateDirectory(const QString& dir)
|
||||
{
|
||||
m_load_thread.EmplaceItem(Command{CommandType::UpdateDirectory, dir});
|
||||
@ -76,13 +83,21 @@ void GameTracker::AddDirectoryInternal(const QString& dir)
|
||||
UpdateDirectoryInternal(dir);
|
||||
}
|
||||
|
||||
static std::unique_ptr<QDirIterator> GetIterator(const QString& dir)
|
||||
{
|
||||
return std::make_unique<QDirIterator>(dir, game_filters, QDir::NoFilter,
|
||||
SConfig::GetInstance().m_RecursiveISOFolder ?
|
||||
QDirIterator::Subdirectories :
|
||||
QDirIterator::NoIteratorFlags);
|
||||
}
|
||||
|
||||
void GameTracker::RemoveDirectoryInternal(const QString& dir)
|
||||
{
|
||||
removePath(dir);
|
||||
QDirIterator it(dir, game_filters, QDir::NoFilter, QDirIterator::Subdirectories);
|
||||
while (it.hasNext())
|
||||
auto it = GetIterator(dir);
|
||||
while (it->hasNext())
|
||||
{
|
||||
QString path = QFileInfo(it.next()).canonicalFilePath();
|
||||
QString path = QFileInfo(it->next()).canonicalFilePath();
|
||||
if (m_tracked_files.contains(path))
|
||||
{
|
||||
m_tracked_files[path].remove(dir);
|
||||
@ -98,10 +113,10 @@ void GameTracker::RemoveDirectoryInternal(const QString& dir)
|
||||
|
||||
void GameTracker::UpdateDirectoryInternal(const QString& dir)
|
||||
{
|
||||
QDirIterator it(dir, game_filters, QDir::NoFilter, QDirIterator::Subdirectories);
|
||||
while (it.hasNext())
|
||||
auto it = GetIterator(dir);
|
||||
while (it->hasNext())
|
||||
{
|
||||
QString path = QFileInfo(it.next()).canonicalFilePath();
|
||||
QString path = QFileInfo(it->next()).canonicalFilePath();
|
||||
|
||||
if (m_tracked_files.contains(path))
|
||||
{
|
||||
@ -147,7 +162,7 @@ void GameTracker::UpdateFileInternal(const QString& file)
|
||||
|
||||
QSet<QString> GameTracker::FindMissingFiles(const QString& dir)
|
||||
{
|
||||
QDirIterator it(dir, game_filters, QDir::NoFilter, QDirIterator::Subdirectories);
|
||||
auto it = GetIterator(dir);
|
||||
|
||||
QSet<QString> missing_files;
|
||||
|
||||
@ -157,9 +172,9 @@ QSet<QString> GameTracker::FindMissingFiles(const QString& dir)
|
||||
missing_files.insert(key);
|
||||
}
|
||||
|
||||
while (it.hasNext())
|
||||
while (it->hasNext())
|
||||
{
|
||||
QString path = QFileInfo(it.next()).canonicalFilePath();
|
||||
QString path = QFileInfo(it->next()).canonicalFilePath();
|
||||
if (m_tracked_files.contains(path))
|
||||
missing_files.remove(path);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
|
||||
void AddDirectory(const QString& dir);
|
||||
void RemoveDirectory(const QString& dir);
|
||||
void ReloadDirectory(const QString& dir);
|
||||
|
||||
signals:
|
||||
void GameLoaded(std::shared_ptr<const UICommon::GameFile> game);
|
||||
|
@ -80,6 +80,11 @@ void Settings::RemovePath(const QString& qpath)
|
||||
emit PathRemoved(qpath);
|
||||
}
|
||||
|
||||
void Settings::ReloadPath(const QString& qpath)
|
||||
{
|
||||
emit PathReloadRequested(qpath);
|
||||
}
|
||||
|
||||
QString Settings::GetDefaultGame() const
|
||||
{
|
||||
return QString::fromStdString(SConfig::GetInstance().m_strDefaultISO);
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
void SetPreferredView(bool list);
|
||||
QString GetDefaultGame() const;
|
||||
void SetDefaultGame(QString path);
|
||||
void ReloadPath(const QString& qpath);
|
||||
|
||||
// Emulation
|
||||
int GetStateSlot() const;
|
||||
@ -119,6 +120,7 @@ signals:
|
||||
void PathAdded(const QString&);
|
||||
void PathRemoved(const QString&);
|
||||
void DefaultGameChanged(const QString&);
|
||||
void PathReloadRequested(const QString&);
|
||||
void HideCursorChanged();
|
||||
void VolumeChanged(int volume);
|
||||
void NANDRefresh();
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QFileDialog>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
@ -81,9 +82,20 @@ QGroupBox* PathPane::MakeGameFolderBox()
|
||||
hlayout->addStretch();
|
||||
QPushButton* add = new QPushButton(tr("Add"));
|
||||
QPushButton* remove = new QPushButton(tr("Remove"));
|
||||
|
||||
auto* checkbox = new QCheckBox(tr("Search Subfolders"));
|
||||
checkbox->setChecked(SConfig::GetInstance().m_RecursiveISOFolder);
|
||||
|
||||
hlayout->addWidget(add);
|
||||
hlayout->addWidget(remove);
|
||||
vlayout->addLayout(hlayout);
|
||||
vlayout->addWidget(checkbox);
|
||||
|
||||
connect(checkbox, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
SConfig::GetInstance().m_RecursiveISOFolder = checked;
|
||||
for (const auto& path : Settings::Instance().GetPaths())
|
||||
Settings::Instance().ReloadPath(path);
|
||||
});
|
||||
|
||||
connect(add, &QPushButton::clicked, this, &PathPane::Browse);
|
||||
connect(remove, &QPushButton::clicked, this, &PathPane::RemovePath);
|
||||
|
Loading…
Reference in New Issue
Block a user