mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-09 00:08:52 -04:00
parent
b00d6fa61a
commit
b7ff23aa33
@ -70,6 +70,16 @@ Returns the selected features in the attribute table in table sorted order.
|
||||
%End
|
||||
|
||||
|
||||
void scrollToFeature( const QgsFeatureId &fid, int column = -1 );
|
||||
%Docstring
|
||||
Scroll to a feature with a given ``fid``.
|
||||
|
||||
Optionally a ``column`` can be specified, which will also bring that column into view.
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual void mousePressEvent( QMouseEvent *event );
|
||||
|
@ -627,6 +627,7 @@ void QgsAttributeTableDialog::mActionAddFeatureViaAttributeTable_triggered()
|
||||
{
|
||||
masterModel->reload( masterModel->index( 0, 0 ), masterModel->index( masterModel->rowCount() - 1, masterModel->columnCount() - 1 ) );
|
||||
mMainView->setCurrentEditSelection( QgsFeatureIds() << action.feature().id() );
|
||||
mMainView->tableView()->scrollToFeature( action.feature().id(), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@ -648,6 +649,7 @@ void QgsAttributeTableDialog::mActionAddFeatureViaAttributeForm_triggered()
|
||||
{
|
||||
masterModel->reload( masterModel->index( 0, 0 ), masterModel->index( masterModel->rowCount() - 1, masterModel->columnCount() - 1 ) );
|
||||
mMainView->setCurrentEditSelection( QgsFeatureIds() << action.feature().id() );
|
||||
mMainView->tableView()->scrollToFeature( action.feature().id(), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -497,3 +497,20 @@ void QgsAttributeTableView::recreateActionWidgets()
|
||||
}
|
||||
mActionWidgets.clear();
|
||||
}
|
||||
|
||||
void QgsAttributeTableView::scrollToFeature( const QgsFeatureId &fid, int col )
|
||||
{
|
||||
QModelIndex index = mFilterModel->fidToIndex( fid );
|
||||
|
||||
if ( !index.isValid() )
|
||||
return;
|
||||
|
||||
scrollTo( index );
|
||||
|
||||
QModelIndex selectionIndex = index.sibling( index.row(), col );
|
||||
|
||||
if ( !selectionIndex.isValid() )
|
||||
return;
|
||||
|
||||
selectionModel()->setCurrentIndex( index, QItemSelectionModel::SelectCurrent );
|
||||
}
|
||||
|
@ -89,6 +89,16 @@ class GUI_EXPORT QgsAttributeTableView : public QTableView
|
||||
QList<QgsFeatureId> selectedFeaturesIds() const;
|
||||
|
||||
|
||||
/**
|
||||
* Scroll to a feature with a given \a fid.
|
||||
|
||||
Optionally a \a column can be specified, which will also bring that column into view.
|
||||
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
void scrollToFeature( const QgsFeatureId &fid, int column = -1 );
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user