Skip to content

Commit

Permalink
fix watched-unwatched for TV shows and episodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Voyager-xbmc committed Jul 25, 2012
1 parent 8d978da commit 392cef8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
20 changes: 16 additions & 4 deletions xbmc/video/windows/GUIWindowVideoNav.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -522,9 +522,9 @@ void CGUIWindowVideoNav::UpdateButtons()


bool CGUIWindowVideoNav::GetFilteredItems(const CStdString &filter, CFileItemList &items) bool CGUIWindowVideoNav::GetFilteredItems(const CStdString &filter, CFileItemList &items)
{ {
bool result = CGUIMediaWindow::GetFilteredItems(filter, items); bool listchanged = CGUIMediaWindow::GetFilteredItems(filter, items);
ApplyWatchedFilter(items); listchanged |= ApplyWatchedFilter(items);
return result || g_settings.GetWatchMode(m_vecItems->GetContent()) != VIDEO_SHOW_ALL; return listchanged;
} }


/// \brief Search for names, genres, artists, directors, and plots with search string \e strSearch in the /// \brief Search for names, genres, artists, directors, and plots with search string \e strSearch in the
Expand Down Expand Up @@ -1564,8 +1564,9 @@ CStdString CGUIWindowVideoNav::GetStartFolder(const CStdString &dir)
return CGUIWindowVideoBase::GetStartFolder(dir); return CGUIWindowVideoBase::GetStartFolder(dir);
} }


void CGUIWindowVideoNav::ApplyWatchedFilter(CFileItemList &items) bool CGUIWindowVideoNav::ApplyWatchedFilter(CFileItemList &items)
{ {
bool listchanged = false;
CVideoDatabaseDirectory dir; CVideoDatabaseDirectory dir;
NODE_TYPE node = dir.GetDirectoryChildType(items.GetPath()); NODE_TYPE node = dir.GetDirectoryChildType(items.GetPath());


Expand Down Expand Up @@ -1599,7 +1600,10 @@ void CGUIWindowVideoNav::ApplyWatchedFilter(CFileItemList &items)
item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("unwatchedepisodes").asInteger(); item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("unwatchedepisodes").asInteger();
if (watchMode == VIDEO_SHOW_WATCHED) if (watchMode == VIDEO_SHOW_WATCHED)
item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("watchedepisodes").asInteger(); item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("watchedepisodes").asInteger();
if (watchMode == VIDEO_SHOW_ALL)
item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("totalepisodes").asInteger();
item->SetProperty("numepisodes", item->GetVideoInfoTag()->m_iEpisode); item->SetProperty("numepisodes", item->GetVideoInfoTag()->m_iEpisode);
listchanged = true;
} }


if (filterWatched) if (filterWatched)
Expand All @@ -1609,9 +1613,17 @@ void CGUIWindowVideoNav::ApplyWatchedFilter(CFileItemList &items)
{ {
items.Remove(i); items.Remove(i);
i--; i--;
listchanged = true;
} }
} }
} }

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.
FormatAndSort(items);

return listchanged;
} }


bool CGUIWindowVideoNav::GetItemsForTag(const CStdString &strHeading, const std::string &type, CFileItemList &items, int idTag /* = -1 */, bool showAll /* = true */) bool CGUIWindowVideoNav::GetItemsForTag(const CStdString &strHeading, const std::string &type, CFileItemList &items, int idTag /* = -1 */, bool showAll /* = true */)
Expand Down
2 changes: 1 addition & 1 deletion xbmc/video/windows/GUIWindowVideoNav.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CGUIWindowVideoNav : public CGUIWindowVideoBase
*/ */
void LoadVideoInfo(CFileItemList &items); void LoadVideoInfo(CFileItemList &items);


void ApplyWatchedFilter(CFileItemList &items); bool ApplyWatchedFilter(CFileItemList &items);
virtual bool GetFilteredItems(const CStdString &filter, CFileItemList &items); virtual bool GetFilteredItems(const CStdString &filter, CFileItemList &items);


virtual void OnItemLoaded(CFileItem* pItem) {}; virtual void OnItemLoaded(CFileItem* pItem) {};
Expand Down
5 changes: 3 additions & 2 deletions xbmc/windows/GUIMediaWindow.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ void CGUIMediaWindow::OnPrepareFileItems(CFileItemList &items)
// to modify the fileitems. Eg. to modify the item label // to modify the fileitems. Eg. to modify the item label
void CGUIMediaWindow::OnFinalizeFileItems(CFileItemList &items) void CGUIMediaWindow::OnFinalizeFileItems(CFileItemList &items)
{ {
m_unfilteredItems->SetPath(items.GetPath()); // use the original path - it'll likely be relied on for other things later.
m_unfilteredItems->Append(items); m_unfilteredItems->Append(items);


CStdString filter(GetProperty("filter").asString()); CStdString filter(GetProperty("filter").asString());
Expand Down Expand Up @@ -1523,7 +1524,7 @@ void CGUIMediaWindow::OnFilterItems(const CStdString &filter)


m_viewControl.Clear(); m_viewControl.Clear();


CFileItemList items; CFileItemList items(m_unfilteredItems->GetPath()); // use the original path - it'll likely be relied on for other things later.
items.Append(*m_unfilteredItems); items.Append(*m_unfilteredItems);
if (GetFilteredItems(filter, items)) if (GetFilteredItems(filter, items))
{ {
Expand All @@ -1546,7 +1547,7 @@ bool CGUIMediaWindow::GetFilteredItems(const CStdString &filter, CFileItemList &
if (trimmedFilter.IsEmpty()) if (trimmedFilter.IsEmpty())
return true; return true;


CFileItemList filteredItems; CFileItemList filteredItems(items.GetPath()); // use the original path - it'll likely be relied on for other things later.
bool numericMatch = StringUtils::IsNaturalNumber(trimmedFilter); bool numericMatch = StringUtils::IsNaturalNumber(trimmedFilter);
for (int i = 0; i < items.Size(); i++) for (int i = 0; i < items.Size(); i++)
{ {
Expand Down

0 comments on commit 392cef8

Please sign in to comment.