本文整理汇总了C++中PlayableItem::query方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayableItem::query方法的具体用法?C++ PlayableItem::query怎么用?C++ PlayableItem::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayableItem
的用法示例。
在下文中一共展示了PlayableItem::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
GridItemDelegate::onPlayClicked( const QPersistentModelIndex& index )
{
QPoint pos = m_playButton[ index ]->pos();
clearButtons();
AnimatedSpinner* spinner = new AnimatedSpinner( m_view );
spinner->setAutoCenter( false );
spinner->fadeIn();
spinner->move( pos );
spinner->setFocusPolicy( Qt::NoFocus );
spinner->installEventFilter( this );
m_spinner[ index ] = spinner;
PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
NewClosure( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ),
const_cast<GridItemDelegate*>(this), SLOT( onPlaybackStarted( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
if ( item )
{
if ( !item->query().isNull() )
AudioEngine::instance()->playItem( m_model->playlistInterface(), item->query() );
else if ( !item->album().isNull() )
AudioEngine::instance()->playItem( item->album() );
else if ( !item->artist().isNull() )
AudioEngine::instance()->playItem( item->artist() );
}
}
示例2: indexAt
void
TreeView::mousePressEvent( QMouseEvent* event )
{
QTreeView::mousePressEvent( event );
if ( !m_model || m_proxyModel->style() != PlayableProxyModel::Collection )
return;
QModelIndex idx = indexAt( event->pos() );
if ( event->pos().x() > header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) - 16 &&
event->pos().x() < header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) )
{
PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( idx ) );
if ( item->query().isNull() )
return;
switch ( idx.column() )
{
case 0:
{
ViewManager::instance()->show( item->query()->displayQuery() );
break;
}
default:
break;
}
}
}
示例3: itemFromIndex
bool
PlayableProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
{
PlayableItem* pi = itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
if ( !pi )
return false;
if ( m_maxVisibleItems >= 0 && sourceRow > m_maxVisibleItems - 1 )
return false;
if ( m_hideDupeItems )
{
for ( int i = 0; i < sourceRow; i++ )
{
PlayableItem* di = itemFromIndex( sourceModel()->index( i, 0, sourceParent ) );
if ( !di )
continue;
bool b = ( pi->query() && pi->query()->equals( di->query() ) ) ||
( pi->album() && pi->album() == di->album() ) ||
( pi->artist() && pi->artist()->name() == di->artist()->name() );
if ( b && filterAcceptsRow( i, sourceParent ) )
return false;
}
}
if ( pi->query() )
{
const Tomahawk::query_ptr& q = pi->query()->displayQuery();
if ( q.isNull() ) // uh oh? filter out invalid queries i guess
return false;
Tomahawk::result_ptr r;
if ( q->numResults() )
r = q->results().first();
if ( !m_showOfflineResults && ( r.isNull() || !r->isOnline() ) )
return false;
if ( filterRegExp().isEmpty() )
return true;
QStringList sl = filterRegExp().pattern().split( " ", QString::SkipEmptyParts );
foreach( QString s, sl )
{
s = s.toLower();
if ( !q->artist().toLower().contains( s ) &&
!q->album().toLower().contains( s ) &&
!q->track().toLower().contains( s ) )
{
return false;
}
}
}
示例4: query_ptr
Tomahawk::query_ptr
PlayableProxyModelPlaylistInterface::queryAt( qint64 index ) const
{
if ( m_proxyModel.isNull() )
return query_ptr();
PlayableItem* item = reinterpret_cast<PlayableItem*>( (void*)index );
if ( item && item->query() )
return item->query();
return query_ptr();
}
示例5: result_ptr
Tomahawk::result_ptr
PlayableProxyModelPlaylistInterface::currentItem() const
{
if ( m_proxyModel.isNull() )
return Tomahawk::result_ptr();
PlayableProxyModel* proxyModel = m_proxyModel.data();
PlayableItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->currentIndex() ) );
if ( item && !item->query().isNull() && item->query()->playable() )
return item->query()->results().at( 0 );
return Tomahawk::result_ptr();
}
示例6: querySelected
void
TrackView::currentChanged( const QModelIndex& current, const QModelIndex& previous )
{
QTreeView::currentChanged( current, previous );
PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( current ) );
if ( item && item->query() )
{
emit querySelected( item->query() );
}
else
{
emit querySelected( query_ptr() );
}
}
示例7: NewClosure
void
TrackView::startAutoPlay( const QModelIndex& index )
{
if ( tryToPlayItem( index ) )
return;
// item isn't playable but still resolving
PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
if ( item && !item->query().isNull() && !item->query()->resolvingFinished() )
{
m_autoPlaying = item->query(); // So we can kill it if user starts autoplaying this playlist again
NewClosure( item->query().data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( autoPlayResolveFinished( Tomahawk::query_ptr, int ) ),
item->query(), index.row() );
return;
}
示例8: index
void
QueueProxyModel::onPlaybackStarted( const Tomahawk::result_ptr& result )
{
for ( int i = 0; i < rowCount(); i++ )
{
QModelIndex idx = index( i, 0 );
PlayableItem* item = itemFromIndex( mapToSource( idx ) );
if ( item && item->query() && ( item->query()->results().contains( result ) ||
item->query()->track()->equals( result->track() ) ) )
{
removeIndex( idx );
if ( !rowCount() )
ViewManager::instance()->hideQueue();
}
}
}
示例9: if
void
ColumnView::onCustomContextMenu( const QPoint& pos )
{
m_contextMenu->clear();
QModelIndex idx = indexAt( pos );
idx = idx.sibling( idx.row(), 0 );
m_contextMenuIndex = idx;
if ( !idx.isValid() )
return;
QList<query_ptr> queries;
QList<artist_ptr> artists;
QList<album_ptr> albums;
QModelIndexList indexes = selectedIndexes();
if ( !indexes.contains( idx ) )
{
indexes.clear();
indexes << idx;
}
foreach ( const QModelIndex& index, indexes )
{
if ( index.column() || indexes.contains( index.parent() ) )
continue;
PlayableItem* item = m_proxyModel->itemFromIndex( m_proxyModel->mapToSource( index ) );
if ( item && !item->result().isNull() )
queries << item->result()->toQuery();
else if ( item && !item->query().isNull() )
queries << item->query();
if ( item && !item->artist().isNull() )
artists << item->artist();
if ( item && !item->album().isNull() )
albums << item->album();
}
m_contextMenu->setQueries( queries );
m_contextMenu->setArtists( artists );
m_contextMenu->setAlbums( albums );
m_contextMenu->setPlaylistInterface( proxyModel()->playlistInterface() );
m_contextMenu->exec( viewport()->mapToGlobal( pos ) );
}
示例10: QModelIndex
void
ContextView::onDownloadAll()
{
for ( int i = 0; i < m_trackView->proxyModel()->rowCount( QModelIndex() ); i++ )
{
PlayableItem* item = m_trackView->proxyModel()->itemFromIndex( m_trackView->proxyModel()->mapToSource( m_trackView->proxyModel()->index( i, 0, QModelIndex() ) ) );
if ( !item || !item->query() || !item->query()->results().count() )
continue;
if ( !item->query()->results().first()->downloadFormats().count() )
continue;
if ( !DownloadManager::instance()->localFileForDownload( item->query()->results().first()->downloadFormats().first().url.toString() ).isEmpty() )
continue;
if ( !item->result()->downloadFormats().isEmpty() )
DownloadManager::instance()->addJob( item->result()->toDownloadJob( item->result()->downloadFormats().first() ) );
}
}
示例11: if
void
GridView::onItemActivated( const QModelIndex& index )
{
PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
if ( item )
{
// qDebug() << "Result activated:" << item->album()->tracks().first()->toString() << item->album()->tracks().first()->results().first()->url();
// APP->audioEngine()->playItem( item->album().data(), item->album()->tracks().first()->results().first() );
if ( !item->album().isNull() )
ViewManager::instance()->show( item->album() );
else if ( !item->artist().isNull() )
ViewManager::instance()->show( item->artist() );
else if ( !item->query().isNull() )
ViewManager::instance()->show( item->query() );
}
}
示例12: if
void
GridItemDelegate::onPlayClicked( const QPersistentModelIndex& index )
{
QPoint pos = m_playButton[ index ]->pos();
foreach ( ImageButton* button, m_playButton )
button->deleteLater();
m_playButton.clear();
AnimatedSpinner* spinner = new AnimatedSpinner( m_view );
spinner->setAutoCenter( false );
spinner->fadeIn();
spinner->move( pos );
spinner->setFocusPolicy( Qt::NoFocus );
spinner->installEventFilter( this );
m_spinner[ index ] = spinner;
PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
if ( item )
{
NewClosure( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ),
const_cast<GridItemDelegate*>(this), SLOT( onPlaybackStarted( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
m_closures.remove( index );
m_closures.insertMulti( index, NewClosure( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ),
const_cast<GridItemDelegate*>(this), SLOT( onPlaylistChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ) );
m_closures.insertMulti( index, NewClosure( AudioEngine::instance(), SIGNAL( stopped() ),
const_cast<GridItemDelegate*>(this), SLOT( onPlaylistChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ) );
foreach ( _detail::Closure* closure, m_closures.values( index ) )
closure->setAutoDelete( false );
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackFinished() ) );
if ( !item->query().isNull() )
AudioEngine::instance()->playItem( Tomahawk::playlistinterface_ptr(), item->query() );
else if ( !item->album().isNull() )
AudioEngine::instance()->playItem( item->album() );
else if ( !item->artist().isNull() )
AudioEngine::instance()->playItem( item->artist() );
}
}
示例13: if
void
TreeView::currentChanged( const QModelIndex& current, const QModelIndex& previous )
{
QTreeView::currentChanged( current, previous );
if ( !m_updateContextView )
return;
PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( current ) );
if ( item )
{
if ( !item->result().isNull() )
ViewManager::instance()->context()->setQuery( item->result()->toQuery() );
else if ( !item->artist().isNull() )
ViewManager::instance()->context()->setArtist( item->artist() );
else if ( !item->album().isNull() )
ViewManager::instance()->context()->setAlbum( item->album() );
else if ( !item->query().isNull() )
ViewManager::instance()->context()->setQuery( item->query() );
}
}
示例14: if
void
PlayableProxyModel::updateDetailedInfo( const QModelIndex& index )
{
PlayableItem* item = itemFromIndex( mapToSource( index ) );
if ( item->album() )
{
item->album()->cover( QSize( 0, 0 ) );
}
else if ( item->artist() )
{
item->artist()->cover( QSize( 0, 0 ) );
}
else if ( item->query() )
{
item->query()->track()->cover( QSize( 0, 0 ) );
/* if ( style() == PlayableProxyModel::Fancy )
{
item->query()->track()->loadSocialActions();
}*/
}
}
示例15:
void
TrackView::currentChanged( const QModelIndex& current, const QModelIndex& previous )
{
QTreeView::currentChanged( current, previous );
if ( !m_updateContextView )
return;
PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( current ) );
if ( item )
{
ViewManager::instance()->context()->setQuery( item->query() );
}
}