Skip to content

Commit

Permalink
Merge pull request #51215 from uclaros/fix-relation-multi-completer
Browse files Browse the repository at this point in the history
Allow filtering in value relation widget when allowing multiple selections
  • Loading branch information
troopa81 committed Jan 3, 2023
2 parents 9593a56 + 10c5a4a commit f4d2f27
Show file tree
Hide file tree
Showing 8 changed files with 438 additions and 146 deletions.
Expand Up @@ -78,6 +78,12 @@ Optionally a ``column`` can be specified, which will also bring that column into
.. versionadded:: 3.16
%End

void closeCurrentEditor();
%Docstring
Closes the editor delegate for the current item, committing its changes to the model.

.. versionadded:: 3.30
%End
protected:

virtual void mousePressEvent( QMouseEvent *event );
Expand Down
9 changes: 5 additions & 4 deletions src/app/qgsattributetabledialog.cpp
Expand Up @@ -857,10 +857,11 @@ void QgsAttributeTableDialog::mActionToggleEditing_toggled( bool )
if ( !mLayer )
return;

//this has to be done, because in case only one cell has been changed and is still enabled, the change
//would not be added to the mEditBuffer. By disabling, it looses focus and the change will be stored.
if ( mLayer->isEditable() && mMainView->tableView()->indexWidget( mMainView->tableView()->currentIndex() ) )
mMainView->tableView()->indexWidget( mMainView->tableView()->currentIndex() )->setEnabled( false );
if ( mLayer->isEditable() )
{
// commit changes in the currently active cell
mMainView->tableView()->closeCurrentEditor();
}

if ( !QgisApp::instance()->toggleEditing( mLayer ) )
{
Expand Down
7 changes: 7 additions & 0 deletions src/gui/attributetable/qgsattributetableview.cpp
Expand Up @@ -549,3 +549,10 @@ void QgsAttributeTableView::scrollToFeature( const QgsFeatureId &fid, int col )

selectionModel()->setCurrentIndex( index, QItemSelectionModel::SelectCurrent );
}

void QgsAttributeTableView::closeCurrentEditor()
{
QWidget *editor = indexWidget( currentIndex() );
commitData( editor );
closeEditor( editor, QAbstractItemDelegate::NoHint );
}
6 changes: 6 additions & 0 deletions src/gui/attributetable/qgsattributetableview.h
Expand Up @@ -104,6 +104,12 @@ class GUI_EXPORT QgsAttributeTableView : public QgsTableView
*/
void scrollToFeature( const QgsFeatureId &fid, int column = -1 );

/**
* Closes the editor delegate for the current item, committing its changes to the model.
*
* \since QGIS 3.30
*/
void closeCurrentEditor();
protected:

/**
Expand Down

0 comments on commit f4d2f27

Please sign in to comment.