Skip to content
Permalink
Browse files
Remove method and fix widget hiding
  • Loading branch information
elpaso committed Jul 6, 2021
1 parent 27eb574 commit dfc56482041ce0a3a075535a07ddfb1a7c97cd69
@@ -49,15 +49,6 @@ Sets the connection to ``connection``, ownership is transferred to the widget.
Convenience method to set the SQL editor text to ``sql``.
%End

void setSqlVectorLayerOptions( const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions &options );
%Docstring
Sets the SQL layer ``options``. This method automatically populates and shows the "Load as new layer" panel.
%End

QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions sqlVectorLayerOptions() const;
%Docstring
Returns the sqlVectorLayerOptions
%End

public slots:

@@ -31,8 +31,6 @@ QgsQueryResultWidget::QgsQueryResultWidget( QWidget *parent, QgsAbstractDatabase
// Unsure :/
// mSqlEditor->setLineNumbersVisible( true );

mSqlEditor->

connect( mExecuteButton, &QPushButton::pressed, this, &QgsQueryResultWidget::executeQuery );
connect( mClearButton, &QPushButton::pressed, this, [ = ]
{
@@ -70,6 +68,27 @@ QgsQueryResultWidget::QgsQueryResultWidget( QWidget *parent, QgsAbstractDatabase
mSqlErrorText->hide();

mLoadAsNewLayerGroupBox->setCollapsed( true );

connect( mLoadAsNewLayerGroupBox, &QgsCollapsibleGroupBox::collapsedStateChanged, this, [ = ]( bool collapsed )
{
if ( ! collapsed )
{
// Configure the load layer interface
const bool showPkConfig { connection &&connection->sqlLayerDefinitionCapabilities().testFlag( QgsAbstractDatabaseProviderConnection::SqlLayerDefinitionCapability::PrimaryKeys )};
mPkColumnsCheckBox->setVisible( showPkConfig );
mPkColumnsComboBox->setVisible( showPkConfig );

const bool showGeometryColumnConfig {connection &&connection->sqlLayerDefinitionCapabilities().testFlag( QgsAbstractDatabaseProviderConnection::SqlLayerDefinitionCapability::GeometryColumn )};
mGeometryColumnCheckBox->setVisible( showGeometryColumnConfig );
mGeometryColumnComboBox->setVisible( showGeometryColumnConfig );

const bool showFilterConfig { connection &&connection->sqlLayerDefinitionCapabilities().testFlag( QgsAbstractDatabaseProviderConnection::SqlLayerDefinitionCapability::Filters ) };
mFilterLabel->setVisible( showFilterConfig );
mFilterToolButton->setVisible( showFilterConfig );
mFilterLineEdit->setVisible( showFilterConfig );
}
} );

setConnection( connection );
}

@@ -305,26 +324,6 @@ void QgsQueryResultWidget::setConnection( QgsAbstractDatabaseProviderConnection
if ( connection )
{

// Configure the load layer interface
if ( ! connection->sqlLayerDefinitionCapabilities().testFlag( QgsAbstractDatabaseProviderConnection::SqlLayerDefinitionCapability::PrimaryKeys ) )
{
mPkColumnsCheckBox->hide();
mPkColumnsComboBox->hide();
}

if ( ! connection->sqlLayerDefinitionCapabilities().testFlag( QgsAbstractDatabaseProviderConnection::SqlLayerDefinitionCapability::GeometryColumn ) )
{
mGeometryColumnCheckBox->hide();
mGeometryColumnComboBox->hide();
}

if ( ! connection->sqlLayerDefinitionCapabilities().testFlag( QgsAbstractDatabaseProviderConnection::SqlLayerDefinitionCapability::Filters ) )
{
mFilterLabel->hide();
mFilterToolButton->hide();
mFilterLineEdit->hide();
}

// Add provider specific APIs
const auto keywordsDict { connection->sqlDictionary() };
QStringList keywords;
@@ -359,11 +358,6 @@ void QgsQueryResultWidget::setQuery( const QString &sql )
mSqlEditor->setText( sql );
}

void QgsQueryResultWidget::setSqlVectorLayerOptions( const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions &options )
{
mSqlVectorLayerOptions = options;
// TODO: check items
}

///@cond private

@@ -104,15 +104,6 @@ class GUI_EXPORT QgsQueryResultWidget: public QWidget, private Ui::QgsQueryResul
*/
void setQuery( const QString &sql );

/**
* Sets the SQL layer \a options. This method automatically populates and shows the "Load as new layer" panel.
*/
void setSqlVectorLayerOptions( const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions &options );

/**
* Returns the sqlVectorLayerOptions
*/
QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions sqlVectorLayerOptions() const;

public slots:

@@ -187,6 +178,12 @@ class GUI_EXPORT QgsQueryResultWidget: public QWidget, private Ui::QgsQueryResul
*/
void startFetching();

/**
* Returns the sqlVectorLayerOptions
*/
QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions sqlVectorLayerOptions() const;


friend class TestQgsQueryResultWidget;

};

0 comments on commit dfc5648

Please sign in to comment.