本文整理汇总了C++中meta::TrackPtr::isPlayable方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackPtr::isPlayable方法的具体用法?C++ TrackPtr::isPlayable怎么用?C++ TrackPtr::isPlayable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meta::TrackPtr
的用法示例。
在下文中一共展示了TrackPtr::isPlayable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nominalImageRect
//.........这里部分代码省略.........
bool italic = element.italic();
bool underline = element.underline();
int alignment = element.alignment();
QFont font = option.font;
font.setBold( bold );
font.setItalic( italic );
font.setUnderline( underline );
painter->setFont( font );
int value = element.value();
QModelIndex textIndex = index.model()->index( index.row(), value );
// -- paint the element
if( value == Rating )
{
int rating = textIndex.data( Qt::DisplayRole ).toInt();
KRatingPainter::paintRating( painter,
QRect( currentItemX, rowOffsetY,
itemWidth, rowHeight ),
element.alignment(), rating );
}
else if( value == Divider )
{
QPixmap left = The::svgHandler()->renderSvg( "divider_left",
1, rowHeight ,
"divider_left" );
QPixmap right = The::svgHandler()->renderSvg( "divider_right",
1, rowHeight,
"divider_right" );
if( alignment & Qt::AlignLeft )
{
painter->drawPixmap( currentItemX, rowOffsetY, left );
painter->drawPixmap( currentItemX + 1, rowOffsetY, right );
}
else if( alignment & Qt::AlignRight )
{
painter->drawPixmap( currentItemX + itemWidth - 1, rowOffsetY, left );
painter->drawPixmap( currentItemX + itemWidth, rowOffsetY, right );
}
else
{
int center = currentItemX + ( itemWidth / 2 );
painter->drawPixmap( center, rowOffsetY, left );
painter->drawPixmap( center + 1, rowOffsetY, right );
}
}
else if( value == Moodbar )
{
//we cannot ask the model for the moodbar directly as we have no
//way of asking for a specific size. Instead just get the track from
//the model and ask the moodbar manager ourselves.
Meta::TrackPtr track = index.data( TrackRole ).value<Meta::TrackPtr>();
if( The::moodbarManager()->hasMoodbar( track ) )
{
QPixmap moodbar = The::moodbarManager()->getMoodbar( track, itemWidth, rowHeight - 8 );
painter->drawPixmap( currentItemX, rowOffsetY + 4, moodbar );
}
}
//actual playlist item text is drawn here
else
{
//TODO: get rid of passing TrackPtr as data, use custom role instead
Meta::TrackPtr track = index.data( TrackRole ).value<Meta::TrackPtr>();
QString text = textIndex.data( Qt::DisplayRole ).toString();
Amarok::QStringx prefix( element.prefix() );
Amarok::QStringx suffix( element.suffix() );
text = prefix.namedOptArgs( trackArgs ) + text + suffix.namedOptArgs( trackArgs );
text = QFontMetricsF( font ).elidedText( text, Qt::ElideRight, itemWidth );
//if the track can't be played, it should be grayed out to show that it is unavailable
if( !track->isPlayable() )
{
painter->save();
QPen grayPen = painter->pen();
grayPen.setColor( QColor( 127, 127, 127 ) ); // TODO: use disabled role
painter->setPen( grayPen );
painter->drawText( QRect( currentItemX + frameHMargin, rowOffsetY,
itemWidth - frameHMargin * 2, rowHeight ),
alignment, text );
painter->restore();
}
else
{
painter->drawText( QRect( currentItemX + frameHMargin, rowOffsetY,
itemWidth - frameHMargin * 2, rowHeight ),
alignment, text );
}
}
currentItemX += itemWidth;
}
rowOffsetY += rowHeight;
}
}