Skip to content

Commit 003bf3a

Browse files
committed
QgsGeoNodeSourceSelect is a QgsAbstractDataSourceWidget
1 parent 92a2499 commit 003bf3a

5 files changed

+32
-38
lines changed

python/gui/geonode/qgsgeonodesourceselect.sip

+8-7
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,24 @@ class QgsGeonodeItemDelegate : QItemDelegate
2929
explicit QgsGeonodeItemDelegate( QObject *parent = 0 );
3030
};
3131

32-
class QgsGeoNodeSourceSelect: QDialog
32+
class QgsGeoNodeSourceSelect: QgsAbstractDataSourceWidget
3333
{
3434

3535
%TypeHeaderCode
3636
#include "qgsgeonodesourceselect.h"
3737
%End
3838
public:
3939

40-
QgsGeoNodeSourceSelect( QWidget *parent, Qt::WindowFlags fl, bool embeddedMode = false );
40+
QgsGeoNodeSourceSelect( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
41+
4142
~QgsGeoNodeSourceSelect();
4243

44+
public slots:
45+
46+
virtual void addButtonClicked();
47+
48+
4349
signals:
44-
void connectionsChanged();
45-
void addRasterLayer( const QString &rasterLayerPath,
46-
const QString &baseName,
47-
const QString &providerKey );
48-
void addRasterLayer();
4950

5051
void addWfsLayer(
5152
const QString &uri,

src/app/qgisapp.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -4443,13 +4443,13 @@ void QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )
44434443

44444444
void QgisApp::addGeonodeLayer()
44454445
{
4446-
QgsGeoNodeSourceSelect *geonodes = new QgsGeoNodeSourceSelect( this, 0, true );
4446+
QgsGeoNodeSourceSelect *geonodes = new QgsGeoNodeSourceSelect( this, 0, QgsProviderRegistry::WidgetMode::None );
44474447
if ( !geonodes )
44484448
{
44494449
QMessageBox::warning( this, tr( "Geonode" ), tr( "Cannot get Geonode select dialog." ) );
44504450
return;
44514451
}
4452-
connect( geonodes, static_cast<void ( QgsGeoNodeSourceSelect::* )()>( &QgsGeoNodeSourceSelect::addRasterLayer ), this, static_cast<void ( QgisApp::* )()>( &QgisApp::addRasterLayer ) );
4452+
//connect( geonodes, static_cast<void ( QgsGeoNodeSourceSelect::* )()>( &QgsGeoNodeSourceSelect::addRasterLayer ), this, static_cast<void ( QgisApp::* )()>( &QgisApp::addRasterLayer ) );
44534453
connect( geonodes, &QgsGeoNodeSourceSelect::addWfsLayer, this, &QgisApp::addVectorLayer );
44544454
geonodes->exec();
44554455
delete geonodes;

src/gui/geonode/qgsgeonodesourceselect.cpp

+12-18
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,15 @@ enum
3939
MODEL_IDX_WEB_SERVICE
4040
};
4141

42-
QgsGeoNodeSourceSelect::QgsGeoNodeSourceSelect( QWidget *parent, Qt::WindowFlags fl, bool embeddedMode )
43-
: QDialog( parent, fl )
42+
QgsGeoNodeSourceSelect::QgsGeoNodeSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
43+
: QgsAbstractDataSourceWidget( parent, fl, widgetMode )
4444
{
4545
setupUi( this );
46-
47-
if ( embeddedMode != QgsProviderRegistry::WidgetMode::None )
48-
{
49-
// For some obscure reasons hiding does not work!
50-
// buttonBox->button( QDialogButtonBox::Close )->hide();
51-
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Close ) );
52-
}
53-
54-
mAddButton = new QPushButton( tr( "&Add" ) );
55-
mAddButton->setEnabled( false );
56-
57-
buttonBox->addButton( mAddButton, QDialogButtonBox::ActionRole );
46+
setupButtons( buttonBox );
47+
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsGeoNodeSourceSelect::showHelp );
5848

5949
populateConnectionList();
6050

61-
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsGeoNodeSourceSelect::reject );
6251
connect( btnNew, &QPushButton::clicked, this, &QgsGeoNodeSourceSelect::addConnectionsEntryList );
6352
connect( btnEdit, &QPushButton::clicked, this, &QgsGeoNodeSourceSelect::modifyConnectionsEntryList );
6453
connect( btnDelete, &QPushButton::clicked, this, &QgsGeoNodeSourceSelect::deleteConnectionsEntryList );
@@ -67,7 +56,6 @@ QgsGeoNodeSourceSelect::QgsGeoNodeSourceSelect( QWidget *parent, Qt::WindowFlags
6756
connect( btnLoad, &QPushButton::clicked, this, &QgsGeoNodeSourceSelect::loadGeonodeConnection );
6857
connect( lineFilter, &QLineEdit::textChanged, this, &QgsGeoNodeSourceSelect::filterChanged );
6958
connect( treeView, &QTreeView::clicked, this, &QgsGeoNodeSourceSelect::treeViewSelectionChanged );
70-
connect( mAddButton, &QPushButton::clicked, this, &QgsGeoNodeSourceSelect::addButtonClicked );
7159

7260
mItemDelegate = new QgsGeonodeItemDelegate( treeView );
7361
treeView->setItemDelegate( mItemDelegate );
@@ -185,6 +173,12 @@ void QgsGeoNodeSourceSelect::setConnectionListPosition()
185173
}
186174
}
187175

176+
void QgsGeoNodeSourceSelect::showHelp()
177+
{
178+
//TODO - correct URL
179+
//QgsHelp::openHelp( QStringLiteral( "managing_data_source/opening_data.html#spatialite-layers" ) );
180+
}
181+
188182
void QgsGeoNodeSourceSelect::connectToGeonodeConnection()
189183
{
190184
QApplication::setOverrideCursor( Qt::BusyCursor );
@@ -366,7 +360,7 @@ void QgsGeoNodeSourceSelect::treeViewSelectionChanged()
366360
qDebug() << "Current index is invalid";
367361
return;
368362
}
369-
mAddButton->setEnabled( false );
363+
addButton()->setEnabled( false );
370364
QModelIndexList modelIndexList = treeView->selectionModel()->selectedRows();
371365
for ( int i = 0; i < modelIndexList.size(); i++ )
372366
{
@@ -380,7 +374,7 @@ void QgsGeoNodeSourceSelect::treeViewSelectionChanged()
380374
if ( typeItem == tr( "Layer" ) )
381375
{
382376
// Enable if there is a layer selected
383-
mAddButton->setEnabled( true );
377+
addButton()->setEnabled( true );
384378
return;
385379
}
386380
}

src/gui/geonode/qgsgeonodesourceselect.h

+9-10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <QItemDelegate>
2222
#include <QStandardItemModel>
2323
#include <QSortFilterProxyModel>
24+
#include "qgsabstractdatasourcewidget.h"
2425
#include "ui_qgsgeonodesourceselectbase.h"
2526
#include "qgis_gui.h"
2627

@@ -32,21 +33,21 @@ class GUI_EXPORT QgsGeonodeItemDelegate : public QItemDelegate
3233
explicit QgsGeonodeItemDelegate( QObject *parent = nullptr ) : QItemDelegate( parent ) { }
3334
};
3435

35-
class GUI_EXPORT QgsGeoNodeSourceSelect: public QDialog, private Ui::QgsGeonodeSourceSelectBase
36+
class GUI_EXPORT QgsGeoNodeSourceSelect: public QgsAbstractDataSourceWidget, private Ui::QgsGeonodeSourceSelectBase
3637
{
3738
Q_OBJECT
3839

3940
public:
4041

41-
QgsGeoNodeSourceSelect( QWidget *parent, Qt::WindowFlags fl, bool embeddedMode = false );
42+
QgsGeoNodeSourceSelect( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
43+
4244
~QgsGeoNodeSourceSelect();
4345

46+
public slots:
47+
48+
void addButtonClicked() override;
49+
4450
signals:
45-
void connectionsChanged();
46-
void addRasterLayer( const QString &rasterLayerPath,
47-
const QString &baseName,
48-
const QString &providerKey );
49-
void addRasterLayer();
5051

5152
void addWfsLayer(
5253
const QString &uri,
@@ -65,7 +66,6 @@ class GUI_EXPORT QgsGeoNodeSourceSelect: public QDialog, private Ui::QgsGeonodeS
6566
QStandardItemModel *mModel = nullptr;
6667
QSortFilterProxyModel *mModelProxy = nullptr;
6768
QPushButton *mBuildQueryButton = nullptr;
68-
QPushButton *mAddButton = nullptr;
6969
QModelIndex mSQLIndex;
7070

7171
private slots:
@@ -77,10 +77,9 @@ class GUI_EXPORT QgsGeoNodeSourceSelect: public QDialog, private Ui::QgsGeonodeS
7777
void loadGeonodeConnection();
7878
void filterChanged( const QString &text );
7979
void treeViewSelectionChanged();
80-
void addButtonClicked();
81-
8280
void populateConnectionList();
8381
void setConnectionListPosition();
82+
void showHelp();
8483

8584
};
8685

src/gui/qgsdatasourcemanagerdialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsBrowserModel *browser
7474

7575

7676
QDialog *geonodeDialog = new QgsGeoNodeSourceSelect( this, Qt::Widget, QgsProviderRegistry::WidgetMode::Embedded );
77-
dlg = addDialog( geonodeDialog, QStringLiteral( "geonode" ), tr( "GeoNode" ), QStringLiteral( "/mActionAddGeonodeLayer.svg" ) );
77+
QDialog *dlg = addDialog( geonodeDialog, QStringLiteral( "geonode" ), tr( "GeoNode" ), QStringLiteral( "/mActionAddGeonodeLayer.svg" ) );
7878

7979
if ( dlg )
8080
{

0 commit comments

Comments
 (0)