mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 13:17:34 +02:00
* Delegates use the base-class impls for painting / handling.
This commit is contained in:
@@ -48,14 +48,6 @@ AlbumItemDelegate::AlbumItemDelegate( TrackView* parent, PlayableProxyModel* pro
|
|||||||
, m_view( parent )
|
, m_view( parent )
|
||||||
, m_model( proxy )
|
, m_model( proxy )
|
||||||
{
|
{
|
||||||
m_centerOption = QTextOption( Qt::AlignVCenter );
|
|
||||||
m_centerOption.setWrapMode( QTextOption::NoWrap );
|
|
||||||
|
|
||||||
m_centerRightOption = QTextOption( Qt::AlignVCenter | Qt::AlignRight );
|
|
||||||
m_centerRightOption.setWrapMode( QTextOption::NoWrap );
|
|
||||||
|
|
||||||
connect( proxy, SIGNAL( modelReset() ), this, SLOT( modelChanged() ) );
|
|
||||||
connect( parent, SIGNAL( modelChanged() ), this, SLOT( modelChanged() ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,11 +74,10 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
opt.text.clear();
|
opt.text.clear();
|
||||||
|
|
||||||
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
|
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
|
||||||
|
|
||||||
if ( m_view->header()->visualIndex( index.column() ) > 0 )
|
if ( m_view->header()->visualIndex( index.column() ) > 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const track_ptr track = item->query()->track();
|
const track_ptr& track = item->query()->track();
|
||||||
QString lowerText;
|
QString lowerText;
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
@@ -102,73 +93,41 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
r.adjust( pixHeight, 0, 0, 0 );
|
r.adjust( pixHeight, 0, 0, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
QFont boldFont = opt.font;
|
painter->setFont( m_bigBoldFont );
|
||||||
boldFont.setPointSize( TomahawkUtils::defaultFontSize() + 2 );
|
|
||||||
boldFont.setWeight( 99 );
|
|
||||||
QFontMetrics boldFontMetrics( boldFont );
|
|
||||||
|
|
||||||
QFont smallBoldFont = opt.font;
|
|
||||||
smallBoldFont.setPointSize( TomahawkUtils::defaultFontSize() - 1 );
|
|
||||||
smallBoldFont.setBold( true );
|
|
||||||
smallBoldFont.setWeight( 60 );
|
|
||||||
QFontMetrics smallBoldFontMetrics( smallBoldFont );
|
|
||||||
|
|
||||||
painter->setFont( boldFont );
|
|
||||||
painter->setPen( option.palette.text().color().lighter( 450 ) );
|
painter->setPen( option.palette.text().color().lighter( 450 ) );
|
||||||
|
|
||||||
|
QRect leftRect = r;
|
||||||
QRect figureRect = r.adjusted( 4, 0, 0, 0 );
|
QRect figureRect = r.adjusted( 4, 0, 0, 0 );
|
||||||
figureRect.setWidth( QFontMetrics( painter->font() ).width( "888" ) );
|
figureRect.setWidth( QFontMetrics( painter->font() ).width( "888" ) );
|
||||||
painter->drawText( figureRect, QString::number( index.row() + 1 ), QTextOption( Qt::AlignCenter ) );
|
|
||||||
|
|
||||||
r.adjust( figureRect.width() + 12, 0, 0, 0 );
|
|
||||||
QRect rightRect = r.adjusted( r.width() - smallBoldFontMetrics.width( TomahawkUtils::timeToString( track->duration() ) ), 0, 0, 0 );
|
|
||||||
QRect leftRect = r.adjusted( 0, 0, -( rightRect.width() + 8 ), 0 );
|
|
||||||
|
|
||||||
const int sourceIconSize = r.height();
|
|
||||||
|
|
||||||
if ( hoveringOver() == index && index.column() == 0 )
|
if ( hoveringOver() == index && index.column() == 0 )
|
||||||
{
|
{
|
||||||
const QPixmap infoIcon = TomahawkUtils::defaultPixmap( TomahawkUtils::InfoIcon, TomahawkUtils::Original, QSize( sourceIconSize, sourceIconSize ) );
|
drawInfoButton( painter, figureRect.adjusted( 1, 0, 0, 0 ), index, 1.0 );
|
||||||
QRect arrowRect = QRect( rightRect.right() - sourceIconSize, r.center().y() - sourceIconSize / 2, infoIcon.width(), infoIcon.height() );
|
|
||||||
painter->drawPixmap( arrowRect, infoIcon );
|
|
||||||
|
|
||||||
setInfoButtonRect( index, arrowRect );
|
|
||||||
rightRect.moveLeft( rightRect.left() - infoIcon.width() - 8 );
|
|
||||||
leftRect.adjust( 0, 0, -( infoIcon.width() + 8 ), 0 );
|
|
||||||
}
|
}
|
||||||
else if ( item->query()->numResults() && !item->query()->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) ).isNull() )
|
else
|
||||||
{
|
{
|
||||||
const QPixmap sourceIcon = item->query()->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) );
|
painter->drawText( figureRect, QString::number( index.row() + 1 ), QTextOption( Qt::AlignCenter ) );
|
||||||
painter->setOpacity( 0.8 );
|
|
||||||
painter->drawPixmap( QRect( rightRect.right() - sourceIconSize, r.center().y() - sourceIconSize / 2, sourceIcon.width(), sourceIcon.height() ), sourceIcon );
|
|
||||||
painter->setOpacity( 1.0 );
|
|
||||||
rightRect.moveLeft( rightRect.left() - sourceIcon.width() - 8 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString text = painter->fontMetrics().elidedText( track->track(), Qt::ElideRight, leftRect.width() );
|
leftRect = r;
|
||||||
|
leftRect.adjust( figureRect.width() + 12, 0, 0, 0 );
|
||||||
|
QRect rightRect = r.adjusted( r.width() - m_smallBoldFontMetrics.width( TomahawkUtils::timeToString( track->duration() ) ), 0, 0, 0 );
|
||||||
|
{
|
||||||
|
const QRect leftRectBefore = leftRect;
|
||||||
|
leftRect = drawSourceIcon( painter, leftRect, item, 1.0 );
|
||||||
|
rightRect.moveLeft( rightRect.left() - ( leftRectBefore.width() - leftRect.width() ) );
|
||||||
|
leftRect.setWidth( leftRect.width() - rightRect.width() );
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString text = painter->fontMetrics().elidedText( track->track(), Qt::ElideRight, leftRect.width() );
|
||||||
painter->setPen( opt.palette.text().color() );
|
painter->setPen( opt.palette.text().color() );
|
||||||
painter->drawText( leftRect, text, m_centerOption );
|
painter->drawText( leftRect, text, m_centerOption );
|
||||||
|
|
||||||
if ( track->duration() > 0 )
|
if ( track->duration() > 0 )
|
||||||
{
|
{
|
||||||
painter->setPen( opt.palette.text().color() );
|
painter->setFont( m_smallBoldFont );
|
||||||
painter->setFont( smallBoldFont );
|
|
||||||
painter->drawText( rightRect, TomahawkUtils::timeToString( track->duration() ), m_centerRightOption );
|
painter->drawText( rightRect, TomahawkUtils::timeToString( track->duration() ), m_centerRightOption );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AlbumItemDelegate::doUpdateIndex( const QPersistentModelIndex& idx )
|
|
||||||
{
|
|
||||||
if ( idx.isValid() )
|
|
||||||
emit updateIndex( idx );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AlbumItemDelegate::modelChanged()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
@@ -47,14 +47,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
|
|
||||||
private slots:
|
|
||||||
void doUpdateIndex( const QPersistentModelIndex& idx );
|
|
||||||
void modelChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTextOption m_centerOption;
|
|
||||||
QTextOption m_centerRightOption;
|
|
||||||
|
|
||||||
TrackView* m_view;
|
TrackView* m_view;
|
||||||
PlayableProxyModel* m_model;
|
PlayableProxyModel* m_model;
|
||||||
};
|
};
|
||||||
|
@@ -543,6 +543,20 @@ GridItemDelegate::onCurrentIndexChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
GridItemDelegate::resetHoverIndex()
|
||||||
|
{
|
||||||
|
foreach ( ImageButton* button, m_playButton )
|
||||||
|
button->deleteLater();
|
||||||
|
m_playButton.clear();
|
||||||
|
|
||||||
|
QModelIndex idx = m_hoveringOver;
|
||||||
|
m_hoveringOver = QPersistentModelIndex();
|
||||||
|
m_hoverIndex = QPersistentModelIndex();
|
||||||
|
doUpdateIndex( idx );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GridItemDelegate::createPauseButton( const QPersistentModelIndex& index )
|
GridItemDelegate::createPauseButton( const QPersistentModelIndex& index )
|
||||||
{
|
{
|
||||||
|
@@ -48,6 +48,9 @@ public:
|
|||||||
QSize itemSize() const { return m_itemSize; }
|
QSize itemSize() const { return m_itemSize; }
|
||||||
void setItemSize( const QSize& size ) { m_itemSize = size; }
|
void setItemSize( const QSize& size ) { m_itemSize = size; }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void resetHoverIndex();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
|
@@ -37,8 +37,6 @@
|
|||||||
|
|
||||||
#include "utils/TomahawkUtilsGui.h"
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include <utils/PixmapDelegateFader.h>
|
|
||||||
#include <utils/Closure.h>
|
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -49,17 +47,6 @@ PlaylistLargeItemDelegate::PlaylistLargeItemDelegate( DisplayMode mode, TrackVie
|
|||||||
, m_model( proxy )
|
, m_model( proxy )
|
||||||
, m_mode( mode )
|
, m_mode( mode )
|
||||||
{
|
{
|
||||||
m_topOption = QTextOption( Qt::AlignTop );
|
|
||||||
m_topOption.setWrapMode( QTextOption::NoWrap );
|
|
||||||
|
|
||||||
m_centerRightOption = QTextOption( Qt::AlignVCenter | Qt::AlignRight );
|
|
||||||
m_centerRightOption.setWrapMode( QTextOption::NoWrap );
|
|
||||||
|
|
||||||
m_bottomOption = QTextOption( Qt::AlignBottom );
|
|
||||||
m_bottomOption.setWrapMode( QTextOption::NoWrap );
|
|
||||||
|
|
||||||
connect( proxy, SIGNAL( modelReset() ), SLOT( modelChanged() ) );
|
|
||||||
connect( parent, SIGNAL( modelChanged() ), SLOT( modelChanged() ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -91,7 +78,6 @@ PlaylistLargeItemDelegate::drawRichText( QPainter* painter, const QStyleOptionVi
|
|||||||
y += ( rect.height() - height ) / 2;
|
y += ( rect.height() - height ) / 2;
|
||||||
|
|
||||||
QAbstractTextDocumentLayout::PaintContext context;
|
QAbstractTextDocumentLayout::PaintContext context;
|
||||||
|
|
||||||
context.palette.setColor( QPalette::Text, painter->pen().color() );
|
context.palette.setColor( QPalette::Text, painter->pen().color() );
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
@@ -111,10 +97,10 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
prepareStyleOption( &opt, index, item );
|
prepareStyleOption( &opt, index, item );
|
||||||
|
|
||||||
bool isUnlistened = true;
|
bool isUnlistened = true;
|
||||||
if( m_mode == Inbox )
|
if ( m_mode == Inbox )
|
||||||
{
|
{
|
||||||
QList< Tomahawk::SocialAction > socialActions = item->query()->queryTrack()->allSocialActions();
|
QList< Tomahawk::SocialAction > socialActions = item->query()->queryTrack()->allSocialActions();
|
||||||
foreach( const Tomahawk::SocialAction& sa, socialActions )
|
foreach ( const Tomahawk::SocialAction& sa, socialActions )
|
||||||
{
|
{
|
||||||
if ( sa.action.toString() == "Inbox" && sa.value.toBool() == false )
|
if ( sa.action.toString() == "Inbox" && sa.value.toBool() == false )
|
||||||
{
|
{
|
||||||
@@ -132,8 +118,8 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
|
|
||||||
const track_ptr track = item->query()->track();
|
const track_ptr track = item->query()->track();
|
||||||
QString lowerText;
|
QString lowerText;
|
||||||
|
|
||||||
QSize avatarSize( 32, 32 );
|
QSize avatarSize( 32, 32 );
|
||||||
|
|
||||||
if ( m_mode == RecentlyPlayed && item->playbackLog().source )
|
if ( m_mode == RecentlyPlayed && item->playbackLog().source )
|
||||||
{
|
{
|
||||||
QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->playbackLog().timestamp ), true );
|
QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->playbackLog().timestamp ), true );
|
||||||
@@ -147,7 +133,6 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
if ( m_mode == LatestAdditions && item->query()->numResults() )
|
if ( m_mode == LatestAdditions && item->query()->numResults() )
|
||||||
{
|
{
|
||||||
QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->query()->results().first()->modificationTime() ), true );
|
QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->query()->results().first()->modificationTime() ), true );
|
||||||
|
|
||||||
lowerText = QString( tr( "added %1", "e.g. added 3 hours ago" ) ).arg( playtime );
|
lowerText = QString( tr( "added %1", "e.g. added 3 hours ago" ) ).arg( playtime );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,78 +155,43 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
if ( item->isPlaying() )
|
if ( item->isPlaying() )
|
||||||
{
|
{
|
||||||
painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, npr.size() ) );
|
painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, npr.size() ) );
|
||||||
r.adjust( pixHeight + 2*pixMargin, 0, 0, 0 );
|
r.adjust( pixHeight + 2 * pixMargin, 0, 0, 0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
npr = npr.adjusted( 0, npr.height() / 4, -npr.width() / 2, -npr.height() / 4 );
|
npr = npr.adjusted( 0, npr.height() / 4, -npr.width() / 2, -npr.height() / 4 );
|
||||||
painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::InboxNewItem, TomahawkUtils::Original, npr.size() ) );
|
painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::InboxNewItem, TomahawkUtils::Original, npr.size() ) );
|
||||||
r.adjust( npr.width() + 2*pixMargin, 0, 0, 0 );
|
r.adjust( npr.width() + 2 * pixMargin, 0, 0, 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->setPen( opt.palette.text().color() );
|
painter->setPen( opt.palette.text().color() );
|
||||||
|
|
||||||
QRect pixmapRect = r.adjusted( 6, 0, -option.rect.width() + option.rect.height() - 6 + r.left(), 0 );
|
r.adjust( 4, 0, -16, 0 );
|
||||||
QRect avatarRect = r.adjusted( option.rect.width() - r.left() - 12 - avatarSize.width(), ( option.rect.height() - avatarSize.height() ) / 2 - 5, 0, 0 );
|
QRect leftRect;
|
||||||
avatarRect.setSize( avatarSize );
|
|
||||||
|
|
||||||
if ( !m_pixmaps.contains( index ) )
|
|
||||||
{
|
|
||||||
m_pixmaps.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->query(), pixmapRect.size(), TomahawkUtils::RoundedCorners, false ) ) );
|
|
||||||
_detail::Closure* closure = NewClosure( m_pixmaps[ index ], SIGNAL( repaintRequest() ), const_cast<PlaylistLargeItemDelegate*>(this), SLOT( doUpdateIndex( const QPersistentModelIndex& ) ), QPersistentModelIndex( index ) );
|
|
||||||
closure->setAutoDelete( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
const QPixmap pixmap = m_pixmaps[ index ]->currentPixmap();
|
|
||||||
painter->drawPixmap( pixmapRect, pixmap );
|
|
||||||
|
|
||||||
QFont boldFont = opt.font;
|
|
||||||
boldFont.setPointSize( TomahawkUtils::defaultFontSize() + 2 );
|
|
||||||
boldFont.setWeight( 99 );
|
|
||||||
QFontMetrics boldFontMetrics( boldFont );
|
|
||||||
|
|
||||||
QFont smallBoldFont = opt.font;
|
|
||||||
smallBoldFont.setPointSize( TomahawkUtils::defaultFontSize() - 1 );
|
|
||||||
smallBoldFont.setBold( true );
|
|
||||||
smallBoldFont.setWeight( 60 );
|
|
||||||
QFontMetrics smallBoldFontMetrics( smallBoldFont );
|
|
||||||
|
|
||||||
QFont smallFont = opt.font;
|
|
||||||
smallFont.setPointSize( TomahawkUtils::defaultFontSize() - 1 );
|
|
||||||
|
|
||||||
r.adjust( pixmapRect.width() + 12, 1, - 16, 0 );
|
|
||||||
QRect rightRect = r.adjusted( r.width() - smallBoldFontMetrics.width( TomahawkUtils::timeToString( track->duration() ) ), 0, 0, 0 );
|
|
||||||
QRect leftRect = r.adjusted( 0, 0, -( rightRect.width() + 8 ), 0 );
|
|
||||||
|
|
||||||
const int sourceIconSize = avatarRect.width() - 6;
|
|
||||||
|
|
||||||
if ( hoveringOver() == index && !index.data().toString().isEmpty() && index.column() == 0 )
|
if ( hoveringOver() == index && !index.data().toString().isEmpty() && index.column() == 0 )
|
||||||
{
|
{
|
||||||
const QPixmap infoIcon = TomahawkUtils::defaultPixmap( TomahawkUtils::InfoIcon, TomahawkUtils::Original, QSize( sourceIconSize, sourceIconSize ) );
|
leftRect = drawInfoButton( painter, r, index, 0.9 );
|
||||||
QRect arrowRect = QRect( rightRect.right() - sourceIconSize, r.center().y() - sourceIconSize / 2, infoIcon.width(), infoIcon.height() );
|
|
||||||
painter->drawPixmap( arrowRect, infoIcon );
|
|
||||||
|
|
||||||
setInfoButtonRect( index, arrowRect );
|
|
||||||
rightRect.moveLeft( rightRect.left() - infoIcon.width() - 8 );
|
|
||||||
leftRect.adjust( 0, 0, -( infoIcon.width() + 8 ), 0 );
|
|
||||||
}
|
}
|
||||||
else if ( item->query()->numResults() && !item->query()->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) ).isNull() )
|
else
|
||||||
{
|
{
|
||||||
const QPixmap sourceIcon = item->query()->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) );
|
leftRect = drawCover( painter, r, item, index );
|
||||||
painter->setOpacity( 0.8 );
|
|
||||||
painter->drawPixmap( QRect( rightRect.right() - sourceIconSize, r.center().y() - sourceIconSize / 2, sourceIcon.width(), sourceIcon.height() ), sourceIcon );
|
|
||||||
painter->setOpacity( 1.0 );
|
|
||||||
|
|
||||||
rightRect.moveLeft( rightRect.left() - sourceIcon.width() - 8 );
|
|
||||||
leftRect.adjust( 0, 0, -( sourceIcon.width() + 8 ), 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->setFont( boldFont );
|
leftRect.setX( leftRect.left() + 8 );
|
||||||
QString text = painter->fontMetrics().elidedText( track->track(), Qt::ElideRight, leftRect.width() );
|
QRect rightRect = r.adjusted( r.width() - m_smallBoldFontMetrics.width( TomahawkUtils::timeToString( track->duration() ) ), 0, 0, 0 );
|
||||||
|
{
|
||||||
|
const QRect leftRectBefore = leftRect;
|
||||||
|
leftRect = drawSourceIcon( painter, leftRect, item, 0.5 );
|
||||||
|
rightRect.moveLeft( rightRect.left() - ( leftRectBefore.width() - leftRect.width() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->setFont( m_bigBoldFont );
|
||||||
|
const QString text = painter->fontMetrics().elidedText( track->track(), Qt::ElideRight, leftRect.width() );
|
||||||
painter->drawText( leftRect, text, m_topOption );
|
painter->drawText( leftRect, text, m_topOption );
|
||||||
|
|
||||||
painter->setFont( smallFont );
|
painter->setFont( m_smallFont );
|
||||||
QTextDocument textDoc;
|
QTextDocument textDoc;
|
||||||
if ( track->album().isEmpty() )
|
if ( track->album().isEmpty() )
|
||||||
textDoc.setHtml( tr( "by <b>%1</b>", "e.g. by SomeArtist" ).arg( track->artist() ) );
|
textDoc.setHtml( tr( "by <b>%1</b>", "e.g. by SomeArtist" ).arg( track->artist() ) );
|
||||||
@@ -252,7 +202,7 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
textDoc.setDefaultTextOption( m_topOption );
|
textDoc.setDefaultTextOption( m_topOption );
|
||||||
|
|
||||||
if ( textDoc.idealWidth() <= leftRect.width() )
|
if ( textDoc.idealWidth() <= leftRect.width() )
|
||||||
drawRichText( painter, opt, leftRect.adjusted( 0, boldFontMetrics.height() + 1, 0, 0 ), Qt::AlignTop, textDoc );
|
drawRichText( painter, opt, leftRect.adjusted( 0, m_bigBoldFontMetrics.height() + 1, 0, 0 ), Qt::AlignTop, textDoc );
|
||||||
|
|
||||||
if ( !( option.state & QStyle::State_Selected || item->isPlaying() ) )
|
if ( !( option.state & QStyle::State_Selected || item->isPlaying() ) )
|
||||||
painter->setPen( opt.palette.text().color().darker() );
|
painter->setPen( opt.palette.text().color().darker() );
|
||||||
@@ -270,7 +220,7 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
if ( track->duration() > 0 )
|
if ( track->duration() > 0 )
|
||||||
{
|
{
|
||||||
painter->setPen( opt.palette.text().color() );
|
painter->setPen( opt.palette.text().color() );
|
||||||
painter->setFont( smallBoldFont );
|
painter->setFont( m_smallBoldFont );
|
||||||
painter->drawText( rightRect, TomahawkUtils::timeToString( track->duration() ), m_centerRightOption );
|
painter->drawText( rightRect, TomahawkUtils::timeToString( track->duration() ), m_centerRightOption );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,16 +228,8 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PlaylistLargeItemDelegate::doUpdateIndex( const QPersistentModelIndex& idx )
|
|
||||||
{
|
|
||||||
if ( idx.isValid() )
|
|
||||||
emit updateIndex( idx );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistLargeItemDelegate::modelChanged()
|
PlaylistLargeItemDelegate::modelChanged()
|
||||||
{
|
{
|
||||||
m_pixmaps.clear();
|
PlaylistItemDelegate::modelChanged();
|
||||||
}
|
}
|
||||||
|
@@ -27,10 +27,6 @@
|
|||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
#include "Typedefs.h"
|
#include "Typedefs.h"
|
||||||
|
|
||||||
namespace Tomahawk {
|
|
||||||
class PixmapDelegateFader;
|
|
||||||
}
|
|
||||||
|
|
||||||
class PlayableItem;
|
class PlayableItem;
|
||||||
class PlayableProxyModel;
|
class PlayableProxyModel;
|
||||||
class TrackView;
|
class TrackView;
|
||||||
@@ -50,19 +46,12 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
|
|
||||||
private slots:
|
protected slots:
|
||||||
void doUpdateIndex( const QPersistentModelIndex& idx );
|
virtual void modelChanged();
|
||||||
void modelChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void drawRichText( QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, int flags, QTextDocument& text ) const;
|
void drawRichText( QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, int flags, QTextDocument& text ) const;
|
||||||
|
|
||||||
QTextOption m_topOption;
|
|
||||||
QTextOption m_centerRightOption;
|
|
||||||
QTextOption m_bottomOption;
|
|
||||||
|
|
||||||
mutable QHash< QPersistentModelIndex, QSharedPointer< Tomahawk::PixmapDelegateFader > > m_pixmaps;
|
|
||||||
|
|
||||||
TrackView* m_view;
|
TrackView* m_view;
|
||||||
PlayableProxyModel* m_model;
|
PlayableProxyModel* m_model;
|
||||||
DisplayMode m_mode;
|
DisplayMode m_mode;
|
||||||
|
Reference in New Issue
Block a user