From: Ilkka Ollakka Date: Wed, 23 Jun 2010 09:51:14 +0000 (+0300) Subject: Qt4: highlight nodepath to current item on icon_view X-Git-Tag: 1.2.0-pre1~6088 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=0d9ca0e07cdbe2903b8edc6126ee45cec815734b;p=vlc Qt4: highlight nodepath to current item on icon_view Shows user where the current input is on icon_view with tree-mode. --- diff --git a/modules/gui/qt4/components/playlist/icon_view.cpp b/modules/gui/qt4/components/playlist/icon_view.cpp index 60e1ca5af9..6a01d6e9fe 100644 --- a/modules/gui/qt4/components/playlist/icon_view.cpp +++ b/modules/gui/qt4/components/playlist/icon_view.cpp @@ -168,7 +168,10 @@ void PlIconViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt 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() ); diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp index 756ee00d0f..2c1fb7644e 100644 --- a/modules/gui/qt4/components/playlist/playlist_model.cpp +++ b/modules/gui/qt4/components/playlist/playlist_model.cpp @@ -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 ¤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; diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp index 033cdc691a..90dcf17165 100644 --- a/modules/gui/qt4/components/playlist/playlist_model.hpp +++ b/modules/gui/qt4/components/playlist/playlist_model.hpp @@ -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 ¤t) const; bool isCurrent( const QModelIndex &index ) const; int itemId( const QModelIndex &index ) const; static int columnFromMeta( int meta_column );