Commit f8aeca6a authored by Jakob Leben's avatar Jakob Leben

Qt: show folder icon for non-leaf nodes in iconView and listView

close #3343
parent 3fbf9b48
......@@ -160,6 +160,21 @@ void PlIconViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
QFont font( index.data( Qt::FontRole ).value<QFont>() );
font.setPointSize( 7 );
//Draw children indicator
if( !index.data( PLModel::IsLeafNodeRole ).toBool() )
{
painter->setOpacity( 0.75 );
QRect r( option.rect );
r.setSize( QSize( 25, 25 ) );
r.translate( 5, 5 );
painter->fillRect( r, option.palette.color( QPalette::Mid ) );
painter->setOpacity( 1.0 );
QPixmap dirPix( ":/type/node" );
QRect r2( dirPix.rect() );
r2.moveCenter( r.center() );
painter->drawPixmap( r2, dirPix );
}
// Draw title
font.setItalic( true );
painter->setFont( font );
......@@ -254,6 +269,15 @@ void PlListViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
textRect.moveBottom( option.rect.center().y() - 1 );
}
//Draw children indicator
if( !index.data( PLModel::IsLeafNodeRole ).toBool() )
{
QPixmap dirPix = QPixmap( ":/type/node" );
painter->drawPixmap( QPoint( textRect.x(), textRect.center().y() - dirPix.height() / 2 ),
dirPix );
textRect.setLeft( textRect.x() + dirPix.width() + 5 );
}
painter->drawText( textRect,
fm.elidedText( title, Qt::ElideRight, textRect.width() ),
textOpt );
......
......@@ -354,7 +354,19 @@ QVariant PLModel::data( const QModelIndex &index, int role ) const
return QVariant( QBrush( Qt::gray ) );
}
else if( role == IsCurrentRole ) return QVariant( isCurrent( index ) );
else if( role == IsLeafNodeRole )
{
QVariant isLeaf;
PL_LOCK;
playlist_item_t *plItem =
playlist_ItemGetById( p_playlist, item->i_id );
if( plItem )
isLeaf = plItem->i_children == -1;
PL_UNLOCK;
return isLeaf;
}
return QVariant();
}
......
......@@ -55,7 +55,8 @@ friend class PLItem;
public:
enum {
IsCurrentRole = Qt::UserRole
IsCurrentRole = Qt::UserRole,
IsLeafNodeRole
};
PLModel( playlist_t *, intf_thread_t *,
......
......@@ -406,7 +406,7 @@ void StandardPLPanel::cycleViews()
void StandardPLPanel::activate( const QModelIndex &index )
{
if( model->hasChildren( index ) )
if( !index.data( PLModel::IsLeafNodeRole ).toBool() )
{
if( currentView != treeView )
browseInto( index );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment