DolphinQt2: don't use custom delegate for GameList
This commit is contained in:
parent
aa33fabded
commit
e76f5d85b2
|
@ -22,7 +22,6 @@
|
||||||
#include "DolphinQt2/Config/PropertiesDialog.h"
|
#include "DolphinQt2/Config/PropertiesDialog.h"
|
||||||
#include "DolphinQt2/GameList/GameList.h"
|
#include "DolphinQt2/GameList/GameList.h"
|
||||||
#include "DolphinQt2/GameList/ListProxyModel.h"
|
#include "DolphinQt2/GameList/ListProxyModel.h"
|
||||||
#include "DolphinQt2/GameList/TableDelegate.h"
|
|
||||||
#include "DolphinQt2/Settings.h"
|
#include "DolphinQt2/Settings.h"
|
||||||
|
|
||||||
static bool CompressCB(const std::string&, float, void*);
|
static bool CompressCB(const std::string&, float, void*);
|
||||||
|
@ -35,8 +34,6 @@ GameList::GameList(QWidget* parent) : QStackedWidget(parent)
|
||||||
m_list_proxy = new ListProxyModel(this);
|
m_list_proxy = new ListProxyModel(this);
|
||||||
m_list_proxy->setSourceModel(m_model);
|
m_list_proxy->setSourceModel(m_model);
|
||||||
|
|
||||||
m_delegate = new TableDelegate(this);
|
|
||||||
|
|
||||||
MakeTableView();
|
MakeTableView();
|
||||||
MakeListView();
|
MakeListView();
|
||||||
MakeEmptyView();
|
MakeEmptyView();
|
||||||
|
@ -59,7 +56,7 @@ void GameList::MakeTableView()
|
||||||
{
|
{
|
||||||
m_table = new QTableView(this);
|
m_table = new QTableView(this);
|
||||||
m_table->setModel(m_table_proxy);
|
m_table->setModel(m_table_proxy);
|
||||||
m_table->setItemDelegate(m_delegate);
|
|
||||||
m_table->setSelectionMode(QAbstractItemView::SingleSelection);
|
m_table->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
m_table->setSelectionBehavior(QAbstractItemView::SelectRows);
|
m_table->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
m_table->setAlternatingRowColors(true);
|
m_table->setAlternatingRowColors(true);
|
||||||
|
@ -67,6 +64,7 @@ void GameList::MakeTableView()
|
||||||
m_table->setSortingEnabled(true);
|
m_table->setSortingEnabled(true);
|
||||||
m_table->setCurrentIndex(QModelIndex());
|
m_table->setCurrentIndex(QModelIndex());
|
||||||
m_table->setContextMenuPolicy(Qt::CustomContextMenu);
|
m_table->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
m_table->setWordWrap(false);
|
||||||
|
|
||||||
connect(m_table, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
|
connect(m_table, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,6 @@
|
||||||
#include "DolphinQt2/GameList/GameFile.h"
|
#include "DolphinQt2/GameList/GameFile.h"
|
||||||
#include "DolphinQt2/GameList/GameListModel.h"
|
#include "DolphinQt2/GameList/GameListModel.h"
|
||||||
|
|
||||||
class TableDelegate;
|
|
||||||
|
|
||||||
class GameList final : public QStackedWidget
|
class GameList final : public QStackedWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -56,7 +54,6 @@ private:
|
||||||
void ConsiderViewChange();
|
void ConsiderViewChange();
|
||||||
|
|
||||||
GameListModel* m_model;
|
GameListModel* m_model;
|
||||||
TableDelegate* m_delegate;
|
|
||||||
QSortFilterProxyModel* m_table_proxy;
|
QSortFilterProxyModel* m_table_proxy;
|
||||||
QSortFilterProxyModel* m_list_proxy;
|
QSortFilterProxyModel* m_list_proxy;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include "DolphinQt2/GameList/GameListModel.h"
|
#include "DolphinQt2/GameList/GameListModel.h"
|
||||||
#include "DolphinQt2/Resources.h"
|
#include "DolphinQt2/Resources.h"
|
||||||
|
|
||||||
|
const QSize GAMECUBE_BANNER_SIZE(96, 32);
|
||||||
|
|
||||||
GameListModel::GameListModel(QObject* parent) : QAbstractTableModel(parent)
|
GameListModel::GameListModel(QObject* parent) : QAbstractTableModel(parent)
|
||||||
{
|
{
|
||||||
connect(&m_tracker, &GameTracker::GameLoaded, this, &GameListModel::UpdateGame);
|
connect(&m_tracker, &GameTracker::GameLoaded, this, &GameListModel::UpdateGame);
|
||||||
|
@ -19,14 +21,29 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QSharedPointer<GameFile> game = m_games[index.row()];
|
QSharedPointer<GameFile> game = m_games[index.row()];
|
||||||
if (role == Qt::DisplayRole)
|
if (role == Qt::DecorationRole)
|
||||||
{
|
{
|
||||||
switch (index.column())
|
switch (index.column())
|
||||||
{
|
{
|
||||||
case COL_PLATFORM:
|
case COL_PLATFORM:
|
||||||
return static_cast<int>(game->GetPlatformID());
|
return Resources::GetPlatform(static_cast<int>(game->GetPlatformID()));
|
||||||
|
case COL_COUNTRY:
|
||||||
|
return Resources::GetCountry(static_cast<int>(game->GetCountryID()));
|
||||||
|
case COL_RATING:
|
||||||
|
return Resources::GetRating(game->GetRating());
|
||||||
case COL_BANNER:
|
case COL_BANNER:
|
||||||
return game->GetBanner();
|
// GameCube banners are 96x32, but Wii banners are 192x64.
|
||||||
|
// TODO: use custom banners from rom directory like DolphinWX?
|
||||||
|
QPixmap banner = game->GetBanner();
|
||||||
|
banner.setDevicePixelRatio(std::max(banner.width() / GAMECUBE_BANNER_SIZE.width(),
|
||||||
|
banner.height() / GAMECUBE_BANNER_SIZE.height()));
|
||||||
|
return banner;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (role == Qt::DisplayRole)
|
||||||
|
{
|
||||||
|
switch (index.column())
|
||||||
|
{
|
||||||
case COL_TITLE:
|
case COL_TITLE:
|
||||||
return game->GetLongName();
|
return game->GetLongName();
|
||||||
case COL_ID:
|
case COL_ID:
|
||||||
|
@ -36,11 +53,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
|
||||||
case COL_MAKER:
|
case COL_MAKER:
|
||||||
return game->GetMaker();
|
return game->GetMaker();
|
||||||
case COL_SIZE:
|
case COL_SIZE:
|
||||||
return game->GetFileSize();
|
return FormatSize(game->GetFileSize());
|
||||||
case COL_COUNTRY:
|
|
||||||
return static_cast<int>(game->GetCountryID());
|
|
||||||
case COL_RATING:
|
|
||||||
return game->GetRating();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "DolphinQt2/GameList/GameListModel.h"
|
#include "DolphinQt2/GameList/GameListModel.h"
|
||||||
#include "DolphinQt2/GameList/ListProxyModel.h"
|
#include "DolphinQt2/GameList/ListProxyModel.h"
|
||||||
|
|
||||||
static QSize LARGE_BANNER_SIZE(144, 48);
|
const QSize LARGE_BANNER_SIZE(144, 48);
|
||||||
|
|
||||||
ListProxyModel::ListProxyModel(QObject* parent) : QSortFilterProxyModel(parent)
|
ListProxyModel::ListProxyModel(QObject* parent) : QSortFilterProxyModel(parent)
|
||||||
{
|
{
|
||||||
|
@ -25,10 +25,12 @@ QVariant ListProxyModel::data(const QModelIndex& i, int role) const
|
||||||
}
|
}
|
||||||
else if (role == Qt::DecorationRole)
|
else if (role == Qt::DecorationRole)
|
||||||
{
|
{
|
||||||
return sourceModel()
|
auto pixmap = sourceModel()
|
||||||
->data(sourceModel()->index(source_index.row(), GameListModel::COL_BANNER), Qt::DisplayRole)
|
->data(sourceModel()->index(source_index.row(), GameListModel::COL_BANNER),
|
||||||
.value<QPixmap>()
|
Qt::DecorationRole)
|
||||||
.scaled(LARGE_BANNER_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
.value<QPixmap>();
|
||||||
|
return pixmap.scaled(LARGE_BANNER_SIZE * pixmap.devicePixelRatio(), Qt::KeepAspectRatio,
|
||||||
|
Qt::SmoothTransformation);
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue