Skip to content
Permalink
Browse files

refresh postgres schema in browser after import

  • Loading branch information
blazek committed Jun 29, 2017
1 parent 797bd16 commit dcf2816835efc496e7b837abf8266ec43685bdf8
Showing with 16 additions and 4 deletions.
  1. +14 −3 src/providers/postgres/qgspostgresdataitems.cpp
  2. +2 −1 src/providers/postgres/qgspostgresdataitems.h
@@ -152,6 +152,17 @@ void QgsPGConnectionItem::refreshConnection()
refresh();
}

void QgsPGConnectionItem::refreshSchema( const QString &schema )
{
Q_FOREACH ( QgsDataItem *child, mChildren )
{
if ( child->name() == schema || schema.isEmpty() )
{
child->refresh();
}
}
}

void QgsPGConnectionItem::createSchema()
{
QString schemaName = QInputDialog::getText( nullptr, tr( "Create Schema" ), tr( "Schema name:" ) );
@@ -229,7 +240,7 @@ bool QgsPGConnectionItem::handleDrop( const QMimeData *data, const QString &toSc
{
// this is gross - TODO - find a way to get access to messageBar from data items
QMessageBox::information( nullptr, tr( "Import to PostGIS database" ), tr( "Import was successful." ) );
refresh();
refreshSchema( toSchema );
} );

// when an error occurs:
@@ -242,7 +253,7 @@ bool QgsPGConnectionItem::handleDrop( const QMimeData *data, const QString &toSc
output->setMessage( tr( "Failed to import some layers!\n\n" ) + errorMessage, QgsMessageOutput::MessageText );
output->showMessage();
}
refresh();
refreshSchema( toSchema );
} );

QgsApplication::taskManager()->addTask( exportTask.release() );
@@ -448,11 +459,11 @@ QgsPGSchemaItem::QgsPGSchemaItem( QgsDataItem *parent, const QString &connection

QVector<QgsDataItem *> QgsPGSchemaItem::createChildren()
{

QVector<QgsDataItem *>items;

QgsDataSourceUri uri = QgsPostgresConn::connUri( mConnectionName );
QgsPostgresConn *conn = QgsPostgresConnPool::instance()->acquireConnection( uri.connectionInfo( false ) );

if ( !conn )
{
items.append( new QgsErrorItem( this, tr( "Connection failed" ), mPath + "/error" ) );
@@ -70,8 +70,9 @@ class QgsPGConnectionItem : public QgsDataCollectionItem
void editConnection();
void deleteConnection();
void refreshConnection();
// refresh specified schema or all schemas if schema name is empty
void refreshSchema( const QString &schema );
void createSchema();

};

class QgsPGSchemaItem : public QgsDataCollectionItem

0 comments on commit dcf2816

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