Make click on a unchecked layer in the tree view check all its parents.

This removes the Ctrl+clic requirement added initially.
This commit is contained in:
Even Rouault 2017-01-03 12:47:35 +01:00
parent 60a1701377
commit 02b78a96f6
2 changed files with 6 additions and 2 deletions

View File

@ -394,7 +394,11 @@ bool QgsLayerTreeModel::setData( const QModelIndex& index, const QVariant& value
return false;
bool checked = static_cast< Qt::CheckState >( value.toInt() ) == Qt::Checked;
if ( testFlag( ActionHierarchical ) )
if ( checked && node->children().isEmpty() )
{
node->setItemVisibilityCheckedParentRecursive( checked );
}
else if ( testFlag( ActionHierarchical ) )
{
if ( node->children().isEmpty() )
node->setItemVisibilityCheckedParentRecursive( checked );

View File

@ -148,7 +148,7 @@ QAction* QgsLayerTreeViewDefaultActions::actionCheckAndAllParents( QObject* pare
QgsLayerTreeNode* node = mView->currentNode();
if ( !node || !QgsLayerTree::isLayer( node ) || node->isVisible() )
return nullptr;
QAction* a = new QAction( tr( "Check and all its parents (Ctrl-click)" ), parent );
QAction* a = new QAction( tr( "Check and all its parents" ), parent );
connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::checkAndAllParents );
return a;
}