Permalink
Browse files

videodb/musicdb: remove the "filter" and "xsp" options if they don't …

…match the currently retrieved item type
  • Loading branch information...
1 parent cbfb997 commit 7ce8dd9d43e8f08df8c73957394c93f43bf7bb81 @Montellese committed Jul 24, 2012
@@ -135,7 +135,7 @@ class CDatabase
*/
bool CommitInsertQueries();
- virtual bool GetFilter(const CDbUrl &dbUrl, Filter &filter) { return true; }
+ virtual bool GetFilter(CDbUrl &dbUrl, Filter &filter) { return true; }
virtual bool BuildSQL(const CStdString &strBaseDir, const CStdString &strQuery, Filter &filter, CStdString &strSQL, CDbUrl &dbUrl);
protected:
@@ -5262,7 +5262,7 @@ string CMusicDatabase::GetArtistArtForItem(int mediaId, const string &mediaType,
return GetSingleValue(query, m_pDS2);
}
-bool CMusicDatabase::GetFilter(const CDbUrl &musicUrl, Filter &filter)
+bool CMusicDatabase::GetFilter(CDbUrl &musicUrl, Filter &filter)
{
if (!musicUrl.IsValid())
return false;
@@ -5450,8 +5450,15 @@ bool CMusicDatabase::GetFilter(const CDbUrl &musicUrl, Filter &filter)
if (!xspFilter.LoadFromJson(option->second.asString()))
return false;
- std::set<CStdString> playlists;
- filter.AppendWhere(xspFilter.GetWhereClause(*this, playlists));
+ // check if the filter playlist matches the item type
+ if (xspFilter.GetType() == type)
+ {
+ std::set<CStdString> playlists;
+ filter.AppendWhere(xspFilter.GetWhereClause(*this, playlists));
+ }
+ // remove the filter if it doesn't match the item type
+ else
+ musicUrl.AddOption("filter", "");
}
return true;
@@ -272,7 +272,7 @@ class CMusicDatabase : public CDatabase
*/
std::string GetArtistArtForItem(int mediaId, const std::string &mediaType, const std::string &artType);
- virtual bool GetFilter(const CDbUrl &musicUrl, Filter &filter);
+ virtual bool GetFilter(CDbUrl &musicUrl, Filter &filter);
protected:
std::map<CStdString, int> m_artistCache;
@@ -8982,7 +8982,7 @@ bool CVideoDatabase::GetItemsForPath(const CStdString &content, const CStdString
return items.Size() > 0;
}
-bool CVideoDatabase::GetFilter(const CDbUrl &videoUrl, Filter &filter)
+bool CVideoDatabase::GetFilter(CDbUrl &videoUrl, Filter &filter)
{
if (!videoUrl.IsValid())
return false;
@@ -9407,8 +9407,15 @@ bool CVideoDatabase::GetFilter(const CDbUrl &videoUrl, Filter &filter)
if (!xspFilter.LoadFromJson(option->second.asString()))
return false;
- std::set<CStdString> playlists;
- filter.AppendWhere(xspFilter.GetWhereClause(*this, playlists));
+ // check if the filter playlist matches the item type
+ if (xspFilter.GetType() == itemType)
+ {
+ std::set<CStdString> playlists;
+ filter.AppendWhere(xspFilter.GetWhereClause(*this, playlists));
+ }
+ // remove the filter if it doesn't match the item type
+ else
+ videoUrl.AddOption("filter", "");
}
return true;
@@ -686,7 +686,7 @@ class CVideoDatabase : public CDatabase
void AddTagToItem(int idItem, int idTag, const std::string &type);
void RemoveTagFromItem(int idItem, int idTag, const std::string &type);
- virtual bool GetFilter(const CDbUrl &videoUrl, Filter &filter);
+ virtual bool GetFilter(CDbUrl &videoUrl, Filter &filter);
protected:
int GetMovieId(const CStdString& strFilenameAndPath);

0 comments on commit 7ce8dd9

Please sign in to comment.