mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 07:36:48 +02:00
Align some columns centered in playlistitemdelegate: albumpos, duration, etc
This commit is contained in:
@@ -59,6 +59,9 @@ PlaylistItemDelegate::PlaylistItemDelegate( TrackView* parent, TrackProxyModel*
|
|||||||
m_centerOption = QTextOption( Qt::AlignVCenter );
|
m_centerOption = QTextOption( Qt::AlignVCenter );
|
||||||
m_centerOption.setWrapMode( QTextOption::NoWrap );
|
m_centerOption.setWrapMode( QTextOption::NoWrap );
|
||||||
|
|
||||||
|
m_hCenterOption = QTextOption( Qt::AlignHCenter );
|
||||||
|
m_hCenterOption.setWrapMode( QTextOption::NoWrap );
|
||||||
|
|
||||||
m_defaultAvatar = TomahawkUtils::createAvatarFrame( QPixmap( RESPATH "images/user-avatar.png" ) );
|
m_defaultAvatar = TomahawkUtils::createAvatarFrame( QPixmap( RESPATH "images/user-avatar.png" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,15 +310,35 @@ PlaylistItemDelegate::paintDetailed( QPainter* painter, const QStyleOptionViewIt
|
|||||||
|
|
||||||
painter->setPen( opt.palette.text().color() );
|
painter->setPen( opt.palette.text().color() );
|
||||||
QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, r.width() - 3 );
|
QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, r.width() - 3 );
|
||||||
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_centerOption );
|
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, textOptionForColumn( index.column() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
painter->setPen( opt.palette.text().color() );
|
painter->setPen( opt.palette.text().color() );
|
||||||
QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, opt.rect.width() - 3 );
|
QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, opt.rect.width() - 3 );
|
||||||
painter->drawText( opt.rect.adjusted( 3, 1, 0, 0 ), text, m_centerOption );
|
painter->drawText( opt.rect.adjusted( 3, 1, 0, 0 ), text, textOptionForColumn( index.column() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QTextOption
|
||||||
|
PlaylistItemDelegate::textOptionForColumn( int column ) const
|
||||||
|
{
|
||||||
|
switch( column )
|
||||||
|
{
|
||||||
|
case TrackModel::Age:
|
||||||
|
case TrackModel::AlbumPos:
|
||||||
|
case TrackModel::Bitrate:
|
||||||
|
case TrackModel::Duration:
|
||||||
|
case TrackModel::Filesize:
|
||||||
|
case TrackModel::Year:
|
||||||
|
return m_hCenterOption;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return m_centerOption;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -52,6 +52,8 @@ private:
|
|||||||
void paintDetailed( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
void paintDetailed( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
void paintShort( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, bool useAvatars = false ) const;
|
void paintShort( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, bool useAvatars = false ) const;
|
||||||
|
|
||||||
|
const QTextOption textOptionForColumn( int column ) const;
|
||||||
|
|
||||||
unsigned int m_removalProgress;
|
unsigned int m_removalProgress;
|
||||||
|
|
||||||
mutable QHash< qint64, QPixmap > m_cache;
|
mutable QHash< qint64, QPixmap > m_cache;
|
||||||
@@ -61,6 +63,7 @@ private:
|
|||||||
QTextOption m_topOption;
|
QTextOption m_topOption;
|
||||||
QTextOption m_centerOption;
|
QTextOption m_centerOption;
|
||||||
QTextOption m_bottomOption;
|
QTextOption m_bottomOption;
|
||||||
|
QTextOption m_hCenterOption;
|
||||||
|
|
||||||
TrackView* m_view;
|
TrackView* m_view;
|
||||||
TrackProxyModel* m_model;
|
TrackProxyModel* m_model;
|
||||||
|
Reference in New Issue
Block a user