Skip to content

Commit

Permalink
regroup onTreeView_clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Nov 11, 2021
1 parent de436c7 commit 0f39b82
Show file tree
Hide file tree
Showing 16 changed files with 14 additions and 44 deletions.
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::clicked, this, &QgsOgrDbSourceSelect::mTablesTreeView_clicked );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsOgrDbSourceSelect::mTablesTreeView_doubleClicked );
setupButtons( buttonBox );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsOgrDbSourceSelect::showHelp );
Expand Down Expand Up @@ -104,7 +103,7 @@ void QgsOgrDbSourceSelect::cbxAllowGeometrylessTables_stateChanged( int )
btnConnect_clicked();
}

void QgsOgrDbSourceSelect::mTablesTreeView_clicked( const QModelIndex &index )
void QgsOgrDbSourceSelect::treeviewClicked( const QModelIndex &index )
{
mBuildQueryButton->setEnabled( index.parent().isValid() && mTablesTreeView->currentIndex().data( Qt::UserRole + 2 ) != QLatin1String( "Raster" ) );
}
Expand Down
5 changes: 4 additions & 1 deletion src/gui/providers/ogr/qgsogrdbsourceselect.h
Expand Up @@ -90,14 +90,17 @@ class QgsOgrDbSourceSelect: public QgsDbSourceSelectBase
void cbxAllowGeometrylessTables_stateChanged( int );
void setSql( const QModelIndex &index );
void cmbConnections_activated( int );
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 &regexp );

void showHelp();

private slots:
void treeviewClicked( const QModelIndex &index ) override;


private:
void setConnectionListPosition();
//! Model that acts as datasource for mTableTreeWidget
Expand Down
6 changes: 6 additions & 0 deletions src/gui/providers/qgsdbsourceselectbase.cpp
Expand Up @@ -97,6 +97,12 @@ void QgsDbSourceSelectBase::init( QgsAbstractDbTableModel *model, QItemDelegate
connect( mSearchTableEdit, &QLineEdit::textChanged, this, [ = ]() {filterResults();} );
}

void QgsDbSourceSelectBase::treeviewClicked( const QModelIndex &index )
{
mBuildQueryButton->setEnabled( index.parent().isValid() );

}


void QgsDbSourceSelectBase::filterResults()
{
Expand Down
3 changes: 3 additions & 0 deletions src/gui/providers/qgsdbsourceselectbase.h
Expand Up @@ -44,6 +44,9 @@ class GUI_EXPORT QgsDbSourceSelectBase : public QgsAbstractDataSourceWidget, pro
//! Returns the proxy model used to filter the results
QSortFilterProxyModel *proxyModel() {return mProxyModel;}

private slots:
virtual void treeviewClicked( const QModelIndex &index );

private:
void filterResults();

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::clicked, this, &QgsDb2SourceSelect::mTablesTreeView_clicked );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsDb2SourceSelect::mTablesTreeView_doubleClicked );
setupButtons( buttonBox );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDb2SourceSelect::showHelp );
Expand Down Expand Up @@ -275,11 +274,6 @@ void QgsDb2SourceSelect::refresh()
populateConnectionList();
}

void QgsDb2SourceSelect::mTablesTreeView_clicked( const QModelIndex &index )
{
mBuildQueryButton->setEnabled( index.parent().isValid() );
}

void QgsDb2SourceSelect::mTablesTreeView_doubleClicked( const QModelIndex & )
{
addButtonClicked();
Expand Down
1 change: 0 additions & 1 deletion src/providers/db2/qgsdb2sourceselect.h
Expand Up @@ -138,7 +138,6 @@ class QgsDb2SourceSelect : public QgsDbSourceSelectBase
//! 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
Expand Down
6 changes: 0 additions & 6 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::clicked, this, &QgsHanaSourceSelect::mTablesTreeView_clicked );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsHanaSourceSelect::mTablesTreeView_doubleClicked );
setupButtons( buttonBox );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsHanaSourceSelect::showHelp );
Expand Down Expand Up @@ -344,11 +343,6 @@ void QgsHanaSourceSelect::buildQuery()
setSql( mTablesTreeView->currentIndex() );
}

void QgsHanaSourceSelect::mTablesTreeView_clicked( const QModelIndex &index )
{
mBuildQueryButton->setEnabled( index.parent().isValid() );
}

void QgsHanaSourceSelect::mTablesTreeView_doubleClicked( const QModelIndex &index )
{
const QgsSettings settings;
Expand Down
1 change: 0 additions & 1 deletion src/providers/hana/qgshanasourceselect.h
Expand Up @@ -116,7 +116,6 @@ class QgsHanaSourceSelect : public QgsDbSourceSelectBase
//! Store the selected database
void cmbConnections_activated( int );
void setLayerType( const QgsHanaLayerProperty &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
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::clicked, this, &QgsMssqlSourceSelect::mTablesTreeView_clicked );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsMssqlSourceSelect::mTablesTreeView_doubleClicked );
setupButtons( buttonBox );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsMssqlSourceSelect::showHelp );
Expand Down Expand Up @@ -273,11 +272,6 @@ void QgsMssqlSourceSelect::buildQuery()
setSql( mTablesTreeView->currentIndex() );
}

void QgsMssqlSourceSelect::mTablesTreeView_clicked( const QModelIndex &index )
{
mBuildQueryButton->setEnabled( index.parent().isValid() );
}

void QgsMssqlSourceSelect::mTablesTreeView_doubleClicked( const QModelIndex & )
{
addButtonClicked();
Expand Down
1 change: 0 additions & 1 deletion src/providers/mssql/qgsmssqlsourceselect.h
Expand Up @@ -111,7 +111,6 @@ class QgsMssqlSourceSelect : public QgsDbSourceSelectBase
//! Store the selected database
void cmbConnections_activated( int );
void setLayerType( const QgsMssqlLayerProperty &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
Expand Down
5 changes: 0 additions & 5 deletions src/providers/oracle/qgsoraclesourceselect.cpp
Expand Up @@ -313,11 +313,6 @@ void QgsOracleSourceSelect::buildQuery()
setSql( mTablesTreeView->currentIndex() );
}

void QgsOracleSourceSelect::on_mTablesTreeView_clicked( const QModelIndex &index )
{
mBuildQueryButton->setEnabled( index.parent().isValid() );
}

void QgsOracleSourceSelect::on_mTablesTreeView_doubleClicked( const QModelIndex & )
{
addButtonClicked();
Expand Down
1 change: 0 additions & 1 deletion src/providers/oracle/qgsoraclesourceselect.h
Expand Up @@ -118,7 +118,6 @@ class QgsOracleSourceSelect : public QgsDbSourceSelectBase
void setSql( const QModelIndex &index );
//! Store the selected database
void setLayerType( const QgsOracleLayerProperty &layerProperty );
void on_mTablesTreeView_clicked( const QModelIndex &index );
void on_mTablesTreeView_doubleClicked( const QModelIndex &index );
void treeWidgetSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
//!Sets a new regular expression to the model
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::clicked, this, &QgsPgSourceSelect::mTablesTreeView_clicked );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsPgSourceSelect::mTablesTreeView_doubleClicked );
setupButtons( buttonBox );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsPgSourceSelect::showHelp );
Expand Down Expand Up @@ -353,11 +352,6 @@ void QgsPgSourceSelect::buildQuery()
setSql( mTablesTreeView->currentIndex() );
}

void QgsPgSourceSelect::mTablesTreeView_clicked( const QModelIndex &index )
{
mBuildQueryButton->setEnabled( index.parent().isValid() );
}

void QgsPgSourceSelect::mTablesTreeView_doubleClicked( const QModelIndex & )
{
addButtonClicked();
Expand Down
1 change: 0 additions & 1 deletion src/providers/postgres/qgspgsourceselect.h
Expand Up @@ -108,7 +108,6 @@ class QgsPgSourceSelect : public QgsDbSourceSelectBase
void setSql( const QModelIndex &index );
//! Store the selected database
void setLayerType( const QgsPostgresLayerProperty &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
Expand Down
6 changes: 0 additions & 6 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::clicked, this, &QgsSpatiaLiteSourceSelect::mTablesTreeView_clicked );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, &QgsSpatiaLiteSourceSelect::mTablesTreeView_doubleClicked );
setupButtons( buttonBox );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsSpatiaLiteSourceSelect::showHelp );
Expand Down Expand Up @@ -147,11 +146,6 @@ void QgsSpatiaLiteSourceSelect::cbxAllowGeometrylessTables_stateChanged( int )
btnConnect_clicked();
}

void QgsSpatiaLiteSourceSelect::mTablesTreeView_clicked( const QModelIndex &index )
{
mBuildQueryButton->setEnabled( index.parent().isValid() );
}

void QgsSpatiaLiteSourceSelect::mTablesTreeView_doubleClicked( const QModelIndex &index )
{
setSql( index );
Expand Down
1 change: 0 additions & 1 deletion src/providers/spatialite/qgsspatialitesourceselect.h
Expand Up @@ -85,7 +85,6 @@ class QgsSpatiaLiteSourceSelect: public QgsDbSourceSelectBase
void setSql( const QModelIndex &index );
void cmbConnections_activated( int );
void setLayerType( const QString &table, const QString &column, const QString &type );
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
Expand Down

0 comments on commit 0f39b82

Please sign in to comment.