[vlc-devel] commit: Qt4: disable removing service discovery items (Jakob Leben )
git version control
git at videolan.org
Sun Nov 1 15:58:44 CET 2009
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Sun Nov 1 15:45:19 2009 +0100| [ee145e3acff6449afb3a27a9e505213518873d40] | committer: Jakob Leben
Qt4: disable removing service discovery items
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ee145e3acff6449afb3a27a9e505213518873d40
---
.../gui/qt4/components/playlist/playlist_model.cpp | 25 ++++++++++++-------
.../gui/qt4/components/playlist/playlist_model.hpp | 1 +
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 198cb85..f5b6273 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -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];
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index 10697fb..620ea81 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -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;
More information about the vlc-devel
mailing list