@@ -76,7 +76,7 @@ void QgsPgTableModel::addTableEntry( QgsPostgresLayerProperty layerProperty )
76
76
QList<QStandardItem*> childItemList;
77
77
78
78
QStandardItem *schemaNameItem = new QStandardItem ( layerProperty.schemaName );
79
- schemaNameItem->setFlags ( Qt::ItemIsEnabled );
79
+ schemaNameItem->setFlags ( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
80
80
81
81
QStandardItem *typeItem = new QStandardItem ( iconForGeomType ( geomType ),
82
82
geomType == QGis::UnknownGeometry
@@ -121,13 +121,18 @@ void QgsPgTableModel::addTableEntry( QgsPostgresLayerProperty layerProperty )
121
121
childItemList << selItem;
122
122
childItemList << sqlItem;
123
123
124
- if ( geomType == QGis::UnknownGeometry ||
125
- ( geomType != QGis::NoGeometry && layerProperty.srid .isEmpty () ) ||
126
- pkText == tr ( " Select..." ) )
124
+ bool detailsFromThread = geomType == QGis::UnknownGeometry ||
125
+ ( geomType != QGis::NoGeometry && layerProperty.srid .isEmpty () );
126
+
127
+ if ( detailsFromThread || pkText == tr ( " Select..." ) )
127
128
{
129
+ Qt::ItemFlags flags = Qt::ItemIsSelectable;
130
+ if ( detailsFromThread )
131
+ flags |= Qt::ItemIsEnabled;
132
+
128
133
foreach ( QStandardItem *item, childItemList )
129
134
{
130
- item->setFlags ( item->flags () & ~( Qt::ItemIsEnabled | Qt::ItemIsSelectable ) );
135
+ item->setFlags ( item->flags () & ~flags );
131
136
}
132
137
}
133
138
@@ -348,19 +353,25 @@ QString QgsPgTableModel::layerURI( const QModelIndex &index, QString connInfo, b
348
353
349
354
QString schemaName = index.sibling ( index.row (), dbtmSchema ).data ( Qt::DisplayRole ).toString ();
350
355
QString tableName = index.sibling ( index.row (), dbtmTable ).data ( Qt::DisplayRole ).toString ();
351
- QString geomColumnName = index.sibling ( index.row (), dbtmGeomCol ).data ( Qt::DisplayRole ).toString ();
352
356
353
- QString srid = index.sibling ( index.row (), dbtmSrid ).data ( Qt::DisplayRole ).toString ();
354
- bool ok;
355
- srid.toInt ( &ok );
356
- if ( !ok )
357
- return QString::null;
357
+ QString geomColumnName;
358
+ QString srid;
359
+ if ( geomType != QGis::NoGeometry )
360
+ {
361
+ geomColumnName = index.sibling ( index.row (), dbtmGeomCol ).data ( Qt::DisplayRole ).toString ();
362
+
363
+ srid = index.sibling ( index.row (), dbtmSrid ).data ( Qt::DisplayRole ).toString ();
364
+ bool ok;
365
+ srid.toInt ( &ok );
366
+ if ( !ok )
367
+ return QString::null;
368
+ }
358
369
359
370
bool selectAtId = itemFromIndex ( index.sibling ( index.row (), dbtmSelectAtId ) )->checkState () == Qt::Checked;
360
371
QString sql = index.sibling ( index.row (), dbtmSql ).data ( Qt::DisplayRole ).toString ();
361
372
362
373
QgsDataSourceURI uri ( connInfo );
363
- uri.setDataSource ( schemaName, tableName, geomType != QGis::NoGeometry ? geomColumnName : QString::null , sql, pkColumnName );
374
+ uri.setDataSource ( schemaName, tableName, geomColumnName, sql, pkColumnName );
364
375
uri.setUseEstimatedMetadata ( useEstimatedMetadata );
365
376
uri.setGeometryType ( geomType );
366
377
uri.setSrid ( srid );
0 commit comments