summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/GameList/GameList.h
blob: 0c00811743e5c55fd048ba83c02f8f0775ed0aa0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright 2015 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <memory>

#include <QStackedWidget>

#include "DolphinQt/GameList/GameListModel.h"

class QAbstractItemView;
class QLabel;
class QListView;
class QSortFilterProxyModel;
class QTableView;

namespace UICommon
{
class GameFile;
}

class GameList final : public QStackedWidget
{
  Q_OBJECT

public:
  explicit GameList(QWidget* parent = nullptr);
  ~GameList() override;

  std::shared_ptr<const UICommon::GameFile> GetSelectedGame() const;
  QList<std::shared_ptr<const UICommon::GameFile>> GetSelectedGames() const;
  bool HasMultipleSelected() const;
  std::shared_ptr<const UICommon::GameFile> FindGame(const std::string& path) const;
  std::shared_ptr<const UICommon::GameFile> FindSecondDisc(const UICommon::GameFile& game) const;
  std::string GetNetPlayName(const UICommon::GameFile& game) const;

  void SetListView() { SetPreferredView(true); }
  void SetGridView() { SetPreferredView(false); }
  void SetViewColumn(int col, bool view);
  void SetSearchTerm(const QString& term);

  void OnColumnVisibilityToggled(const QString& row, bool visible);
  void OnGameListVisibilityChanged();

  void UpdateGameCount() const;

  void resizeEvent(QResizeEvent* event) override;

  void PurgeCache();

  const GameListModel& GetGameListModel() const { return m_model; }

signals:
  void GameSelected();
  void GameCountUpdated(int total_games, int visible_games) const;
  void OnStartWithRiivolution(const UICommon::GameFile& game);
  void NetPlayHost(const UICommon::GameFile& game);
  void SelectionChanged(const std::shared_ptr<const UICommon::GameFile>& game_file);
  void OpenGeneralSettings();
  void OpenGraphicsSettings();
#ifdef USE_RETRO_ACHIEVEMENTS
  void OpenAchievementSettings();
#endif  // USE_RETRO_ACHIEVEMENTS

private:
  void ShowHeaderContextMenu(const QPoint& pos);
  void ShowContextMenu(const QPoint&);
  void OpenContainingFolder();
  void OpenProperties();
  void OpenWiiSaveFolder();
  void OpenGCSaveFolder();
  void OpenWiki();
  void StartWithRiivolution();
  void SetDefaultISO();
  void DeleteFile();
#ifdef _WIN32
  bool AddShortcutToDesktop();
#endif
  void InstallWAD();
  void UninstallWAD();
  void ExportWiiSave();
  void ConvertFile();
  void ChangeDisc();
  void NewTag();
  void DeleteTag();
  void UpdateColumnVisibility();

  void ZoomIn();
  void ZoomOut();

  void OnHeaderViewChanged();
  void OnSectionResized(int index, int, int);

  void MakeListView();
  void MakeGridView();
  void MakeEmptyView();
  // We only have two views, just use a bool to distinguish.
  void SetPreferredView(bool list);
  QAbstractItemView* GetActiveView() const;
  QSortFilterProxyModel* GetActiveProxyModel() const;
  void ConsiderViewChange();
  void UpdateFont();

  GameListModel m_model;
  QSortFilterProxyModel* m_list_proxy;
  QSortFilterProxyModel* m_grid_proxy;

  QListView* m_grid;
  QTableView* m_list;
  QLabel* m_empty;
  bool m_prefer_list;

protected:
  void keyPressEvent(QKeyEvent* event) override;
};