Skip to content
Permalink
Browse files

Dropping on mssql schema items should import to that schema (fix #8327)

  • Loading branch information
nyalldawson committed Jan 29, 2016
1 parent 4a1bf6d commit 6efe1eb86bf0a4a3a4161fb377401ca6e5ed42bf
Showing with 30 additions and 2 deletions.
  1. +25 −2 src/providers/mssql/qgsmssqldataitems.cpp
  2. +5 −0 src/providers/mssql/qgsmssqldataitems.h
@@ -338,12 +338,16 @@ void QgsMssqlConnectionItem::deleteConnection()
}

bool QgsMssqlConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction )
{
return handleDrop( data, QString() );
}

bool QgsMssqlConnectionItem::handleDrop( const QMimeData* data, const QString& toSchema )
{
if ( !QgsMimeDataUtils::isUriList( data ) )
return false;

// TODO: probably should show a GUI with settings etc

qApp->setOverrideCursor( Qt::WaitCursor );

QStringList importResults;
@@ -363,7 +367,17 @@ bool QgsMssqlConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction

if ( srcLayer->isValid() )
{
QString uri = connInfo() + " table=" + u.name + " (geom)";
QString tableName;
if ( !toSchema.isEmpty() )
{
tableName = QString( "\"%1\".\"%2\"" ).arg( toSchema, u.name );
}
else
{
tableName = u.name;
}

QString uri = connInfo() + " table=" + tableName + " (geom)";

QgsVectorLayerImport::ImportError err;
QString importError;
@@ -474,6 +488,15 @@ void QgsMssqlSchemaItem::addLayers( QgsDataItem* newLayers )
}
}

bool QgsMssqlSchemaItem::handleDrop( const QMimeData* data, Qt::DropAction )
{
QgsMssqlConnectionItem *conn = qobject_cast<QgsMssqlConnectionItem *>( parent() );
if ( !conn )
return 0;

return conn->handleDrop( data, mName );
}

QgsMssqlLayerItem* QgsMssqlSchemaItem::addLayer( QgsMssqlLayerProperty layerProperty, bool refresh )
{
QGis::WkbType wkbType = QgsMssqlTableModel::wkbTypeFromMssql( layerProperty.type );
@@ -60,6 +60,9 @@ class QgsMssqlConnectionItem : public QgsDataCollectionItem

virtual bool acceptDrop() override { return true; }
virtual bool handleDrop( const QMimeData * data, Qt::DropAction action ) override;

bool handleDrop( const QMimeData * data, const QString& toSchema );

void refresh() override;

QString connInfo() const { return mConnInfo; }
@@ -100,6 +103,8 @@ class QgsMssqlSchemaItem : public QgsDataCollectionItem
QgsMssqlLayerItem* addLayer( QgsMssqlLayerProperty layerProperty, bool refresh );
void refresh() override {} // do not refresh directly
void addLayers( QgsDataItem* newLayers );
virtual bool acceptDrop() override { return true; }
virtual bool handleDrop( const QMimeData * data, Qt::DropAction action ) override;
};

class QgsMssqlLayerItem : public QgsLayerItem

0 comments on commit 6efe1eb

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