Merge pull request #25922 from sarbes/shader-cleanup
[xbmc.git] / xbmc / video / GUIViewStateVideo.cpp
blobee20ba1e7f186e5fb4a5244568954a829c3b2ac3
1 /*
2 * Copyright (C) 2016-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "GUIViewStateVideo.h"
11 #include "FileItem.h"
12 #include "FileItemList.h"
13 #include "ServiceBroker.h"
14 #include "VideoDatabase.h"
15 #include "filesystem/Directory.h"
16 #include "filesystem/VideoDatabaseDirectory.h"
17 #include "guilib/WindowIDs.h"
18 #include "playlists/PlayListFileItemClassify.h"
19 #include "playlists/PlayListTypes.h"
20 #include "settings/MediaSettings.h"
21 #include "settings/MediaSourceSettings.h"
22 #include "settings/Settings.h"
23 #include "settings/SettingsComponent.h"
24 #include "utils/FileExtensionProvider.h"
25 #include "utils/SortUtils.h"
26 #include "video/VideoFileItemClassify.h"
27 #include "view/ViewStateSettings.h"
29 using namespace KODI;
30 using namespace XFILE;
31 using namespace VIDEODATABASEDIRECTORY;
33 std::string CGUIViewStateWindowVideo::GetLockType()
35 return "video";
38 std::string CGUIViewStateWindowVideo::GetExtensions()
40 return CServiceBroker::GetFileExtensionProvider().GetVideoExtensions();
43 PLAYLIST::Id CGUIViewStateWindowVideo::GetPlaylist() const
45 return PLAYLIST::Id::TYPE_VIDEO;
48 std::vector<CMediaSource>& CGUIViewStateWindowVideo::GetSources()
50 AddLiveTVSources();
51 return CGUIViewState::GetSources();
54 bool CGUIViewStateWindowVideo::AutoPlayNextItem()
56 return AutoPlayNextVideoItem();
59 /***************************/
61 CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
63 SortAttribute sortAttributes = SortAttributeNone;
64 if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING))
65 sortAttributes = SortAttributeIgnoreArticle;
67 if (items.IsVirtualDirectoryRoot())
69 AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, Size | Label, empty
70 SetSortMethod(SortByNone);
72 SetViewAsControl(DEFAULT_VIEW_LIST);
74 SetSortOrder(SortOrderNone);
76 else if (VIDEO::IsVideoDb(items))
78 NODE_TYPE NodeType=CVideoDatabaseDirectory::GetDirectoryChildType(items.GetPath());
79 CQueryParams params;
80 CVideoDatabaseDirectory::GetQueryParams(items.GetPath(),params);
82 switch (NodeType)
84 case NODE_TYPE_MOVIES_OVERVIEW:
85 case NODE_TYPE_TVSHOWS_OVERVIEW:
86 case NODE_TYPE_MUSICVIDEOS_OVERVIEW:
87 case NODE_TYPE_OVERVIEW:
89 AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "%I", "%L", "")); // Filename, Size | Label, empty
91 SetSortMethod(SortByNone);
93 SetViewAsControl(DEFAULT_VIEW_LIST);
95 SetSortOrder(SortOrderNone);
97 break;
98 case NODE_TYPE_DIRECTOR:
99 case NODE_TYPE_ACTOR:
101 AddSortMethod(SortByLabel, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty
102 AddSortMethod(SortByRelevance, 38026, LABEL_MASKS("%T", "%c", "%L", "%c")); // Title, Actor's appearances (Relevance) | Label, Actor's appearances (Relevance)
103 SetSortMethod(SortByLabel);
105 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavactors");
106 SetViewAsControl(viewState->m_viewMode);
107 SetSortOrder(viewState->m_sortDescription.sortOrder);
109 break;
110 case NODE_TYPE_YEAR:
112 AddSortMethod(SortByLabel, 562, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty
113 SetSortMethod(SortByLabel);
115 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavyears");
116 SetViewAsControl(viewState->m_viewMode);
117 SetSortOrder(viewState->m_sortDescription.sortOrder);
119 break;
120 case NODE_TYPE_SEASONS:
122 AddSortMethod(SortBySortTitle, 556, LABEL_MASKS("%L", "","%L","")); // Label, empty | Label, empty
123 SetSortMethod(SortBySortTitle);
125 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavseasons");
126 SetViewAsControl(viewState->m_viewMode);
127 SetSortOrder(viewState->m_sortDescription.sortOrder);
129 break;
130 case NODE_TYPE_TITLE_TVSHOWS:
131 case NODE_TYPE_INPROGRESS_TVSHOWS:
133 AddSortMethod(SortBySortTitle, sortAttributes, 556, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
134 AddSortMethod(SortByOriginalTitle, sortAttributes, 20376,
135 LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
137 AddSortMethod(SortByNumberOfEpisodes, sortAttributes, 20360,
138 LABEL_MASKS("%L", "%M", "%L", "%M")); // Label, #Episodes | Label, #Episodes
139 AddSortMethod(
140 SortByLastPlayed, sortAttributes, 568,
141 LABEL_MASKS("%T", "%p", "%T", "%p")); // Title, #Last played | Title, #Last played
142 AddSortMethod(SortByDateAdded, sortAttributes, 570,
143 LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded
144 AddSortMethod(SortByYear, sortAttributes, 562,
145 LABEL_MASKS("%L", "%Y", "%L", "%Y")); // Label, Year | Label, Year
146 AddSortMethod(SortByRating, sortAttributes, 563,
147 LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
148 AddSortMethod(SortByUserRating, sortAttributes, 38018,
149 LABEL_MASKS("%T", "%r", "%T", "%r")); // Title, Userrating | Title, Userrating
150 SetSortMethod(SortByLabel);
152 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavtvshows");
153 SetViewAsControl(viewState->m_viewMode);
154 SetSortOrder(viewState->m_sortDescription.sortOrder);
156 break;
157 case NODE_TYPE_MUSICVIDEOS_ALBUM:
158 case NODE_TYPE_GENRE:
159 case NODE_TYPE_COUNTRY:
160 case NODE_TYPE_STUDIO:
162 AddSortMethod(SortByLabel, 551, LABEL_MASKS("%T", "%R", "%L", "")); // Title, Rating | Label, empty
163 SetSortMethod(SortByLabel);
165 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavgenres");
166 SetViewAsControl(viewState->m_viewMode);
167 SetSortOrder(viewState->m_sortDescription.sortOrder);
169 break;
170 case NODE_TYPE_SETS:
172 AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T","%R", "%T","%R")); // Title, Rating | Title, Rating
174 AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year
175 AddSortMethod(SortByRating, 563, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
176 AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded
177 AddSortMethod(SortByPlaycount, 567,
178 LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount
180 SetSortMethod(SortByLabel);
182 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavgenres");
183 SetViewAsControl(viewState->m_viewMode);
184 SetSortOrder(viewState->m_sortDescription.sortOrder);
186 break;
187 case NODE_TYPE_TAGS:
188 case NODE_TYPE_VIDEOVERSIONS:
190 AddSortMethod(SortByLabel, sortAttributes, 551,
191 LABEL_MASKS("%T", "", "%T", "")); // Title, empty | Title, empty
192 SetSortMethod(SortByLabel);
194 const CViewState* viewState = CViewStateSettings::GetInstance().Get("videonavgenres");
195 SetViewAsControl(viewState->m_viewMode);
196 SetSortOrder(viewState->m_sortDescription.sortOrder);
198 break;
199 case NODE_TYPE_EPISODES:
201 if (params.GetSeason() > -1)
203 AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%E. %T","%R")); // Episode. Title, Rating | empty, empty
204 AddSortMethod(SortByRating, 563, LABEL_MASKS("%E. %T", "%R")); // Episode. Title, Rating | empty, empty
205 AddSortMethod(SortByUserRating, 38018, LABEL_MASKS("%E. %T", "%r")); // Episode. Title, Userrating | empty, empty
206 AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%E. %T", "%O")); // Episode. Title, MPAA | empty, empty
207 AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%E. %T","%P", "%E. %T","%P")); // Episode. Title, ProductionCode | Episode. Title, ProductionCode
208 AddSortMethod(SortByDate, 552, LABEL_MASKS("%E. %T","%J","%E. %T","%J")); // Episode. Title, Date | Episode. Title, Date
209 AddSortMethod(SortByPlaycount, 567,
210 LABEL_MASKS("%E. %T", "%V")); // Episode. Title, Playcount | empty, empty
212 else
214 AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%H. %T","%R")); // Order. Title, Rating | empty, empty
215 AddSortMethod(SortByRating, 563, LABEL_MASKS("%H. %T", "%R")); // Order. Title, Rating | empty, empty
216 AddSortMethod(SortByUserRating, 38018, LABEL_MASKS("%H. %T", "%r")); // Order. Title, Userrating | empty, empty
217 AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%H. %T", "%O")); // Order. Title, MPAA | empty, empty
218 AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%H. %T","%P", "%H. %T","%P")); // Order. Title, ProductionCode | Episode. Title, ProductionCode
219 AddSortMethod(SortByDate, 552, LABEL_MASKS("%H. %T","%J","%H. %T","%J")); // Order. Title, Date | Episode. Title, Date
220 AddSortMethod(SortByPlaycount, 567,
221 LABEL_MASKS("%H. %T", "%V")); // Order. Title, Playcount | empty, empty
223 AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T","%R")); // Title, Rating | empty, empty
225 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavepisodes");
226 SetSortMethod(viewState->m_sortDescription);
227 SetViewAsControl(viewState->m_viewMode);
228 SetSortOrder(viewState->m_sortDescription.sortOrder);
229 break;
231 case NODE_TYPE_RECENTLY_ADDED_EPISODES:
233 AddSortMethod(SortByNone, 552, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty
234 SetSortMethod(SortByNone);
236 SetViewAsControl(CViewStateSettings::GetInstance().Get("videonavepisodes")->m_viewMode);
237 SetSortOrder(SortOrderNone);
239 break;
241 case NODE_TYPE_TITLE_MOVIES:
243 if (params.GetSetId() > -1) // Is this a listing within a set?
245 AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty
246 AddSortMethod(SortBySortTitle, sortAttributes, 556, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty
247 AddSortMethod(SortByOriginalTitle, sortAttributes, 20376,
248 LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty
250 else
252 AddSortMethod(SortBySortTitle, sortAttributes, 556, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
253 AddSortMethod(SortByOriginalTitle, sortAttributes, 20376,
254 LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
255 AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year
257 AddSortMethod(SortByRating, 563, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
258 AddSortMethod(SortByUserRating, 38018, LABEL_MASKS("%T", "%r", "%T", "%r")); // Title, Userrating | Title, Userrating
259 AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O")); // Title, MPAA | empty, empty
260 AddSortMethod(SortByTime, 180, LABEL_MASKS("%T", "%D")); // Title, Duration | empty, empty
261 AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded
262 AddSortMethod(SortByLastPlayed, 568, LABEL_MASKS("%T", "%p", "%T", "%p")); // Title, #Last played | Title, #Last played
263 AddSortMethod(SortByPlaycount, 567,
264 LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount
266 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavtitles");
267 if (params.GetSetId() > -1)
269 SetSortMethod(SortByYear);
270 SetSortOrder(SortOrderAscending);
272 else
274 SetSortMethod(viewState->m_sortDescription);
275 SetSortOrder(viewState->m_sortDescription.sortOrder);
278 SetViewAsControl(viewState->m_viewMode);
280 break;
281 case NODE_TYPE_TITLE_MUSICVIDEOS:
283 AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T - %A", "%Y")); // Title, Artist, Year | empty, empty
284 AddSortMethod(SortByAlbum, sortAttributes, 558, LABEL_MASKS("%B - %T - %A", "%Y")); // Album, Title, Artist, Year | empty, empty
285 AddSortMethod(SortByArtist, sortAttributes, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty
286 AddSortMethod(SortByArtistThenYear, sortAttributes, 578, LABEL_MASKS("%A - %T", "%Y")); // Artist, Title, Year| empty, empty
287 AddSortMethod(SortByYear, 562, LABEL_MASKS("%T - %A", "%Y")); // Title, Artist, Year| empty, empty
288 AddSortMethod(SortByTime, 180, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty
289 AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T - %A", "%a")); // Title - Artist, DateAdded | empty, empty
290 AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T - %A", "%V")); // Title - Artist, PlayCount
291 AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T - %A", "%O")); // Title - Artist, MPAARating
292 AddSortMethod(SortByUserRating, 38018, LABEL_MASKS("%T - %A", "%r")); // Title - Artist, UserRating
294 std::string strTrack=CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT);
295 AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrack, "%N")); // Userdefined, Track Number | empty, empty
297 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavmusicvideos");
298 SetSortMethod(viewState->m_sortDescription);
299 SetViewAsControl(viewState->m_viewMode);
300 SetSortOrder(viewState->m_sortDescription.sortOrder);
302 break;
303 case NODE_TYPE_RECENTLY_ADDED_MOVIES:
305 AddSortMethod(SortByNone, 552, LABEL_MASKS("%T", "%R")); // Title, Rating | empty, empty
306 SetSortMethod(SortByNone);
308 SetViewAsControl(CViewStateSettings::GetInstance().Get("videonavtitles")->m_viewMode);
310 SetSortOrder(SortOrderNone);
312 break;
313 case NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS:
315 AddSortMethod(SortByNone, 552, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty
316 SetSortMethod(SortByNone);
318 SetViewAsControl(CViewStateSettings::GetInstance().Get("videonavmusicvideos")->m_viewMode);
320 SetSortOrder(SortOrderNone);
322 break;
323 default:
324 break;
327 else
329 AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty
330 AddSortMethod(SortBySize, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // Label, Size | Label, Size
331 AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Label, Date | Label, Date
332 AddSortMethod(SortByFile, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty
334 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videofiles");
335 SetSortMethod(viewState->m_sortDescription);
336 SetViewAsControl(viewState->m_viewMode);
337 SetSortOrder(viewState->m_sortDescription.sortOrder);
339 LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
342 void CGUIViewStateWindowVideoNav::SaveViewState()
344 if (VIDEO::IsVideoDb(m_items))
346 NODE_TYPE NodeType = CVideoDatabaseDirectory::GetDirectoryChildType(m_items.GetPath());
347 CQueryParams params;
348 CVideoDatabaseDirectory::GetQueryParams(m_items.GetPath(),params);
349 switch (NodeType)
351 case NODE_TYPE_ACTOR:
352 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::GetInstance().Get("videonavactors"));
353 break;
354 case NODE_TYPE_YEAR:
355 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::GetInstance().Get("videonavyears"));
356 break;
357 case NODE_TYPE_GENRE:
358 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::GetInstance().Get("videonavgenres"));
359 break;
360 case NODE_TYPE_TITLE_MOVIES:
361 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, params.GetSetId() > -1 ? NULL : CViewStateSettings::GetInstance().Get("videonavtitles"));
362 break;
363 case NODE_TYPE_EPISODES:
364 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::GetInstance().Get("videonavepisodes"));
365 break;
366 case NODE_TYPE_TITLE_TVSHOWS:
367 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::GetInstance().Get("videonavtvshows"));
368 break;
369 case NODE_TYPE_SEASONS:
370 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::GetInstance().Get("videonavseasons"));
371 break;
372 case NODE_TYPE_TITLE_MUSICVIDEOS:
373 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::GetInstance().Get("videonavmusicvideos"));
374 break;
375 default:
376 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV);
377 break;
380 else
382 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::GetInstance().Get("videofiles"));
386 std::vector<CMediaSource>& CGUIViewStateWindowVideoNav::GetSources()
388 // Setup shares we want to have
389 m_sources.clear();
390 CFileItemList items;
391 if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_MYVIDEOS_FLATTEN))
392 CDirectory::GetDirectory("library://video_flat/", items, "", DIR_FLAG_DEFAULTS);
393 else
394 CDirectory::GetDirectory("library://video/", items, "", DIR_FLAG_DEFAULTS);
395 for (int i=0; i<items.Size(); ++i)
397 CFileItemPtr item=items[i];
398 CMediaSource share;
399 share.strName=item->GetLabel();
400 share.strPath = item->GetPath();
401 share.m_strThumbnailImage = item->GetArt("icon");
402 share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
403 m_sources.push_back(share);
405 return CGUIViewStateWindowVideo::GetSources();
408 bool CGUIViewStateWindowVideoNav::AutoPlayNextItem()
410 CQueryParams params;
411 CVideoDatabaseDirectory::GetQueryParams(m_items.GetPath(),params);
412 if (static_cast<VideoDbContentType>(params.GetContentType()) == VideoDbContentType::MUSICVIDEOS)
413 return CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_MUSICPLAYER_AUTOPLAYNEXTITEM);
415 return CGUIViewStateWindowVideo::AutoPlayNextItem();
418 CGUIViewStateWindowVideoPlaylist::CGUIViewStateWindowVideoPlaylist(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
420 AddSortMethod(SortByNone, 551, LABEL_MASKS("%L", "", "%L", "")); // Label, empty | Label, empty
421 SetSortMethod(SortByNone);
423 SetViewAsControl(DEFAULT_VIEW_LIST);
425 SetSortOrder(SortOrderNone);
427 LoadViewState(items.GetPath(), WINDOW_VIDEO_PLAYLIST);
430 void CGUIViewStateWindowVideoPlaylist::SaveViewState()
432 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_PLAYLIST);
435 bool CGUIViewStateWindowVideoPlaylist::HideExtensions()
437 return true;
440 bool CGUIViewStateWindowVideoPlaylist::HideParentDirItems()
442 return true;
445 std::vector<CMediaSource>& CGUIViewStateWindowVideoPlaylist::GetSources()
447 m_sources.clear();
448 // Playlist share
449 CMediaSource share;
450 share.strPath= "playlistvideo://";
451 share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
452 m_sources.push_back(share);
454 // no plugins in playlist window
455 return m_sources;
458 CGUIViewStateVideoMovies::CGUIViewStateVideoMovies(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
460 SortAttribute sortAttributes = SortAttributeNone;
461 if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
462 CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING))
463 sortAttributes = SortAttributeIgnoreArticle;
465 AddSortMethod(SortBySortTitle, sortAttributes, 556,
466 LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
467 AddSortMethod(SortByOriginalTitle, sortAttributes, 20376,
468 LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
469 AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year
470 AddSortMethod(SortByRating, 563, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
471 AddSortMethod(SortByUserRating, 38018, LABEL_MASKS("%T", "%r", "%T", "%r")); // Title, Userrating | Title, Userrating
472 AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O")); // Title, MPAA | empty, empty
473 AddSortMethod(SortByTime, 180, LABEL_MASKS("%T", "%D")); // Title, Duration | empty, empty
474 AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded
475 AddSortMethod(SortByPlaycount, 567,
476 LABEL_MASKS("%T", "%V", "%T", "%V")); // Title, Playcount | Title, Playcount
478 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavtitles");
479 if (PLAYLIST::IsSmartPlayList(items) || items.IsLibraryFolder())
480 AddPlaylistOrder(items, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating
481 else
483 SetSortMethod(viewState->m_sortDescription);
484 SetSortOrder(viewState->m_sortDescription.sortOrder);
487 SetViewAsControl(viewState->m_viewMode);
489 LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
492 void CGUIViewStateVideoMovies::SaveViewState()
494 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::GetInstance().Get("videonavtitles"));
497 CGUIViewStateVideoMusicVideos::CGUIViewStateVideoMusicVideos(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
499 SortAttribute sortAttributes = SortAttributeNone;
500 const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings();
501 if (settings->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING))
502 sortAttributes = SortAttributeIgnoreArticle;
504 AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T - %A", "%Y")); // Title, Artist, Year | empty, empty
505 AddSortMethod(SortByAlbum, sortAttributes, 558, LABEL_MASKS("%B - %T - %A", "%Y")); // Album, Title, Artist, Year | empty, empty
506 AddSortMethod(SortByArtist, sortAttributes, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty
507 AddSortMethod(SortByArtistThenYear, sortAttributes, 578, LABEL_MASKS("%A - %T", "%Y")); // Artist, Title, Year| empty, empty
508 AddSortMethod(SortByYear, 562, LABEL_MASKS("%T - %A", "%Y")); // Title, Artist, Year| empty, empty
509 AddSortMethod(SortByTime, 180, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty
510 AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T - %A", "%a")); // Title - Artist, DateAdded | empty, empty
511 AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T - %A", "%V")); // Title - Artist, PlayCount
512 AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T - %A", "%O")); // Title - Artist, MPAARating
513 AddSortMethod(SortByUserRating, 38018, LABEL_MASKS("%T - %A", "%r")); // Title - Artist, UserRating
515 std::string strTrack = settings->GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT);
516 AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrack, "%N")); // Userdefined, Track Number | empty, empty
518 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavmusicvideos");
519 if (PLAYLIST::IsSmartPlayList(items) || items.IsLibraryFolder())
520 AddPlaylistOrder(items, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty
521 else
523 SetSortMethod(viewState->m_sortDescription);
524 SetSortOrder(viewState->m_sortDescription.sortOrder);
527 SetViewAsControl(viewState->m_viewMode);
529 LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
532 void CGUIViewStateVideoMusicVideos::SaveViewState()
534 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::GetInstance().Get("videonavmusicvideos"));
537 CGUIViewStateVideoTVShows::CGUIViewStateVideoTVShows(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
539 SortAttribute sortAttributes = SortAttributeNone;
540 const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings();
541 if (settings->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING))
542 sortAttributes = SortAttributeIgnoreArticle;
544 AddSortMethod(SortBySortTitle, sortAttributes, 556,
545 LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
546 AddSortMethod(SortByNumberOfEpisodes, sortAttributes, 20360,
547 LABEL_MASKS("%L", "%M", "%L", "%M")); // Label, #Episodes | Label, #Episodes
548 AddSortMethod(SortByLastPlayed, sortAttributes, 568,
549 LABEL_MASKS("%T", "%p", "%T", "%p")); // Title, #Last played | Title, #Last played
550 AddSortMethod(SortByDateAdded, sortAttributes, 570,
551 LABEL_MASKS("%T", "%a", "%T", "%a")); // Title, DateAdded | Title, DateAdded
552 AddSortMethod(SortByYear, sortAttributes, 562,
553 LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year
554 AddSortMethod(SortByUserRating, sortAttributes, 38018,
555 LABEL_MASKS("%T", "%r", "%T", "%r")); // Title, Userrating | Title, Userrating
557 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavtvshows");
558 if (PLAYLIST::IsSmartPlayList(items) || items.IsLibraryFolder())
559 AddPlaylistOrder(items, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes
560 else
562 SetSortMethod(viewState->m_sortDescription);
563 SetSortOrder(viewState->m_sortDescription.sortOrder);
566 SetViewAsControl(viewState->m_viewMode);
568 LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
571 void CGUIViewStateVideoTVShows::SaveViewState()
573 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::GetInstance().Get("videonavtvshows"));
576 CGUIViewStateVideoEpisodes::CGUIViewStateVideoEpisodes(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
578 // TvShow - Order. Title, Rating | empty, empty
579 AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%Z - %H. %T","%R"));
580 // TvShow - Order. Title, Rating | empty, empty
581 AddSortMethod(SortByRating, 563, LABEL_MASKS("%Z - %H. %T", "%R"));
582 // TvShow - Order. Title, Userrating | empty, empty
583 AddSortMethod(SortByUserRating, 38018, LABEL_MASKS("%Z - %H. %T", "%r"));
584 // TvShow - Order. Title, MPAA | empty, empty
585 AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%Z - %H. %T", "%O"));
586 // TvShow - Order. Title, Production Code | empty, empty
587 AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%Z - %H. %T","%P"));
588 // TvShow - Order. Title, Date | empty, empty
589 AddSortMethod(SortByDate, 552, LABEL_MASKS("%Z - %H. %T","%J"));
590 // TvShow - Order. Title, Playcount | empty, empty
591 AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%H. %T", "%V"));
593 AddSortMethod(SortByLabel, 551, LABEL_MASKS("%Z - %H. %T","%R"), // TvShow - Order. Title, Rating | empty, empty
594 CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone);
596 const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavepisodes");
597 if (PLAYLIST::IsSmartPlayList(items) || items.IsLibraryFolder())
598 AddPlaylistOrder(items, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty
599 else
601 SetSortMethod(viewState->m_sortDescription);
602 SetSortOrder(viewState->m_sortDescription.sortOrder);
605 SetViewAsControl(viewState->m_viewMode);
607 LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
610 void CGUIViewStateVideoEpisodes::SaveViewState()
612 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::GetInstance().Get("videonavepisodes"));
615 CGUIViewStateVideoPlaylist::CGUIViewStateVideoPlaylist(const CFileItemList& items)
616 : CGUIViewStateWindowVideo(items)
618 SortAttribute sortAttributes = SortAttributeNone;
619 if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
620 CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING))
621 sortAttributes = SortAttributeIgnoreArticle;
623 AddSortMethod(SortByPlaylistOrder, 559, LABEL_MASKS("%L", "")); // Label, empty
624 AddSortMethod(SortByLabel, sortAttributes, 551,
625 LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty
626 AddSortMethod(SortBySize, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // Label, Size | Label, Size
627 AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Label, Date | Label, Date
628 AddSortMethod(SortByFile, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Label, Size | Label, empty
630 SetSortMethod(SortByPlaylistOrder);
632 const CViewState* viewState = CViewStateSettings::GetInstance().Get("videofiles");
633 SetViewAsControl(viewState->m_viewMode);
634 SetSortOrder(viewState->m_sortDescription.sortOrder);
636 LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
639 void CGUIViewStateVideoPlaylist::SaveViewState()
641 SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV);