]> git.sesse.net Git - vlc/commitdiff
Qt4: highlight nodepath to current item on icon_view
authorIlkka Ollakka <ileoo@videolan.org>
Wed, 23 Jun 2010 09:51:14 +0000 (12:51 +0300)
committerIlkka Ollakka <ileoo@videolan.org>
Wed, 23 Jun 2010 09:52:27 +0000 (12:52 +0300)
Shows user where the current input is on icon_view with tree-mode.

modules/gui/qt4/components/playlist/icon_view.cpp
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.hpp

index 60e1ca5af9ebd55d36d10f6f2ebdd035eb34d2a0..6a01d6e9fe422d7b702f7ad9cfc030df4c995b73 100644 (file)
@@ -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() );
index 756ee00d0f86eba2b02282b15dd5eb491249fbdc..2c1fb7644e2f206f7bcf4b361d3648fc2c773f36 100644 (file)
@@ -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;
index 033cdc691ac1e576ee82d64c273d2b3c7e40bbe2..90dcf1716548b53ce2fd674d13937b75ee87612a 100644 (file)
@@ -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 );