本文整理汇总了C++中mpd::SongList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ SongList::insert方法的具体用法?C++ SongList::insert怎么用?C++ SongList::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpd::SongList
的用法示例。
在下文中一共展示了SongList::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSelectedSongs
MPD::SongList Browser::getSelectedSongs()
{
MPD::SongList result;
auto item_handler = [this, &result](const MPD::Item &item) {
if (item.type == itDirectory)
{
# ifndef WIN32
if (isLocal())
{
MPD::ItemList list;
GetLocalDirectory(list, item.name, true);
for (auto it = list.begin(); it != list.end(); ++it)
result.push_back(*it->song);
}
else
# endif // !WIN32
{
auto list = Mpd.GetDirectoryRecursive(item.name);
result.insert(result.end(), list.begin(), list.end());
}
}
else if (item.type == itSong)
result.push_back(*item.song);
else if (item.type == itPlaylist)
{
auto list = Mpd.GetPlaylistContent(item.name);
result.insert(result.end(), list.begin(), list.end());
}
};
for (auto it = w.begin(); it != w.end(); ++it)
if (it->isSelected())
item_handler(it->value());
// if no item is selected, add current one
if (result.empty() && !w.empty())
item_handler(w.current().value());
return result;
}
示例2: getSelectedSongs
MPD::SongList MediaLibrary::getSelectedSongs()
{
MPD::SongList result;
if (isActiveWindow(Tags))
{
auto tag_handler = [&result](const std::string &tag) {
Mpd.StartSearch(true);
Mpd.AddSearch(Config.media_lib_primary_tag, tag);
Mpd.CommitSearchSongs(vectorMoveInserter(result));
};
bool any_selected = false;
for (auto &e : Tags)
{
if (e.isSelected())
{
any_selected = true;
tag_handler(e.value().tag());
}
}
// if no item is selected, add current one
if (!any_selected && !Tags.empty())
tag_handler(Tags.current().value().tag());
}
else if (isActiveWindow(Albums))
{
bool any_selected = false;
for (auto it = Albums.begin(); it != Albums.end() && !it->isSeparator(); ++it)
{
if (it->isSelected())
{
any_selected = true;
auto &sc = it->value();
Mpd.StartSearch(true);
if (hasTwoColumns)
Mpd.AddSearch(Config.media_lib_primary_tag, sc.entry().tag());
else
Mpd.AddSearch(Config.media_lib_primary_tag,
Tags.current().value().tag());
Mpd.AddSearch(MPD_TAG_ALBUM, sc.entry().album());
Mpd.AddSearch(MPD_TAG_DATE, sc.entry().date());
size_t begin = result.size();
Mpd.CommitSearchSongs(vectorMoveInserter(result));
std::sort(result.begin()+begin, result.end(), SortSongs(false));
}
}
// if no item is selected, add songs from right column
if (!any_selected && !Albums.empty())
{
withUnfilteredMenu(Songs, [this, &result]() {
result.insert(result.end(), Songs.beginV(), Songs.endV());
});
}
}
else if (isActiveWindow(Songs))
{
for (auto it = Songs.begin(); it != Songs.end(); ++it)
if (it->isSelected())
result.push_back(it->value());
// if no item is selected, add current one
if (result.empty() && !Songs.empty())
result.push_back(Songs.current().value());
}
return result;
}