1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 01:09:42 +01:00

* Fixed default row-height for TreeItemDelegate.

This commit is contained in:
Christian Muehlhaeuser 2012-12-23 18:52:56 +01:00
parent 3d210c05e5
commit bc3824dfad
2 changed files with 32 additions and 1 deletions

View File

@ -45,6 +45,35 @@ TreeItemDelegate::TreeItemDelegate( TreeView* parent, TreeProxyModel* proxy )
}
QSize
TreeItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
QSize size = QStyledItemDelegate::sizeHint( option, index );
if ( index.isValid() )
{
PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
if ( item )
{
if ( item->album() )
{
size.setHeight( option.fontMetrics.height() * 3 );
return size;
}
else if ( item->query() || item->result() )
{
size.setHeight( option.fontMetrics.height() * 1.6 );
return size;
}
}
}
// artist per default
size.setHeight( option.fontMetrics.height() * 4 );
return size;
}
void
TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{

View File

@ -36,7 +36,9 @@ class DLLEXPORT TreeItemDelegate : public QStyledItemDelegate
Q_OBJECT
public:
TreeItemDelegate( TreeView* parent = 0, TreeProxyModel* proxy = 0 );
TreeItemDelegate( TreeView* parent, TreeProxyModel* proxy );
virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
protected:
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;