QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
17 #include <QListWidgetItem>
20 #include "ui_qgsdatasourcemanagerdialog.h"
36 , ui( new Ui::QgsDataSourceManagerDialog )
38 , mMapCanvas( canvas )
39 , mBrowserModel( browserModel )
42 ui->verticalLayout_2->setSpacing( 6 );
43 ui->verticalLayout_2->setContentsMargins( 0, 0, 0, 0 );
46 mMessageBar->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
47 static_cast<QVBoxLayout *
>( layout() )->insertWidget( 0, mMessageBar );
59 mBrowserWidget->setFeatures( QDockWidget::NoDockWidgetFeatures );
60 ui->mOptionsStackedWidget->addWidget( mBrowserWidget );
61 mPageNames.append( QStringLiteral(
"browser" ) );
75 QgsMessageLog::logMessage( tr(
"Cannot get %1 select dialog from source select provider %2." ).arg( provider->name(), provider->providerKey() ), QStringLiteral(
"DataSourceManager" ), Qgis::MessageLevel::Critical );
78 addProviderDialog( dlg, provider->providerKey(), provider->text(), provider->icon( ), provider->toolTip( ) );
91 const int pageIdx = mPageNames.indexOf( pageName );
94 QTimer::singleShot( 0,
this, [ = ] { setCurrentPage( pageIdx ); } );
105 mPreviousRow = ui->mOptionsStackedWidget->currentIndex();
106 ui->mOptionsStackedWidget->setCurrentIndex( index );
107 setWindowTitle( tr(
"Data Source Manager | %1" ).arg( ui->mOptionsListWidget->currentItem()->text() ) );
108 resizeAlltabs( index );
113 const int prevPage = mPreviousRow != -1 ? mPreviousRow : 0;
114 setCurrentPage( prevPage );
119 mBrowserWidget->browserWidget()->refresh();
120 emit providerDialogsRefreshRequested();
125 const int pageCount = ui->mOptionsStackedWidget->count();
126 for (
int i = 0; i < pageCount; ++i )
128 QWidget *widget = ui->mOptionsStackedWidget->widget( i );
130 if ( dataSourceWidget )
131 dataSourceWidget->
reset();
137 emit addRasterLayer( uri, baseName, providerKey );
142 emit addRasterLayers( layersList );
147 emit addVectorLayer( vectorLayerPath, baseName, providerKey );
152 emit addVectorLayers( layerQStringList, enc, dataSourceType );
155 void QgsDataSourceManagerDialog::addProviderDialog(
QgsAbstractDataSourceWidget *dlg,
const QString &providerKey,
const QString &providerName,
const QIcon &icon,
const QString &toolTip )
157 mPageNames.append( providerKey );
158 ui->mOptionsStackedWidget->addWidget( dlg );
159 QListWidgetItem *layerItem =
new QListWidgetItem( providerName, ui->mOptionsListWidget );
160 layerItem->setToolTip( toolTip.isEmpty() ? tr(
"Add %1 layer" ).arg( providerName ) : toolTip );
161 layerItem->setIcon( icon );
169 connect( dlg, &QgsAbstractDataSourceWidget::rejected,
this, &QgsDataSourceManagerDialog::reject );
170 connect( dlg, &QgsAbstractDataSourceWidget::accepted,
this, &QgsDataSourceManagerDialog::accept );
171 makeConnections( dlg, providerKey );
184 const QString key = specifiedProvider.isEmpty() ? providerKey : specifiedProvider;
185 this->vectorLayerAdded( vectorLayerPath, baseName, key );
193 this, [ = ](
const QString & uri,
const QString & baseName,
const QString & providerKey )
195 addRasterLayer( uri, baseName, providerKey );
215 mMessageBar->pushMessage( title, message, level );
221 ui->mOptionsStackedWidget->currentWidget()->show();
223 resizeAlltabs( ui->mOptionsStackedWidget->currentIndex() );
void showEvent(QShowEvent *event) override
void vectorLayerAdded(const QString &vectorLayerPath, const QString &baseName, const QString &providerKey)
A vector layer was added: for signal forwarding to QgisApp.
void openPage(const QString &pageName)
Open a given page in the dialog.
~QgsDataSourceManagerDialog() override
void setPreviousPage()
Reset current page to previously selected page.
A base dialog for options and properties dialogs that offers vertical tabs. It handles saving/restori...
void showStatusMessage(const QString &message)
Emitted when a status message needs to be shown: for signal forwarding to QgisApp.
Map canvas is a class for displaying all GIS data types on a canvas.
This is the interface for those who want to add entries to the QgsDataSourceManagerDialog.
void addVectorTileLayer(const QString &uri, const QString &baseName)
Emitted when a vector tile layer was selected for addition: for signal forwarding to QgisApp.
void connectionsChanged()
Emitted when a connection has changed inside the provider dialogs This signal is normally forwarded t...
void addDatabaseLayers(const QStringList &layerPathList, const QString &providerKey)
Emitted when a DB layer was selected for addition: for signal forwarding to QgisApp.
void vectorLayersAdded(const QStringList &layerQStringList, const QString &enc, const QString &dataSourceType)
One or more vector layer were added: for signal forwarding to QgisApp.
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 refresh()
Refresh the browser view.
void handleDropUriList(const QgsMimeDataUtils::UriList &)
Emitted when drop uri list needs to be handled from the browser.
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.
void rasterLayerAdded(QString const &uri, QString const &baseName, QString const &providerKey)
A raster layer was added: for signal forwarding to QgisApp.
void rasterLayersAdded(const QStringList &layersList)
One or more raster layer were added: for signal forwarding to QgisApp.
A bar for displaying non-blocking messages to the user.
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).
void initOptionsBase(bool restoreUi=true, const QString &title=QString())
Set up the base ui connections for vertical tabs.
void updateProjectHome()
Update project home directory.
void providerDialogsRefreshRequested()
One or more provider connections have changed and the dialogs should be refreshed.
QList< QgsSourceSelectProvider * > providers()
Gets list of available providers.
MessageLevel
Level for messages This will be used both for message log and message bar in application.
void setCurrentPage(int index)
Sync current page with the leftbar list.
void showEvent(QShowEvent *e) override
void reset()
Resets the interface of the datasource manager after reopening the dialog.
QgsDataSourceManagerDialog(QgsBrowserGuiModel *browserModel, QWidget *parent=nullptr, QgsMapCanvas *canvas=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
QgsDataSourceManagerDialog constructor.
QgsMessageBar * messageBar() const
Returns the dialog's message bar.
A model for showing available data sources and other items in a structured tree.
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.
void openFile(const QString &fileName, const QString &fileTypeHint=QString())
Emitted when a file needs to be opened.
void restoreOptionsBaseUi(const QString &title=QString())
Restore the base ui.
static QgsSourceSelectProviderRegistry * sourceSelectProviderRegistry()
Returns the global source select provider registry, used for managing all known source select widget ...