[vlc-commits] commit: Qt: show folder icon for non-leaf nodes in iconView and listView ( Jakob Leben )

git version control git at videolan.org
Wed Mar 3 18:41:31 CET 2010


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Wed Mar  3 18:38:49 2010 +0100| [f8aeca6aea380d1477e325ee2303140281f80e3b] | committer: Jakob Leben 

Qt: show folder icon for non-leaf nodes in iconView and listView

close #3343

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f8aeca6aea380d1477e325ee2303140281f80e3b
---

 modules/gui/qt4/components/playlist/icon_view.cpp  |   24 ++++++++++++++++++++
 .../gui/qt4/components/playlist/playlist_model.cpp |   12 ++++++++++
 .../gui/qt4/components/playlist/playlist_model.hpp |    3 +-
 .../gui/qt4/components/playlist/standardpanel.cpp  |    2 +-
 4 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/icon_view.cpp b/modules/gui/qt4/components/playlist/icon_view.cpp
index ebd8f77..73c8a42 100644
--- a/modules/gui/qt4/components/playlist/icon_view.cpp
+++ b/modules/gui/qt4/components/playlist/icon_view.cpp
@@ -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 );
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 3f14247..3d63618 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -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();
 }
 
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index 88c78e3..2bd9ef2 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -55,7 +55,8 @@ friend class PLItem;
 
 public:
     enum {
-      IsCurrentRole = Qt::UserRole
+      IsCurrentRole = Qt::UserRole,
+      IsLeafNodeRole
     };
 
     PLModel( playlist_t *, intf_thread_t *,
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index a508cb8..bc31e5a 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -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 );



More information about the vlc-commits mailing list