@@ -154,27 +154,28 @@ QVector<QgsDataItem *> QgsGeoPackageConnectionItem::createChildren()
154
154
QString geometryType = pieces[3 ];
155
155
QgsLayerItem::LayerType layerType;
156
156
layerType = layerTypeFromDb ( geometryType );
157
- if ( layerType != QgsLayerItem::LayerType::NoType )
157
+ if ( geometryType. contains ( QStringLiteral ( " Collection " ), Qt::CaseInsensitive ) )
158
158
{
159
- if ( geometryType.contains ( QStringLiteral ( " Collection" ), Qt::CaseInsensitive ) )
159
+ QgsDebugMsgLevel ( QStringLiteral ( " Layer %1 is a geometry collection: skipping %2" ).arg ( name, mPath ), 3 );
160
+ }
161
+ else
162
+ {
163
+ // example URI: '/path/gdal_sample_v1.2_no_extensions.gpkg|layerid=7|geometrytype=Point'
164
+ QString uri;
165
+ // We do not need to add a geometry type for table layers
166
+ if ( layerType != QgsLayerItem::LayerType::TableLayer )
160
167
{
161
- QgsDebugMsgLevel ( QStringLiteral ( " Layer %1 is a geometry collection: skipping %2 " ).arg ( name, mPath ), 3 );
168
+ uri = QStringLiteral ( " %1|layerid=%2|geometrytype=%3 " ).arg ( mPath , layerId, geometryType );
162
169
}
163
170
else
164
171
{
165
- // example URI: '/path/gdal_sample_v1.2_no_extensions.gpkg|layerid=7|geometrytype=Point'
166
- QString uri = QStringLiteral ( " %1|layerid=%2|geometrytype=%3" ).arg ( mPath , layerId, geometryType );
167
- // TODO?: not sure, but if it's a collection, an expandable node would be better?
168
- QgsGeoPackageVectorLayerItem *item = new QgsGeoPackageVectorLayerItem ( this , name, mPath , uri, layerType );
169
- QgsDebugMsgLevel ( QStringLiteral ( " Adding GPKG Vector item %1 %2 %3" ).arg ( name, uri, geometryType ), 3 );
170
- children.append ( item );
172
+ uri = QStringLiteral ( " %1|layerid=%2" ).arg ( mPath , layerId );
171
173
}
174
+ // TODO?: not sure, but if it's a collection, an expandable node would be better?
175
+ QgsGeoPackageVectorLayerItem *item = new QgsGeoPackageVectorLayerItem ( this , name, mPath , uri, layerType );
176
+ QgsDebugMsgLevel ( QStringLiteral ( " Adding GPKG Vector item %1 %2 %3" ).arg ( name, uri, geometryType ), 3 );
177
+ children.append ( item );
172
178
}
173
- else
174
- {
175
- QgsDebugMsgLevel ( QStringLiteral ( " Layer type is not a supported GeoPackage Vector layer %1" ).arg ( mPath ), 3 );
176
- }
177
-
178
179
}
179
180
}
180
181
// Raster layers
@@ -235,16 +236,12 @@ QgsLayerItem::LayerType QgsGeoPackageConnectionItem::layerTypeFromDb( const QStr
235
236
{
236
237
return QgsLayerItem::LayerType::Vector;
237
238
}
238
- else if ( geometryType.contains ( QStringLiteral ( " Table" ), Qt::CaseInsensitive ) )
239
- {
240
- return QgsLayerItem::LayerType::Table;
241
- }
242
239
// To be moved in a parent class that would also work for gdal and rasters
243
240
else if ( geometryType.contains ( QStringLiteral ( " Raster" ), Qt::CaseInsensitive ) )
244
241
{
245
242
return QgsLayerItem::LayerType::Raster;
246
243
}
247
- return QgsLayerItem::LayerType::NoType ;
244
+ return QgsLayerItem::LayerType::TableLayer ;
248
245
}
249
246
250
247
void QgsGeoPackageConnectionItem::deleteConnection ()
0 commit comments