mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
DolphinQt2: Rename "Table"/"List" to "List View"/"Grid View"
Sentret_C posted this comment on Transifex recently: "What Dolphin refers to as "Table View" and "List View" are similar to "List View" and "Grid View" in Steam, and I think the Steam names describe them better." I agree with that, so here's a commit that changes the names.
This commit is contained in:
@ -25,8 +25,8 @@
|
||||
|
||||
#include "DolphinQt2/Config/PropertiesDialog.h"
|
||||
#include "DolphinQt2/GameList/GameList.h"
|
||||
#include "DolphinQt2/GameList/GridProxyModel.h"
|
||||
#include "DolphinQt2/GameList/ListProxyModel.h"
|
||||
#include "DolphinQt2/GameList/TableProxyModel.h"
|
||||
#include "DolphinQt2/QtUtils/DoubleClickEventFilter.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
|
||||
@ -35,59 +35,59 @@ static bool CompressCB(const std::string&, float, void*);
|
||||
GameList::GameList(QWidget* parent) : QStackedWidget(parent)
|
||||
{
|
||||
m_model = new GameListModel(this);
|
||||
m_table_proxy = new TableProxyModel(this);
|
||||
m_table_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
m_table_proxy->setSortRole(Qt::InitialSortOrderRole);
|
||||
m_table_proxy->setSourceModel(m_model);
|
||||
m_list_proxy = new ListProxyModel(this);
|
||||
m_list_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
m_list_proxy->setSortRole(Qt::InitialSortOrderRole);
|
||||
m_list_proxy->setSourceModel(m_model);
|
||||
m_grid_proxy = new GridProxyModel(this);
|
||||
m_grid_proxy->setSourceModel(m_model);
|
||||
|
||||
MakeTableView();
|
||||
MakeListView();
|
||||
MakeGridView();
|
||||
MakeEmptyView();
|
||||
|
||||
connect(m_table, &QTableView::doubleClicked, this, &GameList::GameSelected);
|
||||
connect(m_list, &QListView::doubleClicked, this, &GameList::GameSelected);
|
||||
connect(m_list, &QTableView::doubleClicked, this, &GameList::GameSelected);
|
||||
connect(m_grid, &QListView::doubleClicked, this, &GameList::GameSelected);
|
||||
connect(&Settings::Instance(), &Settings::PathAdded, m_model, &GameListModel::DirectoryAdded);
|
||||
connect(&Settings::Instance(), &Settings::PathRemoved, m_model, &GameListModel::DirectoryRemoved);
|
||||
connect(m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange);
|
||||
connect(m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange);
|
||||
|
||||
addWidget(m_table);
|
||||
addWidget(m_list);
|
||||
addWidget(m_grid);
|
||||
addWidget(m_empty);
|
||||
m_prefer_table = Settings::Instance().GetPreferredView();
|
||||
m_prefer_list = Settings::Instance().GetPreferredView();
|
||||
ConsiderViewChange();
|
||||
}
|
||||
|
||||
void GameList::MakeTableView()
|
||||
void GameList::MakeListView()
|
||||
{
|
||||
m_table = new QTableView(this);
|
||||
m_table->setModel(m_table_proxy);
|
||||
m_list = new QTableView(this);
|
||||
m_list->setModel(m_list_proxy);
|
||||
|
||||
m_table->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_table->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_table->setAlternatingRowColors(true);
|
||||
m_table->setShowGrid(false);
|
||||
m_table->setSortingEnabled(true);
|
||||
m_table->setCurrentIndex(QModelIndex());
|
||||
m_table->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_table->setWordWrap(false);
|
||||
m_list->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_list->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_list->setAlternatingRowColors(true);
|
||||
m_list->setShowGrid(false);
|
||||
m_list->setSortingEnabled(true);
|
||||
m_list->setCurrentIndex(QModelIndex());
|
||||
m_list->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_list->setWordWrap(false);
|
||||
|
||||
connect(m_table, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
|
||||
connect(m_list, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
|
||||
|
||||
m_table->setColumnHidden(GameListModel::COL_PLATFORM, !SConfig::GetInstance().m_showSystemColumn);
|
||||
m_table->setColumnHidden(GameListModel::COL_ID, !SConfig::GetInstance().m_showIDColumn);
|
||||
m_table->setColumnHidden(GameListModel::COL_BANNER, !SConfig::GetInstance().m_showBannerColumn);
|
||||
m_table->setColumnHidden(GameListModel::COL_TITLE, !SConfig::GetInstance().m_showTitleColumn);
|
||||
m_table->setColumnHidden(GameListModel::COL_DESCRIPTION,
|
||||
!SConfig::GetInstance().m_showDescriptionColumn);
|
||||
m_table->setColumnHidden(GameListModel::COL_MAKER, !SConfig::GetInstance().m_showMakerColumn);
|
||||
m_table->setColumnHidden(GameListModel::COL_SIZE, !SConfig::GetInstance().m_showSizeColumn);
|
||||
m_table->setColumnHidden(GameListModel::COL_COUNTRY, !SConfig::GetInstance().m_showRegionColumn);
|
||||
m_table->setColumnHidden(GameListModel::COL_RATING, !SConfig::GetInstance().m_showStateColumn);
|
||||
m_list->setColumnHidden(GameListModel::COL_PLATFORM, !SConfig::GetInstance().m_showSystemColumn);
|
||||
m_list->setColumnHidden(GameListModel::COL_ID, !SConfig::GetInstance().m_showIDColumn);
|
||||
m_list->setColumnHidden(GameListModel::COL_BANNER, !SConfig::GetInstance().m_showBannerColumn);
|
||||
m_list->setColumnHidden(GameListModel::COL_TITLE, !SConfig::GetInstance().m_showTitleColumn);
|
||||
m_list->setColumnHidden(GameListModel::COL_DESCRIPTION,
|
||||
!SConfig::GetInstance().m_showDescriptionColumn);
|
||||
m_list->setColumnHidden(GameListModel::COL_MAKER, !SConfig::GetInstance().m_showMakerColumn);
|
||||
m_list->setColumnHidden(GameListModel::COL_SIZE, !SConfig::GetInstance().m_showSizeColumn);
|
||||
m_list->setColumnHidden(GameListModel::COL_COUNTRY, !SConfig::GetInstance().m_showRegionColumn);
|
||||
m_list->setColumnHidden(GameListModel::COL_RATING, !SConfig::GetInstance().m_showStateColumn);
|
||||
|
||||
QHeaderView* hor_header = m_table->horizontalHeader();
|
||||
QHeaderView* hor_header = m_list->horizontalHeader();
|
||||
|
||||
connect(hor_header, &QHeaderView::sortIndicatorChanged, this, &GameList::OnHeaderViewChanged);
|
||||
connect(hor_header, &QHeaderView::sectionResized, this, &GameList::OnHeaderViewChanged);
|
||||
@ -107,8 +107,8 @@ void GameList::MakeTableView()
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_DESCRIPTION, QHeaderView::Stretch);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_RATING, QHeaderView::ResizeToContents);
|
||||
|
||||
m_table->verticalHeader()->hide();
|
||||
m_table->setFrameStyle(QFrame::NoFrame);
|
||||
m_list->verticalHeader()->hide();
|
||||
m_list->setFrameStyle(QFrame::NoFrame);
|
||||
}
|
||||
|
||||
void GameList::MakeEmptyView()
|
||||
@ -128,16 +128,16 @@ void GameList::MakeEmptyView()
|
||||
});
|
||||
}
|
||||
|
||||
void GameList::MakeListView()
|
||||
void GameList::MakeGridView()
|
||||
{
|
||||
m_list = new QListView(this);
|
||||
m_list->setModel(m_list_proxy);
|
||||
m_list->setViewMode(QListView::IconMode);
|
||||
m_list->setResizeMode(QListView::Adjust);
|
||||
m_list->setUniformItemSizes(true);
|
||||
m_list->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_list->setFrameStyle(QFrame::NoFrame);
|
||||
connect(m_list, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
|
||||
m_grid = new QListView(this);
|
||||
m_grid->setModel(m_grid_proxy);
|
||||
m_grid->setViewMode(QListView::IconMode);
|
||||
m_grid->setResizeMode(QListView::Adjust);
|
||||
m_grid->setUniformItemSizes(true);
|
||||
m_grid->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_grid->setFrameStyle(QFrame::NoFrame);
|
||||
connect(m_grid, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
|
||||
}
|
||||
|
||||
void GameList::ShowContextMenu(const QPoint&)
|
||||
@ -383,16 +383,16 @@ QString GameList::GetSelectedGame() const
|
||||
{
|
||||
QAbstractItemView* view;
|
||||
QSortFilterProxyModel* proxy;
|
||||
if (currentWidget() == m_table)
|
||||
{
|
||||
view = m_table;
|
||||
proxy = m_table_proxy;
|
||||
}
|
||||
else
|
||||
if (currentWidget() == m_list)
|
||||
{
|
||||
view = m_list;
|
||||
proxy = m_list_proxy;
|
||||
}
|
||||
else
|
||||
{
|
||||
view = m_grid;
|
||||
proxy = m_grid_proxy;
|
||||
}
|
||||
QItemSelectionModel* sel_model = view->selectionModel();
|
||||
if (sel_model->hasSelection())
|
||||
{
|
||||
@ -402,10 +402,10 @@ QString GameList::GetSelectedGame() const
|
||||
return QStringLiteral("");
|
||||
}
|
||||
|
||||
void GameList::SetPreferredView(bool table)
|
||||
void GameList::SetPreferredView(bool list)
|
||||
{
|
||||
m_prefer_table = table;
|
||||
Settings::Instance().SetPreferredView(table);
|
||||
m_prefer_list = list;
|
||||
Settings::Instance().SetPreferredView(list);
|
||||
ConsiderViewChange();
|
||||
}
|
||||
|
||||
@ -413,10 +413,10 @@ void GameList::ConsiderViewChange()
|
||||
{
|
||||
if (m_model->rowCount(QModelIndex()) > 0)
|
||||
{
|
||||
if (m_prefer_table)
|
||||
setCurrentWidget(m_table);
|
||||
else
|
||||
if (m_prefer_list)
|
||||
setCurrentWidget(m_list);
|
||||
else
|
||||
setCurrentWidget(m_grid);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -444,13 +444,13 @@ void GameList::OnColumnVisibilityToggled(const QString& row, bool visible)
|
||||
{tr("Title"), GameListModel::COL_TITLE},
|
||||
{tr("State"), GameListModel::COL_RATING}};
|
||||
|
||||
m_table->setColumnHidden(rowname_to_col_index[row], !visible);
|
||||
m_list->setColumnHidden(rowname_to_col_index[row], !visible);
|
||||
}
|
||||
|
||||
void GameList::OnGameListVisibilityChanged()
|
||||
{
|
||||
m_table_proxy->invalidate();
|
||||
m_list_proxy->invalidate();
|
||||
m_grid_proxy->invalidate();
|
||||
}
|
||||
|
||||
static bool CompressCB(const std::string& text, float percent, void* ptr)
|
||||
@ -466,5 +466,5 @@ static bool CompressCB(const std::string& text, float percent, void* ptr)
|
||||
void GameList::OnHeaderViewChanged()
|
||||
{
|
||||
QSettings().setValue(QStringLiteral("tableheader/state"),
|
||||
m_table->horizontalHeader()->saveState());
|
||||
m_list->horizontalHeader()->saveState());
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ public:
|
||||
explicit GameList(QWidget* parent = nullptr);
|
||||
QString GetSelectedGame() const;
|
||||
|
||||
void SetTableView() { SetPreferredView(true); }
|
||||
void SetListView() { SetPreferredView(false); }
|
||||
void SetViewColumn(int col, bool view) { m_table->setColumnHidden(col, !view); }
|
||||
void SetListView() { SetPreferredView(true); }
|
||||
void SetGridView() { SetPreferredView(false); }
|
||||
void SetViewColumn(int col, bool view) { m_list->setColumnHidden(col, !view); }
|
||||
void OnColumnVisibilityToggled(const QString& row, bool visible);
|
||||
void OnGameListVisibilityChanged();
|
||||
|
||||
@ -46,21 +46,21 @@ private:
|
||||
void CompressISO();
|
||||
void OnHeaderViewChanged();
|
||||
|
||||
void MakeTableView();
|
||||
void MakeListView();
|
||||
void MakeGridView();
|
||||
void MakeEmptyView();
|
||||
// We only have two views, just use a bool to distinguish.
|
||||
void SetPreferredView(bool table);
|
||||
void SetPreferredView(bool list);
|
||||
void ConsiderViewChange();
|
||||
|
||||
GameListModel* m_model;
|
||||
QSortFilterProxyModel* m_table_proxy;
|
||||
QSortFilterProxyModel* m_list_proxy;
|
||||
QSortFilterProxyModel* m_grid_proxy;
|
||||
|
||||
QListView* m_list;
|
||||
QTableView* m_table;
|
||||
QListView* m_grid;
|
||||
QTableView* m_list;
|
||||
QLabel* m_empty;
|
||||
bool m_prefer_table;
|
||||
bool m_prefer_list;
|
||||
|
||||
protected:
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
|
42
Source/Core/DolphinQt2/GameList/GridProxyModel.cpp
Normal file
42
Source/Core/DolphinQt2/GameList/GridProxyModel.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright 2015 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QSize>
|
||||
|
||||
#include "DolphinQt2/GameList/GameListModel.h"
|
||||
#include "DolphinQt2/GameList/GridProxyModel.h"
|
||||
|
||||
const QSize LARGE_BANNER_SIZE(144, 48);
|
||||
|
||||
GridProxyModel::GridProxyModel(QObject* parent) : QSortFilterProxyModel(parent)
|
||||
{
|
||||
setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
sort(GameListModel::COL_TITLE);
|
||||
}
|
||||
|
||||
QVariant GridProxyModel::data(const QModelIndex& i, int role) const
|
||||
{
|
||||
QModelIndex source_index = mapToSource(i);
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
return sourceModel()->data(sourceModel()->index(source_index.row(), GameListModel::COL_TITLE),
|
||||
Qt::DisplayRole);
|
||||
}
|
||||
else if (role == Qt::DecorationRole)
|
||||
{
|
||||
auto pixmap = sourceModel()
|
||||
->data(sourceModel()->index(source_index.row(), GameListModel::COL_BANNER),
|
||||
Qt::DecorationRole)
|
||||
.value<QPixmap>();
|
||||
return pixmap.scaled(LARGE_BANNER_SIZE * pixmap.devicePixelRatio(), Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool GridProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||
{
|
||||
GameListModel* glm = qobject_cast<GameListModel*>(sourceModel());
|
||||
return glm->ShouldDisplayGameListItem(source_row);
|
||||
}
|
19
Source/Core/DolphinQt2/GameList/GridProxyModel.h
Normal file
19
Source/Core/DolphinQt2/GameList/GridProxyModel.h
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2015 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
// This subclass of QSortFilterProxyModel transforms the raw data into a
|
||||
// single-column large icon + name to be displayed in a QListView.
|
||||
class GridProxyModel final : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GridProxyModel(QObject* parent = nullptr);
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
|
||||
};
|
@ -1,38 +1,12 @@
|
||||
// Copyright 2015 Dolphin Emulator Project
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QSize>
|
||||
|
||||
#include "DolphinQt2/GameList/GameListModel.h"
|
||||
#include "DolphinQt2/GameList/ListProxyModel.h"
|
||||
|
||||
const QSize LARGE_BANNER_SIZE(144, 48);
|
||||
#include "DolphinQt2/GameList/GameListModel.h"
|
||||
|
||||
ListProxyModel::ListProxyModel(QObject* parent) : QSortFilterProxyModel(parent)
|
||||
{
|
||||
setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
sort(GameListModel::COL_TITLE);
|
||||
}
|
||||
|
||||
QVariant ListProxyModel::data(const QModelIndex& i, int role) const
|
||||
{
|
||||
QModelIndex source_index = mapToSource(i);
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
return sourceModel()->data(sourceModel()->index(source_index.row(), GameListModel::COL_TITLE),
|
||||
Qt::DisplayRole);
|
||||
}
|
||||
else if (role == Qt::DecorationRole)
|
||||
{
|
||||
auto pixmap = sourceModel()
|
||||
->data(sourceModel()->index(source_index.row(), GameListModel::COL_BANNER),
|
||||
Qt::DecorationRole)
|
||||
.value<QPixmap>();
|
||||
return pixmap.scaled(LARGE_BANNER_SIZE * pixmap.devicePixelRatio(), Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool ListProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2015 Dolphin Emulator Project
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
@ -6,14 +6,12 @@
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
// This subclass of QSortFilterProxyModel transforms the raw data into a
|
||||
// single-column large icon + name to be displayed in a QListView.
|
||||
// This subclass of QSortFilterProxyModel allows the data to be filtered by the view.
|
||||
class ListProxyModel final : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ListProxyModel(QObject* parent = nullptr);
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
|
||||
};
|
||||
|
@ -1,16 +0,0 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DolphinQt2/GameList/TableProxyModel.h"
|
||||
#include "DolphinQt2/GameList/GameListModel.h"
|
||||
|
||||
TableProxyModel::TableProxyModel(QObject* parent) : QSortFilterProxyModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool TableProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||
{
|
||||
GameListModel* glm = qobject_cast<GameListModel*>(sourceModel());
|
||||
return glm->ShouldDisplayGameListItem(source_row);
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
// This subclass of QSortFilterProxyModel allows the data to be filtered by the view.
|
||||
class TableProxyModel final : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TableProxyModel(QObject* parent = nullptr);
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
|
||||
};
|
Reference in New Issue
Block a user