Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move from the old library sorting (in SSortFileItem) to the new imple…

…mentation (in SortUtils)
  • Loading branch information...
commit fa329d041aad4baa62a7cb0b7bcc0f2a817aa42c 1 parent 82adcef
@Montellese Montellese authored
Showing with 267 additions and 781 deletions.
  1. +1 −1  xbmc/Autorun.cpp
  2. +128 −74 xbmc/FileItem.cpp
  3. +10 −8 xbmc/FileItem.h
  4. +3 −3 xbmc/GUIInfoManager.cpp
  5. +15 −15 xbmc/GUIViewState.cpp
  6. +5 −5 xbmc/GUIViewState.h
  7. +0 −1  xbmc/Makefile.in
  8. +0 −500 xbmc/SortFileItem.cpp
  9. +1 −71 xbmc/SortFileItem.h
  10. +1 −1  xbmc/ViewDatabase.cpp
  11. +3 −3 xbmc/ViewState.h
  12. +1 −1  xbmc/addons/GUIDialogAddonInfo.cpp
  13. +1 −1  xbmc/addons/GUIViewStateAddonBrowser.cpp
  14. +2 −2 xbmc/addons/GUIWindowAddonBrowser.cpp
  15. +1 −1  xbmc/dialogs/GUIDialogFileBrowser.cpp
  16. +1 −1  xbmc/dialogs/GUIDialogSelect.cpp
  17. +7 −7 xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp
  18. +17 −17 xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp
  19. +1 −1  xbmc/filesystem/AddonsDirectory.cpp
  20. +1 −1  xbmc/filesystem/LibraryDirectory.cpp
  21. +1 −1  xbmc/filesystem/MultiPathDirectory.cpp
  22. +1 −1  xbmc/filesystem/MusicDatabaseDirectory/DirectoryNode.cpp
  23. +1 −1  xbmc/filesystem/RarManager.cpp
  24. +1 −1  xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.cpp
  25. +2 −1  xbmc/guilib/GUIBaseContainer.cpp
  26. +2 −2 xbmc/input/ButtonTranslator.cpp
  27. +3 −3 xbmc/interfaces/http-api/XBMChttp.cpp
  28. +3 −3 xbmc/interfaces/json-rpc/AudioLibrary.cpp
  29. +4 −4 xbmc/interfaces/json-rpc/FileItemHandler.cpp
  30. +1 −1  xbmc/interfaces/json-rpc/FileItemHandler.h
  31. +1 −1  xbmc/interfaces/json-rpc/FileOperations.cpp
  32. +2 −2 xbmc/interfaces/python/xbmcmodule/listitem.cpp
  33. +14 −14 xbmc/music/GUIViewStateMusic.cpp
  34. +2 −2 xbmc/music/infoscanner/MusicInfoScanner.cpp
  35. +2 −2 xbmc/music/windows/GUIWindowMusicBase.cpp
  36. +1 −1  xbmc/network/UPnP.cpp
  37. +1 −1  xbmc/pictures/GUIViewStatePictures.cpp
  38. +3 −3 xbmc/pictures/GUIWindowSlideShow.cpp
  39. +4 −4 xbmc/pictures/GUIWindowSlideShow.h
  40. +1 −1  xbmc/pictures/PictureThumbLoader.cpp
  41. +2 −2 xbmc/settings/Settings.cpp
  42. +1 −1  xbmc/storage/MediaManager.cpp
  43. +7 −7 xbmc/video/GUIViewStateVideo.cpp
  44. +1 −1  xbmc/video/VideoInfoScanner.cpp
  45. +1 −1  xbmc/video/windows/GUIWindowVideoBase.cpp
  46. +1 −1  xbmc/video/windows/GUIWindowVideoNav.cpp
  47. +3 −3 xbmc/windows/GUIMediaWindow.cpp
  48. +2 −2 xbmc/windows/GUIWindowFileManager.cpp
View
2  xbmc/Autorun.cpp
@@ -216,7 +216,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, SORT_ORDER_ASC);
+ items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO);
g_playlistPlayer.Add(PLAYLIST_VIDEO, items);
g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO);
View
202 xbmc/FileItem.cpp
@@ -57,6 +57,7 @@
#include "music/karaoke/karaokelyricsfactory.h"
#include "ThumbnailCache.h"
#include "utils/Mime.h"
+#include "utils/CharsetConverter.h"
using namespace std;
using namespace XFILE;
@@ -347,7 +348,7 @@ void CFileItem::Reset()
delete m_pictureInfoTag;
m_pictureInfoTag=NULL;
m_extrainfo.Empty();
- m_specialSort = SORT_NORMALLY;
+ m_specialSort = SortSpecialNone;
SetInvalid();
}
@@ -426,7 +427,7 @@ void CFileItem::Archive(CArchive& ar)
ar >> m_mimetype;
ar >> m_extrainfo;
ar >> temp;
- m_specialSort = (SPECIAL_SORT)temp;
+ m_specialSort = (SortSpecial)temp;
int iType;
ar >> iType;
@@ -465,6 +466,34 @@ void CFileItem::Serialize(CVariant& value)
(*m_pictureInfoTag).Serialize(value["pictureInfoTag"]);
}
+void CFileItem::ToSortable(SortItem &sortable)
+{
+ sortable[FieldPath] = m_strPath;
+ sortable[FieldDate] = (m_dateTime.IsValid()) ? m_dateTime.GetAsRFC1123DateTime() : "";
+ sortable[FieldSize] = (int) m_dwSize / 1000;
+ sortable[FieldDriveType] = m_iDriveType;
+ sortable[FieldStartOffset] = m_lStartOffset;
+ sortable[FieldStartOffset] = m_lEndOffset;
+ sortable[FieldProgramCount] = m_iprogramCount;
+ sortable[FieldBitrate] = m_dwSize;
+ sortable[FieldTitle] = m_strTitle;
+ sortable[FieldSortSpecial] = m_specialSort;
+ sortable[FieldFolder] = m_bIsFolder;
+
+ // If there's ever a need to convert more properties from CGUIListItem it might be
+ // worth to make CGUIListItem implement ISortable as well and call it from here
+ sortable[FieldLabel] = GetLabel();
+
+ if (HasMusicInfoTag())
+ GetMusicInfoTag()->ToSortable(sortable);
+
+ if (HasVideoInfoTag())
+ GetVideoInfoTag()->ToSortable(sortable);
+
+ if (HasPictureInfoTag())
+ GetPictureInfoTag()->ToSortable(sortable);
+}
+
bool CFileItem::Exists(bool bUseCache /* = true */) const
{
if (m_strPath.IsEmpty()
@@ -1034,7 +1063,7 @@ void CFileItem::SetLabel(const CStdString &strLabel)
{
m_bIsParentFolder=true;
m_bIsFolder=true;
- m_specialSort = SORT_ON_TOP;
+ m_specialSort = SortSpecialOnTop;
SetLabelPreformated(true);
}
CGUIListItem::SetLabel(strLabel);
@@ -1186,10 +1215,10 @@ void CFileItem::UpdateInfo(const CFileItem &item, bool replaceLabels /*=true*/)
CFileItemList::CFileItemList()
{
m_fastLookup = false;
- m_bIsFolder=true;
- m_cacheToDisc=CACHE_IF_SLOW;
- m_sortMethod=SORT_METHOD_NONE;
- m_sortOrder=SORT_ORDER_NONE;
+ m_bIsFolder = true;
+ m_cacheToDisc = CACHE_IF_SLOW;
+ m_sortMethod = SORT_METHOD_NONE;
+ m_sortOrder = SortOrderNone;
m_sortIgnoreFolders = false;
m_replaceListing = false;
}
@@ -1197,9 +1226,9 @@ CFileItemList::CFileItemList()
CFileItemList::CFileItemList(const CStdString& strPath) : CFileItem(strPath, true)
{
m_fastLookup = false;
- m_cacheToDisc=CACHE_IF_SLOW;
- m_sortMethod=SORT_METHOD_NONE;
- m_sortOrder=SORT_ORDER_NONE;
+ m_cacheToDisc = CACHE_IF_SLOW;
+ m_sortMethod = SORT_METHOD_NONE;
+ m_sortOrder = SortOrderNone;
m_sortIgnoreFolders = false;
m_replaceListing = false;
}
@@ -1271,10 +1300,10 @@ void CFileItemList::Clear()
CSingleLock lock(m_lock);
ClearItems();
- m_sortMethod=SORT_METHOD_NONE;
- m_sortOrder=SORT_ORDER_NONE;
+ m_sortMethod = SORT_METHOD_NONE;
+ m_sortOrder = SortOrderNone;
m_sortIgnoreFolders = false;
- m_cacheToDisc=CACHE_IF_SLOW;
+ m_cacheToDisc = CACHE_IF_SLOW;
m_sortDetails.clear();
m_replaceListing = false;
m_content.Empty();
@@ -1509,125 +1538,121 @@ void CFileItemList::FillSortFields(FILEITEMFILLFUNC func)
std::for_each(m_items.begin(), m_items.end(), func);
}
-void CFileItemList::Sort(SORT_METHOD sortMethod, SORT_ORDER sortOrder)
+void CFileItemList::Sort(SORT_METHOD sortMethod, SortOrder sortOrder)
{
// Already sorted?
- if (sortMethod==m_sortMethod && m_sortOrder==sortOrder)
+ if (sortMethod == m_sortMethod && m_sortOrder == sortOrder)
return;
+ SortBy sortBy = SortByNone;
+ SortAttribute sortAttributes = SortAttributeNone;
+
switch (sortMethod)
{
case SORT_METHOD_LABEL:
case SORT_METHOD_LABEL_IGNORE_FOLDERS:
- FillSortFields(SSortFileItem::ByLabel);
- break;
case SORT_METHOD_LABEL_IGNORE_THE:
- FillSortFields(SSortFileItem::ByLabelNoThe);
+ sortBy = SortByLabel;
break;
case SORT_METHOD_DATE:
- FillSortFields(SSortFileItem::ByDate);
+ sortBy = SortByDate;
break;
case SORT_METHOD_SIZE:
- FillSortFields(SSortFileItem::BySize);
+ sortBy = SortBySize;
break;
case SORT_METHOD_BITRATE:
- FillSortFields(SSortFileItem::ByBitrate);
+ sortBy = SortByBitrate;
break;
case SORT_METHOD_DRIVE_TYPE:
- FillSortFields(SSortFileItem::ByDriveType);
+ sortBy = SortByDriveType;
break;
case SORT_METHOD_TRACKNUM:
- FillSortFields(SSortFileItem::BySongTrackNum);
+ sortBy = SortByTrackNumber;
break;
case SORT_METHOD_EPISODE:
- FillSortFields(SSortFileItem::ByEpisodeNum);
+ sortBy = SortByEpisodeNumber;
break;
case SORT_METHOD_DURATION:
- FillSortFields(SSortFileItem::BySongDuration);
- break;
- case SORT_METHOD_TITLE_IGNORE_THE:
- FillSortFields(SSortFileItem::BySongTitleNoThe);
+ case SORT_METHOD_VIDEO_RUNTIME:
+ sortBy = SortByTime;
break;
case SORT_METHOD_TITLE:
- FillSortFields(SSortFileItem::BySongTitle);
+ case SORT_METHOD_TITLE_IGNORE_THE:
+ case SORT_METHOD_VIDEO_TITLE:
+ sortBy = SortByTitle;
break;
case SORT_METHOD_ARTIST:
- FillSortFields(SSortFileItem::BySongArtist);
- break;
case SORT_METHOD_ARTIST_IGNORE_THE:
- FillSortFields(SSortFileItem::BySongArtistNoThe);
+ sortBy = SortByArtist;
break;
case SORT_METHOD_ALBUM:
- FillSortFields(SSortFileItem::BySongAlbum);
- break;
case SORT_METHOD_ALBUM_IGNORE_THE:
- FillSortFields(SSortFileItem::BySongAlbumNoThe);
+ sortBy = SortByAlbum;
break;
case SORT_METHOD_GENRE:
- FillSortFields(SSortFileItem::ByGenre);
+ sortBy = SortByGenre;
break;
case SORT_METHOD_COUNTRY:
- FillSortFields(SSortFileItem::ByCountry);
+ sortBy = SortByCountry;
break;
case SORT_METHOD_DATEADDED:
- FillSortFields(SSortFileItem::ByDateAdded);
+ sortBy = SortByDateAdded;
break;
case SORT_METHOD_FILE:
- FillSortFields(SSortFileItem::ByFile);
+ sortBy = SortByFile;
break;
+ case SORT_METHOD_SONG_RATING:
case SORT_METHOD_VIDEO_RATING:
- FillSortFields(SSortFileItem::ByMovieRating);
- break;
- case SORT_METHOD_VIDEO_TITLE:
- FillSortFields(SSortFileItem::ByMovieTitle);
+ sortBy = SortByRating;
break;
case SORT_METHOD_VIDEO_SORT_TITLE:
- FillSortFields(SSortFileItem::ByMovieSortTitle);
- break;
case SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE:
- FillSortFields(SSortFileItem::ByMovieSortTitleNoThe);
+ sortBy = SortBySortTitle;
break;
case SORT_METHOD_YEAR:
- FillSortFields(SSortFileItem::ByYear);
+ sortBy = SortByYear;
break;
case SORT_METHOD_PRODUCTIONCODE:
- FillSortFields(SSortFileItem::ByProductionCode);
+ sortBy = SortByProductionCode;
break;
case SORT_METHOD_PROGRAM_COUNT:
- case SORT_METHOD_PLAYLIST_ORDER:
- // TODO: Playlist order is hacked into program count variable (not nice, but ok until 2.0)
- FillSortFields(SSortFileItem::ByProgramCount);
+ sortBy = SortByProgramCount;
break;
- case SORT_METHOD_SONG_RATING:
- FillSortFields(SSortFileItem::BySongRating);
+ case SORT_METHOD_PLAYLIST_ORDER:
+ sortBy = SortByPlaylistOrder;
break;
case SORT_METHOD_MPAA_RATING:
- FillSortFields(SSortFileItem::ByMPAARating);
- break;
- case SORT_METHOD_VIDEO_RUNTIME:
- FillSortFields(SSortFileItem::ByMovieRuntime);
+ sortBy = SortByMPAA;
break;
case SORT_METHOD_STUDIO:
- FillSortFields(SSortFileItem::ByStudio);
- break;
case SORT_METHOD_STUDIO_IGNORE_THE:
- FillSortFields(SSortFileItem::ByStudioNoThe);
+ sortBy = SortByStudio;
break;
case SORT_METHOD_FULLPATH:
- FillSortFields(SSortFileItem::ByFullPath);
+ sortBy = SortByPath;
break;
case SORT_METHOD_LASTPLAYED:
- FillSortFields(SSortFileItem::ByLastPlayed);
+ sortBy = SortByLastPlayed;
break;
case SORT_METHOD_PLAYCOUNT:
- FillSortFields(SSortFileItem::ByPlayCount);
+ sortBy = SortByPlaycount;
break;
case SORT_METHOD_LISTENERS:
- FillSortFields(SSortFileItem::ByListeners);
+ sortBy = SortByListeners;
break;
default:
- break;
+ CLog::Log(LOGWARNING, "Unknown sort method %d", sortMethod);
+ return;
}
+
+ if (sortMethod == SORT_METHOD_LABEL_IGNORE_THE ||
+ sortMethod == SORT_METHOD_TITLE_IGNORE_THE ||
+ sortMethod == SORT_METHOD_ARTIST_IGNORE_THE ||
+ sortMethod == SORT_METHOD_ALBUM_IGNORE_THE ||
+ sortMethod == SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE ||
+ sortMethod == SORT_METHOD_STUDIO_IGNORE_THE)
+ sortAttributes = (SortAttribute)((int)sortAttributes | SortAttributeIgnoreArticle);
+
if (sortMethod == SORT_METHOD_FILE ||
sortMethod == SORT_METHOD_VIDEO_SORT_TITLE ||
sortMethod == SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE ||
@@ -1635,15 +1660,44 @@ void CFileItemList::Sort(SORT_METHOD sortMethod, SORT_ORDER sortOrder)
sortMethod == SORT_METHOD_DATEADDED ||
sortMethod == SORT_METHOD_VIDEO_RATING ||
sortMethod == SORT_METHOD_YEAR ||
+ sortMethod == SORT_METHOD_PLAYLIST_ORDER ||
sortMethod == SORT_METHOD_LASTPLAYED ||
sortMethod == SORT_METHOD_PLAYCOUNT ||
m_sortIgnoreFolders)
- Sort(sortOrder==SORT_ORDER_ASC ? SSortFileItem::IgnoreFoldersAscending : SSortFileItem::IgnoreFoldersDescending);
- else if (sortMethod != SORT_METHOD_NONE && sortMethod != SORT_METHOD_UNSORTED)
- Sort(sortOrder==SORT_ORDER_ASC ? SSortFileItem::Ascending : SSortFileItem::Descending);
+ sortAttributes = (SortAttribute)((int)sortAttributes | SortAttributeIgnoreFolders);
+
+ if (sortBy == SortByNone)
+ return;
+
+ SortItems sortItems((size_t)Size());
+ for (int index = 0; index < Size(); index++)
+ {
+ m_items[index]->ToSortable(sortItems[index]);
+ sortItems[index][FieldId] = index;
+ }
+
+ // do the sorting
+ SortUtils::Sort(sortBy, sortOrder, sortAttributes, sortItems);
+
+ // apply the new order to the existing CFileItems
+ VECFILEITEMS sortedFileItems;
+ sortedFileItems.reserve(Size());
+ for (SortItems::const_iterator it = sortItems.begin(); it != sortItems.end(); it++)
+ {
+ CFileItemPtr item = m_items[(int)it->at(FieldId).asInteger()];
+ // Set the sort label in the CFileItem
+ CStdString sortLabel;
+ g_charsetConverter.wToUTF8(it->at(FieldSort).asWideString(), sortLabel);
+ item->SetSortLabel(sortLabel);
+
+ sortedFileItems.push_back(item);
+ }
+
+ // replace the current list with the re-ordered one
+ m_items.assign(sortedFileItems.begin(), sortedFileItems.end());
- m_sortMethod=sortMethod;
- m_sortOrder=sortOrder;
+ m_sortMethod = sortMethod;
+ m_sortOrder = sortOrder;
}
void CFileItemList::Randomize()
@@ -1728,7 +1782,7 @@ void CFileItemList::Archive(CArchive& ar)
ar >> (int&)tempint;
m_sortMethod = SORT_METHOD(tempint);
ar >> (int&)tempint;
- m_sortOrder = SORT_ORDER(tempint);
+ m_sortOrder = SortOrder(tempint);
ar >> m_sortIgnoreFolders;
ar >> (int&)tempint;
m_cacheToDisc = CACHE_TYPE(tempint);
@@ -1998,7 +2052,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, SORT_ORDER_ASC);
+ Sort(SORT_METHOD_LABEL, SortOrderAscending);
StackFolders();
@@ -2990,8 +3044,8 @@ void CFileItemList::SetReplaceListing(bool replace)
void CFileItemList::ClearSortState()
{
- m_sortMethod=SORT_METHOD_NONE;
- m_sortOrder=SORT_ORDER_NONE;
+ m_sortMethod = SORT_METHOD_NONE;
+ m_sortOrder = SortOrderNone;
}
CVideoInfoTag* CFileItem::GetVideoInfoTag()
View
18 xbmc/FileItem.h
@@ -28,6 +28,7 @@
#include "guilib/GUIListItem.h"
#include "utils/Archive.h"
#include "utils/ISerializable.h"
+#include "utils/ISortable.h"
#include "XBDateTime.h"
#include "SortFileItem.h"
#include "utils/LabelFormatter.h"
@@ -61,7 +62,7 @@ class CMediaSource;
\sa CFileItemList
*/
class CFileItem :
- public CGUIListItem, public IArchivable, public ISerializable
+ public CGUIListItem, public IArchivable, public ISerializable, public ISortable
{
public:
CFileItem(void);
@@ -86,6 +87,7 @@ class CFileItem :
const CFileItem& operator=(const CFileItem& item);
virtual void Archive(CArchive& ar);
virtual void Serialize(CVariant& value);
+ virtual void ToSortable(SortItem &sortable);
virtual bool IsFileItem() const { return true; };
bool Exists(bool bUseCache = true) const;
@@ -158,9 +160,9 @@ class CFileItem :
int GetVideoContentType() const; /* return VIDEODB_CONTENT_TYPE, but don't want to include videodb in this header */
bool IsLabelPreformated() const { return m_bLabelPreformated; }
void SetLabelPreformated(bool bYesNo) { m_bLabelPreformated=bYesNo; }
- bool SortsOnTop() const { return m_specialSort == SORT_ON_TOP; }
- bool SortsOnBottom() const { return m_specialSort == SORT_ON_BOTTOM; }
- void SetSpecialSort(SPECIAL_SORT sort) { m_specialSort = sort; }
+ bool SortsOnTop() const { return m_specialSort == SortSpecialOnTop; }
+ bool SortsOnBottom() const { return m_specialSort == SortSpecialOnBottom; }
+ void SetSpecialSort(SortSpecial sort) { m_specialSort = sort; }
inline bool HasMusicInfoTag() const
{
@@ -317,7 +319,7 @@ class CFileItem :
private:
CStdString m_strPath; ///< complete path to item
- SPECIAL_SORT m_specialSort;
+ SortSpecial m_specialSort;
bool m_bIsParentFolder;
bool m_bCanQueue;
bool m_bLabelPreformated;
@@ -401,7 +403,7 @@ class CFileItemList : public CFileItem
void Assign(const CFileItemList& itemlist, bool append = false);
bool Copy (const CFileItemList& item);
void Reserve(int iCount);
- void Sort(SORT_METHOD sortMethod, SORT_ORDER sortOrder);
+ void Sort(SORT_METHOD sortMethod, SortOrder sortOrder);
void Randomize();
void SetMusicThumbs();
void FillInDefaultIcons();
@@ -422,7 +424,7 @@ class CFileItemList : public CFileItem
*/
void Stack(bool stackFiles = true);
- SORT_ORDER GetSortOrder() const { return m_sortOrder; }
+ SortOrder GetSortOrder() const { return m_sortOrder; }
SORT_METHOD GetSortMethod() const { return m_sortMethod; }
/*! \brief load a CFileItemList out of the cache
@@ -510,7 +512,7 @@ class CFileItemList : public CFileItem
MAPFILEITEMS m_map;
bool m_fastLookup;
SORT_METHOD m_sortMethod;
- SORT_ORDER m_sortOrder;
+ SortOrder m_sortOrder;
bool m_sortIgnoreFolders;
CACHE_TYPE m_cacheToDisc;
bool m_replaceListing;
View
6 xbmc/GUIInfoManager.cpp
@@ -880,11 +880,11 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition)
}
if (prop.name == "sortdirection")
{
- SORT_ORDER order = SORT_ORDER_NONE;
+ SortOrder order = SortOrderNone;
if (prop.param().Equals("ascending"))
- order = SORT_ORDER_ASC;
+ order = SortOrderAscending;
else if (prop.param().Equals("descending"))
- order = SORT_ORDER_DESC;
+ order = SortOrderDescending;
return AddMultiInfo(GUIInfo(CONTAINER_SORT_DIRECTION, order));
}
else if (prop.name == "sort")
View
30 xbmc/GUIViewState.cpp
@@ -141,14 +141,14 @@ CGUIViewState::CGUIViewState(const CFileItemList& items) : m_items(items)
m_currentViewAsControl=0;
m_currentSortMethod=0;
m_playlist = PLAYLIST_NONE;
- m_sortOrder=SORT_ORDER_ASC;
+ m_sortOrder = SortOrderAscending;
}
CGUIViewState::~CGUIViewState()
{
}
-SORT_ORDER CGUIViewState::GetDisplaySortOrder() const
+SortOrder CGUIViewState::GetDisplaySortOrder() const
{
// we actually treat some sort orders in reverse, so that we can have
// the one sort order variable to save but it can be ascending usually,
@@ -159,18 +159,18 @@ SORT_ORDER CGUIViewState::GetDisplaySortOrder() const
sortMethod == SORT_METHOD_VIDEO_RATING || sortMethod == SORT_METHOD_PROGRAM_COUNT ||
sortMethod == SORT_METHOD_SONG_RATING || sortMethod == SORT_METHOD_BITRATE || sortMethod == SORT_METHOD_LISTENERS)
{
- if (m_sortOrder == SORT_ORDER_ASC) return SORT_ORDER_DESC;
- if (m_sortOrder == SORT_ORDER_DESC) return SORT_ORDER_ASC;
+ if (m_sortOrder == SortOrderAscending) return SortOrderDescending;
+ if (m_sortOrder == SortOrderDescending) return SortOrderAscending;
}
return m_sortOrder;
}
-SORT_ORDER CGUIViewState::SetNextSortOrder()
+SortOrder CGUIViewState::SetNextSortOrder()
{
- if (m_sortOrder==SORT_ORDER_ASC)
- SetSortOrder(SORT_ORDER_DESC);
+ if (m_sortOrder == SortOrderAscending)
+ SetSortOrder(SortOrderDescending);
else
- SetSortOrder(SORT_ORDER_ASC);
+ SetSortOrder(SortOrderAscending);
SaveViewState();
@@ -396,15 +396,15 @@ CGUIViewStateGeneral::CGUIViewStateGeneral(const CFileItemList& items) : CGUIVie
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_ASC);
+ SetSortOrder(SortOrderAscending);
}
-void CGUIViewState::SetSortOrder(SORT_ORDER sortOrder)
+void CGUIViewState::SetSortOrder(SortOrder sortOrder)
{
if (GetSortMethod() == SORT_METHOD_NONE)
- m_sortOrder = SORT_ORDER_NONE;
- else if (sortOrder == SORT_ORDER_NONE)
- m_sortOrder = SORT_ORDER_ASC;
+ m_sortOrder = SortOrderNone;
+ else if (sortOrder == SortOrderNone)
+ m_sortOrder = SortOrderAscending;
else
m_sortOrder = sortOrder;
}
@@ -454,7 +454,7 @@ CGUIViewStateFromItems::CGUIViewStateFromItems(const CFileItemList &items) : CGU
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_ASC);
+ SetSortOrder(SortOrderAscending);
if (items.IsPlugin())
{
CURL url(items.GetPath());
@@ -480,7 +480,7 @@ CGUIViewStateLibrary::CGUIViewStateLibrary(const CFileItemList &items) : CGUIVie
{
AddSortMethod(SORT_METHOD_NONE, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, Size | Foldername, empty
SetSortMethod(SORT_METHOD_NONE);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
SetViewAsControl(DEFAULT_VIEW_LIST);
View
10 xbmc/GUIViewState.h
@@ -46,9 +46,9 @@ class CGUIViewState
void GetSortMethodLabelMasks(LABEL_MASKS& masks) const;
void GetSortMethods(std::vector< std::pair<int,int> > &sortMethods) const;
- SORT_ORDER SetNextSortOrder();
- SORT_ORDER GetSortOrder() const { return m_sortOrder; };
- SORT_ORDER GetDisplaySortOrder() const;
+ SortOrder SetNextSortOrder();
+ SortOrder GetSortOrder() const { return m_sortOrder; };
+ SortOrder GetDisplaySortOrder() const;
virtual bool HideExtensions();
virtual bool HideParentDirItems();
virtual bool DisableAddSourceButtons();
@@ -77,7 +77,7 @@ class CGUIViewState
void AddSortMethod(SORT_METHOD sortMethod, int buttonLabel, LABEL_MASKS labelmasks);
void SetSortMethod(SORT_METHOD sortMethod);
- void SetSortOrder(SORT_ORDER sortOrder);
+ void SetSortOrder(SortOrder sortOrder);
const CFileItemList& m_items;
static VECSOURCES m_sources;
@@ -88,7 +88,7 @@ class CGUIViewState
std::vector<SORT_METHOD_DETAILS> m_sortMethods;
int m_currentSortMethod;
- SORT_ORDER m_sortOrder;
+ SortOrder m_sortOrder;
static CStdString m_strPlaylistDirectory;
};
View
1  xbmc/Makefile.in
@@ -19,7 +19,6 @@ SRCS=Application.cpp \
PlayListPlayer.cpp \
PartyModeManager.cpp \
SectionLoader.cpp \
- SortFileItem.cpp \
SystemGlobals.cpp \
Temperature.cpp \
TextureCache.cpp \
View
500 xbmc/SortFileItem.cpp
@@ -1,500 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "SortFileItem.h"
-#include "settings/AdvancedSettings.h"
-#include "utils/StringUtils.h"
-#include "music/tags/MusicInfoTag.h"
-#include "FileItem.h"
-#include "URL.h"
-#include "utils/log.h"
-#include "video/VideoInfoTag.h"
-
-#define RETURN_IF_NULL(x,y) if ((x) == NULL) { CLog::Log(LOGWARNING, "%s, sort item is null", __FUNCTION__); return y; }
-
-CStdString SSortFileItem::RemoveArticles(const CStdString &label)
-{
- for (unsigned int i=0;i<g_advancedSettings.m_vecTokens.size();++i)
- {
- if (g_advancedSettings.m_vecTokens[i].size() < label.size() &&
- strnicmp(g_advancedSettings.m_vecTokens[i].c_str(), label.c_str(), g_advancedSettings.m_vecTokens[i].size()) == 0)
- return label.Mid(g_advancedSettings.m_vecTokens[i].size());
- }
- return label;
-}
-
-bool SSortFileItem::Ascending(const CFileItemPtr &left, const CFileItemPtr &right)
-{
- // sanity
- RETURN_IF_NULL(left,false); RETURN_IF_NULL(right,false);
-
- // ignore items that should sort on top or bottom
- if (left->SortsOnTop() != right->SortsOnTop())
- return left->SortsOnTop();
- if (left->SortsOnBottom() != right->SortsOnBottom())
- return !left->SortsOnBottom();
- if (left->SortsOnTop() || left->SortsOnBottom())
- return false; // both have either sort on top or sort on bottom -> leave as-is
- if (left->m_bIsFolder == right->m_bIsFolder)
- return StringUtils::AlphaNumericCompare(left->GetSortLabel().c_str(),right->GetSortLabel().c_str()) < 0;
- return left->m_bIsFolder;
-}
-
-bool SSortFileItem::Descending(const CFileItemPtr &left, const CFileItemPtr &right)
-{
- // sanity
- RETURN_IF_NULL(left,false); RETURN_IF_NULL(right,false);
-
- // ignore items that should sort on top or bottom
- if (left->SortsOnTop() != right->SortsOnTop())
- return left->SortsOnTop();
- if (left->SortsOnBottom() != right->SortsOnBottom())
- return !left->SortsOnBottom();
- if (left->SortsOnTop() || left->SortsOnBottom())
- return false; // both have either sort on top or sort on bottom -> leave as-is
- if (left->m_bIsFolder == right->m_bIsFolder)
- return StringUtils::AlphaNumericCompare(left->GetSortLabel().c_str(),right->GetSortLabel().c_str()) > 0;
- return left->m_bIsFolder;
-}
-
-bool SSortFileItem::IgnoreFoldersAscending(const CFileItemPtr &left, const CFileItemPtr &right)
-{
- // sanity
- RETURN_IF_NULL(left,false); RETURN_IF_NULL(right,false);
-
- // ignore items that should sort on top or bottom
- if (left->SortsOnTop() != right->SortsOnTop())
- return left->SortsOnTop();
- if (left->SortsOnBottom() != right->SortsOnBottom())
- return !left->SortsOnBottom();
- if (left->SortsOnTop() || left->SortsOnBottom())
- return false; // both have either sort on top or sort on bottom -> leave as-is
- return StringUtils::AlphaNumericCompare(left->GetSortLabel().c_str(),right->GetSortLabel().c_str()) < 0;
-}
-
-bool SSortFileItem::IgnoreFoldersDescending(const CFileItemPtr &left, const CFileItemPtr &right)
-{
- // sanity
- RETURN_IF_NULL(left,false); RETURN_IF_NULL(right,false);
-
- // ignore items that should sort on top or bottom
- if (left->SortsOnTop() != right->SortsOnTop())
- return left->SortsOnTop();
- if (left->SortsOnBottom() != right->SortsOnBottom())
- return !left->SortsOnBottom();
- if (left->SortsOnTop() || left->SortsOnBottom())
- return false; // both have either sort on top or sort on bottom -> leave as-is
- return StringUtils::AlphaNumericCompare(left->GetSortLabel().c_str(),right->GetSortLabel().c_str()) > 0;
-}
-
-void SSortFileItem::ByLabel(CFileItemPtr &item)
-{
- if (!item) return;
- item->SetSortLabel(item->GetLabel());
-}
-
-void SSortFileItem::ByLabelNoThe(CFileItemPtr &item)
-{
- if (!item) return;
- item->SetSortLabel(RemoveArticles(item->GetLabel()));
-}
-
-void SSortFileItem::ByFile(CFileItemPtr &item)
-{
- if (!item) return;
-
- CURL url(item->GetPath());
- CStdString label;
- label.Format("%s %d", url.GetFileNameWithoutPath().c_str(), item->m_lStartOffset);
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::ByFullPath(CFileItemPtr &item)
-{
- if (!item) return;
-
- CStdString label;
- label.Format("%s %d", item->GetPath(), item->m_lStartOffset);
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::ByLastPlayed(CFileItemPtr &item)
-{
- if (!item) return;
-
- if (item->HasVideoInfoTag())
- item->SetSortLabel(item->GetVideoInfoTag()->m_lastPlayed.GetAsDBDateTime());
- else if (item->HasMusicInfoTag()) // TODO: No last played info in the fileitem for music
- item->SetSortLabel(item->GetMusicInfoTag()->GetTitle());
- else
- item->SetSortLabel(item->GetLabel());
-}
-
-void SSortFileItem::ByPlayCount(CFileItemPtr &item)
-{
- if (!item) return;
-
- CStdString label;
- if (item->HasVideoInfoTag())
- label.Format("%i %s", item->GetVideoInfoTag()->m_playCount, item->GetLabel().c_str());
- if (item->HasMusicInfoTag())
- label.Format("%i %s", item->GetMusicInfoTag()->GetPlayCount(), item->GetLabel().c_str());
-
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::ByDate(CFileItemPtr &item)
-{
- if (!item) return;
-
- CStdString label;
- label.Format("%s %s", item->m_dateTime.GetAsDBDateTime().c_str(), item->GetLabel().c_str());
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::ByDateAdded(CFileItemPtr &item)
-{
- if (!item) return;
-
- CStdString label;
- label.Format("%s %d", item->GetVideoInfoTag()->m_dateAdded.GetAsDBDateTime().c_str(), item->GetVideoInfoTag()->m_iFileId);
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::BySize(CFileItemPtr &item)
-{
- if (!item) return;
-
- CStdString label;
- label.Format("%"PRId64, item->m_dwSize);
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::ByDriveType(CFileItemPtr &item)
-{
- if (!item) return;
-
- CStdString label;
- label.Format("%d %s", item->m_iDriveType, item->GetLabel().c_str());
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::BySongTitle(CFileItemPtr &item)
-{
- if (!item) return;
- item->SetSortLabel(item->GetMusicInfoTag()->GetTitle());
-}
-
-void SSortFileItem::BySongTitleNoThe(CFileItemPtr &item)
-{
- if (!item) return;
- item->SetSortLabel(RemoveArticles(item->GetMusicInfoTag()->GetTitle()));
-}
-
-void SSortFileItem::BySongAlbum(CFileItemPtr &item)
-{
- if (!item) return;
-
- CStdString label;
- if (item->HasMusicInfoTag())
- label = item->GetMusicInfoTag()->GetAlbum();
- else if (item->HasVideoInfoTag())
- label = item->GetVideoInfoTag()->m_strAlbum;
-
- CStdString artist;
- if (item->HasMusicInfoTag())
- artist = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
- else if (item->HasVideoInfoTag())
- artist = StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator);
- label += " " + artist;
-
- if (item->HasMusicInfoTag())
- label.AppendFormat(" %i", item->GetMusicInfoTag()->GetTrackAndDiskNumber());
-
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::BySongAlbumNoThe(CFileItemPtr &item)
-{
- if (!item) return;
- CStdString label;
- if (item->HasMusicInfoTag())
- label = item->GetMusicInfoTag()->GetAlbum();
- else if (item->HasVideoInfoTag())
- label = item->GetVideoInfoTag()->m_strAlbum;
- label = RemoveArticles(label);
-
- CStdString artist;
- if (item->HasMusicInfoTag())
- artist = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
- else if (item->HasVideoInfoTag())
- artist = StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator);
- label += " " + RemoveArticles(artist);
-
- if (item->HasMusicInfoTag())
- label.AppendFormat(" %i", item->GetMusicInfoTag()->GetTrackAndDiskNumber());
-
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::BySongArtist(CFileItemPtr &item)
-{
- if (!item) return;
-
- CStdString label;
- if (item->HasMusicInfoTag())
- label = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
- else if (item->HasVideoInfoTag())
- label = StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator);
-
- if (g_advancedSettings.m_bMusicLibraryAlbumsSortByArtistThenYear)
- {
- int year = 0;
- if (item->HasMusicInfoTag())
- year = item->GetMusicInfoTag()->GetYear();
- else if (item->HasVideoInfoTag())
- year = item->GetVideoInfoTag()->m_iYear;
- label.AppendFormat(" %i", year);
- }
-
- CStdString album;
- if (item->HasMusicInfoTag())
- album = item->GetMusicInfoTag()->GetAlbum();
- else if (item->HasVideoInfoTag())
- album = item->GetVideoInfoTag()->m_strAlbum;
- label += " " + album;
-
- if (item->HasMusicInfoTag())
- label.AppendFormat(" %i", item->GetMusicInfoTag()->GetTrackAndDiskNumber());
-
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::BySongArtistNoThe(CFileItemPtr &item)
-{
- if (!item) return;
-
- CStdString label;
- if (item->HasMusicInfoTag())
- label = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
- else if (item->HasVideoInfoTag())
- label = StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator);
- label = RemoveArticles(label);
-
- if (g_advancedSettings.m_bMusicLibraryAlbumsSortByArtistThenYear)
- {
- int year = 0;
- if (item->HasMusicInfoTag())
- year = item->GetMusicInfoTag()->GetYear();
- else if (item->HasVideoInfoTag())
- year = item->GetVideoInfoTag()->m_iYear;
- label.AppendFormat(" %i", year);
- }
-
- CStdString album;
- if (item->HasMusicInfoTag())
- album = item->GetMusicInfoTag()->GetAlbum();
- else if (item->HasVideoInfoTag())
- album = item->GetVideoInfoTag()->m_strAlbum;
- label += " " + RemoveArticles(album);
-
- if (item->HasMusicInfoTag())
- label.AppendFormat(" %i", item->GetMusicInfoTag()->GetTrackAndDiskNumber());
-
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::BySongTrackNum(CFileItemPtr &item)
-{
- if (!item) return;
- CStdString label;
- if (item->HasMusicInfoTag())
- label.Format("%i", item->GetMusicInfoTag()->GetTrackAndDiskNumber());
- if (item->HasVideoInfoTag())
- label.Format("%i", item->GetVideoInfoTag()->m_iTrack);
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::BySongDuration(CFileItemPtr &item)
-{
- if (!item) return;
- CStdString label;
- label.Format("%i", item->GetMusicInfoTag()->GetDuration());
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::BySongRating(CFileItemPtr &item)
-{
- if (!item) return;
- CStdString label;
- label.Format("%c %s", item->GetMusicInfoTag()->GetRating(), item->GetMusicInfoTag()->GetTitle().c_str());
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::ByProgramCount(CFileItemPtr &item)
-{
- if (!item) return;
- CStdString label;
- label.Format("%i", item->m_iprogramCount);
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::ByGenre(CFileItemPtr &item)
-{
- if (!item) return;
-
- if (item->HasMusicInfoTag())
- item->SetSortLabel(StringUtils::Join(item->GetMusicInfoTag()->GetGenre(), g_advancedSettings.m_musicItemSeparator));
- else
- item->SetSortLabel(StringUtils::Join(item->GetVideoInfoTag()->m_genre, g_advancedSettings.m_videoItemSeparator));
-}
-
-void SSortFileItem::ByCountry(CFileItemPtr &item)
-{
- if (!item) return;
- item->SetSortLabel(StringUtils::Join(item->GetVideoInfoTag()->m_country, g_advancedSettings.m_videoItemSeparator));
-}
-
-
-void SSortFileItem::ByYear(CFileItemPtr &item)
-{
- if (!item) return;
-
- CStdString label;
- if (item->HasMusicInfoTag())
- label.Format("%i %s", item->GetMusicInfoTag()->GetYear(), item->GetLabel().c_str());
- else
- label.Format("%s %s %i %s", item->GetVideoInfoTag()->m_premiered.GetAsDBDate().c_str(), item->GetVideoInfoTag()->m_firstAired.GetAsDBDate(), item->GetVideoInfoTag()->m_iYear, item->GetLabel().c_str());
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::ByMovieTitle(CFileItemPtr &item)
-{
- if (!item) return;
- item->SetSortLabel(item->GetVideoInfoTag()->m_strTitle);
-}
-
-void SSortFileItem::ByMovieSortTitle(CFileItemPtr &item)
-{
- if (!item) return;
- if (!item->GetVideoInfoTag()->m_strSortTitle.IsEmpty())
- item->SetSortLabel(item->GetVideoInfoTag()->m_strSortTitle);
- else
- item->SetSortLabel(item->GetVideoInfoTag()->m_strTitle);
-}
-
-void SSortFileItem::ByMovieSortTitleNoThe(CFileItemPtr &item)
-{
- if (!item) return;
- CStdString label;
- if (!item->GetVideoInfoTag()->m_strSortTitle.IsEmpty())
- label = item->GetVideoInfoTag()->m_strSortTitle;
- else
- label = item->GetVideoInfoTag()->m_strTitle;
- item->SetSortLabel(RemoveArticles(label));
-}
-
-void SSortFileItem::ByMovieRating(CFileItemPtr &item)
-{
- if (!item) return;
- CStdString label;
- label.Format("%f %s", item->GetVideoInfoTag()->m_fRating, item->GetLabel().c_str());
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::ByMovieRuntime(CFileItemPtr &item)
-{
- if (!item) return;
- CStdString label;
- if (item->GetVideoInfoTag()->m_streamDetails.GetVideoDuration() > 0)
- label.Format("%i %s", item->GetVideoInfoTag()->m_streamDetails.GetVideoDuration(), item->GetLabel().c_str());
- else
- label.Format("%s %s", item->GetVideoInfoTag()->m_strRuntime, item->GetLabel().c_str());
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::ByMPAARating(CFileItemPtr &item)
-{
- if (!item) return;
- item->SetSortLabel(item->GetVideoInfoTag()->m_strMPAARating + " " + item->GetLabel());
-}
-
-void SSortFileItem::ByStudio(CFileItemPtr &item)
-{
- if (!item) return;
- item->SetSortLabel(StringUtils::Join(item->GetVideoInfoTag()->m_studio, g_advancedSettings.m_videoItemSeparator));
-}
-
-void SSortFileItem::ByStudioNoThe(CFileItemPtr &item)
-{
- if (!item) return;
- CStdString studio = StringUtils::Join(item->GetVideoInfoTag()->m_studio, g_advancedSettings.m_videoItemSeparator);
- item->SetSortLabel(RemoveArticles(studio));
-}
-
-void SSortFileItem::ByEpisodeNum(CFileItemPtr &item)
-{
- if (!item) return;
-
- const CVideoInfoTag *tag = item->GetVideoInfoTag();
-
- // we calculate an offset number based on the episode's
- // sort season and episode values. in addition
- // we include specials 'episode' numbers to get proper
- // sorting of multiple specials in a row. each
- // of these are given their particular ranges to semi-ensure uniqueness.
- // theoretical problem: if a show has > 2^15 specials and two of these are placed
- // after each other they will sort backwards. if a show has > 2^32-1 seasons
- // or if a season has > 2^16-1 episodes strange things will happen (overflow)
- uint64_t num;
- if (tag->m_iSpecialSortEpisode > 0)
- num = ((uint64_t)tag->m_iSpecialSortSeason<<32)+(tag->m_iSpecialSortEpisode<<16)-((2<<15) - tag->m_iEpisode);
- else
- num = ((uint64_t)tag->m_iSeason<<32)+(tag->m_iEpisode<<16);
-
- // check filename as there can be duplicates now
- CURL file(tag->m_strFileNameAndPath);
- CStdString label;
- label.Format("%"PRIu64" %s", num, file.GetFileName().c_str());
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::ByProductionCode(CFileItemPtr &item)
-{
- if (!item) return;
- item->SetSortLabel(item->GetVideoInfoTag()->m_strProductionCode);
-}
-
-void SSortFileItem::ByBitrate(CFileItemPtr &item)
-{
- if (!item) return;
- CStdString label;
- label.Format("%"PRId64, item->m_dwSize);
- item->SetSortLabel(label);
-}
-
-void SSortFileItem::ByListeners(CFileItemPtr &item)
-{
- if (!item) return;
- CStdString label;
- label.Format("%i", item->GetMusicInfoTag()->GetListeners());
- item->SetSortLabel(label);
-}
View
72 xbmc/SortFileItem.h
@@ -21,65 +21,7 @@
*/
#include "utils/LabelFormatter.h"
-#include <boost/shared_ptr.hpp>
-
-class CFileItem; typedef boost::shared_ptr<CFileItem> CFileItemPtr;
-
-struct SSortFileItem
-{
- /*! \brief Remove any articles (eg "the", "a") from the start of a label
- \param label the label to process
- \return the label stripped of any articles
- */
- static CStdString RemoveArticles(const CStdString &label);
-
- // Sort by sort field
- static bool Ascending(const CFileItemPtr &left, const CFileItemPtr &right);
- static bool Descending(const CFileItemPtr &left, const CFileItemPtr &right);
- static bool IgnoreFoldersAscending(const CFileItemPtr &left, const CFileItemPtr &right);
- static bool IgnoreFoldersDescending(const CFileItemPtr &left, const CFileItemPtr &right);
-
- // Fill in sort field
- static void ByLabel(CFileItemPtr &item);
- static void ByLabelNoThe(CFileItemPtr &item);
- static void ByFile(CFileItemPtr &item);
- static void ByFullPath(CFileItemPtr &item);
- static void ByDate(CFileItemPtr &item);
- static void ByDateAdded(CFileItemPtr &item);
- static void BySize(CFileItemPtr &item);
- static void ByDriveType(CFileItemPtr &item);
- static void BySongTitle(CFileItemPtr &item);
- static void BySongTitleNoThe(CFileItemPtr &item);
- static void BySongAlbum(CFileItemPtr &item);
- static void BySongAlbumNoThe(CFileItemPtr &item);
- static void BySongArtist(CFileItemPtr &item);
- static void BySongArtistNoThe(CFileItemPtr &item);
- static void BySongTrackNum(CFileItemPtr &item);
- static void BySongDuration(CFileItemPtr &item);
- static void BySongRating(CFileItemPtr &item);
-
- static void ByProgramCount(CFileItemPtr &item);
-
- static void ByGenre(CFileItemPtr &item);
- static void ByCountry(CFileItemPtr &item);
- static void ByYear(CFileItemPtr &item);
-
- static void ByMovieTitle(CFileItemPtr &item);
- static void ByMovieSortTitle(CFileItemPtr &item);
- static void ByMovieSortTitleNoThe(CFileItemPtr &item);
- static void ByMovieRating(CFileItemPtr &item);
- static void ByMovieRuntime(CFileItemPtr &item);
- static void ByMPAARating(CFileItemPtr &item);
- static void ByStudio(CFileItemPtr &item);
- static void ByStudioNoThe(CFileItemPtr &item);
-
- static void ByEpisodeNum(CFileItemPtr &item);
- static void ByProductionCode(CFileItemPtr &item);
- static void ByLastPlayed(CFileItemPtr &item);
- static void ByPlayCount(CFileItemPtr &item);
- static void ByBitrate(CFileItemPtr &item);
- static void ByListeners(CFileItemPtr &item);
-};
+#include "utils/SortUtils.h"
typedef enum {
SORT_METHOD_NONE=0,
@@ -124,18 +66,6 @@ typedef enum {
SORT_METHOD_MAX
} SORT_METHOD;
-typedef enum {
- SORT_ORDER_NONE=0,
- SORT_ORDER_ASC,
- SORT_ORDER_DESC
-} SORT_ORDER;
-
-typedef enum {
- SORT_NORMALLY=0,
- SORT_ON_TOP,
- SORT_ON_BOTTOM
-} SPECIAL_SORT;
-
typedef struct
{
SORT_METHOD m_sortMethod;
View
2  xbmc/ViewDatabase.cpp
@@ -99,7 +99,7 @@ bool CViewDatabase::GetViewState(const CStdString &path, int window, CViewState
{ // 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 = (SORT_ORDER)m_pDS->fv("sortOrder").get_asInt();
+ state.m_sortOrder = (SortOrder)m_pDS->fv("sortOrder").get_asInt();
m_pDS->close();
return true;
}
View
6 xbmc/ViewState.h
@@ -33,7 +33,7 @@
class CViewState
{
public:
- CViewState(int viewMode, SORT_METHOD sortMethod, SORT_ORDER sortOrder)
+ CViewState(int viewMode, SORT_METHOD sortMethod, SortOrder sortOrder)
{
m_viewMode = viewMode;
m_sortMethod = sortMethod;
@@ -43,10 +43,10 @@ class CViewState
{
m_viewMode = 0;
m_sortMethod = SORT_METHOD_LABEL;
- m_sortOrder = SORT_ORDER_ASC;
+ m_sortOrder = SortOrderAscending;
};
int m_viewMode;
SORT_METHOD m_sortMethod;
- SORT_ORDER m_sortOrder;
+ SortOrder m_sortOrder;
};
View
2  xbmc/addons/GUIDialogAddonInfo.cpp
@@ -378,7 +378,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,SORT_ORDER_ASC);
+ items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
for (int i=0;i<items.Size();++i)
{
if (items[i]->m_bIsFolder)
View
2  xbmc/addons/GUIViewStateAddonBrowser.cpp
@@ -39,7 +39,7 @@ CGUIViewStateAddonBrowser::CGUIViewStateAddonBrowser(const CFileItemList& items)
SetViewAsControl(DEFAULT_VIEW_AUTO);
- SetSortOrder(SORT_ORDER_ASC);
+ SetSortOrder(SortOrderAscending);
LoadViewState(items.GetPath(), WINDOW_ADDON_BROWSER);
}
View
4 xbmc/addons/GUIWindowAddonBrowser.cpp
@@ -449,10 +449,10 @@ int CGUIWindowAddonBrowser::SelectAddonID(const vector<ADDON::TYPE> &types, CStd
item->SetLabel(g_localizeStrings.Get(231));
item->SetLabel2(g_localizeStrings.Get(24040));
item->SetIconImage("DefaultAddonNone.png");
- item->SetSpecialSort(SORT_ON_TOP);
+ item->SetSpecialSort(SortSpecialOnTop);
items.Add(item);
}
- items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);
+ items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
if (addonIDs.size() > 0)
{
View
2  xbmc/dialogs/GUIDialogFileBrowser.cpp
@@ -332,7 +332,7 @@ void CGUIDialogFileBrowser::ClearFileItems()
void CGUIDialogFileBrowser::OnSort()
{
if (!m_singleList)
- m_vecItems->Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);
+ m_vecItems->Sort(SORT_METHOD_LABEL, SortOrderAscending);
}
void CGUIDialogFileBrowser::Update(const CStdString &strDirectory)
View
2  xbmc/dialogs/GUIDialogSelect.cpp
@@ -213,7 +213,7 @@ bool CGUIDialogSelect::IsButtonPressed()
void CGUIDialogSelect::Sort(bool bSortOrder /*=true*/)
{
- m_vecList->Sort(SORT_METHOD_LABEL,bSortOrder?SORT_ORDER_ASC:SORT_ORDER_DESC);
+ m_vecList->Sort(SORT_METHOD_LABEL, bSortOrder ? SortOrderAscending : SortOrderDescending);
}
void CGUIDialogSelect::SetSelected(int iSelected)
View
14 xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp
@@ -236,7 +236,7 @@ void CGUIDialogSmartPlaylistEditor::OnOrder()
{
CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_ORDER_FIELD);
OnMessage(msg);
- m_playlist.m_orderField = (CSmartPlaylistRule::DATABASE_FIELD)msg.GetParam1();
+ m_playlist.m_orderField = (SortBy)msg.GetParam1();
UpdateButtons();
}
@@ -271,7 +271,7 @@ void CGUIDialogSmartPlaylistEditor::UpdateButtons()
for (unsigned int i = 0; i < m_playlist.m_playlistRules.size(); i++)
{
CFileItemPtr item(new CFileItem("", false));
- if (m_playlist.m_playlistRules[i].m_field == CSmartPlaylistRule::FIELD_NONE)
+ if (m_playlist.m_playlistRules[i].m_field == FieldNone)
item->SetLabel(g_localizeStrings.Get(21423));
else
item->SetLabel(m_playlist.m_playlistRules[i].GetLocalizedRule());
@@ -295,11 +295,11 @@ void CGUIDialogSmartPlaylistEditor::UpdateButtons()
CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_ORDER_FIELD);
OnMessage(msg);
}
- vector<CSmartPlaylistRule::DATABASE_FIELD> fields = CSmartPlaylistRule::GetFields(m_playlist.GetType(), true);
- for (unsigned int i = 0; i < fields.size(); i++)
+ vector<SortBy> orders = CSmartPlaylistRule::GetOrders(m_playlist.GetType());
+ for (unsigned int i = 0; i < orders.size(); i++)
{
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_ORDER_FIELD, fields[i]);
- msg.SetLabel(CSmartPlaylistRule::GetLocalizedField(fields[i]));
+ CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_ORDER_FIELD, orders[i]);
+ msg.SetLabel(CSmartPlaylistRule::GetLocalizedOrder(orders[i]));
OnMessage(msg);
}
{
@@ -451,7 +451,7 @@ void CGUIDialogSmartPlaylistEditor::OnRuleAdd()
CSmartPlaylistRule rule;
if (CGUIDialogSmartPlaylistRule::EditRule(rule,m_playlist.GetType()))
{
- if (m_playlist.m_playlistRules.size() == 1 && m_playlist.m_playlistRules[0].m_field == CSmartPlaylistRule::FIELD_NONE)
+ if (m_playlist.m_playlistRules.size() == 1 && m_playlist.m_playlistRules[0].m_field == FieldNone)
m_playlist.m_playlistRules[0] = rule;
else
m_playlist.m_playlistRules.push_back(rule);
View
34 xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp
@@ -106,7 +106,7 @@ void CGUIDialogSmartPlaylistRule::OnBrowse()
type = VIDEODB_CONTENT_EPISODES;
int iLabel = 0;
- if (m_rule.m_field == CSmartPlaylistRule::FIELD_GENRE)
+ if (m_rule.m_field == FieldGenre)
{
if (m_type.Equals("tvshows") || m_type.Equals("episodes") || m_type.Equals("movies"))
videodatabase.GetGenresNav("videodb://2/1/",items,type);
@@ -120,15 +120,15 @@ void CGUIDialogSmartPlaylistRule::OnBrowse()
}
iLabel = 515;
}
- else if (m_rule.m_field == CSmartPlaylistRule::FIELD_COUNTRY)
+ else if (m_rule.m_field == FieldCountry)
{
videodatabase.GetCountriesNav("videodb://2/1/",items,type);
iLabel = 574;
}
- else if (m_rule.m_field == CSmartPlaylistRule::FIELD_ARTIST || m_rule.m_field == CSmartPlaylistRule::FIELD_ALBUMARTIST)
+ else if (m_rule.m_field == FieldArtist || m_rule.m_field == FieldAlbumArtist)
{
if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums"))
- database.GetArtistsNav("musicdb://5/",items,-1,m_rule.m_field == CSmartPlaylistRule::FIELD_ALBUMARTIST);
+ database.GetArtistsNav("musicdb://5/",items,-1,m_rule.m_field == FieldAlbumArtist);
if (m_type.Equals("musicvideos") || m_type.Equals("mixed"))
{
CFileItemList items2;
@@ -137,7 +137,7 @@ void CGUIDialogSmartPlaylistRule::OnBrowse()
}
iLabel = 557;
}
- else if (m_rule.m_field == CSmartPlaylistRule::FIELD_ALBUM)
+ else if (m_rule.m_field == FieldAlbum)
{
if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums"))
database.GetAlbumsNav("musicdb://6/",items,-1,-1,-1,-1);
@@ -149,32 +149,32 @@ void CGUIDialogSmartPlaylistRule::OnBrowse()
}
iLabel = 558;
}
- else if (m_rule.m_field == CSmartPlaylistRule::FIELD_ACTOR)
+ else if (m_rule.m_field == FieldActor)
{
videodatabase.GetActorsNav("",items,type);
iLabel = 20337;
}
- else if (m_rule.m_field == CSmartPlaylistRule::FIELD_DIRECTOR)
+ else if (m_rule.m_field == FieldDirector)
{
videodatabase.GetDirectorsNav("",items,type);
iLabel = 20339;
}
- else if (m_rule.m_field == CSmartPlaylistRule::FIELD_STUDIO)
+ else if (m_rule.m_field == FieldStudio)
{
videodatabase.GetStudiosNav("",items,type);
iLabel = 572;
}
- else if (m_rule.m_field == CSmartPlaylistRule::FIELD_WRITER)
+ else if (m_rule.m_field == FieldWriter)
{
videodatabase.GetWritersNav("",items,type);
iLabel = 20417;
}
- else if (m_rule.m_field == CSmartPlaylistRule::FIELD_TVSHOWTITLE)
+ else if (m_rule.m_field == FieldTvShowTitle)
{
videodatabase.GetTvShowsNav("",items);
iLabel = 20343;
}
- else if (m_rule.m_field == CSmartPlaylistRule::FIELD_PLAYLIST)
+ else if (m_rule.m_field == FieldPlaylist)
{
// use filebrowser to grab another smart playlist
@@ -194,7 +194,7 @@ void CGUIDialogSmartPlaylistRule::OnBrowse()
}
iLabel = 559;
}
- else if (m_rule.m_field == CSmartPlaylistRule::FIELD_PATH)
+ else if (m_rule.m_field == FieldPath)
{
VECSOURCES sources;
if (m_type == "songs" || m_type == "mixed")
@@ -210,7 +210,7 @@ void CGUIDialogSmartPlaylistRule::OnBrowse()
UpdateButtons();
return;
}
- else if (m_rule.m_field == CSmartPlaylistRule::FIELD_SET)
+ else if (m_rule.m_field == FieldSet)
{
videodatabase.GetSetsNav("videodb://1/7/", items, VIDEODB_CONTENT_MOVIES);
iLabel = 20434;
@@ -221,7 +221,7 @@ void CGUIDialogSmartPlaylistRule::OnBrowse()
}
// sort the items
- items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);
+ items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
pDialog->Reset();
@@ -248,7 +248,7 @@ void CGUIDialogSmartPlaylistRule::OnField()
{
CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_FIELD);
OnMessage(msg);
- m_rule.m_field = (CSmartPlaylistRule::DATABASE_FIELD)msg.GetParam1();
+ m_rule.m_field = (Field)msg.GetParam1();
UpdateButtons();
}
@@ -268,7 +268,7 @@ void CGUIDialogSmartPlaylistRule::UpdateButtons()
SendMessage(GUI_MSG_ITEM_SELECT, CONTROL_FIELD, m_rule.m_field);
CGUIMessage msg2(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_FIELD);
OnMessage(msg2);
- m_rule.m_field = (CSmartPlaylistRule::DATABASE_FIELD)msg2.GetParam1();
+ m_rule.m_field = (Field)msg2.GetParam1();
// and now update the operator set
SendMessage(GUI_MSG_LABEL_RESET, CONTROL_OPERATOR);
@@ -373,7 +373,7 @@ void CGUIDialogSmartPlaylistRule::OnInitWindow()
ChangeButtonToEdit(CONTROL_VALUE, true); // true for single label
CGUIDialog::OnInitWindow();
// add the fields to the field spincontrol
- vector<CSmartPlaylistRule::DATABASE_FIELD> fields = CSmartPlaylistRule::GetFields(m_type);
+ vector<Field> fields = CSmartPlaylistRule::GetFields(m_type);
for (unsigned int i = 0; i < fields.size(); i++)
{
CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_FIELD, fields[i]);
View
2  xbmc/filesystem/AddonsDirectory.cpp
@@ -314,7 +314,7 @@ CFileItemPtr CAddonsDirectory::GetMoreItem(const CStdString &content)
item->SetLabelPreformated(true);
item->SetLabel(g_localizeStrings.Get(21452));
item->SetIconImage("DefaultAddon.png");
- item->SetSpecialSort(SORT_ON_BOTTOM);
+ item->SetSpecialSort(SortSpecialOnBottom);
return item;
}
View
2  xbmc/filesystem/LibraryDirectory.cpp
@@ -141,7 +141,7 @@ bool CLibraryDirectory::GetDirectory(const CStdString& strPath, CFileItemList &i
items.Add(item);
}
}
- items.Sort(SORT_METHOD_PLAYLIST_ORDER, SORT_ORDER_ASC);
+ items.Sort(SORT_METHOD_PLAYLIST_ORDER, SortOrderAscending);
return true;
}
View
2  xbmc/filesystem/MultiPathDirectory.cpp
@@ -252,7 +252,7 @@ void CMultiPathDirectory::MergeItems(CFileItemList &items)
return;
// sort items by label
// folders are before files in this sort method
- items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);
+ items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
int i = 0;
// if first item in the sorted list is a file, just abort
View
2  xbmc/filesystem/MusicDatabaseDirectory/DirectoryNode.cpp
@@ -333,7 +333,7 @@ void CDirectoryNode::AddQueuingFolder(CFileItemList& items) const
if (pItem)
{
pItem->m_bIsFolder = true;
- pItem->SetSpecialSort(g_advancedSettings.m_bMusicLibraryAllItemsOnBottom ? SORT_ON_BOTTOM : SORT_ON_TOP);
+ pItem->SetSpecialSort(g_advancedSettings.m_bMusicLibraryAllItemsOnBottom ? SortSpecialOnBottom : SortSpecialOnTop);
pItem->SetCanQueue(false);
pItem->SetLabelPreformated(true);
if (g_advancedSettings.m_bMusicLibraryAllItemsOnBottom)
View
2  xbmc/filesystem/RarManager.cpp
@@ -120,7 +120,7 @@ bool CRarManager::CacheRarredFile(CStdString& strPathInCache, const CStdString&
{
CFileItemList items;
CDirectory::GetDirectory(g_advancedSettings.m_cachePath,items);
- items.Sort(SORT_METHOD_SIZE, SORT_ORDER_DESC);
+ items.Sort(SORT_METHOD_SIZE, SortOrderDescending);
while (items.Size() && CheckFreeSpace(strDir) < iSize)
{
if (!items[0]->m_bIsFolder)
View
2  xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.cpp
@@ -337,7 +337,7 @@ void CDirectoryNode::AddQueuingFolder(CFileItemList& items) const
if (pItem)
{
pItem->m_bIsFolder = true;
- pItem->SetSpecialSort(g_advancedSettings.m_bVideoLibraryAllItemsOnBottom ? SORT_ON_BOTTOM : SORT_ON_TOP);
+ pItem->SetSpecialSort(g_advancedSettings.m_bVideoLibraryAllItemsOnBottom ? SortSpecialOnBottom : SortSpecialOnTop);
pItem->SetCanQueue(false);
items.Add(pItem);
}
View
3  xbmc/guilib/GUIBaseContainer.cpp
@@ -26,6 +26,7 @@
#include "GUIInfoManager.h"
#include "utils/TimeUtils.h"
#include "utils/log.h"
+#include "utils/SortUtils.h"
#include "utils/StringUtils.h"
#include "GUIStaticItem.h"
#include "Key.h"
@@ -521,7 +522,7 @@ void CGUIBaseContainer::OnJumpLetter(char letter)
for (unsigned int i = (offset + 1) % m_items.size(); i != offset; i = (i+1) % m_items.size())
{
CGUIListItemPtr item = m_items[i];
- if (0 == strnicmp(SSortFileItem::RemoveArticles(item->GetLabel()).c_str(), m_match.c_str(), m_match.size()))
+ if (0 == strnicmp(SortUtils::RemoveArticles(item->GetLabel()).c_str(), m_match.c_str(), m_match.size()))
{
SelectItem(i);
return;
View
4 xbmc/input/ButtonTranslator.cpp
@@ -444,7 +444,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, SORT_ORDER_ASC);
+ files.Sort(SORT_METHOD_FILE, SortOrderAscending);
for(int fileIndex = 0; fileIndex<files.Size(); ++fileIndex)
{
if (!files[fileIndex]->m_bIsFolder)
@@ -463,7 +463,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, SORT_ORDER_ASC);
+ files.Sort(SORT_METHOD_FILE, SortOrderAscending);
for(int fileIndex = 0; fileIndex<files.Size(); ++fileIndex)
{
if (!files[fileIndex]->m_bIsFolder)
View
6 xbmc/interfaces/http-api/XBMChttp.cpp
@@ -408,7 +408,7 @@ int CXbmcHttp::displayDir(int numParas, CStdString paras[])
tmp.Format("%i", dirItems.Size());
return SetResponse(openTag+tmp);
}
- dirItems.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);
+ dirItems.Sort(SORT_METHOD_LABEL, SortOrderAscending);
if (lineStart > dirItems.Size() || lineStart < 0)
return SetResponse(openTag+"Error:Line start value out of range");
if (numLines == -1)
@@ -495,7 +495,7 @@ void CXbmcHttp::AddItemToPlayList(const CFileItemPtr &pItem, int playList, int s
CStdString strDirectory=pItem->GetPath();
CFileItemList items;
CDirectory::GetDirectory(pItem->GetPath(), items, mask);
- items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);
+ items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
for (int i=0; i < items.Size(); ++i)
if (!(CFileItem*)items[i]->m_bIsFolder || recursive)
AddItemToPlayList(items[i], playList, sortMethod, mask, recursive);
@@ -762,7 +762,7 @@ int CXbmcHttp::xbmcGetMediaLocation(int numParas, CStdString paras[])
tmp.Format("%i",items.Size());
return SetResponse(openTag+tmp);
}
- items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);
+ items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
CStdString strLine;
if (lineStart>items.Size() || lineStart<0)
return SetResponse(openTag+"Error:Line start value out of range");
View
6 xbmc/interfaces/json-rpc/AudioLibrary.cpp
@@ -536,14 +536,14 @@ bool CAudioLibrary::FillFileItemList(const CVariant &parameterObject, 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, SORT_ORDER_ASC);
+ list.Sort(SORT_METHOD_ALBUM_IGNORE_THE, SortOrderAscending);
// 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, SORT_ORDER_ASC);
+ list.Sort(SORT_METHOD_ARTIST_IGNORE_THE, SortOrderAscending);
// otherwise we sort by track number
else
- list.Sort(SORT_METHOD_TRACKNUM, SORT_ORDER_ASC);
+ list.Sort(SORT_METHOD_TRACKNUM, SortOrderAscending);
}
}
View
8 xbmc/interfaces/json-rpc/FileItemHandler.cpp
@@ -331,12 +331,12 @@ bool CFileItemHandler::FillFileItemList(const CVariant &parameterObject, CFileIt
return (list.Size() > 0);
}
-bool CFileItemHandler::ParseSortMethods(const CStdString &method, const bool &ignorethe, const CStdString &order, SORT_METHOD &sortmethod, SORT_ORDER &sortorder)
+bool CFileItemHandler::ParseSortMethods(const CStdString &method, const bool &ignorethe, const CStdString &order, SORT_METHOD &sortmethod, SortOrder &sortorder)
{
if (order.Equals("ascending"))
- sortorder = SORT_ORDER_ASC;
+ sortorder = SortOrderAscending;
else if (order.Equals("descending"))
- sortorder = SORT_ORDER_DESC;
+ sortorder = SortOrderDescending;
else
return false;
@@ -419,7 +419,7 @@ void CFileItemHandler::Sort(CFileItemList &items, const CVariant &parameterObjec
order = order.ToLower();
SORT_METHOD sortmethod = SORT_METHOD_NONE;
- SORT_ORDER sortorder = SORT_ORDER_ASC;
+ SortOrder sortorder = SortOrderAscending;
if (ParseSortMethods(method, parameterObject["ignorearticle"].asBoolean(), order, sortmethod, sortorder))
items.Sort(sortmethod, sortorder);
View
2  xbmc/interfaces/json-rpc/FileItemHandler.h
@@ -36,7 +36,7 @@ namespace JSONRPC
static bool FillFileItemList(const CVariant &parameterObject, CFileItemList &list);
private:
- static bool ParseSortMethods(const CStdString &method, const bool &ignorethe, const CStdString &order, SORT_METHOD &sortmethod, SORT_ORDER &sortorder);
+ static bool ParseSortMethods(const CStdString &method, const bool &ignorethe, const CStdString &order, SORT_METHOD &sortmethod, SortOrder &sortorder);
static void Sort(CFileItemList &items, const CVariant& parameterObject);
};
}
View
2  xbmc/interfaces/json-rpc/FileOperations.cpp
@@ -295,7 +295,7 @@ bool CFileOperations::FillFileItemList(const CVariant &parameterObject, CFileIte
CDirectory directory;
if (directory.GetDirectory(strPath, items, extensions))
{
- items.Sort(SORT_METHOD_FILE, SORT_ORDER_ASC);
+ items.Sort(SORT_METHOD_FILE, SortOrderAscending);
CFileItemList filteredDirectories;
for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
{
View
4 xbmc/interfaces/python/xbmcmodule/listitem.cpp
@@ -801,9 +801,9 @@ namespace PYXBMC
else if (lowerKey.CompareNoCase("specialsort") == 0)
{
if (uText == "bottom")
- self->item->SetSpecialSort(SORT_ON_BOTTOM);
+ self->item->SetSpecialSort(SortSpecialOnBottom);
else if (uText == "top")
- self->item->SetSpecialSort(SORT_ON_TOP);
+ self->item->SetSpecialSort(SortSpecialOnTop);
}
else
self->item->SetProperty(lowerKey.ToLower(), uText.c_str());
View
28 xbmc/music/GUIViewStateMusic.cpp
@@ -137,7 +137,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
}
break;
case NODE_TYPE_TOP100:
@@ -147,7 +147,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
}
break;
case NODE_TYPE_GENRE:
@@ -157,7 +157,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_ASC);
+ SetSortOrder(SortOrderAscending);
}
break;
case NODE_TYPE_YEAR:
@@ -167,7 +167,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_ASC);
+ SetSortOrder(SortOrderAscending);
}
break;
case NODE_TYPE_ARTIST:
@@ -221,7 +221,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
SetViewAsControl(g_settings.m_viewStateMusicNavAlbums.m_viewMode);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
}
break;
case NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS:
@@ -231,7 +231,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
SetViewAsControl(g_settings.m_viewStateMusicNavSongs.m_viewMode);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
}
break;
case NODE_TYPE_ALBUM_RECENTLY_PLAYED:
@@ -241,7 +241,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
SetViewAsControl(g_settings.m_viewStateMusicNavAlbums.m_viewMode);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
}
break;
case NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS:
@@ -251,7 +251,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
SetViewAsControl(g_settings.m_viewStateMusicNavAlbums.m_viewMode);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
}
break;
case NODE_TYPE_ALBUM_TOP100:
@@ -261,7 +261,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
}
break;
case NODE_TYPE_SINGLES:
@@ -333,7 +333,7 @@ CGUIViewStateMusicDatabase::CGUIViewStateMusicDatabase(const CFileItemList& item
SetViewAsControl(g_settings.m_viewStateMusicNavSongs.m_viewMode);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
}
break;
default:
@@ -500,7 +500,7 @@ CGUIViewStateWindowMusicNav::CGUIViewStateWindowMusicNav(const CFileItemList& it
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
}
else
{
@@ -542,7 +542,7 @@ CGUIViewStateWindowMusicNav::CGUIViewStateWindowMusicNav(const CFileItemList& it
}
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_ASC);
+ SetSortOrder(SortOrderAscending);
}
LoadViewState(items.GetPath(), WINDOW_MUSIC_NAV);
}
@@ -623,7 +623,7 @@ CGUIViewStateWindowMusicSongs::CGUIViewStateWindowMusicSongs(const CFileItemList
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_ASC);
+ SetSortOrder(SortOrderAscending);
}
else if (items.GetPath() == "special://musicplaylists/")
{ // playlists list sorts by label only, ignoring folders
@@ -676,7 +676,7 @@ CGUIViewStateWindowMusicPlaylist::CGUIViewStateWindowMusicPlaylist(const CFileIt
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
LoadViewState(items.GetPath(), WINDOW_MUSIC_PLAYLIST);
}
View
4 xbmc/music/infoscanner/MusicInfoScanner.cpp
@@ -378,7 +378,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, SORT_ORDER_ASC);
+ items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
CStdString hash;
GetPathHash(items, hash);
@@ -396,7 +396,7 @@ bool CMusicInfoScanner::DoScan(const CStdString& strDirectory)
// filter items in the sub dir (for .cue sheet support)
items.FilterCueItems();
- items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);
+ items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
// and then scan in the new information
if (RetrieveMusicInfo(items, strDirectory) > 0)
View
4 xbmc/music/windows/GUIWindowMusicBase.cpp
@@ -1336,14 +1336,14 @@ bool CGUIWindowMusicBase::GetDirectory(const CStdString &strDirectory, CFileItem
newPlaylist.reset(new CFileItem("newplaylist://", false));
newPlaylist->SetLabel(g_localizeStrings.Get(525));
newPlaylist->SetLabelPreformated(true);
- newPlaylist->SetSpecialSort(SORT_ON_BOTTOM);
+ newPlaylist->SetSpecialSort(SortSpecialOnBottom);
newPlaylist->SetCanQueue(false);
items.Add(newPlaylist);
newPlaylist.reset(new CFileItem("newsmartplaylist://music", false));
newPlaylist->SetLabel(g_localizeStrings.Get(21437));
newPlaylist->SetLabelPreformated(true);
- newPlaylist->SetSpecialSort(SORT_ON_BOTTOM);
+ newPlaylist->SetSpecialSort(SortSpecialOnBottom);
newPlaylist->SetCanQueue(false);
items.Add(newPlaylist);
}
View
2  xbmc/network/UPnP.cpp
@@ -1108,7 +1108,7 @@ CUPnPServer::OnBrowseDirectChildren(PLT_ActionReference& action,
}
// Always sort by label
- items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC);
+ items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
// Don't pass parent_id if action is Search not BrowseDirectChildren, as
// we want the engine to determine the best parent id, not necessarily the one
View
2  xbmc/pictures/GUIViewStatePictures.cpp
@@ -44,7 +44,7 @@ CGUIViewStateWindowPictures::CGUIViewStateWindowPictures(const CFileItemList& it
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_ASC);
+ SetSortOrder(SortOrderAscending);
}
else
{
View
6 xbmc/pictures/GUIWindowSlideShow.cpp
@@ -913,7 +913,7 @@ int CGUIWindowSlideShow::CurrentSlide() const
void CGUIWindowSlideShow::AddFromPath(const CStdString &strPath,
bool bRecursive,
- SORT_METHOD method, SORT_ORDER order, const CStdString &strExtensions)
+ SORT_METHOD method, SortOrder order, const CStdString &strExtensions)
{
if (strPath!="")
{
@@ -933,7 +933,7 @@ void CGUIWindowSlideShow::AddFromPath(const CStdString &strPath,
void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath,
bool bRecursive /* = false */, bool bRandom /* = false */,
bool bNotRandom /* = false */, SORT_METHOD method /* = SORT_METHOD_LABEL */,
- SORT_ORDER order /* = SORT_ORDER_ASC */, const CStdString &strExtensions)
+ SortOrder order /* = SortOrderAscending */, const CStdString &strExtensions)
{
// stop any video
if (g_application.IsPlayingVideo())
@@ -955,7 +955,7 @@ void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath,
g_windowManager.ActivateWindow(WINDOW_SLIDESHOW);
}
-void CGUIWindowSlideShow::AddItems(const CStdString &strPath, path_set *recursivePaths, SORT_METHOD method, SORT_ORDER order)
+void CGUIWindowSlideShow::AddItems(const CStdString &strPath, path_set *recursivePaths, SORT_METHOD method, SortOrder order)
{
// check whether we've already added this path
if (recursivePaths)
View
8 xbmc/pictures/GUIWindowSlideShow.h
@@ -76,10 +76,10 @@ class CGUIWindowSlideShow : public CGUIWindow
void RunSlideShow(const CStdString &strPath, bool bRecursive = false,
bool bRandom = false, bool bNotRandom = false,
SORT_METHOD method = SORT_METHOD_LABEL,
- SORT_ORDER order = SORT_ORDER_ASC, const CStdString &strExtensions="");
+ SortOrder order = SortOrderAscending, const CStdString &strExtensions="");
void AddFromPath(const CStdString &strPath, bool bRecursive,
SORT_METHOD method=SORT_METHOD_LABEL,
- SORT_ORDER order=SORT_ORDER_ASC, const CStdString &strExtensions="");
+ SortOrder order = SortOrderAscending, const CStdString &strExtensions="");
void StartSlideShow(bool screensaver=false);
bool InSlideShow() const;
virtual bool OnMessage(CGUIMessage& message);
@@ -98,8 +98,8 @@ class CGUIWindowSlideShow : public CGUIWindow
private:
typedef std::set<CStdString> path_set; // set to track which paths we're adding
void AddItems(const CStdString &strPath, path_set *recursivePaths,
- SORT_METHOD method=SORT_METHOD_LABEL,
- SORT_ORDER order=SORT_ORDER_ASC);
+ SORT_METHOD method = SORT_METHOD_LABEL,
+ SortOrder order = SortOrderAscending);
void RenderPause();
void RenderErrorMessage();
void Rotate();
View
2  xbmc/pictures/PictureThumbLoader.cpp
@@ -206,7 +206,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, SORT_ORDER_ASC);
+ items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
CStdString thumb = CTextureCache::GetWrappedThumbURL(items[0]->GetPath());
db.SetTextureForPath(pItem->GetPath(), "thumb", thumb);
CTextureCache::Get().BackgroundCacheImage(thumb);
View
4 xbmc/settings/Settings.cpp
@@ -458,8 +458,8 @@ void CSettings::GetViewState(const TiXmlElement *pRootElement, const CStdString
viewState.m_sortMethod = (SORT_METHOD)sortMethod;
int sortOrder;
- GetInteger(pNode, "sortorder", sortOrder, SORT_ORDER_ASC, SORT_ORDER_NONE, SORT_ORDER_DESC);
- viewState.m_sortOrder = (SORT_ORDER)sortOrder;
+ GetInteger(pNode, "sortorder", sortOrder, SortOrderAscending, SortOrderNone, SortOrderDescending);
+ viewState.m_sortOrder = (SortOrder)sortOrder;
}
void CSettings::SetViewState(TiXmlNode *pRootNode, const CStdString &strTagName, const CViewState &viewState) const
View
2  xbmc/storage/MediaManager.cpp
@@ -541,7 +541,7 @@ bool CMediaManager::HashDVD(const CStdString& dvdpath, uint32_t& crc)
Crc32 crc32;
bool dataRead = false;
- vecItemsTS.Sort(SORT_METHOD_FILE, SORT_ORDER_ASC);
+ vecItemsTS.Sort(SORT_METHOD_FILE, SortOrderAscending);
for (int i = 0; i < vecItemsTS.Size(); i++)
{
CFileItemPtr videoTSItem = vecItemsTS[i];
View
14 xbmc/video/GUIViewStateVideo.cpp
@@ -67,7 +67,7 @@ CGUIViewStateWindowVideoFiles::CGUIViewStateWindowVideoFiles(const CFileItemList
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_ASC);
+ SetSortOrder(SortOrderAscending);
}
else
{
@@ -106,7 +106,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
}
else if (items.IsVideoDb())
{
@@ -127,7 +127,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
SetViewAsControl(DEFAULT_VIEW_LIST);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
}
break;
case NODE_TYPE_DIRECTOR:
@@ -253,7 +253,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
SetSortMethod(SORT_METHOD_NONE);
SetViewAsControl(g_settings.m_viewStateVideoNavEpisodes.m_viewMode);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);
break;
}
@@ -335,7 +335,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it
SetViewAsControl(g_settings.m_viewStateVideoNavTitles.m_viewMode);
- SetSortOrder(SORT_ORDER_NONE);
+ SetSortOrder(SortOrderNone);