本文整理汇总了C++中PlaylistModel::playlist方法的典型用法代码示例。如果您正苦于以下问题:C++ PlaylistModel::playlist方法的具体用法?C++ PlaylistModel::playlist怎么用?C++ PlaylistModel::playlist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlaylistModel
的用法示例。
在下文中一共展示了PlaylistModel::playlist方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addFile
void PlaylistView::addFile(const std::string& path)
{
PlaylistModel *plsModel = static_cast<PlaylistModel*>(model());
const std::string::size_type slashPos = path.rfind('/');
const std::string fileName = slashPos != std::string::npos
? path.substr(slashPos + 1)
: path;
const Utils::FileType fileType = Utils::getFileType(path);
switch (fileType) {
case Utils::FileType::Media:
m_xmmsClient->playlistAddUrl(plsModel->playlist(),
std::string("file://").append(path));
StatusArea::showMessage("Adding \"%s\" file to \"%s\" playlist",
fileName, plsModel->playlist());
break;
case Utils::FileType::Playlist:
m_xmmsClient->playlistAddPlaylistFile(plsModel->playlist(),
std::string("file://").append(path));
StatusArea::showMessage("Adding \"%s\" playlist to \"%s\" playlist",
fileName, plsModel->playlist());
break;
case Utils::FileType::Unknown:
StatusArea::showMessage("Unknown file type!");
break;
}
}
示例2: addUrl
void PlaylistView::addUrl(const std::string& url)
{
PlaylistModel *plsModel = static_cast<PlaylistModel*>(model());
m_xmmsClient->playlistAddUrl(plsModel->playlist(), url);
// FIXME: Url may be too long to display
StatusArea::showMessage("Adding \"%s\" to \"%s\" playlist", url, plsModel->playlist());
}
示例3: if
playlist_ptr
ViewManager::playlistForPage( ViewPage* page ) const
{
playlist_ptr p;
PlaylistViewPage* fv = dynamic_cast< PlaylistViewPage* >( page );
if ( fv && fv->view()->trackView()->model() )
{
PlaylistModel* m = dynamic_cast< PlaylistModel* >( fv->view()->trackView()->model() );
if ( m && m->playlist() )
{
p = m->playlist();
}
}
else if ( dynamic_cast< DynamicWidget* >( page ) )
p = dynamic_cast< DynamicWidget* >( page )->playlist();
return p;
}
示例4: removeSelectedSongs
void PlaylistView::removeSelectedSongs()
{
PlaylistModel *plsModel = static_cast<PlaylistModel*>(model());
if (plsModel->itemsCount() && !isCurrentItemHidden()) {
// Actually we don't have to make copy of selectedItems, since removeEntry
// doesn't modify it immediately, but this is not obvious and may lead to
// problems in the future.
const std::vector<int> selectedSongs = selectedItems();
if (!selectedSongs.empty()) {
assert(std::is_sorted(selectedSongs.begin(), selectedSongs.end()));
std::for_each(selectedSongs.rbegin(), selectedSongs.rend(), [&](int item){
m_xmmsClient->playlistRemoveEntry(plsModel->playlist(), item);
});
} else {
m_xmmsClient->playlistRemoveEntry(plsModel->playlist(), currentItem());
}
showCurrentItem();
}
}
示例5: moveSelectedSongs
void PlaylistView::moveSelectedSongs()
{
PlaylistModel *plsModel = static_cast<PlaylistModel*>(model());
const std::vector<int> selectedSongs = selectedItems();
assert(std::is_sorted(selectedSongs.begin(), selectedSongs.end()));
if (isCurrentItemHidden() || selectedSongs.empty())
return;
const int moveTo = currentItem();
auto it = std::lower_bound(selectedSongs.begin(), selectedSongs.end(), moveTo);
int to = moveTo;
for (size_t i = it - selectedSongs.begin(); i < selectedSongs.size(); ++i, ++to) {
m_xmmsClient->playlistMoveEntry(plsModel->playlist(), selectedSongs[i], to);
}
to = it == selectedSongs.end() ? moveTo : moveTo - 1;
for (ptrdiff_t i = it - selectedSongs.begin() - 1; i >= 0; --i, --to) {
m_xmmsClient->playlistMoveEntry(plsModel->playlist(), selectedSongs[i], to);
}
}
示例6: addPath
void PlaylistView::addPath(const std::string& path)
{
// TODO: Introduce FileInfo class instead of using glib functions,
// maybe simple stat call wrapper
if (!g_file_test(path.c_str(), G_FILE_TEST_EXISTS)) {
StatusArea::showMessage("File doesn't exist!");
return;
}
if (g_file_test(path.c_str(), G_FILE_TEST_IS_REGULAR)) {
addFile(path);
} else if (g_file_test(path.c_str(), G_FILE_TEST_IS_DIR)) {
PlaylistModel *plsModel = static_cast<PlaylistModel*>(model());
m_xmmsClient->playlistAddRecursive(plsModel->playlist(),
std::string("file://").append(path));
// FIXME: Path may be too long to display
StatusArea::showMessage("Adding \"%s\" directory to \"%s\" playlist",
path, plsModel->playlist());
} else {
StatusArea::showMessage("File is neither a directory nor regular file!");
}
}
示例7: 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);
}
}
示例8: onItemEntered
void PlaylistView::onItemEntered(int item)
{
PlaylistModel *plsModel = static_cast<PlaylistModel*>(model());
m_xmmsClient->playlistPlayItem(plsModel->playlist(), item);
}