Commit ee145e3a authored by Jakob Leben's avatar Jakob Leben

Qt4: disable removing service discovery items

parent c235001a
...@@ -113,15 +113,7 @@ Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const ...@@ -113,15 +113,7 @@ Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const
PLItem *item = index.isValid() ? getItem( index ) : rootItem; PLItem *item = index.isValid() ? getItem( index ) : rootItem;
input_item_t *pl_input = if( canEdit() )
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 ) )
{ {
PL_LOCK; PL_LOCK;
playlist_item_t *plItem = playlist_item_t *plItem =
...@@ -610,6 +602,19 @@ int PLModel::columnFromMeta( int meta_col ) const ...@@ -610,6 +602,19 @@ int PLModel::columnFromMeta( int meta_col ) const
return column; 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 *****************************/ /************************* Updates handling *****************************/
void PLModel::customEvent( QEvent *event ) void PLModel::customEvent( QEvent *event )
{ {
...@@ -823,6 +828,8 @@ void PLModel::updateTreeItem( PLItem *item ) ...@@ -823,6 +828,8 @@ void PLModel::updateTreeItem( PLItem *item )
*/ */
void PLModel::doDelete( QModelIndexList selected ) void PLModel::doDelete( QModelIndexList selected )
{ {
if( !canEdit() ) return;
for( int i = selected.size() -1 ; i >= 0; i-- ) for( int i = selected.size() -1 ; i >= 0; i-- )
{ {
QModelIndex index = selected[i]; QModelIndex index = selected[i];
......
...@@ -171,6 +171,7 @@ private: ...@@ -171,6 +171,7 @@ private:
static inline PLItem *getItem( QModelIndex index ); static inline PLItem *getItem( QModelIndex index );
int columnFromMeta( int meta_column ) const; int columnFromMeta( int meta_column ) const;
int columnToMeta( int column ) const; int columnToMeta( int column ) const;
bool canEdit() const;
PLItem *p_cached_item; PLItem *p_cached_item;
PLItem *p_cached_item_bi; PLItem *p_cached_item_bi;
int i_cached_id; int i_cached_id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment