-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qt: Implement Show Platforms / Show Regions #5786
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lint errors also need to be fixed.
@@ -0,0 +1,19 @@ | |||
// Copyright 2015 Dolphin Emulator Project |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -0,0 +1,16 @@ | |||
// Copyright 2015 Dolphin Emulator Project |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
beginInsertRows(QModelIndex(), entry, entry); | ||
m_games.insert(entry, game); | ||
endInsertRows(); | ||
endInsertRows(); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
The above issues are fixed now, @sepalani |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also please squash your commits into a single one?
bool GameListModel::ShouldDisplayGameListItem(const QModelIndex& index) { | ||
QSharedPointer<GameFile> game = m_games[index.row()]; | ||
|
||
|
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -148,6 +205,7 @@ void GameListModel::UpdateGame(QSharedPointer<GameFile> game) | |||
else | |||
return; | |||
|
|||
|
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
public: | ||
explicit TableProxyModel(QObject* parent = nullptr); | ||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; | ||
|
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the small mistakes here and there and the Linter error, looks pretty good to me.
Definitely well done for a first-time contribution!
bool TableProxyModel::filterAcceptsRow(int sourceRow, | ||
const QModelIndex &sourceParent) const | ||
{ | ||
GameListModel *glm = qobject_cast<GameListModel *>(sourceModel()); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
bool ListProxyModel::filterAcceptsRow(int sourceRow, | ||
const QModelIndex &sourceParent) const | ||
{ | ||
GameListModel *glm = qobject_cast<GameListModel *>(sourceModel()); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
QSharedPointer<GameFile> game = m_games[index.row()]; | ||
|
||
|
||
const bool show_platform = [&game] { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -13,4 +13,5 @@ class ListProxyModel final : public QSortFilterProxyModel | |||
public: | |||
explicit ListProxyModel(QObject* parent = nullptr); | |||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | |||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
||
public: | ||
explicit TableProxyModel(QObject* parent = nullptr); | ||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/DolphinQt2/MenuBar.cpp
Outdated
@@ -270,6 +273,66 @@ void MenuBar::AddTableColumnsMenu(QMenu* view_menu) | |||
} | |||
} | |||
|
|||
void MenuBar::AddShowPlatformsMenu(QMenu* view_menu) | |||
{ | |||
static const QMap<QString, bool*> platform_menu{ |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/DolphinQt2/MenuBar.cpp
Outdated
{tr("Show ELF/DOL"), &SConfig::GetInstance().m_ListElfDol}}; | ||
|
||
QActionGroup* platform_group = new QActionGroup(this); | ||
QMenu* plat_menu = view_menu->addMenu(tr("Show Platforms")); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -195,6 +195,10 @@ void MainWindow::ConnectMenuBar() | |||
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView); | |||
connect(m_menu_bar, &MenuBar::ColumnVisibilityToggled, m_game_list, | |||
&GameList::OnColumnVisibilityToggled); | |||
connect(m_menu_bar, &MenuBar::GameListPlatformVisibilityToggled, m_game_list, | |||
&GameList::OnGameListPlatformVisibilityToggled); | |||
connect(m_menu_bar, &MenuBar::GameListRegionVisibilityToggled, m_game_list, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
m_list_proxy->invalidate(); | ||
} | ||
|
||
void GameList::OnGameListRegionVisibilityToggled() |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This pr seems to break being able to sort the gamelist by platform. The JAP, PAL and USA are seperated from the rest on wx, because those are the actual main regions. If you copy wx 1:1, you need to seperate them the same way. Adding Korea to those 3 would make sense though, since that's the 4th known possible region of wiis. It might be a good idea to rebase the pr on top of latest master, because master contains a change related to the gamelist sorting. If you don't know how to do that, ask on irc, or look at my cheat sheet:
|
It doesn't make much sense that DolphinWX does that, because it's not actually filtering by region. (For instance, if you have a PAL game that shows up with a French flag, it doesn't show up if only PAL is selected, because "PAL" means "Europe flag" to DolphinWX.) I'm fine with doing a 1:1 copy of wx for now, though. |
Thanks for the advice. I am away for the weekend now so I will rebase my changes onto latest master , incorporate @spycrab 's suggestions and then push everything up on Monday or Tuesday :) |
default: | ||
return false; | ||
} | ||
}(); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -138,6 +138,63 @@ int GameListModel::columnCount(const QModelIndex& parent) const | |||
return NUM_COLS; | |||
} | |||
|
|||
bool GameListModel::ShouldDisplayGameListItem(const QModelIndex& index) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -50,6 +50,8 @@ class MenuBar final : public QMenuBar | |||
void ShowTable(); | |||
void ShowList(); | |||
void ColumnVisibilityToggled(const QString& row, bool visible); | |||
void GameListPlatformVisibilityToggled(const QString& row, bool visible); | |||
void GameListRegionVisibilityToggled(const QString& row, bool visible); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Looks pretty good, couple comments. I do wonder if we might want to extract the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The design looks good! The way WX has three separate has already been mentioned, but it doesn't quite work so I don't mind that it isn't here. So I'm going to go ahead and approve!
ba84e21
to
6364c0f
Compare
Rebased after making requested changes and squashing them. |
6364c0f
to
1ad5c78
Compare
Addressed linting errors, amended commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two additional code comments.
Also, the lint buildbot doesn't seem to be working correctly: it says "Invalid symmetric difference expression bcdab8a..." but returns successfully :/
EDIT: Okay, it worked properly after a rebuild. I guess it was some transitory error.
@@ -34,9 +35,7 @@ static bool CompressCB(const std::string&, float, void*); | |||
GameList::GameList(QWidget* parent) : QStackedWidget(parent) | |||
{ | |||
m_model = new GameListModel(this); | |||
m_table_proxy = new QSortFilterProxyModel(this); | |||
m_table_proxy->setSortCaseSensitivity(Qt::CaseInsensitive); | |||
m_table_proxy->setSortRole(Qt::InitialSortOrderRole); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
TableProxyModel::TableProxyModel(QObject* parent) : QSortFilterProxyModel(parent) | ||
{ | ||
setSortCaseSensitivity(Qt::CaseInsensitive); | ||
sort(GameListModel::COL_TITLE); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
1ad5c78
to
84a71bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you make the linter happy, good to go by me:
!!! Source/Core/DolphinQt2/MenuBar.cpp not compliant to coding style, here is the fix:
--- Source/Core/DolphinQt2/MenuBar.cpp 2017-07-18 10:21:02.321969281 +0000
+++ /dev/fd/63 2017-07-18 10:21:02.857974465 +0000
@@ -315,7 +315,7 @@
{tr("Show Taiwan"), &SConfig::GetInstance().m_ListTaiwan},
{tr("Show World"), &SConfig::GetInstance().m_ListWorld},
{tr("Show Unknown"), &SConfig::GetInstance().m_ListUnknown}};
-
+
QActionGroup* region_group = new QActionGroup(this);
QMenu* region_menu = view_menu->addMenu(tr("Show Regions"));
region_group->setExclusive(false);
84a71bf
to
894e6d7
Compare
Thanks @spycrab , think linter should be happy with this one 🤞 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing, then it's fine with me.
@@ -34,3 +34,9 @@ QVariant ListProxyModel::data(const QModelIndex& i, int role) const | |||
} | |||
return QVariant(); | |||
} | |||
|
|||
bool ListProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
I'm not a Qt guy but besides what @ligfx mentioned for both |
894e6d7
to
7e3940b
Compare
@ligfx , I've amended the commit. :) |
@@ -27,6 +27,7 @@ class GameListModel final : public QAbstractTableModel | |||
|
|||
// Path of the Game at the specified index. | |||
QString GetPath(int index) const { return m_games[index]->GetFilePath(); } | |||
bool ShouldDisplayGameListItem(const int index); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Porting the View config logic from WX to Qt. Adds to the View Menu
7e3940b
to
df35a26
Compare
@leoetlino , I changed the signature of ShouldDisplayGameListItem |
I'm happy with the state of this PR now, just for the record of whoever is merging it. 👍 |
Porting the View config logic from WX to Qt for Show Platforms & Show Regions.
Adds to the View Menu.