]> git.sesse.net Git - vlc/commitdiff
Qt: show folder icon for non-leaf nodes in iconView and listView
authorJakob Leben <jleben@videolan.org>
Wed, 3 Mar 2010 17:38:49 +0000 (18:38 +0100)
committerJakob Leben <jleben@videolan.org>
Wed, 3 Mar 2010 17:41:04 +0000 (18:41 +0100)
close #3343

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

index ebd8f77aeeb0aeab757d3dff090fac6e4c6e51e7..73c8a420255d0bfb72d5539d0eae4568ce89943b 100644 (file)
@@ -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 );
index 3f14247ed4fc28c89239d9cb6121ea8244200872..3d63618aacf6f5eb9522b48630462ddce84d02f3 100644 (file)
@@ -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();
 }
 
index 88c78e3c7820300f505598bc69c29dec54b22827..2bd9ef2e7df314daee8c2587e22027dfdf9554c8 100644 (file)
@@ -55,7 +55,8 @@ friend class PLItem;
 
 public:
     enum {
-      IsCurrentRole = Qt::UserRole
+      IsCurrentRole = Qt::UserRole,
+      IsLeafNodeRole
     };
 
     PLModel( playlist_t *, intf_thread_t *,
index a508cb806d15f76103e1929c9ee130c430f90397..bc31e5ae9b6fb1ec1dae925b7111aaaf4537703e 100644 (file)
@@ -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 );