Skip to content
Permalink
Browse files

non spatial are not identifiable

also removes checkboxes from items not being checkable
  • Loading branch information
3nids committed Sep 3, 2018
1 parent c6caa29 commit 88d482e144ce8f79d3c7f193ace5c30484239e1e
Showing with 30 additions and 18 deletions.
  1. +28 −17 src/app/qgslayercapabilitiesmodel.cpp
  2. +2 −1 src/core/qgsmaplayer.cpp
@@ -128,7 +128,14 @@ Qt::ItemFlags QgsLayerCapabilitiesModel::flags( const QModelIndex &idx ) const
{
if ( idx.column() == IdentifiableColumn )
{
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsUserCheckable;
if ( layer->isSpatial() )
{
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsUserCheckable;
}
else
{
return nullptr;
}
}
else if ( idx.column() == ReadOnlyColumn )
{
@@ -138,7 +145,7 @@ Qt::ItemFlags QgsLayerCapabilitiesModel::flags( const QModelIndex &idx ) const
}
else
{
return Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
return nullptr;
}
}
else if ( idx.column() == SearchableColumn )
@@ -224,15 +231,18 @@ QVariant QgsLayerCapabilitiesModel::data( const QModelIndex &idx, int role ) con
QVariant falseValue = role == Qt::CheckStateRole ? Qt::Unchecked : false;
if ( idx.column() == IdentifiableColumn )
{
return !mNonIdentifiableLayers.contains( layer->id() ) ? trueValue : falseValue;
if ( layer->isSpatial() )
return !mNonIdentifiableLayers.contains( layer->id() ) ? trueValue : falseValue;
}
else if ( idx.column() == ReadOnlyColumn )
{
return mReadOnlyLayers.value( layer, true ) ? trueValue : falseValue;
if ( layer->type() == QgsMapLayer::VectorLayer )
return mReadOnlyLayers.value( layer, true ) ? trueValue : falseValue;
}
else if ( idx.column() == SearchableColumn )
{
return mSearchableLayers.value( layer, true ) ? trueValue : falseValue;
if ( layer->type() == QgsMapLayer::VectorLayer )
return mSearchableLayers.value( layer, true ) ? trueValue : falseValue;
}
}
}
@@ -249,19 +259,21 @@ bool QgsLayerCapabilitiesModel::setData( const QModelIndex &index, const QVarian
{
if ( index.column() == IdentifiableColumn )
{
bool nonIdentifiable = value == Qt::Unchecked;
bool containsLayer = mNonIdentifiableLayers.contains( layer->id() );
if ( containsLayer && !nonIdentifiable )
mNonIdentifiableLayers.removeAll( layer->id() );
if ( !containsLayer && nonIdentifiable )
mNonIdentifiableLayers.append( layer->id() );
emit dataChanged( index, index );
return true;
if ( layer->isSpatial() )
{
bool nonIdentifiable = value == Qt::Unchecked;
bool containsLayer = mNonIdentifiableLayers.contains( layer->id() );
if ( containsLayer && !nonIdentifiable )
mNonIdentifiableLayers.removeAll( layer->id() );
if ( !containsLayer && nonIdentifiable )
mNonIdentifiableLayers.append( layer->id() );
emit dataChanged( index, index );
return true;
}
}
else if ( index.column() == ReadOnlyColumn )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
if ( vl )
if ( layer->type() == QgsMapLayer::VectorLayer )
{
mReadOnlyLayers.insert( layer, value == Qt::Checked );
emit dataChanged( index, index );
@@ -270,8 +282,7 @@ bool QgsLayerCapabilitiesModel::setData( const QModelIndex &index, const QVarian
}
else if ( index.column() == SearchableColumn )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
if ( vl )
if ( layer->type() == QgsMapLayer::VectorLayer )
{
mSearchableLayers.insert( layer, value == Qt::Checked );
emit dataChanged( index, index );
@@ -247,7 +247,8 @@ bool QgsMapLayer::readLayerXml( const QDomElement &layerElement, QgsReadWriteCo
QDomNode srsNode = layerElement.namedItem( QStringLiteral( "srs" ) );
mCRS.readXml( srsNode );
mCRS.setValidationHint( tr( "Specify CRS for layer %1" ).arg( mne.text() ) );
mCRS.validate();
if ( isSpatial() )
mCRS.validate();
savedCRS = mCRS;

// Do not validate any projections in children, they will be overwritten anyway.

0 comments on commit 88d482e

Please sign in to comment.
You can’t perform that action at this time.