[vlc-commits] Qt: PLModel: don't rely on model's root for finding root type

Francois Cartegnie git at videolan.org
Mon Aug 19 23:01:47 CEST 2013


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Aug 19 23:00:05 2013 +0200| [8003386079161d9c7c0c1adc2789aecad1376310] | committer: Francois Cartegnie

Qt: PLModel: don't rely on model's root for finding root type

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

 .../gui/qt4/components/playlist/playlist_model.cpp    |   17 +++++++++++++----
 .../gui/qt4/components/playlist/playlist_model.hpp    |    3 ++-
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index f6aec2c..527bdbb 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -613,11 +613,20 @@ PLItem * PLModel::findInner( PLItem *root, int i_id, bool b_isinputid ) const
 
 PLModel::pl_nodetype PLModel::getPLRootType() const
 {
-    if ( rootItem->id( PLAYLIST_ID ) == 3 )
+    /* can't rely on rootitem as it depends on view / rebuild() */
+    AbstractPLItem *plitem = rootItem;
+
+    while( plitem->parent() ) plitem = plitem->parent();
+
+    switch( plitem->id( PLAYLIST_ID ) )
+    {
+    case 2:
+        return ROOTTYPE_CURRENT_PLAYING;
+    case 3:
         return ROOTTYPE_MEDIA_LIBRARY;
-    else
-        return ROOTTYPE_CURRENT_PLAYING; // id == 2
-    /* FIXME: handle all cases */
+    default:
+        return ROOTTYPE_OTHER;
+    }
 }
 
 bool PLModel::canEdit() const
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index c0081ad..1434f1b 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -221,7 +221,8 @@ private:
     enum pl_nodetype
     {
         ROOTTYPE_CURRENT_PLAYING,
-        ROOTTYPE_MEDIA_LIBRARY
+        ROOTTYPE_MEDIA_LIBRARY,
+        ROOTTYPE_OTHER
     };
     pl_nodetype getPLRootType() const;
 



More information about the vlc-commits mailing list