2018-09-07 20:08:08 +00:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
#include <QList>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QRunnable>
|
|
|
|
#include <QString>
|
2019-06-07 22:51:58 +00:00
|
|
|
#include <QVector>
|
2018-09-07 20:08:08 +00:00
|
|
|
|
|
|
|
#include "common/common_types.h"
|
2018-09-09 23:09:37 +00:00
|
|
|
#include "yuzu/compatibility_list.h"
|
2018-09-07 20:08:08 +00:00
|
|
|
|
|
|
|
class QStandardItem;
|
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
class NCA;
|
|
|
|
class VfsFilesystem;
|
|
|
|
} // namespace FileSys
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Asynchronous worker object for populating the game list.
|
|
|
|
* Communicates with other threads through Qt's signal/slot system.
|
|
|
|
*/
|
|
|
|
class GameListWorker : public QObject, public QRunnable {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2019-05-01 21:21:04 +00:00
|
|
|
explicit GameListWorker(std::shared_ptr<FileSys::VfsFilesystem> vfs,
|
|
|
|
FileSys::ManualContentProvider* provider,
|
2019-06-07 22:51:58 +00:00
|
|
|
QVector<UISettings::GameDir>& game_dirs,
|
2019-05-01 21:21:04 +00:00
|
|
|
const CompatibilityList& compatibility_list);
|
2018-09-07 20:08:08 +00:00
|
|
|
~GameListWorker() override;
|
|
|
|
|
|
|
|
/// Starts the processing of directory tree information.
|
|
|
|
void run() override;
|
|
|
|
|
|
|
|
/// Tells the worker that it should no longer continue processing. Thread-safe.
|
|
|
|
void Cancel();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
/**
|
|
|
|
* The `EntryReady` signal is emitted once an entry has been prepared and is ready
|
|
|
|
* to be added to the game list.
|
2019-05-01 21:21:04 +00:00
|
|
|
* @param entry_items a list with `QStandardItem`s that make up the columns of the new
|
|
|
|
* entry.
|
2018-09-07 20:08:08 +00:00
|
|
|
*/
|
2019-05-01 21:21:04 +00:00
|
|
|
void DirEntryReady(GameListDir* entry_items);
|
|
|
|
void EntryReady(QList<QStandardItem*> entry_items, GameListDir* parent_dir);
|
2018-09-07 20:08:08 +00:00
|
|
|
|
|
|
|
/**
|
2019-05-01 21:21:04 +00:00
|
|
|
* After the worker has traversed the game directory looking for entries, this signal is
|
|
|
|
* emitted with a list of folders that should be watched for changes as well.
|
2018-09-07 20:08:08 +00:00
|
|
|
*/
|
|
|
|
void Finished(QStringList watch_list);
|
|
|
|
|
|
|
|
private:
|
2019-05-01 21:21:04 +00:00
|
|
|
void AddTitlesToGameList(GameListDir* parent_dir);
|
2019-03-04 17:40:53 +00:00
|
|
|
|
|
|
|
enum class ScanTarget {
|
|
|
|
FillManualContentProvider,
|
|
|
|
PopulateGameList,
|
|
|
|
};
|
|
|
|
|
2021-05-25 23:32:56 +00:00
|
|
|
void ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan,
|
2019-05-01 21:21:04 +00:00
|
|
|
GameListDir* parent_dir);
|
2018-09-07 20:08:08 +00:00
|
|
|
|
|
|
|
std::shared_ptr<FileSys::VfsFilesystem> vfs;
|
2019-03-04 17:40:53 +00:00
|
|
|
FileSys::ManualContentProvider* provider;
|
2019-06-07 22:51:58 +00:00
|
|
|
QVector<UISettings::GameDir>& game_dirs;
|
2019-10-04 23:41:02 +00:00
|
|
|
const CompatibilityList& compatibility_list;
|
|
|
|
|
|
|
|
QStringList watch_list;
|
2018-09-07 20:08:08 +00:00
|
|
|
std::atomic_bool stop_processing;
|
|
|
|
};
|