本文整理汇总了C++中query_ptr::duration方法的典型用法代码示例。如果您正苦于以下问题:C++ query_ptr::duration方法的具体用法?C++ query_ptr::duration怎么用?C++ query_ptr::duration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类query_ptr
的用法示例。
在下文中一共展示了query_ptr::duration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: durationFontMetrics
void
PlaylistChartItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) 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 query_ptr q = item->query()->displayQuery();
unsigned int duration = q->duration();
QString artist = q->artist();
QString track = q->track();
QPixmap avatar;
QString upperText, lowerText;
painter->save();
{
QRect r = opt.rect.adjusted( 4, 6, 0, -6 );
// Paint Now Playing Speaker Icon
if ( item->isPlaying() )
{
const int pixMargin = 4;
const int pixHeight = r.height() - pixMargin * 2;
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 );
}
QFont figureFont = opt.font;
figureFont.setPointSize( TomahawkUtils::defaultFontSize() + 6 );
figureFont.setWeight( 99 );
QFont boldFont = opt.font;
boldFont.setPointSize( TomahawkUtils::defaultFontSize() + 1 );
boldFont.setWeight( 99 );
QFont smallBoldFont = opt.font;
smallBoldFont.setPointSize( TomahawkUtils::defaultFontSize() );
smallBoldFont.setWeight( 60 );
QFont durationFont = opt.font;
durationFont.setPointSize( TomahawkUtils::defaultFontSize() );
durationFont.setWeight( 80 );
QFontMetrics durationFontMetrics( durationFont );
if ( index.row() == 0 )
{
figureFont.setPointSize( TomahawkUtils::defaultFontSize() + 33 );
boldFont.setPointSize( TomahawkUtils::defaultFontSize() + 13 );
smallBoldFont.setPointSize( TomahawkUtils::defaultFontSize() + 9 );
}
else if ( index.row() == 1 )
{
figureFont.setPointSize( TomahawkUtils::defaultFontSize() + 17 );
boldFont.setPointSize( TomahawkUtils::defaultFontSize() + 9 );
smallBoldFont.setPointSize( TomahawkUtils::defaultFontSize() + 4 );
}
else if ( index.row() == 2 )
{
figureFont.setPointSize( TomahawkUtils::defaultFontSize() + 9 );
boldFont.setPointSize( TomahawkUtils::defaultFontSize() + 4 );
smallBoldFont.setPointSize( TomahawkUtils::defaultFontSize() + 2 );
}
else if ( index.row() >= 10 )
{
boldFont.setPointSize( TomahawkUtils::defaultFontSize() );
smallBoldFont.setPointSize( TomahawkUtils::defaultFontSize() - 1 );
}
QRect figureRect = r.adjusted( 0, 0, -option.rect.width() + 60 - 6 + r.left(), 0 );
painter->setFont( figureFont );
painter->setPen( option.palette.text().color().lighter( 450 ) );
painter->drawText( figureRect, QString::number( index.row() + 1 ), m_centerOption );
painter->setPen( opt.palette.text().color() );
QRect pixmapRect = r.adjusted( figureRect.width() + 6, 0, -option.rect.width() + figureRect.width() + option.rect.height() - 6 + r.left(), 0 );
if ( !m_pixmaps.contains( index ) )
{
m_pixmaps.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->query(), pixmapRect.size(), TomahawkUtils::Original, false ) ) );
_detail::Closure* closure = NewClosure( m_pixmaps[ index ], SIGNAL( repaintRequest() ), const_cast<PlaylistChartItemDelegate*>(this), SLOT( doUpdateIndex( const QPersistentModelIndex& ) ), QPersistentModelIndex( index ) );
closure->setAutoDelete( false );
}
const QPixmap pixmap = m_pixmaps[ index ]->currentPixmap();
painter->drawPixmap( pixmapRect, pixmap );
r.adjust( pixmapRect.width() + figureRect.width() + 18, 1, -28, 0 );
QRect leftRect = r.adjusted( 0, 0, -durationFontMetrics.width( TomahawkUtils::timeToString( duration ) ) - 8, 0 );
painter->setFont( boldFont );
QString text = painter->fontMetrics().elidedText( track, Qt::ElideRight, leftRect.width() );
//.........这里部分代码省略.........