]> git.sesse.net Git - vlc/commitdiff
Qt4: disable removing service discovery items
authorJakob Leben <jleben@videolan.org>
Sun, 1 Nov 2009 14:45:19 +0000 (15:45 +0100)
committerJakob Leben <jleben@videolan.org>
Sun, 1 Nov 2009 14:45:19 +0000 (15:45 +0100)
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.hpp

index 198cb854eeeea4c7102098104f0e30aeb1cba79a..f5b627368c6518a20287496a0e60160920019862 100644 (file)
@@ -113,15 +113,7 @@ Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const
 
     PLItem *item = index.isValid() ? getItem( index ) : rootItem;
 
-    input_item_t *pl_input =
-        p_playlist->p_local_category ?
-        p_playlist->p_local_category->p_input : NULL;
-    input_item_t *ml_input =
-        p_playlist->p_ml_category ?
-        p_playlist->p_ml_category->p_input : NULL;
-
-    if( ( pl_input && rootItem->p_input == pl_input ) ||
-              ( ml_input && rootItem->p_input == ml_input ) )
+    if( canEdit() )
     {
         PL_LOCK;
         playlist_item_t *plItem =
@@ -610,6 +602,19 @@ int PLModel::columnFromMeta( int meta_col ) const
     return column;
 }
 
+bool PLModel::canEdit() const
+{
+  return (
+    rootItem != NULL &&
+    (
+      rootItem->p_input == p_playlist->p_local_category->p_input ||
+      (
+        p_playlist->p_ml_category &&
+        rootItem->p_input == p_playlist->p_ml_category->p_input
+      )
+    )
+  );
+}
 /************************* Updates handling *****************************/
 void PLModel::customEvent( QEvent *event )
 {
@@ -823,6 +828,8 @@ void PLModel::updateTreeItem( PLItem *item )
  */
 void PLModel::doDelete( QModelIndexList selected )
 {
+    if( !canEdit() ) return;
+
     for( int i = selected.size() -1 ; i >= 0; i-- )
     {
         QModelIndex index = selected[i];
index 10697fb95a704b2367677827749c3c69eab925f2..620ea81db8bc0f0d5e15234e33f6bc4abf14097d 100644 (file)
@@ -171,6 +171,7 @@ private:
     static inline PLItem *getItem( QModelIndex index );
     int columnFromMeta( int meta_column ) const;
     int columnToMeta( int column ) const;
+    bool canEdit() const;
     PLItem *p_cached_item;
     PLItem *p_cached_item_bi;
     int i_cached_id;