From 7ec41ee12967345673bad456d6d52a7a04a4f235 Mon Sep 17 00:00:00 2001 From: montellese Date: Wed, 18 Jul 2012 15:18:57 +0200 Subject: cleanup sorting to (almost) get rid of the old SORT_METHOD_FOO --- xbmc/Autorun.cpp | 12 +- xbmc/FileItem.cpp | 105 +++++---- xbmc/FileItem.h | 13 +- xbmc/GUIInfoManager.cpp | 8 +- xbmc/SortFileItem.h | 10 - xbmc/addons/AddonInstaller.cpp | 6 +- xbmc/addons/GUIDialogAddonInfo.cpp | 2 +- xbmc/addons/GUIViewStateAddonBrowser.cpp | 6 +- xbmc/addons/GUIWindowAddonBrowser.cpp | 2 +- xbmc/dialogs/GUIDialogFileBrowser.cpp | 2 +- xbmc/dialogs/GUIDialogMediaFilter.cpp | 2 +- xbmc/dialogs/GUIDialogSelect.cpp | 2 +- xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp | 2 +- xbmc/filesystem/BlurayDirectory.cpp | 4 +- xbmc/filesystem/HTSPDirectory.cpp | 14 +- xbmc/filesystem/LibraryDirectory.cpp | 2 +- xbmc/filesystem/MultiPathDirectory.cpp | 2 +- xbmc/filesystem/MythDirectory.cpp | 29 +-- xbmc/filesystem/PVRDirectory.cpp | 2 +- xbmc/filesystem/PluginDirectory.cpp | 96 +++------ xbmc/filesystem/PluginDirectory.h | 1 + xbmc/filesystem/RSSDirectory.cpp | 8 +- xbmc/filesystem/RarManager.cpp | 2 +- xbmc/filesystem/SmartPlaylistDirectory.cpp | 2 +- xbmc/filesystem/UPnPDirectory.cpp | 8 +- xbmc/filesystem/test/TestRarFile.cpp | 12 +- xbmc/input/ButtonTranslator.cpp | 4 +- xbmc/interfaces/json-rpc/AudioLibrary.cpp | 6 +- xbmc/interfaces/json-rpc/FileOperations.cpp | 2 +- xbmc/music/GUIViewStateMusic.cpp | 304 ++++++++++---------------- xbmc/music/infoscanner/MusicInfoScanner.cpp | 4 +- xbmc/network/upnp/UPnPServer.cpp | 40 ++-- xbmc/pictures/GUIViewStatePictures.cpp | 20 +- xbmc/pictures/GUIWindowPictures.cpp | 15 +- xbmc/pictures/GUIWindowSlideShow.cpp | 20 +- xbmc/pictures/GUIWindowSlideShow.h | 17 +- xbmc/pictures/PictureThumbLoader.cpp | 2 +- xbmc/programs/GUIViewStatePrograms.cpp | 10 +- xbmc/pvr/windows/GUIViewStatePVR.cpp | 13 +- xbmc/pvr/windows/GUIWindowPVRCommon.cpp | 23 +- xbmc/pvr/windows/GUIWindowPVRCommon.h | 3 +- xbmc/pvr/windows/GUIWindowPVRRecordings.cpp | 4 +- xbmc/pvr/windows/GUIWindowPVRSearch.cpp | 2 +- xbmc/pvr/windows/GUIWindowPVRTimers.cpp | 2 +- xbmc/utils/SortUtils.h | 8 + xbmc/video/GUIViewStateVideo.cpp | 323 ++++++++++++---------------- xbmc/video/VideoDatabase.cpp | 6 +- xbmc/video/VideoInfoScanner.cpp | 2 +- xbmc/video/windows/GUIWindowVideoBase.cpp | 4 +- xbmc/video/windows/GUIWindowVideoNav.cpp | 8 +- xbmc/view/GUIViewState.cpp | 122 ++++++----- xbmc/view/GUIViewState.h | 12 +- xbmc/view/ViewDatabase.cpp | 57 ++++- xbmc/view/ViewDatabase.h | 2 +- xbmc/view/ViewState.h | 14 +- xbmc/view/ViewStateSettings.cpp | 30 ++- xbmc/view/ViewStateSettings.h | 2 +- xbmc/windows/GUIMediaWindow.cpp | 27 +-- xbmc/windows/GUIWindowFileManager.cpp | 2 +- 59 files changed, 700 insertions(+), 764 deletions(-) diff --git a/xbmc/Autorun.cpp b/xbmc/Autorun.cpp index 78f2f6a9fd..75c598d11f 100644 --- a/xbmc/Autorun.cpp +++ b/xbmc/Autorun.cpp @@ -138,7 +138,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded } // Sorting necessary for easier HDDVD handling - vecItems.Sort(SORT_METHOD_LABEL, SortOrderAscending); + vecItems.Sort(SortByLabel, SortOrderAscending); bool bAllowVideo = true; // bool bAllowPictures = true; @@ -220,7 +220,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded { // HD DVD Standard says the highest numbered playlist has to be handled first. CLog::Log(LOGINFO,"HD DVD: Playlist found. Set filetypes to *.xpl for external player."); - items.Sort(SORT_METHOD_LABEL, SortOrderDescending); + items.Sort(SortByLabel, SortOrderDescending); phddvdItem = pItem; hddvdname = URIUtils::GetFileName(items[0]->GetPath()); CLog::Log(LOGINFO,"HD DVD: %s", items[0]->GetPath().c_str()); @@ -240,7 +240,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded { // HD DVD Standard says the lowest numbered ifo has to be handled first. CLog::Log(LOGINFO,"HD DVD: IFO found. Set filename to HV* and filetypes to *.ifo for external player."); - items.Sort(SORT_METHOD_LABEL, SortOrderAscending); + items.Sort(SortByLabel, SortOrderAscending); phddvdItem = pItem; hddvdname = URIUtils::GetFileName(items[0]->GetPath()); CLog::Log(LOGINFO,"HD DVD: %s",items[0]->GetPath().c_str()); @@ -253,7 +253,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded if (items.Size()) { // Sort *.evo files in alphabetical order. - items.Sort(SORT_METHOD_LABEL, SortOrderAscending); + items.Sort(SortByLabel, SortOrderAscending); int64_t asize = 0; int ecount = 0; // calculate average size of elements above 1gb @@ -269,7 +269,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded if (items[j]->m_dwSize >= asize) sitems.Add (items[j]); // Sort *.evo files by size. - items.Sort(SORT_METHOD_SIZE, SortOrderDescending); + items.Sort(SortBySize, SortOrderDescending); // Add other files with descending size to bottom of new list. for (int j = 0; j < items.Size(); j++) if (items[j]->m_dwSize < asize) @@ -329,7 +329,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded CDirectory::GetDirectory(pItem->GetPath(), items, strExt); if (items.Size()) { - items.Sort(SORT_METHOD_LABEL, SortOrderAscending); + items.Sort(SortByLabel, SortOrderAscending); g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Add(PLAYLIST_VIDEO, items); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp index 28088b06b2..5a9301e7a8 100644 --- a/xbmc/FileItem.cpp +++ b/xbmc/FileItem.cpp @@ -1532,8 +1532,6 @@ CFileItemList::CFileItemList() m_fastLookup = false; m_bIsFolder = true; m_cacheToDisc = CACHE_IF_SLOW; - m_sortMethod = SORT_METHOD_NONE; - m_sortOrder = SortOrderNone; m_sortIgnoreFolders = false; m_replaceListing = false; } @@ -1542,8 +1540,6 @@ CFileItemList::CFileItemList(const CStdString& strPath) : CFileItem(strPath, tru { m_fastLookup = false; m_cacheToDisc = CACHE_IF_SLOW; - m_sortMethod = SORT_METHOD_NONE; - m_sortOrder = SortOrderNone; m_sortIgnoreFolders = false; m_replaceListing = false; } @@ -1613,8 +1609,9 @@ void CFileItemList::Clear() CSingleLock lock(m_lock); ClearItems(); - m_sortMethod = SORT_METHOD_NONE; - m_sortOrder = SortOrderNone; + m_sortDescription.sortBy = SortByNone; + m_sortDescription.sortOrder = SortOrderNone; + m_sortDescription.sortAttributes = SortAttributeNone; m_sortIgnoreFolders = false; m_cacheToDisc = CACHE_IF_SLOW; m_sortDetails.clear(); @@ -1715,8 +1712,7 @@ void CFileItemList::Assign(const CFileItemList& itemlist, bool append) SetPath(itemlist.GetPath()); SetLabel(itemlist.GetLabel()); m_sortDetails = itemlist.m_sortDetails; - m_sortMethod = itemlist.m_sortMethod; - m_sortOrder = itemlist.m_sortOrder; + m_sortDescription = itemlist.m_sortDescription; m_replaceListing = itemlist.m_replaceListing; m_content = itemlist.m_content; m_mapProperties = itemlist.m_mapProperties; @@ -1729,13 +1725,12 @@ bool CFileItemList::Copy(const CFileItemList& items, bool copyItems /* = true */ *(CFileItem*)this = *(CFileItem*)&items; // assign the rest of the CFileItemList properties - m_replaceListing = items.m_replaceListing; - m_content = items.m_content; - m_mapProperties = items.m_mapProperties; - m_cacheToDisc = items.m_cacheToDisc; - m_sortDetails = items.m_sortDetails; - m_sortMethod = items.m_sortMethod; - m_sortOrder = items.m_sortOrder; + m_replaceListing = items.m_replaceListing; + m_content = items.m_content; + m_mapProperties = items.m_mapProperties; + m_cacheToDisc = items.m_cacheToDisc; + m_sortDetails = items.m_sortDetails; + m_sortDescription = items.m_sortDescription; m_sortIgnoreFolders = items.m_sortIgnoreFolders; if (copyItems) @@ -1847,26 +1842,24 @@ void CFileItemList::FillSortFields(FILEITEMFILLFUNC func) std::for_each(m_items.begin(), m_items.end(), func); } -void CFileItemList::Sort(SORT_METHOD sortMethod, SortOrder sortOrder) +void CFileItemList::Sort(SortBy sortBy, SortOrder sortOrder, SortAttribute sortAttributes /* = SortAttributeNone */) { - // Already sorted? - if (sortMethod == m_sortMethod && m_sortOrder == sortOrder) + if (sortBy == SortByNone || + (m_sortDescription.sortBy == sortBy && m_sortDescription.sortOrder == sortOrder && + m_sortDescription.sortAttributes == sortAttributes)) return; - SortDescription sorting = SortUtils::TranslateOldSortMethod(sortMethod); + SortDescription sorting; + sorting.sortBy = sortBy; sorting.sortOrder = sortOrder; + sorting.sortAttributes = sortAttributes; Sort(sorting); - - m_sortMethod = sortMethod; - m_sortOrder = sortOrder; + m_sortDescription = sorting; } void CFileItemList::Sort(SortDescription sortDescription) { - if (sortDescription.sortBy == SortByNone) - return; - if (sortDescription.sortBy == SortByFile || sortDescription.sortBy == SortBySortTitle || sortDescription.sortBy == SortByDateAdded || @@ -1877,6 +1870,11 @@ void CFileItemList::Sort(SortDescription sortDescription) sortDescription.sortBy == SortByPlaycount) sortDescription.sortAttributes = (SortAttribute)((int)sortDescription.sortAttributes | SortAttributeIgnoreFolders); + if (sortDescription.sortBy == SortByNone || + (m_sortDescription.sortBy == sortDescription.sortBy && m_sortDescription.sortOrder == sortDescription.sortOrder && + m_sortDescription.sortAttributes == sortDescription.sortAttributes)) + return; + if (m_sortIgnoreFolders) sortDescription.sortAttributes = (SortAttribute)((int)sortDescription.sortAttributes | SortAttributeIgnoreFolders); @@ -1927,8 +1925,9 @@ void CFileItemList::Archive(CArchive& ar) ar << m_fastLookup; - ar << (int)m_sortMethod; - ar << (int)m_sortOrder; + ar << (int)m_sortDescription.sortBy; + ar << (int)m_sortDescription.sortOrder; + ar << (int)m_sortDescription.sortAttributes; ar << m_sortIgnoreFolders; ar << (int)m_cacheToDisc; @@ -1936,7 +1935,9 @@ void CFileItemList::Archive(CArchive& ar) for (unsigned int j = 0; j < m_sortDetails.size(); ++j) { const SORT_METHOD_DETAILS &details = m_sortDetails[j]; - ar << (int)details.m_sortMethod; + ar << (int)details.m_sortDescription.sortBy; + ar << (int)details.m_sortDescription.sortOrder; + ar << (int)details.m_sortDescription.sortAttributes; ar << details.m_buttonLabel; ar << details.m_labelMasks.m_strLabelFile; ar << details.m_labelMasks.m_strLabelFolder; @@ -1986,9 +1987,11 @@ void CFileItemList::Archive(CArchive& ar) int tempint; ar >> (int&)tempint; - m_sortMethod = SORT_METHOD(tempint); + m_sortDescription.sortBy = (SortBy)tempint; + ar >> (int&)tempint; + m_sortDescription.sortOrder = (SortOrder)tempint; ar >> (int&)tempint; - m_sortOrder = SortOrder(tempint); + m_sortDescription.sortAttributes = (SortAttribute)tempint; ar >> m_sortIgnoreFolders; ar >> (int&)tempint; m_cacheToDisc = CACHE_TYPE(tempint); @@ -1999,7 +2002,11 @@ void CFileItemList::Archive(CArchive& ar) { SORT_METHOD_DETAILS details; ar >> (int&)tempint; - details.m_sortMethod = SORT_METHOD(tempint); + details.m_sortDescription.sortBy = (SortBy)tempint; + ar >> (int&)tempint; + details.m_sortDescription.sortOrder = (SortOrder)tempint; + ar >> (int&)tempint; + details.m_sortDescription.sortAttributes = (SortAttribute)tempint; ar >> details.m_buttonLabel; ar >> details.m_labelMasks.m_strLabelFile; ar >> details.m_labelMasks.m_strLabelFolder; @@ -2245,7 +2252,7 @@ void CFileItemList::Stack(bool stackFiles /* = true */) SetProperty("isstacked", true); // items needs to be sorted for stuff below to work properly - Sort(SORT_METHOD_LABEL, SortOrderAscending); + Sort(SortByLabel, SortOrderAscending); StackFolders(); @@ -2364,7 +2371,7 @@ void CFileItemList::StackFolders() item->SetPath(dvdPath); item->SetLabel2(""); item->SetLabelPreformated(true); - m_sortMethod = SORT_METHOD_NONE; /* sorting is now broken */ + m_sortDescription.sortBy = SortByNone; /* sorting is now broken */ } } } @@ -2558,7 +2565,8 @@ bool CFileItemList::Load(int windowID) CLog::Log(LOGDEBUG,"Loading fileitems [%s]",GetPath().c_str()); CArchive ar(&file, CArchive::load); ar >> *this; - CLog::Log(LOGDEBUG," -- items: %i, directory: %s sort method: %i, ascending: %s",Size(),GetPath().c_str(), m_sortMethod, m_sortOrder ? "true" : "false"); + CLog::Log(LOGDEBUG," -- items: %i, directory: %s sort method: %i, ascending: %s", Size(), GetPath().c_str(), m_sortDescription.sortBy, + m_sortDescription.sortOrder == SortOrderAscending ? "true" : "false"); ar.Close(); file.Close(); return true; @@ -2580,7 +2588,7 @@ bool CFileItemList::Save(int windowID) { CArchive ar(&file, CArchive::store); ar << *this; - CLog::Log(LOGDEBUG," -- items: %i, sort method: %i, ascending: %s",iSize,m_sortMethod, m_sortOrder ? "true" : "false"); + CLog::Log(LOGDEBUG," -- items: %i, sort method: %i, ascending: %s", iSize, m_sortDescription.sortBy, m_sortDescription.sortOrder == SortOrderAscending ? "true" : "false"); ar.Close(); file.Close(); return true; @@ -3070,12 +3078,26 @@ bool CFileItemList::UpdateItem(const CFileItem *item) return false; } -void CFileItemList::AddSortMethod(SORT_METHOD sortMethod, int buttonLabel, const LABEL_MASKS &labelMasks) +void CFileItemList::AddSortMethod(SortBy sortBy, int buttonLabel, const LABEL_MASKS &labelMasks, SortAttribute sortAttributes /* = SortAttributeNone */) +{ + AddSortMethod(sortBy, sortAttributes, buttonLabel, labelMasks); +} + +void CFileItemList::AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, int buttonLabel, const LABEL_MASKS &labelMasks) +{ + SortDescription sorting; + sorting.sortBy = sortBy; + sorting.sortAttributes = sortAttributes; + + AddSortMethod(sorting, buttonLabel, labelMasks); +} + +void CFileItemList::AddSortMethod(SortDescription sortDescription, int buttonLabel, const LABEL_MASKS &labelMasks) { SORT_METHOD_DETAILS sort; - sort.m_sortMethod=sortMethod; - sort.m_buttonLabel=buttonLabel; - sort.m_labelMasks=labelMasks; + sort.m_sortDescription = sortDescription; + sort.m_buttonLabel = buttonLabel; + sort.m_labelMasks = labelMasks; m_sortDetails.push_back(sort); } @@ -3087,8 +3109,9 @@ void CFileItemList::SetReplaceListing(bool replace) void CFileItemList::ClearSortState() { - m_sortMethod = SORT_METHOD_NONE; - m_sortOrder = SortOrderNone; + m_sortDescription.sortBy = SortByNone; + m_sortDescription.sortOrder = SortOrderNone; + m_sortDescription.sortAttributes = SortAttributeNone; } CVideoInfoTag* CFileItem::GetVideoInfoTag() diff --git a/xbmc/FileItem.h b/xbmc/FileItem.h index f55d78df98..4253fe1234 100644 --- a/xbmc/FileItem.h +++ b/xbmc/FileItem.h @@ -517,7 +517,7 @@ public: void Assign(const CFileItemList& itemlist, bool append = false); bool Copy (const CFileItemList& item, bool copyItems = true); void Reserve(int iCount); - void Sort(SORT_METHOD sortMethod, SortOrder sortOrder); + void Sort(SortBy sortBy, SortOrder sortOrder, SortAttribute sortAttributes = SortAttributeNone); /* \brief Sorts the items based on the given sorting options In contrast to Sort (see above) this does not change the internal @@ -545,8 +545,8 @@ public: */ void Stack(bool stackFiles = true); - SortOrder GetSortOrder() const { return m_sortOrder; } - SORT_METHOD GetSortMethod() const { return m_sortMethod; } + SortOrder GetSortOrder() const { return m_sortDescription.sortOrder; } + SortBy GetSortMethod() const { return m_sortDescription.sortBy; } /*! \brief load a CFileItemList out of the cache The file list may be cached based on which window we're viewing in, as different @@ -593,7 +593,9 @@ public: */ bool UpdateItem(const CFileItem *item); - void AddSortMethod(SORT_METHOD method, int buttonLabel, const LABEL_MASKS &labelMasks); + void AddSortMethod(SortBy sortBy, int buttonLabel, const LABEL_MASKS &labelMasks, SortAttribute sortAttributes = SortAttributeNone); + void AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, int buttonLabel, const LABEL_MASKS &labelMasks); + void AddSortMethod(SortDescription sortDescription, int buttonLabel, const LABEL_MASKS &labelMasks); bool HasSortDetails() const { return m_sortDetails.size() != 0; }; const std::vector &GetSortDetails() const { return m_sortDetails; }; @@ -630,8 +632,7 @@ private: VECFILEITEMS m_items; MAPFILEITEMS m_map; bool m_fastLookup; - SORT_METHOD m_sortMethod; - SortOrder m_sortOrder; + SortDescription m_sortDescription; bool m_sortIgnoreFolders; CACHE_TYPE m_cacheToDisc; bool m_replaceListing; diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index 3f4bbd8992..3261496ae9 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -1046,10 +1046,8 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition) } else if (prop.name == "sort") { - SORT_METHOD sort = SORT_METHOD_NONE; - if (prop.param().Equals("songrating")) sort = SORT_METHOD_SONG_RATING; - if (sort != SORT_METHOD_NONE) - return AddMultiInfo(GUIInfo(CONTAINER_SORT_METHOD, sort)); + if (prop.param().Equals("songrating")) + return AddMultiInfo(GUIInfo(CONTAINER_SORT_METHOD, SortByRating)); } } else if (cat.name == "listitem") @@ -2867,7 +2865,7 @@ bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, c { const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState(); if (viewState) - bReturn = ((unsigned int)viewState->GetSortMethod() == info.GetData1()); + bReturn = ((unsigned int)viewState->GetSortMethod().sortBy == info.GetData1()); } break; } diff --git a/xbmc/SortFileItem.h b/xbmc/SortFileItem.h index 458b125b24..6296e98963 100644 --- a/xbmc/SortFileItem.h +++ b/xbmc/SortFileItem.h @@ -19,8 +19,6 @@ * */ -#include "utils/LabelFormatter.h" - typedef enum { SORT_METHOD_NONE=0, SORT_METHOD_LABEL, @@ -65,11 +63,3 @@ typedef enum { SORT_METHOD_DATE_TAKEN, SORT_METHOD_MAX } SORT_METHOD; - -typedef struct -{ - SORT_METHOD m_sortMethod; - int m_buttonLabel; - LABEL_MASKS m_labelMasks; -} SORT_METHOD_DETAILS; - diff --git a/xbmc/addons/AddonInstaller.cpp b/xbmc/addons/AddonInstaller.cpp index 5faafcb092..0d43f0c483 100644 --- a/xbmc/addons/AddonInstaller.cpp +++ b/xbmc/addons/AddonInstaller.cpp @@ -413,11 +413,11 @@ void CAddonInstaller::PrunePackageCache() for (std::map::const_iterator it = packs.begin(); it != packs.end();++it) { - it->second->Sort(SORT_METHOD_LABEL,SortOrderDescending); + it->second->Sort(SortByLabel, SortOrderDescending); for (int j=2;jsecond->Size();++j) items.Add(CFileItemPtr(new CFileItem(*it->second->Get(j)))); } - items.Sort(SORT_METHOD_SIZE,SortOrderDescending); + items.Sort(SortBySize, SortOrderDescending); int i=0; while (size > limit && i < items.Size()) { @@ -435,7 +435,7 @@ void CAddonInstaller::PrunePackageCache() if (it->second->Size() > 1) items.Add(CFileItemPtr(new CFileItem(*it->second->Get(1)))); } - items.Sort(SORT_METHOD_DATE,SortOrderAscending); + items.Sort(SortByDate, SortOrderAscending); i=0; while (size > limit && i < items.Size()) { diff --git a/xbmc/addons/GUIDialogAddonInfo.cpp b/xbmc/addons/GUIDialogAddonInfo.cpp index 8e81fe3218..1d4d942fdd 100644 --- a/xbmc/addons/GUIDialogAddonInfo.cpp +++ b/xbmc/addons/GUIDialogAddonInfo.cpp @@ -396,7 +396,7 @@ void CGUIDialogAddonInfo::GrabRollbackVersions() { CFileItemList items; XFILE::CDirectory::GetDirectory("special://home/addons/packages/",items,".zip",DIR_FLAG_NO_FILE_DIRS); - items.Sort(SORT_METHOD_LABEL, SortOrderAscending); + items.Sort(SortByLabel, SortOrderAscending); for (int i=0;im_bIsFolder) diff --git a/xbmc/addons/GUIViewStateAddonBrowser.cpp b/xbmc/addons/GUIViewStateAddonBrowser.cpp index 5dc531a87d..633b9a2ded 100644 --- a/xbmc/addons/GUIViewStateAddonBrowser.cpp +++ b/xbmc/addons/GUIViewStateAddonBrowser.cpp @@ -32,9 +32,9 @@ using namespace ADDON; CGUIViewStateAddonBrowser::CGUIViewStateAddonBrowser(const CFileItemList& items) : CGUIViewState(items) { - AddSortMethod(SORT_METHOD_LABEL_IGNORE_FOLDERS, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | Foldername, empty - AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Filename, Date | Foldername, Date - SetSortMethod(SORT_METHOD_LABEL_IGNORE_FOLDERS); + AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | Foldername, empty + AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Filename, Date | Foldername, Date + SetSortMethod(SortByLabel, SortAttributeIgnoreFolders); SetViewAsControl(DEFAULT_VIEW_AUTO); diff --git a/xbmc/addons/GUIWindowAddonBrowser.cpp b/xbmc/addons/GUIWindowAddonBrowser.cpp index 2e10124c2b..33c9a2be21 100644 --- a/xbmc/addons/GUIWindowAddonBrowser.cpp +++ b/xbmc/addons/GUIWindowAddonBrowser.cpp @@ -448,7 +448,7 @@ int CGUIWindowAddonBrowser::SelectAddonID(const vector &types, CStd item->SetSpecialSort(SortSpecialOnTop); items.Add(item); } - items.Sort(SORT_METHOD_LABEL, SortOrderAscending); + items.Sort(SortByLabel, SortOrderAscending); if (addonIDs.size() > 0) { diff --git a/xbmc/dialogs/GUIDialogFileBrowser.cpp b/xbmc/dialogs/GUIDialogFileBrowser.cpp index a7ca8e34b3..fc45250c05 100644 --- a/xbmc/dialogs/GUIDialogFileBrowser.cpp +++ b/xbmc/dialogs/GUIDialogFileBrowser.cpp @@ -334,7 +334,7 @@ void CGUIDialogFileBrowser::ClearFileItems() void CGUIDialogFileBrowser::OnSort() { if (!m_singleList) - m_vecItems->Sort(SORT_METHOD_LABEL, SortOrderAscending); + m_vecItems->Sort(SortByLabel, SortOrderAscending); } void CGUIDialogFileBrowser::Update(const CStdString &strDirectory) diff --git a/xbmc/dialogs/GUIDialogMediaFilter.cpp b/xbmc/dialogs/GUIDialogMediaFilter.cpp index 5232681925..7a9ca7bdff 100644 --- a/xbmc/dialogs/GUIDialogMediaFilter.cpp +++ b/xbmc/dialogs/GUIDialogMediaFilter.cpp @@ -752,7 +752,7 @@ void CGUIDialogMediaFilter::OnBrowse(const Filter &filter, CFileItemList &items, } // sort the items - selectItems.Sort(SORT_METHOD_LABEL, SortOrderAscending); + selectItems.Sort(SortByLabel, SortOrderAscending); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); diff --git a/xbmc/dialogs/GUIDialogSelect.cpp b/xbmc/dialogs/GUIDialogSelect.cpp index 1b7d4166f3..c635b28bd2 100644 --- a/xbmc/dialogs/GUIDialogSelect.cpp +++ b/xbmc/dialogs/GUIDialogSelect.cpp @@ -228,7 +228,7 @@ bool CGUIDialogSelect::IsButtonPressed() void CGUIDialogSelect::Sort(bool bSortOrder /*=true*/) { - m_vecList->Sort(SORT_METHOD_LABEL, bSortOrder ? SortOrderAscending : SortOrderDescending); + m_vecList->Sort(SortByLabel, bSortOrder ? SortOrderAscending : SortOrderDescending); } void CGUIDialogSelect::SetSelected(int iSelected) diff --git a/xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp b/xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp index a1e4a92106..aa06f377df 100644 --- a/xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp +++ b/xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp @@ -308,7 +308,7 @@ void CGUIDialogSmartPlaylistRule::OnBrowse() } // sort the items - items.Sort(SORT_METHOD_LABEL, SortOrderAscending); + items.Sort(SortByLabel, SortOrderAscending); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); diff --git a/xbmc/filesystem/BlurayDirectory.cpp b/xbmc/filesystem/BlurayDirectory.cpp index 9aa452d912..278434226a 100644 --- a/xbmc/filesystem/BlurayDirectory.cpp +++ b/xbmc/filesystem/BlurayDirectory.cpp @@ -174,8 +174,8 @@ bool CBlurayDirectory::GetDirectory(const CStdString& path, CFileItemList &items else return false; - items.AddSortMethod(SORT_METHOD_TRACKNUM , 554, LABEL_MASKS("%L", "%D", "%L", "")); // FileName, Duration | Foldername, empty - items.AddSortMethod(SORT_METHOD_SIZE , 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // FileName, Size | Foldername, Size + items.AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS("%L", "%D", "%L", "")); // FileName, Duration | Foldername, empty + items.AddSortMethod(SortBySize, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // FileName, Size | Foldername, Size return true; } diff --git a/xbmc/filesystem/HTSPDirectory.cpp b/xbmc/filesystem/HTSPDirectory.cpp index 0253e2b832..d05ccf6f58 100644 --- a/xbmc/filesystem/HTSPDirectory.cpp +++ b/xbmc/filesystem/HTSPDirectory.cpp @@ -389,17 +389,9 @@ bool CHTSPDirectory::GetChannels( const CURL &base items.Add(item); } - items.AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS("%K[ - %B]", "%Z", "%L", "")); - - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - items.AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B", "%Z", "%L", "")); - else - items.AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B", "%Z", "%L", "")); - - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%Z", "%B", "%L", "")); - else - items.AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%Z", "%B", "%L", "")); + items.AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS("%K[ - %B]", "%Z", "%L", "")); + items.AddSortMethod(SortByAlbum, 558, LABEL_MASKS("%B", "%Z", "%L", ""), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); + items.AddSortMethod(SortByLabel, 551, LABEL_MASKS("%Z", "%B", "%L", ""), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); items.SetContent("livetv"); diff --git a/xbmc/filesystem/LibraryDirectory.cpp b/xbmc/filesystem/LibraryDirectory.cpp index 3d4f0fbf7c..f0f30c5dad 100644 --- a/xbmc/filesystem/LibraryDirectory.cpp +++ b/xbmc/filesystem/LibraryDirectory.cpp @@ -140,7 +140,7 @@ bool CLibraryDirectory::GetDirectory(const CStdString& strPath, CFileItemList &i items.Add(item); } } - items.Sort(SORT_METHOD_PLAYLIST_ORDER, SortOrderAscending); + items.Sort(SortByPlaylistOrder, SortOrderAscending); return true; } diff --git a/xbmc/filesystem/MultiPathDirectory.cpp b/xbmc/filesystem/MultiPathDirectory.cpp index 6db139ca80..13c5155e0c 100644 --- a/xbmc/filesystem/MultiPathDirectory.cpp +++ b/xbmc/filesystem/MultiPathDirectory.cpp @@ -260,7 +260,7 @@ void CMultiPathDirectory::MergeItems(CFileItemList &items) return; // sort items by label // folders are before files in this sort method - items.Sort(SORT_METHOD_LABEL, SortOrderAscending); + items.Sort(SortByLabel, SortOrderAscending); int i = 0; // if first item in the sorted list is a file, just abort diff --git a/xbmc/filesystem/MythDirectory.cpp b/xbmc/filesystem/MythDirectory.cpp index f18e2abeef..f83bf6373d 100644 --- a/xbmc/filesystem/MythDirectory.cpp +++ b/xbmc/filesystem/MythDirectory.cpp @@ -150,7 +150,7 @@ bool CMythDirectory::GetGuide(const CStdString& base, CFileItemList &items) } } - items.AddSortMethod(SORT_METHOD_LABEL, 551 /* Name */, LABEL_MASKS("", "", "%K", "")); + items.AddSortMethod(SortByLabel, 551 /* Name */, LABEL_MASKS("", "", "%K", "")); m_dll->ref_release(list); return true; @@ -227,7 +227,7 @@ bool CMythDirectory::GetGuideForChannel(const CStdString& base, CFileItemList &i * result in the guide being shown in the wrong order for skins that sort by date in descending * order by default with no option to change to ascending, e.g. Confluence. */ - items.AddSortMethod(SORT_METHOD_NONE, 552 /* Date */, LABEL_MASKS("%K", "%J")); // Still leave the date label + items.AddSortMethod(SortByNone, 552 /* Date */, LABEL_MASKS("%K", "%J")); // Still leave the date label m_dll->ref_release(program); return true; @@ -325,13 +325,8 @@ bool CMythDirectory::GetRecordings(const CStdString& base, CFileItemList &items, * the subtitle doesn't influence the sort order and they are sorted by date. */ if (type != TV_SHOWS) - { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%K", "%J")); - else - items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%K", "%J")); - } - items.AddSortMethod(SORT_METHOD_DATE, 552 /* Date */, LABEL_MASKS("%K", "%J")); + items.AddSortMethod(SortBySortTitle, 556 /* Name */, LABEL_MASKS("%K", "%J"), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); + items.AddSortMethod(SortByDate, 552 /* Date */, LABEL_MASKS("%K", "%J")); return true; } @@ -392,11 +387,8 @@ bool CMythDirectory::GetTvShowFolders(const CStdString& base, CFileItemList &ite } m_dll->ref_release(list); - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551 /* Name */, LABEL_MASKS("", "", "%L", "%J")); - else - items.AddSortMethod(SORT_METHOD_LABEL, 551 /* Name */, LABEL_MASKS("", "", "%L", "%J")); - items.AddSortMethod(SORT_METHOD_DATE, 552 /* Date */, LABEL_MASKS("", "", "%L", "%J")); + items.AddSortMethod(SortByLabel, 551 /* Name */, LABEL_MASKS("", "", "%L", "%J"), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); + items.AddSortMethod(SortByDate, 552 /* Date */, LABEL_MASKS("", "", "%L", "%J")); return true; } @@ -464,15 +456,12 @@ bool CMythDirectory::GetChannels(const CStdString& base, CFileItemList &items) m_dll->ref_release(program); } - items.AddSortMethod(SORT_METHOD_LABEL, 551 /* Name */, LABEL_MASKS("%K", "%B")); + items.AddSortMethod(SortByLabel, 551 /* Name */, LABEL_MASKS("%K", "%B")); /* * Video sort title is set to the channel number. */ - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556 /* Title */, LABEL_MASKS("%K", "%B")); - else - items.AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556 /* Title */, LABEL_MASKS("%K", "%B")); + items.AddSortMethod(SortBySortTitle, 556 /* Title */, LABEL_MASKS("%K", "%B"), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); return true; } @@ -528,7 +517,7 @@ bool CMythDirectory::GetDirectory(const CStdString& strPath, CFileItemList &item item->SetLabel(g_localizeStrings.Get(22020)); // Guide items.Add(item); - items.AddSortMethod(SORT_METHOD_NONE, 564 /* Type */, LABEL_MASKS("", "", "%L", "")); // No sorting, as added to list. + items.AddSortMethod(SortByNone, 564 /* Type */, LABEL_MASKS("", "", "%L", "")); // No sorting, as added to list. /* * Clear the directory cache so the cached sub-folders are guaranteed to be accurate. diff --git a/xbmc/filesystem/PVRDirectory.cpp b/xbmc/filesystem/PVRDirectory.cpp index 21ac6d3de4..9c226ee6ba 100644 --- a/xbmc/filesystem/PVRDirectory.cpp +++ b/xbmc/filesystem/PVRDirectory.cpp @@ -92,7 +92,7 @@ bool CPVRDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items items.Add(item); // Sort by name only. Labels are preformated. - items.AddSortMethod(SORT_METHOD_LABEL, 551 /* Name */, LABEL_MASKS("%L", "", "%L", "")); + items.AddSortMethod(SortByLabel, 551 /* Name */, LABEL_MASKS("%L", "", "%L", "")); return true; } diff --git a/xbmc/filesystem/PluginDirectory.cpp b/xbmc/filesystem/PluginDirectory.cpp index c99b99c0cf..438cd7b044 100644 --- a/xbmc/filesystem/PluginDirectory.cpp +++ b/xbmc/filesystem/PluginDirectory.cpp @@ -209,7 +209,7 @@ void CPluginDirectory::EndOfDirectory(int handle, bool success, bool replaceList dir->m_listItems->SetReplaceListing(replaceListing); if (!dir->m_listItems->HasSortDetails()) - dir->m_listItems->AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS("%L", "%D")); + dir->m_listItems->AddSortMethod(SortByNone, 552, LABEL_MASKS("%L", "%D")); // set the event to mark that we're done dir->m_fetchComplete.Set(); @@ -228,145 +228,119 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const C case SORT_METHOD_LABEL: case SORT_METHOD_LABEL_IGNORE_THE: { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - dir->m_listItems->AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T", label2Mask)); - else - dir->m_listItems->AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByLabel, 551, LABEL_MASKS("%T", label2Mask), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); break; } case SORT_METHOD_TITLE: case SORT_METHOD_TITLE_IGNORE_THE: { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - dir->m_listItems->AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", label2Mask)); - else - dir->m_listItems->AddSortMethod(SORT_METHOD_TITLE, 556, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByTitle, 556, LABEL_MASKS("%T", label2Mask), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); break; } case SORT_METHOD_ARTIST: case SORT_METHOD_ARTIST_IGNORE_THE: { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - dir->m_listItems->AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%T", "%A")); - else - dir->m_listItems->AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%T", "%A")); + dir->m_listItems->AddSortMethod(SortByArtist, 557, LABEL_MASKS("%T", "%A"), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); break; } case SORT_METHOD_ALBUM: case SORT_METHOD_ALBUM_IGNORE_THE: { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - dir->m_listItems->AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%T", "%B")); - else - dir->m_listItems->AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%T", "%B")); + dir->m_listItems->AddSortMethod(SortByAlbum, 558, LABEL_MASKS("%T", "%B"), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); break; } case SORT_METHOD_DATE: { - dir->m_listItems->AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%T", "%J")); + dir->m_listItems->AddSortMethod(SortByDate, 552, LABEL_MASKS("%T", "%J")); break; } case SORT_METHOD_BITRATE: { - dir->m_listItems->AddSortMethod(SORT_METHOD_BITRATE, 623, LABEL_MASKS("%T", "%X")); + dir->m_listItems->AddSortMethod(SortByBitrate, 623, LABEL_MASKS("%T", "%X")); break; } case SORT_METHOD_SIZE: { - dir->m_listItems->AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS("%T", "%I")); + dir->m_listItems->AddSortMethod(SortBySize, 553, LABEL_MASKS("%T", "%I")); break; } case SORT_METHOD_FILE: { - dir->m_listItems->AddSortMethod(SORT_METHOD_FILE, 561, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByFile, 561, LABEL_MASKS("%T", label2Mask)); break; } case SORT_METHOD_TRACKNUM: { - dir->m_listItems->AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS("[%N. ]%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS("[%N. ]%T", label2Mask)); break; } case SORT_METHOD_DURATION: + case SORT_METHOD_VIDEO_RUNTIME: { - dir->m_listItems->AddSortMethod(SORT_METHOD_DURATION, 180, LABEL_MASKS("%T", "%D")); + dir->m_listItems->AddSortMethod(SortByTime, 180, LABEL_MASKS("%T", "%D")); break; } case SORT_METHOD_VIDEO_RATING: + case SORT_METHOD_SONG_RATING: { - dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%T", "%R")); + dir->m_listItems->AddSortMethod(SortByRating, 563, LABEL_MASKS("%T", "%R")); break; } case SORT_METHOD_YEAR: { - dir->m_listItems->AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y")); - break; - } - case SORT_METHOD_SONG_RATING: - { - dir->m_listItems->AddSortMethod(SORT_METHOD_SONG_RATING, 563, LABEL_MASKS("%T", "%R")); + dir->m_listItems->AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y")); break; } case SORT_METHOD_GENRE: { - dir->m_listItems->AddSortMethod(SORT_METHOD_GENRE, 515, LABEL_MASKS("%T", "%G")); + dir->m_listItems->AddSortMethod(SortByGenre, 515, LABEL_MASKS("%T", "%G")); break; } case SORT_METHOD_COUNTRY: { - dir->m_listItems->AddSortMethod(SORT_METHOD_COUNTRY, 574, LABEL_MASKS("%T", "%G")); + dir->m_listItems->AddSortMethod(SortByCountry, 574, LABEL_MASKS("%T", "%G")); break; } case SORT_METHOD_VIDEO_TITLE: { - dir->m_listItems->AddSortMethod(SORT_METHOD_VIDEO_TITLE, 369, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByTitle, 369, LABEL_MASKS("%T", label2Mask)); break; } case SORT_METHOD_VIDEO_SORT_TITLE: case SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE: { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - 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, 556, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortBySortTitle, 556, LABEL_MASKS("%T", label2Mask), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); break; } case SORT_METHOD_MPAA_RATING: { - 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, 180, LABEL_MASKS("%T", "%D")); + dir->m_listItems->AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O")); break; } case SORT_METHOD_STUDIO: case SORT_METHOD_STUDIO_IGNORE_THE: { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - dir->m_listItems->AddSortMethod(SORT_METHOD_STUDIO_IGNORE_THE, 572, LABEL_MASKS("%T", "%U")); - else - dir->m_listItems->AddSortMethod(SORT_METHOD_STUDIO, 572, LABEL_MASKS("%T", "%U")); + dir->m_listItems->AddSortMethod(SortByStudio, 572, LABEL_MASKS("%T", "%U"), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); break; } case SORT_METHOD_PROGRAM_COUNT: { - dir->m_listItems->AddSortMethod(SORT_METHOD_PROGRAM_COUNT, 567, LABEL_MASKS("%T", "%C")); + dir->m_listItems->AddSortMethod(SortByProgramCount, 567, LABEL_MASKS("%T", "%C")); break; } case SORT_METHOD_UNSORTED: { - dir->m_listItems->AddSortMethod(SORT_METHOD_UNSORTED, 571, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByNone, 571, LABEL_MASKS("%T", label2Mask)); break; } case SORT_METHOD_NONE: { - dir->m_listItems->AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByNone, 552, LABEL_MASKS("%T", label2Mask)); break; } case SORT_METHOD_DRIVE_TYPE: { - dir->m_listItems->AddSortMethod(SORT_METHOD_DRIVE_TYPE, 564, LABEL_MASKS()); // Preformatted + dir->m_listItems->AddSortMethod(SortByDriveType, 564, LABEL_MASKS()); // Preformatted break; } case SORT_METHOD_PLAYLIST_ORDER: @@ -374,53 +348,53 @@ void CPluginDirectory::AddSortMethod(int handle, SORT_METHOD sortMethod, const C CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright"); - dir->m_listItems->AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS(strTrackLeft, strTrackRight)); + dir->m_listItems->AddSortMethod(SortByPlaylistOrder, 559, LABEL_MASKS(strTrackLeft, strTrackRight)); break; } case SORT_METHOD_EPISODE: { - dir->m_listItems->AddSortMethod(SORT_METHOD_EPISODE,20359,LABEL_MASKS("%E. %T","%R")); + dir->m_listItems->AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%E. %T","%R")); break; } case SORT_METHOD_PRODUCTIONCODE: { //dir->m_listItems.AddSortMethod(SORT_METHOD_PRODUCTIONCODE,20368,LABEL_MASKS("%E. %T","%P", "%E. %T","%P")); - dir->m_listItems->AddSortMethod(SORT_METHOD_PRODUCTIONCODE,20368,LABEL_MASKS("%H. %T","%P", "%H. %T","%P")); + dir->m_listItems->AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%H. %T","%P", "%H. %T","%P")); break; } case SORT_METHOD_LISTENERS: { - dir->m_listItems->AddSortMethod(SORT_METHOD_LISTENERS,20455,LABEL_MASKS("%T","%W")); + dir->m_listItems->AddSortMethod(SortByListeners, 20455, LABEL_MASKS("%T","%W")); break; } case SORT_METHOD_DATEADDED: { - dir->m_listItems->AddSortMethod(SORT_METHOD_DATEADDED, 570, LABEL_MASKS("%T", "%a")); + dir->m_listItems->AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T", "%a")); break; } case SORT_METHOD_FULLPATH: { - dir->m_listItems->AddSortMethod(SORT_METHOD_FULLPATH, 573, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByPath, 573, LABEL_MASKS("%T", label2Mask)); break; } case SORT_METHOD_LABEL_IGNORE_FOLDERS: { - dir->m_listItems->AddSortMethod(SORT_METHOD_LABEL_IGNORE_FOLDERS, 551, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS("%T", label2Mask)); break; } case SORT_METHOD_LASTPLAYED: { - dir->m_listItems->AddSortMethod(SORT_METHOD_LASTPLAYED, 568, LABEL_MASKS("%T", "%G")); + dir->m_listItems->AddSortMethod(SortByLastPlayed, 568, LABEL_MASKS("%T", "%G")); break; } case SORT_METHOD_PLAYCOUNT: { - dir->m_listItems->AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V")); + dir->m_listItems->AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V")); break; } case SORT_METHOD_CHANNEL: { - dir->m_listItems->AddSortMethod(SORT_METHOD_CHANNEL, 19029, LABEL_MASKS("%T", label2Mask)); + dir->m_listItems->AddSortMethod(SortByChannel, 19029, LABEL_MASKS("%T", label2Mask)); break; } diff --git a/xbmc/filesystem/PluginDirectory.h b/xbmc/filesystem/PluginDirectory.h index 50699c215c..35cd2276cd 100644 --- a/xbmc/filesystem/PluginDirectory.h +++ b/xbmc/filesystem/PluginDirectory.h @@ -33,6 +33,7 @@ #include "threads/Event.h" class CURL; +class CFileItem; class CFileItemList; namespace XFILE diff --git a/xbmc/filesystem/RSSDirectory.cpp b/xbmc/filesystem/RSSDirectory.cpp index 0cd44b11fb..965c405a17 100644 --- a/xbmc/filesystem/RSSDirectory.cpp +++ b/xbmc/filesystem/RSSDirectory.cpp @@ -613,10 +613,10 @@ bool CRSSDirectory::GetDirectory(const CStdString& path, CFileItemList &items) items.Add(item); } - items.AddSortMethod(SORT_METHOD_UNSORTED , 231, LABEL_MASKS("%L", "%D", "%L", "")); // FileName, Duration | Foldername, empty - items.AddSortMethod(SORT_METHOD_LABEL , 551, LABEL_MASKS("%L", "%D", "%L", "")); // FileName, Duration | Foldername, empty - items.AddSortMethod(SORT_METHOD_SIZE , 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // FileName, Size | Foldername, Size - items.AddSortMethod(SORT_METHOD_DATE , 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // FileName, Date | Foldername, Date + items.AddSortMethod(SortByNone , 231, LABEL_MASKS("%L", "%D", "%L", "")); // FileName, Duration | Foldername, empty + items.AddSortMethod(SortByLabel , 551, LABEL_MASKS("%L", "%D", "%L", "")); // FileName, Duration | Foldername, empty + items.AddSortMethod(SortBySize , 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // FileName, Size | Foldername, Size + items.AddSortMethod(SortByDate , 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // FileName, Date | Foldername, Date CDateTime time = CDateTime::GetCurrentDateTime(); int mins = 60; diff --git a/xbmc/filesystem/RarManager.cpp b/xbmc/filesystem/RarManager.cpp index ed77d0d930..cee70e7f91 100644 --- a/xbmc/filesystem/RarManager.cpp +++ b/xbmc/filesystem/RarManager.cpp @@ -117,7 +117,7 @@ bool CRarManager::CacheRarredFile(CStdString& strPathInCache, const CStdString& { CFileItemList items; CDirectory::GetDirectory(g_advancedSettings.m_cachePath,items); - items.Sort(SORT_METHOD_SIZE, SortOrderDescending); + items.Sort(SortBySize, SortOrderDescending); while (items.Size() && CheckFreeSpace(strDir) < iSize) { if (!items[0]->m_bIsFolder) diff --git a/xbmc/filesystem/SmartPlaylistDirectory.cpp b/xbmc/filesystem/SmartPlaylistDirectory.cpp index 6528ddb66f..2b779da4b8 100644 --- a/xbmc/filesystem/SmartPlaylistDirectory.cpp +++ b/xbmc/filesystem/SmartPlaylistDirectory.cpp @@ -287,7 +287,7 @@ namespace XFILE // sort grouped list by label if (items.Size() > 1 && !group.empty()) - items.Sort(SORT_METHOD_LABEL_IGNORE_THE, SortOrderAscending); + items.Sort(SortByLabel, SortOrderAscending, SortAttributeIgnoreArticle); // go through and set the playlist order for (int i = 0; i < items.Size(); i++) diff --git a/xbmc/filesystem/UPnPDirectory.cpp b/xbmc/filesystem/UPnPDirectory.cpp index 8f3347175f..223e3edfdf 100644 --- a/xbmc/filesystem/UPnPDirectory.cpp +++ b/xbmc/filesystem/UPnPDirectory.cpp @@ -355,10 +355,10 @@ CUPnPDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items) items.SetContent(content); if (content == "unknown") { - items.AddSortMethod(SORT_METHOD_UNSORTED, 571, LABEL_MASKS("%L", "%I", "%L", "")); - items.AddSortMethod(SORT_METHOD_LABEL_IGNORE_FOLDERS, 551, LABEL_MASKS("%L", "%I", "%L", "")); - items.AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); - items.AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); + items.AddSortMethod(SortByNone, 571, LABEL_MASKS("%L", "%I", "%L", "")); + items.AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS("%L", "%I", "%L", "")); + items.AddSortMethod(SortBySize, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); + items.AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); } } diff --git a/xbmc/filesystem/test/TestRarFile.cpp b/xbmc/filesystem/test/TestRarFile.cpp index 898222af91..9fcf914142 100644 --- a/xbmc/filesystem/test/TestRarFile.cpp +++ b/xbmc/filesystem/test/TestRarFile.cpp @@ -202,7 +202,7 @@ TEST(TestRarFile, StoredRAR) reffile = XBMC_REF_FILE_PATH("xbmc/filesystem/test/refRARstored.rar"); URIUtils::CreateArchivePath(strrarpath, "rar", reffile, ""); ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strrarpath, itemlist)); - itemlist.Sort(SORT_METHOD_FULLPATH, SortOrderAscending); + itemlist.Sort(SortByPath, SortOrderAscending); /* /reffile.txt */ /* @@ -286,7 +286,7 @@ TEST(TestRarFile, StoredRAR) itemlist.Clear(); ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strpathinrar, itemlist)); - itemlist.Sort(SORT_METHOD_FULLPATH, SortOrderAscending); + itemlist.Sort(SortByPath, SortOrderAscending); /* /testdir/reffile.txt */ strpathinrar = itemlist[1]->GetPath(); @@ -367,7 +367,7 @@ TEST(TestRarFile, StoredRAR) itemlist.Clear(); ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strpathinrar, itemlist)); - itemlist.Sort(SORT_METHOD_FULLPATH, SortOrderAscending); + itemlist.Sort(SortByPath, SortOrderAscending); /* /testdir/testsubdir/reffile.txt */ strpathinrar = itemlist[0]->GetPath(); @@ -428,7 +428,7 @@ TEST(TestRarFile, NormalRAR) reffile = XBMC_REF_FILE_PATH("xbmc/filesystem/test/refRARnormal.rar"); URIUtils::CreateArchivePath(strrarpath, "rar", reffile, ""); ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strrarpath, itemlist)); - itemlist.Sort(SORT_METHOD_FULLPATH, SortOrderAscending); + itemlist.Sort(SortByPath, SortOrderAscending); /* /reffile.txt */ strpathinrar = itemlist[1]->GetPath(); @@ -508,7 +508,7 @@ TEST(TestRarFile, NormalRAR) itemlist.Clear(); ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strpathinrar, itemlist)); - itemlist.Sort(SORT_METHOD_FULLPATH, SortOrderAscending); + itemlist.Sort(SortByPath, SortOrderAscending); /* /testdir/reffile.txt */ strpathinrar = itemlist[1]->GetPath(); @@ -589,7 +589,7 @@ TEST(TestRarFile, NormalRAR) itemlist.Clear(); ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strpathinrar, itemlist)); - itemlist.Sort(SORT_METHOD_FULLPATH, SortOrderAscending); + itemlist.Sort(SortByPath, SortOrderAscending); /* /testdir/testsubdir/reffile.txt */ strpathinrar = itemlist[0]->GetPath(); diff --git a/xbmc/input/ButtonTranslator.cpp b/xbmc/input/ButtonTranslator.cpp index 811caf00f5..d8760e0945 100644 --- a/xbmc/input/ButtonTranslator.cpp +++ b/xbmc/input/ButtonTranslator.cpp @@ -529,7 +529,7 @@ bool CButtonTranslator::Load(bool AlwaysLoad) CFileItemList files; XFILE::CDirectory::GetDirectory(DIRS_TO_CHECK[dirIndex], files, ".xml"); // Sort the list for filesystem based priorities, e.g. 01-keymap.xml, 02-keymap-overrides.xml - files.Sort(SORT_METHOD_FILE, SortOrderAscending); + files.Sort(SortByFile, SortOrderAscending); for(int fileIndex = 0; fileIndexm_bIsFolder) @@ -548,7 +548,7 @@ bool CButtonTranslator::Load(bool AlwaysLoad) CFileItemList files; XFILE::CDirectory::GetDirectory(devicedir, files, ".xml"); // Sort the list for filesystem based priorities, e.g. 01-keymap.xml, 02-keymap-overrides.xml - files.Sort(SORT_METHOD_FILE, SortOrderAscending); + files.Sort(SortByFile, SortOrderAscending); for(int fileIndex = 0; fileIndexm_bIsFolder) diff --git a/xbmc/interfaces/json-rpc/AudioLibrary.cpp b/xbmc/interfaces/json-rpc/AudioLibrary.cpp index ec4a81eaaa..716e91aabc 100644 --- a/xbmc/interfaces/json-rpc/AudioLibrary.cpp +++ b/xbmc/interfaces/json-rpc/AudioLibrary.cpp @@ -638,14 +638,14 @@ bool CAudioLibrary::FillFileItemList(const CVariant ¶meterObject, CFileItemL // If we retrieved the list of songs by "artistid" // we sort by album (and implicitly by track number) if (artistID != -1) - list.Sort(SORT_METHOD_ALBUM_IGNORE_THE, SortOrderAscending); + list.Sort(SortByAlbum, SortOrderAscending, SortAttributeIgnoreArticle); // If we retrieve the list of songs by "genreid" // we sort by artist (and implicitly by album and track number) else if (genreID != -1) - list.Sort(SORT_METHOD_ARTIST_IGNORE_THE, SortOrderAscending); + list.Sort(SortByArtist, SortOrderAscending, SortAttributeIgnoreArticle); // otherwise we sort by track number else - list.Sort(SORT_METHOD_TRACKNUM, SortOrderAscending); + list.Sort(SortByTrackNumber, SortOrderAscending); } diff --git a/xbmc/interfaces/json-rpc/FileOperations.cpp b/xbmc/interfaces/json-rpc/FileOperations.cpp index ee516a31b6..5bc094d6b6 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.cpp +++ b/xbmc/interfaces/json-rpc/FileOperations.cpp @@ -314,7 +314,7 @@ bool CFileOperations::FillFileItemList(const CVariant ¶meterObject, CFileIte CDirectory directory; if (directory.GetDirectory(strPath, items, extensions)) { - items.Sort(SORT_METHOD_FILE, SortOrderAscending); + items.Sort(SortByFile, SortOrderAscending); CFileItemList filteredDirectories; for (unsigned int i = 0; i < (unsigned int)items.Size(); i++) { diff --git a/xbmc/music/GUIViewStateMusic.cpp b/xbmc/music/GUIViewStateMusic.cpp index bb82a61bac..0526af1979 100644 --- a/xbmc/music/GUIViewStateMusic.cpp +++ b/xbmc/music/GUIViewStateMusic.cpp @@ -82,20 +82,16 @@ CGUIViewStateMusicSearch::CGUIViewStateMusicSearch(const CFileItemList& items) : if (strAlbumRight.IsEmpty()) strAlbumRight = "%A"; // artist + SortAttribute sortAttribute = SortAttributeNone; if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - { - AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D", "%L", "%A")); // Title, Artist, Duration| empty, empty - SetSortMethod(SORT_METHOD_TITLE_IGNORE_THE); - } - else - { - AddSortMethod(SORT_METHOD_TITLE, 556, LABEL_MASKS("%T - %A", "%D", "%L", "%A")); // Title, Artist, Duration| empty, empty - SetSortMethod(SORT_METHOD_TITLE); - } + sortAttribute = SortAttributeIgnoreArticle; + + AddSortMethod(SortByTitle, sortAttribute, 556, LABEL_MASKS("%T - %A", "%D", "%L", "%A")); // Title, Artist, Duration| empty, empty + SetSortMethod(SortByTitle, sortAttribute); const CViewState *viewState = CViewStateSettings::Get().Get("musicnavsongs"); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); LoadViewState(items.GetPath(), WINDOW_MUSIC_NAV); } @@ -127,12 +123,16 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item CLog::Log(LOGDEBUG,"Album format left = [%s]", strAlbumLeft.c_str()); CLog::Log(LOGDEBUG,"Album format right = [%s]", strAlbumRight.c_str()); + SortAttribute sortAttribute = SortAttributeNone; + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) + sortAttribute = SortAttributeIgnoreArticle; + switch (NodeType) { case NODE_TYPE_OVERVIEW: { - AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "", "%L", "")); // Filename, empty | Foldername, empty - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "", "%L", "")); // Filename, empty | Foldername, empty + SetSortMethod(SortByNone); SetViewAsControl(DEFAULT_VIEW_LIST); @@ -141,8 +141,8 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item break; case NODE_TYPE_TOP100: { - AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "", "%L", "")); // Filename, empty | Foldername, empty - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "", "%L", "")); // Filename, empty | Foldername, empty + SetSortMethod(SortByNone); SetViewAsControl(DEFAULT_VIEW_LIST); @@ -151,8 +151,8 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item break; case NODE_TYPE_GENRE: { - AddSortMethod(SORT_METHOD_GENRE, 515, LABEL_MASKS("%F", "", "%G", "")); // Filename, empty | Genre, empty - SetSortMethod(SORT_METHOD_GENRE); + AddSortMethod(SortByGenre, 515, LABEL_MASKS("%F", "", "%G", "")); // Filename, empty | Genre, empty + SetSortMethod(SortByGenre); SetViewAsControl(DEFAULT_VIEW_LIST); @@ -161,8 +161,8 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item break; case NODE_TYPE_YEAR: { - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%F", "", "%Y", "")); // Filename, empty | Year, empty - SetSortMethod(SORT_METHOD_LABEL); + AddSortMethod(SortByLabel, 551, LABEL_MASKS("%F", "", "%Y", "")); // Filename, empty | Year, empty + SetSortMethod(SortByLabel); SetViewAsControl(DEFAULT_VIEW_LIST); @@ -171,20 +171,12 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item break; case NODE_TYPE_ARTIST: { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - { - 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, 557, LABEL_MASKS("%F", "", "%A", "")); // Filename, empty | Artist, empty - SetSortMethod(SORT_METHOD_ARTIST); - } + AddSortMethod(SortByArtist, sortAttribute, 557, LABEL_MASKS("%F", "", "%A", "")); // Filename, empty | Artist, empty + SetSortMethod(SortByArtist, sortAttribute); const CViewState *viewState = CViewStateSettings::Get().Get("musicnavartists"); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } break; case NODE_TYPE_ALBUM_COMPILATIONS: @@ -192,30 +184,22 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item case NODE_TYPE_YEAR_ALBUM: { // album - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined - else - AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined - + AddSortMethod(SortByAlbum, sortAttribute, 558, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined // artist - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined - else - AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined - + AddSortMethod(SortByArtist, sortAttribute, 557, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined // year - AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); + AddSortMethod(SortByYear, 562, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); const CViewState *viewState = CViewStateSettings::Get().Get("musicnavalbums"); - SetSortMethod(viewState->m_sortMethod); + SetSortMethod(viewState->m_sortDescription); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } break; case NODE_TYPE_ALBUM_RECENTLY_ADDED: { - AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 552, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined + SetSortMethod(SortByNone); SetViewAsControl(CViewStateSettings::Get().Get("musicnavalbums")->m_viewMode); @@ -224,8 +208,8 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item break; case NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS: { - AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 552, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty + SetSortMethod(SortByNone); SetViewAsControl(CViewStateSettings::Get().Get("musicnavsongs")->m_viewMode); @@ -234,8 +218,8 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item break; case NODE_TYPE_ALBUM_RECENTLY_PLAYED: { - AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined + SetSortMethod(SortByNone); SetViewAsControl(CViewStateSettings::Get().Get("musicnavalbums")->m_viewMode); @@ -244,8 +228,8 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item break; case NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS: { - AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 551, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty + SetSortMethod(SortByNone); SetViewAsControl(CViewStateSettings::Get().Get("musicnavalbums")->m_viewMode); @@ -254,8 +238,8 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item break; case NODE_TYPE_ALBUM_TOP100: { - AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined + SetSortMethod(SortByNone); SetViewAsControl(DEFAULT_VIEW_LIST); SetSortOrder(SortOrderNone); @@ -263,25 +247,16 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item break; case NODE_TYPE_SINGLES: { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - { - AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Title, Duration| empty, empty - AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty - AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS(strTrackLeft, strTrackRight)); - } - else - { - AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Title, Duration| empty, empty - 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, 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(SortByArtist, sortAttribute, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Title, Duration| empty, empty + AddSortMethod(SortByTitle, sortAttribute, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty + AddSortMethod(SortByLabel, sortAttribute, 551, LABEL_MASKS(strTrackLeft, strTrackRight)); + AddSortMethod(SortByTime, 180, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty + AddSortMethod(SortByRating, 563, LABEL_MASKS("%T - %A", "%R")); // Title - Artist, Rating const CViewState *viewState = CViewStateSettings::Get().Get("musicnavsongs"); - SetSortMethod(viewState->m_sortMethod); + SetSortMethod(viewState->m_sortDescription); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } break; case NODE_TYPE_ALBUM_COMPILATIONS_SONGS: @@ -289,43 +264,33 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item case NODE_TYPE_YEAR_SONG: case NODE_TYPE_SONG: { - AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined| empty, empty - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - { - AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty - AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T - %A", "%D")); // Album, Title, Artist, Duration| empty, empty - AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Title, Duration| empty, empty - AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS(strTrackLeft, strTrackRight)); - } - else - { - AddSortMethod(SORT_METHOD_TITLE, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty - AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B - %T - %A", "%D")); // Album, Title, Artist, Duration| empty, empty - 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, 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 + AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined| empty, empty + AddSortMethod(SortByTitle, sortAttribute, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty + AddSortMethod(SortByAlbum, sortAttribute, 558, LABEL_MASKS("%B - %T - %A", "%D")); // Album, Title, Artist, Duration| empty, empty + AddSortMethod(SortByArtist, sortAttribute, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Title, Duration| empty, empty + AddSortMethod(SortByLabel, sortAttribute, 551, LABEL_MASKS(strTrackLeft, strTrackRight)); + AddSortMethod(SortByTime, 180, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty + AddSortMethod(SortByRating, 563, LABEL_MASKS("%T - %A", "%R")); // Title - Artist, Rating + AddSortMethod(SortByYear, 562, LABEL_MASKS("%T - %A", "%Y")); // Title, Artist, Year const CViewState *viewState = CViewStateSettings::Get().Get("musicnavsongs"); - // the "All Albums" entries always default to SORT_METHOD_ALBUM as this is most logical - user can always + // the "All Albums" entries always default to SortByAlbum as this is most logical - user can always // change it and the change will be saved for this particular path if (dir.IsAllItem(items.GetPath())) - SetSortMethod(CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SORT_METHOD_ALBUM_IGNORE_THE : SORT_METHOD_ALBUM); + SetSortMethod(SortByAlbum, sortAttribute); else - SetSortMethod(viewState->m_sortMethod); + SetSortMethod(viewState->m_sortDescription); - AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T - %A", "%V")); // Titel - Artist, PlayCount + AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T - %A", "%V")); // Titel - Artist, PlayCount SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } break; case NODE_TYPE_SONG_TOP100: { - AddSortMethod(SORT_METHOD_NONE, 576, LABEL_MASKS("%T - %A", "%V")); - SetSortMethod(SORT_METHOD_PLAYCOUNT); + AddSortMethod(SortByNone, 576, LABEL_MASKS("%T - %A", "%V")); + SetSortMethod(SortByPlaycount); SetViewAsControl(CViewStateSettings::Get().Get("musicnavsongs")->m_viewMode); @@ -376,31 +341,24 @@ void CGUIViewStateMusicDatabase::SaveViewState() } } - CGUIViewStateMusicSmartPlaylist::CGUIViewStateMusicSmartPlaylist(const CFileItemList& items) : CGUIViewStateWindowMusic(items) { + SortAttribute sortAttribute = SortAttributeNone; + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) + sortAttribute = SortAttributeIgnoreArticle; + if (items.GetContent() == "songs" || items.GetContent() == "mixed") { CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright"); - AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined| empty, empty - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - { - AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty - AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T - %A", "%D")); // Album, Titel, Artist, Duration| empty, empty - AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Titel, Duration| empty, empty - AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS(strTrackLeft, strTrackRight)); - } - else - { - AddSortMethod(SORT_METHOD_TITLE, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty - AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B - %T - %A", "%D")); // Album, Titel, Artist, Duration| empty, empty - 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, 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 + AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined| empty, empty + AddSortMethod(SortByTitle, sortAttribute, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty + AddSortMethod(SortByAlbum, sortAttribute, 558, LABEL_MASKS("%B - %T - %A", "%D")); // Album, Titel, Artist, Duration| empty, empty + AddSortMethod(SortByArtist, sortAttribute, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Titel, Duration| empty, empty + AddSortMethod(SortByLabel, sortAttribute, 551, LABEL_MASKS(strTrackLeft, strTrackRight)); + AddSortMethod(SortByTime, 180, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty + AddSortMethod(SortByRating, 563, LABEL_MASKS("%T - %A", "%R")); // Titel, Artist, Rating| empty, empty AddPlaylistOrder(items, LABEL_MASKS(strTrackLeft, strTrackRight)); SetViewAsControl(CViewStateSettings::Get().Get("musicnavsongs")->m_viewMode); @@ -415,19 +373,11 @@ CGUIViewStateMusicSmartPlaylist::CGUIViewStateMusicSmartPlaylist(const CFileItem strAlbumRight = "%A"; // artist // album - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined - else - AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined - + AddSortMethod(SortByAlbum, sortAttribute, 558, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined // artist - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined - else - AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined - + AddSortMethod(SortByArtist, sortAttribute, 557, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); // Filename, empty | Userdefined, Userdefined // year - AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); + AddSortMethod(SortByYear, 562, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); AddPlaylistOrder(items, LABEL_MASKS("%F", "", strAlbumLeft, strAlbumRight)); @@ -448,33 +398,26 @@ void CGUIViewStateMusicSmartPlaylist::SaveViewState() CGUIViewStateMusicPlaylist::CGUIViewStateMusicPlaylist(const CFileItemList& items) : CGUIViewStateWindowMusic(items) { + SortAttribute sortAttribute = SortAttributeNone; + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) + sortAttribute = SortAttributeIgnoreArticle; + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); CStdString strTrackRight=CSettings::Get().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 (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - { - AddSortMethod(SORT_METHOD_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty - AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T - %A", "%D")); // Album, Titel, Artist, Duration| empty, empty - AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Titel, Duration| empty, empty - AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS(strTrackLeft, strTrackRight)); - } - else - { - AddSortMethod(SORT_METHOD_TITLE, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty - AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B - %T - %A", "%D")); // Album, Titel, Artist, Duration| empty, empty - 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, 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); + AddSortMethod(SortByPlaylistOrder, 559, LABEL_MASKS(strTrackLeft, strTrackRight)); + AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined| empty, empty + AddSortMethod(SortByTitle, sortAttribute, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty + AddSortMethod(SortByAlbum, sortAttribute, 558, LABEL_MASKS("%B - %T - %A", "%D")); // Album, Titel, Artist, Duration| empty, empty + AddSortMethod(SortByArtist, sortAttribute, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Titel, Duration| empty, empty + AddSortMethod(SortByLabel, sortAttribute, 551, LABEL_MASKS(strTrackLeft, strTrackRight)); + AddSortMethod(SortByTime, 180, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty + AddSortMethod(SortByRating, 563, LABEL_MASKS("%T - %A", "%R")); // Titel, Artist, Rating| empty, empty + SetSortMethod(SortByPlaylistOrder); const CViewState *viewState = CViewStateSettings::Get().Get("musicfiles"); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); LoadViewState(items.GetPath(), WINDOW_MUSIC_FILES); } @@ -484,13 +427,16 @@ void CGUIViewStateMusicPlaylist::SaveViewState() SaveViewToDb(m_items.GetPath(), WINDOW_MUSIC_FILES); } - CGUIViewStateWindowMusicNav::CGUIViewStateWindowMusicNav(const CFileItemList& items) : CGUIViewStateWindowMusic(items) { + SortAttribute sortAttribute = SortAttributeNone; + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) + sortAttribute = SortAttributeIgnoreArticle; + if (items.IsVirtualDirectoryRoot()) { - AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, Size | Foldername, empty - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, Size | Foldername, empty + SetSortMethod(SortByNone); SetViewAsControl(DEFAULT_VIEW_LIST); @@ -504,35 +450,25 @@ CGUIViewStateWindowMusicNav::CGUIViewStateWindowMusicNav(const CFileItemList& it XFILE::CVideoDatabaseDirectory::GetQueryParams(items[CSettings::Get().GetBool("filelists.showparentdiritems")?1:0]->GetPath(),params); if (params.GetMVideoId() != -1) { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - 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")); - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - { - AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE,557, LABEL_MASKS("%A - %T", "%Y")); - AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE,558, LABEL_MASKS("%B - %T", "%Y")); - } - else - { - AddSortMethod(SORT_METHOD_ARTIST,557, LABEL_MASKS("%A - %T", "%Y")); - AddSortMethod(SORT_METHOD_ALBUM,558, LABEL_MASKS("%B - %T", "%Y")); - } + AddSortMethod(SortByLabel, sortAttribute, 551, LABEL_MASKS("%T", "%Y")); // Filename, Duration | Foldername, empty + AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y")); + AddSortMethod(SortByArtist, sortAttribute, 557, LABEL_MASKS("%A - %T", "%Y")); + AddSortMethod(SortByAlbum, sortAttribute, 558, LABEL_MASKS("%B - %T", "%Y")); + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright"); - AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined| empty, empty + AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined| empty, empty } else { - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%F", "%D", "%L", "")); // Filename, Duration | Foldername, empty - SetSortMethod(SORT_METHOD_LABEL); + AddSortMethod(SortByLabel, 551, LABEL_MASKS("%F", "%D", "%L", "")); // Filename, Duration | Foldername, empty + SetSortMethod(SortByLabel); } } else { - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%F", "%D", "%L", "")); // Filename, Duration | Foldername, empty - SetSortMethod(SORT_METHOD_LABEL); + AddSortMethod(SortByLabel, 551, LABEL_MASKS("%F", "%D", "%L", "")); // Filename, Duration | Foldername, empty + SetSortMethod(SortByLabel); } SetViewAsControl(DEFAULT_VIEW_LIST); @@ -613,9 +549,9 @@ CGUIViewStateWindowMusicSongs::CGUIViewStateWindowMusicSongs(const CFileItemList { if (items.IsVirtualDirectoryRoot()) { - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS()); // Preformated - AddSortMethod(SORT_METHOD_DRIVE_TYPE, 564, LABEL_MASKS()); // Preformated - SetSortMethod(SORT_METHOD_LABEL); + AddSortMethod(SortByLabel, 551, LABEL_MASKS()); // Preformated + AddSortMethod(SortByDriveType, 564, LABEL_MASKS()); // Preformated + SetSortMethod(SortByLabel); SetViewAsControl(DEFAULT_VIEW_LIST); @@ -623,28 +559,26 @@ CGUIViewStateWindowMusicSongs::CGUIViewStateWindowMusicSongs(const CFileItemList } else if (items.GetPath() == "special://musicplaylists/") { // playlists list sorts by label only, ignoring folders - AddSortMethod(SORT_METHOD_LABEL_IGNORE_FOLDERS, 551, LABEL_MASKS("%F", "%D", "%L", "")); // Filename, Duration | Foldername, empty - SetSortMethod(SORT_METHOD_LABEL_IGNORE_FOLDERS); + AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551, LABEL_MASKS("%F", "%D", "%L", "")); // Filename, Duration | Foldername, empty + SetSortMethod(SortByLabel, SortAttributeIgnoreFolders); } else { CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright"); - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", "")); // Userdefined, Userdefined | FolderName, empty - else - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", "")); // Userdefined, Userdefined | FolderName, empty - AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS(strTrackLeft, "%I", "%L", "%I")); // Userdefined, Size | FolderName, Size - AddSortMethod(SORT_METHOD_BITRATE, 623, LABEL_MASKS(strTrackLeft, "%X", "%L", "%X")); // Userdefined, Bitrate | FolderName, Bitrate - AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS(strTrackLeft, "%J", "%L", "%J")); // Userdefined, Date | FolderName, Date - AddSortMethod(SORT_METHOD_FILE, 561, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", "")); // Userdefined, Userdefined | FolderName, empty - AddSortMethod(SORT_METHOD_LISTENERS,20455,LABEL_MASKS(strTrackLeft, "%W", "%L", "%W")); - + AddSortMethod(SortByLabel, 551, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", ""), // Userdefined, Userdefined | FolderName, empty + CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); + AddSortMethod(SortBySize, 553, LABEL_MASKS(strTrackLeft, "%I", "%L", "%I")); // Userdefined, Size | FolderName, Size + AddSortMethod(SortByBitrate, 623, LABEL_MASKS(strTrackLeft, "%X", "%L", "%X")); // Userdefined, Bitrate | FolderName, Bitrate + AddSortMethod(SortByDate, 552, LABEL_MASKS(strTrackLeft, "%J", "%L", "%J")); // Userdefined, Date | FolderName, Date + AddSortMethod(SortByFile, 561, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", "")); // Userdefined, Userdefined | FolderName, empty + AddSortMethod(SortByListeners, 20455,LABEL_MASKS(strTrackLeft, "%W", "%L", "%W")); + const CViewState *viewState = CViewStateSettings::Get().Get("musicfiles"); - SetSortMethod(viewState->m_sortMethod); + SetSortMethod(viewState->m_sortDescription); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } LoadViewState(items.GetPath(), WINDOW_MUSIC_FILES); } @@ -670,8 +604,8 @@ CGUIViewStateWindowMusicPlaylist::CGUIViewStateWindowMusicPlaylist(const CFileIt if (strTrackRight.IsEmpty()) strTrackRight = CSettings::Get().GetString("musicfiles.trackformatright"); - AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", "")); // Userdefined, Userdefined | FolderName, empty - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 551, LABEL_MASKS(strTrackLeft, strTrackRight, "%L", "")); // Userdefined, Userdefined | FolderName, empty + SetSortMethod(SortByNone); SetViewAsControl(DEFAULT_VIEW_LIST); diff --git a/xbmc/music/infoscanner/MusicInfoScanner.cpp b/xbmc/music/infoscanner/MusicInfoScanner.cpp index 5da9ced466..69c0d7927b 100644 --- a/xbmc/music/infoscanner/MusicInfoScanner.cpp +++ b/xbmc/music/infoscanner/MusicInfoScanner.cpp @@ -390,7 +390,7 @@ bool CMusicInfoScanner::DoScan(const CStdString& strDirectory) // sort and get the path hash. Note that we don't filter .cue sheet items here as we want // to detect changes in the .cue sheet as well. The .cue sheet items only need filtering // if we have a changed hash. - items.Sort(SORT_METHOD_LABEL, SortOrderAscending); + items.Sort(SortByLabel, SortOrderAscending); CStdString hash; GetPathHash(items, hash); @@ -405,7 +405,7 @@ bool CMusicInfoScanner::DoScan(const CStdString& strDirectory) // filter items in the sub dir (for .cue sheet support) items.FilterCueItems(); - items.Sort(SORT_METHOD_LABEL, SortOrderAscending); + items.Sort(SortByLabel, SortOrderAscending); // and then scan in the new information if (RetrieveMusicInfo(strDirectory, items) > 0) diff --git a/xbmc/network/upnp/UPnPServer.cpp b/xbmc/network/upnp/UPnPServer.cpp index b0e2c2b620..dd92e6f3f8 100644 --- a/xbmc/network/upnp/UPnPServer.cpp +++ b/xbmc/network/upnp/UPnPServer.cpp @@ -655,7 +655,7 @@ CUPnPServer::OnBrowseDirectChildren(PLT_ActionReference& action, item->SetLabelPreformated(true); items.Add(item); - items.Sort(SORT_METHOD_LABEL, SortOrderAscending); + items.Sort(SortByLabel, SortOrderAscending); } else { // this is the only way to hide unplayable items in the 'files' // view as we cannot tell what context (eg music vs video) the @@ -1203,46 +1203,49 @@ CUPnPServer::SortItems(CFileItemList& items, const char* sort_criteria) bool sorted = false; CStdStringArray tokens = StringUtils::SplitString(criteria, ","); for (vector::reverse_iterator itr = tokens.rbegin(); itr != tokens.rend(); itr++) { - /* Platinum guarantees 1st char is - or + */ - SortOrder order = itr->Left(1).Equals("+") ? SortOrderAscending : SortOrderDescending; CStdString method = itr->Mid(1); - SORT_METHOD scheme = SORT_METHOD_LABEL_IGNORE_THE; + SortDescription sorting; + /* Platinum guarantees 1st char is - or + */ + sorting.sortOrder = itr->Left(1).Equals("+") ? SortOrderAscending : SortOrderDescending; /* resource specific */ if (method.Equals("res@duration")) - scheme = SORT_METHOD_DURATION; + sorting.sortBy = SortByTime; else if (method.Equals("res@size")) - scheme = SORT_METHOD_SIZE; + sorting.sortBy = SortBySize; else if (method.Equals("res@bitrate")) - scheme = SORT_METHOD_BITRATE; + sorting.sortBy = SortByBitrate; /* dc: */ else if (method.Equals("dc:date")) - scheme = SORT_METHOD_DATE; + sorting.sortBy = SortByDate; else if (method.Equals("dc:title")) - scheme = SORT_METHOD_TITLE_IGNORE_THE; + { + sorting.sortBy = SortByTitle; + sorting.sortAttributes = SortAttributeIgnoreArticle; + } /* upnp: */ else if (method.Equals("upnp:album")) - scheme = SORT_METHOD_ALBUM; + sorting.sortBy = SortByAlbum; else if (method.Equals("upnp:artist") || method.Equals("upnp:albumArtist")) - scheme = SORT_METHOD_ARTIST; + sorting.sortBy = SortByArtist; else if (method.Equals("upnp:episodeNumber")) - scheme = SORT_METHOD_EPISODE; + sorting.sortBy = SortByEpisodeNumber; else if (method.Equals("upnp:genre")) - scheme = SORT_METHOD_GENRE; + sorting.sortBy = SortByGenre; else if (method.Equals("upnp:originalTrackNumber")) - scheme = SORT_METHOD_TRACKNUM; + sorting.sortBy = SortByTrackNumber; else if(method.Equals("upnp:rating")) - scheme = SORT_METHOD_SONG_RATING; + sorting.sortBy = SortByRating; else { CLog::Log(LOGINFO, "UPnP: unsupported sort criteria '%s' passed", method.c_str()); continue; // needed so unidentified sort methods don't re-sort by label } - CLog::Log(LOGINFO, "UPnP: Sorting by %d, %d", scheme, order); - items.Sort(scheme, order); + CLog::Log(LOGINFO, "UPnP: Sorting by method %d, order %d, attributes %d", sorting.sortBy, sorting.sortOrder, sorting.sortAttributes); + items.Sort(sorting); sorted = true; } @@ -1255,7 +1258,8 @@ CUPnPServer::DefaultSortItems(CFileItemList& items) CGUIViewState* viewState = CGUIViewState::GetViewState(items.IsVideoDb() ? WINDOW_VIDEO_NAV : -1, items); if (viewState) { - items.Sort(viewState->GetSortMethod(), viewState->GetSortOrder()); + SortDescription sorting = viewState->GetSortMethod(); + items.Sort(sorting.sortBy, sorting.sortOrder, sorting.sortAttributes); delete viewState; } } diff --git a/xbmc/pictures/GUIViewStatePictures.cpp b/xbmc/pictures/GUIViewStatePictures.cpp index 1f527bc66a..2e5983afeb 100644 --- a/xbmc/pictures/GUIViewStatePictures.cpp +++ b/xbmc/pictures/GUIViewStatePictures.cpp @@ -37,9 +37,9 @@ CGUIViewStateWindowPictures::CGUIViewStateWindowPictures(const CFileItemList& it { if (items.IsVirtualDirectoryRoot()) { - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS()); - AddSortMethod(SORT_METHOD_DRIVE_TYPE, 564, LABEL_MASKS()); - SetSortMethod(SORT_METHOD_LABEL); + AddSortMethod(SortByLabel, 551, LABEL_MASKS()); + AddSortMethod(SortByDriveType, 564, LABEL_MASKS()); + SetSortMethod(SortByLabel); SetViewAsControl(DEFAULT_VIEW_LIST); @@ -47,16 +47,16 @@ CGUIViewStateWindowPictures::CGUIViewStateWindowPictures(const CFileItemList& it } else { - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | Foldername, empty - AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // Filename, Size | Foldername, Size - AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Filename, Date | Foldername, Date - AddSortMethod(SORT_METHOD_DATE_TAKEN, 577, LABEL_MASKS("%L", "%t", "%L", "%J")); // Filename, DateTaken | Foldername, Date - AddSortMethod(SORT_METHOD_FILE, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | FolderName, empty + AddSortMethod(SortByLabel, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | Foldername, empty + AddSortMethod(SortBySize, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // Filename, Size | Foldername, Size + AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Filename, Date | Foldername, Date + AddSortMethod(SortByDateTaken, 577, LABEL_MASKS("%L", "%t", "%L", "%J")); // Filename, DateTaken | Foldername, Date + AddSortMethod(SortByFile, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | FolderName, empty const CViewState *viewState = CViewStateSettings::Get().Get("pictures"); - SetSortMethod(viewState->m_sortMethod); + SetSortMethod(viewState->m_sortDescription); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } LoadViewState(items.GetPath(), WINDOW_PICTURES); } diff --git a/xbmc/pictures/GUIWindowPictures.cpp b/xbmc/pictures/GUIWindowPictures.cpp index d3b4aa0f92..57b6f3a516 100644 --- a/xbmc/pictures/GUIWindowPictures.cpp +++ b/xbmc/pictures/GUIWindowPictures.cpp @@ -383,9 +383,10 @@ void CGUIWindowPictures::OnShowPictureRecursive(const CStdString& strPath) // stop any video if (g_application.IsPlayingVideo()) g_application.StopPlaying(); + + SortDescription sorting = m_guiState->GetSortMethod(); pSlideShow->AddFromPath(strPath, true, - m_guiState->GetSortMethod(), - m_guiState->GetSortOrder()); + sorting.sortBy, sorting.sortOrder, sorting.sortAttributes); if (pSlideShow->NumSlides()) { m_slideShowStarted = true; @@ -408,11 +409,12 @@ void CGUIWindowPictures::OnSlideShowRecursive(const CStdString &strPicture) delete viewState; } m_slideShowStarted = true; + + SortDescription sorting = m_guiState->GetSortMethod(); pSlideShow->RunSlideShow(strPicture, true, CSettings::Get().GetBool("slideshow.shuffle"),false, "", true, - m_guiState->GetSortMethod(), - m_guiState->GetSortOrder(), + sorting.sortBy, sorting.sortOrder, sorting.sortAttributes, strExtensions); } } @@ -442,10 +444,11 @@ void CGUIWindowPictures::OnSlideShow(const CStdString &strPicture) delete viewState; } m_slideShowStarted = true; + + SortDescription sorting = m_guiState->GetSortMethod(); pSlideShow->RunSlideShow(strPicture, false ,false, false, "", true, - m_guiState->GetSortMethod(), - m_guiState->GetSortOrder(), + sorting.sortBy, sorting.sortOrder, sorting.sortAttributes, strExtensions); } } diff --git a/xbmc/pictures/GUIWindowSlideShow.cpp b/xbmc/pictures/GUIWindowSlideShow.cpp index 753c264d88..8f65961d79 100644 --- a/xbmc/pictures/GUIWindowSlideShow.cpp +++ b/xbmc/pictures/GUIWindowSlideShow.cpp @@ -1190,7 +1190,8 @@ int CGUIWindowSlideShow::CurrentSlide() const void CGUIWindowSlideShow::AddFromPath(const CStdString &strPath, bool bRecursive, - SORT_METHOD method, SortOrder order, const CStdString &strExtensions) + SortBy method, SortOrder order, SortAttribute sortAttributes, + const CStdString &strExtensions) { if (strPath!="") { @@ -1200,24 +1201,25 @@ void CGUIWindowSlideShow::AddFromPath(const CStdString &strPath, if (bRecursive) { path_set recursivePaths; - AddItems(strPath, &recursivePaths, method, order); + AddItems(strPath, &recursivePaths, method, order, sortAttributes); } else - AddItems(strPath, NULL, method, order); + AddItems(strPath, NULL, method, order, sortAttributes); } } void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath, - bool bRecursive /* = false */, bool bRandom /* = false */, + bool bRecursive /* = false */, bool bRandom /* = false */, bool bNotRandom /* = false */, const CStdString &beginSlidePath /* = "" */, - bool startSlideShow /* = true */, SORT_METHOD method /* = SORT_METHOD_LABEL */, - SortOrder order /* = SortOrderAscending */, const CStdString &strExtensions /* = "" */) + bool startSlideShow /* = true */, SortBy method /* = SortByLabel */, + SortOrder order /* = SortOrderAscending */, SortAttribute sortAttributes /* = SortAttributeNone */, + const CStdString &strExtensions) { // stop any video if (g_application.IsPlayingVideo()) g_application.StopPlaying(); - AddFromPath(strPath, bRecursive, method, order, strExtensions); + AddFromPath(strPath, bRecursive, method, order, sortAttributes, strExtensions); if (!NumSlides()) return; @@ -1247,7 +1249,7 @@ void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath, g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); } -void CGUIWindowSlideShow::AddItems(const CStdString &strPath, path_set *recursivePaths, SORT_METHOD method, SortOrder order) +void CGUIWindowSlideShow::AddItems(const CStdString &strPath, path_set *recursivePaths, SortBy method, SortOrder order, SortAttribute sortAttributes) { // check whether we've already added this path if (recursivePaths) @@ -1264,7 +1266,7 @@ void CGUIWindowSlideShow::AddItems(const CStdString &strPath, path_set *recursiv if (!CDirectory::GetDirectory(strPath, items, m_strExtensions.IsEmpty()?g_advancedSettings.m_pictureExtensions:m_strExtensions,DIR_FLAG_NO_FILE_DIRS,true)) return; - items.Sort(method, order); + items.Sort(method, order, sortAttributes); // need to go into all subdirs for (int i = 0; i < items.Size(); i++) diff --git a/xbmc/pictures/GUIWindowSlideShow.h b/xbmc/pictures/GUIWindowSlideShow.h index c3af48dfed..b59b4ee134 100644 --- a/xbmc/pictures/GUIWindowSlideShow.h +++ b/xbmc/pictures/GUIWindowSlideShow.h @@ -78,11 +78,15 @@ public: void RunSlideShow(const CStdString &strPath, bool bRecursive = false, bool bRandom = false, bool bNotRandom = false, const CStdString &beginSlidePath="", bool startSlideShow = true, - SORT_METHOD method = SORT_METHOD_LABEL, - SortOrder order = SortOrderAscending, const CStdString &strExtensions=""); + SortBy method = SortByLabel, + SortOrder order = SortOrderAscending, + SortAttribute sortAttributes = SortAttributeNone, + const CStdString &strExtensions=""); void AddFromPath(const CStdString &strPath, bool bRecursive, - SORT_METHOD method=SORT_METHOD_LABEL, - SortOrder order = SortOrderAscending, const CStdString &strExtensions=""); + SortBy method = SortByLabel, + SortOrder order = SortOrderAscending, + SortAttribute sortAttributes = SortAttributeNone, + const CStdString &strExtensions=""); void StartSlideShow(); bool InSlideShow() const; virtual bool OnMessage(CGUIMessage& message); @@ -102,8 +106,9 @@ public: private: typedef std::set path_set; // set to track which paths we're adding void AddItems(const CStdString &strPath, path_set *recursivePaths, - SORT_METHOD method = SORT_METHOD_LABEL, - SortOrder order = SortOrderAscending); + SortBy method = SortByLabel, + SortOrder order = SortOrderAscending, + SortAttribute sortAttributes = SortAttributeNone); bool PlayVideo(); CSlideShowPic::DISPLAY_EFFECT GetDisplayEffect(int iSlideNumber) const; void RenderPause(); diff --git a/xbmc/pictures/PictureThumbLoader.cpp b/xbmc/pictures/PictureThumbLoader.cpp index 69822073cf..c7084dbdc0 100644 --- a/xbmc/pictures/PictureThumbLoader.cpp +++ b/xbmc/pictures/PictureThumbLoader.cpp @@ -222,7 +222,7 @@ void CPictureThumbLoader::ProcessFoldersAndArchives(CFileItem *pItem) if (items.Size() < 4 || pItem->IsCBR() || pItem->IsCBZ()) { // less than 4 items, so just grab the first thumb - items.Sort(SORT_METHOD_LABEL, SortOrderAscending); + items.Sort(SortByLabel, SortOrderAscending); CStdString thumb = CTextureCache::GetWrappedThumbURL(items[0]->GetPath()); db.SetTextureForPath(pItem->GetPath(), "thumb", thumb); CTextureCache::Get().BackgroundCacheImage(thumb); diff --git a/xbmc/programs/GUIViewStatePrograms.cpp b/xbmc/programs/GUIViewStatePrograms.cpp index 5d21298a13..f9cc9a37ff 100644 --- a/xbmc/programs/GUIViewStatePrograms.cpp +++ b/xbmc/programs/GUIViewStatePrograms.cpp @@ -32,15 +32,13 @@ using namespace XFILE; CGUIViewStateWindowPrograms::CGUIViewStateWindowPrograms(const CFileItemList& items) : CGUIViewState(items) { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%K", "%I", "%L", "")); // Titel, Size | Foldername, empty - else - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%K", "%I", "%L", "")); // Titel, Size | Foldername, empty + AddSortMethod(SortByLabel, 551, LABEL_MASKS("%K", "%I", "%L", ""), // Titel, Size | Foldername, empty + CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); const CViewState *viewState = CViewStateSettings::Get().Get("programs"); - SetSortMethod(viewState->m_sortMethod); + SetSortMethod(viewState->m_sortDescription); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); LoadViewState(items.GetPath(), WINDOW_PROGRAMS); } diff --git a/xbmc/pvr/windows/GUIViewStatePVR.cpp b/xbmc/pvr/windows/GUIViewStatePVR.cpp index 5c372931ea..4ffca74880 100644 --- a/xbmc/pvr/windows/GUIViewStatePVR.cpp +++ b/xbmc/pvr/windows/GUIViewStatePVR.cpp @@ -32,16 +32,13 @@ CGUIViewStatePVR::CGUIViewStatePVR(const CFileItemList& items) : PVRWindow ActiveView = GetActiveView(); if (ActiveView == PVR_WINDOW_RECORDINGS) { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%L", "%I", "%L", "")); // FileName, Size | Foldername, e - else - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%L", "%I", "%L", "")); // FileName, Size | Foldername, empty - AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // FileName, Size | Foldername, Size - AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // FileName, Date | Foldername, Date - AddSortMethod(SORT_METHOD_FILE, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | FolderName, empty + AddSortMethod(SortByLabel, 551, LABEL_MASKS("%L", "%I", "%L", ""), CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); // FileName, Size | Foldername, empty + AddSortMethod(SortBySize, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // FileName, Size | Foldername, Size + AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // FileName, Date | Foldername, Date + AddSortMethod(SortByFile, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | FolderName, empty // Sort recordings view by date as default - SetSortMethod(SORT_METHOD_DATE); + SetSortMethod(SortByDate); } LoadViewState(items.GetPath(), ActiveView == PVR_WINDOW_UNKNOWN ? WINDOW_PVR : WINDOW_PVR + 100 - ActiveView ); diff --git a/xbmc/pvr/windows/GUIWindowPVRCommon.cpp b/xbmc/pvr/windows/GUIWindowPVRCommon.cpp index ae3fe77f30..29d2e721b3 100644 --- a/xbmc/pvr/windows/GUIWindowPVRCommon.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRCommon.cpp @@ -62,11 +62,14 @@ CGUIWindowPVRCommon::CGUIWindowPVRCommon(CGUIWindowPVR *parent, PVRWindow window m_bUpdateRequired = false; m_iSelected = 0; m_iSortOrder = SortOrderAscending; - m_iSortMethod = SORT_METHOD_DATE; + m_iSortMethod = SortByDate; + m_iSortAttributes = SortAttributeNone; if( m_parent->GetViewState() ) { - m_iSortOrder = m_parent->GetViewState()->GetSortOrder(); - m_iSortMethod = m_parent->GetViewState()->GetSortMethod(); + SortDescription sorting = m_parent->GetViewState()->GetSortMethod(); + m_iSortOrder = sorting.sortOrder; + m_iSortMethod = sorting.sortBy; + m_iSortAttributes = sorting.sortAttributes; } } @@ -230,9 +233,9 @@ bool CGUIWindowPVRCommon::OnContextButtonSortByDate(CFileItem *item, CONTEXT_BUT { bReturn = true; - if (m_iSortMethod != SORT_METHOD_DATE) + if (m_iSortMethod != SortByDate) { - m_iSortMethod = SORT_METHOD_DATE; + m_iSortMethod = SortByDate; m_iSortOrder = SortOrderAscending; CGUIMessage message(GUI_MSG_CHANGE_SORT_METHOD, m_parent->GetID(), 0, m_iSortMethod, 0); m_parent->OnMessage(message); @@ -257,9 +260,9 @@ bool CGUIWindowPVRCommon::OnContextButtonSortByName(CFileItem *item, CONTEXT_BUT { bReturn = true; - if (m_iSortMethod != SORT_METHOD_LABEL) + if (m_iSortMethod != SortByLabel) { - m_iSortMethod = SORT_METHOD_LABEL; + m_iSortMethod = SortByLabel; m_iSortOrder = SortOrderAscending; CGUIMessage message(GUI_MSG_CHANGE_SORT_METHOD, m_parent->GetID(), 0, m_iSortMethod, 0); m_parent->OnMessage(message); @@ -284,9 +287,9 @@ bool CGUIWindowPVRCommon::OnContextButtonSortByChannel(CFileItem *item, CONTEXT_ { bReturn = true; - if (m_iSortMethod != SORT_METHOD_CHANNEL) + if (m_iSortMethod != SortByChannel) { - m_iSortMethod = SORT_METHOD_CHANNEL; + m_iSortMethod = SortByChannel; m_iSortOrder = SortOrderAscending; } else @@ -638,7 +641,7 @@ bool CGUIWindowPVRCommon::PlayRecording(CFileItem *item, bool bPlayMinimized /* CFileItemList items; CDirectory::GetDirectory(dir, items); - items.Sort(SORT_METHOD_FILE, SortOrderAscending); + items.Sort(SortByFile, SortOrderAscending); vector stack; for (int i = 0; i < items.Size(); ++i) diff --git a/xbmc/pvr/windows/GUIWindowPVRCommon.h b/xbmc/pvr/windows/GUIWindowPVRCommon.h index fb9107cf27..1d65bff40f 100644 --- a/xbmc/pvr/windows/GUIWindowPVRCommon.h +++ b/xbmc/pvr/windows/GUIWindowPVRCommon.h @@ -139,7 +139,8 @@ namespace PVR bool m_bUpdateRequired; int m_iSelected; SortOrder m_iSortOrder; - SORT_METHOD m_iSortMethod; + SortBy m_iSortMethod; + SortAttribute m_iSortAttributes; CCriticalSection m_critSection; CDirectoryHistory m_history; }; diff --git a/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp b/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp index e78cdc9b02..fa4ea137a9 100644 --- a/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp @@ -145,13 +145,13 @@ void CGUIWindowPVRRecordings::GetContextButtons(int itemNumber, CContextButtons buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */ // Update sort by button -//if (m_guiState->GetSortMethod()!=SORT_METHOD_NONE) +//if (m_guiState->GetSortMethod()!=SortByNone) //{ // CStdString sortLabel; // sortLabel.Format(g_localizeStrings.Get(550).c_str(), g_localizeStrings.Get(m_guiState->GetSortMethodLabel()).c_str()); // buttons.Add(CONTEXT_BUTTON_SORTBY, sortLabel); /* Sort method */ // -// if (m_guiState->GetDisplaySortOrder()==SORT_ORDER_ASC) +// if (m_guiState->GetDisplaySortOrder()==SortOrderAscending) // buttons.Add(CONTEXT_BUTTON_SORTASC, 584); /* Sort up or down */ // else // buttons.Add(CONTEXT_BUTTON_SORTASC, 585); /* Sort up or down */ diff --git a/xbmc/pvr/windows/GUIWindowPVRSearch.cpp b/xbmc/pvr/windows/GUIWindowPVRSearch.cpp index 2ffdff8740..b43ada768d 100644 --- a/xbmc/pvr/windows/GUIWindowPVRSearch.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRSearch.cpp @@ -141,7 +141,7 @@ void CGUIWindowPVRSearch::UpdateData(bool bUpdateSelectedFile /* = true */) } else { - m_parent->m_vecItems->Sort(m_iSortMethod, m_iSortOrder); + m_parent->m_vecItems->Sort(m_iSortMethod, m_iSortOrder, m_iSortAttributes); } m_parent->m_viewControl.SetItems(*m_parent->m_vecItems); diff --git a/xbmc/pvr/windows/GUIWindowPVRTimers.cpp b/xbmc/pvr/windows/GUIWindowPVRTimers.cpp index 3e2418d4e1..e8420c02df 100644 --- a/xbmc/pvr/windows/GUIWindowPVRTimers.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRTimers.cpp @@ -111,7 +111,7 @@ void CGUIWindowPVRTimers::UpdateData(bool bUpdateSelectedFile /* = true */) m_parent->m_vecItems->Clear(); m_parent->m_vecItems->SetPath("pvr://timers/"); m_parent->Update(m_parent->m_vecItems->GetPath()); - m_parent->m_vecItems->Sort(m_iSortMethod, m_iSortOrder); + m_parent->m_vecItems->Sort(m_iSortMethod, m_iSortOrder, m_iSortAttributes); m_parent->m_viewControl.SetItems(*m_parent->m_vecItems); if (bUpdateSelectedFile) diff --git a/xbmc/utils/SortUtils.h b/xbmc/utils/SortUtils.h index b5b5627a5c..63f00859f8 100644 --- a/xbmc/utils/SortUtils.h +++ b/xbmc/utils/SortUtils.h @@ -24,6 +24,7 @@ #include "DatabaseUtils.h" #include "SortFileItem.h" +#include "LabelFormatter.h" typedef enum { SortOrderNone = 0, @@ -105,6 +106,13 @@ typedef struct SortDescription { { } } SortDescription; +typedef struct +{ + SortDescription m_sortDescription; + int m_buttonLabel; + LABEL_MASKS m_labelMasks; +} SORT_METHOD_DETAILS; + typedef DatabaseResult SortItem; typedef DatabaseResults SortItems; diff --git a/xbmc/video/GUIViewStateVideo.cpp b/xbmc/video/GUIViewStateVideo.cpp index f0418c1986..303262c3f1 100644 --- a/xbmc/video/GUIViewStateVideo.cpp +++ b/xbmc/video/GUIViewStateVideo.cpp @@ -62,9 +62,9 @@ CGUIViewStateWindowVideoFiles::CGUIViewStateWindowVideoFiles(const CFileItemList { if (items.IsVirtualDirectoryRoot()) { - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS()); // Preformated - AddSortMethod(SORT_METHOD_DRIVE_TYPE, 564, LABEL_MASKS()); // Preformated - SetSortMethod(SORT_METHOD_LABEL); + AddSortMethod(SortByLabel, 551, LABEL_MASKS()); // Preformated + AddSortMethod(SortByDriveType, 564, LABEL_MASKS()); // Preformated + SetSortMethod(SortByLabel); SetViewAsControl(DEFAULT_VIEW_LIST); @@ -72,18 +72,16 @@ CGUIViewStateWindowVideoFiles::CGUIViewStateWindowVideoFiles(const CFileItemList } else { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty - else - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty - AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // Label, Size | Label, Size - AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Label, Date | Label, Date - AddSortMethod(SORT_METHOD_FILE, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty + AddSortMethod(SortByLabel, 551, LABEL_MASKS("%L", "%I", "%L", ""), // Label, Size | Label, empty + CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); + AddSortMethod(SortBySize, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // Label, Size | Label, Size + AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Label, Date | Label, Date + AddSortMethod(SortByFile, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty const CViewState *viewState = CViewStateSettings::Get().Get("videofiles"); - SetSortMethod(viewState->m_sortMethod); + SetSortMethod(viewState->m_sortDescription); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } LoadViewState(items.GetPath(), WINDOW_VIDEO_FILES); } @@ -102,10 +100,14 @@ VECSOURCES& CGUIViewStateWindowVideoFiles::GetSources() CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { + SortAttribute sortAttributes = SortAttributeNone; + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) + sortAttributes = SortAttributeIgnoreArticle; + if (items.IsVirtualDirectoryRoot()) { - AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, Size | Label, empty - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, Size | Label, empty + SetSortMethod(SortByNone); SetViewAsControl(DEFAULT_VIEW_LIST); @@ -124,9 +126,9 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it case NODE_TYPE_MUSICVIDEOS_OVERVIEW: case NODE_TYPE_OVERVIEW: { - AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, Size | Label, empty + AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, Size | Label, empty - SetSortMethod(SORT_METHOD_NONE); + SetSortMethod(SortByNone); SetViewAsControl(DEFAULT_VIEW_LIST); @@ -136,50 +138,47 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it case NODE_TYPE_DIRECTOR: case NODE_TYPE_ACTOR: { - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty - SetSortMethod(SORT_METHOD_LABEL); + AddSortMethod(SortByLabel, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty + SetSortMethod(SortByLabel); const CViewState *viewState = CViewStateSettings::Get().Get("videonavactors"); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } break; case NODE_TYPE_YEAR: { - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty - SetSortMethod(SORT_METHOD_LABEL); + AddSortMethod(SortByLabel, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty + SetSortMethod(SortByLabel); const CViewState *viewState = CViewStateSettings::Get().Get("videonavyears"); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } break; case NODE_TYPE_SEASONS: { - AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%L", "","%L","")); // Label, empty | Label, empty - SetSortMethod(SORT_METHOD_VIDEO_SORT_TITLE); + AddSortMethod(SortBySortTitle, 556, LABEL_MASKS("%L", "","%L","")); // Label, empty | Label, empty + SetSortMethod(SortBySortTitle); const CViewState *viewState = CViewStateSettings::Get().Get("videonavseasons"); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } break; case NODE_TYPE_TITLE_TVSHOWS: { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - 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, 556, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes + AddSortMethod(SortBySortTitle, sortAttributes, 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_LASTPLAYED, 568, LABEL_MASKS("%T", "%p", "%T", "%p")); // Title, #Last played | Title, #Last played - AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%L","%Y","%L","%Y")); // Label, Year | Label, Year - SetSortMethod(SORT_METHOD_LABEL); + // NOTE: This uses SortByEpisodeNumber to mean "sort shows by the number of episodes" and uses the label "Episodes" + AddSortMethod(SortByEpisodeNumber, 20360, LABEL_MASKS("%L", "%M", "%L", "%M")); // Label, #Episodes | Label, #Episodes + AddSortMethod(SortByLastPlayed, 568, LABEL_MASKS("%T", "%p", "%T", "%p")); // Title, #Last played | Title, #Last played + AddSortMethod(SortByYear, 562, LABEL_MASKS("%L","%Y","%L","%Y")); // Label, Year | Label, Year + SetSortMethod(SortByLabel); const CViewState *viewState = CViewStateSettings::Get().Get("videonavtvshows"); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } break; case NODE_TYPE_MUSICVIDEOS_ALBUM: @@ -187,88 +186,78 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it case NODE_TYPE_COUNTRY: case NODE_TYPE_STUDIO: { - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty - SetSortMethod(SORT_METHOD_LABEL); + AddSortMethod(SortByLabel, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty + SetSortMethod(SortByLabel); const CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } break; case NODE_TYPE_SETS: { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T","%R", "%T","%R")); // Title, Rating | Title, Rating - else - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R", "%T","%R")); // Title, Rating | Title, Rating + AddSortMethod(SortByLabel, sortAttributes, 551, 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_DATEADDED, 570, LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded + AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year + AddSortMethod(SortByRating, 563, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating + AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll) - AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount + AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount - SetSortMethod(SORT_METHOD_LABEL_IGNORE_THE); + SetSortMethod(SortByLabel, SortAttributeIgnoreArticle); const CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } break; case NODE_TYPE_TAGS: { - SORT_METHOD method = SORT_METHOD_LABEL_IGNORE_THE; - if (!CSettings::Get().GetBool("filelists.ignorethewhensorting")) - method = SORT_METHOD_LABEL; - - AddSortMethod(method, 551, LABEL_MASKS("%T","", "%T","")); // Title, empty | Title, empty - SetSortMethod(method); - + AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T","", "%T","")); // Title, empty | Title, empty + SetSortMethod(SortByLabel, sortAttributes); + const CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres"); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } break; case NODE_TYPE_EPISODES: { if (params.GetSeason() > -1) { - AddSortMethod(SORT_METHOD_EPISODE, 20359, LABEL_MASKS("%E. %T","%R")); // Episode. Title, Rating | empty, empty - AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%E. %T", "%R")); // Episode. Title, Rating | empty, empty - AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%E. %T", "%O")); // Episode. Title, MPAA | empty, empty - AddSortMethod(SORT_METHOD_PRODUCTIONCODE, 20368, LABEL_MASKS("%E. %T","%P", "%E. %T","%P")); // Episode. Title, ProductionCode | Episode. Title, ProductionCode - AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%E. %T","%J","%E. %T","%J")); // Episode. Title, Date | Episode. Title, Date + AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%E. %T","%R")); // Episode. Title, Rating | empty, empty + AddSortMethod(SortByRating, 563, LABEL_MASKS("%E. %T", "%R")); // Episode. Title, Rating | empty, empty + AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%E. %T", "%O")); // Episode. Title, MPAA | empty, empty + AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%E. %T","%P", "%E. %T","%P")); // Episode. Title, ProductionCode | Episode. Title, ProductionCode + AddSortMethod(SortByDate, 552, LABEL_MASKS("%E. %T","%J","%E. %T","%J")); // Episode. Title, Date | Episode. Title, Date if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll) - AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%E. %T", "%V")); // Episode. Title, Playcount | empty, empty + AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%E. %T", "%V")); // Episode. Title, Playcount | empty, empty } else { - AddSortMethod(SORT_METHOD_EPISODE, 20359, LABEL_MASKS("%H. %T","%R")); // Order. Title, Rating | emtpy, empty - AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%H. %T", "%R")); // Order. Title, Rating | emtpy, empty - AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%H. %T", "%O")); // Order. Title, MPAA | emtpy, empty - AddSortMethod(SORT_METHOD_PRODUCTIONCODE, 20368, LABEL_MASKS("%H. %T","%P", "%H. %T","%P")); // Order. Title, ProductionCode | Episode. Title, ProductionCode - AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%H. %T","%J","%H. %T","%J")); // Order. Title, Date | Episode. Title, Date + AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%H. %T","%R")); // Order. Title, Rating | emtpy, empty + AddSortMethod(SortByRating, 563, LABEL_MASKS("%H. %T", "%R")); // Order. Title, Rating | emtpy, empty + AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%H. %T", "%O")); // Order. Title, MPAA | emtpy, empty + AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%H. %T","%P", "%H. %T","%P")); // Order. Title, ProductionCode | Episode. Title, ProductionCode + AddSortMethod(SortByDate, 552, LABEL_MASKS("%H. %T","%J","%H. %T","%J")); // Order. Title, Date | Episode. Title, Date if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll) - AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%H. %T", "%V")); // Order. Title, Playcount | empty, empty + AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%H. %T", "%V")); // Order. Title, Playcount | empty, empty } - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%T","%R")); // Title, Rating | empty, empty - else - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty + AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T","%R")); // Title, Rating | empty, empty const CViewState *viewState = CViewStateSettings::Get().Get("videonavepisodes"); - SetSortMethod(viewState->m_sortMethod); + SetSortMethod(viewState->m_sortDescription); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); break; } case NODE_TYPE_RECENTLY_ADDED_EPISODES: { - AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 552, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty + SetSortMethod(SortByNone); SetViewAsControl(CViewStateSettings::Get().Get("videonavepisodes")->m_viewMode); SetSortOrder(SortOrderNone); @@ -279,76 +268,57 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it { if (params.GetSetId() > -1) // Is this a listing within a set? { - AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty - - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 556, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty - else - AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 556, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty + AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty + AddSortMethod(SortBySortTitle, sortAttributes, 556, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty } else { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - 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, 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(SortBySortTitle, sortAttributes, 556, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating + AddSortMethod(SortByYear, 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, 180, LABEL_MASKS("%T", "%D")); // Title, Duration | empty, empty - AddSortMethod(SORT_METHOD_DATEADDED, 570, LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded + AddSortMethod(SortByRating, 563, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating + AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O")); // Title, MPAA | empty, empty + AddSortMethod(SortByTime, 180, LABEL_MASKS("%T", "%D")); // Title, Duration | empty, empty + AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll) - AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount + AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount const CViewState *viewState = CViewStateSettings::Get().Get("videonavtitles"); if (params.GetSetId() > -1) - SetSortMethod(SORT_METHOD_YEAR); + SetSortMethod(SortByYear); else - SetSortMethod(viewState->m_sortMethod); + SetSortMethod(viewState->m_sortDescription); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } break; case NODE_TYPE_TITLE_MUSICVIDEOS: { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - 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")); - AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - { - AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty - AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty - } - else - { - AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty - AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty - } + AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty + AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O")); + AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty + AddSortMethod(SortByArtist, sortAttributes, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty + AddSortMethod(SortByAlbum, sortAttributes, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll) - AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty + AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright"); - AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty + AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty const CViewState *viewState = CViewStateSettings::Get().Get("videonavmusicvideos"); - SetSortMethod(viewState->m_sortMethod); + SetSortMethod(viewState->m_sortDescription); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } break; case NODE_TYPE_RECENTLY_ADDED_MOVIES: { - AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 552, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty + SetSortMethod(SortByNone); SetViewAsControl(CViewStateSettings::Get().Get("videonavtitles")->m_viewMode); @@ -357,8 +327,8 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it break; case NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS: { - AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 552, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty + SetSortMethod(SortByNone); SetViewAsControl(CViewStateSettings::Get().Get("videonavmusicvideos")->m_viewMode); @@ -371,18 +341,15 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it } else { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty - else - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty - AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // Label, Size | Label, Size - AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Label, Date | Label, Date - AddSortMethod(SORT_METHOD_FILE, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty - + AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty + AddSortMethod(SortBySize, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // Label, Size | Label, Size + AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Label, Date | Label, Date + AddSortMethod(SortByFile, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty + const CViewState *viewState = CViewStateSettings::Get().Get("videofiles"); - SetSortMethod(viewState->m_sortMethod); + SetSortMethod(viewState->m_sortDescription); SetViewAsControl(viewState->m_viewMode); - SetSortOrder(viewState->m_sortOrder); + SetSortOrder(viewState->m_sortDescription.sortOrder); } LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); } @@ -465,8 +432,8 @@ bool CGUIViewStateWindowVideoNav::AutoPlayNextItem() CGUIViewStateWindowVideoPlaylist::CGUIViewStateWindowVideoPlaylist(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { - AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%L", "", "%L", "")); // Label, empty | Label, empty - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 551, LABEL_MASKS("%L", "", "%L", "")); // Label, empty | Label, empty + SetSortMethod(SortByNone); SetViewAsControl(DEFAULT_VIEW_LIST); @@ -503,24 +470,21 @@ VECSOURCES& CGUIViewStateWindowVideoPlaylist::GetSources() return m_sources; } - CGUIViewStateVideoMovies::CGUIViewStateVideoMovies(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - 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, 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 + AddSortMethod(SortBySortTitle, 556, LABEL_MASKS("%T", "%R", "%T", "%R"), // Title, Rating | Title, Rating + CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); + AddSortMethod(SortByRating, 563, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating + AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O")); // Title, MPAA | empty, empty + AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year const CViewState *viewState = CViewStateSettings::Get().Get("videonavtitles"); if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) AddPlaylistOrder(items, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating else { - SetSortMethod(viewState->m_sortMethod); - SetSortOrder(viewState->m_sortOrder); + SetSortMethod(viewState->m_sortDescription); + SetSortOrder(viewState->m_sortDescription.sortOrder); } SetViewAsControl(viewState->m_viewMode); @@ -533,39 +497,31 @@ void CGUIViewStateVideoMovies::SaveViewState() SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavtitles")); } - CGUIViewStateVideoMusicVideos::CGUIViewStateVideoMusicVideos(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { + SortAttribute sortAttributes = SortAttributeNone; if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - 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")); - AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - { - AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty - AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty - } - else - { - AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty - AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty - } + sortAttributes = SortAttributeIgnoreArticle; - AddSortMethod(SORT_METHOD_PLAYCOUNT, 567, LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty + AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty + AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O")); + AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty + AddSortMethod(SortByArtist, sortAttributes, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty + AddSortMethod(SortByAlbum, sortAttributes, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty + AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty + CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat"); CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright"); - AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty + AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty const CViewState *viewState = CViewStateSettings::Get().Get("videonavmusicvideos"); if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) AddPlaylistOrder(items, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty else { - SetSortMethod(viewState->m_sortMethod); - SetSortOrder(viewState->m_sortOrder); + SetSortMethod(viewState->m_sortDescription); + SetSortOrder(viewState->m_sortDescription.sortOrder); } SetViewAsControl(viewState->m_viewMode); @@ -580,19 +536,17 @@ void CGUIViewStateVideoMusicVideos::SaveViewState() CGUIViewStateVideoTVShows::CGUIViewStateVideoTVShows(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - 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, 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 + AddSortMethod(SortBySortTitle, 556, LABEL_MASKS("%T", "%M", "%T", "%M"), // Title, #Episodes | Title, #Episodes + CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); + AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year const CViewState *viewState = CViewStateSettings::Get().Get("videonavtvshows"); if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) AddPlaylistOrder(items, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes else { - SetSortMethod(viewState->m_sortMethod); - SetSortOrder(viewState->m_sortOrder); + SetSortMethod(viewState->m_sortDescription); + SetSortOrder(viewState->m_sortDescription.sortOrder); } SetViewAsControl(viewState->m_viewMode); @@ -605,28 +559,25 @@ void CGUIViewStateVideoTVShows::SaveViewState() SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavtvshows")); } - CGUIViewStateVideoEpisodes::CGUIViewStateVideoEpisodes(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { - if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) - AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%Z - %H. %T","%R")); // TvShow - Order. Title, Rating | empty, empty - else - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty + AddSortMethod(SortByLabel, 551, LABEL_MASKS("%Z - %H. %T","%R"), // TvShow - Order. Title, Rating | empty, empty + CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); if (0)//params.GetSeason() > -1) { - AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%E. %T", "%R")); // Episode. Title, Rating | empty, empty - AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%E. %T", "%O")); // Episode. Title, MPAA | empty, empty - AddSortMethod(SORT_METHOD_EPISODE, 20359, LABEL_MASKS("%E. %T","%R")); // Episode. Title, Rating | empty, empty - AddSortMethod(SORT_METHOD_PRODUCTIONCODE, 20368, LABEL_MASKS("%E. %T","%P", "%E. %T","%P")); // Episode. Title, Production Code | Episode. Title, Production Code - AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%E. %T","%J","E. %T","%J")); // Episode. Title, Date | Episode. Title, Date + AddSortMethod(SortByRating, 563, LABEL_MASKS("%E. %T", "%R")); // Episode. Title, Rating | empty, empty + AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%E. %T", "%O")); // Episode. Title, MPAA | empty, empty + AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%E. %T","%R")); // Episode. Title, Rating | empty, empty + AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%E. %T","%P", "%E. %T","%P")); // Episode. Title, Production Code | Episode. Title, Production Code + AddSortMethod(SortByDate, 552, LABEL_MASKS("%E. %T","%J","E. %T","%J")); // Episode. Title, Date | Episode. Title, Date } else { // format here is tvshowtitle - season/episode number. episode title - AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty - AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%Z - %H. %T", "%O")); // TvShow - Order. Title, MPAA | empty, empty - AddSortMethod(SORT_METHOD_EPISODE, 20359, LABEL_MASKS("%Z - %H. %T","%R")); // TvShow - Order. Title, Rating | empty, empty - AddSortMethod(SORT_METHOD_PRODUCTIONCODE, 20368, LABEL_MASKS("%Z - %H. %T","%P")); // TvShow - Order. Title, Production Code | empty, empty - AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%Z - %H. %T","%J")); // TvShow - Order. Title, Date | empty, empty + AddSortMethod(SortByRating, 563, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty + AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%Z - %H. %T", "%O")); // TvShow - Order. Title, MPAA | empty, empty + AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%Z - %H. %T","%R")); // TvShow - Order. Title, Rating | empty, empty + AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%Z - %H. %T","%P")); // TvShow - Order. Title, Production Code | empty, empty + AddSortMethod(SortByDate, 552, LABEL_MASKS("%Z - %H. %T","%J")); // TvShow - Order. Title, Date | empty, empty } const CViewState *viewState = CViewStateSettings::Get().Get("videonavepisodes"); @@ -634,8 +585,8 @@ CGUIViewStateVideoEpisodes::CGUIViewStateVideoEpisodes(const CFileItemList& item AddPlaylistOrder(items, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty else { - SetSortMethod(viewState->m_sortMethod); - SetSortOrder(viewState->m_sortOrder); + SetSortMethod(viewState->m_sortDescription); + SetSortOrder(viewState->m_sortDescription.sortOrder); } SetViewAsControl(viewState->m_viewMode); diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index bdbadc9299..2d268d4944 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -6220,7 +6220,7 @@ void CVideoDatabase::Stack(CFileItemList& items, VIDEODB_CONTENT_TYPE type, bool case VIDEODB_CONTENT_TVSHOWS: { // sort by Title - items.Sort(SORT_METHOD_VIDEO_TITLE, SortOrderAscending); + items.Sort(SortBySortTitle, SortOrderAscending); int i = 0; while (i < items.Size()) @@ -6287,7 +6287,7 @@ void CVideoDatabase::Stack(CFileItemList& items, VIDEODB_CONTENT_TYPE type, bool case VIDEODB_CONTENT_EPISODES: { // sort by ShowTitle, Episode, Filename - items.Sort(SORT_METHOD_EPISODE, SortOrderAscending); + items.Sort(SortByEpisodeNumber, SortOrderAscending); int i = 0; while (i < items.Size()) @@ -6382,7 +6382,7 @@ void CVideoDatabase::Stack(CFileItemList& items, VIDEODB_CONTENT_TYPE type, bool if (maintainSortOrder) { // restore original sort order - essential for smartplaylists - items.Sort(SORT_METHOD_PROGRAM_COUNT, SortOrderAscending); + items.Sort(SortByProgramCount, SortOrderAscending); } } diff --git a/xbmc/video/VideoInfoScanner.cpp b/xbmc/video/VideoInfoScanner.cpp index 3db96d825f..9c89cdba94 100644 --- a/xbmc/video/VideoInfoScanner.cpp +++ b/xbmc/video/VideoInfoScanner.cpp @@ -704,7 +704,7 @@ namespace VIDEO */ // since we're doing this now anyway, should other items be stacked? - items.Sort(SORT_METHOD_FULLPATH, SortOrderAscending); + items.Sort(SortByPath, SortOrderAscending); int x = 0; while (x < items.Size()) { diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index a023ef5c59..aa6d743b50 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -1532,7 +1532,7 @@ bool CGUIWindowVideoBase::OnPlayMedia(int iItem) CFileItemList items; CDirectory::GetDirectory(dir, items); - items.Sort(SORT_METHOD_FILE, SortOrderAscending); + items.Sort(SortByFile, SortOrderAscending); vector stack; for (int i = 0; i < items.Size(); ++i) @@ -2143,7 +2143,7 @@ void CGUIWindowVideoBase::AppendAndClearSearchItems(CFileItemList &searchItems, if (!searchItems.Size()) return; - searchItems.Sort(CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SORT_METHOD_LABEL_IGNORE_THE : SORT_METHOD_LABEL, SortOrderAscending); + searchItems.Sort(SortByLabel, SortOrderAscending, CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); for (int i = 0; i < searchItems.Size(); i++) searchItems[i]->SetLabel(prependLabel + searchItems[i]->GetLabel()); results.Append(searchItems); diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index 3ac89beeb4..105270c452 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -1538,7 +1538,7 @@ void CGUIWindowVideoNav::OnLinkMovieToTvShow(int itemnumber, bool bRemove) int iSelectedLabel = 0; if (list.Size() > 1) { - list.Sort(CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SORT_METHOD_LABEL_IGNORE_THE : SORT_METHOD_LABEL, SortOrderAscending); + list.Sort(SortByLabel, SortOrderAscending, CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetItems(&list); @@ -1802,7 +1802,7 @@ bool CGUIWindowVideoNav::GetItemsForTag(const CStdString &strHeading, const std: if (dialog == NULL) return false; - listItems.Sort(SORT_METHOD_LABEL_IGNORE_THE, SortOrderAscending); + listItems.Sort(SortByLabel, SortOrderAscending, SortAttributeIgnoreArticle); dialog->Reset(); dialog->SetMultiSelection(true); @@ -1836,7 +1836,7 @@ bool CGUIWindowVideoNav::GetMoviesForSet(CFileItemPtr &setItem, CFileItemList &o if (dialog == NULL) return false; - listItems.Sort(SORT_METHOD_LABEL_IGNORE_THE, SortOrderAscending); + listItems.Sort(SortByLabel, SortOrderAscending, SortAttributeIgnoreArticle); dialog->Reset(); dialog->SetMultiSelection(true); @@ -1877,7 +1877,7 @@ bool CGUIWindowVideoNav::GetSetForMovie(CFileItemPtr &movieItem, CFileItemPtr &s CStdString baseDir = "videodb://movies/sets/"; if (!CDirectory::GetDirectory(baseDir, listItems) || listItems.Size() <= 0) return false; - listItems.Sort(SORT_METHOD_LABEL_IGNORE_THE, SortOrderAscending); + listItems.Sort(SortByLabel, SortOrderAscending, SortAttributeIgnoreArticle); int currentSetId = 0; CStdString currentSetLabel; diff --git a/xbmc/view/GUIViewState.cpp b/xbmc/view/GUIViewState.cpp index 3a241ee3d2..95c8a9a057 100644 --- a/xbmc/view/GUIViewState.cpp +++ b/xbmc/view/GUIViewState.cpp @@ -165,14 +165,17 @@ SortOrder CGUIViewState::GetDisplaySortOrder() const // the one sort order variable to save but it can be ascending usually, // and descending for the views which should be usually descending. // default sort order for date, size, program count + rating is reversed - SORT_METHOD sortMethod = GetSortMethod(); - if (sortMethod == SORT_METHOD_DATE || sortMethod == SORT_METHOD_SIZE || sortMethod == SORT_METHOD_PLAYCOUNT || - sortMethod == SORT_METHOD_VIDEO_RATING || sortMethod == SORT_METHOD_PROGRAM_COUNT || - sortMethod == SORT_METHOD_SONG_RATING || sortMethod == SORT_METHOD_BITRATE || sortMethod == SORT_METHOD_LISTENERS) + SortDescription sorting = GetSortMethod(); + if (sorting.sortBy == SortByDate || sorting.sortBy == SortBySize || sorting.sortBy == SortByPlaycount || + sorting.sortBy == SortByRating || sorting.sortBy == SortByProgramCount || + sorting.sortBy == SortByBitrate || sorting.sortBy == SortByListeners) { - if (m_sortOrder == SortOrderAscending) return SortOrderDescending; - if (m_sortOrder == SortOrderDescending) return SortOrderAscending; + if (m_sortOrder == SortOrderAscending) + return SortOrderDescending; + if (m_sortOrder == SortOrderDescending) + return SortOrderAscending; } + return m_sortOrder; } @@ -207,12 +210,14 @@ void CGUIViewState::SaveViewAsControl(int viewAsControl) SaveViewState(); } -SORT_METHOD CGUIViewState::GetSortMethod() const +SortDescription CGUIViewState::GetSortMethod() const { + SortDescription sorting; if (m_currentSortMethod>=0 && m_currentSortMethod<(int)m_sortMethods.size()) - return m_sortMethods[m_currentSortMethod].m_sortMethod; + sorting = m_sortMethods[m_currentSortMethod].m_sortDescription; + sorting.sortOrder = m_sortOrder; - return SORT_METHOD_NONE; + return sorting; } int CGUIViewState::GetSortMethodLabel() const @@ -223,12 +228,6 @@ int CGUIViewState::GetSortMethodLabel() const return 103; // Sort By: Name } -void CGUIViewState::GetSortMethods(vector< pair > &sortMethods) const -{ - for (unsigned int i = 0; i < m_sortMethods.size(); i++) - sortMethods.push_back(make_pair(m_sortMethods[i].m_sortMethod, m_sortMethods[i].m_buttonLabel)); -} - void CGUIViewState::GetSortMethodLabelMasks(LABEL_MASKS& masks) const { if (m_currentSortMethod>=0 && m_currentSortMethod<(int)m_sortMethods.size()) @@ -244,54 +243,69 @@ void CGUIViewState::GetSortMethodLabelMasks(LABEL_MASKS& masks) const return; } -void CGUIViewState::AddSortMethod(SORT_METHOD sortMethod, int buttonLabel, LABEL_MASKS labelmasks) +void CGUIViewState::AddSortMethod(SortBy sortBy, int buttonLabel, const LABEL_MASKS &labelMasks, SortAttribute sortAttributes /* = SortAttributeNone */) +{ + AddSortMethod(sortBy, sortAttributes, buttonLabel, labelMasks); +} + +void CGUIViewState::AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, int buttonLabel, const LABEL_MASKS &labelMasks) { for (size_t i = 0; i < m_sortMethods.size(); ++i) - if (m_sortMethods[i].m_sortMethod == sortMethod) + if (m_sortMethods[i].m_sortDescription.sortBy == sortBy) return; SORT_METHOD_DETAILS sort; - sort.m_sortMethod=sortMethod; - sort.m_buttonLabel=buttonLabel; - sort.m_labelMasks=labelmasks; + sort.m_sortDescription.sortBy = sortBy; + sort.m_sortDescription.sortAttributes = sortAttributes; + sort.m_buttonLabel = buttonLabel; + sort.m_labelMasks = labelMasks; m_sortMethods.push_back(sort); } +void CGUIViewState::AddSortMethod(SortDescription sortDescription, int buttonLabel, const LABEL_MASKS &labelMasks) +{ + AddSortMethod(sortDescription.sortBy, sortDescription.sortAttributes, buttonLabel, labelMasks); +} + void CGUIViewState::SetCurrentSortMethod(int method) { - bool ignoreThe = CSettings::Get().GetBool("filelists.ignorethewhensorting"); + SortBy sortBy = (SortBy)method; + SortAttribute sortAttributes = SortAttributeNone; + if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) + sortAttributes = SortAttributeIgnoreArticle; - if (method < SORT_METHOD_NONE || method >= SORT_METHOD_MAX) + if (sortBy < SortByNone || sortBy > SortByRandom) return; // invalid - // compensate for "Ignore The" options to make it easier on the skin - if (ignoreThe && (method == SORT_METHOD_LABEL || method == SORT_METHOD_TITLE || method == SORT_METHOD_ARTIST || method == SORT_METHOD_ALBUM || method == SORT_METHOD_STUDIO || method == SORT_METHOD_VIDEO_SORT_TITLE)) - method++; - else if (!ignoreThe && (method == SORT_METHOD_LABEL_IGNORE_THE || method == SORT_METHOD_TITLE_IGNORE_THE || method == SORT_METHOD_ARTIST_IGNORE_THE || method==SORT_METHOD_ALBUM_IGNORE_THE || method == SORT_METHOD_STUDIO_IGNORE_THE || method == SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE)) - method--; - - SetSortMethod((SORT_METHOD)method); + SetSortMethod(sortBy, sortAttributes); SaveViewState(); } -void CGUIViewState::SetSortMethod(SORT_METHOD sortMethod) +void CGUIViewState::SetSortMethod(SortBy sortBy, SortAttribute sortAttributes /* = SortAttributeNone */) { - for (int i=0; i<(int)m_sortMethods.size(); ++i) + for (int i = 0; i < (int)m_sortMethods.size(); ++i) { - if (m_sortMethods[i].m_sortMethod==sortMethod) + if (m_sortMethods[i].m_sortDescription.sortBy == sortBy && + // don't care about SortAttributeIgnoreFolders as it wasn't part of the old sorting comparison + m_sortMethods[i].m_sortDescription.sortAttributes == (sortAttributes & ~SortAttributeIgnoreFolders)) { - m_currentSortMethod=i; + m_currentSortMethod = i; break; } } } -SORT_METHOD CGUIViewState::SetNextSortMethod(int direction /* = 1 */) +void CGUIViewState::SetSortMethod(SortDescription sortDescription) +{ + return SetSortMethod(sortDescription.sortBy, sortDescription.sortAttributes); +} + +SortDescription CGUIViewState::SetNextSortMethod(int direction /* = 1 */) { m_currentSortMethod += direction; if (m_currentSortMethod >= (int)m_sortMethods.size()) - m_currentSortMethod=0; + m_currentSortMethod = 0; if (m_currentSortMethod < 0) m_currentSortMethod = m_sortMethods.size() ? (int)m_sortMethods.size() - 1 : 0; @@ -345,7 +359,6 @@ bool CGUIViewState::IsCurrentPlaylistDirectory(const CStdString& strDirectory) return (m_strPlaylistDirectory==strDir); } - bool CGUIViewState::AutoPlayNextItem() { return false; @@ -424,8 +437,8 @@ void CGUIViewState::AddLiveTVSources() CGUIViewStateGeneral::CGUIViewStateGeneral(const CFileItemList& items) : CGUIViewState(items) { - AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, size | Foldername, empty - SetSortMethod(SORT_METHOD_LABEL); + AddSortMethod(SortByLabel, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, size | Foldername, empty + SetSortMethod(SortByLabel); SetViewAsControl(DEFAULT_VIEW_LIST); @@ -434,7 +447,7 @@ CGUIViewStateGeneral::CGUIViewStateGeneral(const CFileItemList& items) : CGUIVie void CGUIViewState::SetSortOrder(SortOrder sortOrder) { - if (GetSortMethod() == SORT_METHOD_NONE) + if (GetSortMethod().sortBy == SortByNone) m_sortOrder = SortOrderNone; else if (sortOrder == SortOrderNone) m_sortOrder = SortOrderAscending; @@ -452,8 +465,8 @@ void CGUIViewState::LoadViewState(const CStdString &path, int windowID) db.GetViewState(path, windowID, state, "")) { SetViewAsControl(state.m_viewMode); - SetSortMethod(state.m_sortMethod); - SetSortOrder(state.m_sortOrder); + SetSortMethod(state.m_sortDescription); + SetSortOrder(state.m_sortDescription.sortOrder); } db.Close(); } @@ -464,7 +477,8 @@ void CGUIViewState::SaveViewToDb(const CStdString &path, int windowID, CViewStat CViewDatabase db; if (db.Open()) { - CViewState state(m_currentViewAsControl, GetSortMethod(), m_sortOrder); + SortDescription sorting = GetSortMethod(); + CViewState state(m_currentViewAsControl, sorting.sortBy, m_sortOrder, sorting.sortAttributes); if (viewState) *viewState = state; db.SetViewState(path, windowID, state, CSettings::Get().GetString("lookandfeel.skin")); @@ -476,26 +490,20 @@ 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; + SortBy sortBy = SortByPlaylistOrder; int sortLabel = 559; SortOrder sortOrder = SortOrderAscending; if (items.HasProperty(PROPERTY_SORT_ORDER)) { - SortBy sortBy = (SortBy)items.GetProperty(PROPERTY_SORT_ORDER).asInteger(); + sortBy = (SortBy)items.GetProperty(PROPERTY_SORT_ORDER).asInteger(); if (sortBy != SortByNone) { - sortMethod = SortUtils::TranslateOldSortMethod(sortBy, CSettings::Get().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; - } + sortLabel = SortUtils::GetSortLabel(sortBy); + sortOrder = items.GetProperty(PROPERTY_SORT_ASCENDING).asBoolean() ? SortOrderAscending : SortOrderDescending; } } - AddSortMethod(sortMethod, sortLabel, label_masks); - SetSortMethod(sortMethod); + AddSortMethod(sortBy, sortLabel, label_masks); + SetSortMethod(sortBy); SetSortOrder(sortOrder); } @@ -506,7 +514,7 @@ CGUIViewStateFromItems::CGUIViewStateFromItems(const CFileItemList &items) : CGU for (unsigned int i = 0; i < details.size(); i++) { const SORT_METHOD_DETAILS sort = details[i]; - AddSortMethod(sort.m_sortMethod, sort.m_buttonLabel, sort.m_labelMasks); + AddSortMethod(sort.m_sortDescription, sort.m_buttonLabel, sort.m_labelMasks); } // TODO: Should default sort/view mode be specified? m_currentSortMethod = 0; @@ -537,8 +545,8 @@ void CGUIViewStateFromItems::SaveViewState() CGUIViewStateLibrary::CGUIViewStateLibrary(const CFileItemList &items) : CGUIViewState(items) { - AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, Size | Foldername, empty - SetSortMethod(SORT_METHOD_NONE); + AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, Size | Foldername, empty + SetSortMethod(SortByNone); SetSortOrder(SortOrderNone); SetViewAsControl(DEFAULT_VIEW_LIST); diff --git a/xbmc/view/GUIViewState.h b/xbmc/view/GUIViewState.h index cf91611b49..54c766b1e0 100644 --- a/xbmc/view/GUIViewState.h +++ b/xbmc/view/GUIViewState.h @@ -37,12 +37,11 @@ public: void SaveViewAsControl(int viewAsControl); int GetViewAsControl() const; - SORT_METHOD SetNextSortMethod(int direction = 1); + SortDescription SetNextSortMethod(int direction = 1); void SetCurrentSortMethod(int method); - SORT_METHOD GetSortMethod() const; + SortDescription GetSortMethod() const; int GetSortMethodLabel() const; void GetSortMethodLabelMasks(LABEL_MASKS& masks) const; - void GetSortMethods(std::vector< std::pair > &sortMethods) const; SortOrder SetNextSortOrder(); SortOrder GetSortOrder() const { return m_sortOrder; }; @@ -83,8 +82,11 @@ protected: */ 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 AddSortMethod(SortBy sortBy, int buttonLabel, const LABEL_MASKS &labelMasks, SortAttribute sortAttributes = SortAttributeNone); + void AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, int buttonLabel, const LABEL_MASKS &labelMasks); + void AddSortMethod(SortDescription sortDescription, int buttonLabel, const LABEL_MASKS &labelMasks); + void SetSortMethod(SortBy sortBy, SortAttribute sortAttributes = SortAttributeNone); + void SetSortMethod(SortDescription sortDescription); void SetSortOrder(SortOrder sortOrder); const CFileItemList& m_items; diff --git a/xbmc/view/ViewDatabase.cpp b/xbmc/view/ViewDatabase.cpp index 17001bb994..e107d8be88 100644 --- a/xbmc/view/ViewDatabase.cpp +++ b/xbmc/view/ViewDatabase.cpp @@ -28,6 +28,7 @@ #include "linux/ConvUtils.h" // GetLastError() #endif #include "dbwrappers/dataset.h" +#include "SortFileItem.h" //******************************************************************************************************************************** @@ -54,7 +55,15 @@ bool CViewDatabase::CreateTables() CDatabase::CreateTables(); CLog::Log(LOGINFO, "create view table"); - m_pDS->exec("CREATE TABLE view ( idView integer primary key, window integer, path text, viewMode integer, sortMethod integer, sortOrder integer, skin text)\n"); + m_pDS->exec("CREATE TABLE view (" + "idView integer primary key," + "window integer," + "path text," + "viewMode integer," + "sortMethod integer," + "sortOrder integer," + "sortAttributes integer," + "skin text)\n"); CLog::Log(LOGINFO, "create view index"); m_pDS->exec("CREATE INDEX idxViews ON view(path)"); CLog::Log(LOGINFO, "create view - window index"); @@ -99,6 +108,41 @@ bool CViewDatabase::UpdateOldVersion(int version) m_pDS->exec(PrepareSQL("UPDATE view SET path='%s' WHERE idView=%d", it->second.c_str(), it->first).c_str()); } } + if (version < 6) + { + // convert the "path" table + m_pDS->exec("CREATE TABLE tmp_view AS SELECT * FROM view"); + m_pDS->exec("DROP INDEX idxViews"); + m_pDS->exec("DROP INDEX idxViewsWindow"); + m_pDS->exec("DROP TABLE view"); + + m_pDS->exec("CREATE TABLE view (" + "idView integer primary key," + "window integer," + "path text," + "viewMode integer," + "sortMethod integer," + "sortOrder integer," + "sortAttributes integer," + "skin text)\n"); + m_pDS->exec("CREATE INDEX idxViews ON view(path)"); + m_pDS->exec("CREATE INDEX idxViewsWindow ON view(window)"); + + m_pDS->query("SELECT * FROM tmp_view"); + while (!m_pDS->eof()) + { + SortDescription sorting = SortUtils::TranslateOldSortMethod((SORT_METHOD)m_pDS->fv(4).get_asInt()); + + CStdString sql = PrepareSQL("INSERT INTO view (idView, window, path, viewMode, sortMethod, sortOrder, sortAttributes, skin) VALUES (%i, %i, '%s', %i, %i, %i, %i, '%s')", + m_pDS->fv(0).get_asInt(), m_pDS->fv(1).get_asInt(), m_pDS->fv(2).get_asString().c_str(), m_pDS->fv(3).get_asInt(), + (int)sorting.sortBy, m_pDS->fv(5).get_asInt(), (int)sorting.sortAttributes, m_pDS->fv(6).get_asString().c_str()); + m_pDS2->exec(sql); + + m_pDS->next(); + } + m_pDS->exec("DROP TABLE tmp_view"); + } + return true; } @@ -123,8 +167,9 @@ bool CViewDatabase::GetViewState(const CStdString &path, int window, CViewState if (!m_pDS->eof()) { // have some information state.m_viewMode = m_pDS->fv("viewMode").get_asInt(); - state.m_sortMethod = (SORT_METHOD)m_pDS->fv("sortMethod").get_asInt(); - state.m_sortOrder = (SortOrder)m_pDS->fv("sortOrder").get_asInt(); + state.m_sortDescription.sortBy = (SortBy)m_pDS->fv("sortMethod").get_asInt(); + state.m_sortDescription.sortOrder = (SortOrder)m_pDS->fv("sortOrder").get_asInt(); + state.m_sortDescription.sortAttributes = (SortAttribute)m_pDS->fv("sortAttributes").get_asInt(); m_pDS->close(); return true; } @@ -154,13 +199,15 @@ bool CViewDatabase::SetViewState(const CStdString &path, int window, const CView { // update the view int idView = m_pDS->fv("idView").get_asInt(); m_pDS->close(); - sql = PrepareSQL("update view set viewMode=%i,sortMethod=%i,sortOrder=%i where idView=%i", state.m_viewMode, (int)state.m_sortMethod, (int)state.m_sortOrder, idView); + sql = PrepareSQL("update view set viewMode=%i,sortMethod=%i,sortOrder=%i,sortAttributes=%i where idView=%i", + state.m_viewMode, (int)state.m_sortDescription.sortBy, (int)state.m_sortDescription.sortOrder, (int)state.m_sortDescription.sortAttributes, idView); m_pDS->exec(sql.c_str()); } else { // add the view m_pDS->close(); - sql = PrepareSQL("insert into view (idView, path, window, viewMode, sortMethod, sortOrder, skin) values(NULL, '%s', %i, %i, %i, %i, '%s')", path1.c_str(), window, state.m_viewMode, (int)state.m_sortMethod, (int)state.m_sortOrder, skin.c_str()); + sql = PrepareSQL("insert into view (idView, path, window, viewMode, sortMethod, sortOrder, sortAttributes, skin) values(NULL, '%s', %i, %i, %i, %i, %i, '%s')", + path1.c_str(), window, state.m_viewMode, (int)state.m_sortDescription.sortOrder, (int)state.m_sortDescription.sortAttributes, skin.c_str()); m_pDS->exec(sql.c_str()); } } diff --git a/xbmc/view/ViewDatabase.h b/xbmc/view/ViewDatabase.h index 76aec016f7..191a20f322 100644 --- a/xbmc/view/ViewDatabase.h +++ b/xbmc/view/ViewDatabase.h @@ -36,6 +36,6 @@ public: protected: virtual bool CreateTables(); virtual bool UpdateOldVersion(int version); - virtual int GetMinVersion() const { return 5; }; + virtual int GetMinVersion() const { return 6; }; const char *GetBaseDBName() const { return "ViewModes"; }; }; diff --git a/xbmc/view/ViewState.h b/xbmc/view/ViewState.h index dde07963c1..d5e7f293c8 100644 --- a/xbmc/view/ViewState.h +++ b/xbmc/view/ViewState.h @@ -32,20 +32,20 @@ class CViewState { public: - CViewState(int viewMode, SORT_METHOD sortMethod, SortOrder sortOrder) + CViewState(int viewMode, SortBy sortMethod, SortOrder sortOrder, SortAttribute sortAttributes = SortAttributeNone) { m_viewMode = viewMode; - m_sortMethod = sortMethod; - m_sortOrder = sortOrder; + m_sortDescription.sortBy = sortMethod; + m_sortDescription.sortOrder = sortOrder; + m_sortDescription.sortAttributes = sortAttributes; }; CViewState() { m_viewMode = 0; - m_sortMethod = SORT_METHOD_LABEL; - m_sortOrder = SortOrderAscending; + m_sortDescription.sortBy = SortByLabel; + m_sortDescription.sortOrder = SortOrderAscending; }; int m_viewMode; - SORT_METHOD m_sortMethod; - SortOrder m_sortOrder; + SortDescription m_sortDescription; }; diff --git a/xbmc/view/ViewStateSettings.cpp b/xbmc/view/ViewStateSettings.cpp index 24a7ed76f9..0d853472b0 100644 --- a/xbmc/view/ViewStateSettings.cpp +++ b/xbmc/view/ViewStateSettings.cpp @@ -31,6 +31,7 @@ #define XML_VIEWMODE "viewmode" #define XML_SORTMETHOD "sortmethod" #define XML_SORTORDER "sortorder" +#define XML_SORTATTRIBUTES "sortattributes" #define XML_GENERAL "general" #define XML_SETTINGLEVEL "settinglevel" @@ -46,7 +47,7 @@ CViewStateSettings::CViewStateSettings() AddViewState("videonavyears"); AddViewState("videonavgenres"); AddViewState("videonavtitles"); - AddViewState("videonavepisodes", DEFAULT_VIEW_AUTO, SORT_METHOD_EPISODE); + AddViewState("videonavepisodes", DEFAULT_VIEW_AUTO, SortByEpisodeNumber); AddViewState("videonavtvshows"); AddViewState("videonavseasons"); AddViewState("videonavmusicvideos"); @@ -93,13 +94,25 @@ bool CViewStateSettings::Load(const TiXmlNode *settings) XMLUtils::GetInt(pViewState, XML_VIEWMODE, viewState->second->m_viewMode, DEFAULT_VIEW_LIST, DEFAULT_VIEW_MAX); - int sortMethod; - if (XMLUtils::GetInt(pViewState, XML_SORTMETHOD, sortMethod, SORT_METHOD_NONE, SORT_METHOD_MAX)) - viewState->second->m_sortMethod = (SORT_METHOD)sortMethod; + // keep backwards compatibility to the old sorting methods + if (pViewState->FirstChild(XML_SORTATTRIBUTES) == NULL) + { + int sortMethod; + if (XMLUtils::GetInt(pViewState, XML_SORTMETHOD, sortMethod, SORT_METHOD_NONE, SORT_METHOD_MAX)) + viewState->second->m_sortDescription = SortUtils::TranslateOldSortMethod((SORT_METHOD)sortMethod); + } + else + { + int sortMethod; + if (XMLUtils::GetInt(pViewState, XML_SORTMETHOD, sortMethod, SortByNone, SortByRandom)) + viewState->second->m_sortDescription.sortBy = (SortBy)sortMethod; + if (XMLUtils::GetInt(pViewState, XML_SORTATTRIBUTES, sortMethod, SortAttributeNone, SortAttributeIgnoreFolders)) + viewState->second->m_sortDescription.sortAttributes = (SortAttribute)sortMethod; + } int sortOrder; if (XMLUtils::GetInt(pViewState, XML_SORTORDER, sortOrder, SortOrderNone, SortOrderDescending)) - viewState->second->m_sortOrder = (SortOrder)sortOrder; + viewState->second->m_sortDescription.sortOrder = (SortOrder)sortOrder; } pElement = settings->FirstChild(XML_GENERAL); @@ -138,8 +151,9 @@ bool CViewStateSettings::Save(TiXmlNode *settings) const continue; XMLUtils::SetInt(pNewNode, XML_VIEWMODE, viewState->second->m_viewMode); - XMLUtils::SetInt(pNewNode, XML_SORTMETHOD, (int)viewState->second->m_sortMethod); - XMLUtils::SetInt(pNewNode, XML_SORTORDER, (int)viewState->second->m_sortOrder); + XMLUtils::SetInt(pNewNode, XML_SORTMETHOD, (int)viewState->second->m_sortDescription.sortBy); + XMLUtils::SetInt(pNewNode, XML_SORTORDER, (int)viewState->second->m_sortDescription.sortOrder); + XMLUtils::SetInt(pNewNode, XML_SORTATTRIBUTES, (int)viewState->second->m_sortDescription.sortAttributes); } TiXmlNode *generalNode = settings->FirstChild(XML_GENERAL); @@ -204,7 +218,7 @@ SettingLevel CViewStateSettings::GetNextSettingLevel() const return level; } -void CViewStateSettings::AddViewState(const std::string& strTagName, int defaultView /* = DEFAULT_VIEW_LIST */, SORT_METHOD defaultSort /* = SORT_METHOD_LABEL */) +void CViewStateSettings::AddViewState(const std::string& strTagName, int defaultView /* = DEFAULT_VIEW_LIST */, SortBy defaultSort /* = SortByLabel */) { if (strTagName.empty() || m_viewStates.find(strTagName) != m_viewStates.end()) return; diff --git a/xbmc/view/ViewStateSettings.h b/xbmc/view/ViewStateSettings.h index d29bf66eee..cc0ca8d4a2 100644 --- a/xbmc/view/ViewStateSettings.h +++ b/xbmc/view/ViewStateSettings.h @@ -58,5 +58,5 @@ private: SettingLevel m_settingLevel; CCriticalSection m_critical; - void AddViewState(const std::string& strTagName, int defaultView = DEFAULT_VIEW_LIST, SORT_METHOD defaultSort = SORT_METHOD_LABEL); + void AddViewState(const std::string& strTagName, int defaultView = DEFAULT_VIEW_LIST, SortBy defaultSort = SortByLabel); }; diff --git a/xbmc/windows/GUIMediaWindow.cpp b/xbmc/windows/GUIMediaWindow.cpp index 7a64e02efb..99dfa1e420 100644 --- a/xbmc/windows/GUIMediaWindow.cpp +++ b/xbmc/windows/GUIMediaWindow.cpp @@ -546,14 +546,11 @@ void CGUIMediaWindow::UpdateButtons() m_viewControl.SetCurrentView(m_guiState->GetViewAsControl()); // Update sort by button - if (m_guiState->GetSortMethod()==SORT_METHOD_NONE) - { + if (m_guiState->GetSortMethod().sortBy == SortByNone) CONTROL_DISABLE(CONTROL_BTNSORTBY); - } else - { CONTROL_ENABLE(CONTROL_BTNSORTBY); - } + CStdString sortLabel; sortLabel.Format(g_localizeStrings.Get(550).c_str(), g_localizeStrings.Get(m_guiState->GetSortMethodLabel()).c_str()); SET_CONTROL_LABEL(CONTROL_BTNSORTBY, sortLabel); @@ -580,35 +577,30 @@ void CGUIMediaWindow::SortItems(CFileItemList &items) if (guiState.get()) { - bool sorted = false; - SORT_METHOD sortMethod = guiState->GetSortMethod(); + SortDescription sorting = guiState->GetSortMethod(); + sorting.sortOrder = guiState->GetDisplaySortOrder(); // 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)) + if ((sorting.sortBy == SortByPlaylistOrder) && 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 = CSettings::Get().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. + // in CGUIViewState::AddPlaylistOrder that SortByPlaylistOrder 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()); + items.Sort(sorting); } } @@ -630,8 +622,7 @@ void CGUIMediaWindow::FormatItemLabels(CFileItemList &items, const LABEL_MASKS & fileFormatter.FormatLabels(pItem.get()); } - if(items.GetSortMethod() == SORT_METHOD_LABEL_IGNORE_THE - || items.GetSortMethod() == SORT_METHOD_LABEL) + if (items.GetSortMethod() == SortByLabel) items.ClearSortState(); } @@ -646,7 +637,7 @@ void CGUIMediaWindow::FormatAndSort(CFileItemList &items) viewState->GetSortMethodLabelMasks(labelMasks); FormatItemLabels(items, labelMasks); - items.Sort(viewState->GetSortMethod(), viewState->GetDisplaySortOrder()); + items.Sort(viewState->GetSortMethod().sortBy, viewState->GetDisplaySortOrder(), viewState->GetSortMethod().sortAttributes); } } diff --git a/xbmc/windows/GUIWindowFileManager.cpp b/xbmc/windows/GUIWindowFileManager.cpp index eeb40ed441..124786ae61 100644 --- a/xbmc/windows/GUIWindowFileManager.cpp +++ b/xbmc/windows/GUIWindowFileManager.cpp @@ -352,7 +352,7 @@ void CGUIWindowFileManager::OnSort(int iList) } - m_vecItems[iList]->Sort(SORT_METHOD_LABEL, SortOrderAscending); + m_vecItems[iList]->Sort(SortByLabel, SortOrderAscending); } void CGUIWindowFileManager::ClearFileItems(int iList) -- cgit v1.2.3