1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-07 14:46:33 +02:00

* A few more cleanups inside the playlist item delegate.

This commit is contained in:
Christian Muehlhaeuser
2011-01-24 05:55:57 +01:00
parent b9eb9ca6d4
commit fcad645e45
2 changed files with 11 additions and 6 deletions

View File

@@ -2,7 +2,6 @@
#include <QDebug> #include <QDebug>
#include <QPainter> #include <QPainter>
#include <QAbstractItemView>
#include "query.h" #include "query.h"
#include "result.h" #include "result.h"
@@ -22,6 +21,7 @@ PlaylistItemDelegate::PlaylistItemDelegate( TrackView* parent, TrackProxyModel*
, m_view( parent ) , m_view( parent )
, m_model( proxy ) , m_model( proxy )
{ {
m_nowPlayingIcon = QPixmap( PLAYING_ICON );
} }
@@ -65,18 +65,21 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
painter->setRenderHint( QPainter::Antialiasing ); painter->setRenderHint( QPainter::Antialiasing );
{ {
QRect r = option.rect.adjusted( 3, 0, 0, -3 ); QRect r = option.rect.adjusted( 3, 0, 0, 0 );
if ( m_view->header()->visualIndex( index.column() ) == 0 ) if ( m_view->header()->visualIndex( index.column() ) == 0 )
{ {
painter->drawPixmap( r.adjusted( 3, 3, 18 - r.width(), 0 ), QPixmap( PLAYING_ICON ) ); r.adjust( 0, 0, 0, -3 );
r = r.adjusted( 22, 0, 0, 0 ); painter->drawPixmap( r.adjusted( 3, 3, 18 - r.width(), 0 ), m_nowPlayingIcon );
r.adjust( 22, 0, 0, 3 );
} }
QTextOption to( Qt::AlignVCenter );
painter->setPen( option.palette.text().color() ); painter->setPen( option.palette.text().color() );
painter->drawText( r.adjusted( 0, 2, 0, 0 ), index.data().toString() ); painter->drawText( r.adjusted( 0, 1, 0, 0 ), index.data().toString(), to );
} }
if ( m_view->header()->visualIndex( index.column() ) == m_view->header()->visibleSectionCount() - 1 ) if ( m_view->header()->visualIndex( index.column() ) == m_view->header()->visibleSectionCount() - 1 )
{ {
QRect r = QRect( 3, option.rect.y() + 1, m_view->viewport()->width() - 6, option.rect.height() - 2 ); QRect r = QRect( 3, option.rect.y() + 1, m_view->viewport()->width() - 6, option.rect.height() - 2 );
painter->setPen( option.palette.highlight().color() ); painter->setPen( option.palette.highlight().color() );

View File

@@ -28,6 +28,8 @@ protected:
private: private:
unsigned int m_removalProgress; unsigned int m_removalProgress;
QPixmap m_nowPlayingIcon;
TrackView* m_view; TrackView* m_view;
TrackProxyModel* m_model; TrackProxyModel* m_model;
}; };