Skip to content
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

Merged
merged 1 commit into from
Jul 26, 2017

Conversation

grimpunch
Copy link

Porting the View config logic from WX to Qt for Show Platforms & Show Regions.
Adds to the View Menu.

Copy link
Contributor

@sepalani sepalani left a 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.

@@ -0,0 +1,16 @@
// Copyright 2015 Dolphin Emulator Project

This comment was marked as off-topic.

beginInsertRows(QModelIndex(), entry, entry);
m_games.insert(entry, game);
endInsertRows();
endInsertRows();

This comment was marked as off-topic.

@grimpunch
Copy link
Author

The above issues are fixed now, @sepalani

Copy link
Contributor

@sepalani sepalani left a 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.

@@ -148,6 +205,7 @@ void GameListModel::UpdateGame(QSharedPointer<GameFile> game)
else
return;


This comment was marked as off-topic.

public:
explicit TableProxyModel(QObject* parent = nullptr);
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;

This comment was marked as off-topic.

Copy link
Contributor

@spycrab spycrab left a 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.

bool ListProxyModel::filterAcceptsRow(int sourceRow,
const QModelIndex &sourceParent) const
{
GameListModel *glm = qobject_cast<GameListModel *>(sourceModel());

This comment was marked as off-topic.

QSharedPointer<GameFile> game = m_games[index.row()];


const bool show_platform = [&game] {

This comment was marked as off-topic.

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


public:
explicit TableProxyModel(QObject* parent = nullptr);
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;

This comment was marked as off-topic.

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

{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.

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

m_list_proxy->invalidate();
}

void GameList::OnGameListRegionVisibilityToggled()

This comment was marked as off-topic.

@mimimi085181
Copy link
Contributor

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:

Link your upstream to the official master(only once):
git remote add upstream https://github.com/dolphin-emu/dolphin.git

Rebase on top of latest master:
git pull --rebase upstream master

@JosJuice
Copy link
Member

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

@grimpunch
Copy link
Author

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.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

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

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

@ligfx
Copy link
Contributor

ligfx commented Jul 14, 2017

Looks pretty good, couple comments.

I do wonder if we might want to extract the filterAcceptsRow logic into it's own proxy model that the others pull from (e.g. list and table proxy models <- region/platform filter proxy model <- game list model), but that's not necessary right now.

Copy link
Contributor

@MayImilae MayImilae left a 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!

@grimpunch grimpunch force-pushed the qt_viewoptions branch 2 times, most recently from ba84e21 to 6364c0f Compare July 17, 2017 11:55
@grimpunch
Copy link
Author

Rebased after making requested changes and squashing them.

@grimpunch
Copy link
Author

Addressed linting errors, amended commit.

@grimpunch
Copy link
Author

@spycrab @sepalani , I think everything is okay now if you have a chance to look over it. 👍

Copy link
Contributor

@ligfx ligfx left a 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.

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.

Copy link
Contributor

@spycrab spycrab left a 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);

@grimpunch
Copy link
Author

Thanks @spycrab , think linter should be happy with this one 🤞

@grimpunch
Copy link
Author

@ligfx & @sepalani , is it okay with you two?

Copy link
Contributor

@ligfx ligfx left a 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.

@sepalani
Copy link
Contributor

I'm not a Qt guy but besides what @ligfx mentioned for both filterAcceptsRow methods (which should also be changed in the header files) SGTM.

@grimpunch
Copy link
Author

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

Porting the View config logic from WX to Qt.
Adds to the View Menu
@grimpunch
Copy link
Author

@leoetlino , I changed the signature of ShouldDisplayGameListItem

@grimpunch
Copy link
Author

I'm happy with the state of this PR now, just for the record of whoever is merging it. 👍

@leoetlino leoetlino merged commit be83243 into dolphin-emu:master Jul 26, 2017
@grimpunch grimpunch deleted the qt_viewoptions branch July 26, 2017 09:26
@leoetlino leoetlino modified the milestone: Qt Sep 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

9 participants