2020-08-01 16:57:12 +00:00
|
|
|
#pragma once
|
|
|
|
#include "core/types.h"
|
2020-09-01 02:29:22 +00:00
|
|
|
#include "frontend-common/game_list.h"
|
2020-08-01 16:57:12 +00:00
|
|
|
#include <QtCore/QAbstractTableModel>
|
|
|
|
#include <QtGui/QPixmap>
|
2020-09-23 14:02:13 +00:00
|
|
|
#include <algorithm>
|
2020-08-01 16:57:12 +00:00
|
|
|
#include <array>
|
|
|
|
#include <optional>
|
2020-09-23 14:02:13 +00:00
|
|
|
#include <unordered_map>
|
2020-08-01 16:57:12 +00:00
|
|
|
|
|
|
|
class GameListModel final : public QAbstractTableModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Column : int
|
|
|
|
{
|
|
|
|
Column_Type,
|
|
|
|
Column_Code,
|
|
|
|
Column_Title,
|
|
|
|
Column_FileTitle,
|
2021-04-17 04:23:47 +00:00
|
|
|
Column_Developer,
|
|
|
|
Column_Publisher,
|
|
|
|
Column_Genre,
|
|
|
|
Column_Year,
|
|
|
|
Column_Players,
|
2020-08-01 16:57:12 +00:00
|
|
|
Column_Size,
|
|
|
|
Column_Region,
|
|
|
|
Column_Compatibility,
|
2020-09-23 14:02:13 +00:00
|
|
|
Column_Cover,
|
2020-08-01 16:57:12 +00:00
|
|
|
|
|
|
|
Column_Count
|
|
|
|
};
|
|
|
|
|
|
|
|
static std::optional<Column> getColumnIdForName(std::string_view name);
|
|
|
|
static const char* getColumnName(Column col);
|
|
|
|
|
|
|
|
GameListModel(GameList* game_list, QObject* parent = nullptr);
|
|
|
|
~GameListModel();
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
|
|
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
|
|
|
|
|
|
ALWAYS_INLINE const QString& getColumnDisplayName(int column) { return m_column_display_names[column]; }
|
|
|
|
|
|
|
|
void refresh();
|
|
|
|
|
|
|
|
bool titlesLessThan(int left_row, int right_row, bool ascending) const;
|
|
|
|
|
|
|
|
bool lessThan(const QModelIndex& left_index, const QModelIndex& right_index, int column, bool ascending) const;
|
|
|
|
|
2020-09-23 14:02:13 +00:00
|
|
|
bool getShowCoverTitles() const { return m_show_titles_for_covers; }
|
|
|
|
void setShowCoverTitles(bool enabled) { m_show_titles_for_covers = enabled; }
|
|
|
|
|
|
|
|
float getCoverScale() const { return m_cover_scale; }
|
|
|
|
void setCoverScale(float scale);
|
|
|
|
int getCoverArtWidth() const;
|
|
|
|
int getCoverArtHeight() const;
|
|
|
|
int getCoverArtSpacing() const;
|
2020-09-23 14:08:29 +00:00
|
|
|
void refreshCovers();
|
2020-09-23 14:02:13 +00:00
|
|
|
|
2020-08-01 16:57:12 +00:00
|
|
|
private:
|
|
|
|
void loadCommonImages();
|
|
|
|
void setColumnDisplayNames();
|
|
|
|
|
|
|
|
GameList* m_game_list;
|
2020-09-23 14:02:13 +00:00
|
|
|
float m_cover_scale = 1.0f;
|
|
|
|
bool m_show_titles_for_covers = false;
|
2020-08-01 16:57:12 +00:00
|
|
|
|
|
|
|
std::array<QString, Column_Count> m_column_display_names;
|
|
|
|
|
|
|
|
QPixmap m_type_disc_pixmap;
|
|
|
|
QPixmap m_type_exe_pixmap;
|
2020-08-15 10:39:11 +00:00
|
|
|
QPixmap m_type_playlist_pixmap;
|
2021-01-24 04:24:13 +00:00
|
|
|
QPixmap m_type_psf_pixmap;
|
2020-08-01 16:57:12 +00:00
|
|
|
|
2020-09-10 10:47:59 +00:00
|
|
|
QPixmap m_region_jp_pixmap;
|
|
|
|
QPixmap m_region_eu_pixmap;
|
|
|
|
QPixmap m_region_us_pixmap;
|
2021-01-24 04:24:13 +00:00
|
|
|
QPixmap m_region_other_pixmap;
|
2020-08-01 16:57:12 +00:00
|
|
|
|
|
|
|
std::array<QPixmap, static_cast<int>(GameListCompatibilityRating::Count)> m_compatibiliy_pixmaps;
|
2020-09-23 14:02:13 +00:00
|
|
|
mutable std::unordered_map<std::string, QPixmap> m_cover_pixmap_cache;
|
2020-08-01 16:57:12 +00:00
|
|
|
};
|