1 // Copyright 2015 Dolphin Emulator Project
2 // Licensed under GPLv2+
3 // Refer to the license.txt file included.
4 
5 #pragma once
6 
7 #include <memory>
8 
9 #include <QStackedWidget>
10 
11 class GameListModel;
12 class QLabel;
13 class QListView;
14 class QSortFilterProxyModel;
15 class QTableView;
16 
17 namespace UICommon
18 {
19 class GameFile;
20 }
21 
22 class GameList final : public QStackedWidget
23 {
24   Q_OBJECT
25 
26 public:
27   explicit GameList(QWidget* parent = nullptr);
28   ~GameList();
29 
30   std::shared_ptr<const UICommon::GameFile> GetSelectedGame() const;
31   QList<std::shared_ptr<const UICommon::GameFile>> GetSelectedGames() const;
32   bool HasMultipleSelected() const;
33   std::shared_ptr<const UICommon::GameFile> FindGame(const std::string& path) const;
34   std::shared_ptr<const UICommon::GameFile> FindSecondDisc(const UICommon::GameFile& game) const;
35   std::string GetNetPlayName(const UICommon::GameFile& game) const;
36 
SetListView()37   void SetListView() { SetPreferredView(true); }
SetGridView()38   void SetGridView() { SetPreferredView(false); }
39   void SetViewColumn(int col, bool view);
40   void SetSearchTerm(const QString& term);
41 
42   void OnColumnVisibilityToggled(const QString& row, bool visible);
43   void OnGameListVisibilityChanged();
44 
45   void resizeEvent(QResizeEvent* event) override;
46 
47   void PurgeCache();
48 
49 signals:
50   void GameSelected();
51   void NetPlayHost(const UICommon::GameFile& game);
52   void SelectionChanged(std::shared_ptr<const UICommon::GameFile> game_file);
53   void OpenGeneralSettings();
54 
55 private:
56   void ShowHeaderContextMenu(const QPoint& pos);
57   void ShowContextMenu(const QPoint&);
58   void OpenContainingFolder();
59   void OpenProperties();
60   void OpenWiiSaveFolder();
61   void OpenGCSaveFolder();
62   void OpenWiki();
63   void SetDefaultISO();
64   void DeleteFile();
65   void InstallWAD();
66   void UninstallWAD();
67   void ExportWiiSave();
68   void ConvertFile();
69   void ChangeDisc();
70   void NewTag();
71   void DeleteTag();
72   void UpdateColumnVisibility();
73 
74   void ZoomIn();
75   void ZoomOut();
76 
77   void OnHeaderViewChanged();
78   void OnSectionResized(int index, int, int);
79 
80   void MakeListView();
81   void MakeGridView();
82   void MakeEmptyView();
83   // We only have two views, just use a bool to distinguish.
84   void SetPreferredView(bool list);
85   void ConsiderViewChange();
86   void UpdateFont();
87 
88   GameListModel* m_model;
89   QSortFilterProxyModel* m_list_proxy;
90   QSortFilterProxyModel* m_grid_proxy;
91 
92   QListView* m_grid;
93   QTableView* m_list;
94   QLabel* m_empty;
95   bool m_prefer_list;
96 
97 protected:
98   void keyPressEvent(QKeyEvent* event) override;
99 };
100