17 #include <QListWidgetItem> 20 #include "ui_qgsdatasourcemanagerdialog.h" 39 ui->verticalLayout_2->setSpacing( 6 );
40 ui->verticalLayout_2->setMargin( 0 );
41 ui->verticalLayout_2->setContentsMargins( 0, 0, 0, 0 );
52 mBrowserWidget->setFeatures( QDockWidget::NoDockWidgetFeatures );
53 ui->mOptionsStackedWidget->addWidget( mBrowserWidget );
54 mPageNames.append( QStringLiteral(
"browser" ) );
63 for (
const auto &provider : sourceSelectProviders )
68 QgsMessageLog::logMessage( tr(
"Cannot get %1 select dialog from source select provider %2." ).arg( provider->name(), provider->providerKey() ), QStringLiteral(
"DataSourceManager" ),
Qgis::Critical );
71 addProviderDialog( dlg, provider->providerKey(), provider->text(), provider->icon( ), provider->toolTip( ) );
83 int pageIdx = mPageNames.indexOf( pageName );
86 QTimer::singleShot( 0,
this, [ = ] {
setCurrentPage( pageIdx ); } );
92 mPreviousRow = ui->mOptionsStackedWidget->currentIndex();
93 ui->mOptionsStackedWidget->setCurrentIndex( index );
94 setWindowTitle( tr(
"Data Source Manager | %1" ).arg( ui->mOptionsListWidget->currentItem()->text() ) );
99 int prevPage = mPreviousRow != -1 ? mPreviousRow : 0;
125 void QgsDataSourceManagerDialog::addProviderDialog(
QgsAbstractDataSourceWidget *dlg,
const QString &providerKey,
const QString &providerName,
const QIcon &icon,
const QString &toolTip )
127 mPageNames.append( providerKey );
128 ui->mOptionsStackedWidget->addWidget( dlg );
129 QListWidgetItem *layerItem =
new QListWidgetItem( providerName, ui->mOptionsListWidget );
130 layerItem->setToolTip( toolTip.isEmpty() ? tr(
"Add %1 layer" ).arg( providerName ) : toolTip );
131 layerItem->setIcon( icon );
137 connect( dlg, &QgsAbstractDataSourceWidget::rejected,
this, &QgsDataSourceManagerDialog::reject );
138 connect( dlg, &QgsAbstractDataSourceWidget::accepted,
this, &QgsDataSourceManagerDialog::accept );
139 makeConnections( dlg, providerKey );
145 connect( dlg, SIGNAL(
addDatabaseLayers( QStringList
const &, QString
const & ) ),
147 connect( dlg, SIGNAL( progress(
int,
int ) ),
149 connect( dlg, SIGNAL( progressMessage( QString ) ),
154 QString key = specifiedProvider.isEmpty() ? providerKey : specifiedProvider;
162 connect( dlg, SIGNAL(
addRasterLayer( QString
const &, QString
const &, QString
const & ) ),
163 this, SIGNAL(
addRasterLayer( QString
const &, QString
const &, QString
const & ) ) );
166 connect( dlg, SIGNAL( replaceVectorLayer( QString, QString, QString, QString ) ),
175 ui->mOptionsStackedWidget->currentWidget()->show();
void rasterLayerAdded(QString const &uri, QString const &baseName, QString const &providerKey)
A raster layer was added: for signal forwarding to QgisApp TODO: use this with an internal source sel...
void connectionsChanged()
Emitted when a connection has changed inside the provider dialogs This signal is normally forwarded t...
void showEvent(QShowEvent *event) override
void showProgress(int progress, int totalSteps)
Emitted when the dialog is busy: for signal forwarding to QgisApp.
void refresh()
Refresh the browser view.
void initOptionsBase(bool restoreUi=true, const QString &title=QString())
Set up the base ui connections for vertical tabs.
QList< QgsSourceSelectProvider * > providers()
Gets list of available providers.
static QgsSourceSelectProviderRegistry * sourceSelectProviderRegistry()
Returns the global source select provider registry, used for managing all known source select widget ...
The QgsDataSourceManagerDialog class embeds the browser panel and all the provider dialogs...
~QgsDataSourceManagerDialog() override
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 providerDialogsRefreshRequested()
One or more provider connections have changed and the dialogs should be refreshed.
void setPreviousPage()
Reset current page to previously selected page.
void handleDropUriList(const QgsMimeDataUtils::UriList &)
Emitted when drop uri list needs to be handled from the browser.
Map canvas is a class for displaying all GIS data types on a canvas.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
void openPage(const QString &pageName)
Open a given page in the dialog.
void updateProjectHome()
Update project home directory.
A base dialog for options and properties dialogs that offers vertical tabs.
void showEvent(QShowEvent *e) 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.
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 showStatusMessage(const QString &message)
Emitted when a status message needs to be shown: for signal forwarding to QgisApp.
A model for showing available data sources and other items in a structured tree.
void openFile(const QString &fileName, const QString &fileTypeHint=QString())
Emitted when a file needs to be opened.
QgsDataSourceManagerDialog(QgsBrowserModel *browserModel, QWidget *parent=nullptr, QgsMapCanvas *canvas=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
QgsDataSourceManagerDialog constructor.
void addDatabaseLayers(const QStringList &layerPathList, const QString &providerKey)
Emitted when a DB layer was selected for addition: for signal forwarding to QgisApp.
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 setCurrentPage(int index)
Sync current page with the leftbar list.