Skip to content

Commit

Permalink
regroup onTreeView_doubleClicked
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Nov 11, 2021
1 parent 67bcb31 commit 9843038
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 34 deletions.
Expand Up @@ -40,6 +40,7 @@ Returns the proxy model used to filter the results

protected slots:
virtual void treeviewClicked( const QModelIndex &index );
virtual void treeviewDoubleClicked( const QModelIndex &index );
virtual void setSql( const QModelIndex &index ) = 0;
void buildQuery();

Expand Down
3 changes: 1 addition & 2 deletions src/gui/providers/ogr/qgsogrdbsourceselect.cpp
Expand Up @@ -46,7 +46,6 @@ QgsOgrDbSourceSelect::QgsOgrDbSourceSelect( const QString &theSettingsKey, const
connect( btnDelete, &QPushButton::clicked, this, &QgsOgrDbSourceSelect::btnDelete_clicked );
connect( cbxAllowGeometrylessTables, &QCheckBox::stateChanged, this, &QgsOgrDbSourceSelect::cbxAllowGeometrylessTables_stateChanged );
connect( cmbConnections, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsOgrDbSourceSelect::cmbConnections_activated );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsOgrDbSourceSelect::mTablesTreeView_doubleClicked );
setupButtons( buttonBox );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsOgrDbSourceSelect::showHelp );

Expand Down Expand Up @@ -97,7 +96,7 @@ void QgsOgrDbSourceSelect::treeviewClicked( const QModelIndex &index )
mBuildQueryButton->setEnabled( index.parent().isValid() && mTablesTreeView->currentIndex().data( Qt::UserRole + 2 ) != QLatin1String( "Raster" ) );
}

void QgsOgrDbSourceSelect::mTablesTreeView_doubleClicked( const QModelIndex &index )
void QgsOgrDbSourceSelect::treeviewDoubleClicked( const QModelIndex &index )
{
setSql( index );
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/providers/ogr/qgsogrdbsourceselect.h
Expand Up @@ -88,7 +88,6 @@ class QgsOgrDbSourceSelect: public QgsDbSourceSelectBase
void btnDelete_clicked();
void cbxAllowGeometrylessTables_stateChanged( int );
void cmbConnections_activated( int );
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 &regexp );
Expand All @@ -98,6 +97,7 @@ class QgsOgrDbSourceSelect: public QgsDbSourceSelectBase
protected slots:
void treeviewClicked( const QModelIndex &index ) override;
void setSql( const QModelIndex &index ) override;
void treeviewDoubleClicked( const QModelIndex &index ) override;

private:
void setConnectionListPosition();
Expand Down
10 changes: 10 additions & 0 deletions src/gui/providers/qgsdbsourceselectbase.cpp
Expand Up @@ -44,6 +44,10 @@ QgsDbSourceSelectBase::QgsDbSourceSelectBase( QWidget *parent, Qt::WindowFlags f
mBuildQueryButton->setToolTip( tr( "Set Filter" ) );
mBuildQueryButton->setDisabled( true );
buttonBox->addButton( mBuildQueryButton, QDialogButtonBox::ActionRole );

connect( mTablesTreeView, &QTreeView::clicked, this, &QgsDbSourceSelectBase::treeviewClicked );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsDbSourceSelectBase::treeviewDoubleClicked );

connect( mBuildQueryButton, &QAbstractButton::clicked, this, &QgsDbSourceSelectBase::buildQuery );
}

Expand Down Expand Up @@ -108,6 +112,12 @@ void QgsDbSourceSelectBase::treeviewClicked( const QModelIndex &index )
mBuildQueryButton->setEnabled( index.parent().isValid() );
}

void QgsDbSourceSelectBase::treeviewDoubleClicked( const QModelIndex &index )
{
Q_UNUSED( index )
addButtonClicked();
}

void QgsDbSourceSelectBase::buildQuery()
{
setSql( mTablesTreeView->currentIndex() );
Expand Down
1 change: 1 addition & 0 deletions src/gui/providers/qgsdbsourceselectbase.h
Expand Up @@ -46,6 +46,7 @@ class GUI_EXPORT QgsDbSourceSelectBase : public QgsAbstractDataSourceWidget, pro

protected slots:
virtual void treeviewClicked( const QModelIndex &index );
virtual void treeviewDoubleClicked( const QModelIndex &index );
virtual void setSql( const QModelIndex &index ) = 0;
void buildQuery();

Expand Down
6 changes: 0 additions & 6 deletions src/providers/db2/qgsdb2sourceselect.cpp
Expand Up @@ -135,7 +135,6 @@ QgsDb2SourceSelect::QgsDb2SourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs
connect( btnSave, &QPushButton::clicked, this, &QgsDb2SourceSelect::btnSave_clicked );
connect( btnLoad, &QPushButton::clicked, this, &QgsDb2SourceSelect::btnLoad_clicked );
connect( cmbConnections, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsDb2SourceSelect::cmbConnections_activated );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsDb2SourceSelect::mTablesTreeView_doubleClicked );
setupButtons( buttonBox );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDb2SourceSelect::showHelp );

Expand Down Expand Up @@ -259,11 +258,6 @@ void QgsDb2SourceSelect::refresh()
populateConnectionList();
}

void QgsDb2SourceSelect::mTablesTreeView_doubleClicked( const QModelIndex & )
{
addButtonClicked();
}

void QgsDb2SourceSelect::setLayerType( const QgsDb2LayerProperty &layerProperty )
{
mTableModel->setGeometryTypesForTable( layerProperty );
Expand Down
3 changes: 1 addition & 2 deletions src/providers/hana/qgshanasourceselect.cpp
Expand Up @@ -213,7 +213,6 @@ QgsHanaSourceSelect::QgsHanaSourceSelect(
connect( btnLoad, &QPushButton::clicked, this, &QgsHanaSourceSelect::btnLoad_clicked );
connect( cmbConnections, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ),
this, &QgsHanaSourceSelect::cmbConnections_activated );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsHanaSourceSelect::mTablesTreeView_doubleClicked );
setupButtons( buttonBox );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsHanaSourceSelect::showHelp );

Expand Down Expand Up @@ -328,7 +327,7 @@ void QgsHanaSourceSelect::cbxAllowGeometrylessTables_stateChanged( int )
btnConnect_clicked();
}

void QgsHanaSourceSelect::mTablesTreeView_doubleClicked( const QModelIndex &index )
void QgsHanaSourceSelect::treeviewDoubleClicked( const QModelIndex &index )
{
const QgsSettings settings;
if ( settings.value( QStringLiteral( "qgis/addHANADC" ), false ).toBool() )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/hana/qgshanasourceselect.h
Expand Up @@ -113,7 +113,6 @@ class QgsHanaSourceSelect : public QgsDbSourceSelectBase
//! Store the selected database
void cmbConnections_activated( int );
void setLayerType( const QgsHanaLayerProperty &layerProperty );
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 &regexp );
Expand All @@ -122,6 +121,7 @@ class QgsHanaSourceSelect : public QgsDbSourceSelectBase

protected slots:
void setSql( const QModelIndex &index ) override;
void treeviewDoubleClicked( const QModelIndex &index ) override;

private:
// Set the position of the database connection list to the last
Expand Down
6 changes: 0 additions & 6 deletions src/providers/mssql/qgsmssqlsourceselect.cpp
Expand Up @@ -137,7 +137,6 @@ QgsMssqlSourceSelect::QgsMssqlSourceSelect( QWidget *parent, Qt::WindowFlags fl,
connect( btnSave, &QPushButton::clicked, this, &QgsMssqlSourceSelect::btnSave_clicked );
connect( btnLoad, &QPushButton::clicked, this, &QgsMssqlSourceSelect::btnLoad_clicked );
connect( cmbConnections, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsMssqlSourceSelect::cmbConnections_activated );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsMssqlSourceSelect::mTablesTreeView_doubleClicked );
setupButtons( buttonBox );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsMssqlSourceSelect::showHelp );

Expand Down Expand Up @@ -256,11 +255,6 @@ void QgsMssqlSourceSelect::cbxAllowGeometrylessTables_stateChanged( int )
btnConnect_clicked();
}

void QgsMssqlSourceSelect::mTablesTreeView_doubleClicked( const QModelIndex & )
{
addButtonClicked();
}

void QgsMssqlSourceSelect::setLayerType( const QgsMssqlLayerProperty &layerProperty )
{
mTableModel->setGeometryTypesForTable( layerProperty );
Expand Down
1 change: 0 additions & 1 deletion src/providers/mssql/qgsmssqlsourceselect.h
Expand Up @@ -109,7 +109,6 @@ class QgsMssqlSourceSelect : public QgsDbSourceSelectBase
//! Store the selected database
void cmbConnections_activated( int );
void setLayerType( const QgsMssqlLayerProperty &layerProperty );
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 &regexp );
Expand Down
5 changes: 0 additions & 5 deletions src/providers/oracle/qgsoraclesourceselect.cpp
Expand Up @@ -298,11 +298,6 @@ void QgsOracleSourceSelect::on_cbxAllowGeometrylessTables_stateChanged( int )
on_btnConnect_clicked();
}

void QgsOracleSourceSelect::on_mTablesTreeView_doubleClicked( const QModelIndex & )
{
addButtonClicked();
}

void QgsOracleSourceSelect::setLayerType( const QgsOracleLayerProperty &layerProperty )
{
mTableModel->addTableEntry( layerProperty );
Expand Down
1 change: 0 additions & 1 deletion src/providers/oracle/qgsoraclesourceselect.h
Expand Up @@ -116,7 +116,6 @@ class QgsOracleSourceSelect : public QgsDbSourceSelectBase
void on_cmbConnections_currentIndexChanged( const QString &text );
//! Store the selected database
void setLayerType( const QgsOracleLayerProperty &layerProperty );
void on_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 &regexp );
Expand Down
6 changes: 0 additions & 6 deletions src/providers/postgres/qgspgsourceselect.cpp
Expand Up @@ -227,7 +227,6 @@ QgsPgSourceSelect::QgsPgSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsPr
connect( btnSave, &QPushButton::clicked, this, &QgsPgSourceSelect::btnSave_clicked );
connect( btnLoad, &QPushButton::clicked, this, &QgsPgSourceSelect::btnLoad_clicked );
connect( cmbConnections, &QComboBox::currentTextChanged, this, &QgsPgSourceSelect::cmbConnections_currentIndexChanged );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsPgSourceSelect::mTablesTreeView_doubleClicked );
setupButtons( buttonBox );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsPgSourceSelect::showHelp );

Expand Down Expand Up @@ -337,11 +336,6 @@ void QgsPgSourceSelect::cbxAllowGeometrylessTables_stateChanged( int )
btnConnect_clicked();
}

void QgsPgSourceSelect::mTablesTreeView_doubleClicked( const QModelIndex & )
{
addButtonClicked();
}

void QgsPgSourceSelect::setLayerType( const QgsPostgresLayerProperty &layerProperty )
{
mTableModel->addTableEntry( layerProperty );
Expand Down
1 change: 0 additions & 1 deletion src/providers/postgres/qgspgsourceselect.h
Expand Up @@ -106,7 +106,6 @@ class QgsPgSourceSelect : public QgsDbSourceSelectBase
void cmbConnections_currentIndexChanged( const QString &text );
//! Store the selected database
void setLayerType( const QgsPostgresLayerProperty &layerProperty );
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 &regexp );
Expand Down
3 changes: 1 addition & 2 deletions src/providers/spatialite/qgsspatialitesourceselect.cpp
Expand Up @@ -55,7 +55,6 @@ QgsSpatiaLiteSourceSelect::QgsSpatiaLiteSourceSelect( QWidget *parent, Qt::Windo
connect( btnDelete, &QPushButton::clicked, this, &QgsSpatiaLiteSourceSelect::btnDelete_clicked );
connect( cbxAllowGeometrylessTables, &QCheckBox::stateChanged, this, &QgsSpatiaLiteSourceSelect::cbxAllowGeometrylessTables_stateChanged );
connect( cmbConnections, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsSpatiaLiteSourceSelect::cmbConnections_activated );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsSpatiaLiteSourceSelect::mTablesTreeView_doubleClicked );
setupButtons( buttonBox );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsSpatiaLiteSourceSelect::showHelp );

Expand Down Expand Up @@ -136,7 +135,7 @@ void QgsSpatiaLiteSourceSelect::cbxAllowGeometrylessTables_stateChanged( int )
btnConnect_clicked();
}

void QgsSpatiaLiteSourceSelect::mTablesTreeView_doubleClicked( const QModelIndex &index )
void QgsSpatiaLiteSourceSelect::treeviewDoubleClicked( const QModelIndex &index )
{
setSql( index );
}
Expand Down
1 change: 1 addition & 0 deletions src/providers/spatialite/qgsspatialitesourceselect.h
Expand Up @@ -92,6 +92,7 @@ class QgsSpatiaLiteSourceSelect: public QgsDbSourceSelectBase

protected slots:
void setSql( const QModelIndex &index ) override;
void treeviewDoubleClicked( const QModelIndex &index ) override;

private:
enum Columns
Expand Down

0 comments on commit 9843038

Please sign in to comment.