本文整理汇总了C++中CSmartPlaylist::GetWhereClause方法的典型用法代码示例。如果您正苦于以下问题:C++ CSmartPlaylist::GetWhereClause方法的具体用法?C++ CSmartPlaylist::GetWhereClause怎么用?C++ CSmartPlaylist::GetWhereClause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSmartPlaylist
的用法示例。
在下文中一共展示了CSmartPlaylist::GetWhereClause方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDirectory
bool CSmartPlaylistDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items)
{
// Load in the SmartPlaylist and get the WHERE query
CSmartPlaylist playlist;
if (!playlist.Load(strPath))
return false;
bool success = false, success2 = false;
if (playlist.GetType().Equals("music") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty())
{
CMusicDatabase db;
db.Open();
CStdString type=playlist.GetType();
if (type.IsEmpty())
type = "music";
if (playlist.GetType().Equals("mixed"))
playlist.SetType("music");
CStdString whereOrder = playlist.GetWhereClause() + " " + playlist.GetOrderClause();
success = db.GetSongsByWhere("", whereOrder, items);
db.Close();
playlist.SetType(type);
}
if (playlist.GetType().Equals("video") || playlist.GetType().Equals("mixed"))
{
CVideoDatabase db;
db.Open();
CStdString type=playlist.GetType();
if (playlist.GetType().Equals("mixed"))
playlist.SetType("video");
CStdString whereOrder = playlist.GetWhereClause() + " " + playlist.GetOrderClause();
CFileItemList items2;
success2 = db.GetMusicVideosByWhere("videodb://3/2/", whereOrder, items2);
db.Close();
items.Append(items2);
playlist.SetType(type);
}
if (playlist.GetType().Equals("mixed"))
return success || success2;
else if (playlist.GetType().Equals("video"))
return success2;
else
return success;
}
示例2: GetWhereClause
CStdString CSmartPlaylistRule::GetWhereClause(CDatabase &db, const CStdString& strType)
{
SEARCH_OPERATOR op = m_operator;
if ((strType == "tvshows" || strType == "episodes") && m_field == FIELD_YEAR)
{ // special case for premiered which is a date rather than a year
// TODO: SMARTPLAYLISTS do we really need this, or should we just make this field the premiered date and request a date?
if (op == OPERATOR_EQUALS)
op = OPERATOR_CONTAINS;
else if (op == OPERATOR_DOES_NOT_EQUAL)
op = OPERATOR_DOES_NOT_CONTAIN;
}
CStdString operatorString, negate;
CStdString parameter;
if (GetFieldType(m_field) == TEXTIN_FIELD)
{
CStdStringArray split;
StringUtils::SplitString(m_parameter, ",", split);
for (CStdStringArray::iterator it=split.begin(); it!=split.end(); ++it)
{
if (!parameter.IsEmpty())
parameter += ",";
parameter += db.PrepareSQL("'%s'", (*it).Trim().c_str());
}
parameter = " IN (" + parameter + ")";
if (op == OPERATOR_DOES_NOT_EQUAL)
negate = " NOT";
}
else
{
// the comparison piece
switch (op)
{
case OPERATOR_CONTAINS:
operatorString = " LIKE '%%%s%%'"; break;
case OPERATOR_DOES_NOT_CONTAIN:
negate = " NOT"; operatorString = " LIKE '%%%s%%'"; break;
case OPERATOR_EQUALS:
operatorString = " LIKE '%s'"; break;
case OPERATOR_DOES_NOT_EQUAL:
negate = " NOT"; operatorString = " LIKE '%s'"; break;
case OPERATOR_STARTS_WITH:
operatorString = " LIKE '%s%%'"; break;
case OPERATOR_ENDS_WITH:
operatorString = " LIKE '%%%s'"; break;
case OPERATOR_AFTER:
case OPERATOR_GREATER_THAN:
case OPERATOR_IN_THE_LAST:
operatorString = " > '%s'"; break;
case OPERATOR_BEFORE:
case OPERATOR_LESS_THAN:
case OPERATOR_NOT_IN_THE_LAST:
operatorString = " < '%s'"; break;
case OPERATOR_TRUE:
operatorString = " = 1"; break;
case OPERATOR_FALSE:
negate = " NOT "; operatorString = " = 0"; break;
default:
break;
}
parameter = db.PrepareSQL(operatorString.c_str(), m_parameter.c_str());
}
if (m_field == FIELD_LASTPLAYED || m_field == FIELD_AIRDATE)
{
if (m_operator == OPERATOR_IN_THE_LAST || m_operator == OPERATOR_NOT_IN_THE_LAST)
{ // translate time period
CDateTime date=CDateTime::GetCurrentDateTime();
CDateTimeSpan span;
span.SetFromPeriod(m_parameter);
date-=span;
parameter = db.PrepareSQL(operatorString.c_str(), date.GetAsDBDate().c_str());
}
}
else if (m_field == FIELD_TIME)
{ // translate time to seconds
CStdString seconds; seconds.Format("%i", StringUtils::TimeStringToSeconds(m_parameter));
parameter = db.PrepareSQL(operatorString.c_str(), seconds.c_str());
}
// now the query parameter
CStdString query;
if (strType == "songs")
{
if (m_field == FIELD_GENRE)
query = negate + " ((strGenre" + parameter + ") or idSong IN (select idSong from genre,exgenresong where exgenresong.idGenre = genre.idGenre and genre.strGenre" + parameter + "))";
else if (m_field == FIELD_ARTIST)
query = negate + " ((strArtist" + parameter + ") or idSong IN (select idSong from artist,exartistsong where exartistsong.idArtist = artist.idArtist and artist.strArtist" + parameter + "))";
else if (m_field == FIELD_ALBUMARTIST)
query = negate + " (idalbum in (select idalbum from artist,album where album.idArtist=artist.idArtist and artist.strArtist" + parameter + ") or idalbum in (select idalbum from artist,exartistalbum where exartistalbum.idArtist = artist.idArtist and artist.strArtist" + parameter + "))";
else if (m_field == FIELD_LASTPLAYED && (m_operator == OPERATOR_LESS_THAN || m_operator == OPERATOR_BEFORE || m_operator == OPERATOR_NOT_IN_THE_LAST))
query = "lastPlayed is NULL or lastPlayed" + parameter;
}
else if (strType == "albums")
{
if (m_field == FIELD_GENRE)
query = negate + " (idAlbum in (select song.idAlbum from song join genre on song.idGenre=genre.idGenre where genre.strGenre" + parameter + ") or "
"idAlbum in (select song.idAlbum from song join exgenresong on song.idSong=exgenresong.idSong join genre on exgenresong.idGenre=genre.idGenre where genre.strGenre" + parameter + "))";
else if (m_field == FIELD_ARTIST)
query = negate + " (idAlbum in (select song.idAlbum from song join artist on song.idArtist=artist.idArtist where artist.strArtist" + parameter + ") or "
//.........这里部分代码省略.........
示例3: GetDirectory
bool CSmartPlaylistDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items)
{
// Load in the SmartPlaylist and get the WHERE query
CSmartPlaylist playlist;
if (!playlist.Load(strPath))
return false;
bool success = false, success2 = false;
if (playlist.GetType().Equals("tvshows"))
{
CVideoDatabase db;
db.Open();
CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db);
success = db.GetTvShowsByWhere("videodb://2/2/", whereOrder, items);
items.SetContent("tvshows");
db.Close();
}
else if (playlist.GetType().Equals("episodes"))
{
CVideoDatabase db;
db.Open();
CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db);
success = db.GetEpisodesByWhere("videodb://2/2/", whereOrder, items);
items.SetContent("episodes");
db.Close();
}
else if (playlist.GetType().Equals("movies"))
{
CVideoDatabase db;
db.Open();
success = db.GetMoviesByWhere("videodb://1/2/", playlist.GetWhereClause(db), playlist.GetOrderClause(db), items, true);
items.SetContent("movies");
db.Close();
}
else if (playlist.GetType().Equals("albums"))
{
CMusicDatabase db;
db.Open();
success = db.GetAlbumsByWhere("musicdb://3/", playlist.GetWhereClause(db), playlist.GetOrderClause(db), items);
items.SetContent("albums");
db.Close();
}
if (playlist.GetType().Equals("songs") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty())
{
CMusicDatabase db;
db.Open();
CStdString type=playlist.GetType();
if (type.IsEmpty())
type = "songs";
if (playlist.GetType().Equals("mixed"))
playlist.SetType("songs");
CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db);
success = db.GetSongsByWhere("", whereOrder, items);
items.SetContent("songs");
db.Close();
playlist.SetType(type);
}
if (playlist.GetType().Equals("musicvideos") || playlist.GetType().Equals("mixed"))
{
CVideoDatabase db;
db.Open();
CStdString type=playlist.GetType();
if (playlist.GetType().Equals("mixed"))
playlist.SetType("musicvideos");
CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db);
CFileItemList items2;
success2 = db.GetMusicVideosByWhere("videodb://3/2/", whereOrder, items2, false); // TODO: SMARTPLAYLISTS Don't check locks???
db.Close();
items.Append(items2);
if (items2.Size())
items.SetContent("musicvideos");
playlist.SetType(type);
}
// go through and set the playlist order
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
item->m_iprogramCount = i; // hack for playlist order
}
if (playlist.GetType().Equals("mixed"))
return success || success2;
else if (playlist.GetType().Equals("musicvideos"))
return success2;
else
return success;
}
示例4: Enable
bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUSIC*/, const CStdString& strXspPath /*= ""*/)
{
// Filter using our PartyMode xml file
CSmartPlaylist playlist;
CStdString partyModePath;
bool playlistLoaded;
m_bIsVideo = context == PARTYMODECONTEXT_VIDEO;
if (!strXspPath.IsEmpty()) //if a path to a smartplaylist is supplied use it
partyModePath = strXspPath;
else if (m_bIsVideo)
partyModePath = g_settings.GetUserDataItem("PartyMode-Video.xsp");
else
partyModePath = g_settings.GetUserDataItem("PartyMode.xsp");
playlistLoaded=playlist.Load(partyModePath);
if ( playlistLoaded )
{
m_type = playlist.GetType();
if (context == PARTYMODECONTEXT_UNKNOWN)
{
//get it from the xsp file
m_bIsVideo = (m_type.Equals("video") || m_type.Equals("musicvideos") || m_type.Equals("mixed"));
}
if (m_type.Equals("mixed"))
playlist.SetType("songs");
if (m_type.Equals("mixed"))
playlist.SetType("video");
playlist.SetType(m_type);
}
else
{
m_strCurrentFilterMusic.Empty();
m_strCurrentFilterVideo.Empty();
m_type = m_bIsVideo ? "musicvideos" : "songs";
}
CGUIDialogProgress* pDialog = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
int iHeading = (m_bIsVideo ? 20250 : 20121);
int iLine0 = (m_bIsVideo ? 20251 : 20123);
pDialog->SetHeading(iHeading);
pDialog->SetLine(0, iLine0);
pDialog->SetLine(1, "");
pDialog->SetLine(2, "");
pDialog->StartModal();
ClearState();
unsigned int time = XbmcThreads::SystemClockMillis();
vector< pair<int,int> > songIDs;
if (m_type.Equals("songs") || m_type.Equals("mixed"))
{
CMusicDatabase db;
if (db.Open())
{
set<CStdString> playlists;
if ( playlistLoaded )
m_strCurrentFilterMusic = playlist.GetWhereClause(db, playlists);
CLog::Log(LOGINFO, "PARTY MODE MANAGER: Registering filter:[%s]", m_strCurrentFilterMusic.c_str());
m_iMatchingSongs = (int)db.GetSongIDs(m_strCurrentFilterMusic, songIDs);
if (m_iMatchingSongs < 1 && m_type.Equals("songs"))
{
pDialog->Close();
db.Close();
OnError(16031, (CStdString)"Party mode found no matching songs. Aborting.");
return false;
}
}
else
{
pDialog->Close();
OnError(16033, (CStdString)"Party mode could not open database. Aborting.");
return false;
}
db.Close();
}
if (m_type.Equals("musicvideos") || m_type.Equals("mixed"))
{
vector< pair<int,int> > songIDs2;
CVideoDatabase db;
if (db.Open())
{
set<CStdString> playlists;
if ( playlistLoaded )
m_strCurrentFilterVideo = playlist.GetWhereClause(db, playlists);
CLog::Log(LOGINFO, "PARTY MODE MANAGER: Registering filter:[%s]", m_strCurrentFilterVideo.c_str());
m_iMatchingSongs += (int)db.GetMusicVideoIDs(m_strCurrentFilterVideo, songIDs2);
if (m_iMatchingSongs < 1)
{
pDialog->Close();
db.Close();
OnError(16031, (CStdString)"Party mode found no matching songs. Aborting.");
return false;
}
//.........这里部分代码省略.........
示例5: GetItems
int CGUIDialogMediaFilter::GetItems(const Filter &filter, std::vector<std::string> &items, bool countOnly /* = false */)
{
CFileItemList selectItems;
// remove the rule for the field of the filter we want to retrieve items for
CSmartPlaylist tmpFilter = *m_filter;
for (CDatabaseQueryRules::iterator rule = tmpFilter.m_ruleCombination.m_rules.begin(); rule != tmpFilter.m_ruleCombination.m_rules.end(); rule++)
{
if ((*rule)->m_field == filter.field)
{
tmpFilter.m_ruleCombination.m_rules.erase(rule);
break;
}
}
if (m_mediaType == "movies" || m_mediaType == "tvshows" || m_mediaType == "episodes" || m_mediaType == "musicvideos")
{
CVideoDatabase videodb;
if (!videodb.Open())
return -1;
std::set<std::string> playlists;
CDatabase::Filter dbfilter;
dbfilter.where = tmpFilter.GetWhereClause(videodb, playlists);
VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES;
if (m_mediaType == "tvshows")
type = VIDEODB_CONTENT_TVSHOWS;
else if (m_mediaType == "episodes")
type = VIDEODB_CONTENT_EPISODES;
else if (m_mediaType == "musicvideos")
type = VIDEODB_CONTENT_MUSICVIDEOS;
if (filter.field == FieldGenre)
videodb.GetGenresNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly);
else if (filter.field == FieldActor || filter.field == FieldArtist)
videodb.GetActorsNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly);
else if (filter.field == FieldDirector)
videodb.GetDirectorsNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly);
else if (filter.field == FieldStudio)
videodb.GetStudiosNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly);
else if (filter.field == FieldAlbum)
videodb.GetMusicVideoAlbumsNav(m_dbUrl->ToString(), selectItems, -1, dbfilter, countOnly);
else if (filter.field == FieldTag)
videodb.GetTagsNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly);
}
else if (m_mediaType == "artists" || m_mediaType == "albums" || m_mediaType == "songs")
{
CMusicDatabase musicdb;
if (!musicdb.Open())
return -1;
std::set<std::string> playlists;
CDatabase::Filter dbfilter;
dbfilter.where = tmpFilter.GetWhereClause(musicdb, playlists);
if (filter.field == FieldGenre)
musicdb.GetGenresNav(m_dbUrl->ToString(), selectItems, dbfilter, countOnly);
else if (filter.field == FieldArtist)
musicdb.GetArtistsNav(m_dbUrl->ToString(), selectItems, m_mediaType == "albums", -1, -1, -1, dbfilter, SortDescription(), countOnly);
else if (filter.field == FieldAlbum)
musicdb.GetAlbumsNav(m_dbUrl->ToString(), selectItems, -1, -1, dbfilter, SortDescription(), countOnly);
else if (filter.field == FieldAlbumType)
musicdb.GetAlbumTypesNav(m_dbUrl->ToString(), selectItems, dbfilter, countOnly);
else if (filter.field == FieldMusicLabel)
musicdb.GetMusicLabelsNav(m_dbUrl->ToString(), selectItems, dbfilter, countOnly);
}
int size = selectItems.Size();
if (size <= 0)
return 0;
if (countOnly)
{
if (size == 1 && selectItems.Get(0)->HasProperty("total"))
return (int)selectItems.Get(0)->GetProperty("total").asInteger();
return 0;
}
// sort the items
selectItems.Sort(SortByLabel, SortOrderAscending);
for (int index = 0; index < size; ++index)
items.push_back(selectItems.Get(index)->GetLabel());
return items.size();
}
示例6: GetDirectory
bool CSmartPlaylistDirectory::GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items)
{
bool success = false, success2 = false;
std::set<CStdString> playlists;
if (playlist.GetType().Equals("tvshows"))
{
CVideoDatabase db;
db.Open();
CStdString whereOrder = playlist.GetWhereClause(db, playlists) + " " + playlist.GetOrderClause(db);
success = db.GetTvShowsByWhere("videodb://2/2/", whereOrder, items);
items.SetContent("tvshows");
db.Close();
}
else if (playlist.GetType().Equals("episodes"))
{
CVideoDatabase db;
db.Open();
CStdString whereOrder = playlist.GetWhereClause(db, playlists) + " " + playlist.GetOrderClause(db);
success = db.GetEpisodesByWhere("videodb://2/2/", whereOrder, items);
items.SetContent("episodes");
db.Close();
}
else if (playlist.GetType().Equals("movies"))
{
CVideoDatabase db;
db.Open();
success = db.GetMoviesByWhere("videodb://1/2/", playlist.GetWhereClause(db, playlists), playlist.GetOrderClause(db), items, true);
items.SetContent("movies");
db.Close();
}
else if (playlist.GetType().Equals("albums"))
{
CMusicDatabase db;
db.Open();
success = db.GetAlbumsByWhere("musicdb://3/", playlist.GetWhereClause(db, playlists), playlist.GetOrderClause(db), items);
items.SetContent("albums");
db.Close();
}
if (playlist.GetType().Equals("songs") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty())
{
CMusicDatabase db;
db.Open();
CStdString whereOrder;
if (playlist.GetType().IsEmpty() || playlist.GetType().Equals("mixed"))
{
CSmartPlaylist songPlaylist(playlist);
songPlaylist.SetType("songs");
whereOrder = songPlaylist.GetWhereClause(db, playlists) + " " + songPlaylist.GetOrderClause(db);
}
else
whereOrder = playlist.GetWhereClause(db, playlists) + " " + playlist.GetOrderClause(db);
success = db.GetSongsByWhere("", whereOrder, items);
items.SetContent("songs");
db.Close();
}
if (playlist.GetType().Equals("musicvideos") || playlist.GetType().Equals("mixed"))
{
CVideoDatabase db;
db.Open();
CStdString whereOrder;
if (playlist.GetType().Equals("mixed"))
{
CSmartPlaylist mvidPlaylist(playlist);
mvidPlaylist.SetType("musicvideos");
whereOrder = mvidPlaylist.GetWhereClause(db, playlists) + " " + mvidPlaylist.GetOrderClause(db);
}
else
whereOrder = playlist.GetWhereClause(db, playlists) + " " + playlist.GetOrderClause(db);
CFileItemList items2;
success2 = db.GetMusicVideosByWhere("videodb://3/2/", whereOrder, items2, false); // TODO: SMARTPLAYLISTS Don't check locks???
db.Close();
items.Append(items2);
if (items2.Size())
items.SetContent("musicvideos");
}
items.SetLabel(playlist.GetName());
// go through and set the playlist order
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
item->m_iprogramCount = i; // hack for playlist order
}
if (playlist.GetType().Equals("mixed"))
return success || success2;
else if (playlist.GetType().Equals("musicvideos"))
return success2;
else
return success;
}