gamelistwidget.h (3132B)
1 // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com> 2 // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) 3 4 #pragma once 5 #include "ui_emptygamelistwidget.h" 6 #include "ui_gamelistwidget.h" 7 8 #include "core/game_list.h" 9 10 #include <QtWidgets/QListView> 11 #include <QtWidgets/QTableView> 12 13 Q_DECLARE_METATYPE(const GameList::Entry*); 14 15 class GameListModel; 16 class GameListSortModel; 17 class GameListRefreshThread; 18 19 class GameListGridListView : public QListView 20 { 21 Q_OBJECT 22 23 public: 24 GameListGridListView(QWidget* parent = nullptr); 25 26 Q_SIGNALS: 27 void zoomOut(); 28 void zoomIn(); 29 30 protected: 31 void wheelEvent(QWheelEvent* e); 32 }; 33 34 class GameListWidget : public QWidget 35 { 36 Q_OBJECT 37 38 public: 39 GameListWidget(QWidget* parent = nullptr); 40 ~GameListWidget(); 41 42 ALWAYS_INLINE GameListModel* getModel() const { return m_model; } 43 44 void initialize(); 45 void resizeTableViewColumnsToFit(); 46 47 void refresh(bool invalidate_cache); 48 void refreshModel(); 49 void cancelRefresh(); 50 void reloadThemeSpecificImages(); 51 52 bool isShowingGameList() const; 53 bool isShowingGameGrid() const; 54 bool isShowingGridCoverTitles() const; 55 bool isMergingDiscSets() const; 56 bool isShowingGameIcons() const; 57 58 const GameList::Entry* getSelectedEntry() const; 59 60 Q_SIGNALS: 61 void refreshProgress(const QString& status, int current, int total); 62 void refreshComplete(); 63 64 void selectionChanged(); 65 void entryActivated(); 66 void entryContextMenuRequested(const QPoint& point); 67 68 void addGameDirectoryRequested(); 69 void layoutChange(); 70 71 private Q_SLOTS: 72 void onRefreshProgress(const QString& status, int current, int total, float time); 73 void onRefreshComplete(); 74 75 void onSelectionModelCurrentChanged(const QModelIndex& current, const QModelIndex& previous); 76 void onTableViewItemActivated(const QModelIndex& index); 77 void onTableViewContextMenuRequested(const QPoint& point); 78 void onTableViewHeaderContextMenuRequested(const QPoint& point); 79 void onTableViewHeaderSortIndicatorChanged(int, Qt::SortOrder); 80 void onListViewItemActivated(const QModelIndex& index); 81 void onListViewContextMenuRequested(const QPoint& point); 82 void onCoverScaleChanged(); 83 84 public Q_SLOTS: 85 void showGameList(); 86 void showGameGrid(); 87 void setShowCoverTitles(bool enabled); 88 void setMergeDiscSets(bool enabled); 89 void setShowGameIcons(bool enabled); 90 void gridZoomIn(); 91 void gridZoomOut(); 92 void gridIntScale(int int_scale); 93 void refreshGridCovers(); 94 95 protected: 96 void resizeEvent(QResizeEvent* event); 97 98 private: 99 void loadTableViewColumnVisibilitySettings(); 100 void saveTableViewColumnVisibilitySettings(); 101 void saveTableViewColumnVisibilitySettings(int column); 102 void loadTableViewColumnSortSettings(); 103 void saveTableViewColumnSortSettings(); 104 void listZoom(float delta); 105 void updateToolbar(); 106 107 Ui::GameListWidget m_ui; 108 109 GameListModel* m_model = nullptr; 110 GameListSortModel* m_sort_model = nullptr; 111 QTableView* m_table_view = nullptr; 112 GameListGridListView* m_list_view = nullptr; 113 114 QWidget* m_empty_widget = nullptr; 115 Ui::EmptyGameListWidget m_empty_ui; 116 117 GameListRefreshThread* m_refresh_thread = nullptr; 118 };