Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix spell, layout and sip
  • Loading branch information
3nids authored and nyalldawson committed Jan 21, 2022
1 parent 5f33b4f commit 973b97a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
Expand Up @@ -40,13 +40,23 @@ Returns the proxy model used to filter the results


protected slots:

virtual void setSql( const QModelIndex &index ) = 0;
%Docstring
This is called to define the SQL query and must be re-implemented. The implementation should call :py:class:`QgsAbstractDbTableModel`.setSql
This is called to define the SQL query and must be re-implemented.
The implementation should call :py:class:`QgsAbstractDbTableModel`.setSql
The index is in the source model.
%End

virtual void treeviewClicked( const QModelIndex &index );
%Docstring
Called on click for the source ``index``
%End

virtual void treeviewDoubleClicked( const QModelIndex &index );
%Docstring
Called on double-click for the source ``index``
%End

};

Expand Down
14 changes: 8 additions & 6 deletions src/gui/providers/qgsabstractdbsourceselect.cpp
Expand Up @@ -45,21 +45,23 @@ QgsAbstractDbSourceSelect::QgsAbstractDbSourceSelect( QWidget *parent, Qt::Windo
mBuildQueryButton->setDisabled( true );
buttonBox->addButton( mBuildQueryButton, QDialogButtonBox::ActionRole );

connect( mTablesTreeView, &QTreeView::clicked, this, [ = ](const QModelIndex &index){
connect( mTablesTreeView, &QTreeView::clicked, this, [ = ]( const QModelIndex & index )
{
treeviewClicked( mProxyModel->mapToSource( index ) );
});
connect( mTablesTreeView, &QTreeView::doubleClicked, this, [ = ](const QModelIndex &index){
} );
connect( mTablesTreeView, &QTreeView::doubleClicked, this, [ = ]( const QModelIndex & index )
{
treeviewDoubleClicked( mProxyModel->mapToSource( index ) );
});
} );

connect( mBuildQueryButton, &QAbstractButton::clicked, this, [ = ]() {setSql( mProxyModel->mapToSource(mTablesTreeView->currentIndex() ));} );
connect( mBuildQueryButton, &QAbstractButton::clicked, this, [ = ]() {setSql( mProxyModel->mapToSource( mTablesTreeView->currentIndex() ) );} );
}

void QgsAbstractDbSourceSelect::init( QgsAbstractDbTableModel *model, QItemDelegate *delegate )
{
mProxyModel->setSourceModel( model );
mTablesTreeView->setModel( mProxyModel );
if (delegate)
if ( delegate )
mTablesTreeView->setItemDelegate( delegate );

// setting the search coluns in search settings menu using the model header data
Expand Down
11 changes: 7 additions & 4 deletions src/gui/providers/qgsabstractdbsourceselect.h
Expand Up @@ -47,15 +47,18 @@ class GUI_EXPORT QgsAbstractDbSourceSelect : public QgsAbstractDataSourceWidget,
QPushButton *mBuildQueryButton = nullptr;

protected slots:
//! This is called to define the SQL query and must be re-implemented.
//! The implementation should call QgsAbstractDbTableModel::setSql
//! The index is in the source model.

/**
* This is called to define the SQL query and must be re-implemented.
* The implementation should call QgsAbstractDbTableModel::setSql
* The index is in the source model.
*/
virtual void setSql( const QModelIndex &index ) = 0;

//! Called on click for the source \a index
virtual void treeviewClicked( const QModelIndex &index );

//! Called on double click for the source \a index
//! Called on double-click for the source \a index
virtual void treeviewDoubleClicked( const QModelIndex &index );

private:
Expand Down

0 comments on commit 973b97a

Please sign in to comment.