Skip to content

Commit

Permalink
[videodb] - evaluate the setting for hiding watched
Browse files Browse the repository at this point in the history
movies/episodes/musicvideos in
recently added job (should influence homescreen of skins only)
  • Loading branch information
Memphiz committed Nov 18, 2014
1 parent 9e4e36f commit dbf7d6a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
10 changes: 5 additions & 5 deletions xbmc/utils/RecentlyAddedJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "utils/Variant.h"
#include "utils/StringUtils.h"
#include "settings/AdvancedSettings.h"
#include "settings/Settings.h"
#include "music/MusicThumbLoader.h"
#include "video/VideoThumbLoader.h"

Expand All @@ -57,8 +58,8 @@ bool CRecentlyAddedJob::UpdateVideo()
loader.OnLoaderStart();

videodatabase.Open();

if (videodatabase.GetRecentlyAddedMoviesNav("videodb://recentlyaddedmovies/", items, NUM_ITEMS))
bool hideWatched = CSettings::Get().GetBool("videolibrary.hiderecentlywatchedvideos");
if (videodatabase.GetRecentlyAddedMoviesNav("videodb://recentlyaddedmovies/", items, NUM_ITEMS, hideWatched))
{
for (; i < items.Size(); ++i)
{
Expand Down Expand Up @@ -97,8 +98,7 @@ bool CRecentlyAddedJob::UpdateVideo()

i = 0;
CFileItemList TVShowItems;

if (videodatabase.GetRecentlyAddedEpisodesNav("videodb://recentlyaddedepisodes/", TVShowItems, NUM_ITEMS))
if (videodatabase.GetRecentlyAddedEpisodesNav("videodb://recentlyaddedepisodes/", TVShowItems, NUM_ITEMS, hideWatched))
{
for (; i < TVShowItems.Size(); ++i)
{
Expand Down Expand Up @@ -151,7 +151,7 @@ bool CRecentlyAddedJob::UpdateVideo()
i = 0;
CFileItemList MusicVideoItems;

if (videodatabase.GetRecentlyAddedMusicVideosNav("videodb://recentlyaddedmusicvideos/", MusicVideoItems, NUM_ITEMS))
if (videodatabase.GetRecentlyAddedMusicVideosNav("videodb://recentlyaddedmusicvideos/", MusicVideoItems, NUM_ITEMS, hideWatched))
{
for (; i < MusicVideoItems.Size(); ++i)
{
Expand Down
18 changes: 15 additions & 3 deletions xbmc/video/VideoDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6596,27 +6596,39 @@ bool CVideoDatabase::GetMusicVideosNav(const CStdString& strBaseDir, CFileItemLi
return GetMusicVideosByWhere(videoUrl.ToString(), filter, items, true, sortDescription);
}

bool CVideoDatabase::GetRecentlyAddedMoviesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit)
bool CVideoDatabase::GetRecentlyAddedMoviesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit, bool hideWatched)
{
Filter filter;
filter.order = "dateAdded desc, idMovie desc";
filter.limit = PrepareSQL("%u", limit ? limit : g_advancedSettings.m_iVideoLibraryRecentlyAddedItems);

if (hideWatched)
filter.AppendWhere("playCount > 0");// only query unwatched items

return GetMoviesByWhere(strBaseDir, filter, items);
}

bool CVideoDatabase::GetRecentlyAddedEpisodesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit)
bool CVideoDatabase::GetRecentlyAddedEpisodesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit, bool hideWatched)
{
Filter filter;
filter.order = "dateAdded desc, idEpisode desc";
filter.limit = PrepareSQL("%u", limit ? limit : g_advancedSettings.m_iVideoLibraryRecentlyAddedItems);

if (hideWatched)
filter.AppendWhere("playCount > 0");// only query unwatched items

return GetEpisodesByWhere(strBaseDir, filter, items, false);
}

bool CVideoDatabase::GetRecentlyAddedMusicVideosNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit)
bool CVideoDatabase::GetRecentlyAddedMusicVideosNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit, bool hideWatched)
{
Filter filter;
filter.order = "dateAdded desc, idMVideo desc";
filter.limit = PrepareSQL("%u", limit ? limit : g_advancedSettings.m_iVideoLibraryRecentlyAddedItems);

if (hideWatched)
filter.AppendWhere("playCount > 0");// only query unwatched items

return GetMusicVideosByWhere(strBaseDir, filter, items);
}

Expand Down
6 changes: 3 additions & 3 deletions xbmc/video/VideoDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,9 @@ class CVideoDatabase : public CDatabase
bool GetEpisodesNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idShow=-1, int idSeason=-1, const SortDescription &sortDescription = SortDescription());
bool GetMusicVideosNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idArtist=-1, int idDirector=-1, int idStudio=-1, int idAlbum=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription());

bool GetRecentlyAddedMoviesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit=0);
bool GetRecentlyAddedEpisodesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit=0);
bool GetRecentlyAddedMusicVideosNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit=0);
bool GetRecentlyAddedMoviesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit=0, bool hideWatched=false);
bool GetRecentlyAddedEpisodesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit=0, bool hideWatched=false);
bool GetRecentlyAddedMusicVideosNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit=0, bool hideWatched=false);

bool HasContent();
bool HasContent(VIDEODB_CONTENT_TYPE type);
Expand Down

0 comments on commit dbf7d6a

Please sign in to comment.