Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Store sorting information for smartplaylists and library nodes #1686

Merged
16 commits merged into from

2 participants

jmarshallnz Sascha Montellese
jmarshallnz
Owner

Cosmetically, this allows the sort by label for library nodes and smartplaylist to be specific to the playlist (i.e. if the playlist is sort by date added, then that's what we'll use) rather than displaying the ambiguous "sort by playlist".

It also allows some of the grouping changes that @Montellese has been doing to work a little nicer, as we can re-sort the list after grouping without problems.

Sascha Montellese
Owner

Looks good to me and certainly would help one of the problems I'm having with grouping and sorting. Maybe we could add the string ID to the table in SortUtils instead of having to ask CSmartPlaylist about it? But I guess then the information would be duplicate.

Did I see that right that if the playlist has an order that isn't available to GUIViewStates (e.g. SortByVideoAspectRatio) that it will fall back to sorting by playlist? I guess in these cases there would still be a problem with sorting and grouping but the question remains if anyone actually uses those.

jmarshallnz
Owner

Yes - if the sort mode doesn't have a corresponding SORT_METHOD_* then it'll drop back to sorting by playlist. This has to remain that way at least until SORT_METHOD_* is replaced with SortBy*.

I thought about popping the string in the LUT - it would save inclusion of the smartplaylist header but have the disadvantage of duplicate information being present. Will see if I have time tomorrow to do it up, as I think it's better that way (and it gives something useful for the LUT to give once SORT_METHOD_* is gone.

xbmc/GUIViewState.cpp
@@ -469,6 +477,27 @@ void CGUIViewState::SaveViewToDb(const CStdString &path, int windowID, CViewStat
}
}
+void CGUIViewState::AddPlaylistOrder(const CFileItemList &items, LABEL_MASKS label_masks)
+{
+ SORT_METHOD sortMethod = SORT_METHOD_PLAYLIST_ORDER;
+ int sortLabel = 559;
+ SortOrder sortOrder = SortOrderAscending;
+ if (items.HasProperty(PROPERTY_SORT_ORDER))
+ {
+ SortBy sortBy = CSmartPlaylistRule::TranslateOrder(items.GetProperty(PROPERTY_SORT_ORDER).asString().c_str());
Sascha Montellese Owner

Any reason why you store the sort order as a string instead of just the value of the SortBy enum? You have to convert it to the string when storing it and back from a string when reading it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sascha Montellese
Owner

As we got a way to retrieve the original sort method and order with this from the CFileItemList we could add some additional logic to CGUIMediaWindow which looks for those properties before sorting in case the sort method is set to SORT_METHOD_PLAYLIST and use the properties from the list instead of m_iPlaylistOrder for sorting. That would also cover the other sort methods that are not covered by SORT_METHOD_FOO. If the properties are not present we could still fall back to sorting by m_iPlaylistOrder.

Sascha Montellese
Owner

I'm playing around with your code and noticed that if a smartplaylist has a sort method that is not available through SORT_METHOD_FOO the code in AddPlaylistOrder will fall back to SORT_METHOD_NONE instead of SORT_METHOD_PLAYLIST_ORDER so that will need an extra check. I'll see if I can add it in and upload a commit.

Sascha Montellese
Owner

See the last three commits at Montellese@master...sort_those_nodes. The first one solves the case where we can't translate from SortByFoo to SORT_METHOD_FOO (and should fall back to SORT_METHOD_PLAYLIST_ORDER and not SORT_METHOD_NONE). The second and especially the third one would be more something for my grouping work and would allow to fall back to the sort method specified in the CFileItemList's properties instead of using SORT_METHOD_PLAYLIST and should solve all of the sorting-related problems in my grouping work.

jmarshallnz
Owner

Do you need the SORT_METHOD_NONE case in GUIMediaWindow::SortItems given the other commit? I think we need to clearly comment in SortItems that the block is required only to support SortBy* that don't have an equivalent SORT_METHOD_*. The inverting of order isn't particularly obvious either (it is correct), so could do with a comment. I'll pull those commits in. Will also just use SortBy field directly as suggested I think to save the translation to and from string, and pop the localised string in the lut.

Sascha Montellese
Owner

I first added the SORT_METHOD_NONE because it didn't work properly without it, then found the root cause but I guess it doesn't hurt to be there or does it? Sure I can add comments, just wanted to see if it works and get your opinion on the approach.

jmarshallnz
Owner

It doesn't hurt, but doesn't really help either. I'm happy to do up the comments over lunch.

jmarshallnz
Owner

Updated with SortUtils::GetSortLabel.

During the process, I went through and found a bunch of inconsistency, where we often used alternate (and sometimes incorrect) labels for sorting in the UI (i.e. the label shown after Sort By: in the GUI). They're all consistent after the last 8 commits, but I'm not sure if they're all required or desired. Changes are:

  1. HTSP seemed to use "TV Shows" when it sorted by library (one presumes, due to it feeding TV Shows in?)
  2. Sorting by Title and Label used Title and Label interchangeably.
  3. Sorting by Genre in music used "Label" in the UI (it's the only sort order available).
  4. Sorting by Artist in music used "Label" in the UI (it's the only sort order available).
  5. Sorting by Play count used "Times played" rather than "Play count". The latter is consistent with how it's displayed in the playlist editor.
  6. Sorting by duration or runtime used "Time" and sometimes "Duration" - now always uses Duration.

@cptspiff signoff is up to you. I'm happy to drop commits that you think are not required.

Sascha Montellese
Owner

Most of those fixes you added with your latest commits are somewhere in one of my local branches as well so +1 for those. I just never got around to finish going through all the sort methods added in a specific view.

Sascha Montellese Montellese commented on the diff
xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp
@@ -296,7 +296,7 @@ void CGUIDialogSmartPlaylistEditor::UpdateButtons()
for (unsigned int i = 0; i < orders.size(); i++)
{
CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_ORDER_FIELD, orders[i]);
- msg.SetLabel(CSmartPlaylistRule::GetLocalizedOrder(orders[i]));
+ msg.SetLabel(SortUtils::GetSortLabel(orders[i]));
Sascha Montellese Owner

This causes all the SortByFoo methods which don't have a corresponding SORT_METHOD_FOO (and therefore aren't listed in the map in SortUtils) to appear as "None" in the smartplaylist editor dialog. Either add the missing SortByFoo to the map in SortUtils or keep CSmartPlaylistRule::GetLocalizedOrder() for now (as the map it uses is still present anyway).

jmarshallnz Owner

fixed in the rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
jmarshallnz
Owner

Previously everything included sortfileitem.h (which included SortUtils.h) for the SORT_METHOD_* enums, while actually used SortUtils.h for the sorting. SortFileItem.h will (eventually) be dropped completely - it is now included only here (for the enums).

jmarshallnz

I believe because we want it in the order specified.

jmarshallnz

Yup - it's there as otherwise we'd need to increase the SORT_METHOD_* with all the stuff SortBy* supports.

Deleted user ghost merged commit 73c9e9f into from
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 2, 2012
  1. add lookup table from old SORT_METHOD to new SortBy, and routines for…

    Jonathan Marshall authored
    … translating them
  2. use SortUtils::GetSortLabel rather than having a specific routine in …

    Jonathan Marshall authored
    …CSmartPlaylistRule
  3. check before adding sort methods in GUIViewState::AddSortMethod

    Jonathan Marshall authored
  4. store the smartplaylist order when retrieving the directory, and use …

    Jonathan Marshall authored
    …it to set the default sort method
  5. Sascha Montellese

    fix SortByNumberOfEpisodes and SortByNumberOfWatchedEpisodes based on…

    Montellese authored Jonathan Marshall committed
    … a list of CFileItems
  6. Sascha Montellese

    CGUIMediaWindow: prefer the specific sort order (if available) over S…

    Montellese authored Jonathan Marshall committed
    …ortByPlaylist and SortByNone
  7. consistency: use Label as the sort mode when sorting by label in HTSP…

    Jonathan Marshall authored
    …Directory
Commits on Nov 8, 2012
  1. consistency: Use Duration as the label when sorting by Duration or Ru…

    Jonathan Marshall authored
    …ntime
  2. consistency: use MPAA as the label when sorting by MPAA rating

    Jonathan Marshall authored
  3. consistency: use Genre as the label when sorting by genre

    Jonathan Marshall authored
  4. consistency: use Artist as the label when sorting by artists

    Jonathan Marshall authored
  5. consistency: use Label as the sort label when sorting by label

    Jonathan Marshall authored
  6. consistency: add a comment about inconsistent use of SORT_METHOD_EPIS…

    Jonathan Marshall authored
    …ODE for sorting by the number of episodes (rather than episode number)
This page is out of date. Refresh to see the latest.
134 xbmc/FileItem.cpp
View
@@ -702,7 +702,17 @@ void CFileItem::ToSortable(SortItem &sortable)
GetMusicInfoTag()->ToSortable(sortable);
if (HasVideoInfoTag())
+ {
GetVideoInfoTag()->ToSortable(sortable);
+
+ if (GetVideoInfoTag()->m_type == "tvshow")
+ {
+ if (HasProperty("totalepisodes"))
+ sortable[FieldNumberOfEpisodes] = GetProperty("totalepisodes");
+ if (HasProperty("unwatchedepisodes"))
+ sortable[FieldNumberOfWatchedEpisodes] = GetProperty("unwatchedepisodes");
+ }
+ }
if (HasPictureInfoTag())
GetPictureInfoTag()->ToSortable(sortable);
@@ -1821,131 +1831,9 @@ void CFileItemList::Sort(SORT_METHOD sortMethod, SortOrder sortOrder)
if (sortMethod == m_sortMethod && m_sortOrder == sortOrder)
return;
- SortDescription sorting;
+ SortDescription sorting = SortUtils::TranslateOldSortMethod(sortMethod);
sorting.sortOrder = sortOrder;
- switch (sortMethod)
- {
- case SORT_METHOD_LABEL:
- case SORT_METHOD_LABEL_IGNORE_FOLDERS:
- case SORT_METHOD_LABEL_IGNORE_THE:
- sorting.sortBy = SortByLabel;
- break;
- case SORT_METHOD_DATE:
- sorting.sortBy = SortByDate;
- break;
- case SORT_METHOD_SIZE:
- sorting.sortBy = SortBySize;
- break;
- case SORT_METHOD_BITRATE:
- sorting.sortBy = SortByBitrate;
- break;
- case SORT_METHOD_DRIVE_TYPE:
- sorting.sortBy = SortByDriveType;
- break;
- case SORT_METHOD_TRACKNUM:
- sorting.sortBy = SortByTrackNumber;
- break;
- case SORT_METHOD_EPISODE:
- sorting.sortBy = SortByEpisodeNumber;
- break;
- case SORT_METHOD_DURATION:
- case SORT_METHOD_VIDEO_RUNTIME:
- sorting.sortBy = SortByTime;
- break;
- case SORT_METHOD_TITLE:
- case SORT_METHOD_TITLE_IGNORE_THE:
- case SORT_METHOD_VIDEO_TITLE:
- sorting.sortBy = SortByTitle;
- break;
- case SORT_METHOD_ARTIST:
- case SORT_METHOD_ARTIST_IGNORE_THE:
- sorting.sortBy = SortByArtist;
- break;
- case SORT_METHOD_ALBUM:
- case SORT_METHOD_ALBUM_IGNORE_THE:
- sorting.sortBy = SortByAlbum;
- break;
- case SORT_METHOD_GENRE:
- sorting.sortBy = SortByGenre;
- break;
- case SORT_METHOD_COUNTRY:
- sorting.sortBy = SortByCountry;
- break;
- case SORT_METHOD_DATEADDED:
- sorting.sortBy = SortByDateAdded;
- break;
- case SORT_METHOD_FILE:
- sorting.sortBy = SortByFile;
- break;
- case SORT_METHOD_SONG_RATING:
- case SORT_METHOD_VIDEO_RATING:
- sorting.sortBy = SortByRating;
- break;
- case SORT_METHOD_VIDEO_SORT_TITLE:
- case SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE:
- sorting.sortBy = SortBySortTitle;
- break;
- case SORT_METHOD_YEAR:
- sorting.sortBy = SortByYear;
- break;
- case SORT_METHOD_PRODUCTIONCODE:
- sorting.sortBy = SortByProductionCode;
- break;
- case SORT_METHOD_PROGRAM_COUNT:
- sorting.sortBy = SortByProgramCount;
- break;
- case SORT_METHOD_PLAYLIST_ORDER:
- sorting.sortBy = SortByPlaylistOrder;
- break;
- case SORT_METHOD_MPAA_RATING:
- sorting.sortBy = SortByMPAA;
- break;
- case SORT_METHOD_STUDIO:
- case SORT_METHOD_STUDIO_IGNORE_THE:
- sorting.sortBy = SortByStudio;
- break;
- case SORT_METHOD_FULLPATH:
- sorting.sortBy = SortByPath;
- break;
- case SORT_METHOD_LASTPLAYED:
- sorting.sortBy = SortByLastPlayed;
- break;
- case SORT_METHOD_PLAYCOUNT:
- sorting.sortBy = SortByPlaycount;
- break;
- case SORT_METHOD_LISTENERS:
- sorting.sortBy = SortByListeners;
- break;
- case SORT_METHOD_CHANNEL:
- sorting.sortBy = SortByChannel;
- break;
- default:
- CLog::Log(LOGWARNING, "Unknown sort method %d", sortMethod);
- return;
- }
-
- if (sortMethod == SORT_METHOD_LABEL_IGNORE_THE ||
- sortMethod == SORT_METHOD_TITLE_IGNORE_THE ||
- sortMethod == SORT_METHOD_ARTIST_IGNORE_THE ||
- sortMethod == SORT_METHOD_ALBUM_IGNORE_THE ||
- sortMethod == SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE ||
- sortMethod == SORT_METHOD_STUDIO_IGNORE_THE)
- sorting.sortAttributes = (SortAttribute)((int)sorting.sortAttributes | SortAttributeIgnoreArticle);
-
- if (sortMethod == SORT_METHOD_FILE ||
- sortMethod == SORT_METHOD_VIDEO_SORT_TITLE ||
- sortMethod == SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE ||
- sortMethod == SORT_METHOD_LABEL_IGNORE_FOLDERS ||
- sortMethod == SORT_METHOD_DATEADDED ||
- sortMethod == SORT_METHOD_VIDEO_RATING ||
- sortMethod == SORT_METHOD_YEAR ||
- sortMethod == SORT_METHOD_PLAYLIST_ORDER ||
- sortMethod == SORT_METHOD_LASTPLAYED ||
- sortMethod == SORT_METHOD_PLAYCOUNT ||
- m_sortIgnoreFolders)
- sorting.sortAttributes = (SortAttribute)((int)sorting.sortAttributes | SortAttributeIgnoreFolders);
-
Sort(sorting);
m_sortMethod = sortMethod;
2  xbmc/FileItem.h
View
@@ -29,7 +29,7 @@
#include "utils/ISerializable.h"
#include "utils/ISortable.h"
#include "XBDateTime.h"
-#include "SortFileItem.h"
+#include "utils/SortUtils.h"
#include "utils/LabelFormatter.h"
#include "GUIPassword.h"
#include "threads/CriticalSection.h"
35 xbmc/GUIViewState.cpp
View
@@ -47,6 +47,10 @@
#if defined(TARGET_ANDROID)
#include "filesystem/AndroidAppDirectory.h"
#endif
+
+#define PROPERTY_SORT_ORDER "sort.order"
+#define PROPERTY_SORT_ASCENDING "sort.ascending"
+
using namespace std;
using namespace ADDON;
using namespace PVR;
@@ -244,11 +248,14 @@ void CGUIViewState::GetSortMethodLabelMasks(LABEL_MASKS& masks) const
void CGUIViewState::AddSortMethod(SORT_METHOD sortMethod, int buttonLabel, LABEL_MASKS labelmasks)
{
+ for (size_t i = 0; i < m_sortMethods.size(); ++i)
+ if (m_sortMethods[i].m_sortMethod == sortMethod)
+ return;
+
SORT_METHOD_DETAILS sort;
sort.m_sortMethod=sortMethod;
sort.m_buttonLabel=buttonLabel;
sort.m_labelMasks=labelmasks;
-
m_sortMethods.push_back(sort);
}
@@ -469,6 +476,32 @@ void CGUIViewState::SaveViewToDb(const CStdString &path, int windowID, CViewStat
}
}
+void CGUIViewState::AddPlaylistOrder(const CFileItemList &items, LABEL_MASKS label_masks)
+{
+ SORT_METHOD sortMethod = SORT_METHOD_PLAYLIST_ORDER;
+ int sortLabel = 559;
+ SortOrder sortOrder = SortOrderAscending;
+ if (items.HasProperty(PROPERTY_SORT_ORDER))
+ {
+ SortBy sortBy = (SortBy)items.GetProperty(PROPERTY_SORT_ORDER).asInteger();
+ if (sortBy != SortByNone)
+ {
+ sortMethod = SortUtils::TranslateOldSortMethod(sortBy, g_guiSettings.GetBool("filelists.ignorethewhensorting"));
+ if (sortMethod == SORT_METHOD_NONE)
+ sortMethod = SORT_METHOD_PLAYLIST_ORDER;
+ else
+ {
+ sortLabel = SortUtils::GetSortLabel(sortBy);
+ sortOrder = items.GetProperty(PROPERTY_SORT_ASCENDING).asBoolean() ? SortOrderAscending : SortOrderDescending;
+ }
+ }
+ }
+ AddSortMethod(sortMethod, sortLabel, label_masks);
+ SetSortMethod(sortMethod);
+ SetSortOrder(sortOrder);
+}
+
+
CGUIViewStateFromItems::CGUIViewStateFromItems(const CFileItemList &items) : CGUIViewState(items)
{
const vector<SORT_METHOD_DETAILS> &details = items.GetSortDetails();
9 xbmc/GUIViewState.h
View
@@ -21,7 +21,7 @@
*/
#include "utils/LabelFormatter.h"
-#include "SortFileItem.h"
+#include "utils/SortUtils.h"
#include "MediaSource.h"
class CViewState; // forward
@@ -76,6 +76,13 @@ class CGUIViewState
#endif
void AddLiveTVSources();
+ /*! \brief Add the sort order defined in a smartplaylist
+ Defaults to SORT_METHOD_PLAYLIST_ORDER if no order is defined.
+ \param items the list of items for the view state.
+ \param label_mask the label masks for formatting items.
+ */
+ void AddPlaylistOrder(const CFileItemList &items, LABEL_MASKS label_masks);
+
void AddSortMethod(SORT_METHOD sortMethod, int buttonLabel, LABEL_MASKS labelmasks);
void SetSortMethod(SORT_METHOD sortMethod);
void SetSortOrder(SortOrder sortOrder);
1  xbmc/SortFileItem.h
View
@@ -20,7 +20,6 @@
*/
#include "utils/LabelFormatter.h"
-#include "utils/SortUtils.h"
typedef enum {
SORT_METHOD_NONE=0,
2  xbmc/ViewState.h
View
@@ -19,7 +19,7 @@
*
*/
-#include "SortFileItem.h"
+#include "utils/SortUtils.h"
#define DEFAULT_VIEW_AUTO (VIEW_TYPE_AUTO << 16)
#define DEFAULT_VIEW_LIST (VIEW_TYPE_LIST << 16)
2  xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp
View
@@ -296,7 +296,7 @@ void CGUIDialogSmartPlaylistEditor::UpdateButtons()
for (unsigned int i = 0; i < orders.size(); i++)
{
CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_ORDER_FIELD, orders[i]);
- msg.SetLabel(CSmartPlaylistRule::GetLocalizedOrder(orders[i]));
+ msg.SetLabel(SortUtils::GetSortLabel(orders[i]));
Sascha Montellese Owner

This causes all the SortByFoo methods which don't have a corresponding SORT_METHOD_FOO (and therefore aren't listed in the map in SortUtils) to appear as "None" in the smartplaylist editor dialog. Either add the missing SortByFoo to the map in SortUtils or keep CSmartPlaylistRule::GetLocalizedOrder() for now (as the map it uses is still present anyway).

jmarshallnz Owner

fixed in the rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
OnMessage(msg);
}
{
4 xbmc/filesystem/HTSPDirectory.cpp
View
@@ -397,9 +397,9 @@ bool CHTSPDirectory::GetChannels( const CURL &base
items.AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B", "%Z", "%L", ""));
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
- items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 20364, LABEL_MASKS("%Z", "%B", "%L", ""));
+ items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%Z", "%B", "%L", ""));
else
- items.AddSortMethod(SORT_METHOD_LABEL, 20364, LABEL_MASKS("%Z", "%B", "%L", ""));
+ items.AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%Z", "%B", "%L", ""));
items.SetContent("livetv");
4 xbmc/filesystem/MythDirectory.cpp
View
@@ -329,9 +329,9 @@ bool CMythDirectory::GetRecordings(const CStdString& base, CFileItemList &items,
if (type != TV_SHOWS)
{
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
- items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 551 /* Name */, LABEL_MASKS("%K", "%J"));
+ items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%K", "%J"));
else
- items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 551 /* Name */, LABEL_MASKS("%K", "%J"));
+ items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%K", "%J"));
}
items.AddSortMethod(SORT_METHOD_DATE, 552 /* Date */, LABEL_MASKS("%K", "%J"));
10 xbmc/filesystem/PluginDirectory.cpp
View
@@ -292,7 +292,7 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const C
}
case SORT_METHOD_DURATION:
{
- dir->m_listItems->AddSortMethod(SORT_METHOD_DURATION, 555, LABEL_MASKS("%T", "%D"));
+ dir->m_listItems->AddSortMethod(SORT_METHOD_DURATION, 180, LABEL_MASKS("%T", "%D"));
break;
}
case SORT_METHOD_VIDEO_RATING:
@@ -329,19 +329,19 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const C
case SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE:
{
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
- dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 369, LABEL_MASKS("%T", label2Mask));
+ dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", label2Mask));
else
- dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 369, LABEL_MASKS("%T", label2Mask));
+ dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", label2Mask));
break;
}
case SORT_METHOD_MPAA_RATING:
{
- dir->m_listItems->AddSortMethod(SORT_METHOD_MPAA_RATING, 563, LABEL_MASKS("%T", "%O"));
+ dir->m_listItems->AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%T", "%O"));
break;
}
case SORT_METHOD_VIDEO_RUNTIME:
{
- dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_RUNTIME, 555, LABEL_MASKS("%T", "%D"));
+ dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_RUNTIME, 180, LABEL_MASKS("%T", "%D"));
break;
}
case SORT_METHOD_STUDIO:
4 xbmc/filesystem/SmartPlaylistDirectory.cpp
View
@@ -32,6 +32,8 @@
#include "utils/URIUtils.h"
#define PROPERTY_PATH_DB "path.db"
+#define PROPERTY_SORT_ORDER "sort.order"
+#define PROPERTY_SORT_ASCENDING "sort.ascending"
namespace XFILE
{
@@ -240,6 +242,8 @@ namespace XFILE
}
}
items.SetLabel(playlist.GetName());
+ items.SetProperty(PROPERTY_SORT_ORDER, (int)playlist.GetOrder());
+ items.SetProperty(PROPERTY_SORT_ASCENDING, playlist.GetOrderDirection() == SortOrderAscending);
// go through and set the playlist order
for (int i = 0; i < items.Size(); i++)
2  xbmc/interfaces/json-rpc/JSONUtils.h
View
@@ -23,7 +23,7 @@
#include <stdlib.h>
#include "JSONRPCUtils.h"
-#include "SortFileItem.h"
+#include "utils/SortUtils.h"
#include "interfaces/IAnnouncer.h"
#include "playlists/SmartPlayList.h"
#include "utils/JSONVariantWriter.h"
28 xbmc/music/GUIViewStateMusic.cpp
View
@@ -150,7 +150,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
break;
case NODE_TYPE_GENRE:
{
- AddSortMethod(SORT_METHOD_GENRE, 551, LABEL_MASKS("%F", "", "%G", "")); // Filename, empty | Genre, empty
+ AddSortMethod(SORT_METHOD_GENRE, 515, LABEL_MASKS("%F", "", "%G", "")); // Filename, empty | Genre, empty
SetSortMethod(SORT_METHOD_GENRE);
SetViewAsControl(DEFAULT_VIEW_LIST);
@@ -172,12 +172,12 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
{
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
{
- AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 551, LABEL_MASKS("%F", "", "%A", "")); // Filename, empty | Artist, empty
+ AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%F", "", "%A", "")); // Filename, empty | Artist, empty
SetSortMethod(SORT_METHOD_ARTIST_IGNORE_THE);
}
else
{
- AddSortMethod(SORT_METHOD_ARTIST, 551, LABEL_MASKS("%F", "", "%A", "")); // Filename, empty | Artist, empty
+ AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%F", "", "%A", "")); // Filename, empty | Artist, empty
SetSortMethod(SORT_METHOD_ARTIST);
}
@@ -276,7 +276,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
AddSortMethod(SORT_METHOD_TITLE, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty
AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS(strTrackLeft, strTrackRight));
}
- AddSortMethod(SORT_METHOD_DURATION, 555, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty
+ AddSortMethod(SORT_METHOD_DURATION, 180, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty
AddSortMethod(SORT_METHOD_SONG_RATING, 563, LABEL_MASKS("%T - %A", "%R")); // Title - Artist, Rating
SetSortMethod(g_settings.m_viewStateMusicNavSongs.m_sortMethod);
@@ -306,7 +306,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Title, Duration| empty, empty
AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS(strTrackLeft, strTrackRight));
}
- AddSortMethod(SORT_METHOD_DURATION, 555, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty
+ AddSortMethod(SORT_METHOD_DURATION, 180, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty
AddSortMethod(SORT_METHOD_SONG_RATING, 563, LABEL_MASKS("%T - %A", "%R")); // Title - Artist, Rating
AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T - %A", "%Y")); // Title, Artist, Year
@@ -317,7 +317,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
else
SetSortMethod(g_settings.m_viewStateMusicNavSongs.m_sortMethod);
- AddSortMethod(SORT_METHOD_PLAYCOUNT, 576, LABEL_MASKS("%T - %A", "%V")); // Titel - Artist, PlayCount
+ AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T - %A", "%V")); // Titel - Artist, PlayCount
SetViewAsControl(g_settings.m_viewStateMusicNavSongs.m_viewMode);
@@ -386,7 +386,6 @@ CGUIViewStateMusicSmartPlaylist::CGUIViewStateMusicSmartPlaylist(const CFileItem
CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat");
CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright");
- AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS(strTrackLeft, strTrackRight));
AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined| empty, empty
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
{
@@ -402,13 +401,11 @@ CGUIViewStateMusicSmartPlaylist::CGUIViewStateMusicSmartPlaylist(const CFileItem
AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Titel, Duration| empty, empty
AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS(strTrackLeft, strTrackRight));
}
- AddSortMethod(SORT_METHOD_DURATION, 555, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty
+ AddSortMethod(SORT_METHOD_DURATION, 180, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty
AddSortMethod(SORT_METHOD_SONG_RATING, 563, LABEL_MASKS("%T - %A", "%R")); // Titel, Artist, Rating| empty, empty
- SetSortMethod(SORT_METHOD_PLAYLIST_ORDER);
+ AddPlaylistOrder(items, LABEL_MASKS(strTrackLeft, strTrackRight));
SetViewAsControl(g_settings.m_viewStateMusicNavSongs.m_viewMode);
-
- SetSortOrder(g_settings.m_viewStateMusicNavSongs.m_sortOrder);
}
else if (items.GetContent() == "albums")
{
@@ -419,7 +416,6 @@ CGUIViewStateMusicSmartPlaylist::CGUIViewStateMusicSmartPlaylist(const CFileItem
if (strAlbumRight.IsEmpty())
strAlbumRight = "%A"; // artist
- AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight));
// album
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined
@@ -435,9 +431,9 @@ CGUIViewStateMusicSmartPlaylist::CGUIViewStateMusicSmartPlaylist(const CFileItem
// year
AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight));
- SetSortMethod(SORT_METHOD_PLAYLIST_ORDER);
+ AddPlaylistOrder(items, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight));
+
SetViewAsControl(g_settings.m_viewStateMusicNavAlbums.m_viewMode);
- SetSortOrder(g_settings.m_viewStateMusicNavAlbums.m_sortOrder);
}
else
{
@@ -473,7 +469,7 @@ CGUIViewStateMusicPlaylist::CGUIViewStateMusicPlaylist(const CFileItemList& item
AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Titel, Duration| empty, empty
AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS(strTrackLeft, strTrackRight));
}
- AddSortMethod(SORT_METHOD_DURATION, 555, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty
+ AddSortMethod(SORT_METHOD_DURATION, 180, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty
AddSortMethod(SORT_METHOD_SONG_RATING, 563, LABEL_MASKS("%T - %A", "%R")); // Titel, Artist, Rating| empty, empty
SetSortMethod(SORT_METHOD_PLAYLIST_ORDER);
@@ -509,7 +505,7 @@ CGUIViewStateWindowMusicNav::CGUIViewStateWindowMusicNav(const CFileItemList& it
if (params.GetMVideoId() != -1)
{
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
- AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 556, LABEL_MASKS("%T", "%Y")); // Filename, Duration | Foldername, empty
+ AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T", "%Y")); // Filename, Duration | Foldername, empty
else
AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%Y")); // Filename, Duration | Foldername, empty
AddSortMethod(SORT_METHOD_YEAR,562, LABEL_MASKS("%T", "%Y"));
2  xbmc/pictures/GUIWindowSlideShow.h
View
@@ -27,7 +27,7 @@
#include "threads/Event.h"
#include "SlideShowPicture.h"
#include "DllImageLib.h"
-#include "SortFileItem.h"
+#include "utils/SortUtils.h"
class CFileItemList;
class CVariant;
7 xbmc/playlists/SmartPlayList.cpp
View
@@ -326,13 +326,6 @@ CStdString CSmartPlaylistRule::GetLocalizedField(Field field)
return g_localizeStrings.Get(16018);
}
-CStdString CSmartPlaylistRule::GetLocalizedOrder(SortBy order)
-{
- for (unsigned int i = 0; i < NUM_FIELDS; i++)
- if (order == fields[i].sort) return g_localizeStrings.Get(fields[i].localizedString);
- return g_localizeStrings.Get(16018);
-}
-
CSmartPlaylistRule::FIELD_TYPE CSmartPlaylistRule::GetFieldType(Field field)
{
for (unsigned int i = 0; i < NUM_FIELDS; i++)
1  xbmc/playlists/SmartPlayList.h
View
@@ -88,7 +88,6 @@ class CSmartPlaylistRule : public ISmartPlaylistRule
static CStdString TranslateOperator(SEARCH_OPERATOR oper);
static CStdString GetLocalizedField(Field field);
- static CStdString GetLocalizedOrder(SortBy order);
static CStdString GetLocalizedOperator(SEARCH_OPERATOR oper);
static std::vector<Field> GetFields(const CStdString &type);
static std::vector<SortBy> GetOrders(const CStdString &type);
112 xbmc/utils/SortUtils.cpp
View
@@ -744,3 +744,115 @@ string SortUtils::RemoveArticles(const string &label)
return label;
}
+
+typedef struct
+{
+ SortBy sort;
+ SORT_METHOD old;
+ SortAttribute flags;
+ int label;
+} sort_map;
+
+const sort_map table[] = {
+ { SortByLabel, SORT_METHOD_LABEL, SortAttributeNone, 551 },
+ { SortByLabel, SORT_METHOD_LABEL_IGNORE_THE, SortAttributeIgnoreArticle, 551 },
+ { SortByLabel, SORT_METHOD_LABEL_IGNORE_FOLDERS, SortAttributeIgnoreFolders, 551 },
+ { SortByDate, SORT_METHOD_DATE, SortAttributeNone, 552 },
+ { SortBySize, SORT_METHOD_SIZE, SortAttributeNone, 553 },
+ { SortByBitrate, SORT_METHOD_BITRATE, SortAttributeNone, 623 },
+ { SortByDriveType, SORT_METHOD_DRIVE_TYPE, SortAttributeNone, 564 },
+ { SortByTrackNumber, SORT_METHOD_TRACKNUM, SortAttributeNone, 554 },
+ { SortByEpisodeNumber, SORT_METHOD_EPISODE, SortAttributeNone, 20359 },// 20360 "Episodes" used for SORT_METHOD_EPISODE for sorting tvshows by episode count
+ { SortByTime, SORT_METHOD_DURATION, SortAttributeNone, 180 },
+ { SortByTime, SORT_METHOD_VIDEO_RUNTIME, SortAttributeNone, 180 },
+ { SortByTitle, SORT_METHOD_TITLE, SortAttributeNone, 556 },
+ { SortByTitle, SORT_METHOD_TITLE_IGNORE_THE, SortAttributeIgnoreArticle, 556 },
+ { SortByTitle, SORT_METHOD_VIDEO_TITLE, SortAttributeNone, 556 },
+ { SortByArtist, SORT_METHOD_ARTIST, SortAttributeNone, 557 },
+ { SortByArtist, SORT_METHOD_ARTIST_IGNORE_THE, SortAttributeIgnoreArticle, 557 },
+ { SortByAlbum, SORT_METHOD_ALBUM, SortAttributeNone, 558 },
+ { SortByAlbum, SORT_METHOD_ALBUM_IGNORE_THE, SortAttributeIgnoreArticle, 558 },
+ { SortByGenre, SORT_METHOD_GENRE, SortAttributeNone, 515 },
+ { SortByCountry, SORT_METHOD_COUNTRY, SortAttributeNone, 574 },
+ { SortByDateAdded, SORT_METHOD_DATEADDED, SortAttributeIgnoreFolders, 570 },
+ { SortByFile, SORT_METHOD_FILE, SortAttributeIgnoreFolders, 561 },
+ { SortByRating, SORT_METHOD_SONG_RATING, SortAttributeNone, 563 },
+ { SortByRating, SORT_METHOD_VIDEO_RATING, SortAttributeIgnoreFolders, 563 },
+ { SortBySortTitle, SORT_METHOD_VIDEO_SORT_TITLE, SortAttributeIgnoreFolders, 556 },
+ { SortBySortTitle, SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, (SortAttribute)(SortAttributeIgnoreFolders | SortAttributeIgnoreArticle), 556 },
+ { SortByYear, SORT_METHOD_YEAR, SortAttributeIgnoreFolders, 562 },
+ { SortByProductionCode, SORT_METHOD_PRODUCTIONCODE, SortAttributeNone, 20368 },
+ { SortByProgramCount, SORT_METHOD_PROGRAM_COUNT, SortAttributeNone, 567 }, // label is "play count"
+ { SortByPlaylistOrder, SORT_METHOD_PLAYLIST_ORDER, SortAttributeIgnoreFolders, 559 },
+ { SortByMPAA, SORT_METHOD_MPAA_RATING, SortAttributeNone, 20074 },
+ { SortByStudio, SORT_METHOD_STUDIO, SortAttributeNone, 572 },
+ { SortByStudio, SORT_METHOD_STUDIO_IGNORE_THE, SortAttributeIgnoreArticle, 572 },
+ { SortByPath, SORT_METHOD_FULLPATH, SortAttributeNone, 573 },
+ { SortByLastPlayed, SORT_METHOD_LASTPLAYED, SortAttributeIgnoreFolders, 568 },
+ { SortByPlaycount, SORT_METHOD_PLAYCOUNT, SortAttributeIgnoreFolders, 567 },
+ { SortByListeners, SORT_METHOD_LISTENERS, SortAttributeNone, 20455 },
+ { SortByChannel, SORT_METHOD_CHANNEL, SortAttributeNone, 19029 },
+ { SortByNone, SORT_METHOD_NONE, SortAttributeNone, 16018 },
+ // the following have no corresponding SORT_METHOD_*
+ { SortByAlbumType, SORT_METHOD_NONE, SortAttributeNone, 564 },
+ { SortByVotes, SORT_METHOD_NONE, SortAttributeNone, 205 },
+ { SortByTop250, SORT_METHOD_NONE, SortAttributeNone, 13409 },
+ { SortByMPAA, SORT_METHOD_NONE, SortAttributeNone, 20074 },
+ { SortByDateAdded, SORT_METHOD_NONE, SortAttributeNone, 570 },
+ { SortByTvShowTitle, SORT_METHOD_NONE, SortAttributeNone, 20364 },
+ { SortByTvShowStatus, SORT_METHOD_NONE, SortAttributeNone, 126 },
+ { SortBySeason, SORT_METHOD_NONE, SortAttributeNone, 20373 },
+ { SortByNumberOfEpisodes, SORT_METHOD_NONE, SortAttributeNone, 20360 },
+ { SortByNumberOfWatchedEpisodes, SORT_METHOD_NONE, SortAttributeNone, 21441 },
+ { SortByVideoResolution, SORT_METHOD_NONE, SortAttributeNone, 21443 },
+ { SortByVideoCodec, SORT_METHOD_NONE, SortAttributeNone, 21445 },
+ { SortByVideoAspectRatio, SORT_METHOD_NONE, SortAttributeNone, 21374 },
+ { SortByAudioChannels, SORT_METHOD_NONE, SortAttributeNone, 21444 },
+ { SortByAudioCodec, SORT_METHOD_NONE, SortAttributeNone, 21446 },
+ { SortByAudioLanguage, SORT_METHOD_NONE, SortAttributeNone, 21447 },
+ { SortBySubtitleLanguage, SORT_METHOD_NONE, SortAttributeNone, 21448 },
+ { SortByRandom, SORT_METHOD_NONE, SortAttributeNone, 590 }
+};
+
+SORT_METHOD SortUtils::TranslateOldSortMethod(SortBy sortBy, bool ignoreArticle)
+{
+ for (size_t i = 0; i < sizeof(table) / sizeof(sort_map); i++)
+ {
+ if (table[i].sort == sortBy)
+ {
+ if (ignoreArticle == ((table[i].flags & SortAttributeIgnoreArticle) == SortAttributeIgnoreArticle))
+ return table[i].old;
+ }
+ }
+ for (size_t i = 0; i < sizeof(table) / sizeof(sort_map); i++)
+ {
+ if (table[i].sort == sortBy)
+ return table[i].old;
+ }
+ return SORT_METHOD_NONE;
+}
+
+SortDescription SortUtils::TranslateOldSortMethod(SORT_METHOD sortBy)
+{
+ SortDescription description;
+ for (size_t i = 0; i < sizeof(table) / sizeof(sort_map); i++)
+ {
+ if (table[i].old == sortBy)
+ {
+ description.sortBy = table[i].sort;
+ description.sortAttributes = table[i].flags;
+ break;
+ }
+ }
+ return description;
+}
+
+int SortUtils::GetSortLabel(SortBy sortBy)
+{
+ for (size_t i = 0; i < sizeof(table) / sizeof(sort_map); i++)
+ {
+ if (table[i].sort == sortBy)
+ return table[i].label;
+ }
+ return 16018; // None
+}
10 xbmc/utils/SortUtils.h
View
@@ -23,6 +23,7 @@
#include <string>
#include "DatabaseUtils.h"
+#include "SortFileItem.h"
typedef enum {
SortOrderNone = 0,
@@ -109,6 +110,15 @@ typedef DatabaseResults SortItems;
class SortUtils
{
public:
+ static SORT_METHOD TranslateOldSortMethod(SortBy sortBy, bool ignoreArticle);
+ static SortDescription TranslateOldSortMethod(SORT_METHOD sortBy);
+
+ /*! \brief retrieve the label id associated with a sort method for displaying in the UI.
+ \param sortBy the sort method in question.
+ \return the label id of the sort method.
+ */
+ static int GetSortLabel(SortBy sortBy);
+
static void Sort(SortBy sortBy, SortOrder sortOrder, SortAttribute attributes, SortItems& items, int limitEnd = -1, int limitStart = 0);
static void Sort(const SortDescription &sortDescription, SortItems& items);
static bool SortFromDataset(const SortDescription &sortDescription, MediaType mediaType, const std::auto_ptr<dbiplus::Dataset> &dataset, DatabaseResults &results);
83 xbmc/video/GUIViewStateVideo.cpp
View
@@ -142,7 +142,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
break;
case NODE_TYPE_YEAR:
{
- AddSortMethod(SORT_METHOD_LABEL, 562, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty
+ AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty
SetSortMethod(SORT_METHOD_LABEL);
SetViewAsControl(g_settings.m_viewStateVideoNavYears.m_viewMode);
@@ -152,7 +152,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
break;
case NODE_TYPE_SEASONS:
{
- AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 551, LABEL_MASKS("%L", "","%L","")); // Label, empty | Label, empty
+ AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%L", "","%L","")); // Label, empty | Label, empty
SetSortMethod(SORT_METHOD_VIDEO_SORT_TITLE);
SetViewAsControl(g_settings.m_viewStateVideoNavSeasons.m_viewMode);
@@ -163,10 +163,11 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
case NODE_TYPE_TITLE_TVSHOWS:
{
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
- AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 551, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
+ AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
else
- AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 551, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
+ AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
+ // NOTE: This uses SORT_METHOD_EPISODE to mean "sort shows by the number of episodes" and uses the label "Episodes"
AddSortMethod(SORT_METHOD_EPISODE, 20360, LABEL_MASKS("%L", "%M", "%L", "%M")); // Label, #Episodes | Label, #Episodes
AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%L","%Y","%L","%Y")); // Label, Year | Label, Year
SetSortMethod(SORT_METHOD_LABEL);
@@ -201,7 +202,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
AddSortMethod(SORT_METHOD_DATEADDED, 570, LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded
if (g_settings.GetWatchMode(items.GetContent()) == VIDEO_SHOW_ALL)
- AddSortMethod(SORT_METHOD_PLAYCOUNT, 576, LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount
+ AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount
SetSortMethod(SORT_METHOD_LABEL_IGNORE_THE);
@@ -233,7 +234,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%E. %T","%J","%E. %T","%J")); // Episode. Title, Date | Episode. Title, Date
if (g_settings.GetWatchMode(items.GetContent()) == VIDEO_SHOW_ALL)
- AddSortMethod(SORT_METHOD_PLAYCOUNT, 576, LABEL_MASKS("%E. %T", "%V")); // Episode. Title, Playcount | empty, empty
+ AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%E. %T", "%V")); // Episode. Title, Playcount | empty, empty
}
else
{
@@ -244,7 +245,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%H. %T","%J","%H. %T","%J")); // Order. Title, Date | Episode. Title, Date
if (g_settings.GetWatchMode(items.GetContent()) == VIDEO_SHOW_ALL)
- AddSortMethod(SORT_METHOD_PLAYCOUNT, 576, LABEL_MASKS("%H. %T", "%V")); // Order. Title, Playcount | empty, empty
+ AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%H. %T", "%V")); // Order. Title, Playcount | empty, empty
}
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T","%R")); // Title, Rating | empty, empty
@@ -275,26 +276,26 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
- AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 551, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty
+ AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty
else
- AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 551, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty
+ AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty
}
else
{
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
- AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 551, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
+ AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
else
- AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 551, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
+ AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year
}
AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%T", "%O")); // Title, MPAA | empty, empty
- AddSortMethod(SORT_METHOD_VIDEO_RUNTIME, 2050, LABEL_MASKS("%T", "%D")); // Title, Duration | empty, empty
+ AddSortMethod(SORT_METHOD_VIDEO_RUNTIME, 180, LABEL_MASKS("%T", "%D")); // Title, Duration | empty, empty
AddSortMethod(SORT_METHOD_DATEADDED, 570, LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded
if (g_settings.GetWatchMode(items.GetContent()) == VIDEO_SHOW_ALL)
- AddSortMethod(SORT_METHOD_PLAYCOUNT, 576, LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount
+ AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount
if (params.GetSetId() > -1)
SetSortMethod(SORT_METHOD_YEAR);
@@ -309,7 +310,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
case NODE_TYPE_TITLE_MUSICVIDEOS:
{
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
- AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 556, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty
+ AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty
else
AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty
AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%T", "%O"));
@@ -326,7 +327,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
}
if (g_settings.GetWatchMode(items.GetContent()) == VIDEO_SHOW_ALL)
- AddSortMethod(SORT_METHOD_PLAYCOUNT, 576, LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty
+ AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty
CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat");
CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright");
@@ -500,25 +501,23 @@ VECSOURCES& CGUIViewStateWindowVideoPlaylist::GetSources()
CGUIViewStateVideoMovies::CGUIViewStateVideoMovies(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
{
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
- AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 551, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
+ AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
else
- AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 551, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
+ AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%T", "%O")); // Title, MPAA | empty, empty
AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year
if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean())
- {
- AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
- SetSortMethod(SORT_METHOD_PLAYLIST_ORDER);
- }
+ AddPlaylistOrder(items, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
else
+ {
SetSortMethod(g_settings.m_viewStateVideoNavTitles.m_sortMethod);
+ SetSortOrder(g_settings.m_viewStateVideoNavTitles.m_sortOrder);
+ }
SetViewAsControl(g_settings.m_viewStateVideoNavTitles.m_viewMode);
- SetSortOrder(g_settings.m_viewStateVideoNavTitles.m_sortOrder);
-
LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
}
@@ -531,7 +530,7 @@ void CGUIViewStateVideoMovies::SaveViewState()
CGUIViewStateVideoMusicVideos::CGUIViewStateVideoMusicVideos(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
{
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
- AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 556, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty
+ AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty
else
AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty
AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%T", "%O"));
@@ -547,24 +546,22 @@ CGUIViewStateVideoMusicVideos::CGUIViewStateVideoMusicVideos(const CFileItemList
AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty
}
- AddSortMethod(SORT_METHOD_PLAYCOUNT, 576, LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty
+ AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty
CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat");
CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright");
AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty
if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean())
- {
- AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty
- SetSortMethod(SORT_METHOD_PLAYLIST_ORDER);
- }
+ AddPlaylistOrder(items, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty
else
+ {
SetSortMethod(g_settings.m_viewStateVideoNavMusicVideos.m_sortMethod);
+ SetSortOrder(g_settings.m_viewStateVideoNavMusicVideos.m_sortOrder);
+ }
SetViewAsControl(g_settings.m_viewStateVideoNavMusicVideos.m_viewMode);
- SetSortOrder(g_settings.m_viewStateVideoNavMusicVideos.m_sortOrder);
-
LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
}
@@ -576,23 +573,21 @@ void CGUIViewStateVideoMusicVideos::SaveViewState()
CGUIViewStateVideoTVShows::CGUIViewStateVideoTVShows(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
{
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
- AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 551, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
+ AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
else
- AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 551, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
+ AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year
if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean())
- {
- AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
- SetSortMethod(SORT_METHOD_PLAYLIST_ORDER);
- }
+ AddPlaylistOrder(items, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
else
+ {
SetSortMethod(g_settings.m_viewStateVideoNavTvShows.m_sortMethod);
+ SetSortOrder(g_settings.m_viewStateVideoNavTvShows.m_sortOrder);
+ }
SetViewAsControl(g_settings.m_viewStateVideoNavTvShows.m_viewMode);
- SetSortOrder(g_settings.m_viewStateVideoNavTvShows.m_sortOrder);
-
LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
}
@@ -626,17 +621,15 @@ CGUIViewStateVideoEpisodes::CGUIViewStateVideoEpisodes(const CFileItemList& item
}
if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean())
- {
- AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty
- SetSortMethod(SORT_METHOD_PLAYLIST_ORDER);
- }
+ AddPlaylistOrder(items, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty
else
+ {
SetSortMethod(g_settings.m_viewStateVideoNavEpisodes.m_sortMethod);
+ SetSortOrder(g_settings.m_viewStateVideoNavEpisodes.m_sortOrder);
+ }
SetViewAsControl(g_settings.m_viewStateVideoNavEpisodes.m_viewMode);
- SetSortOrder(g_settings.m_viewStateVideoNavEpisodes.m_sortOrder);
-
LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
}
32 xbmc/windows/GUIMediaWindow.cpp
View
@@ -79,6 +79,8 @@
#define CONTROL_LABELFILES 12
#define PROPERTY_PATH_DB "path.db"
+#define PROPERTY_SORT_ORDER "sort.order"
+#define PROPERTY_SORT_ASCENDING "sort.ascending"
using namespace std;
using namespace ADDON;
@@ -586,7 +588,35 @@ void CGUIMediaWindow::SortItems(CFileItemList &items)
if (guiState.get())
{
- items.Sort(guiState->GetSortMethod(), guiState->GetDisplaySortOrder());
+ bool sorted = false;
+ SORT_METHOD sortMethod = guiState->GetSortMethod();
+ // If the sort method is "sort by playlist" and we have a specific
+ // sort order available we can use the specified sort order to do the sorting
+ // We do this as the new SortBy methods are a superset of the SORT_METHOD methods, thus
+ // not all are available. This may be removed once SORT_METHOD_* have been replaced by
+ // SortBy.
+ if ((sortMethod == SORT_METHOD_PLAYLIST_ORDER) && items.HasProperty(PROPERTY_SORT_ORDER))
+ {
+ SortBy sortBy = (SortBy)items.GetProperty(PROPERTY_SORT_ORDER).asInteger();
+ if (sortBy != SortByNone && sortBy != SortByPlaylistOrder && sortBy != SortByProgramCount)
+ {
+ SortDescription sorting;
+ sorting.sortBy = sortBy;
+ sorting.sortOrder = items.GetProperty(PROPERTY_SORT_ASCENDING).asBoolean() ? SortOrderAscending : SortOrderDescending;
+ sorting.sortAttributes = g_guiSettings.GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone;
+
+ // if the sort order is descending, we need to switch the original sort order, as we assume
+ // in CGUIViewState::AddPlaylistOrder that SORT_METHOD_PLAYLIST_ORDER is ascending.
+ if (guiState->GetDisplaySortOrder() == SortOrderDescending)
+ sorting.sortOrder = sorting.sortOrder == SortOrderDescending ? SortOrderAscending : SortOrderDescending;
+
+ items.Sort(sorting);
+ sorted = true;
+ }
+ }
+
+ if (!sorted)
+ items.Sort(sortMethod, guiState->GetDisplaySortOrder());
// Should these items be saved to the hdd
if (items.CacheToDiscAlways() && !IsFiltered())
Something went wrong with that request. Please try again.