@@ -128,7 +128,14 @@ Qt::ItemFlags QgsLayerCapabilitiesModel::flags( const QModelIndex &idx ) const
128
128
{
129
129
if ( idx.column () == IdentifiableColumn )
130
130
{
131
- return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsUserCheckable;
131
+ if ( layer->isSpatial () )
132
+ {
133
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsUserCheckable;
134
+ }
135
+ else
136
+ {
137
+ return nullptr ;
138
+ }
132
139
}
133
140
else if ( idx.column () == ReadOnlyColumn )
134
141
{
@@ -138,7 +145,7 @@ Qt::ItemFlags QgsLayerCapabilitiesModel::flags( const QModelIndex &idx ) const
138
145
}
139
146
else
140
147
{
141
- return Qt::ItemIsSelectable | Qt::ItemIsUserCheckable ;
148
+ return nullptr ;
142
149
}
143
150
}
144
151
else if ( idx.column () == SearchableColumn )
@@ -224,15 +231,18 @@ QVariant QgsLayerCapabilitiesModel::data( const QModelIndex &idx, int role ) con
224
231
QVariant falseValue = role == Qt::CheckStateRole ? Qt::Unchecked : false ;
225
232
if ( idx.column () == IdentifiableColumn )
226
233
{
227
- return !mNonIdentifiableLayers .contains ( layer->id () ) ? trueValue : falseValue;
234
+ if ( layer->isSpatial () )
235
+ return !mNonIdentifiableLayers .contains ( layer->id () ) ? trueValue : falseValue;
228
236
}
229
237
else if ( idx.column () == ReadOnlyColumn )
230
238
{
231
- return mReadOnlyLayers .value ( layer, true ) ? trueValue : falseValue;
239
+ if ( layer->type () == QgsMapLayer::VectorLayer )
240
+ return mReadOnlyLayers .value ( layer, true ) ? trueValue : falseValue;
232
241
}
233
242
else if ( idx.column () == SearchableColumn )
234
243
{
235
- return mSearchableLayers .value ( layer, true ) ? trueValue : falseValue;
244
+ if ( layer->type () == QgsMapLayer::VectorLayer )
245
+ return mSearchableLayers .value ( layer, true ) ? trueValue : falseValue;
236
246
}
237
247
}
238
248
}
@@ -249,19 +259,21 @@ bool QgsLayerCapabilitiesModel::setData( const QModelIndex &index, const QVarian
249
259
{
250
260
if ( index .column () == IdentifiableColumn )
251
261
{
252
- bool nonIdentifiable = value == Qt::Unchecked;
253
- bool containsLayer = mNonIdentifiableLayers .contains ( layer->id () );
254
- if ( containsLayer && !nonIdentifiable )
255
- mNonIdentifiableLayers .removeAll ( layer->id () );
256
- if ( !containsLayer && nonIdentifiable )
257
- mNonIdentifiableLayers .append ( layer->id () );
258
- emit dataChanged ( index , index );
259
- return true ;
262
+ if ( layer->isSpatial () )
263
+ {
264
+ bool nonIdentifiable = value == Qt::Unchecked;
265
+ bool containsLayer = mNonIdentifiableLayers .contains ( layer->id () );
266
+ if ( containsLayer && !nonIdentifiable )
267
+ mNonIdentifiableLayers .removeAll ( layer->id () );
268
+ if ( !containsLayer && nonIdentifiable )
269
+ mNonIdentifiableLayers .append ( layer->id () );
270
+ emit dataChanged ( index , index );
271
+ return true ;
272
+ }
260
273
}
261
274
else if ( index .column () == ReadOnlyColumn )
262
275
{
263
- QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
264
- if ( vl )
276
+ if ( layer->type () == QgsMapLayer::VectorLayer )
265
277
{
266
278
mReadOnlyLayers .insert ( layer, value == Qt::Checked );
267
279
emit dataChanged ( index , index );
@@ -270,8 +282,7 @@ bool QgsLayerCapabilitiesModel::setData( const QModelIndex &index, const QVarian
270
282
}
271
283
else if ( index .column () == SearchableColumn )
272
284
{
273
- QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
274
- if ( vl )
285
+ if ( layer->type () == QgsMapLayer::VectorLayer )
275
286
{
276
287
mSearchableLayers .insert ( layer, value == Qt::Checked );
277
288
emit dataChanged ( index , index );
0 commit comments