Merge pull request #5886 from JosJuice/rename-list-table

DolphinQt2: Rename "Table"/"List" to "List View"/"Grid View"
This commit is contained in:
Anthony 2017-08-06 09:07:52 -07:00 committed by GitHub
commit 7a74e8ad0b
15 changed files with 155 additions and 157 deletions

View File

@ -63,8 +63,8 @@ set(SRCS
GameList/GameList.cpp
GameList/GameListModel.cpp
GameList/GameTracker.cpp
GameList/GridProxyModel.cpp
GameList/ListProxyModel.cpp
GameList/TableProxyModel.cpp
QtUtils/BlockUserInputFilter.cpp
QtUtils/DoubleClickEventFilter.cpp
QtUtils/ElidedButton.cpp

View File

@ -84,8 +84,8 @@
<QtMoc Include="GameList\GameList.h" />
<QtMoc Include="GameList\GameListModel.h" />
<QtMoc Include="GameList\GameTracker.h" />
<QtMoc Include="GameList\GridProxyModel.h" />
<QtMoc Include="GameList\ListProxyModel.h" />
<QtMoc Include="GameList\TableProxyModel.h" />
<QtMoc Include="Host.h" />
<QtMoc Include="HotkeyScheduler.h" />
<QtMoc Include="InDevelopmentWarning.h" />
@ -126,8 +126,8 @@
<ClCompile Include="$(QtMocOutPrefix)InfoWidget.cpp" />
<ClCompile Include="$(QtMocOutPrefix)InterfacePane.cpp" />
<ClCompile Include="$(QtMocOutPrefix)IOWindow.cpp" />
<ClCompile Include="$(QtMocOutPrefix)GridProxyModel.cpp" />
<ClCompile Include="$(QtMocOutPrefix)ListProxyModel.cpp" />
<ClCompile Include="$(QtMocOutPrefix)TableProxyModel.cpp" />
<ClCompile Include="$(QtMocOutPrefix)LoggerWidget.cpp" />
<ClCompile Include="$(QtMocOutPrefix)MainWindow.cpp" />
<ClCompile Include="$(QtMocOutPrefix)MappingButton.cpp" />
@ -181,8 +181,8 @@
<ClCompile Include="GameList\GameList.cpp" />
<ClCompile Include="GameList\GameListModel.cpp" />
<ClCompile Include="GameList\GameTracker.cpp" />
<ClCompile Include="GameList\GridProxyModel.cpp" />
<ClCompile Include="GameList\ListProxyModel.cpp" />
<ClCompile Include="GameList\TableProxyModel.cpp" />
<ClCompile Include="HotkeyScheduler.cpp" />
<ClCompile Include="Host.cpp" />
<ClCompile Include="InDevelopmentWarning.cpp" />

View File

@ -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());
}

View File

@ -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;

View 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);
}

View 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;
};

View File

@ -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

View File

@ -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;
};

View File

@ -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);
}

View File

@ -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;
};

View File

@ -197,8 +197,8 @@ void MainWindow::ConnectMenuBar()
connect(m_menu_bar, &MenuBar::BootWiiSystemMenu, this, &MainWindow::BootWiiSystemMenu);
// View
connect(m_menu_bar, &MenuBar::ShowTable, m_game_list, &GameList::SetTableView);
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
connect(m_menu_bar, &MenuBar::ShowGrid, m_game_list, &GameList::SetGridView);
connect(m_menu_bar, &MenuBar::ColumnVisibilityToggled, m_game_list,
&GameList::OnColumnVisibilityToggled);

View File

@ -215,7 +215,7 @@ void MenuBar::AddViewMenu()
AddGameListTypeSection(view_menu);
view_menu->addSeparator();
AddTableColumnsMenu(view_menu);
AddListColumnsMenu(view_menu);
view_menu->addSeparator();
AddShowPlatformsMenu(view_menu);
AddShowRegionsMenu(view_menu);
@ -253,27 +253,25 @@ void MenuBar::AddHelpMenu()
void MenuBar::AddGameListTypeSection(QMenu* view_menu)
{
// i18n: When this option is enabled, the game list is displayed as a table
QAction* table_view = view_menu->addAction(tr("Table"));
table_view->setCheckable(true);
// i18n: When this option is enabled, the game list is displayed as a list
QAction* list_view = view_menu->addAction(tr("List"));
QAction* list_view = view_menu->addAction(tr("List View"));
list_view->setCheckable(true);
QAction* grid_view = view_menu->addAction(tr("Grid View"));
grid_view->setCheckable(true);
QActionGroup* list_group = new QActionGroup(this);
list_group->addAction(table_view);
list_group->addAction(list_view);
list_group->addAction(grid_view);
bool prefer_table = Settings::Instance().GetPreferredView();
table_view->setChecked(prefer_table);
list_view->setChecked(!prefer_table);
bool prefer_list = Settings::Instance().GetPreferredView();
list_view->setChecked(prefer_list);
grid_view->setChecked(!prefer_list);
connect(table_view, &QAction::triggered, this, &MenuBar::ShowTable);
connect(list_view, &QAction::triggered, this, &MenuBar::ShowList);
connect(grid_view, &QAction::triggered, this, &MenuBar::ShowGrid);
}
void MenuBar::AddTableColumnsMenu(QMenu* view_menu)
void MenuBar::AddListColumnsMenu(QMenu* view_menu)
{
static const QMap<QString, bool*> columns{
{tr("Platform"), &SConfig::GetInstance().m_showSystemColumn},
@ -287,7 +285,7 @@ void MenuBar::AddTableColumnsMenu(QMenu* view_menu)
{tr("State"), &SConfig::GetInstance().m_showStateColumn}};
QActionGroup* column_group = new QActionGroup(this);
QMenu* cols_menu = view_menu->addMenu(tr("Table Columns"));
QMenu* cols_menu = view_menu->addMenu(tr("List Columns"));
column_group->setExclusive(false);
for (const auto& key : columns.keys())

View File

@ -60,8 +60,8 @@ signals:
void ConfigureHotkeys();
// View
void ShowTable();
void ShowList();
void ShowGrid();
void ColumnVisibilityToggled(const QString& row, bool visible);
void GameListPlatformVisibilityToggled(const QString& row, bool visible);
void GameListRegionVisibilityToggled(const QString& row, bool visible);
@ -78,7 +78,7 @@ private:
void AddViewMenu();
void AddGameListTypeSection(QMenu* view_menu);
void AddTableColumnsMenu(QMenu* view_menu);
void AddListColumnsMenu(QMenu* view_menu);
void AddShowPlatformsMenu(QMenu* view_menu);
void AddShowRegionsMenu(QMenu* view_menu);

View File

@ -77,9 +77,9 @@ bool Settings::GetPreferredView() const
return QSettings().value(QStringLiteral("PreferredView"), true).toBool();
}
void Settings::SetPreferredView(bool table)
void Settings::SetPreferredView(bool list)
{
QSettings().setValue(QStringLiteral("PreferredView"), table);
QSettings().setValue(QStringLiteral("PreferredView"), list);
}
int Settings::GetStateSlot() const

View File

@ -41,7 +41,7 @@ public:
void AddPath(const QString& path);
void RemovePath(const QString& path);
bool GetPreferredView() const;
void SetPreferredView(bool table);
void SetPreferredView(bool list);
// Emulation
int GetStateSlot() const;