mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
* Fixed default row-height for TreeItemDelegate.
This commit is contained in:
@@ -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
|
void
|
||||||
TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
|
@@ -36,7 +36,9 @@ class DLLEXPORT TreeItemDelegate : public QStyledItemDelegate
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TreeItemDelegate( TreeView* parent = 0, TreeProxyModel* proxy = 0 );
|
TreeItemDelegate( TreeView* parent, TreeProxyModel* proxy );
|
||||||
|
|
||||||
|
virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
|
Reference in New Issue
Block a user