mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 13:17:34 +02:00
Ignore results without download options.
This commit is contained in:
@@ -284,47 +284,49 @@ PlaylistItemDelegate::paintDetailed( QPainter* painter, const QStyleOptionViewIt
|
|||||||
else */
|
else */
|
||||||
if ( index.column() == PlayableModel::Download )
|
if ( index.column() == PlayableModel::Download )
|
||||||
{
|
{
|
||||||
QStyleOptionComboBox optc;
|
if ( item->result() && !item->result()->downloadFormats().isEmpty() )
|
||||||
optc.rect = opt.rect.adjusted( 4, 0, -4, 0 );
|
|
||||||
optc.editable = false;
|
|
||||||
// sDebug() << item->track()->currentFormat() << item->track()->formats().count();
|
|
||||||
optc.currentText = tr( "Download %1" ).arg( item->result()->downloadFormats().first().extension );
|
|
||||||
// optc.palette = m_view->palette();
|
|
||||||
|
|
||||||
if ( option.state & QStyle::State_Selected && option.state & QStyle::State_Active )
|
|
||||||
optc.state = QStyle::State_Active | QStyle::State_Selected | QStyle::State_Enabled;
|
|
||||||
else
|
|
||||||
optc.state = QStyle::State_Active | QStyle::State_Enabled;
|
|
||||||
|
|
||||||
if ( !item->result()->downloadJob() )
|
|
||||||
{
|
{
|
||||||
QApplication::style()->drawComplexControl( QStyle::CC_ComboBox, &optc, painter, 0 );
|
QStyleOptionComboBox optc;
|
||||||
optc.rect.adjust( 4, 0, 0, 0 );
|
optc.rect = opt.rect.adjusted( 4, 0, -4, 0 );
|
||||||
QApplication::style()->drawControl( QStyle::CE_ComboBoxLabel, &optc, painter, 0 );
|
optc.editable = false;
|
||||||
}
|
optc.currentText = tr( "Download %1" ).arg( item->result()->downloadFormats().first().extension );
|
||||||
else
|
optc.palette = m_view->palette();
|
||||||
{
|
|
||||||
if ( item->result()->downloadJob()->state() == DownloadJob::Finished )
|
if ( option.state & QStyle::State_Selected && option.state & QStyle::State_Active )
|
||||||
|
optc.state = QStyle::State_Active | QStyle::State_Selected | QStyle::State_Enabled;
|
||||||
|
else
|
||||||
|
optc.state = QStyle::State_Active | QStyle::State_Enabled;
|
||||||
|
|
||||||
|
if ( !item->result()->downloadJob() )
|
||||||
{
|
{
|
||||||
painter->setPen( opt.palette.text().color() );
|
QApplication::style()->drawComplexControl( QStyle::CC_ComboBox, &optc, painter, 0 );
|
||||||
const QString text = painter->fontMetrics().elidedText( tr( "Finished" ), Qt::ElideRight, opt.rect.width() - 3 );
|
optc.rect.adjust( 4, 0, 0, 0 );
|
||||||
painter->drawText( opt.rect, text, textOption );
|
QApplication::style()->drawControl( QStyle::CE_ComboBoxLabel, &optc, painter, 0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QStyleOptionProgressBarV2 optp;
|
if ( item->result()->downloadJob()->state() == DownloadJob::Finished )
|
||||||
optp.rect = optc.rect;
|
{
|
||||||
optp.minimum = 0;
|
painter->setPen( opt.palette.text().color() );
|
||||||
optp.maximum = 100;
|
const QString text = painter->fontMetrics().elidedText( tr( "Finished" ), Qt::ElideRight, opt.rect.width() - 3 );
|
||||||
optp.progress = item->result()->downloadJob()->progressPercentage();
|
painter->drawText( opt.rect, text, textOption );
|
||||||
// optp.palette = m_view->palette();
|
}
|
||||||
|
|
||||||
if ( option.state & QStyle::State_Selected && option.state & QStyle::State_Active )
|
|
||||||
optp.state = QStyle::State_Active | QStyle::State_Selected | QStyle::State_Enabled;
|
|
||||||
else
|
else
|
||||||
optp.state = QStyle::State_Active | QStyle::State_Enabled;
|
{
|
||||||
|
QStyleOptionProgressBarV2 optp;
|
||||||
|
optp.rect = optc.rect;
|
||||||
|
optp.minimum = 0;
|
||||||
|
optp.maximum = 100;
|
||||||
|
optp.progress = item->result()->downloadJob()->progressPercentage();
|
||||||
|
optp.palette = m_view->palette();
|
||||||
|
|
||||||
QApplication::style()->drawControl( QStyle::CE_ProgressBar, &optp, painter, 0 );
|
if ( option.state & QStyle::State_Selected && option.state & QStyle::State_Active )
|
||||||
|
optp.state = QStyle::State_Active | QStyle::State_Selected | QStyle::State_Enabled;
|
||||||
|
else
|
||||||
|
optp.state = QStyle::State_Active | QStyle::State_Enabled;
|
||||||
|
|
||||||
|
QApplication::style()->drawControl( QStyle::CE_ProgressBar, &optp, painter, 0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user