Skip to content

Commit 0e2458e

Browse files
authoredAug 6, 2017
Merge pull request #4969 from boundlessgeo/unified-layer-dialog-raster-mods
Unified layer dialog raster mods
2 parents 7f5b4db + 3a715db commit 0e2458e

19 files changed

+834
-57
lines changed
 

‎python/gui/qgsabstractdatasourcewidget.sip

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ Emitted when a raster layer has been selected for addition
8282
Emitted when a vector layer has been selected for addition
8383
%End
8484

85+
void addVectorLayers( const QStringList &layerQStringList, const QString &enc, const QString &dataSourceType );
86+
%Docstring
87+
Emitted when one or more OGR supported layers are selected for addition
88+
\param layerQStringList list of layers protocol URIs
89+
\param enc encoding
90+
\param dataSourceType string (can be "file" or "database")
91+
%End
92+
8593
void progress( int, int );
8694
%Docstring
8795
Emitted when a progress dialog is shown by the provider dialog

‎src/app/qgisapp.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
294294
#include "qgsuserprofile.h"
295295

296296
#include "qgssublayersdialog.h"
297-
#include "ogr/qgsopenvectorlayerdialog.h"
298297
#include "ogr/qgsvectorlayersaveasdialog.h"
299298

300299
#include "qgsosmdownloaddialog.h"

‎src/gui/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,8 @@ SET(QGIS_GUI_SRCS
179179
locator/qgslocatorfilter.cpp
180180
locator/qgslocatorwidget.cpp
181181

182-
ogr/qgsopenvectorlayerdialog.cpp
183182
ogr/qgsogrhelperfunctions.cpp
184183
ogr/qgsnewogrconnection.cpp
185-
ogr/qgsopenvectorlayerdialog.cpp
186184
ogr/qgsvectorlayersaveasdialog.cpp
187185

188186
qgisinterface.cpp
@@ -508,7 +506,6 @@ SET(QGIS_GUI_MOC_HDRS
508506
qgsdatasourcemanagerdialog.h
509507
qgsabstractdatasourcewidget.h
510508

511-
ogr/qgsopenvectorlayerdialog.h
512509
ogr/qgsnewogrconnection.h
513510
ogr/qgsvectorlayersaveasdialog.h
514511

@@ -718,7 +715,6 @@ SET(QGIS_GUI_HDRS
718715
qgsdatasourcemanagerdialog.h
719716
qgsabstractdatasourcewidget.h
720717

721-
ogr/qgsopenvectorlayerdialog.h
722718
ogr/qgsogrhelperfunctions.h
723719
ogr/qgsnewogrconnection.h
724720
ogr/qgsvectorlayersaveasdialog.h
@@ -816,7 +812,6 @@ SET(QGIS_GUI_UI_HDRS
816812
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgssqlcomposerdialogbase.h
817813
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgssublayersdialogbase.h
818814
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgstablewidgetuibase.h
819-
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsopenvectorlayerdialogbase.h
820815
)
821816

822817
IF(ENABLE_MODELTEST)

‎src/gui/ogr/qgsopenvectorlayerdialog.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ class GUI_EXPORT QgsOpenVectorLayerDialog : public QgsAbstractDataSourceWidget,
9595
void on_cmbConnections_currentIndexChanged( const QString &text );
9696
void on_buttonBox_helpRequested() { QgsHelp::openHelp( QStringLiteral( "working_with_vector/supported_data.html#loading-a-layer-from-a-file" ) ); }
9797

98-
signals:
99-
//! Emitted when in embedded mode
100-
void addVectorLayers( const QStringList &layerQStringList, const QString &enc, const QString &dataSourceType );
10198
};
10299

103100
#endif // QGSOPENVECTORDIALOG_H

‎src/gui/qgsabstractdatasourcewidget.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
8686
//! Emitted when a vector layer has been selected for addition
8787
void addVectorLayer( const QString &uri, const QString &layerName );
8888

89+
/** Emitted when one or more OGR supported layers are selected for addition
90+
* \param layerList list of layers protocol URIs
91+
* \param encoding encoding
92+
* \param dataSourceType string (can be "file" or "database")
93+
*/
94+
void addVectorLayers( const QStringList &layerList, const QString &encoding, const QString &dataSourceType );
95+
8996
//! Emitted when a progress dialog is shown by the provider dialog
9097
void progress( int, int );
9198

‎src/gui/qgsdatasourcemanagerdialog.cpp

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "qgsbrowserdockwidget.h"
2323
#include "qgssettings.h"
2424
#include "qgsproviderregistry.h"
25-
#include "qgsopenvectorlayerdialog.h"
2625
#include "qgsabstractdatasourcewidget.h"
2726
#include "qgsmapcanvas.h"
2827

@@ -56,32 +55,14 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent, QgsMapC
5655
connect( mBrowserWidget, &QgsBrowserDockWidget::connectionsChanged, this, &QgsDataSourceManagerDialog::connectionsChanged );
5756
connect( this, &QgsDataSourceManagerDialog::updateProjectHome, mBrowserWidget, &QgsBrowserDockWidget::updateProjectHome );
5857

59-
// VECTOR Layers (completely different interface: it's not a provider)
60-
QgsOpenVectorLayerDialog *ovl = new QgsOpenVectorLayerDialog( this, Qt::Widget, QgsProviderRegistry::WidgetMode::Embedded );
61-
ui->mOptionsStackedWidget->addWidget( ovl );
62-
QListWidgetItem *ogrItem = new QListWidgetItem( tr( "Vector" ), ui->mOptionsListWidget );
63-
ogrItem->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddOgrLayer.svg" ) ) );
64-
ogrItem->setToolTip( tr( "Add Vector layer" ) );
65-
connect( ovl, &QgsOpenVectorLayerDialog::addVectorLayers, this, &QgsDataSourceManagerDialog::vectorLayersAdded );
66-
connect( ovl, &QgsOpenVectorLayerDialog::rejected, this, &QgsDataSourceManagerDialog::reject );
67-
mPageNames.append( QStringLiteral( "ogr" ) );
68-
69-
// RASTER (forward to app)
70-
ui->mOptionsStackedWidget->addWidget( new QWidget() );
71-
QListWidgetItem *rasterItem = new QListWidgetItem( tr( "Raster" ), ui->mOptionsListWidget );
72-
rasterItem->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddRasterLayer.svg" ) ) );
73-
rasterItem->setToolTip( tr( "Open a GDAL Supported Raster Data Source" ) );
74-
mPageNames.append( QStringLiteral( "raster" ) );
75-
7658
// Add data provider dialogs
7759
QWidget *dlg = nullptr;
7860

79-
dlg = providerDialog( QStringLiteral( "delimitedtext" ), tr( "Delimited Text" ), QStringLiteral( "/mActionAddDelimitedTextLayer.svg" ) );
61+
addVectorProviderDialog( QStringLiteral( "ogr" ), tr( "Vector" ), QStringLiteral( "/mActionAddOgrLayer.svg" ) );
8062

81-
if ( dlg )
82-
{
83-
connect( dlg, SIGNAL( addVectorLayer( QString, QString, QString ) ), this, SLOT( vectorLayerAdded( QString, QString, QString ) ) );
84-
}
63+
addRasterProviderDialog( QStringLiteral( "gdal" ), tr( "Raster" ), QStringLiteral( "/mActionAddRasterLayer.svg" ) );
64+
65+
addVectorProviderDialog( QStringLiteral( "delimitedtext" ), tr( "Delimited Text" ), QStringLiteral( "/mActionAddDelimitedTextLayer.svg" ) );
8566

8667
#ifdef HAVE_POSTGRESQL
8768
addDbProviderDialog( QStringLiteral( "postgres" ), tr( "PostgreSQL" ), QStringLiteral( "/mActionAddPostgisLayer.svg" ) );
@@ -97,11 +78,13 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent, QgsMapC
9778
addDbProviderDialog( QStringLiteral( "oracle" ), tr( "Oracle" ), QStringLiteral( "/mActionAddOracleLayer.svg" ) );
9879
#endif
9980

100-
dlg = providerDialog( QStringLiteral( "virtual" ), tr( "Virtual Layer" ), QStringLiteral( "/mActionAddVirtualLayer.svg" ) );
81+
dlg = addVectorProviderDialog( QStringLiteral( "virtual" ), tr( "Virtual Layer" ), QStringLiteral( "/mActionAddVirtualLayer.svg" ) );
10182

83+
// Apparently this is the only provider using replaceVectorLayer, we should
84+
// move this in to the base abstract class when it is used by at least one
85+
// additional provider.
10286
if ( dlg )
10387
{
104-
connect( dlg, SIGNAL( addVectorLayer( QString, QString, QString ) ), this, SLOT( vectorLayerAdded( QString, QString, QString ) ) );
10588
connect( dlg, SIGNAL( replaceVectorLayer( QString, QString, QString, QString ) ), this, SIGNAL( replaceSelectedVectorLayer( QString, QString, QString, QString ) ) );
10689
}
10790

@@ -136,11 +119,6 @@ void QgsDataSourceManagerDialog::setCurrentPage( int index )
136119
mPreviousRow = ui->mOptionsStackedWidget->currentIndex();
137120
ui->mOptionsStackedWidget->setCurrentIndex( index );
138121
setWindowTitle( tr( "Data Source Manager | %1" ).arg( ui->mOptionsListWidget->currentItem()->text() ) );
139-
if ( 0 <= index && index < mPageNames.size() && mPageNames.at( index ) == QStringLiteral( "raster" ) )
140-
{
141-
emit addRasterLayer();
142-
QTimer::singleShot( 0, this, &QgsDataSourceManagerDialog::setPreviousPage );
143-
}
144122
}
145123

146124
void QgsDataSourceManagerDialog::setPreviousPage()
@@ -197,7 +175,7 @@ QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::providerDialog( const Q
197175
}
198176
}
199177

200-
void QgsDataSourceManagerDialog::addDbProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
178+
QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::addDbProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
201179
{
202180
QgsAbstractDataSourceWidget *dlg = providerDialog( providerKey, providerName, icon, title );
203181
if ( dlg )
@@ -211,9 +189,10 @@ void QgsDataSourceManagerDialog::addDbProviderDialog( const QString providerKey,
211189
connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
212190
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
213191
}
192+
return dlg;
214193
}
215194

216-
void QgsDataSourceManagerDialog::addRasterProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
195+
QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::addRasterProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
217196
{
218197
QgsAbstractDataSourceWidget *dlg = providerDialog( providerKey, providerName, icon, title );
219198
if ( dlg )
@@ -223,17 +202,20 @@ void QgsDataSourceManagerDialog::addRasterProviderDialog( const QString provider
223202
connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
224203
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
225204
}
205+
return dlg;
226206
}
227207

228-
void QgsDataSourceManagerDialog::addVectorProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
208+
QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::addVectorProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
229209
{
230210
QgsAbstractDataSourceWidget *dlg = providerDialog( providerKey, providerName, icon, title );
231211
if ( dlg )
232212
{
233213
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayer, this, [ = ]( const QString & vectorLayerPath, const QString & baseName )
234214
{ this->vectorLayerAdded( vectorLayerPath, baseName, providerKey ); } );
215+
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayers, this, &QgsDataSourceManagerDialog::vectorLayersAdded );
235216
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
236217
}
218+
return dlg;
237219
}
238220

239221
void QgsDataSourceManagerDialog::showEvent( QShowEvent *e )

‎src/gui/qgsdatasourcemanagerdialog.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ class GUI_EXPORT QgsDataSourceManagerDialog : public QgsOptionsDialogBase, priva
116116
private:
117117
// Return the dialog from the provider
118118
QgsAbstractDataSourceWidget *providerDialog( const QString providerKey, const QString providerName, const QString icon, QString title = QString() );
119-
void addDbProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
120-
void addRasterProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
121-
void addVectorProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
119+
QgsAbstractDataSourceWidget *addDbProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
120+
QgsAbstractDataSourceWidget *addRasterProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
121+
QgsAbstractDataSourceWidget *addVectorProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
122122
Ui::QgsDataSourceManagerDialog *ui;
123123
QgsBrowserDockWidget *mBrowserWidget = nullptr;
124124
int mPreviousRow;

‎src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ void QgsDelimitedTextSourceSelect::addButtonClicked()
193193

194194

195195
// add the layer to the map
196-
emit addVectorLayer( QString::fromAscii( url.toEncoded() ), txtLayerName->text(), QStringLiteral( "delimitedtext" ) );
196+
emit addVectorLayer( QString::fromAscii( url.toEncoded() ), txtLayerName->text() );
197197
if ( widgetMode() == QgsProviderRegistry::WidgetMode::None )
198198
{
199199
accept();

‎src/providers/delimitedtext/qgsdelimitedtextsourceselect.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ class QgsDelimitedTextSourceSelect : public QgsAbstractDataSourceWidget, private
7272
void updateFieldsAndEnable();
7373
void enableAccept();
7474
bool validate();
75-
76-
signals:
77-
void addVectorLayer( const QString &, const QString &, const QString & );
7875
};
7976

8077
#endif // QGSDELIMITEDTEXTSOURCESELECT_H

‎src/providers/gdal/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ SET(GDAL_SRCS
22
qgsgdalproviderbase.cpp
33
qgsgdalprovider.cpp
44
qgsgdaldataitems.cpp
5+
qgsgdalsourceselect.cpp
56
)
67
SET(GDAL_MOC_HDRS
78
qgsgdalprovider.h
89
qgsgdaldataitems.h
10+
qgsgdalsourceselect.h
911
)
1012

1113
INCLUDE_DIRECTORIES (
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/***************************************************************************
2+
qgsgdalsourceselect.h
3+
-------------------
4+
begin : August 05 2017
5+
copyright : (C) 2017 by Alessandro Pasotti
6+
email : apasotti at boundlessgeo dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#include "qgsgdalsourceselect.h"
19+
#include "qgsproviderregistry.h"
20+
21+
QgsGdalSourceSelect::QgsGdalSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode ):
22+
QgsAbstractDataSourceWidget( parent, fl, widgetMode )
23+
{
24+
setupUi( this );
25+
setupButtons( buttonBox );
26+
mQgsFileWidget->setFilter( QgsProviderRegistry::instance()->fileRasterFilters() );
27+
connect( mQgsFileWidget, &QgsFileWidget::fileChanged, this, [ = ]( const QString & path )
28+
{
29+
mRasterPath = path;
30+
emit enableButtons( ! mRasterPath.isEmpty() );
31+
} );
32+
}
33+
34+
QgsGdalSourceSelect::~QgsGdalSourceSelect()
35+
{
36+
37+
}
38+
39+
void QgsGdalSourceSelect::addButtonClicked()
40+
{
41+
QFileInfo baseName( mRasterPath );
42+
emit addRasterLayer( mRasterPath, baseName.baseName(), QStringLiteral( "gdal" ) );
43+
}
44+
45+
QGISEXTERN QgsGdalSourceSelect *selectWidget( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
46+
{
47+
return new QgsGdalSourceSelect( parent, fl, widgetMode );
48+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/***************************************************************************
2+
qgsgdalsourceselect.h
3+
-------------------
4+
begin : August 05 2017
5+
copyright : (C) 2017 by Alessandro Pasotti
6+
email : apasotti at boundlessgeo dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
#ifndef QGGDALSOURCESELECT_H
18+
#define QGGDALSOURCESELECT_H
19+
20+
#include "ui_qgsgdalsourceselectbase.h"
21+
#include "qgsabstractdatasourcewidget.h"
22+
23+
24+
/** \class QgsGdalSourceSelect
25+
* \brief Dialog to select GDAL supported rasters
26+
*/
27+
class QgsGdalSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsGdalSourceSelectBase
28+
{
29+
Q_OBJECT
30+
31+
public:
32+
//! Constructor
33+
QgsGdalSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
34+
35+
~QgsGdalSourceSelect();
36+
37+
public slots:
38+
//! Determines the tables the user selected and closes the dialog
39+
void addButtonClicked() override;
40+
41+
private:
42+
43+
QString mRasterPath;
44+
45+
};
46+
47+
#endif // QGGDALSOURCESELECT_H

‎src/providers/ogr/CMakeLists.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ SET (OGR_SRCS
55
qgsogrfeatureiterator.cpp
66
qgsogrconnpool.cpp
77
qgsogrexpressioncompiler.cpp
8+
qgsogrsourceselect.cpp
89
)
910

10-
SET(OGR_MOC_HDRS qgsogrprovider.h qgsogrdataitems.h qgsogrconnpool.h)
11+
SET(OGR_MOC_HDRS
12+
qgsogrprovider.h
13+
qgsogrdataitems.h
14+
qgsogrconnpool.h
15+
qgsogrsourceselect.h
16+
)
1117

1218
########################################################
1319
# Build
@@ -20,9 +26,11 @@ INCLUDE_DIRECTORIES(
2026
${CMAKE_SOURCE_DIR}/src/core/metadata
2127
${CMAKE_SOURCE_DIR}/src/core/symbology-ng
2228
${CMAKE_SOURCE_DIR}/src/core/expression
29+
${CMAKE_SOURCE_DIR}/src/gui
2330

2431
${CMAKE_BINARY_DIR}/src/core
2532
${CMAKE_BINARY_DIR}/src/gui
33+
${CMAKE_BINARY_DIR}/src/ui
2634
)
2735
INCLUDE_DIRECTORIES(SYSTEM
2836
${GDAL_INCLUDE_DIR}
@@ -35,6 +43,14 @@ ADD_LIBRARY(ogrprovider MODULE ${OGR_SRCS} ${OGR_MOC_SRCS})
3543
TARGET_LINK_LIBRARIES(ogrprovider
3644
qgis_core
3745
)
46+
47+
48+
IF (WITH_GUI)
49+
TARGET_LINK_LIBRARIES (ogrprovider
50+
qgis_gui
51+
)
52+
ENDIF ()
53+
3854
IF (MSVC)
3955
#needed for linking to gdal which needs odbc
4056
SET(TARGET_LINK_LIBRARIES ${TARGET_LINK_LIBRARIE} odbc32 odbccp32)

‎src/providers/ogr/qgsogrsourceselect.cpp

Lines changed: 485 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/***************************************************************************
2+
qgsogrsourceselect.h
3+
Dialog to select the type and source for ogr vectors, supports
4+
file, database, directory and protocol sources.
5+
-------------------
6+
---------------------
7+
Adapted to source select:
8+
9+
date : Aug 5, 2017
10+
copyright : (C) 2017 by Alessandro Pasotti
11+
email : apasotti at itopen dot it
12+
13+
Original work done by:
14+
begin : Mon Jan 2 2009
15+
copyright : (C) 2009 by Godofredo Contreras Nava
16+
email : frdcn at hotmail.com
17+
***************************************************************************/
18+
19+
/***************************************************************************
20+
* *
21+
* This program is free software; you can redistribute it and/or modify *
22+
* it under the terms of the GNU General Public License as published by *
23+
* the Free Software Foundation; either version 2 of the License, or *
24+
* (at your option) any later version. *
25+
* *
26+
***************************************************************************/
27+
#ifndef QGSOGRSOURCESELECT_H
28+
#define QGSOGRSOURCESELECT_H
29+
30+
#include <ui_qgsogrsourceselectbase.h>
31+
#include <QDialog>
32+
#include "qgshelp.h"
33+
#include "qgsproviderregistry.h"
34+
#include "qgsabstractdatasourcewidget.h"
35+
#include "qgis_gui.h"
36+
37+
#define SIP_NO_FILE
38+
39+
/**
40+
* Class for a dialog to select the type and source for ogr vectors, supports
41+
* file, database, directory and protocol sources.
42+
* \note not available in Python bindings
43+
*/
44+
class GUI_EXPORT QgsOgrSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsOgrSourceSelectBase
45+
{
46+
Q_OBJECT
47+
48+
public:
49+
QgsOgrSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = 0, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
50+
~QgsOgrSourceSelect();
51+
//! Opens a dialog to select a file datasource*/
52+
QStringList openFile();
53+
//! Opens a dialog to select a directory datasource*/
54+
QString openDirectory();
55+
//! Returns a list of selected datasources*/
56+
QStringList dataSources();
57+
//! Returns the encoding selected for user*/
58+
QString encoding();
59+
//! Returns the connection type
60+
QString dataSourceType();
61+
private:
62+
//! Stores the file vector filters */
63+
QString mVectorFileFilter;
64+
//! Stores the selected datasources */
65+
QStringList mDataSources;
66+
//! Stores the user selected encoding
67+
QString mEnc;
68+
//! Stores the datasource type
69+
QString mDataSourceType;
70+
//! Embedded dialog (do not call parent's accept) and emit signals
71+
QgsProviderRegistry::WidgetMode mWidgetMode = QgsProviderRegistry::WidgetMode::None;
72+
73+
public slots:
74+
void addButtonClicked() override;
75+
76+
private slots:
77+
//! Opens the create connection dialog to build a new connection
78+
void addNewConnection();
79+
//! Opens a dialog to edit an existing connection
80+
void editConnection();
81+
//! Deletes the selected connection
82+
void deleteConnection();
83+
//! Populate the connection list combo box
84+
void populateConnectionList();
85+
//! Sets the actual position in connection list
86+
void setConnectionListPosition();
87+
//! Sets the actual position in types connection list
88+
void setConnectionTypeListPosition();
89+
//! Sets the selected connection type
90+
void setSelectedConnectionType();
91+
//! Sets the selected connection
92+
void setSelectedConnection();
93+
94+
void on_buttonSelectSrc_clicked();
95+
void on_radioSrcFile_toggled( bool checked );
96+
void on_radioSrcDirectory_toggled( bool checked );
97+
void on_radioSrcDatabase_toggled( bool checked );
98+
void on_radioSrcProtocol_toggled( bool checked );
99+
void on_btnNew_clicked();
100+
void on_btnEdit_clicked();
101+
void on_btnDelete_clicked();
102+
void on_cmbDatabaseTypes_currentIndexChanged( const QString &text );
103+
void on_cmbConnections_currentIndexChanged( const QString &text );
104+
void on_buttonBox_helpRequested() { QgsHelp::openHelp( QStringLiteral( "working_with_vector/supported_data.html#loading-a-layer-from-a-file" ) ); }
105+
};
106+
107+
#endif // QGSOGRSOURCESELECT_H

‎src/providers/virtual/qgsvirtuallayersourceselect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ void QgsVirtualLayerSourceSelect::addButtonClicked()
376376
}
377377
else
378378
{
379-
emit addVectorLayer( def.toString(), layerName, QStringLiteral( "virtual" ) );
379+
emit addVectorLayer( def.toString(), layerName );
380380
}
381381
if ( widgetMode() == QgsProviderRegistry::WidgetMode::None )
382382
{

‎src/providers/virtual/qgsvirtuallayersourceselect.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ class QgsVirtualLayerSourceSelect : public QgsAbstractDataSourceWidget, private
5454
void updateLayersList();
5555

5656
signals:
57-
//! Source, name, provider
58-
void addVectorLayer( QString, QString, QString );
5957
//! Old_id, source, name, provider
6058
void replaceVectorLayer( QString, QString, QString, QString );
6159

‎src/ui/qgsgdalsourceselectbase.ui

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>QgsGdalSourceSelectBase</class>
4+
<widget class="QDialog" name="QgsGdalSourceSelectBase">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>355</width>
10+
<height>229</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Add Layer(s) from a Server</string>
15+
</property>
16+
<property name="windowIcon">
17+
<iconset>
18+
<normaloff>.</normaloff>.</iconset>
19+
</property>
20+
<property name="sizeGripEnabled">
21+
<bool>true</bool>
22+
</property>
23+
<property name="modal">
24+
<bool>true</bool>
25+
</property>
26+
<layout class="QGridLayout" name="gridLayout_2">
27+
<item row="3" column="0">
28+
<widget class="QDialogButtonBox" name="buttonBox">
29+
<property name="standardButtons">
30+
<set>QDialogButtonBox::Help</set>
31+
</property>
32+
</widget>
33+
</item>
34+
<item row="1" column="0">
35+
<widget class="QgsFileWidget" name="mQgsFileWidget"/>
36+
</item>
37+
<item row="2" column="0">
38+
<spacer name="verticalSpacer">
39+
<property name="orientation">
40+
<enum>Qt::Vertical</enum>
41+
</property>
42+
<property name="sizeHint" stdset="0">
43+
<size>
44+
<width>20</width>
45+
<height>40</height>
46+
</size>
47+
</property>
48+
</spacer>
49+
</item>
50+
<item row="0" column="0">
51+
<widget class="QLabel" name="label">
52+
<property name="text">
53+
<string>Path to a raster data source</string>
54+
</property>
55+
</widget>
56+
</item>
57+
</layout>
58+
</widget>
59+
<layoutdefault spacing="6" margin="11"/>
60+
<customwidgets>
61+
<customwidget>
62+
<class>QgsFileWidget</class>
63+
<extends>QWidget</extends>
64+
<header>qgsfilewidget.h</header>
65+
</customwidget>
66+
</customwidgets>
67+
<tabstops>
68+
<tabstop>buttonBox</tabstop>
69+
</tabstops>
70+
<resources/>
71+
<connections>
72+
<connection>
73+
<sender>buttonBox</sender>
74+
<signal>rejected()</signal>
75+
<receiver>QgsGdalSourceSelectBase</receiver>
76+
<slot>reject()</slot>
77+
<hints>
78+
<hint type="sourcelabel">
79+
<x>518</x>
80+
<y>510</y>
81+
</hint>
82+
<hint type="destinationlabel">
83+
<x>551</x>
84+
<y>370</y>
85+
</hint>
86+
</hints>
87+
</connection>
88+
</connections>
89+
</ui>

‎src/ui/qgsopenvectorlayerdialogbase.ui renamed to ‎src/ui/qgsogrsourceselectbase.ui

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ui version="4.0">
3-
<class>QgsOpenVectorLayerDialogBase</class>
4-
<widget class="QDialog" name="QgsOpenVectorLayerDialogBase">
3+
<class>QgsOgrSourceSelectBase</class>
4+
<widget class="QDialog" name="QgsOgrSourceSelectBase">
55
<property name="windowModality">
66
<enum>Qt::WindowModal</enum>
77
</property>
@@ -320,7 +320,7 @@
320320
<connection>
321321
<sender>buttonBox</sender>
322322
<signal>accepted()</signal>
323-
<receiver>QgsOpenVectorLayerDialogBase</receiver>
323+
<receiver>QgsOgrSourceSelectDialogBase</receiver>
324324
<slot>accept()</slot>
325325
<hints>
326326
<hint type="sourcelabel">
@@ -336,7 +336,7 @@
336336
<connection>
337337
<sender>buttonBox</sender>
338338
<signal>rejected()</signal>
339-
<receiver>QgsOpenVectorLayerDialogBase</receiver>
339+
<receiver>QgsOgrSourceSelectDialogBase</receiver>
340340
<slot>reject()</slot>
341341
<hints>
342342
<hint type="sourcelabel">

0 commit comments

Comments
 (0)
Please sign in to comment.