Skip to content
Permalink
Browse files
[layertree] do not allow drag'n'drop of internal embedded nodes
  • Loading branch information
wonder-sk committed May 27, 2014
1 parent e4d0f15 commit bba9a99d32b68ea459fb2715b4c7d40e7d39151f
Showing with 14 additions and 3 deletions.
  1. +14 −3 src/gui/layertree/qgslayertreemodel.cpp
@@ -271,15 +271,26 @@ Qt::ItemFlags QgsLayerTreeModel::flags( const QModelIndex& index ) const
return Qt::ItemIsEnabled; // | Qt::ItemIsSelectable;

Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable;

if ( testFlag( AllowNodeRename ) )
f |= Qt::ItemIsEditable;
if ( testFlag( AllowNodeReorder ) )
f |= Qt::ItemIsDragEnabled;

QgsLayerTreeNode* node = index2node( index );
bool isEmbedded = node->customProperty( "embedded" ).toInt();

if ( testFlag( AllowNodeReorder ) )
{
// only root embedded nodes can be reordered
if ( !isEmbedded || ( isEmbedded && node->parent() && !node->parent()->customProperty( "embedded" ).toInt() ) )
f |= Qt::ItemIsDragEnabled;
}

if ( testFlag( AllowNodeChangeVisibility ) && ( QgsLayerTree::isLayer( node ) || QgsLayerTree::isGroup( node ) ) )
f |= Qt::ItemIsUserCheckable;
if ( testFlag( AllowNodeReorder ) && QgsLayerTree::isGroup( node ) )

if ( testFlag( AllowNodeReorder ) && QgsLayerTree::isGroup( node ) && !isEmbedded )
f |= Qt::ItemIsDropEnabled;

return f;
}

0 comments on commit bba9a99

Please sign in to comment.