bool CGUIWindowPVRRecordings::GetFilteredItems(const std::string &filter, CFileItemList &items) { bool listchanged = CGUIWindowPVRBase::GetFilteredItems(filter, items); int watchMode = CMediaSettings::GetInstance().GetWatchedMode("recordings"); CFileItemPtr item; for (int i = 0; i < items.Size(); i++) { item = items.Get(i); if (item->IsParentFolder()) // Don't delete the go to parent folder continue; if (!item->HasPVRRecordingInfoTag()) continue; int iPlayCount = item->GetPVRRecordingInfoTag()->GetPlayCount(); if ((watchMode == WatchedModeWatched && iPlayCount == 0) || (watchMode == WatchedModeUnwatched && iPlayCount > 0)) { items.Remove(i); i--; listchanged = true; } } // Remove the parent folder item, if it's the only item in the folder. if (items.GetObjectCount() == 0 && items.GetFileCount() > 0 && items.Get(0)->IsParentFolder()) items.Remove(0); return listchanged; }
// returns true if: // 1. Have more than 75% folders and // 2. Have more than percent folders with thumbs bool CAutoSwitch::ByFolderThumbPercentage(bool hideParentDirItems, int percent, const CFileItemList &vecItems) { int numItems = vecItems.Size(); if (!hideParentDirItems) numItems--; if (numItems <= 0) return false; int fileCount = vecItems.GetFileCount(); if (fileCount > 0.25f * numItems) return false; int numThumbs = 0; for (int i = 0; i < vecItems.Size(); i++) { const CFileItemPtr item = vecItems[i]; if (item->m_bIsFolder && item->HasArt("thumb")) { numThumbs++; if (numThumbs >= 0.01f * percent * (numItems - fileCount)) return true; } } return false; }
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; }
/// \brief Auto Switch method based on whether there is more than 25% files. /// \param iPercent Percent of non-default thumbs to autoswitch on bool CAutoSwitch::ByFileCount(const CFileItemList& vecItems) { if (vecItems.Size() == 0) return false; float fPercent = (float)vecItems.GetFileCount() / vecItems.Size(); return (fPercent > 0.25); }