mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-06-04 07:17:12 +02:00
[desktop] Rework game list to use MVP architecture (#4042)
Closes #3480 moves the game list model/worker/private stuff to qt_common for later use in QML - `qt_common/game_list/model.{cpp,h}` is the model - `yuzu/game/game_{grid,tree}.*` are the views - `yuzu/game/game_list.cpp` is the presenter This was done very lazily in a manner that "works" while largely maintaining existing structure as much as possible. Most of it is copy-paste, with some bonus reworks/cleanups thrown in. Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4042 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: Lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
27189f39d2
commit
cc8451f764
25 changed files with 1307 additions and 1045 deletions
98
src/qt_common/game_list/model.h
Normal file
98
src/qt_common/game_list/model.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QStandardItemModel>
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
#include <memory>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "frontend_common/play_time_manager.h"
|
||||
#include "qt_common/config/uisettings.h"
|
||||
#include "yuzu/compatibility_list.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
class GameListDir;
|
||||
class GameListWorker;
|
||||
class QStandardItem;
|
||||
|
||||
namespace FileSys {
|
||||
class ManualContentProvider;
|
||||
class VfsFilesystem;
|
||||
} // namespace FileSys
|
||||
|
||||
class GameListModel : public QStandardItemModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Column {
|
||||
COLUMN_NAME,
|
||||
COLUMN_FILE_TYPE,
|
||||
COLUMN_SIZE,
|
||||
COLUMN_PLAY_TIME,
|
||||
COLUMN_ADD_ONS,
|
||||
COLUMN_COMPATIBILITY,
|
||||
COLUMN_COUNT,
|
||||
};
|
||||
|
||||
explicit GameListModel(std::shared_ptr<FileSys::VfsFilesystem> vfs_,
|
||||
FileSys::ManualContentProvider* provider_,
|
||||
const PlayTime::PlayTimeManager& play_time_manager_,
|
||||
Core::System& system_, QObject* parent = nullptr);
|
||||
~GameListModel() override;
|
||||
|
||||
void AddDirEntry(GameListDir* entry_items);
|
||||
void AddEntry(const QList<QStandardItem*>& entry_items, GameListDir* parent);
|
||||
void DonePopulating(const QStringList& watch_list);
|
||||
|
||||
void PopulateAsync(QVector<UISettings::GameDir>& game_dirs);
|
||||
void WorkerEvent();
|
||||
|
||||
bool IsEmpty() const;
|
||||
|
||||
void ToggleFavorite(u64 program_id);
|
||||
|
||||
void RefreshGameDirectory();
|
||||
void RefreshExternalContent();
|
||||
void ResetExternalWatcher();
|
||||
|
||||
void LoadCompatibilityList();
|
||||
|
||||
void OnUpdateThemedIcons();
|
||||
void RetranslateUI();
|
||||
|
||||
QFileSystemWatcher* GetWatcher() const;
|
||||
|
||||
const CompatibilityList& GetCompatibilityList() const;
|
||||
|
||||
void SetFlat(bool flat);
|
||||
|
||||
signals:
|
||||
void ShowList(bool show);
|
||||
void PopulatingCompleted(const QStringList& watch_list);
|
||||
void SaveConfig();
|
||||
|
||||
private:
|
||||
friend class GameListWorker;
|
||||
|
||||
void AddFavorite(u64 program_id);
|
||||
void RemoveFavorite(u64 program_id);
|
||||
|
||||
bool m_flat = false;
|
||||
|
||||
std::shared_ptr<FileSys::VfsFilesystem> vfs;
|
||||
FileSys::ManualContentProvider* provider;
|
||||
CompatibilityList compatibility_list;
|
||||
const PlayTime::PlayTimeManager& play_time_manager;
|
||||
Core::System& system;
|
||||
|
||||
std::unique_ptr<GameListWorker> current_worker;
|
||||
QFileSystemWatcher* watcher = nullptr;
|
||||
QFileSystemWatcher* external_watcher = nullptr;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue