mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
removed mapCanvasChanged() signal and made setMapCanvas virtual in the QgsAbstractDataSourceWidget
This commit is contained in:
parent
5e7e0ae3d3
commit
a59e4680f6
@ -28,12 +28,6 @@ and add layers.
|
||||
%End
|
||||
public:
|
||||
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas );
|
||||
%Docstring
|
||||
Store a pointer to the map canvas to retrieve extent and CRS
|
||||
Used to select an appropriate CRS and possibly to retrieve data only in the current extent
|
||||
%End
|
||||
|
||||
void setBrowserModel( QgsBrowserModel *model );
|
||||
%Docstring
|
||||
Sets a browser ``model`` to use with the widget.
|
||||
@ -43,6 +37,10 @@ Sets a browser ``model`` to use with the widget.
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
virtual QgsMapCanvas *mapCanvas() = 0;
|
||||
|
||||
virtual void setMapCanvas( QgsMapCanvas *mapCanvas ) = 0;
|
||||
|
||||
public slots:
|
||||
|
||||
virtual void refresh();
|
||||
@ -167,11 +165,6 @@ Emitted when the ok/add buttons should be enabled/disabled
|
||||
Emitted when a ``message`` with ``title`` and ``level`` must be shown to the user using the parent visible message bar
|
||||
|
||||
.. versionadded:: 3.14
|
||||
%End
|
||||
|
||||
void mapCanvasChanged();
|
||||
%Docstring
|
||||
Emitted when map canvas is updated
|
||||
%End
|
||||
|
||||
protected:
|
||||
@ -184,11 +177,6 @@ Constructor
|
||||
QgsProviderRegistry::WidgetMode widgetMode() const;
|
||||
%Docstring
|
||||
Returns the widget mode
|
||||
%End
|
||||
|
||||
QgsMapCanvas *mapCanvas();
|
||||
%Docstring
|
||||
Returns the map canvas (can be ``None``)
|
||||
%End
|
||||
|
||||
QgsBrowserModel *browserModel();
|
||||
|
@ -47,6 +47,14 @@ Triggered when the provider's connections need to be refreshed
|
||||
virtual void reset();
|
||||
|
||||
|
||||
virtual void setMapCanvas( QgsMapCanvas *mapCanvas );
|
||||
|
||||
%Docstring
|
||||
Stores the provided map ``canvas`` to the widget.
|
||||
|
||||
.. versionadded:: 3.24
|
||||
%End
|
||||
|
||||
protected slots:
|
||||
void showError( const QString &title, const QString &format, const QString &error );
|
||||
%Docstring
|
||||
@ -197,6 +205,7 @@ Returns currently selected cache load control
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
@ -87,6 +87,18 @@ QgsGdalSourceSelect::QgsGdalSourceSelect( QWidget *parent, Qt::WindowFlags fl, Q
|
||||
mOpenOptionsGroupBox->setVisible( false );
|
||||
}
|
||||
|
||||
void QgsGdalSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsGdalSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
|
||||
bool QgsGdalSourceSelect::isProtocolCloudType()
|
||||
{
|
||||
return ( cmbProtocolTypes->currentText() == QLatin1String( "AWS S3" ) ||
|
||||
|
@ -50,6 +50,24 @@ class QgsGdalSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsG
|
||||
void radioSrcProtocol_toggled( bool checked );
|
||||
void cmbProtocolTypes_currentIndexChanged( const QString &text );
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
private:
|
||||
|
||||
void computeDataSources();
|
||||
@ -59,6 +77,7 @@ class QgsGdalSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsG
|
||||
|
||||
QString mRasterPath;
|
||||
QStringList mDataSources;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
|
||||
};
|
||||
|
||||
|
@ -78,6 +78,17 @@ QgsOgrDbSourceSelect::~QgsOgrDbSourceSelect()
|
||||
settings.setValue( QStringLiteral( "ogr/%1SourceSelect/HoldDialogOpen" ).arg( ogrDriverName( ) ), mHoldDialogOpen->isChecked(), QgsSettings::Section::Providers );
|
||||
}
|
||||
|
||||
void QgsOgrDbSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsOgrDbSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
|
||||
// Remember which database is selected
|
||||
void QgsOgrDbSourceSelect::cmbConnections_activated( int )
|
||||
|
@ -70,6 +70,21 @@ class QgsOgrDbSourceSelect: public QgsAbstractDbSourceSelect
|
||||
//! Open file selector to add new connection
|
||||
static bool newConnection( QWidget *parent );
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
public slots:
|
||||
|
||||
@ -107,6 +122,7 @@ class QgsOgrDbSourceSelect: public QgsAbstractDbSourceSelect
|
||||
QString mOgrDriverName;
|
||||
QString mName;
|
||||
QString mExtension;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
};
|
||||
|
||||
///@endcond
|
||||
|
@ -144,6 +144,17 @@ QgsOgrSourceSelect::QgsOgrSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs
|
||||
mOpenOptionsGroupBox->setVisible( false );
|
||||
}
|
||||
|
||||
void QgsOgrSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsOgrSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
QStringList QgsOgrSourceSelect::dataSources()
|
||||
{
|
||||
return mDataSources;
|
||||
|
@ -64,6 +64,22 @@ class QgsOgrSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsOg
|
||||
//! Returns whether the protocol is a cloud type
|
||||
bool isProtocolCloudType();
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
private:
|
||||
//! Stores the file vector filters
|
||||
QString mVectorFileFilter;
|
||||
@ -119,6 +135,7 @@ class QgsOgrSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsOg
|
||||
std::vector<QWidget *> mOpenOptionsWidgets;
|
||||
|
||||
QString mVectorPath;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
|
||||
};
|
||||
|
||||
|
@ -61,6 +61,17 @@ QgsPointCloudSourceSelect::QgsPointCloudSourceSelect( QWidget *parent, Qt::Windo
|
||||
}
|
||||
}
|
||||
|
||||
void QgsPointCloudSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsPointCloudSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
void QgsPointCloudSourceSelect::addButtonClicked()
|
||||
{
|
||||
if ( mDataSourceType == QLatin1String( "file" ) )
|
||||
|
@ -44,6 +44,22 @@ class QgsPointCloudSourceSelect : public QgsAbstractDataSourceWidget, private Ui
|
||||
//! Determines the tables the user selected and closes the dialog
|
||||
void addButtonClicked() override;
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
private slots:
|
||||
void radioSrcProtocol_toggled( bool checked );
|
||||
void radioSrcFile_toggled( bool checked );
|
||||
@ -54,6 +70,7 @@ class QgsPointCloudSourceSelect : public QgsAbstractDataSourceWidget, private Ui
|
||||
private:
|
||||
QString mPath;
|
||||
QString mDataSourceType;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
};
|
||||
|
||||
///@endcond
|
||||
|
@ -30,11 +30,6 @@ QgsProviderRegistry::WidgetMode QgsAbstractDataSourceWidget::widgetMode() const
|
||||
return mWidgetMode;
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsAbstractDataSourceWidget::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
QgsBrowserModel *QgsAbstractDataSourceWidget::browserModel()
|
||||
{
|
||||
return mBrowserModel;
|
||||
@ -58,12 +53,6 @@ void QgsAbstractDataSourceWidget::setupButtons( QDialogButtonBox *buttonBox )
|
||||
connect( closeButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::reject );
|
||||
}
|
||||
|
||||
void QgsAbstractDataSourceWidget::setMapCanvas( QgsMapCanvas *mapCanvas )
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
emit mapCanvasChanged();
|
||||
}
|
||||
|
||||
void QgsAbstractDataSourceWidget::setBrowserModel( QgsBrowserModel *model )
|
||||
{
|
||||
mBrowserModel = model;
|
||||
|
@ -46,12 +46,6 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Store a pointer to the map canvas to retrieve extent and CRS
|
||||
* Used to select an appropriate CRS and possibly to retrieve data only in the current extent
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas );
|
||||
|
||||
/**
|
||||
* Sets a browser \a model to use with the widget.
|
||||
*
|
||||
@ -60,6 +54,10 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
|
||||
*/
|
||||
void setBrowserModel( QgsBrowserModel *model );
|
||||
|
||||
virtual QgsMapCanvas *mapCanvas() = 0;
|
||||
|
||||
virtual void setMapCanvas( QgsMapCanvas *mapCanvas ) = 0;
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
@ -169,9 +167,6 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
|
||||
*/
|
||||
void pushMessage( const QString &title, const QString &message, const Qgis::MessageLevel level = Qgis::MessageLevel::Info );
|
||||
|
||||
//! Emitted when map canvas is updated
|
||||
void mapCanvasChanged();
|
||||
|
||||
protected:
|
||||
|
||||
//! Constructor
|
||||
@ -180,9 +175,6 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
|
||||
//! Returns the widget mode
|
||||
QgsProviderRegistry::WidgetMode widgetMode() const;
|
||||
|
||||
//! Returns the map canvas (can be NULLPTR)
|
||||
QgsMapCanvas *mapCanvas();
|
||||
|
||||
/**
|
||||
* Returns the associated browser model (may be NULLPTR).
|
||||
*
|
||||
@ -199,7 +191,6 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
|
||||
private:
|
||||
QPushButton *mAddButton = nullptr;
|
||||
QgsProviderRegistry::WidgetMode mWidgetMode;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
QgsBrowserModel *mBrowserModel = nullptr;
|
||||
|
||||
};
|
||||
|
@ -121,6 +121,11 @@ void QgsOWSSourceSelect::reset()
|
||||
mLayersTreeWidget->clearSelection();
|
||||
}
|
||||
|
||||
void QgsOWSSourceSelect::setMapCanvas( QgsMapCanvas *mapCanvas )
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
}
|
||||
|
||||
bool QgsOWSSourceSelect::extentChecked()
|
||||
{
|
||||
return mSourceWidget->extentChecked();
|
||||
@ -128,7 +133,7 @@ bool QgsOWSSourceSelect::extentChecked()
|
||||
|
||||
void QgsOWSSourceSelect::prepareExtent()
|
||||
{
|
||||
mSourceWidget->prepareExtent( QgsAbstractDataSourceWidget::mapCanvas() );
|
||||
mSourceWidget->prepareExtent( mapCanvas() );
|
||||
}
|
||||
|
||||
QgsRectangle QgsOWSSourceSelect::outputExtent()
|
||||
|
@ -69,6 +69,13 @@ class GUI_EXPORT QgsOWSSourceSelect : public QgsAbstractDataSourceWidget, protec
|
||||
|
||||
void reset() override;
|
||||
|
||||
/**
|
||||
* Stores the provided map \a canvas to the widget.
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
protected slots:
|
||||
//! show whatever error is exposed.
|
||||
void showError( const QString &title, const QString &format, const QString &error );
|
||||
@ -199,6 +206,8 @@ class GUI_EXPORT QgsOWSSourceSelect : public QgsAbstractDataSourceWidget, protec
|
||||
//! Layer specific settings widget
|
||||
QgsOWSSourceWidget *mSourceWidget;
|
||||
|
||||
QgsMapCanvas *mMapCanvas;
|
||||
|
||||
private slots:
|
||||
|
||||
//! Opens the create connection dialog to build a new connection
|
||||
|
@ -65,6 +65,17 @@ QgsVectorTileSourceSelect::QgsVectorTileSourceSelect( QWidget *parent, Qt::Windo
|
||||
populateConnectionList();
|
||||
}
|
||||
|
||||
void QgsVectorTileSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsVectorTileSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
void QgsVectorTileSourceSelect::btnNew_clicked()
|
||||
{
|
||||
QgsVectorTileConnectionDialog nc( this );
|
||||
|
@ -44,6 +44,22 @@ class QgsVectorTileSourceSelect : public QgsAbstractDataSourceWidget, private Ui
|
||||
//! Determines the layers the user selected
|
||||
void addButtonClicked() override;
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
private slots:
|
||||
|
||||
//! Opens the create connection dialog to build a new connection
|
||||
@ -64,6 +80,8 @@ class QgsVectorTileSourceSelect : public QgsAbstractDataSourceWidget, private Ui
|
||||
void populateConnectionList();
|
||||
void setConnectionListPosition();
|
||||
void showHelp();
|
||||
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
};
|
||||
|
||||
///@endcond
|
||||
|
@ -109,6 +109,16 @@ QgsArcGisRestSourceSelect::~QgsArcGisRestSourceSelect()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsArcGisRestSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsArcGisRestSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
void QgsArcGisRestSourceSelect::populateImageEncodings( const QString &formats )
|
||||
{
|
||||
const QStringList availableEncodings = formats.split( ',' );
|
||||
|
@ -66,6 +66,22 @@ class QgsArcGisRestSourceSelect : public QgsAbstractDataSourceWidget, protected
|
||||
//! Destructor
|
||||
~QgsArcGisRestSourceSelect() override;
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
protected:
|
||||
|
||||
QgsBrowserGuiModel *mBrowserModel = nullptr;
|
||||
@ -109,6 +125,7 @@ class QgsArcGisRestSourceSelect : public QgsAbstractDataSourceWidget, protected
|
||||
private:
|
||||
|
||||
QString mConnectedService;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
775
src/providers/db2/qgsdb2sourceselect.cpp
Normal file
775
src/providers/db2/qgsdb2sourceselect.cpp
Normal file
@ -0,0 +1,775 @@
|
||||
/***************************************************************************
|
||||
qgsdb2sourceselect.cpp
|
||||
dialog to select DB2 layer(s) and add to the map canvas
|
||||
--------------------------------------
|
||||
Date : 2016-01-27
|
||||
Copyright : (C) 2016 by David Adler
|
||||
Shirley Xiao, David Nguyen
|
||||
Email : dadler at adtechgeospatial.com
|
||||
xshirley2012 at yahoo.com, davidng0123 at gmail.com
|
||||
Adapted from MSSQL provider by Tamas Szekeres
|
||||
****************************************************************************
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsdb2sourceselect.h"
|
||||
#include "qgsdb2dataitems.h"
|
||||
#include "qgsdb2provider.h"
|
||||
#include "qgsdb2newconnection.h"
|
||||
#include "qgsdb2geometrycolumns.h"
|
||||
|
||||
#include "qgslogger.h"
|
||||
#include "qgsapplication.h"
|
||||
#include "qgsmanageconnectionsdialog.h"
|
||||
#include "qgsquerybuilder.h"
|
||||
#include "qgsiconutils.h"
|
||||
#include "qgsdatasourceuri.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgssettings.h"
|
||||
#include "qgsproject.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QStringList>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlError>
|
||||
#include <QSqlField>
|
||||
|
||||
//! Used to create an editor for when the user tries to change the contents of a cell
|
||||
QWidget *QgsDb2SourceSelectDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
|
||||
{
|
||||
Q_UNUSED( option )
|
||||
if ( index.column() == QgsDb2TableModel::DbtmSql )
|
||||
{
|
||||
QLineEdit *le = new QLineEdit( parent );
|
||||
le->setText( index.data( Qt::DisplayRole ).toString() );
|
||||
return le;
|
||||
}
|
||||
|
||||
if ( index.column() == QgsDb2TableModel::DbtmType && index.data( Qt::UserRole + 1 ).toBool() )
|
||||
{
|
||||
QComboBox *cb = new QComboBox( parent );
|
||||
for ( const QgsWkbTypes::Type type :
|
||||
{
|
||||
QgsWkbTypes::Point,
|
||||
QgsWkbTypes::LineString,
|
||||
QgsWkbTypes::Polygon,
|
||||
QgsWkbTypes::MultiPoint,
|
||||
QgsWkbTypes::MultiLineString,
|
||||
QgsWkbTypes::MultiPolygon,
|
||||
QgsWkbTypes::NoGeometry
|
||||
} )
|
||||
{
|
||||
cb->addItem( QgsIconUtils::iconForWkbType( type ), QgsWkbTypes::translatedDisplayString( type ), type );
|
||||
}
|
||||
cb->setCurrentIndex( cb->findData( index.data( Qt::UserRole + 2 ).toInt() ) );
|
||||
return cb;
|
||||
}
|
||||
|
||||
if ( index.column() == QgsDb2TableModel::DbtmPkCol )
|
||||
{
|
||||
const QStringList values = index.data( Qt::UserRole + 1 ).toStringList();
|
||||
|
||||
if ( values.size() > 0 )
|
||||
{
|
||||
QComboBox *cb = new QComboBox( parent );
|
||||
cb->addItems( values );
|
||||
cb->setCurrentIndex( cb->findText( index.data( Qt::DisplayRole ).toString() ) );
|
||||
return cb;
|
||||
}
|
||||
}
|
||||
|
||||
if ( index.column() == QgsDb2TableModel::DbtmSrid )
|
||||
{
|
||||
QLineEdit *le = new QLineEdit( parent );
|
||||
le->setValidator( new QIntValidator( -1, 999999, parent ) );
|
||||
le->insert( index.data( Qt::DisplayRole ).toString() );
|
||||
return le;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelectDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
|
||||
{
|
||||
QComboBox *cb = qobject_cast<QComboBox *>( editor );
|
||||
if ( cb )
|
||||
{
|
||||
if ( index.column() == QgsDb2TableModel::DbtmType )
|
||||
{
|
||||
const QgsWkbTypes::Type type = static_cast< QgsWkbTypes::Type >( cb->currentData().toInt() );
|
||||
|
||||
model->setData( index, QgsIconUtils::iconForWkbType( type ), Qt::DecorationRole );
|
||||
model->setData( index, type != QgsWkbTypes::Unknown ? QgsWkbTypes::translatedDisplayString( type ) : tr( "Select…" ) );
|
||||
model->setData( index, type, Qt::UserRole + 2 );
|
||||
}
|
||||
else if ( index.column() == QgsDb2TableModel::DbtmPkCol )
|
||||
{
|
||||
model->setData( index, cb->currentText() );
|
||||
model->setData( index, cb->currentText(), Qt::UserRole + 2 );
|
||||
}
|
||||
}
|
||||
|
||||
QLineEdit *le = qobject_cast<QLineEdit *>( editor );
|
||||
if ( le )
|
||||
model->setData( index, le->text() );
|
||||
}
|
||||
|
||||
QgsDb2SourceSelect::QgsDb2SourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode theWidgetMode )
|
||||
: QgsAbstractDataSourceWidget( parent, fl, theWidgetMode )
|
||||
{
|
||||
setupUi( this );
|
||||
QgsGui::instance()->enableAutoGeometryRestore( this );
|
||||
|
||||
connect( btnConnect, &QPushButton::clicked, this, &QgsDb2SourceSelect::btnConnect_clicked );
|
||||
connect( cbxAllowGeometrylessTables, &QCheckBox::stateChanged, this, &QgsDb2SourceSelect::cbxAllowGeometrylessTables_stateChanged );
|
||||
connect( btnNew, &QPushButton::clicked, this, &QgsDb2SourceSelect::btnNew_clicked );
|
||||
connect( btnEdit, &QPushButton::clicked, this, &QgsDb2SourceSelect::btnEdit_clicked );
|
||||
connect( btnDelete, &QPushButton::clicked, this, &QgsDb2SourceSelect::btnDelete_clicked );
|
||||
connect( btnSave, &QPushButton::clicked, this, &QgsDb2SourceSelect::btnSave_clicked );
|
||||
connect( btnLoad, &QPushButton::clicked, this, &QgsDb2SourceSelect::btnLoad_clicked );
|
||||
connect( mSearchGroupBox, &QGroupBox::toggled, this, &QgsDb2SourceSelect::mSearchGroupBox_toggled );
|
||||
connect( mSearchTableEdit, &QLineEdit::textChanged, this, &QgsDb2SourceSelect::mSearchTableEdit_textChanged );
|
||||
connect( mSearchColumnComboBox, &QComboBox::currentTextChanged, this, &QgsDb2SourceSelect::mSearchColumnComboBox_currentIndexChanged );
|
||||
connect( mSearchModeComboBox, &QComboBox::currentTextChanged, this, &QgsDb2SourceSelect::mSearchModeComboBox_currentIndexChanged );
|
||||
connect( cmbConnections, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsDb2SourceSelect::cmbConnections_activated );
|
||||
connect( mTablesTreeView, &QTreeView::clicked, this, &QgsDb2SourceSelect::mTablesTreeView_clicked );
|
||||
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsDb2SourceSelect::mTablesTreeView_doubleClicked );
|
||||
setupButtons( buttonBox );
|
||||
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDb2SourceSelect::showHelp );
|
||||
|
||||
setWindowTitle( tr( "Add Db2 Table(s)" ) );
|
||||
|
||||
if ( widgetMode() != QgsProviderRegistry::WidgetMode::None )
|
||||
{
|
||||
mHoldDialogOpen->hide();
|
||||
}
|
||||
|
||||
mBuildQueryButton = new QPushButton( tr( "&Set Filter" ) );
|
||||
mBuildQueryButton->setToolTip( tr( "Set Filter" ) );
|
||||
mBuildQueryButton->setDisabled( true );
|
||||
|
||||
if ( widgetMode() != QgsProviderRegistry::WidgetMode::Manager )
|
||||
{
|
||||
buttonBox->addButton( mBuildQueryButton, QDialogButtonBox::ActionRole );
|
||||
connect( mBuildQueryButton, &QAbstractButton::clicked, this, &QgsDb2SourceSelect::buildQuery );
|
||||
}
|
||||
|
||||
populateConnectionList();
|
||||
|
||||
mSearchModeComboBox->addItem( tr( "Wildcard" ) );
|
||||
mSearchModeComboBox->addItem( tr( "RegExp" ) );
|
||||
|
||||
mSearchColumnComboBox->addItem( tr( "All" ) );
|
||||
mSearchColumnComboBox->addItem( tr( "Schema" ) );
|
||||
mSearchColumnComboBox->addItem( tr( "Table" ) );
|
||||
mSearchColumnComboBox->addItem( tr( "Type" ) );
|
||||
mSearchColumnComboBox->addItem( tr( "Geometry column" ) );
|
||||
mSearchColumnComboBox->addItem( tr( "Primary key column" ) );
|
||||
mSearchColumnComboBox->addItem( tr( "SRID" ) );
|
||||
mSearchColumnComboBox->addItem( tr( "Sql" ) );
|
||||
|
||||
mProxyModel.setParent( this );
|
||||
mProxyModel.setFilterKeyColumn( -1 );
|
||||
mProxyModel.setFilterCaseSensitivity( Qt::CaseInsensitive );
|
||||
mProxyModel.setSourceModel( &mTableModel );
|
||||
|
||||
mTablesTreeView->setModel( &mProxyModel );
|
||||
mTablesTreeView->setSortingEnabled( true );
|
||||
mTablesTreeView->setEditTriggers( QAbstractItemView::CurrentChanged );
|
||||
mTablesTreeView->setItemDelegate( new QgsDb2SourceSelectDelegate( this ) );
|
||||
|
||||
connect( mTablesTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsDb2SourceSelect::treeWidgetSelectionChanged );
|
||||
|
||||
const QgsSettings settings;
|
||||
mTablesTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
|
||||
|
||||
|
||||
//for Qt < 4.3.2, passing -1 to include all model columns
|
||||
//in search does not seem to work
|
||||
mSearchColumnComboBox->setCurrentIndex( 2 );
|
||||
|
||||
mHoldDialogOpen->setChecked( settings.value( QStringLiteral( "Windows/Db2SourceSelect/HoldDialogOpen" ), false ).toBool() );
|
||||
|
||||
for ( int i = 0; i < mTableModel.columnCount(); i++ )
|
||||
{
|
||||
mTablesTreeView->setColumnWidth( i, settings.value( QStringLiteral( "Windows/Db2SourceSelect/columnWidths/%1" ).arg( i ), mTablesTreeView->columnWidth( i ) ).toInt() );
|
||||
}
|
||||
|
||||
//hide the search options by default
|
||||
//they will be shown when the user ticks
|
||||
//the search options group box
|
||||
mSearchLabel->setVisible( false );
|
||||
mSearchColumnComboBox->setVisible( false );
|
||||
mSearchColumnsLabel->setVisible( false );
|
||||
mSearchModeComboBox->setVisible( false );
|
||||
mSearchModeLabel->setVisible( false );
|
||||
mSearchTableEdit->setVisible( false );
|
||||
|
||||
cbxAllowGeometrylessTables->setDisabled( true );
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsDb2SourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::btnNew_clicked()
|
||||
{
|
||||
QgsDb2NewConnection nc( this );
|
||||
if ( nc.exec() )
|
||||
{
|
||||
populateConnectionList();
|
||||
emit connectionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::btnDelete_clicked()
|
||||
{
|
||||
const QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
|
||||
.arg( cmbConnections->currentText() );
|
||||
if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) )
|
||||
return;
|
||||
|
||||
QgsDb2SourceSelect::deleteConnection( cmbConnections->currentText() );
|
||||
|
||||
populateConnectionList();
|
||||
emit connectionsChanged();
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::deleteConnection( const QString &name )
|
||||
{
|
||||
const QString key = "/Db2/connections/" + name;
|
||||
QgsSettings settings;
|
||||
settings.remove( key + "/service" );
|
||||
settings.remove( key + "/driver" );
|
||||
settings.remove( key + "/port" );
|
||||
settings.remove( key + "/host" );
|
||||
settings.remove( key + "/database" );
|
||||
settings.remove( key + "/username" );
|
||||
settings.remove( key + "/password" );
|
||||
settings.remove( key + "/environment" );
|
||||
settings.remove( key + "/allowGeometrylessTables" );
|
||||
settings.remove( key + "/useEstimatedMetadata" );
|
||||
settings.remove( key + "/saveUsername" );
|
||||
settings.remove( key + "/savePassword" );
|
||||
settings.remove( key );
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::btnSave_clicked()
|
||||
{
|
||||
QgsManageConnectionsDialog dlg( this, QgsManageConnectionsDialog::Export, QgsManageConnectionsDialog::DB2 );
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::btnLoad_clicked()
|
||||
{
|
||||
const QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QStringLiteral( "." ),
|
||||
tr( "XML files (*.xml *.XML)" ) );
|
||||
if ( fileName.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QgsManageConnectionsDialog dlg( this, QgsManageConnectionsDialog::Import, QgsManageConnectionsDialog::DB2, fileName );
|
||||
dlg.exec();
|
||||
populateConnectionList();
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::btnEdit_clicked()
|
||||
{
|
||||
QgsDb2NewConnection nc( this, cmbConnections->currentText() );
|
||||
if ( nc.exec() )
|
||||
{
|
||||
populateConnectionList();
|
||||
emit connectionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::cmbConnections_activated( int )
|
||||
{
|
||||
// Remember which database was selected.
|
||||
QgsSettings settings;
|
||||
settings.setValue( QStringLiteral( "Db2/connections/selected" ), cmbConnections->currentText() );
|
||||
|
||||
cbxAllowGeometrylessTables->blockSignals( true );
|
||||
cbxAllowGeometrylessTables->setChecked( settings.value( "/Db2/connections/" + cmbConnections->currentText() + "/allowGeometrylessTables", false ).toBool() );
|
||||
cbxAllowGeometrylessTables->blockSignals( false );
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::cbxAllowGeometrylessTables_stateChanged( int )
|
||||
{
|
||||
btnConnect_clicked();
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::buildQuery()
|
||||
{
|
||||
setSql( mTablesTreeView->currentIndex() );
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::refresh()
|
||||
{
|
||||
populateConnectionList();
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::mTablesTreeView_clicked( const QModelIndex &index )
|
||||
{
|
||||
mBuildQueryButton->setEnabled( index.parent().isValid() );
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::mTablesTreeView_doubleClicked( const QModelIndex & )
|
||||
{
|
||||
addButtonClicked();
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::mSearchGroupBox_toggled( bool checked )
|
||||
{
|
||||
if ( mSearchTableEdit->text().isEmpty() )
|
||||
return;
|
||||
|
||||
mSearchTableEdit_textChanged( checked ? mSearchTableEdit->text() : QString() );
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::mSearchTableEdit_textChanged( const QString &text )
|
||||
{
|
||||
if ( mSearchModeComboBox->currentText() == tr( "Wildcard" ) )
|
||||
{
|
||||
mProxyModel._setFilterWildcard( text );
|
||||
}
|
||||
else if ( mSearchModeComboBox->currentText() == tr( "RegExp" ) )
|
||||
{
|
||||
mProxyModel._setFilterRegExp( text );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::mSearchColumnComboBox_currentIndexChanged( const QString &text )
|
||||
{
|
||||
if ( text == tr( "All" ) )
|
||||
{
|
||||
mProxyModel.setFilterKeyColumn( -1 );
|
||||
}
|
||||
else if ( text == tr( "Schema" ) )
|
||||
{
|
||||
mProxyModel.setFilterKeyColumn( QgsDb2TableModel::DbtmSchema );
|
||||
}
|
||||
else if ( text == tr( "Table" ) )
|
||||
{
|
||||
mProxyModel.setFilterKeyColumn( QgsDb2TableModel::DbtmTable );
|
||||
}
|
||||
else if ( text == tr( "Type" ) )
|
||||
{
|
||||
mProxyModel.setFilterKeyColumn( QgsDb2TableModel::DbtmType );
|
||||
}
|
||||
else if ( text == tr( "Geometry column" ) )
|
||||
{
|
||||
mProxyModel.setFilterKeyColumn( QgsDb2TableModel::DbtmGeomCol );
|
||||
}
|
||||
else if ( text == tr( "Primary key column" ) )
|
||||
{
|
||||
mProxyModel.setFilterKeyColumn( QgsDb2TableModel::DbtmPkCol );
|
||||
}
|
||||
else if ( text == tr( "SRID" ) )
|
||||
{
|
||||
mProxyModel.setFilterKeyColumn( QgsDb2TableModel::DbtmSrid );
|
||||
}
|
||||
else if ( text == tr( "Sql" ) )
|
||||
{
|
||||
mProxyModel.setFilterKeyColumn( QgsDb2TableModel::DbtmSql );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::mSearchModeComboBox_currentIndexChanged( const QString &text )
|
||||
{
|
||||
Q_UNUSED( text )
|
||||
mSearchTableEdit_textChanged( mSearchTableEdit->text() );
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::setLayerType( const QgsDb2LayerProperty &layerProperty )
|
||||
{
|
||||
mTableModel.setGeometryTypesForTable( layerProperty );
|
||||
}
|
||||
|
||||
QgsDb2SourceSelect::~QgsDb2SourceSelect()
|
||||
{
|
||||
if ( mColumnTypeThread )
|
||||
{
|
||||
mColumnTypeThread->stop();
|
||||
mColumnTypeThread->wait();
|
||||
}
|
||||
|
||||
QgsSettings settings;
|
||||
settings.setValue( QStringLiteral( "Windows/Db2SourceSelect/HoldDialogOpen" ), mHoldDialogOpen->isChecked() );
|
||||
|
||||
for ( int i = 0; i < mTableModel.columnCount(); i++ )
|
||||
{
|
||||
settings.setValue( QStringLiteral( "Windows/Db2SourceSelect/columnWidths/%1" ).arg( i ), mTablesTreeView->columnWidth( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::populateConnectionList()
|
||||
{
|
||||
QgsSettings settings;
|
||||
settings.beginGroup( QStringLiteral( "Db2/connections" ) );
|
||||
QStringList keys = settings.childGroups();
|
||||
QStringList::Iterator it = keys.begin();
|
||||
cmbConnections->clear();
|
||||
while ( it != keys.end() )
|
||||
{
|
||||
cmbConnections->addItem( *it );
|
||||
++it;
|
||||
}
|
||||
|
||||
btnConnect->setDisabled( cmbConnections->count() == 0 );
|
||||
btnEdit->setDisabled( cmbConnections->count() == 0 );
|
||||
btnDelete->setDisabled( cmbConnections->count() == 0 );
|
||||
btnSave->setDisabled( cmbConnections->count() == 0 );
|
||||
cmbConnections->setDisabled( cmbConnections->count() == 0 );
|
||||
|
||||
setConnectionListPosition();
|
||||
}
|
||||
|
||||
// Slot for performing action when the Add button is clicked
|
||||
void QgsDb2SourceSelect::addButtonClicked()
|
||||
{
|
||||
QgsDebugMsg( QStringLiteral( "mConnInfo:%1" ).arg( mConnInfo ) );
|
||||
mSelectedTables.clear();
|
||||
|
||||
const QModelIndexList selection = mTablesTreeView->selectionModel()->selection().indexes();
|
||||
for ( const QModelIndex &idx : selection )
|
||||
{
|
||||
if ( idx.column() != QgsDb2TableModel::DbtmTable )
|
||||
continue;
|
||||
|
||||
const QString uri = mTableModel.layerURI( mProxyModel.mapToSource( idx ), mConnInfo, mUseEstimatedMetadata );
|
||||
if ( uri.isNull() )
|
||||
continue;
|
||||
|
||||
mSelectedTables << uri;
|
||||
}
|
||||
|
||||
if ( mSelectedTables.empty() )
|
||||
{
|
||||
QMessageBox::information( this, tr( "Select Table" ), tr( "You must select a table in order to add a layer." ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
emit addDatabaseLayers( mSelectedTables, QStringLiteral( "DB2" ) );
|
||||
if ( !mHoldDialogOpen->isChecked() && widgetMode() == QgsProviderRegistry::WidgetMode::None )
|
||||
{
|
||||
accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::btnConnect_clicked()
|
||||
{
|
||||
cbxAllowGeometrylessTables->setEnabled( true );
|
||||
|
||||
if ( mColumnTypeThread )
|
||||
{
|
||||
mColumnTypeThread->stop();
|
||||
return;
|
||||
}
|
||||
|
||||
const QModelIndex rootItemIndex = mTableModel.indexFromItem( mTableModel.invisibleRootItem() );
|
||||
mTableModel.removeRows( 0, mTableModel.rowCount( rootItemIndex ), rootItemIndex );
|
||||
|
||||
// populate the table list
|
||||
|
||||
QString errorMsg;
|
||||
const bool success = QgsDb2ConnectionItem::ConnInfoFromSettings( cmbConnections->currentText(), mConnInfo, errorMsg );
|
||||
if ( !success )
|
||||
{
|
||||
QgsDebugMsg( "settings error: " + errorMsg );
|
||||
QMessageBox::warning( this,
|
||||
tr( "DB2 Provider" ), errorMsg );
|
||||
return;
|
||||
}
|
||||
|
||||
const QSqlDatabase db = QgsDb2Provider::getDatabase( mConnInfo, errorMsg );
|
||||
|
||||
if ( !errorMsg.isEmpty() )
|
||||
{
|
||||
// Let user know we couldn't initialize the DB2 provider
|
||||
QMessageBox::warning( this,
|
||||
tr( "DB2 Provider" ), errorMsg );
|
||||
return;
|
||||
}
|
||||
|
||||
QgsDb2GeometryColumns db2GC = QgsDb2GeometryColumns( db );
|
||||
const QString sqlcode = db2GC.open();
|
||||
if ( !sqlcode.isEmpty() && QStringLiteral( "0" ) != sqlcode )
|
||||
{
|
||||
QMessageBox::warning( this, tr( "DB2GSE.ST_GEOMETRY_COLUMNS Not Found" ),
|
||||
tr( "DB2GSE.ST_GEOMETRY_COLUMNS not found. The DB2 Spatial Extender is not enabled or set up." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
|
||||
if ( db2GC.isActive() )
|
||||
{
|
||||
// Read supported layers from database
|
||||
QgsDb2LayerProperty layer;
|
||||
|
||||
while ( db2GC.populateLayerProperty( layer ) )
|
||||
{
|
||||
QgsDebugMsg( "layer type: " + layer.type );
|
||||
mTableModel.addTableEntry( layer );
|
||||
|
||||
if ( mColumnTypeThread )
|
||||
{
|
||||
btnConnect->setText( tr( "Stop" ) );
|
||||
mColumnTypeThread->start();
|
||||
}
|
||||
|
||||
//if we have only one schema item, expand it by default
|
||||
const int numTopLevelItems = mTableModel.invisibleRootItem()->rowCount();
|
||||
if ( numTopLevelItems < 2 || mTableModel.tableCount() < 20 )
|
||||
{
|
||||
//expand all the toplevel items
|
||||
for ( int i = 0; i < numTopLevelItems; ++i )
|
||||
{
|
||||
mTablesTreeView->expand( mProxyModel.mapFromSource(
|
||||
mTableModel.indexFromItem( mTableModel.invisibleRootItem()->child( i ) ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QApplication::restoreOverrideCursor();
|
||||
// Let user know we couldn't retrieve tables from the Db2 provider
|
||||
QMessageBox::warning( this,
|
||||
tr( "DB2 Provider" ), db.lastError().text() );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !mColumnTypeThread )
|
||||
{
|
||||
finishList();
|
||||
}
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::finishList()
|
||||
{
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
mTablesTreeView->sortByColumn( QgsDb2TableModel::DbtmTable, Qt::AscendingOrder );
|
||||
mTablesTreeView->sortByColumn( QgsDb2TableModel::DbtmSchema, Qt::AscendingOrder );
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::columnThreadFinished()
|
||||
{
|
||||
delete mColumnTypeThread;
|
||||
mColumnTypeThread = nullptr;
|
||||
btnConnect->setText( tr( "Connect" ) );
|
||||
|
||||
finishList();
|
||||
}
|
||||
|
||||
QStringList QgsDb2SourceSelect::selectedTables()
|
||||
{
|
||||
return mSelectedTables;
|
||||
}
|
||||
|
||||
QString QgsDb2SourceSelect::connectionInfo()
|
||||
{
|
||||
return mConnInfo;
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::setSql( const QModelIndex &index )
|
||||
{
|
||||
if ( !index.parent().isValid() )
|
||||
{
|
||||
QgsDebugMsg( QStringLiteral( "schema item found" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
const QModelIndex idx = mProxyModel.mapToSource( index );
|
||||
const QString tableName = mTableModel.itemFromIndex( idx.sibling( idx.row(), QgsDb2TableModel::DbtmTable ) )->text();
|
||||
|
||||
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
|
||||
std::unique_ptr< QgsVectorLayer > vlayer = std::make_unique< QgsVectorLayer >( mTableModel.layerURI( idx, mConnInfo, mUseEstimatedMetadata ), tableName, QStringLiteral( "DB2" ), options );
|
||||
|
||||
if ( !vlayer->isValid() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// create a query builder object
|
||||
QgsQueryBuilder gb( vlayer.get(), this );
|
||||
if ( gb.exec() )
|
||||
{
|
||||
mTableModel.setSql( mProxyModel.mapToSource( index ), gb.sql() );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::addSearchGeometryColumn( const QString &connectionName, const QgsDb2LayerProperty &layerProperty, bool estimateMetadata )
|
||||
{
|
||||
// store the column details and do the query in a thread
|
||||
if ( !mColumnTypeThread )
|
||||
{
|
||||
mColumnTypeThread = new QgsDb2GeomColumnTypeThread( connectionName, estimateMetadata );
|
||||
|
||||
connect( mColumnTypeThread, &QgsDb2GeomColumnTypeThread::setLayerType,
|
||||
this, &QgsDb2SourceSelect::setLayerType );
|
||||
connect( this, &QgsDb2SourceSelect::addGeometryColumn,
|
||||
mColumnTypeThread, &QgsDb2GeomColumnTypeThread::addGeometryColumn );
|
||||
connect( mColumnTypeThread, &QThread::finished,
|
||||
this, &QgsDb2SourceSelect::columnThreadFinished );
|
||||
|
||||
}
|
||||
|
||||
emit addGeometryColumn( layerProperty );
|
||||
}
|
||||
|
||||
QString QgsDb2SourceSelect::fullDescription( const QString &schema, const QString &table, const QString &column, const QString &type )
|
||||
{
|
||||
QString full_desc;
|
||||
if ( !schema.isEmpty() )
|
||||
full_desc = schema + '.';
|
||||
full_desc += table + " (" + column + ") " + type;
|
||||
return full_desc;
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::setConnectionListPosition()
|
||||
{
|
||||
// If possible, set the item currently displayed database
|
||||
const QgsSettings settings;
|
||||
const QString toSelect = settings.value( QStringLiteral( "Db2/connections/selected" ) ).toString();
|
||||
cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );
|
||||
|
||||
if ( cmbConnections->currentIndex() < 0 )
|
||||
{
|
||||
if ( toSelect.isNull() )
|
||||
cmbConnections->setCurrentIndex( 0 );
|
||||
else
|
||||
cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::setSearchExpression( const QString ®exp )
|
||||
{
|
||||
Q_UNUSED( regexp )
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::treeWidgetSelectionChanged( const QItemSelection &, const QItemSelection & )
|
||||
{
|
||||
emit enableButtons( !mTablesTreeView->selectionModel()->selection().isEmpty() );
|
||||
}
|
||||
|
||||
|
||||
QgsDb2GeomColumnTypeThread::QgsDb2GeomColumnTypeThread( const QString &connectionName, bool useEstimatedMetadata )
|
||||
: mConnectionName( connectionName )
|
||||
, mUseEstimatedMetadata( useEstimatedMetadata )
|
||||
{
|
||||
qRegisterMetaType<QgsDb2LayerProperty>( "QgsDb2LayerProperty" );
|
||||
}
|
||||
|
||||
void QgsDb2GeomColumnTypeThread::addGeometryColumn( const QgsDb2LayerProperty &layerProperty )
|
||||
{
|
||||
layerProperties << layerProperty;
|
||||
}
|
||||
|
||||
void QgsDb2GeomColumnTypeThread::stop()
|
||||
{
|
||||
mStopped = true;
|
||||
}
|
||||
|
||||
void QgsDb2GeomColumnTypeThread::run()
|
||||
{
|
||||
mStopped = false;
|
||||
|
||||
for ( QList<QgsDb2LayerProperty>::iterator it = layerProperties.begin(),
|
||||
end = layerProperties.end();
|
||||
it != end; ++it )
|
||||
{
|
||||
QgsDb2LayerProperty &layerProperty = *it;
|
||||
|
||||
if ( !mStopped )
|
||||
{
|
||||
QString table;
|
||||
table = QStringLiteral( "%1[%2]" )
|
||||
.arg( layerProperty.schemaName.isEmpty() ? QString() : QStringLiteral( "[%1]." ).arg( layerProperty.schemaName ),
|
||||
layerProperty.tableName );
|
||||
|
||||
const QString query = QString( "SELECT %3"
|
||||
" UPPER([%1].STGeometryType()),"
|
||||
" [%1].STSrid"
|
||||
" FROM %2"
|
||||
" WHERE [%1] IS NOT NULL %4"
|
||||
" GROUP BY [%1].STGeometryType(), [%1].STSrid" )
|
||||
.arg( layerProperty.geometryColName,
|
||||
table,
|
||||
mUseEstimatedMetadata ? QStringLiteral( "TOP 1" ) : QString(),
|
||||
layerProperty.sql.isEmpty() ? QString() : QStringLiteral( " AND %1" ).arg( layerProperty.sql ) );
|
||||
|
||||
// issue the sql query
|
||||
const QSqlDatabase db = QSqlDatabase::database( mConnectionName );
|
||||
if ( !QgsDb2Provider::openDatabase( db ) )
|
||||
{
|
||||
QgsDebugMsg( db.lastError().text() );
|
||||
continue;
|
||||
}
|
||||
|
||||
QSqlQuery q = QSqlQuery( db );
|
||||
q.setForwardOnly( true );
|
||||
if ( !q.exec( query ) )
|
||||
{
|
||||
QgsDebugMsg( q.lastError().text() );
|
||||
}
|
||||
|
||||
QString type;
|
||||
QString srid;
|
||||
|
||||
if ( q.isActive() )
|
||||
{
|
||||
QStringList types;
|
||||
QStringList srids;
|
||||
|
||||
while ( q.next() )
|
||||
{
|
||||
const QString type = q.value( 0 ).toString().toUpper();
|
||||
const QString srid = q.value( 1 ).toString();
|
||||
|
||||
if ( type.isEmpty() )
|
||||
continue;
|
||||
|
||||
types << type;
|
||||
srids << srid;
|
||||
}
|
||||
|
||||
type = types.join( ',' );
|
||||
srid = srids.join( ',' );
|
||||
}
|
||||
|
||||
layerProperty.type = type;
|
||||
layerProperty.srid = srid;
|
||||
}
|
||||
else
|
||||
{
|
||||
layerProperty.type.clear();
|
||||
layerProperty.srid.clear();
|
||||
}
|
||||
|
||||
// Now tell the layer list dialog box...
|
||||
emit setLayerType( layerProperty );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsDb2SourceSelect::showHelp()
|
||||
{
|
||||
QgsHelp::openHelp( QStringLiteral( "managing_data_source/opening_data.html#loading-a-database-layer" ) );
|
||||
}
|
206
src/providers/db2/qgsdb2sourceselect.h
Normal file
206
src/providers/db2/qgsdb2sourceselect.h
Normal file
@ -0,0 +1,206 @@
|
||||
/***************************************************************************
|
||||
qgsdb2sourceselect.h
|
||||
dialog to select DB2 layer(s) and add to the map canvas
|
||||
--------------------------------------
|
||||
Date : 2016-01-27
|
||||
Copyright : (C) 2016 by David Adler
|
||||
Shirley Xiao, David Nguyen
|
||||
Email : dadler at adtechgeospatial.com
|
||||
xshirley2012 at yahoo.com, davidng0123 at gmail.com
|
||||
****************************************************************************
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSDB2SOURCESELECT_H
|
||||
#define QGSDB2SOURCESELECT_H
|
||||
|
||||
#include "ui_qgsdbsourceselectbase.h"
|
||||
#include "qgsguiutils.h"
|
||||
#include "qgsdbfilterproxymodel.h"
|
||||
#include "qgsdb2tablemodel.h"
|
||||
#include "qgshelp.h"
|
||||
#include "qgsproviderregistry.h"
|
||||
#include "qgsabstractdatasourcewidget.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QPair>
|
||||
#include <QIcon>
|
||||
#include <QItemDelegate>
|
||||
#include <QThread>
|
||||
|
||||
class QPushButton;
|
||||
class QStringList;
|
||||
class QgisApp;
|
||||
|
||||
class QgsDb2SourceSelectDelegate : public QItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QgsDb2SourceSelectDelegate( QObject *parent = nullptr )
|
||||
: QItemDelegate( parent )
|
||||
{}
|
||||
|
||||
QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
|
||||
void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;
|
||||
};
|
||||
|
||||
// A class that determines the geometry type of a given database
|
||||
// schema.table.column, with the option of doing so in a separate
|
||||
// thread.
|
||||
|
||||
class QgsDb2GeomColumnTypeThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QgsDb2GeomColumnTypeThread( const QString &connectionName, bool useEstimatedMetadata );
|
||||
|
||||
// These functions get the layer types and pass that information out
|
||||
// by emitting the setLayerType() signal.
|
||||
void run() override;
|
||||
|
||||
signals:
|
||||
void setLayerType( QgsDb2LayerProperty layerProperty );
|
||||
|
||||
public slots:
|
||||
void addGeometryColumn( const QgsDb2LayerProperty &layerProperty );
|
||||
void stop();
|
||||
|
||||
private:
|
||||
QgsDb2GeomColumnTypeThread() = delete;
|
||||
|
||||
QString mConnectionName;
|
||||
bool mUseEstimatedMetadata = false;
|
||||
bool mStopped = false;
|
||||
QList<QgsDb2LayerProperty> layerProperties;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \class QgsDb2SourceSelect
|
||||
* \brief Dialog to create connections and add tables from Db2.
|
||||
*
|
||||
* This dialog allows the user to define and save connection information
|
||||
* for Db2 databases. The user can then connect and add
|
||||
* tables from the database to the map canvas.
|
||||
*/
|
||||
class QgsDb2SourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsDbSourceSelectBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! static function to delete a connection
|
||||
static void deleteConnection( const QString &key );
|
||||
|
||||
//! Constructor
|
||||
QgsDb2SourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
|
||||
|
||||
~QgsDb2SourceSelect() override;
|
||||
//! Populate the connection list combo box
|
||||
void populateConnectionList();
|
||||
//! String list containing the selected tables
|
||||
QStringList selectedTables();
|
||||
//! Connection info (database, host, user, password)
|
||||
QString connectionInfo();
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
signals:
|
||||
void addGeometryColumn( QgsDb2LayerProperty );
|
||||
|
||||
public slots:
|
||||
//! Determines the tables the user selected and closes the dialog
|
||||
void addButtonClicked() override;
|
||||
void buildQuery();
|
||||
//! Triggered when the provider's connections need to be refreshed
|
||||
void refresh() override;
|
||||
|
||||
/**
|
||||
* Connects to the database using the stored connection parameters.
|
||||
* Once connected, available layers are displayed.
|
||||
*/
|
||||
void btnConnect_clicked();
|
||||
void cbxAllowGeometrylessTables_stateChanged( int );
|
||||
//! Opens the create connection dialog to build a new connection
|
||||
void btnNew_clicked();
|
||||
//! Opens a dialog to edit an existing connection
|
||||
void btnEdit_clicked();
|
||||
//! Deletes the selected connection
|
||||
void btnDelete_clicked();
|
||||
//! Saves the selected connections to file
|
||||
void btnSave_clicked();
|
||||
//! Loads the selected connections from file
|
||||
void btnLoad_clicked();
|
||||
void mSearchGroupBox_toggled( bool );
|
||||
void mSearchTableEdit_textChanged( const QString &text );
|
||||
void mSearchColumnComboBox_currentIndexChanged( const QString &text );
|
||||
void mSearchModeComboBox_currentIndexChanged( const QString &text );
|
||||
void setSql( const QModelIndex &index );
|
||||
//! Store the selected database
|
||||
void cmbConnections_activated( int );
|
||||
void setLayerType( const QgsDb2LayerProperty &layerProperty );
|
||||
void mTablesTreeView_clicked( const QModelIndex &index );
|
||||
void mTablesTreeView_doubleClicked( const QModelIndex &index );
|
||||
void treeWidgetSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
|
||||
//!Sets a new regular expression to the model
|
||||
void setSearchExpression( const QString ®exp );
|
||||
|
||||
void columnThreadFinished();
|
||||
|
||||
private:
|
||||
typedef QPair<QString, QString> geomPair;
|
||||
typedef QList<geomPair> geomCol;
|
||||
|
||||
// queue another query for the thread
|
||||
void addSearchGeometryColumn( const QString &connectionName, const QgsDb2LayerProperty &layerProperty, bool estimateMetadata );
|
||||
|
||||
// Set the position of the database connection list to the last
|
||||
// used one.
|
||||
void setConnectionListPosition();
|
||||
// Combine the schema, table and column data into a single string
|
||||
// useful for display to the user
|
||||
QString fullDescription( const QString &schema, const QString &table, const QString &column, const QString &type );
|
||||
// The column labels
|
||||
QStringList mColumnLabels;
|
||||
// Our thread for doing long running queries
|
||||
QgsDb2GeomColumnTypeThread *mColumnTypeThread = nullptr;
|
||||
QString mConnInfo;
|
||||
QStringList mSelectedTables;
|
||||
bool mUseEstimatedMetadata = false;
|
||||
// Storage for the range of layer type icons
|
||||
QMap<QString, QPair<QString, QIcon> > mLayerIcons;
|
||||
|
||||
//! Model that acts as datasource for mTableTreeWidget
|
||||
QgsDb2TableModel mTableModel;
|
||||
QgsDatabaseFilterProxyModel mProxyModel;
|
||||
|
||||
QPushButton *mBuildQueryButton = nullptr;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
|
||||
void finishList();
|
||||
|
||||
void showHelp();
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSDb2SOURCESELECT_H
|
@ -118,6 +118,17 @@ QgsDelimitedTextSourceSelect::QgsDelimitedTextSourceSelect( QWidget *parent, Qt:
|
||||
mScanWidget->hide( );
|
||||
}
|
||||
|
||||
void QgsDelimitedTextSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsDelimitedTextSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
void QgsDelimitedTextSourceSelect::addButtonClicked()
|
||||
{
|
||||
// The following conditions should not be hit! OK will not be enabled...
|
||||
|
@ -95,6 +95,22 @@ class QgsDelimitedTextSourceSelect : public QgsAbstractDataSourceWidget, private
|
||||
public:
|
||||
QgsDelimitedTextSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
private:
|
||||
bool loadDelimitedFileDefinition();
|
||||
void updateFieldLists();
|
||||
@ -119,6 +135,7 @@ class QgsDelimitedTextSourceSelect : public QgsAbstractDataSourceWidget, private
|
||||
QPointer<QgsDelimitedTextFileScanTask> mScanTask;
|
||||
QButtonGroup *bgFileFormat = nullptr;
|
||||
QButtonGroup *bgGeomType = nullptr;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
void showHelp();
|
||||
void updateCrsWidgetVisibility();
|
||||
QString url( bool skipOverriddenTypes = false );
|
||||
|
@ -78,6 +78,17 @@ QgsGeoNodeSourceSelect::~QgsGeoNodeSourceSelect()
|
||||
emit abortRequests();
|
||||
}
|
||||
|
||||
void QgsGeoNodeSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsGeoNodeSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
void QgsGeoNodeSourceSelect::reset()
|
||||
{
|
||||
treeView->clearSelection();
|
||||
|
@ -47,6 +47,22 @@ class QgsGeoNodeSourceSelect: public QgsAbstractDataSourceWidget, private Ui::Qg
|
||||
|
||||
void reset() override;
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
private:
|
||||
|
||||
void addButtonClicked() override;
|
||||
@ -68,6 +84,7 @@ class QgsGeoNodeSourceSelect: public QgsAbstractDataSourceWidget, private Ui::Qg
|
||||
QStandardItemModel *mModel = nullptr;
|
||||
QSortFilterProxyModel *mModelProxy = nullptr;
|
||||
QModelIndex mSQLIndex;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
|
||||
void updateButtonStateForAvailableConnections();
|
||||
QgsGeoNodeConnection currentConnection() const;
|
||||
|
@ -41,6 +41,18 @@ QgsGpxSourceSelect::QgsGpxSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs
|
||||
this, &QgsGpxSourceSelect::enableRelevantControls );
|
||||
}
|
||||
|
||||
void QgsGpxSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsGpxSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
|
||||
void QgsGpxSourceSelect::addButtonClicked()
|
||||
{
|
||||
if ( mGpxPath.isEmpty() )
|
||||
|
@ -34,6 +34,22 @@ class QgsGpxSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsGp
|
||||
//! Constructor
|
||||
QgsGpxSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
public slots:
|
||||
//! Determines the tables the user selected and closes the dialog
|
||||
void addButtonClicked() override;
|
||||
@ -44,6 +60,7 @@ class QgsGpxSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsGp
|
||||
|
||||
private:
|
||||
QString mGpxPath;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
|
||||
};
|
||||
|
||||
|
@ -37,6 +37,17 @@ QgsMdalSourceSelect::QgsMdalSourceSelect( QWidget *parent, Qt::WindowFlags fl, Q
|
||||
} );
|
||||
}
|
||||
|
||||
void QgsMdalSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsMdalSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
|
||||
void QgsMdalSourceSelect::addButtonClicked()
|
||||
{
|
||||
if ( mMeshPath.isEmpty() )
|
||||
|
@ -34,13 +34,30 @@ class QgsMdalSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsM
|
||||
//! Constructor
|
||||
QgsMdalSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
|
||||
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
public slots:
|
||||
//! Determines the tables the user selected and closes the dialog
|
||||
void addButtonClicked() override;
|
||||
|
||||
private:
|
||||
QString mMeshPath;
|
||||
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
};
|
||||
|
||||
#endif // QGMDALSOURCESELECT_H
|
||||
|
@ -169,6 +169,16 @@ QgsMssqlSourceSelect::QgsMssqlSourceSelect( QWidget *parent, Qt::WindowFlags fl,
|
||||
cbxAllowGeometrylessTables->setDisabled( true );
|
||||
}
|
||||
|
||||
void QgsMssqlSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsMssqlSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
void QgsMssqlSourceSelect::btnNew_clicked()
|
||||
{
|
||||
QgsMssqlNewConnection nc( this );
|
||||
|
@ -77,6 +77,22 @@ class QgsMssqlSourceSelect : public QgsAbstractDbSourceSelect
|
||||
//! Connection info (database, host, user, password)
|
||||
QString connectionInfo();
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
void reset() override;
|
||||
|
||||
signals:
|
||||
@ -145,6 +161,8 @@ class QgsMssqlSourceSelect : public QgsAbstractDbSourceSelect
|
||||
//! Model that acts as datasource for mTableTreeWidget
|
||||
QgsMssqlTableModel *mTableModel = nullptr;
|
||||
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
|
||||
void finishList();
|
||||
|
||||
void showHelp();
|
||||
|
@ -258,6 +258,17 @@ QgsPgSourceSelect::QgsPgSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsPr
|
||||
}
|
||||
}
|
||||
|
||||
void QgsPgSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsPgSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
//! Autoconnected SLOTS
|
||||
// Slot for adding a new connection
|
||||
void QgsPgSourceSelect::btnNew_clicked()
|
||||
|
@ -77,6 +77,22 @@ class QgsPgSourceSelect : public QgsAbstractDbSourceSelect
|
||||
//! Data source URI
|
||||
QgsDataSourceUri dataSourceUri();
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
signals:
|
||||
void addGeometryColumn( const QgsPostgresLayerProperty & );
|
||||
void progressMessage( const QString & );
|
||||
@ -144,6 +160,7 @@ class QgsPgSourceSelect : public QgsAbstractDbSourceSelect
|
||||
|
||||
//! Model that acts as datasource for mTableTreeWidget
|
||||
QgsPgTableModel *mTableModel = nullptr;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
|
||||
void finishList();
|
||||
|
||||
|
@ -93,6 +93,16 @@ QgsSpatiaLiteSourceSelect::~QgsSpatiaLiteSourceSelect()
|
||||
settings.setValue( QStringLiteral( "Windows/SpatiaLiteSourceSelect/HoldDialogOpen" ), mHoldDialogOpen->isChecked() );
|
||||
}
|
||||
|
||||
void QgsSpatiaLiteSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsSpatiaLiteSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
|
||||
// Remember which database is selected
|
||||
void QgsSpatiaLiteSourceSelect::cmbConnections_activated( int )
|
||||
|
@ -64,6 +64,22 @@ class QgsSpatiaLiteSourceSelect: public QgsAbstractDbSourceSelect
|
||||
// Store the selected database
|
||||
void dbChanged();
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
public slots:
|
||||
|
||||
//! Triggered when the provider's connections need to be refreshed
|
||||
@ -122,6 +138,7 @@ class QgsSpatiaLiteSourceSelect: public QgsAbstractDbSourceSelect
|
||||
|
||||
QString layerURI( const QModelIndex &index );
|
||||
QPushButton *mStatsButton = nullptr;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
};
|
||||
|
||||
#endif // QGSSPATIALITESOURCESELECT_H
|
||||
|
@ -101,6 +101,16 @@ void QgsVirtualLayerSourceSelect::refresh()
|
||||
updateLayersList();
|
||||
}
|
||||
|
||||
void QgsVirtualLayerSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsVirtualLayerSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
void QgsVirtualLayerSourceSelect::layerComboChanged( int idx )
|
||||
{
|
||||
if ( idx == -1 )
|
||||
|
@ -39,6 +39,22 @@ class QgsVirtualLayerSourceSelect : public QgsAbstractDataSourceWidget, private
|
||||
public:
|
||||
QgsVirtualLayerSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
public slots:
|
||||
//! Triggered when the provider's connections need to be refreshed
|
||||
void refresh() override;
|
||||
@ -65,6 +81,8 @@ class QgsVirtualLayerSourceSelect : public QgsAbstractDataSourceWidget, private
|
||||
void addEmbeddedLayer( const QString &name, const QString &provider, const QString &encoding, const QString &source );
|
||||
QgsLayerTreeView *mTreeView = nullptr;
|
||||
bool preFlight();
|
||||
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -43,6 +43,15 @@ QgsWCSSourceSelect::QgsWCSSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs
|
||||
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsWCSSourceSelect::showHelp );
|
||||
}
|
||||
|
||||
void QgsWCSSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsWCSSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
void QgsWCSSourceSelect::populateLayerList()
|
||||
{
|
||||
|
@ -56,8 +56,25 @@ class QgsWCSSourceSelect : public QgsOWSSourceSelect
|
||||
//! Constructor
|
||||
QgsWCSSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
private:
|
||||
QgsWcsCapabilities mCapabilities;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
|
||||
QString selectedIdentifier();
|
||||
void populateExtent();
|
||||
|
@ -130,6 +130,16 @@ QgsWFSSourceSelect::~QgsWFSSourceSelect()
|
||||
delete mBuildQueryButton;
|
||||
}
|
||||
|
||||
void QgsWFSSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsWFSSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
void QgsWFSSourceSelect::reset()
|
||||
{
|
||||
treeView->clearSelection();
|
||||
|
@ -54,6 +54,22 @@ class QgsWFSSourceSelect: public QgsAbstractDataSourceWidget, private Ui::QgsWFS
|
||||
QgsWFSSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
|
||||
~QgsWFSSourceSelect() override;
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
void reset() override;
|
||||
|
||||
private:
|
||||
@ -90,6 +106,8 @@ class QgsWFSSourceSelect: public QgsAbstractDataSourceWidget, private Ui::QgsWFS
|
||||
*/
|
||||
QString getPreferredCrs( const QSet<QString> &crsSet ) const;
|
||||
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
|
||||
void showHelp();
|
||||
|
||||
public slots:
|
||||
|
@ -154,6 +154,15 @@ QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs
|
||||
|
||||
}
|
||||
|
||||
void QgsWMSSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsWMSSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
void QgsWMSSourceSelect::refresh()
|
||||
{
|
||||
|
@ -60,6 +60,22 @@ class QgsWMSSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsWM
|
||||
|
||||
void reset() override;
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
private slots:
|
||||
|
||||
//! Opens the create connection dialog to build a new connection
|
||||
@ -191,6 +207,7 @@ class QgsWMSSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsWM
|
||||
QMap<QTreeWidgetItem *, bool> mTreeInitialExpand = QMap<QTreeWidgetItem *, bool>();
|
||||
|
||||
QgsWmsInterpretationComboBox *mInterpretationCombo = nullptr;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
|
||||
private slots:
|
||||
void lstTilesets_itemClicked( QTableWidgetItem *item );
|
||||
|
@ -47,6 +47,16 @@ QgsXyzSourceSelect::QgsXyzSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs
|
||||
populateConnectionList();
|
||||
}
|
||||
|
||||
void QgsXyzSourceSelect::setMapCanvas(QgsMapCanvas *mapCanvas)
|
||||
{
|
||||
mMapCanvas = mapCanvas;
|
||||
}
|
||||
|
||||
QgsMapCanvas *QgsXyzSourceSelect::mapCanvas()
|
||||
{
|
||||
return mMapCanvas;
|
||||
}
|
||||
|
||||
void QgsXyzSourceSelect::btnNew_clicked()
|
||||
{
|
||||
QgsXyzConnectionDialog nc( this );
|
||||
|
@ -41,6 +41,22 @@ class QgsXyzSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsTi
|
||||
//! Determines the layers the user selected
|
||||
void addButtonClicked() override;
|
||||
|
||||
/**
|
||||
* Sets the dialog map canvas
|
||||
* \see mapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
void setMapCanvas( QgsMapCanvas *mapCanvas ) override;
|
||||
|
||||
/**
|
||||
* Returns the dialog map canvas
|
||||
* \see setMapCanvas()
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
QgsMapCanvas *mapCanvas() override;
|
||||
|
||||
private slots:
|
||||
|
||||
//! Opens the create connection dialog to build a new connection
|
||||
@ -60,6 +76,7 @@ class QgsXyzSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsTi
|
||||
void populateConnectionList();
|
||||
void setConnectionListPosition();
|
||||
void showHelp();
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
};
|
||||
|
||||
#endif // QGSXYZSOURCESELECT_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user