CGUIViewStateVideoEpisodes::CGUIViewStateVideoEpisodes(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { if (0)//params.GetSeason() > -1) { AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%E. %T","%R")); // Episode. Title, Rating | empty, empty AddSortMethod(SortByRating, 563, LABEL_MASKS("%E. %T", "%R")); // Episode. Title, Rating | empty, empty AddSortMethod(SortByUserRating, 38018, LABEL_MASKS("%E. %T", "%r")); // Episode. Title, Userrating | empty, empty AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%E. %T", "%O")); // Episode. Title, MPAA | empty, empty AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%E. %T","%P", "%E. %T","%P")); // Episode. Title, Production Code | Episode. Title, Production Code AddSortMethod(SortByDate, 552, LABEL_MASKS("%E. %T","%J","E. %T","%J")); // Episode. Title, Date | Episode. Title, Date if (CMediaSettings::GetInstance().GetWatchedMode(items.GetContent()) == WatchedModeAll) AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%E. %T", "%V")); // Episode. Title, Playcount | empty, empty } else { // format here is tvshowtitle - season/episode number. episode title AddSortMethod(SortByEpisodeNumber, 20359, LABEL_MASKS("%Z - %H. %T","%R")); // TvShow - Order. Title, Rating | empty, empty AddSortMethod(SortByRating, 563, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty AddSortMethod(SortByUserRating, 38018, LABEL_MASKS("%Z - %H. %T", "%r")); // TvShow - Order. Title, Userrating | empty, empty AddSortMethod(SortByMPAA, 20074, LABEL_MASKS("%Z - %H. %T", "%O")); // TvShow - Order. Title, MPAA | empty, empty AddSortMethod(SortByProductionCode, 20368, LABEL_MASKS("%Z - %H. %T","%P")); // TvShow - Order. Title, Production Code | empty, empty AddSortMethod(SortByDate, 552, LABEL_MASKS("%Z - %H. %T","%J")); // TvShow - Order. Title, Date | empty, empty if (CMediaSettings::GetInstance().GetWatchedMode(items.GetContent()) == WatchedModeAll) AddSortMethod(SortByPlaycount, 567, LABEL_MASKS("%H. %T", "%V")); // Order. Title, Playcount | empty, empty } AddSortMethod(SortByLabel, 551, LABEL_MASKS("%Z - %H. %T","%R"), // TvShow - Order. Title, Rating | empty, empty CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavepisodes"); if (items.IsSmartPlayList() || items.IsLibraryFolder()) AddPlaylistOrder(items, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty else { SetSortMethod(viewState->m_sortDescription); SetSortOrder(viewState->m_sortDescription.sortOrder); } SetViewAsControl(viewState->m_viewMode); LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); }
CGUIViewStateVideoTVShows::CGUIViewStateVideoTVShows(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { AddSortMethod(SortBySortTitle, 556, LABEL_MASKS("%T", "%M", "%T", "%M"), // Title, #Episodes | Title, #Episodes CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); // NOTE: This uses SortByEpisodeNumber to mean "sort shows by the number of episodes" and uses the label "Episodes" AddSortMethod(SortByEpisodeNumber, 20360, LABEL_MASKS("%L", "%M", "%L", "%M")); // Label, #Episodes | Label, #Episodes AddSortMethod(SortByLastPlayed, 568, LABEL_MASKS("%T", "%p", "%T", "%p")); // Title, #Last played | Title, #Last played AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year const CViewState *viewState = CViewStateSettings::Get().Get("videonavtvshows"); if (items.IsSmartPlayList() || items.IsLibraryFolder()) AddPlaylistOrder(items, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes else { SetSortMethod(viewState->m_sortDescription); SetSortOrder(viewState->m_sortDescription.sortOrder); } SetViewAsControl(viewState->m_viewMode); LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); }
CGUIViewStateVideoTVShows::CGUIViewStateVideoTVShows(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { AddSortMethod(SortBySortTitle, 556, LABEL_MASKS("%T", "%M", "%T", "%M"), // Title, #Episodes | Title, #Episodes CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); AddSortMethod(SortByNumberOfEpisodes, 20360, LABEL_MASKS("%L", "%M", "%L", "%M")); // Label, #Episodes | Label, #Episodes AddSortMethod(SortByLastPlayed, 568, LABEL_MASKS("%T", "%p", "%T", "%p")); // Title, #Last played | Title, #Last played AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year AddSortMethod(SortByUserRating, 38018, LABEL_MASKS("%T", "%r", "%T", "%r")); // Title, Userrating | Title, Userrating const CViewState *viewState = CViewStateSettings::GetInstance().Get("videonavtvshows"); if (items.IsSmartPlayList() || items.IsLibraryFolder()) AddPlaylistOrder(items, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes else { SetSortMethod(viewState->m_sortDescription); SetSortOrder(viewState->m_sortDescription.sortOrder); } SetViewAsControl(viewState->m_viewMode); LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); }
bool CGUIWindowVideoNav::GetDirectory(const std::string &strDirectory, CFileItemList &items) { if (m_thumbLoader.IsLoading()) m_thumbLoader.StopThread(); items.ClearArt(); items.ClearProperties(); bool bResult = CGUIWindowVideoBase::GetDirectory(strDirectory, items); if (bResult) { if (items.IsVideoDb()) { XFILE::CVideoDatabaseDirectory dir; CQueryParams params; dir.GetQueryParams(items.GetPath(),params); VIDEODATABASEDIRECTORY::NODE_TYPE node = dir.GetDirectoryChildType(items.GetPath()); int iFlatten = CServiceBroker::GetSettings().GetInt(CSettings::SETTING_VIDEOLIBRARY_FLATTENTVSHOWS); int itemsSize = items.GetObjectCount(); int firstIndex = items.Size() - itemsSize; // perform the flattening logic for tvshows with a single (unwatched) season (+ optional special season) if (node == NODE_TYPE_SEASONS && !items.IsEmpty()) { // check if the last item is the "All seasons" item which should be ignored for flattening if (!items[items.Size() - 1]->HasVideoInfoTag() || items[items.Size() - 1]->GetVideoInfoTag()->m_iSeason < 0) itemsSize -= 1; bool bFlatten = (itemsSize == 1 && iFlatten == 1) || iFlatten == 2 || // flatten if one one season or if always flatten is enabled (itemsSize == 2 && iFlatten == 1 && // flatten if one season + specials (items[firstIndex]->GetVideoInfoTag()->m_iSeason == 0 || items[firstIndex + 1]->GetVideoInfoTag()->m_iSeason == 0)); if (iFlatten > 0 && !bFlatten && (WatchedMode)CMediaSettings::GetInstance().GetWatchedMode("tvshows") == WatchedModeUnwatched) { int count = 0; for(int i = 0; i < items.Size(); i++) { const CFileItemPtr item = items.Get(i); if (item->GetProperty("unwatchedepisodes").asInteger() != 0 && item->GetVideoInfoTag()->m_iSeason > 0) count++; } bFlatten = (count < 2); // flatten if there is only 1 unwatched season (not counting specials) } if (bFlatten) { // flatten if one season or flatten always items.Clear(); CVideoDbUrl videoUrl; if (!videoUrl.FromString(items.GetPath())) return false; videoUrl.AppendPath("-2/"); return GetDirectory(videoUrl.ToString(), items); } } if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_EPISODES || node == NODE_TYPE_SEASONS || node == NODE_TYPE_RECENTLY_ADDED_EPISODES) { CLog::Log(LOGDEBUG, "WindowVideoNav::GetDirectory"); // grab the show thumb CVideoInfoTag details; m_database.GetTvShowInfo("", details, params.GetTvShowId()); std::map<std::string, std::string> art; if (m_database.GetArtForItem(details.m_iDbId, details.m_type, art)) { items.AppendArt(art, details.m_type); items.SetArtFallback("fanart", "tvshow.fanart"); if (node == NODE_TYPE_SEASONS) { // set an art fallback for "thumb" if (items.HasArt("tvshow.poster")) items.SetArtFallback("thumb", "tvshow.poster"); else if (items.HasArt("tvshow.banner")) items.SetArtFallback("thumb", "tvshow.banner"); } } // Grab fanart data items.SetProperty("fanart_color1", details.m_fanart.GetColor(0)); items.SetProperty("fanart_color2", details.m_fanart.GetColor(1)); items.SetProperty("fanart_color3", details.m_fanart.GetColor(2)); // save the show description (showplot) items.SetProperty("showplot", details.m_strPlot); items.SetProperty("showtitle", details.m_strShowTitle); // the container folder thumb is the parent (i.e. season or show) if (itemsSize && (node == NODE_TYPE_EPISODES || node == NODE_TYPE_RECENTLY_ADDED_EPISODES)) { items.SetContent("episodes"); int seasonID = -1; int seasonParam = params.GetSeason(); // grab all season art when flatten always if (seasonParam == -2 && iFlatten == 2) seasonParam = -1; if (seasonParam >= -1) seasonID = m_database.GetSeasonId(details.m_iDbId, seasonParam); else seasonID = items[firstIndex]->GetVideoInfoTag()->m_iIdSeason; CGUIListItem::ArtMap seasonArt; if (seasonID > -1 && m_database.GetArtForItem(seasonID, MediaTypeSeason, seasonArt)) { items.AppendArt(seasonArt, MediaTypeSeason); // set an art fallback for "thumb" if (items.HasArt("season.poster")) items.SetArtFallback("thumb", "season.poster"); else if (items.HasArt("season.banner")) items.SetArtFallback("thumb", "season.banner"); } } else items.SetContent("seasons"); } else if (node == NODE_TYPE_TITLE_MOVIES || node == NODE_TYPE_RECENTLY_ADDED_MOVIES) { if (params.GetSetId() > 0) { CGUIListItem::ArtMap setArt; if (m_database.GetArtForItem(params.GetSetId(), MediaTypeVideoCollection, setArt)) { items.AppendArt(setArt, MediaTypeVideoCollection); items.SetArtFallback("fanart", "set.fanart"); if (items.HasArt("set.poster")) items.SetArtFallback("thumb", "set.poster"); } } items.SetContent("movies"); } else if (node == NODE_TYPE_TITLE_TVSHOWS || node == NODE_TYPE_INPROGRESS_TVSHOWS) items.SetContent("tvshows"); else if (node == NODE_TYPE_TITLE_MUSICVIDEOS || node == NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS) items.SetContent("musicvideos"); else if (node == NODE_TYPE_GENRE) items.SetContent("genres"); else if (node == NODE_TYPE_COUNTRY) items.SetContent("countries"); else if (node == NODE_TYPE_ACTOR) { if (params.GetContentType() == VIDEODB_CONTENT_MUSICVIDEOS) items.SetContent("artists"); else items.SetContent("actors"); } else if (node == NODE_TYPE_DIRECTOR) items.SetContent("directors"); else if (node == NODE_TYPE_STUDIO) items.SetContent("studios"); else if (node == NODE_TYPE_YEAR) items.SetContent("years"); else if (node == NODE_TYPE_MUSICVIDEOS_ALBUM) items.SetContent("albums"); else if (node == NODE_TYPE_SETS) items.SetContent("sets"); else if (node == NODE_TYPE_TAGS) items.SetContent("tags"); else items.SetContent(""); } else if (URIUtils::PathEquals(items.GetPath(), "special://videoplaylists/")) items.SetContent("playlists"); else if (!items.IsVirtualDirectoryRoot()) { // load info from the database std::string label; if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::GetInstance().GetSources("video"), &label)) items.SetLabel(label); if (!items.IsSourcesPath() && !items.IsLibraryFolder()) LoadVideoInfo(items); } CVideoDbUrl videoUrl; if (videoUrl.FromString(items.GetPath()) && items.GetContent() == "tags" && !items.Contains("newtag://" + videoUrl.GetType())) { CFileItemPtr newTag(new CFileItem("newtag://" + videoUrl.GetType(), false)); newTag->SetLabel(g_localizeStrings.Get(20462)); newTag->SetLabelPreformated(true); newTag->SetSpecialSort(SortSpecialOnTop); items.Add(newTag); } } return bResult; }
bool CGUIWindowVideoNav::ApplyWatchedFilter(CFileItemList &items) { bool listchanged = false; CVideoDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(items.GetPath()); // now filter watched items as necessary bool filterWatched=false; if (node == NODE_TYPE_EPISODES || node == NODE_TYPE_SEASONS || node == NODE_TYPE_SETS || node == NODE_TYPE_TAGS || node == NODE_TYPE_TITLE_MOVIES || node == NODE_TYPE_TITLE_TVSHOWS || node == NODE_TYPE_TITLE_MUSICVIDEOS || node == NODE_TYPE_RECENTLY_ADDED_EPISODES || node == NODE_TYPE_RECENTLY_ADDED_MOVIES || node == NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS) filterWatched = true; if (!items.IsVideoDb()) filterWatched = true; if (items.GetContent() == "tvshows" && (items.IsSmartPlayList() || items.IsLibraryFolder())) node = NODE_TYPE_TITLE_TVSHOWS; // so that the check below works int watchMode = CMediaSettings::GetInstance().GetWatchedMode(m_vecItems->GetContent()); for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items.Get(i); if(item->HasVideoInfoTag() && (node == NODE_TYPE_TITLE_TVSHOWS || node == NODE_TYPE_SEASONS)) { if (watchMode == WatchedModeUnwatched) item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("unwatchedepisodes").asInteger(); if (watchMode == WatchedModeWatched) item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("watchedepisodes").asInteger(); if (watchMode == WatchedModeAll) item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("totalepisodes").asInteger(); item->SetProperty("numepisodes", item->GetVideoInfoTag()->m_iEpisode); listchanged = true; } if (filterWatched) { if(!item->IsParentFolder() && // Don't delete the go to parent folder ((watchMode == WatchedModeWatched && item->GetVideoInfoTag()->GetPlayCount() == 0) || (watchMode == WatchedModeUnwatched && item->GetVideoInfoTag()->GetPlayCount() > 0))) { items.Remove(i); i--; listchanged = true; } } } // Remove the parent folder icon, if it's the only thing in the folder. This is needed for hiding seasons. if (items.GetObjectCount() == 0 && items.GetFileCount() > 0 && items.Get(0)->IsParentFolder()) items.Remove(0); if(node == NODE_TYPE_TITLE_TVSHOWS || node == NODE_TYPE_SEASONS) { // the watched filter may change the "numepisodes" property which is reflected in the TV_SHOWS and SEASONS nodes // therefore, the items labels have to be refreshed, and possibly the list needs resorting as well. items.ClearSortState(); // this is needed to force resorting even if sort method did not change FormatAndSort(items); } return listchanged; }
CGUIViewStateMusicSmartPlaylist::CGUIViewStateMusicSmartPlaylist(const CFileItemList& items) : CGUIViewStateWindowMusic(items) { SortAttribute sortAttribute = SortAttributeNone; if (CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING)) sortAttribute = SortAttributeIgnoreArticle; const CViewState *viewState = CViewStateSettings::GetInstance().Get("musicnavsongs"); if (items.GetContent() == "songs" || items.GetContent() == "mixed") { std::string strTrack=CSettings::GetInstance().GetString(CSettings::SETTING_MUSICFILES_TRACKFORMAT); AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrack, "%N")); // Userdefined, Track Number| empty, empty AddSortMethod(SortByTitle, sortAttribute, 556, LABEL_MASKS("%T - %A", "%D")); // Title, Artist, Duration| empty, empty AddSortMethod(SortByAlbum, sortAttribute, 558, LABEL_MASKS("%B - %T - %A", "%D")); // Album, Titel, Artist, Duration| empty, empty AddSortMethod(SortByArtist, sortAttribute, 557, LABEL_MASKS("%A - %T", "%D")); // Artist, Titel, Duration| empty, empty AddSortMethod(SortByArtistThenYear, sortAttribute, 578, LABEL_MASKS("%A - %T", "%D")); // Artist, Titel, Duration| empty, empty AddSortMethod(SortByLabel, sortAttribute, 551, LABEL_MASKS(strTrack, "%D")); AddSortMethod(SortByTime, 180, LABEL_MASKS("%T - %A", "%D")); // Titel, Artist, Duration| empty, empty AddSortMethod(SortByRating, 563, LABEL_MASKS("%T - %A", "%R")); // Titel, Artist, Rating| empty, empty if (items.IsSmartPlayList() || items.IsLibraryFolder()) AddPlaylistOrder(items, LABEL_MASKS(strTrack, "%D")); else { SetSortMethod(viewState->m_sortDescription); SetSortOrder(viewState->m_sortDescription.sortOrder); } SetViewAsControl(CViewStateSettings::GetInstance().Get("musicnavsongs")->m_viewMode); } else if (items.GetContent() == "albums") { std::string strAlbum = g_advancedSettings.m_strMusicLibraryAlbumFormat; if (strAlbum.empty()) strAlbum = "%B"; // album // album AddSortMethod(SortByAlbum, sortAttribute, 558, LABEL_MASKS("%F", "", strAlbum, "")); // Filename, empty | Userdefined, empty // artist AddSortMethod(SortByArtist, sortAttribute, 557, LABEL_MASKS("%F", "", strAlbum, "%A")); // Filename, empty | Userdefined, Artist // artist / year AddSortMethod(SortByArtistThenYear, sortAttribute, 578, LABEL_MASKS("%F", "", strAlbum, "%A / %Y")); // Filename, empty | Userdefined, Artist / Year // year AddSortMethod(SortByYear, 562, LABEL_MASKS("%F", "", strAlbum, "%Y")); if (items.IsSmartPlayList() || items.IsLibraryFolder()) AddPlaylistOrder(items, LABEL_MASKS("%F", "", strAlbum, "%D")); else { SetSortMethod(viewState->m_sortDescription); SetSortOrder(viewState->m_sortDescription.sortOrder); } SetViewAsControl(CViewStateSettings::GetInstance().Get("musicnavalbums")->m_viewMode); } else { CLog::Log(LOGERROR,"Music Smart Playlist must be one of songs, mixed or albums"); } LoadViewState(items.GetPath(), WINDOW_MUSIC_NAV); }
bool CGUIWindowMusicNav::GetDirectory(const std::string &strDirectory, CFileItemList &items) { if (strDirectory.empty()) AddSearchFolder(); bool bResult = CGUIWindowMusicBase::GetDirectory(strDirectory, items); if (bResult) { if (items.IsPlayList()) OnRetrieveMusicInfo(items); } // update our content in the info manager if (StringUtils::StartsWithNoCase(strDirectory, "videodb://") || items.IsVideoDb()) { CVideoDatabaseDirectory dir; VIDEODATABASEDIRECTORY::NODE_TYPE node = dir.GetDirectoryChildType(items.GetPath()); if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_TITLE_MUSICVIDEOS || node == VIDEODATABASEDIRECTORY::NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS) items.SetContent("musicvideos"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_GENRE) items.SetContent("genres"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_COUNTRY) items.SetContent("countries"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_ACTOR) items.SetContent("artists"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_DIRECTOR) items.SetContent("directors"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_STUDIO) items.SetContent("studios"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_YEAR) items.SetContent("years"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_MUSICVIDEOS_ALBUM) items.SetContent("albums"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_TAGS) items.SetContent("tags"); else items.SetContent(""); } else if (StringUtils::StartsWithNoCase(strDirectory, "musicdb://") || items.IsMusicDb()) { CMusicDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(items.GetPath()); if (node == NODE_TYPE_ALBUM || node == NODE_TYPE_ALBUM_RECENTLY_ADDED || node == NODE_TYPE_ALBUM_RECENTLY_PLAYED || node == NODE_TYPE_ALBUM_TOP100 || node == NODE_TYPE_ALBUM_COMPILATIONS || node == NODE_TYPE_YEAR_ALBUM) items.SetContent("albums"); else if (node == NODE_TYPE_ARTIST) items.SetContent("artists"); else if (node == NODE_TYPE_SONG || node == NODE_TYPE_SONG_TOP100 || node == NODE_TYPE_SINGLES || node == NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS || node == NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS || node == NODE_TYPE_ALBUM_COMPILATIONS_SONGS || node == NODE_TYPE_ALBUM_TOP100_SONGS || node == NODE_TYPE_YEAR_SONG) items.SetContent("songs"); else if (node == NODE_TYPE_GENRE) items.SetContent("genres"); else if (node == NODE_TYPE_YEAR) items.SetContent("years"); else items.SetContent(""); } else if (items.IsPlayList()) items.SetContent("songs"); else if (URIUtils::PathEquals(strDirectory, "special://musicplaylists/") || URIUtils::PathEquals(strDirectory, "library://music/playlists.xml/")) items.SetContent("playlists"); else if (URIUtils::PathEquals(strDirectory, "plugin://music/")) items.SetContent("plugins"); else if (items.IsAddonsPath()) items.SetContent("addons"); else if (!items.IsSourcesPath() && !items.IsVirtualDirectoryRoot() && !items.IsLibraryFolder() && !items.IsPlugin() && !items.IsSmartPlayList()) items.SetContent("files"); return bResult; }