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

DolphinQt: Add "File Path" column to Game Grid #8580

Merged
merged 2 commits into from Mar 6, 2020
Merged

DolphinQt: Add "File Path" column to Game Grid #8580

merged 2 commits into from Mar 6, 2020

Conversation

AlexApps99
Copy link
Contributor

@AlexApps99 AlexApps99 commented Jan 24, 2020

The path is generated by finding a file path that contains the filename, then removing the path to that path.

Example:
File paths: /home/foo/games, /home/foo/Desktop/wii
Game path: /home/foo/games/gcn/ntsc/fun game.gcn
File name listed: gcn/ntsc/fun game.gcn
File name listed: games/gcn/ntsc/fun game.gcn

dir.lastIndexOf uses -2 in the case that the file path ends with a trailing slash.

Fixes https://bugs.dolphin-emu.org/issues/10567

This is my first PR to Dolphin, so a thorough review would be awesome, and let me know if this would be better as its' own column instead of replacing "File name".

@MayImilae
Copy link
Contributor

Definitely make this a new column please.

@AlexApps99
Copy link
Contributor Author

Ok, do you have any other feedback?

@MayImilae
Copy link
Contributor

Nothing else for the moment. I'll give it a proper try tomorrow and give you additional feedback then, it's 2am here!

@AlexApps99 AlexApps99 changed the title Add path to File Name column of game grid DolphinQt: Add path to File Name column of game grid Jan 25, 2020
@AlexApps99 AlexApps99 changed the title DolphinQt: Add path to File Name column of game grid DolphinQt: Add "File Path" column to Game Grid Jan 25, 2020
@CookiePLMonster
Copy link
Contributor

Looks good, but is it hidden by default? I imagine this is one of those columns you'd rather default to hidden and allow the user to show it later.

@AlexApps99
Copy link
Contributor Author

AlexApps99 commented Jan 26, 2020

I think it isn't shown by default, but I haven't verified it

@CookiePLMonster
Copy link
Contributor

Please verify then. I'd also appreciate a screenshot as I'm curious how does this display.

@AlexApps99
Copy link
Contributor Author

Ok, deleted config from ~/.config/dolphin-emu/ and ran it.
It is hidden by default
image

@AlexApps99
Copy link
Contributor Author

AlexApps99 commented Jan 26, 2020

Screenshots of it in action
image

image

Copy link
Contributor

@CookiePLMonster CookiePLMonster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, you made it strip "common" parts of the path basing on Game Folders list. If I understand it correctly, then it doesn't work as intended on Windows:

image

image

EDIT:
You probably need to convert those QStrings to paths (QFileInfo?) and work from that.

@AlexApps99
Copy link
Contributor Author

The issue is that the path in Settings uses backslashes and the function to get the path uses forwardslashes.

I'll work on a fix right now

@CookiePLMonster
Copy link
Contributor

Hence my remark that you probably need to compare those as paths and not strings - it'd most likely save some headache with more edge cases and not just slashes.

@AlexApps99
Copy link
Contributor Author

Thanks for the advice, will do that

@AlexApps99
Copy link
Contributor Author

Is this implementation valid? It removes all symlinks/backslashes so the strings will be correctly formatted.

Otherwise, how would I check if a directory is contained in another? I couldn't find a function for this in QFileInfo's docs

Your feedback is appreciated

@CookiePLMonster
Copy link
Contributor

Sorry, I might have been mistaken. Looks like the function you need here is QDir::cleanPath.

So IMO you could erase your last commit by undoing everything in it and just filtering paths with this function, then you should be able to compare everything as you did previously.

As for erasing the commit, you could undo the changes, apply QDir::cleanPath changes, then amend the commit and rename it, then force push (it's fine since it's your own branch).

@AlexApps99
Copy link
Contributor Author

Done

@AlexApps99 AlexApps99 removed the request for review from JosJuice January 26, 2020 12:29
@AlexApps99
Copy link
Contributor Author

I gotta go to sleep now (1:30am here), thanks for all of the assistance so far @CookiePLMonster :)

@CookiePLMonster
Copy link
Contributor

CookiePLMonster commented Jan 26, 2020

Unfortunately it still seems to be invalid:

image

I will debug this in a few hours.

Or maybe I am misunderstanding this feature? How exactly do you expect it to work? Basing on your screenshots I expect my paths to be like

Crash Bandicoot...
Mario Kart...
MGS\Metal Gear...
PaperMario...

Copy link
Contributor

@CookiePLMonster CookiePLMonster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny, build artifacts for a force pushed build must have been incorrect since I built your branch locally and it works probably as expected:

image

@mbc07
Copy link
Contributor

mbc07 commented Jan 26, 2020

Shouldn't it display back slashes instead of forward slashes on Windows?

@CookiePLMonster
Copy link
Contributor

CookiePLMonster commented Jan 26, 2020

I don't think it matters. I'm not convinced you can get Qt to output a "platform natural" path, and that's what you'd need in this case.

Not true, QDir::toNativeSeparators performs exactly that conversion so we could apply this after comparison/slicing for "better" display style.

@AlexApps99
Copy link
Contributor Author

cleanPath will always output forwardslashes, I could either check the platform and replace all forwardslashes with backslashes, or find a different function.

@CookiePLMonster
Copy link
Contributor

I think performing comparisons and slicing on "clean" paths is a good idea - but may want to use "native separators" path for solely for displaying it to the user.

@AlexApps99
Copy link
Contributor Author

Maybe I could put the processed path back into QFileInfo or QDir and get a platform-native relative path

@CookiePLMonster
Copy link
Contributor

No need - QDir::toNativeSeparators should do exactly what you need :)

@AlexApps99
Copy link
Contributor Author

Awesome, will add that as soon as I can 👍

@CookiePLMonster
Copy link
Contributor

Excellent :)

image

Note to self: Verify that paths display consistently everywhere, as right now in Game Folders I can see paths with both styles. Ideally, they should be stored in "clean" format (so they are cross platform) but stored in "native" format!

@CookiePLMonster
Copy link
Contributor

Hmm now that's interesting, did lint bot spot missing brackets or incorrect indentation? Could be both, depending on what you intended this code to do.

@AlexApps99
Copy link
Contributor Author

Yeah, it was missing brackets... Oops

@CookiePLMonster
Copy link
Contributor

One more nitpick - I see you have edited an example of how it is supposed to work (or it's been there and I am just blind), and it would seem like Game Folder path is not to be included in the shown path at all. Yet, if you see the screens I posted above for me dolphin-games still shows in those paths, despite being part of both game folder paths.

Any idea what's up with that?

@AlexApps99
Copy link
Contributor Author

That is a typo, the path shortening behaviour works as I intended it to
If you'd prefer that I remove the base folder path from the columns, that's fine too

@AlexApps99
Copy link
Contributor Author

@CookiePLMonster should I keep the current functionality or change it to reflect the old example?

@CookiePLMonster
Copy link
Contributor

@CookiePLMonster should I keep the current functionality or change it to reflect the old example?

For me the way it works now is good - let's wait for somebody else (preferably those who can merge) to comment on it too.

@AlexApps99
Copy link
Contributor Author

What else needs to be done to complete this PR?

@CookiePLMonster
Copy link
Contributor

What else needs to be done to complete this PR?

I would say it's finished. At this point just sit tight and wait until somebody who
a) is involved with UI
b) has merge rights
reviews it.

@Pokechu22
Copy link
Contributor

I've found a slight weird behavior: if one game folder is nested within another, then the way the path is shortened depends on which one comes first in the list. Listing like this:

F:\Test\Maindir, then F:\Test\Maindir\Subdir

gives this:

Maindir\a.dol, then Maindir\Subdir\b.dol

while listing like this:

F:\Test\Maindir\Subdir, then F:\Test\Maindir

gives this:

Maindir\a.dol, then Subdir\b.dol

This probably doesn't matter too much, though, since I suspect most people with a nested setup will just have search subfolders on. (Also, the F:\Test\ part was successfully stripped on Windows, so that at least is fixed.)

@AlexApps99
Copy link
Contributor Author

I did that because of simplicity, if it's a problem then I could try sort the paths by length before comparing so the most nested paths are checked first.

case COL_FILE_PATH:
if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
{
QString file_path = QDir::cleanPath(QString::fromStdString(game.GetFilePath()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little concerned about the performance impact of the logic here when used with very large game lists. But, I guess if the column is hidden by default, it shouldn't get executed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you suggest I improve the performance impact?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would probably require caching the string in the game list struct. But again, since it's not enabled by default, I don't think it matters all that much.

@MayImilae
Copy link
Contributor

Gave this a quick check. It's not enabled by default, and it all works as advertised!

However, I'm puzzled by the fact that it only shows one tree above the file name. Doesn't that greatly reduce its usefulness?

Here's an example, an issue that I've run into before that this PR could help with, but doesn't.

filepaths1

These two games appear exactly the same under this PR. However, if we take a peek at the full paths...

filepaths2-2
filepaths2-1

One is on my NAS, the other is local.

This is something that this PR could genuinely help with over just showing file names. I use my NAS for storing my games, but I do a local mirror of any game I'm playing through at the moment, with both paths accessible to Dolphin at all times. File names won't help with this, and neither would anything else in the GUI. Only file paths could help. But because this PR only goes up one level, it can't show that difference. It's no more useful than file names here.

Of course, I could rename the folder of my local mirror folder. But at that point, I could also just rename the local mirrored version of the iso's file name, which would work without this PR at all, so...

IMO, I think this PR should just show the full file path. Yes it'll be long, but it's useful in handling edge cases like the one I just outlined where file names are not sufficient. There are also other cases, like having games on a bulk storage drive and an SSD mirror that would this would also apply to. Just showing one folder up from the file name doesn't offer much.

As for the length, why not just show only the path and not the file name? Why have the file name present in the file path when there is a dedicated column for that? That would greatly cut down on the length of the file path column and uses can add the file name column if they want that information.

@AlexApps99
Copy link
Contributor Author

Those are good points you make, I'll use the full file path instead.

@AlexApps99
Copy link
Contributor Author

@MayImilae I've integrated the changes you have requested
image
Should I include the trailing slash? I'm unsure

@CookiePLMonster
Copy link
Contributor

Not to be "that guy", but I guess that if you're to show a full path after all then QFileInfo::path() may be better than tokenizing the path on your own?

@MayImilae
Copy link
Contributor

@AlexApps99 Much better! And yea, the final slash might be nice for combination things like this.

@AlexApps99
Copy link
Contributor Author

Using QFileInfo::path() is a good idea, I'll use that soon

@AlexApps99
Copy link
Contributor Author

It now uses QFileInfo, and the trailing slash is included too.
image

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.

Screen Shot 2020-03-03 at 15 36 58

LGTM!

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.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
8 participants