Shows user where the current input is on icon_view with tree-mode.
QRect r( option.rect );
r.setSize( QSize( 25, 25 ) );
r.translate( 5, 5 );
- painter->fillRect( r, option.palette.color( QPalette::Mid ) );
+ 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" );
QRect r2( dirPix.rect() );
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 ¤t ) 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;
public:
enum {
IsCurrentRole = Qt::UserRole,
- IsLeafNodeRole
+ IsLeafNodeRole,
+ IsCurrentsParentNodeRole
};
PLModel( playlist_t *, intf_thread_t *,
QModelIndex index( PLItem *, int c ) const;
QModelIndex index( int i_id, int c );
QModelIndex currentIndex();
+ bool isParent( const QModelIndex &index, const QModelIndex ¤t) const;
bool isCurrent( const QModelIndex &index ) const;
int itemId( const QModelIndex &index ) const;
static int columnFromMeta( int meta_column );