Commit 0d9ca0e0 authored by Ilkka Ollakka's avatar Ilkka Ollakka

Qt4: highlight nodepath to current item on icon_view

Shows user where the current input is on icon_view with tree-mode.
parent 0455f985
......@@ -168,6 +168,9 @@ void PlIconViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
QRect r( option.rect );
r.setSize( QSize( 25, 25 ) );
r.translate( 5, 5 );
if( index.data( PLModel::IsCurrentsParentNodeRole ).toBool() )
painter->fillRect( r, option.palette.color( QPalette::Highlight ) );
else
painter->fillRect( r, option.palette.color( QPalette::Mid ) );
painter->setOpacity( 1.0 );
QPixmap dirPix( ":/type/node" );
......
......@@ -378,9 +378,25 @@ QVariant PLModel::data( const QModelIndex &index, int role ) const
PL_UNLOCK;
return isLeaf;
}
else if( role == IsCurrentsParentNodeRole )
{
return QVariant( isParent( index, current_index ) );
}
return QVariant();
}
/* Seek from current index toward the top and see if index is one of parent nodes */
bool PLModel::isParent( const QModelIndex &index, const QModelIndex &current ) const
{
if( index == current )
return true;
if( !current.parent().isValid() )
return false;
return isParent( index, current.parent() );
}
bool PLModel::isCurrent( const QModelIndex &index ) const
{
return index == current_index;
......
......@@ -59,7 +59,8 @@ friend class PLSelector;
public:
enum {
IsCurrentRole = Qt::UserRole,
IsLeafNodeRole
IsLeafNodeRole,
IsCurrentsParentNodeRole
};
PLModel( playlist_t *, intf_thread_t *,
......@@ -92,6 +93,7 @@ public:
QModelIndex index( PLItem *, int c ) const;
QModelIndex index( int i_id, int c );
QModelIndex currentIndex();
bool isParent( const QModelIndex &index, const QModelIndex &current) const;
bool isCurrent( const QModelIndex &index ) const;
int itemId( const QModelIndex &index ) const;
static int columnFromMeta( int meta_column );
......
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