mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-12-01 08:22:53 +00:00
9238015dd4
This has gotten sufficiently large enough to warrant moving it to its own source files. Especially given it dumps the file_sys headers around code that doesn't use it for the most part. This'll also make it easier to introduce a type alias for the compatibility list, so a large unordered_map type declaration doesn't need to be specified all the time (we don't want to propagate the game_list_p.h include via the main game_list.h header).
65 lines
1.9 KiB
C++
65 lines
1.9 KiB
C++
// 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>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
class QStandardItem;
|
|
|
|
/**
|
|
* 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:
|
|
GameListWorker(
|
|
QList<UISettings::GameDir>& game_dirs,
|
|
const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list);
|
|
~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.
|
|
* @param entry_items a list with `QStandardItem`s that make up the columns of the new entry.
|
|
*/
|
|
void DirEntryReady(GameListDir* entry_items);
|
|
void EntryReady(QList<QStandardItem*> entry_items, GameListDir* parent_dir);
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
void Finished(QStringList watch_list);
|
|
|
|
private:
|
|
void AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion,
|
|
GameListDir* parent_dir);
|
|
|
|
QStringList watch_list;
|
|
const std::unordered_map<std::string, std::pair<QString, QString>>& compatibility_list;
|
|
QList<UISettings::GameDir>& game_dirs;
|
|
std::atomic_bool stop_processing;
|
|
};
|