17 #include <QListWidgetItem>
20 #include "ui_qgsdatasourcemanagerdialog.h"
22 #include "qgssettings.h"
37 , mMapCanvas( canvas )
38 , mBrowserModel( browserModel )
41 ui->verticalLayout_2->setSpacing( 6 );
42 ui->verticalLayout_2->setContentsMargins( 0, 0, 0, 0 );
45 mMessageBar->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
46 static_cast<QVBoxLayout *
>( layout() )->insertWidget( 0, mMessageBar );
58 mBrowserWidget->setFeatures( QDockWidget::NoDockWidgetFeatures );
59 ui->mOptionsStackedWidget->addWidget( mBrowserWidget );
60 mPageNames.append( QStringLiteral(
"browser" ) );
74 QgsMessageLog::logMessage( tr(
"Cannot get %1 select dialog from source select provider %2." ).arg( provider->name(), provider->providerKey() ), QStringLiteral(
"DataSourceManager" ), Qgis::MessageLevel::Critical );
77 addProviderDialog( dlg, provider->providerKey(), provider->text(), provider->icon( ), provider->toolTip( ) );
90 int pageIdx = mPageNames.indexOf( pageName );
93 QTimer::singleShot( 0,
this, [ = ] {
setCurrentPage( pageIdx ); } );
104 mPreviousRow = ui->mOptionsStackedWidget->currentIndex();
105 ui->mOptionsStackedWidget->setCurrentIndex( index );
106 setWindowTitle( tr(
"Data Source Manager | %1" ).arg( ui->mOptionsListWidget->currentItem()->text() ) );
112 int prevPage = mPreviousRow != -1 ? mPreviousRow : 0;
124 int pageCount = ui->mOptionsStackedWidget->count();
125 for (
int i = 0; i < pageCount; ++i )
127 QWidget *widget = ui->mOptionsStackedWidget->widget( i );
129 if ( dataSourceWidget )
130 dataSourceWidget->
reset();
154 void QgsDataSourceManagerDialog::addProviderDialog(
QgsAbstractDataSourceWidget *dlg,
const QString &providerKey,
const QString &providerName,
const QIcon &icon,
const QString &toolTip )
156 mPageNames.append( providerKey );
157 ui->mOptionsStackedWidget->addWidget( dlg );
158 QListWidgetItem *layerItem =
new QListWidgetItem( providerName, ui->mOptionsListWidget );
159 layerItem->setToolTip( toolTip.isEmpty() ? tr(
"Add %1 layer" ).arg( providerName ) : toolTip );
160 layerItem->setIcon( icon );
168 connect( dlg, &QgsAbstractDataSourceWidget::rejected,
this, &QgsDataSourceManagerDialog::reject );
169 connect( dlg, &QgsAbstractDataSourceWidget::accepted,
this, &QgsDataSourceManagerDialog::accept );
170 makeConnections( dlg, providerKey );
183 QString key = specifiedProvider.isEmpty() ? providerKey : specifiedProvider;
192 this, [ = ](
const QString & uri,
const QString & baseName,
const QString & providerKey )
220 ui->mOptionsStackedWidget->currentWidget()->show();
MessageLevel
Level for messages This will be used both for message log and message bar in application.
A model for showing available data sources and other items in a structured tree.
The QgsDataSourceManagerDialog class embeds the browser panel and all the provider dialogs.
void reset()
Resets the interface of the datasource manager after reopening the dialog.
void refresh()
Refresh the browser view.
void addVectorLayers(const QStringList &layerQStringList, const QString &enc, const QString &dataSourceType)
Emitted when a one or more layer were selected for addition: for signal forwarding to QgisApp.
void openFile(const QString &fileName, const QString &fileTypeHint=QString())
Emitted when a file needs to be opened.
void addMeshLayer(const QString &uri, const QString &baseName, const QString &providerKey)
Emitted when a mesh layer was selected for addition: for signal forwarding to QgisApp.
QgsMessageBar * messageBar() const
Returns the dialog's message bar.
void addPointCloudLayer(const QString &pointCloudLayerPath, const QString &baseName, const QString &providerKey)
Emitted when a point cloud layer was selected for addition: for signal forwarding to QgisApp.
QgsDataSourceManagerDialog(QgsBrowserGuiModel *browserModel, QWidget *parent=nullptr, QgsMapCanvas *canvas=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
QgsDataSourceManagerDialog constructor.
void rasterLayersAdded(const QStringList &layersList)
One or more raster layer were added: for signal forwarding to QgisApp.
void setPreviousPage()
Reset current page to previously selected page.
void addVectorLayer(const QString &vectorLayerPath, const QString &baseName, const QString &providerKey)
Emitted when a vector layer was selected for addition: for signal forwarding to QgisApp.
void showStatusMessage(const QString &message)
Emitted when a status message needs to be shown: for signal forwarding to QgisApp.
void showEvent(QShowEvent *event) override
void replaceSelectedVectorLayer(const QString &oldId, const QString &uri, const QString &layerName, const QString &provider)
Replace the selected layer by a vector layer defined by uri, layer name, data source uri.
void openPage(const QString &pageName)
Open a given page in the dialog.
void connectionsChanged()
Emitted when a connection has changed inside the provider dialogs This signal is normally forwarded t...
void vectorLayersAdded(const QStringList &layerQStringList, const QString &enc, const QString &dataSourceType)
One or more vector layer were added: for signal forwarding to QgisApp.
void addDatabaseLayers(const QStringList &layerPathList, const QString &providerKey)
Emitted when a DB layer was selected for addition: for signal forwarding to QgisApp.
void handleDropUriList(const QgsMimeDataUtils::UriList &)
Emitted when drop uri list needs to be handled from the browser.
void addVectorTileLayer(const QString &uri, const QString &baseName)
Emitted when a vector tile layer was selected for addition: for signal forwarding to QgisApp.
void rasterLayerAdded(QString const &uri, QString const &baseName, QString const &providerKey)
A raster layer was added: for signal forwarding to QgisApp.
void providerDialogsRefreshRequested()
One or more provider connections have changed and the dialogs should be refreshed.
void updateProjectHome()
Update project home directory.
void setCurrentPage(int index)
Sync current page with the leftbar list.
void addRasterLayers(const QStringList &layersList)
Emitted when a one or more layer were selected for addition: for signal forwarding to QgisApp.
~QgsDataSourceManagerDialog() override
void addRasterLayer()
Emitted when the user wants to select a raster layer: for signal forwarding to QgisApp.
void vectorLayerAdded(const QString &vectorLayerPath, const QString &baseName, const QString &providerKey)
A vector layer was added: for signal forwarding to QgisApp.
static QgsSourceSelectProviderRegistry * sourceSelectProviderRegistry()
Returns the global source select provider registry, used for managing all known source select widget ...
Map canvas is a class for displaying all GIS data types on a canvas.
A bar for displaying non-blocking messages to the user.
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=-1)
A convenience method for pushing a message with the specified text to the bar.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
A base dialog for options and properties dialogs that offers vertical tabs.
void resizeAlltabs(int index)
Resizes all tabs when the dialog is resized.
void restoreOptionsBaseUi(const QString &title=QString())
Restore the base ui.
void initOptionsBase(bool restoreUi=true, const QString &title=QString())
Set up the base ui connections for vertical tabs.
void showEvent(QShowEvent *e) override
QList< QgsSourceSelectProvider * > providers()
Gets list of available providers.
This is the interface for those who want to add entries to the QgsDataSourceManagerDialog.