Skip to content

Commit 129e00d

Browse files
committed
[addlayerbutton] Added embeddedMode to all providers
Also switched managerMode and embeddedMode arguments for a more logical arg passing from the factory function.
1 parent ff83bfe commit 129e00d

28 files changed

Lines changed: 71 additions & 47 deletions

‎python/core/qgsproviderregistry.sip‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Set library directory where to search for plugins
8888
%End
8989

9090
QWidget *createSelectionWidget( const QString &providerKey,
91-
QWidget *parent = 0, Qt::WindowFlags fl = Qt::WindowFlags() );
91+
QWidget *parent = 0, Qt::WindowFlags fl = Qt::WindowFlags(), bool embeddedMode = false );
9292
%Docstring
9393
Returns a new widget for selecting layers from a provider.
9494
Either the ``parent`` widget must be set or the caller becomes

‎src/app/qgisapp.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,9 @@ void QgisApp::dataSourceManager()
15991599
this, SLOT( addVectorLayer( QString const &, QString const &, QString const & ) ) );
16001600
connect( mDataSourceManagerDialog, SIGNAL( addVectorLayers( QStringList const &, QString const &, QString const & ) ),
16011601
this, SLOT( addVectorLayers( QStringList const &, QString const &, QString const & ) ) );
1602+
connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::showProgress, this, &QgisApp::showProgress );
1603+
connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::showStatusMessage, this, &QgisApp::showStatusMessage );
1604+
connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::addDatabaseLayers, this, &QgisApp::addDatabaseLayers );
16021605
}
16031606
// TODO: handle docked
16041607
mDataSourceManagerDialog->exec();

‎src/app/qgsdatasourcemanagerdialog.cpp‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,21 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent ) :
8585
{ this->vectorLayerAdded( vectorLayerPath, baseName, QStringLiteral( "WFS" ) ); } );
8686
}
8787

88+
#ifdef HAVE_POSTGRESQL
89+
/////////////////////////////////////////////////////////////////////////////
90+
// POSTGIS
91+
dlg = providerDialog( QStringLiteral( "postgres" ), tr( "PostgreSQL" ), QStringLiteral( "/mActionAddPostgisLayer.svg" ) );
92+
if ( dlg )
93+
{
94+
connect( dlg, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
95+
this, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ) );
96+
connect( dlg, SIGNAL( progress( int, int ) ),
97+
this, SIGNAL( showProgress( int, int ) ) );
98+
connect( dlg, SIGNAL( progressMessage( QString ) ),
99+
this, SIGNAL( showStatusMessage( QString ) ) );
100+
}
101+
#endif
102+
88103
}
89104

90105
QgsDataSourceManagerDialog::~QgsDataSourceManagerDialog()
@@ -115,7 +130,7 @@ void QgsDataSourceManagerDialog::vectorLayersAdded( const QStringList &layerQStr
115130

116131
QDialog *QgsDataSourceManagerDialog::providerDialog( const QString providerKey, const QString providerName, const QString icon )
117132
{
118-
QDialog *dlg = dynamic_cast<QDialog *>( QgsProviderRegistry::instance()->createSelectionWidget( providerKey, this, Qt::Widget ) );
133+
QDialog *dlg = dynamic_cast<QDialog *>( QgsProviderRegistry::instance()->createSelectionWidget( providerKey, this, Qt::Widget, true ) );
119134
if ( !dlg )
120135
{
121136
QMessageBox::warning( this, providerName, tr( "Cannot get %1 select dialog from provider %2." ).arg( providerName, providerKey ) );

‎src/app/qgsdatasourcemanagerdialog.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class QgsDataSourceManagerDialog : public QDialog
5252
void addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey );
5353
void addWfsLayer( const QString &uri, const QString &typeName );
5454
void addVectorLayers( const QStringList &layerQStringList, const QString &enc, const QString &dataSourceType );
55+
void showProgress( int progress, int totalSteps );
56+
void showStatusMessage( const QString &message );
57+
void addDatabaseLayers( QStringList const &layerPathList, QString const &providerKey );
5558

5659
private:
5760
//! Return the dialog from the provider

‎src/core/qgsproviderregistry.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,18 +438,18 @@ int QgsProviderRegistry::providerCapabilities( const QString &providerKey ) cons
438438
}
439439

440440
// This should be QWidget, not QDialog
441-
typedef QWidget *selectFactoryFunction_t( QWidget *parent, Qt::WindowFlags fl );
441+
typedef QWidget *selectFactoryFunction_t( QWidget *parent, Qt::WindowFlags fl, bool embeddedMode );
442442

443443
QWidget *QgsProviderRegistry::createSelectionWidget( const QString &providerKey,
444-
QWidget *parent, Qt::WindowFlags fl )
444+
QWidget *parent, Qt::WindowFlags fl, bool embeddedMode )
445445
{
446446
selectFactoryFunction_t *selectFactory =
447447
reinterpret_cast< selectFactoryFunction_t * >( cast_to_fptr( function( providerKey, "selectWidget" ) ) );
448448

449449
if ( !selectFactory )
450450
return nullptr;
451451

452-
return selectFactory( parent, fl );
452+
return selectFactory( parent, fl, embeddedMode );
453453
}
454454

455455
QFunctionPointer QgsProviderRegistry::function( QString const &providerKey,

‎src/core/qgsproviderregistry.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class CORE_EXPORT QgsProviderRegistry
9898
* responsible for deleting the returned widget.
9999
*/
100100
QWidget *createSelectionWidget( const QString &providerKey,
101-
QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags() );
101+
QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags(), bool embeddedMode = false );
102102

103103
/**
104104
* Get pointer to provider function

‎src/providers/arcgisrest/qgsafsproviderextern.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ QGISEXTERN bool isProvider()
4545
return true;
4646
}
4747

48-
QGISEXTERN QgsAfsSourceSelect *selectWidget( QWidget *parent, Qt::WindowFlags fl )
48+
QGISEXTERN QgsAfsSourceSelect *selectWidget( QWidget *parent, Qt::WindowFlags fl, bool embeddedMode )
4949
{
50-
return new QgsAfsSourceSelect( parent, fl );
50+
return new QgsAfsSourceSelect( parent, fl, embeddedMode );
5151
}
5252

5353
QGISEXTERN int dataCapabilities()

‎src/providers/arcgisrest/qgsamsproviderextern.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ QGISEXTERN bool isProvider()
4545
return true;
4646
}
4747

48-
QGISEXTERN QgsAmsSourceSelect *selectWidget( QWidget *parent, Qt::WindowFlags fl )
48+
QGISEXTERN QgsAmsSourceSelect *selectWidget( QWidget *parent, Qt::WindowFlags fl, bool embeddedMode )
4949
{
50-
return new QgsAmsSourceSelect( parent, fl );
50+
return new QgsAmsSourceSelect( parent, fl, embeddedMode );
5151
}
5252

5353
QGISEXTERN int dataCapabilities()

‎src/providers/db2/qgsdb2provider.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,9 +1711,9 @@ QGISEXTERN int dataCapabilities()
17111711
return QgsDataProvider::Database;
17121712
}
17131713

1714-
QGISEXTERN void *selectWidget( QWidget *parent, Qt::WindowFlags fl )
1714+
QGISEXTERN void *selectWidget( QWidget *parent, Qt::WindowFlags fl, bool embeddedMode )
17151715
{
1716-
return new QgsDb2SourceSelect( parent, fl );
1716+
return new QgsDb2SourceSelect( parent, fl, embeddedMode );
17171717
}
17181718

17191719
QGISEXTERN QgsDataItem *dataItem( QString path, QgsDataItem *parentItem )

‎src/providers/db2/qgsdb2sourceselect.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void QgsDb2SourceSelectDelegate::setModelData( QWidget *editor, QAbstractItemMod
116116
model->setData( index, le->text() );
117117
}
118118

119-
QgsDb2SourceSelect::QgsDb2SourceSelect( QWidget *parent, Qt::WindowFlags fl, bool managerMode, bool embeddedMode )
119+
QgsDb2SourceSelect::QgsDb2SourceSelect( QWidget *parent, Qt::WindowFlags fl, bool embeddedMode, bool managerMode )
120120
: QDialog( parent, fl )
121121
, mManagerMode( managerMode )
122122
, mEmbeddedMode( embeddedMode )

0 commit comments

Comments
 (0)