bool CGUIWindowGames::GetDirectory(const std::string &strDirectory, CFileItemList& items) { if (!CGUIMediaWindow::GetDirectory(strDirectory, items)) return false; // Set label std::string label; if (items.GetLabel().empty()) { std::string source; if (m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::GetInstance().GetSources("games"), &source)) label = std::move(source); } if (!label.empty()) items.SetLabel(label); // Set content std::string content; if (items.GetContent().empty()) { if (!items.IsVirtualDirectoryRoot() && // Don't set content for root directory !items.IsPlugin()) // Don't set content for plugins { content = "games"; } } if (!content.empty()) items.SetContent(content); return true; }
bool CGUIWindowPictures::GetDirectory(const CStdString &strDirectory, CFileItemList& items) { if (!CGUIMediaWindow::GetDirectory(strDirectory, items)) return false; CStdString label; if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::Get().GetSources("pictures"), &label)) items.SetLabel(label); return true; }
bool CGUIWindowPictures::GetDirectory(const CStdString &strDirectory, CFileItemList& items) { if (!CGUIMediaWindow::GetDirectory(strDirectory, items)) return false; CStdString label; if (items.GetLabel().IsEmpty() && m_rootDir.IsSource(items.m_strPath, g_settings.GetSourcesFromType("pictures"), &label)) items.SetLabel(label); return true; }
bool CGUIWindowPictures::GetDirectory(const std::string &strDirectory, CFileItemList& items) { if (!CGUIMediaWindow::GetDirectory(strDirectory, items)) return false; std::string label; if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::GetInstance().GetSources("pictures"), &label)) items.SetLabel(label); if (items.GetContent().empty() && !items.IsVirtualDirectoryRoot() && !items.IsPlugin()) items.SetContent("images"); return true; }
bool CGUIWindowJukeboxSongs::GetDirectory(const CStdString &strDirectory, CFileItemList &items) { if (!CGUIWindowJukeboxBase::GetDirectory(strDirectory, items)) return false; // check for .CUE files here. items.FilterCueItems(); CStdString label; if (items.GetLabel().IsEmpty() && m_rootDir.IsSource(items.GetPath(), g_settings.GetSourcesFromType("music"), &label)) items.SetLabel(label); return true; }
void CFileItemList::Assign(const CFileItemList& itemlist, bool append) { CSingleLock lock(m_lock); if (!append) Clear(); Append(itemlist); SetPath(itemlist.GetPath()); SetLabel(itemlist.GetLabel()); m_content = itemlist.m_content; m_mapProperties = itemlist.m_mapProperties; m_cacheToDisc = itemlist.m_cacheToDisc; }
bool CGUIWindowMusicSongs::GetDirectory(const CStdString &strDirectory, CFileItemList &items) { if (!CGUIWindowMusicBase::GetDirectory(strDirectory, items)) return false; // check for .CUE files here. items.FilterCueItems(); CStdString label; if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::Get().GetSources("music"), &label)) items.SetLabel(label); return true; }
// \brief Set window to a specific directory // \param strDirectory The directory to be displayed in list/thumb control // This function calls OnPrepareFileItems() and OnFinalizeFileItems() bool CGUIMediaWindow::Update(const CStdString &strDirectory) { // TODO: OnInitWindow calls Update() before window path has been set properly. if (strDirectory == "?") return false; // get selected item int iItem = m_viewControl.GetSelectedItem(); CStdString strSelectedItem = ""; if (iItem >= 0 && iItem < m_vecItems->Size()) { CFileItemPtr pItem = m_vecItems->Get(iItem); if (!pItem->IsParentFolder()) { GetDirectoryHistoryString(pItem.get(), strSelectedItem); } } CStdString strOldDirectory = m_vecItems->GetPath(); m_history.SetSelectedItem(strSelectedItem, strOldDirectory); CFileItemList items; if (!GetDirectory(strDirectory, items)) { CLog::Log(LOGERROR,"CGUIMediaWindow::GetDirectory(%s) failed", strDirectory.c_str()); // if the directory is the same as the old directory, then we'll return // false. Else, we assume we can get the previous directory if (strDirectory.Equals(strOldDirectory)) return false; // We assume, we can get the parent // directory again, but we have to // return false to be able to eg. show // an error message. CStdString strParentPath = m_history.GetParentPath(); m_history.RemoveParentPath(); Update(strParentPath); return false; } if (items.GetLabel().IsEmpty()) items.SetLabel(CUtil::GetTitleFromPath(items.GetPath(), true)); ClearFileItems(); m_vecItems->Copy(items); // if we're getting the root source listing // make sure the path history is clean if (strDirectory.IsEmpty()) m_history.ClearPathHistory(); int iWindow = GetID(); int showLabel = 0; if (strDirectory.IsEmpty() && (iWindow == WINDOW_MUSIC_FILES || iWindow == WINDOW_FILES || iWindow == WINDOW_PICTURES || iWindow == WINDOW_PROGRAMS)) showLabel = 1026; if (strDirectory.Equals("sources://video/")) showLabel = 999; if (showLabel && (m_vecItems->Size() == 0 || !m_guiState->DisableAddSourceButtons())) // add 'add source button' { CStdString strLabel = g_localizeStrings.Get(showLabel); CFileItemPtr pItem(new CFileItem(strLabel)); pItem->SetPath("add"); pItem->SetIconImage("DefaultAddSource.png"); pItem->SetLabel(strLabel); pItem->SetLabelPreformated(true); pItem->m_bIsFolder = true; pItem->SetSpecialSort(SORT_ON_BOTTOM); m_vecItems->Add(pItem); } m_iLastControl = GetFocusedControlID(); // Ask the derived class if it wants to load additional info // for the fileitems like media info or additional // filtering on the items, setting thumbs. OnPrepareFileItems(*m_vecItems); // The idea here is to ensure we have something to focus if our file list // is empty. As such, this check MUST be last and ignore the hide parent // fileitems settings. if (m_vecItems->IsEmpty()) { CFileItemPtr pItem(new CFileItem("..")); pItem->SetPath(m_history.GetParentPath()); pItem->m_bIsFolder = true; pItem->m_bIsShareOrDrive = false; m_vecItems->AddFront(pItem, 0); } m_vecItems->FillInDefaultIcons(); m_guiState.reset(CGUIViewState::GetViewState(GetID(), *m_vecItems)); FormatAndSort(*m_vecItems); // Ask the devived class if it wants to do custom list operations, // eg. changing the label OnFinalizeFileItems(*m_vecItems); UpdateButtons(); m_viewControl.SetItems(*m_vecItems); strSelectedItem = m_history.GetSelectedItem(m_vecItems->GetPath()); bool bSelectedFound = false; //int iSongInDirectory = -1; for (int i = 0; i < m_vecItems->Size(); ++i) { CFileItemPtr pItem = m_vecItems->Get(i); // Update selected item if (!bSelectedFound) { CStdString strHistory; GetDirectoryHistoryString(pItem.get(), strHistory); if (strHistory == strSelectedItem) { m_viewControl.SetSelectedItem(i); bSelectedFound = true; } } } // if we haven't found the selected item, select the first item if (!bSelectedFound) m_viewControl.SetSelectedItem(0); if (iWindow != WINDOW_PVR || (iWindow == WINDOW_PVR && m_vecItems->GetPath().Left(17) == "pvr://recordings/")) m_history.AddPath(m_vecItems->GetPath()); //m_history.DumpPathHistory(); return true; }
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 CGUIWindowMusicBase::GetDirectory(const std::string &strDirectory, CFileItemList &items) { items.ClearArt(); bool bResult = CGUIMediaWindow::GetDirectory(strDirectory, items); if (bResult) { CMusicThumbLoader loader; loader.FillThumb(items); CQueryParams params; CDirectoryNode::GetDatabaseInfo(items.GetPath(), params); if (params.GetAlbumId() > 0) { std::map<std::string, std::string> artistArt; if (m_musicdatabase.GetArtistArtForItem(params.GetAlbumId(), MediaTypeAlbum, artistArt)) items.AppendArt(artistArt, MediaTypeArtist); std::map<std::string, std::string> albumArt; if (m_musicdatabase.GetArtForItem(params.GetAlbumId(), MediaTypeAlbum, albumArt)) items.AppendArt(albumArt, MediaTypeAlbum); } if (params.GetArtistId() > 0) { std::map<std::string, std::string> artistArt; if (m_musicdatabase.GetArtForItem(params.GetArtistId(), "artist", artistArt)) items.AppendArt(artistArt, MediaTypeArtist); } // add in the "New Playlist" item if we're in the playlists folder if ((items.GetPath() == "special://musicplaylists/") && !items.Contains("newplaylist://")) { CFileItemPtr newPlaylist(new CFileItem(CProfilesManager::GetInstance().GetUserDataItem("PartyMode.xsp"),false)); newPlaylist->SetLabel(g_localizeStrings.Get(16035)); newPlaylist->SetLabelPreformated(true); newPlaylist->m_bIsFolder = true; items.Add(newPlaylist); newPlaylist.reset(new CFileItem("newplaylist://", false)); newPlaylist->SetLabel(g_localizeStrings.Get(525)); newPlaylist->SetLabelPreformated(true); 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(SortSpecialOnBottom); newPlaylist->SetCanQueue(false); items.Add(newPlaylist); } // check for .CUE files here. items.FilterCueItems(); std::string label; if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::GetInstance().GetSources("music"), &label)) items.SetLabel(label); } return bResult; }