本文整理汇总了C++中PlaylistModel::song方法的典型用法代码示例。如果您正苦于以下问题:C++ PlaylistModel::song方法的具体用法?C++ PlaylistModel::song怎么用?C++ PlaylistModel::song使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlaylistModel
的用法示例。
在下文中一共展示了PlaylistModel::song方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectSongsByRegExp
void PlaylistView::selectSongsByRegExp()
{
// We can't use selectItemsByRegExp here, because it matches ListModelItemData::text,
// but for PlaylistModel its value doesn't correspond to what actually displyed, as
// it uses SongDisplayFormatParser for this job.
auto resultCallback = [this](const std::string& pattern, LineEdit::Result result)
{
if (result == LineEdit::Result::Accepted) {
GRegex *regex = g_regex_new(pattern.c_str(), G_REGEX_OPTIMIZE,
(GRegexMatchFlags)0, nullptr);
if (!regex)
return;
PlaylistModel *plsModel = static_cast<PlaylistModel*>(model());
PlaylistItemDelegate *delegate = static_cast<PlaylistItemDelegate*>(itemDelegate());
selectItems([plsModel, delegate, regex](int item){
return delegate->matchFormattedString(plsModel->song(item), regex);
});
g_regex_unref(regex);
StatusArea::showMessage("%d items selected", selectedItems().size());
}
};
StatusArea::askQuestion("Select items: ", resultCallback, ".*");
}
示例2: unselectSongsByRegExp
void PlaylistView::unselectSongsByRegExp()
{
// The same story here...
auto resultCallback = [this](const std::string& pattern, LineEdit::Result result)
{
if (result == LineEdit::Result::Accepted) {
GRegex *regex = g_regex_new(pattern.c_str(), G_REGEX_OPTIMIZE,
(GRegexMatchFlags)0, nullptr);
if (!regex)
return;
PlaylistModel *plsModel = static_cast<PlaylistModel*>(model());
PlaylistItemDelegate *delegate = static_cast<PlaylistItemDelegate*>(itemDelegate());
unselectItems([plsModel, delegate, regex](int item){
return delegate->matchFormattedString(plsModel->song(item), regex);
});
g_regex_unref(regex);
StatusArea::showMessage("%d items selected", selectedItems().size());
}
};
StatusArea::askQuestion("Unselect items: ", resultCallback, ".*");
}
示例3: keyPressedEvent
void PlaylistView::keyPressedEvent(const KeyEvent& keyEvent)
{
PlaylistModel *plsModel = static_cast<PlaylistModel*>(model());
switch (keyEvent.key()) {
case Hotkeys::PlaylistView::RemoveEntry:
removeSelectedSongs();
break;
case Hotkeys::PlaylistView::ClearPlaylist:
m_xmmsClient->playlistClear(plsModel->playlist());
break;
case Hotkeys::PlaylistView::ShufflePlaylist:
m_xmmsClient->playlistShuffle(plsModel->playlist());
break;
case Hotkeys::PlaylistView::GoToCurrentlyPlayingSong:
setCurrentItem(plsModel->currentSongItem());
break;
case Hotkeys::PlaylistView::MoveSelectedSongs:
moveSelectedSongs();
break;
case Hotkeys::PlaylistView::AddFileOrDirectory:
{
auto resultCallback = [this](const std::string& path, LineEdit::Result result)
{
if (result == LineEdit::Result::Accepted)
addPath(path);
};
StatusArea::askQuestion("Add path: ", resultCallback);
break;
}
case Hotkeys::PlaylistView::AddUrl:
{
auto resultCallback = [this](const std::string& url, LineEdit::Result result)
{
if (result == LineEdit::Result::Accepted)
addUrl(url);
};
StatusArea::askQuestion("Add url: ", resultCallback);
break;
}
case Hotkeys::PlaylistView::ShowSongInfo:
if (plsModel->itemsCount() && !isCurrentItemHidden()) {
int id = plsModel->song(currentItem()).id();
if (id > 0)
showSongInfo(id);
}
break;
case '+': // Select be regexp
selectSongsByRegExp();
break;
case '\\': // Unselect be regexp
unselectSongsByRegExp();
break;
default: ListViewAppIntegrated::keyPressedEvent(keyEvent);
}
}