本文整理汇总了C++中PlayableItem::playbackLog方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayableItem::playbackLog方法的具体用法?C++ PlayableItem::playbackLog怎么用?C++ PlayableItem::playbackLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayableItem
的用法示例。
在下文中一共展示了PlayableItem::playbackLog方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trackCount
void
RecentlyPlayedModel::onPlaybackFinished( const Tomahawk::track_ptr& track, const Tomahawk::PlaybackLog& log )
{
int count = trackCount();
if ( count )
{
PlayableItem* oldestItem = itemFromIndex( index( count - 1, 0, QModelIndex() ) );
if ( oldestItem->playbackLog().timestamp >= log.timestamp )
return;
PlayableItem* youngestItem = itemFromIndex( index( 0, 0, QModelIndex() ) );
if ( youngestItem->playbackLog().timestamp <= log.timestamp )
insertQuery( track->toQuery(), 0, log );
else
{
for ( int i = 0; i < count - 1; i++ )
{
PlayableItem* item1 = itemFromIndex( index( i, 0, QModelIndex() ) );
PlayableItem* item2 = itemFromIndex( index( i + 1, 0, QModelIndex() ) );
if ( item1->playbackLog().timestamp >= log.timestamp && item2->playbackLog().timestamp <= log.timestamp )
{
insertQuery( track->toQuery(), i + 1, log );
break;
}
}
}
}
else
insertQuery( track->toQuery(), 0, log );
if ( trackCount() > (int)m_limit )
remove( m_limit );
ensureResolved();
}
示例2: prepareStyleOption
void
PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, bool useAvatars ) const
{
PlayableItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
Q_ASSERT( item );
QStyleOptionViewItemV4 opt = option;
prepareStyleOption( &opt, index, item );
opt.text.clear();
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
if ( m_view->header()->visualIndex( index.column() ) > 0 )
return;
const track_ptr track = item->query()->track();
QPixmap pixmap;
QString upperText, lowerText;
if ( !item->playbackLog().source )
{
upperText = track->track();
lowerText = track->artist();
}
else
{
upperText = QString( "%1 - %2" ).arg( track->artist() ).arg( track->track() );
QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->playbackLog().timestamp ), true );
if ( item->playbackLog().source->isLocal() )
lowerText = QString( tr( "played %1 by you" ) ).arg( playtime );
else
lowerText = QString( tr( "played %1 by %2" ) ).arg( playtime ).arg( item->playbackLog().source->friendlyName() );
}
painter->save();
{
QRect r = opt.rect.adjusted( 3, 6, 0, -6 );
// Paint Now Playing Speaker Icon
if ( item->isPlaying() )
{
const int pixMargin = 2;
const int pixHeight = r.height() - pixMargin * 2;
const QRect npr = r.adjusted( pixMargin, pixMargin + 1, pixHeight - r.width() + pixMargin, -pixMargin + 1 );
painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, npr.size() ) );
r.adjust( pixHeight + 8, 0, 0, 0 );
}
painter->setPen( opt.palette.text().color() );
QRect ir = r.adjusted( 4, 0, -option.rect.width() + option.rect.height() - 8 + r.left(), 0 );
if ( useAvatars )
{
if ( item->playbackLog().source )
pixmap = item->playbackLog().source->avatar( TomahawkUtils::RoundedCorners, ir.size() );
}
else
pixmap = item->query()->track()->cover( ir.size(), false );
if ( pixmap.isNull() )
{
if ( !useAvatars )
pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::Original, ir.size() );
else
pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::RoundedCorners, ir.size() );
}
painter->drawPixmap( ir, pixmap );
r.adjust( ir.width() + 12, 0, -12, 0 );
painter->setFont( m_boldFont );
QString text = painter->fontMetrics().elidedText( upperText, Qt::ElideRight, r.width() );
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_topOption );
painter->setFont( opt.font );
if ( !( option.state & QStyle::State_Selected || item->isPlaying() ) )
painter->setPen( Qt::gray );
text = painter->fontMetrics().elidedText( lowerText, Qt::ElideRight, r.width() );
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_bottomOption );
}
painter->restore();
}