本文整理汇总了C++中PlaylistModel类的典型用法代码示例。如果您正苦于以下问题:C++ PlaylistModel类的具体用法?C++ PlaylistModel怎么用?C++ PlaylistModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlaylistModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: g_regex_new
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: PlaylistView
bool
PlaylistManager::show( const Tomahawk::album_ptr& album )
{
PlaylistView* view;
if ( !m_albumViews.contains( album ) )
{
view = new PlaylistView();
PlaylistModel* model = new PlaylistModel();
view->setModel( model );
view->setFrameShape( QFrame::NoFrame );
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
model->append( album );
m_albumViews.insert( album, view );
}
else
{
view = m_albumViews.value( album );
}
setPage( view );
emit numSourcesChanged( 1 );
return true;
}
示例3: index
void FilterPlaylistModel::setCurrentIndex(int presentIndex)
{
QModelIndex i = index(presentIndex, 0);
PlaylistModel *playlistmodel = static_cast<PlaylistModel*>(sourceModel());
playlistmodel->setCurrentIndex(mapToSource(i).row());
emit currentIndexChanged();
}
示例4: 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;
}
}
示例5: AnimatedWidget
QueueView::QueueView( AnimatedSplitter* parent )
: AnimatedWidget( parent )
, ui( new Ui::QueueView )
, m_dragTimer( 0 )
{
ui->setupUi( this );
TomahawkUtils::unmarginLayout( layout() );
setContentsMargins( 0, 0, 0, 0 );
setHiddenSize( QSize( 0, 22 ) );
ui->queue->setProxyModel( new QueueProxyModel( ui->queue ) );
ui->queue->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Ignored );
PlaylistModel* queueModel = new PlaylistModel( this );
queueModel->setStyle( PlaylistModel::Short );
queueModel->finishLoading();
ui->queue->setPlaylistModel( queueModel );
queueModel->setReadOnly( false );
// ui->queue->setEmptyTip( tr( "The queue is currently empty. Drop something to enqueue it!" ) );
ui->queue->setEmptyTip( QString() );
connect( queueModel, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( updateLabel() ) );
connect( ui->toggleButton, SIGNAL( clicked() ), SLOT( show() ) );
connect( this, SIGNAL( animationFinished() ), SLOT( onAnimationFinished() ) );
ui->toggleButton->installEventFilter( this );
ui->toggleButton->setCursor( Qt::PointingHandCursor );
}
示例6: 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());
}
示例7: PlaylistView
PlaylistView*
ViewManager::createPageForPlaylist( const playlist_ptr& pl )
{
PlaylistView* view = new PlaylistView();
PlaylistModel* model = new PlaylistModel();
view->setPlaylistModel( model );
model->loadPlaylist( pl );
pl->resolve();
m_playlistViews.insert( pl, view );
return view;
}
示例8: PlaylistView
PlaylistView*
ViewManager::createPageForPlaylist( const playlist_ptr& pl )
{
PlaylistView* view = new PlaylistView();
PlaylistModel* model = new PlaylistModel();
view->setPlaylistModel( model );
model->loadPlaylist( pl );
view->setFrameShape( QFrame::NoFrame );
view->setAttribute( Qt::WA_MacShowFocusRect, 0 );
pl->resolve();
m_playlistViews.insert( pl, view );
return view;
}
示例9: PlaylistViewPage
PlaylistViewPage*
ViewManager::createPageForPlaylist( const playlist_ptr& playlist )
{
PlaylistViewPage* view = new PlaylistViewPage();
PlaylistModel* model = new PlaylistModel();
// We need to set the model on the view before loading the playlist, so spinners & co are connected
view->view()->trackView()->setPlayableModel( model );
model->loadPlaylist( playlist );
playlist->resolve();
return view;
}
示例10: FlexibleView
FlexibleView*
ViewManager::createPageForPlaylist( const playlist_ptr& playlist )
{
FlexibleView* view = new FlexibleView();
PlaylistModel* model = new PlaylistModel();
PlaylistView* pv = new PlaylistView();
pv->setPlaylistModel( model );
view->setDetailedView( pv );
view->setPixmap( pv->pixmap() );
model->loadPlaylist( playlist );
view->setPlayableModel( model );
playlist->resolve();
return view;
}
示例11: openContainingFolder
void PlaylistView::openContainingFolder()
{
PlaylistModel *playlistModel = dynamic_cast<PlaylistModel *>(this->model());
if (playlistModel == nullptr)
{
return;
}
QModelIndex i = this->currentIndex();
if (i.isValid())
{
int row = i.row();
const Song *s = playlistModel->getPlaylist()->getSong(row);
QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromStdString(::mydirname(s->Filename))));
}
}
示例12: 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();
}
}
示例13: FlexibleView
FlexibleView*
ViewManager::createPageForPlaylist( const playlist_ptr& playlist )
{
FlexibleView* view = new FlexibleView();
PlaylistModel* model = new PlaylistModel();
PlaylistView* pv = new PlaylistView();
view->setDetailedView( pv );
view->setPixmap( pv->pixmap() );
// We need to set the model on the view before loading the playlist, so spinners & co are connected
view->setPlaylistModel( model );
pv->setPlaylistModel( model );
model->loadPlaylist( playlist );
playlist->resolve();
return view;
}
示例14: showInspector
void PlaylistView::showInspector()
{
PlaylistModel *playlistModel = dynamic_cast<PlaylistModel *>(this->model());
if (playlistModel == nullptr)
{
return;
}
QModelIndex i = this->currentIndex();
if (i.isValid())
{
int row = i.row();
const Song *s = playlistModel->getPlaylist()->getSong(row);
SongInspector *insp = new SongInspector(s, this);
insp->setAttribute(Qt::WA_DeleteOnClose);
insp->show();
}
}
示例15: 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;
}