Skip to content

Commit

Permalink
[layertree] do not allow drag'n'drop of internal embedded nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed May 27, 2014
1 parent e4d0f15 commit bba9a99
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/gui/layertree/qgslayertreemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit bba9a99

Please sign in to comment.