Merge pull request #4222 from Montellese/jsonrpc_audiolibrary_fixes
[vuplus_xbmc] / xbmc / video / GUIViewStateVideo.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "GUIViewStateVideo.h"
22 #include "PlayListPlayer.h"
23 #include "filesystem/PluginDirectory.h"
24 #include "filesystem/PVRDirectory.h"
25 #include "filesystem/VideoDatabaseDirectory.h"
26 #include "filesystem/Directory.h"
27 #include "VideoDatabase.h"
28 #include "settings/AdvancedSettings.h"
29 #include "settings/MediaSettings.h"
30 #include "settings/MediaSourceSettings.h"
31 #include "settings/Settings.h"
32 #include "FileItem.h"
33 #include "guilib/WindowIDs.h"
34 #include "guilib/LocalizeStrings.h"
35 #include "view/ViewStateSettings.h"
36
37 using namespace XFILE;
38 using namespace VIDEODATABASEDIRECTORY;
39
40 CStdString CGUIViewStateWindowVideo::GetLockType()
41 {
42   return "video";
43 }
44
45 CStdString CGUIViewStateWindowVideo::GetExtensions()
46 {
47   return g_advancedSettings.m_videoExtensions;
48 }
49
50 int CGUIViewStateWindowVideo::GetPlaylist()
51 {
52   return PLAYLIST_VIDEO;
53 }
54
55 VECSOURCES& CGUIViewStateWindowVideo::GetSources()
56 {
57   AddLiveTVSources();
58   return CGUIViewState::GetSources();
59 }
60
61 CGUIViewStateWindowVideoFiles::CGUIViewStateWindowVideoFiles(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
62 {
63   if (items.IsVirtualDirectoryRoot())
64   {
65     AddSortMethod(SortByLabel, 551, LABEL_MASKS()); // Preformated
66     AddSortMethod(SortByDriveType, 564, LABEL_MASKS()); // Preformated
67     SetSortMethod(SortByLabel);
68
69     SetViewAsControl(DEFAULT_VIEW_LIST);
70
71     SetSortOrder(SortOrderAscending);
72   }
73   else
74   {
75     AddSortMethod(SortByLabel, 551, LABEL_MASKS("%L", "%I", "%L", ""),  // Label, Size | Label, empty
76       CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
77     AddSortMethod(SortBySize, 553, LABEL_MASKS("%L", "%I", "%L", "%I"));  // Label, Size | Label, Size
78     AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J"));  // Label, Date | Label, Date
79     AddSortMethod(SortByFile, 561, LABEL_MASKS("%L", "%I", "%L", ""));  // Label, Size | Label, empty
80
81     const CViewState *viewState = CViewStateSettings::Get().Get("videofiles");
82     SetSortMethod(viewState->m_sortDescription);
83     SetViewAsControl(viewState->m_viewMode);
84     SetSortOrder(viewState->m_sortDescription.sortOrder);
85   }
86   LoadViewState(items.GetPath(), WINDOW_VIDEO_FILES);
87 }
88
89 void CGUIViewStateWindowVideoFiles::SaveViewState()
90 {
91   SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_FILES, CViewStateSettings::Get().Get("videofiles"));
92 }
93
94 VECSOURCES& CGUIViewStateWindowVideoFiles::GetSources()
95 {
96   VECSOURCES *videoSources = CMediaSourceSettings::Get().GetSources("video");
97   AddOrReplace(*videoSources, CGUIViewStateWindowVideo::GetSources());
98   return *videoSources;
99 }
100
101 CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
102 {
103   SortAttribute sortAttributes = SortAttributeNone;
104   if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
105     sortAttributes = SortAttributeIgnoreArticle;
106
107   if (items.IsVirtualDirectoryRoot())
108   {
109     AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "%I", "%L", ""));  // Filename, Size | Label, empty
110     SetSortMethod(SortByNone);
111
112     SetViewAsControl(DEFAULT_VIEW_LIST);
113
114     SetSortOrder(SortOrderNone);
115   }
116   else if (items.IsVideoDb())
117   {
118     NODE_TYPE NodeType=CVideoDatabaseDirectory::GetDirectoryChildType(items.GetPath());
119     CQueryParams params;
120     CVideoDatabaseDirectory::GetQueryParams(items.GetPath(),params);
121
122     switch (NodeType)
123     {
124     case NODE_TYPE_MOVIES_OVERVIEW:
125     case NODE_TYPE_TVSHOWS_OVERVIEW:
126     case NODE_TYPE_MUSICVIDEOS_OVERVIEW:
127     case NODE_TYPE_OVERVIEW:
128       {
129         AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "%I", "%L", ""));  // Filename, Size | Label, empty
130
131         SetSortMethod(SortByNone);
132
133         SetViewAsControl(DEFAULT_VIEW_LIST);
134
135         SetSortOrder(SortOrderNone);
136       }
137       break;
138     case NODE_TYPE_DIRECTOR:
139     case NODE_TYPE_ACTOR:
140       {
141         AddSortMethod(SortByLabel, 551, LABEL_MASKS("%T", "%R", "%L", ""));  // Title, Rating | Label, empty
142         SetSortMethod(SortByLabel);
143
144         const CViewState *viewState = CViewStateSettings::Get().Get("videonavactors");
145         SetViewAsControl(viewState->m_viewMode);
146         SetSortOrder(viewState->m_sortDescription.sortOrder);
147       }
148       break;
149     case NODE_TYPE_YEAR:
150       {
151         AddSortMethod(SortByLabel, 551, LABEL_MASKS("%T", "%R", "%L", ""));  // Title, Rating | Label, empty
152         SetSortMethod(SortByLabel);
153
154         const CViewState *viewState = CViewStateSettings::Get().Get("videonavyears");
155         SetViewAsControl(viewState->m_viewMode);
156         SetSortOrder(viewState->m_sortDescription.sortOrder);
157       }
158       break;
159     case NODE_TYPE_SEASONS:
160       {
161         AddSortMethod(SortBySortTitle, 556, LABEL_MASKS("%L", "","%L",""));  // Label, empty | Label, empty
162         SetSortMethod(SortBySortTitle);
163
164         const CViewState *viewState = CViewStateSettings::Get().Get("videonavseasons");
165         SetViewAsControl(viewState->m_viewMode);
166         SetSortOrder(viewState->m_sortDescription.sortOrder);
167       }
168       break;
169     case NODE_TYPE_TITLE_TVSHOWS:
170       {
171         AddSortMethod(SortBySortTitle, sortAttributes, 556, LABEL_MASKS("%T", "%M", "%T", "%M"));  // Title, #Episodes | Title, #Episodes
172
173         // NOTE: This uses SortByEpisodeNumber to mean "sort shows by the number of episodes" and uses the label "Episodes"
174         AddSortMethod(SortByEpisodeNumber, 20360, LABEL_MASKS("%L", "%M", "%L", "%M"));  // Label, #Episodes | Label, #Episodes
175         AddSortMethod(SortByLastPlayed, 568, LABEL_MASKS("%T", "%p", "%T", "%p"));  // Title, #Last played | Title, #Last played
176         AddSortMethod(SortByYear, 562, LABEL_MASKS("%L","%Y","%L","%Y")); // Label, Year | Label, Year
177         SetSortMethod(SortByLabel);
178
179         const CViewState *viewState = CViewStateSettings::Get().Get("videonavtvshows");
180         SetViewAsControl(viewState->m_viewMode);
181         SetSortOrder(viewState->m_sortDescription.sortOrder);
182       }
183       break;
184     case NODE_TYPE_MUSICVIDEOS_ALBUM:
185     case NODE_TYPE_GENRE:
186     case NODE_TYPE_COUNTRY:
187     case NODE_TYPE_STUDIO:
188       {
189         AddSortMethod(SortByLabel, 551, LABEL_MASKS("%T", "%R", "%L", ""));  // Title, Rating | Label, empty
190         SetSortMethod(SortByLabel);
191
192         const CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres");
193         SetViewAsControl(viewState->m_viewMode);
194         SetSortOrder(viewState->m_sortDescription.sortOrder);
195       }
196       break;
197     case NODE_TYPE_SETS:
198       {
199         AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T","%R", "%T","%R"));  // Title, Rating | Title, Rating
200
201         AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y"));  // Title, Year | Title, Year
202         AddSortMethod(SortByRating, 563, LABEL_MASKS("%T", "%R", "%T", "%R"));  // Title, Rating | Title, Rating
203         AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T", "%a", "%T", "%a"));  // Title, DateAdded | Title, DateAdded
204
205         if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll)
206           AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V", "%T", "%V"));  // Title, Playcount | Title, Playcount
207
208         SetSortMethod(SortByLabel, SortAttributeIgnoreArticle);
209
210         const CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres");
211         SetViewAsControl(viewState->m_viewMode);
212         SetSortOrder(viewState->m_sortDescription.sortOrder);
213       }
214       break;
215     case NODE_TYPE_TAGS:
216       {
217         AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T","", "%T",""));  // Title, empty | Title, empty
218         SetSortMethod(SortByLabel, sortAttributes);
219         
220         const CViewState *viewState = CViewStateSettings::Get().Get("videonavgenres");
221         SetViewAsControl(viewState->m_viewMode);
222         SetSortOrder(viewState->m_sortDescription.sortOrder);
223       }
224       break;
225     case NODE_TYPE_EPISODES:
226       {
227         if (params.GetSeason() > -1)
228         {
229           AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%E. %T","%R"));  // Episode. Title, Rating | empty, empty
230           AddSortMethod(SortByRating, 563, LABEL_MASKS("%E. %T", "%R"));  // Episode. Title, Rating | empty, empty
231           AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%E. %T", "%O"));  // Episode. Title, MPAA | empty, empty
232           AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%E. %T","%P", "%E. %T","%P"));  // Episode. Title, ProductionCode | Episode. Title, ProductionCode
233           AddSortMethod(SortByDate, 552, LABEL_MASKS("%E. %T","%J","%E. %T","%J"));  // Episode. Title, Date | Episode. Title, Date
234
235           if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll)
236             AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%E. %T", "%V"));  // Episode. Title, Playcount | empty, empty
237         }
238         else
239         {
240           AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%H. %T","%R"));  // Order. Title, Rating | emtpy, empty
241           AddSortMethod(SortByRating, 563, LABEL_MASKS("%H. %T", "%R"));  // Order. Title, Rating | emtpy, empty
242           AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%H. %T", "%O"));  // Order. Title, MPAA | emtpy, empty
243           AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%H. %T","%P", "%H. %T","%P"));  // Order. Title, ProductionCode | Episode. Title, ProductionCode
244           AddSortMethod(SortByDate, 552, LABEL_MASKS("%H. %T","%J","%H. %T","%J"));  // Order. Title, Date | Episode. Title, Date
245
246           if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll)
247             AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%H. %T", "%V"));  // Order. Title, Playcount | empty, empty
248         }
249         AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T","%R"));  // Title, Rating | empty, empty
250
251         const CViewState *viewState = CViewStateSettings::Get().Get("videonavepisodes");
252         SetSortMethod(viewState->m_sortDescription);
253         SetViewAsControl(viewState->m_viewMode);
254         SetSortOrder(viewState->m_sortDescription.sortOrder);
255         break;
256       }
257     case NODE_TYPE_RECENTLY_ADDED_EPISODES:
258       {
259         AddSortMethod(SortByNone, 552, LABEL_MASKS("%Z - %H. %T", "%R"));  // TvShow - Order. Title, Rating | empty, empty
260         SetSortMethod(SortByNone);
261
262         SetViewAsControl(CViewStateSettings::Get().Get("videonavepisodes")->m_viewMode);
263         SetSortOrder(SortOrderNone);
264
265         break;
266       }
267     case NODE_TYPE_TITLE_MOVIES:
268       {
269         if (params.GetSetId() > -1) // Is this a listing within a set?
270         {
271           AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y"));  // Title, Year | empty, empty
272           AddSortMethod(SortBySortTitle, sortAttributes, 556, LABEL_MASKS("%T", "%R"));  // Title, Rating | empty, empty
273         }
274         else
275         {
276           AddSortMethod(SortBySortTitle, sortAttributes, 556, LABEL_MASKS("%T", "%R", "%T", "%R"));  // Title, Rating | Title, Rating
277           AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y"));  // Title, Year | Title, Year
278         }
279         AddSortMethod(SortByRating, 563, LABEL_MASKS("%T", "%R", "%T", "%R"));  // Title, Rating | Title, Rating
280         AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O"));  // Title, MPAA | empty, empty
281         AddSortMethod(SortByTime, 180, LABEL_MASKS("%T", "%D"));  // Title, Duration | empty, empty
282         AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T", "%a", "%T", "%a"));  // Title, DateAdded | Title, DateAdded
283
284         if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll)
285           AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V", "%T", "%V"));  // Title, Playcount | Title, Playcount
286
287         const CViewState *viewState = CViewStateSettings::Get().Get("videonavtitles");
288         if (params.GetSetId() > -1)
289           SetSortMethod(SortByYear);
290         else
291           SetSortMethod(viewState->m_sortDescription);
292
293         SetViewAsControl(viewState->m_viewMode);
294         SetSortOrder(viewState->m_sortDescription.sortOrder);
295       }
296       break;
297       case NODE_TYPE_TITLE_MUSICVIDEOS:
298       {
299         AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T", "%Y"));  // Title, Year | empty, empty
300         AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O"));
301         AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y"));  // Title, Year | empty, empty
302         AddSortMethod(SortByArtist, sortAttributes, 557, LABEL_MASKS("%A - %T", "%Y"));  // Artist - Title, Year | empty, empty
303         AddSortMethod(SortByAlbum, sortAttributes, 558, LABEL_MASKS("%B - %T", "%Y"));  // Album - Title, Year | empty, empty
304
305         if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll)
306           AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V"));  // Title, Playcount | empty, empty
307
308         CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat");
309         CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright");
310         AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrackLeft, strTrackRight));  // Userdefined, Userdefined | empty, empty
311
312         const CViewState *viewState = CViewStateSettings::Get().Get("videonavmusicvideos");
313         SetSortMethod(viewState->m_sortDescription);
314         SetViewAsControl(viewState->m_viewMode);
315         SetSortOrder(viewState->m_sortDescription.sortOrder);
316       }
317       break;
318     case NODE_TYPE_RECENTLY_ADDED_MOVIES:
319       {
320         AddSortMethod(SortByNone, 552, LABEL_MASKS("%T", "%R"));  // Title, Rating | empty, empty
321         SetSortMethod(SortByNone);
322
323         SetViewAsControl(CViewStateSettings::Get().Get("videonavtitles")->m_viewMode);
324
325         SetSortOrder(SortOrderNone);
326       }
327       break;
328     case NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS:
329       {
330         AddSortMethod(SortByNone, 552, LABEL_MASKS("%A - %T", "%Y"));  // Artist - Title, Year | empty, empty
331         SetSortMethod(SortByNone);
332
333         SetViewAsControl(CViewStateSettings::Get().Get("videonavmusicvideos")->m_viewMode);
334
335         SetSortOrder(SortOrderNone);
336       }
337       break;
338     default:
339       break;
340     }
341   }
342   else
343   {
344     AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%L", "%I", "%L", ""));  // Label, Size | Label, empty
345     AddSortMethod(SortBySize, 553, LABEL_MASKS("%L", "%I", "%L", "%I"));  // Label, Size | Label, Size
346     AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J"));  // Label, Date | Label, Date
347     AddSortMethod(SortByFile, 561, LABEL_MASKS("%L", "%I", "%L", ""));  // Label, Size | Label, empty
348     
349     const CViewState *viewState = CViewStateSettings::Get().Get("videofiles");
350     SetSortMethod(viewState->m_sortDescription);
351     SetViewAsControl(viewState->m_viewMode);
352     SetSortOrder(viewState->m_sortDescription.sortOrder);
353   }
354   LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
355 }
356
357 void CGUIViewStateWindowVideoNav::SaveViewState()
358 {
359   if (m_items.IsVideoDb())
360   {
361     NODE_TYPE NodeType = CVideoDatabaseDirectory::GetDirectoryChildType(m_items.GetPath());
362     CQueryParams params;
363     CVideoDatabaseDirectory::GetQueryParams(m_items.GetPath(),params);
364     switch (NodeType)
365     {
366     case NODE_TYPE_ACTOR:
367       SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavactors"));
368       break;
369     case NODE_TYPE_YEAR:
370       SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavyears"));
371       break;
372     case NODE_TYPE_GENRE:
373       SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavgenres"));
374       break;
375     case NODE_TYPE_TITLE_MOVIES:
376       SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, params.GetSetId() > -1 ? NULL : CViewStateSettings::Get().Get("videonavtitles"));
377       break;
378     case NODE_TYPE_EPISODES:
379       SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavepisodes"));
380       break;
381     case NODE_TYPE_TITLE_TVSHOWS:
382       SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavtvshows"));
383       break;
384     case NODE_TYPE_SEASONS:
385       SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavseasons"));
386       break;
387     case NODE_TYPE_TITLE_MUSICVIDEOS:
388       SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavmusicvideos"));
389       break;
390     default:
391       SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV);
392       break;
393     }
394   }
395   else
396   {
397     SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videofiles"));
398   }
399 }
400
401 VECSOURCES& CGUIViewStateWindowVideoNav::GetSources()
402 {
403   //  Setup shares we want to have
404   m_sources.clear();
405   CFileItemList items;
406   if (CSettings::Get().GetBool("myvideos.flatten"))
407     CDirectory::GetDirectory("library://video_flat/", items, "");
408   else
409     CDirectory::GetDirectory("library://video/", items, "");
410   for (int i=0; i<items.Size(); ++i)
411   {
412     CFileItemPtr item=items[i];
413     CMediaSource share;
414     share.strName=item->GetLabel();
415     share.strPath = item->GetPath();
416     share.m_strThumbnailImage= item->GetIconImage();
417     share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
418     m_sources.push_back(share);
419   }
420   return CGUIViewStateWindowVideo::GetSources();
421 }
422
423 bool CGUIViewStateWindowVideoNav::AutoPlayNextItem()
424 {
425   CQueryParams params;
426   CVideoDatabaseDirectory::GetQueryParams(m_items.GetPath(),params);
427   if (params.GetContentType() == VIDEODB_CONTENT_MUSICVIDEOS || params.GetContentType() == 6) // recently added musicvideos
428     return CSettings::Get().GetBool("musicplayer.autoplaynextitem");
429
430   return CSettings::Get().GetBool("videoplayer.autoplaynextitem");
431 }
432
433 CGUIViewStateWindowVideoPlaylist::CGUIViewStateWindowVideoPlaylist(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
434 {
435   AddSortMethod(SortByNone, 551, LABEL_MASKS("%L", "", "%L", ""));  // Label, empty | Label, empty
436   SetSortMethod(SortByNone);
437
438   SetViewAsControl(DEFAULT_VIEW_LIST);
439
440   SetSortOrder(SortOrderNone);
441
442   LoadViewState(items.GetPath(), WINDOW_VIDEO_PLAYLIST);
443 }
444
445 void CGUIViewStateWindowVideoPlaylist::SaveViewState()
446 {
447   SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_PLAYLIST);
448 }
449
450 bool CGUIViewStateWindowVideoPlaylist::HideExtensions()
451 {
452   return true;
453 }
454
455 bool CGUIViewStateWindowVideoPlaylist::HideParentDirItems()
456 {
457   return true;
458 }
459
460 VECSOURCES& CGUIViewStateWindowVideoPlaylist::GetSources()
461 {
462   m_sources.clear();
463   //  Playlist share
464   CMediaSource share;
465   share.strPath= "playlistvideo://";
466   share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
467   m_sources.push_back(share);
468
469   // no plugins in playlist window
470   return m_sources;
471 }
472
473 CGUIViewStateVideoMovies::CGUIViewStateVideoMovies(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
474 {
475   AddSortMethod(SortBySortTitle, 556, LABEL_MASKS("%T", "%R", "%T", "%R"),  // Title, Rating | Title, Rating
476     CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
477   AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y"));  // Title, Year | Title, Year
478   AddSortMethod(SortByRating, 563, LABEL_MASKS("%T", "%R", "%T", "%R"));  // Title, Rating | Title, Rating
479   AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O"));  // Title, MPAA | empty, empty
480   AddSortMethod(SortByTime, 180, LABEL_MASKS("%T", "%D"));  // Title, Duration | empty, empty
481   AddSortMethod(SortByDateAdded, 570, LABEL_MASKS("%T", "%a", "%T", "%a"));  // Title, DateAdded | Title, DateAdded
482
483   if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll)
484     AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V", "%T", "%V"));  // Title, Playcount | Title, Playcount
485
486   const CViewState *viewState = CViewStateSettings::Get().Get("videonavtitles");
487   if (items.IsSmartPlayList() || items.IsLibraryFolder())
488     AddPlaylistOrder(items, LABEL_MASKS("%T", "%R", "%T", "%R"));  // Title, Rating | Title, Rating
489   else
490   {
491     SetSortMethod(viewState->m_sortDescription);
492     SetSortOrder(viewState->m_sortDescription.sortOrder);
493   }
494
495   SetViewAsControl(viewState->m_viewMode);
496
497   LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
498 }
499
500 void CGUIViewStateVideoMovies::SaveViewState()
501 {
502   SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavtitles"));
503 }
504
505 CGUIViewStateVideoMusicVideos::CGUIViewStateVideoMusicVideos(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
506 {
507   SortAttribute sortAttributes = SortAttributeNone;
508   if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
509     sortAttributes = SortAttributeIgnoreArticle;
510
511   AddSortMethod(SortByLabel, sortAttributes, 551, LABEL_MASKS("%T", "%Y"));  // Title, Year | empty, empty
512   AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%T", "%O"));
513   AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y"));  // Title, Year | empty, empty
514   AddSortMethod(SortByArtist, sortAttributes, 557, LABEL_MASKS("%A - %T", "%Y"));  // Artist - Title, Year | empty, empty
515   AddSortMethod(SortByAlbum, sortAttributes, 558, LABEL_MASKS("%B - %T", "%Y"));  // Album - Title, Year | empty, empty
516
517    if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll)
518     AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%T", "%V"));  // Title, Playcount | empty, empty
519   
520   CStdString strTrackLeft=CSettings::Get().GetString("musicfiles.trackformat");
521   CStdString strTrackRight=CSettings::Get().GetString("musicfiles.trackformatright");
522   AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrackLeft, strTrackRight));  // Userdefined, Userdefined | empty, empty
523
524   const CViewState *viewState = CViewStateSettings::Get().Get("videonavmusicvideos");
525   if (items.IsSmartPlayList() || items.IsLibraryFolder())
526     AddPlaylistOrder(items, LABEL_MASKS("%A - %T", "%Y"));  // Artist - Title, Year | empty, empty
527   else
528   {
529     SetSortMethod(viewState->m_sortDescription);
530     SetSortOrder(viewState->m_sortDescription.sortOrder);
531   }
532
533   SetViewAsControl(viewState->m_viewMode);
534
535   LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
536 }
537
538 void CGUIViewStateVideoMusicVideos::SaveViewState()
539 {
540   SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavmusicvideos"));
541 }
542
543 CGUIViewStateVideoTVShows::CGUIViewStateVideoTVShows(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
544 {
545   AddSortMethod(SortBySortTitle, 556, LABEL_MASKS("%T", "%M", "%T", "%M"),  // Title, #Episodes | Title, #Episodes
546     CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
547   // NOTE: This uses SortByEpisodeNumber to mean "sort shows by the number of episodes" and uses the label "Episodes"
548   AddSortMethod(SortByEpisodeNumber, 20360, LABEL_MASKS("%L", "%M", "%L", "%M"));  // Label, #Episodes | Label, #Episodes
549   AddSortMethod(SortByLastPlayed, 568, LABEL_MASKS("%T", "%p", "%T", "%p"));  // Title, #Last played | Title, #Last played
550   AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y"));  // Title, Year | Title, Year
551
552   const CViewState *viewState = CViewStateSettings::Get().Get("videonavtvshows");
553   if (items.IsSmartPlayList() || items.IsLibraryFolder())
554     AddPlaylistOrder(items, LABEL_MASKS("%T", "%M", "%T", "%M"));  // Title, #Episodes | Title, #Episodes
555   else
556   {
557     SetSortMethod(viewState->m_sortDescription);
558     SetSortOrder(viewState->m_sortDescription.sortOrder);
559   }
560
561   SetViewAsControl(viewState->m_viewMode);
562
563   LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
564 }
565
566 void CGUIViewStateVideoTVShows::SaveViewState()
567 {
568   SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavtvshows"));
569 }
570
571 CGUIViewStateVideoEpisodes::CGUIViewStateVideoEpisodes(const CFileItemList& items) : CGUIViewStateWindowVideo(items)
572 {
573   if (0)//params.GetSeason() > -1)
574   {
575     AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%E. %T","%R"));  // Episode. Title, Rating | empty, empty
576     AddSortMethod(SortByRating, 563, LABEL_MASKS("%E. %T", "%R"));  // Episode. Title, Rating | empty, empty
577     AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%E. %T", "%O"));  // Episode. Title, MPAA | empty, empty
578     AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%E. %T","%P", "%E. %T","%P"));  // Episode. Title, Production Code | Episode. Title, Production Code
579     AddSortMethod(SortByDate, 552, LABEL_MASKS("%E. %T","%J","E. %T","%J"));  // Episode. Title, Date | Episode. Title, Date
580
581     if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll)
582       AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%E. %T", "%V"));  // Episode. Title, Playcount | empty, empty
583   }
584   else
585   { // format here is tvshowtitle - season/episode number. episode title
586     AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%Z - %H. %T","%R"));  // TvShow - Order. Title, Rating | empty, empty
587     AddSortMethod(SortByRating, 563, LABEL_MASKS("%Z - %H. %T", "%R"));  // TvShow - Order. Title, Rating | empty, empty
588     AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%Z - %H. %T", "%O"));  // TvShow - Order. Title, MPAA | empty, empty
589     AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%Z - %H. %T","%P"));  // TvShow - Order. Title, Production Code | empty, empty
590     AddSortMethod(SortByDate, 552, LABEL_MASKS("%Z - %H. %T","%J"));  // TvShow - Order. Title, Date | empty, empty
591
592     if (CMediaSettings::Get().GetWatchedMode(items.GetContent()) == WatchedModeAll)
593       AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%H. %T", "%V"));  // Order. Title, Playcount | empty, empty
594   }
595
596   AddSortMethod(SortByLabel, 551, LABEL_MASKS("%Z - %H. %T","%R"),  // TvShow - Order. Title, Rating | empty, empty
597     CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
598
599   const CViewState *viewState = CViewStateSettings::Get().Get("videonavepisodes");
600   if (items.IsSmartPlayList() || items.IsLibraryFolder())
601     AddPlaylistOrder(items, LABEL_MASKS("%Z - %H. %T", "%R"));  // TvShow - Order. Title, Rating | empty, empty
602   else
603   {
604     SetSortMethod(viewState->m_sortDescription);
605     SetSortOrder(viewState->m_sortDescription.sortOrder);
606   }
607
608   SetViewAsControl(viewState->m_viewMode);
609
610   LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV);
611 }
612
613 void CGUIViewStateVideoEpisodes::SaveViewState()
614 {
615   SaveViewToDb(m_items.GetPath(), WINDOW_VIDEO_NAV, CViewStateSettings::Get().Get("videonavepisodes"));
616 }
617