Skip to content
Permalink
Browse files

Browser table: skip fields conversion + UX & tests

The reason for skipConvertFields is that the providers
are not smart enough to recognize if a field is alredy
compatible and they narrow down all fields anyway
to stay on the safe side.

Fixing all providers would be nice but it's definitely
out of scope for this PR.
  • Loading branch information
elpaso committed Jul 15, 2020
1 parent abb676d commit f0b43aa2b75d51edda01d12974783fa3e1e76e5e
@@ -45,6 +45,10 @@ QgsNewVectorTableDialog constructor

void setGeometryType( QgsWkbTypes::Type type );

void setCrs( const QgsCoordinateReferenceSystem &crs );

QgsCoordinateReferenceSystem crs() const;

QString tableName() const;

QString schemaName() const;
@@ -55,10 +59,10 @@ QgsNewVectorTableDialog constructor

QgsWkbTypes::Type geometryType() const;

QgsCoordinateReferenceSystem crs() const;

void setFields( const QgsFields &fields );

QStringList validationErrors() const;

protected:
virtual void showEvent( QShowEvent *event );

@@ -865,7 +865,7 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *
{
std::unique_ptr<QgsAbstractDatabaseProviderConnection> conn2 { static_cast<QgsAbstractDatabaseProviderConnection *>( md->createConnection( connectionName ) ) };
QgsNewVectorTableDialog dlg { conn2.get(), nullptr };
// TODO: dlg.setCrs( QgsProject::instance()->defaultCrsForNewLayers() );
dlg.setCrs( QgsProject::instance()->defaultCrsForNewLayers() );
if ( isSchema )
{
dlg.setSchemaName( collectionItem->name() );
@@ -878,7 +878,8 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *
const QString geometryColumn { dlg.geometryColumnName() };
const QgsWkbTypes::Type geometryType { dlg.geometryType() };
const QgsCoordinateReferenceSystem crs { dlg.crs( ) };
QMap<QString, QVariant> options;
// This flag tells to the provider that field types do not need conversion
QMap<QString, QVariant> options { { QStringLiteral( "skipConvertFields" ), true } };

if ( ! geometryColumn.isEmpty() )
{

0 comments on commit f0b43aa

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