Skip to content

Commit

Permalink
postgres provider fix: layers with incomplete geometry type/srid/pk d…
Browse files Browse the repository at this point in the history
…ata could not be selected for addition
  • Loading branch information
jef-n committed Apr 18, 2012
1 parent 7b13a89 commit 0b082fb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/providers/postgres/qgspgtablemodel.cpp
Expand Up @@ -97,7 +97,12 @@ void QgsPgTableModel::addTableEntry( QgsPostgresLayerProperty layerProperty )
}
else
{
pkCol = pkText = layerProperty.pkCols[0];
if ( layerProperty.pkCols.size() > 1 )
{
pkText = tr( "Select..." );
}

pkCol = layerProperty.pkCols[0];
}

QStandardItem *pkItem = new QStandardItem( pkText );
Expand Down Expand Up @@ -323,9 +328,9 @@ bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, in

if ( idx.column() == dbtmType || idx.column() == dbtmSrid || idx.column() == dbtmPkCol )
{
QGis::GeometryType geomType = ( QGis::GeometryType ) idx.sibling( idx.row(), dbtmType ).data( Qt::UserRole + 2 ).toInt();
QGis::WkbType geomType = ( QGis::WkbType ) idx.sibling( idx.row(), dbtmType ).data( Qt::UserRole + 2 ).toInt();

bool ok = geomType != QGis::UnknownGeometry;
bool ok = geomType != QGis::WKBUnknown;

if ( ok && geomType != QGis::NoGeometry )
idx.sibling( idx.row(), dbtmSrid ).data().toInt( &ok );
Expand Down

0 comments on commit 0b082fb

Please sign in to comment.