xbmc/xbmc — pull request #2986 by Montellese (2013-07-18 19:36:54+00:00)
Title: smartplaylist: implement sorting of grouped items

A while ago I implemented grouping for smartplaylist (e.g. make a movie smartplaylist and group the result into genres) but I didn't have an implementation for the sort order/direction back then yet. I finally had the time to look into it and came up with this solution.

With this it is possible to make a smartplaylist that e.g. retrieves all action movies, groups them into directors and shows the movies of a specific directory sorted by rating descending. So when opening the smartplaylist the user will see a list of directors that directed at least one action movie. When opening a specific director the user will see a list of action movies directed by that specific director and the list will be sorted by rating descending.

The first commit doesn't really belong here but I had to work through CGUIMediaWindow::Update() once again to see where the sorting information extraction would fit best and came across that refactorable code (and I'm too lazy to move it to a separate PR).

I also refactored CGUIViewState::AddPlaylistOrder() which was introduced by jmarshall a while ago and I turned it into CGUIViewState::AddAndSetSortMethod() which is a bit more generic and more "powerful".

Apart from that the only real change is the extraction of sort information from the "xsp" URL option in CGUIMediaWindow::OnPrepareFileItems(). I'm not 100% happy with that approach but it has to be done somewhere and I didn't want to duplicate the code in a ton of places in e.g. CVideoDatabase and CMusicDatabase. But if anyone has a better idea, I'm all ears.