本文整理汇总了C++中PlayableItem::artist方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayableItem::artist方法的具体用法?C++ PlayableItem::artist怎么用?C++ PlayableItem::artist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayableItem
的用法示例。
在下文中一共展示了PlayableItem::artist方法的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: connect
void
TreeProxyModel::onRowsInserted( const QModelIndex& parent, int /* start */, int /* end */ )
{
if ( m_filter.isEmpty() )
return;
if ( sender() != m_model )
return;
PlayableItem* pi = m_model->itemFromIndex( m_model->index( parent.row(), 0, parent.parent() ) );
if ( pi->artist().isNull() )
return;
Tomahawk::AlbumsRequest* cmd = 0;
if ( !m_model->collection().isNull() )
cmd = m_model->collection()->requestAlbums( pi->artist() );
else
cmd = new Tomahawk::DatabaseCommand_AllAlbums( Tomahawk::collection_ptr(), pi->artist() );
cmd->setFilter( m_filter );
connect( dynamic_cast< QObject* >( cmd ), SIGNAL( albums( QList<Tomahawk::album_ptr> ) ),
SLOT( onFilterAlbums( QList<Tomahawk::album_ptr> ) ) );
cmd->enqueue();
}
示例3: if
void
TreeModel::getCover( const QModelIndex& index )
{
PlayableItem* item = itemFromIndex( index );
if ( !item->artist().isNull() && !item->artist()->coverLoaded() )
item->artist()->cover( QSize( 0, 0 ) );
else if ( !item->album().isNull() && !item->album()->coverLoaded() )
item->album()->cover( QSize( 0, 0 ) );
}
示例4: 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;
}
}
}
示例5: 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 ) );
}
示例6: if
void
ArtistView::onItemActivated( const QModelIndex& index )
{
PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
if ( item )
{
if ( !item->artist().isNull() )
ViewManager::instance()->show( item->artist() );
else if ( !item->album().isNull() )
ViewManager::instance()->show( item->album() );
else if ( !item->result().isNull() && item->result()->isOnline() )
{
m_model->setCurrentItem( item->index );
AudioEngine::instance()->playItem( m_proxyModel->playlistInterface(), item->result() );
}
}
}
示例7: 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() );
}
}
示例8: 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() );
}
}
示例9: 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() );
}
}
示例10: connect
void
TreeProxyModel::onRowsInserted( const QModelIndex& parent, int /* start */, int /* end */ )
{
if ( m_filter.isEmpty() )
return;
if ( sender() != m_model )
return;
PlayableItem* pi = m_model->itemFromIndex( m_model->index( parent.row(), 0, parent.parent() ) );
if ( pi->artist().isNull() )
return;
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( m_model->collection() );
cmd->setArtist( pi->artist() );
cmd->setFilter( m_filter );
connect( cmd, SIGNAL( albums( QList<Tomahawk::album_ptr>, QVariant ) ),
SLOT( onFilterAlbums( QList<Tomahawk::album_ptr> ) ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
}
示例11: 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();
}*/
}
}
示例12: itemFromIndex
bool
PlayableProxyModel::dupeFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent, PlayableProxyModelFilterMemo& memo ) const
{
if ( !m_hideDupeItems )
return true;
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 && filterAcceptsRowInternal( i, di, sourceParent, memo ) )
return false;
}
return true;
}
示例13: textOption
void
ColumnItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
if ( !item )
return;
QTextOption textOption( Qt::AlignVCenter | (Qt::Alignment)index.data( Qt::TextAlignmentRole ).toUInt() );
textOption.setWrapMode( QTextOption::NoWrap );
QString text;
if ( !item->artist().isNull() )
{
text = item->artist()->name();
}
else if ( !item->album().isNull() )
{
text = item->album()->name();
}
else if ( !item->result().isNull() || !item->query().isNull() )
{
float opacity = item->result() && item->result()->isOnline() ? 1.0 : 0.0;
opacity = qMax( (float)0.3, opacity );
QColor textColor = TomahawkUtils::alphaBlend( option.palette.color( QPalette::Foreground ), option.palette.color( QPalette::Background ), opacity );
{
QStyleOptionViewItemV4 o = option;
initStyleOption( &o, QModelIndex() );
painter->save();
o.palette.setColor( QPalette::Text, textColor );
if ( m_view->currentIndex() == index )
o.state |= QStyle::State_Selected;
else
o.state &= ~QStyle::State_Selected;
if ( o.state & QStyle::State_Selected && o.state & QStyle::State_Active )
{
o.palette.setColor( QPalette::Text, o.palette.color( QPalette::HighlightedText ) );
}
if ( item->isPlaying() )
{
textColor = TomahawkStyle::NOW_PLAYING_ITEM_TEXT;
o.palette.setColor( QPalette::Highlight, TomahawkStyle::NOW_PLAYING_ITEM );
o.palette.setColor( QPalette::Text, TomahawkStyle::NOW_PLAYING_ITEM_TEXT );
o.state |= QStyle::State_Selected;
}
int oldX = 0;
// if ( m_view->header()->visualIndex( index.column() ) == 0 )
{
oldX = o.rect.x();
o.rect.setX( 0 );
}
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &o, painter );
if ( oldX > 0 )
o.rect.setX( oldX );
/* if ( m_hoveringOver == index && !index.data().toString().isEmpty() && index.column() == 0 )
{
o.rect.setWidth( o.rect.width() - o.rect.height() );
QRect arrowRect( o.rect.x() + o.rect.width(), o.rect.y() + 1, o.rect.height() - 2, o.rect.height() - 2 );
QPixmap infoIcon = TomahawkUtils::defaultPixmap( TomahawkUtils::InfoIcon, TomahawkUtils::Original, arrowRect.size() );
painter->drawPixmap( arrowRect, infoIcon );
m_infoButtonRects[ index ] = arrowRect;
}*/
{
QRect r = o.rect.adjusted( 3, 0, 0, 0 );
// Paint Now Playing Speaker Icon
if ( item->isPlaying() )
{
const int pixMargin = 1;
const int pixHeight = r.height() - pixMargin * 2;
QRect npr = r.adjusted( pixMargin, pixMargin, pixHeight - r.width() + pixMargin, -pixMargin );
painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, npr.size() ) );
r.adjust( pixHeight + 6, 0, 0, 0 );
}
painter->setPen( o.palette.text().color() );
QString text = index.data().toString();
if ( item->query()->track()->albumpos() > 0 )
{
text = QString( "%1. %2" )
.arg( index.data( PlayableModel::AlbumPosRole ).toString() )
.arg( index.data().toString() );
}
text = painter->fontMetrics().elidedText( text, Qt::ElideRight, r.width() - 3 );
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, textOption );
}
painter->restore();
}
//.........这里部分代码省略.........
示例14: if
void
GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
if ( !item || !index.isValid() )
return;
QStyleOptionViewItemV4 opt = option;
initStyleOption( &opt, QModelIndex() );
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
QRect r = option.rect;
QString top, bottom;
if ( !item->album().isNull() )
{
top = item->album()->name();
if ( !item->album()->artist().isNull() )
bottom = item->album()->artist()->name();
}
else if ( !item->artist().isNull() )
{
top = item->artist()->name();
}
else if ( !item->query().isNull() )
{
top = item->query()->track()->track();
bottom = item->query()->track()->artist();
}
else
{
return;
}
painter->save();
painter->setRenderHint( QPainter::Antialiasing );
if ( !m_covers.contains( index ) )
{
if ( !item->album().isNull() )
{
m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->album(), r.size(), TomahawkUtils::Grid ) ) );
}
else if ( !item->artist().isNull() )
{
m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->artist(), r.size(), TomahawkUtils::Grid ) ) );
}
else
{
m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->query(), r.size(), TomahawkUtils::Grid ) ) );
}
NewClosure( m_covers[ index ], SIGNAL( repaintRequest() ),
const_cast<GridItemDelegate*>(this), SLOT( doUpdateIndex( QPersistentModelIndex ) ), QPersistentModelIndex( index ) )->setAutoDelete( false );
}
QSharedPointer< Tomahawk::PixmapDelegateFader > fader = m_covers[ index ];
if ( fader->size() != r.size() )
fader->setSize( r.size() );
const QPixmap cover = fader->currentPixmap();
painter->drawPixmap( r, cover );
qreal opacity = -1.;
if ( m_hoverFaders.contains( index ) )
{
const qreal pct = ( m_hoverFaders[ index ]->currentFrame() / 100.0 );
opacity = 0.35 - pct * 0.35;
}
else if ( m_hoverIndex == index )
{
opacity = 0.35;
}
if ( opacity > -1.0 )
{
painter->save();
painter->setPen( TomahawkStyle::HOVER_GLOW );
painter->setBrush( TomahawkStyle::HOVER_GLOW );
painter->setOpacity( opacity );
painter->drawRect( r );
painter->restore();
}
QTextOption to;
to.setWrapMode( QTextOption::NoWrap );
QString text;
QFont font = opt.font;
font.setPointSize( TomahawkUtils::defaultFontSize() );
QFont boldFont = font;
boldFont.setBold( true );
boldFont.setPointSize( TomahawkUtils::defaultFontSize() + 1 );
int bottomHeight = QFontMetrics( font ).boundingRect( bottom ).height();
int topHeight = QFontMetrics( boldFont ).boundingRect( top ).height();
int frameHeight = bottomHeight + topHeight + 10;
//.........这里部分代码省略.........
示例15: if
void
GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
if ( !item || !index.isValid() )
return;
QStyleOptionViewItemV4 opt = option;
initStyleOption( &opt, QModelIndex() );
// qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
QRect r = option.rect;
r.setHeight( r.width() );
QString top, bottom;
if ( !item->album().isNull() )
{
top = item->album()->name();
if ( !item->album()->artist().isNull() )
bottom = item->album()->artist()->name();
}
else if ( !item->artist().isNull() )
{
top = item->artist()->name();
}
else if ( !item->query().isNull() )
{
top = item->query()->track()->track();
bottom = item->query()->track()->artist();
}
else
{
return;
}
painter->save();
painter->setRenderHint( QPainter::TextAntialiasing );
if ( !m_covers.contains( index ) )
{
if ( !item->album().isNull() )
{
m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->album(), r.size(), TomahawkUtils::Original, false ) ) );
}
else if ( !item->artist().isNull() )
{
m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->artist(), r.size(), TomahawkUtils::Original, false ) ) );
}
else
{
m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->query(), r.size(), TomahawkUtils::Original, false ) ) );
}
NewClosure( m_covers[ index ], SIGNAL( repaintRequest() ),
const_cast<GridItemDelegate*>(this), SLOT( doUpdateIndex( QPersistentModelIndex ) ), QPersistentModelIndex( index ) )->setAutoDelete( false );
}
QSharedPointer< Tomahawk::PixmapDelegateFader > fader = m_covers[ index ];
if ( fader->size() != r.size() )
fader->setSize( r.size() );
const QPixmap cover = fader->currentPixmap();
qreal opacity = -1.0;
qreal pct = -1.0;
if ( m_hoverFaders.contains( index ) )
{
pct = ( m_hoverFaders[ index ]->currentFrame() / 100.0 );
opacity = 1.0 - pct * 0.70;
}
else if ( m_hoverIndex == index )
{
opacity = 0.3;
pct = 1.0;
}
if ( opacity > -1.0 )
{
painter->save();
const int cropIn = pct * ( (qreal)cover.width() * 0.10 );
const QRect crop = cover.rect().adjusted( cropIn, cropIn, -cropIn, -cropIn );
painter->drawPixmap( r, cover.copy( crop ).scaled( r.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
painter->setOpacity( 1.0 - opacity );
painter->setPen( Qt::transparent );
painter->setBrush( Qt::black );
painter->drawRect( r );
painter->restore();
}
else
{
painter->drawPixmap( r, cover );
}
QTextOption to;
to.setWrapMode( QTextOption::NoWrap );
QString text;
//.........这里部分代码省略.........