Skip to content
Permalink
Browse files

QgsGeoNodeSourceSelect is a QgsAbstractDataSourceWidget

  • Loading branch information
nyalldawson committed Sep 5, 2017
1 parent 92a2499 commit 003bf3a76f2d53762fff9c416fd49e3847139eb0
@@ -29,23 +29,24 @@ class QgsGeonodeItemDelegate : QItemDelegate
explicit QgsGeonodeItemDelegate( QObject *parent = 0 );
};

class QgsGeoNodeSourceSelect: QDialog
class QgsGeoNodeSourceSelect: QgsAbstractDataSourceWidget
{

%TypeHeaderCode
#include "qgsgeonodesourceselect.h"
%End
public:

QgsGeoNodeSourceSelect( QWidget *parent, Qt::WindowFlags fl, bool embeddedMode = false );
QgsGeoNodeSourceSelect( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );

~QgsGeoNodeSourceSelect();

public slots:

virtual void addButtonClicked();


signals:
void connectionsChanged();
void addRasterLayer( const QString &rasterLayerPath,
const QString &baseName,
const QString &providerKey );
void addRasterLayer();

void addWfsLayer(
const QString &uri,
@@ -4443,13 +4443,13 @@ void QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )

void QgisApp::addGeonodeLayer()
{
QgsGeoNodeSourceSelect *geonodes = new QgsGeoNodeSourceSelect( this, 0, true );
QgsGeoNodeSourceSelect *geonodes = new QgsGeoNodeSourceSelect( this, 0, QgsProviderRegistry::WidgetMode::None );
if ( !geonodes )
{
QMessageBox::warning( this, tr( "Geonode" ), tr( "Cannot get Geonode select dialog." ) );
return;
}
connect( geonodes, static_cast<void ( QgsGeoNodeSourceSelect::* )()>( &QgsGeoNodeSourceSelect::addRasterLayer ), this, static_cast<void ( QgisApp::* )()>( &QgisApp::addRasterLayer ) );
//connect( geonodes, static_cast<void ( QgsGeoNodeSourceSelect::* )()>( &QgsGeoNodeSourceSelect::addRasterLayer ), this, static_cast<void ( QgisApp::* )()>( &QgisApp::addRasterLayer ) );
connect( geonodes, &QgsGeoNodeSourceSelect::addWfsLayer, this, &QgisApp::addVectorLayer );
geonodes->exec();
delete geonodes;
@@ -39,26 +39,15 @@ enum
MODEL_IDX_WEB_SERVICE
};

QgsGeoNodeSourceSelect::QgsGeoNodeSourceSelect( QWidget *parent, Qt::WindowFlags fl, bool embeddedMode )
: QDialog( parent, fl )
QgsGeoNodeSourceSelect::QgsGeoNodeSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
: QgsAbstractDataSourceWidget( parent, fl, widgetMode )
{
setupUi( this );

if ( embeddedMode != QgsProviderRegistry::WidgetMode::None )
{
// For some obscure reasons hiding does not work!
// buttonBox->button( QDialogButtonBox::Close )->hide();
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Close ) );
}

mAddButton = new QPushButton( tr( "&Add" ) );
mAddButton->setEnabled( false );

buttonBox->addButton( mAddButton, QDialogButtonBox::ActionRole );
setupButtons( buttonBox );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsGeoNodeSourceSelect::showHelp );

populateConnectionList();

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

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

void QgsGeoNodeSourceSelect::showHelp()
{
//TODO - correct URL
//QgsHelp::openHelp( QStringLiteral( "managing_data_source/opening_data.html#spatialite-layers" ) );
}

void QgsGeoNodeSourceSelect::connectToGeonodeConnection()
{
QApplication::setOverrideCursor( Qt::BusyCursor );
@@ -366,7 +360,7 @@ void QgsGeoNodeSourceSelect::treeViewSelectionChanged()
qDebug() << "Current index is invalid";
return;
}
mAddButton->setEnabled( false );
addButton()->setEnabled( false );
QModelIndexList modelIndexList = treeView->selectionModel()->selectedRows();
for ( int i = 0; i < modelIndexList.size(); i++ )
{
@@ -380,7 +374,7 @@ void QgsGeoNodeSourceSelect::treeViewSelectionChanged()
if ( typeItem == tr( "Layer" ) )
{
// Enable if there is a layer selected
mAddButton->setEnabled( true );
addButton()->setEnabled( true );
return;
}
}
@@ -21,6 +21,7 @@
#include <QItemDelegate>
#include <QStandardItemModel>
#include <QSortFilterProxyModel>
#include "qgsabstractdatasourcewidget.h"
#include "ui_qgsgeonodesourceselectbase.h"
#include "qgis_gui.h"

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

class GUI_EXPORT QgsGeoNodeSourceSelect: public QDialog, private Ui::QgsGeonodeSourceSelectBase
class GUI_EXPORT QgsGeoNodeSourceSelect: public QgsAbstractDataSourceWidget, private Ui::QgsGeonodeSourceSelectBase
{
Q_OBJECT

public:

QgsGeoNodeSourceSelect( QWidget *parent, Qt::WindowFlags fl, bool embeddedMode = false );
QgsGeoNodeSourceSelect( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );

~QgsGeoNodeSourceSelect();

public slots:

void addButtonClicked() override;

signals:
void connectionsChanged();
void addRasterLayer( const QString &rasterLayerPath,
const QString &baseName,
const QString &providerKey );
void addRasterLayer();

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

private slots:
@@ -77,10 +77,9 @@ class GUI_EXPORT QgsGeoNodeSourceSelect: public QDialog, private Ui::QgsGeonodeS
void loadGeonodeConnection();
void filterChanged( const QString &text );
void treeViewSelectionChanged();
void addButtonClicked();

void populateConnectionList();
void setConnectionListPosition();
void showHelp();

};

@@ -74,7 +74,7 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsBrowserModel *browser


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

if ( dlg )
{

0 comments on commit 003bf3a

Please sign in to comment.
You can’t perform that action at this time.