Rename signal and use direct zoom (reviewer feedback)

This commit is contained in:
lanckmann 2025-08-24 18:28:55 -04:00 committed by Nyall Dawson
parent 0b2562d459
commit cf1179aebd
6 changed files with 15 additions and 18 deletions

View File

@ -1,9 +1,9 @@
# The following has been generated automatically from src/gui/attributetable/qgsattributetableview.h
try:
QgsAttributeTableView.__attribute_docs__ = {'willShowContextMenu': 'Emitted in order to provide a hook to add additional* menu entries to\nthe context menu.\n\n:param menu: If additional QMenuItems are added, they will show up in\n the context menu.\n:param atIndex: The QModelIndex, to which the context menu belongs.\n Relative to the source model. In most cases, this will\n be a :py:class:`QgsAttributeTableFilterModel`\n', 'columnResized': 'Emitted when a column in the view has been resized.\n\n:param column: column index (starts at 0)\n:param width: new width in pixel\n', 'finished': '.. deprecated:: 3.40\n\n No longer used.\n', 'zoomToFeatureRequested': 'Emitted when a row header is double-clicked to request zooming to the\nfeature.\n\n:param fid: the feature ID of the double-clicked row\n\n.. versionadded:: 3.46\n'}
QgsAttributeTableView.__attribute_docs__ = {'willShowContextMenu': 'Emitted in order to provide a hook to add additional* menu entries to\nthe context menu.\n\n:param menu: If additional QMenuItems are added, they will show up in\n the context menu.\n:param atIndex: The QModelIndex, to which the context menu belongs.\n Relative to the source model. In most cases, this will\n be a :py:class:`QgsAttributeTableFilterModel`\n', 'columnResized': 'Emitted when a column in the view has been resized.\n\n:param column: column index (starts at 0)\n:param width: new width in pixel\n', 'finished': '.. deprecated:: 3.40\n\n No longer used.\n', 'rowHeaderDoubleClicked': 'Emitted when a row header is double-clicked.\n\n:param fid: the feature ID of the double-clicked row.\n\n.. versionadded:: 4.0\n'}
QgsAttributeTableView.__virtual_methods__ = ['setModel', 'selectRow', '_q_selectRow']
QgsAttributeTableView.__overridden_methods__ = ['eventFilter', 'mousePressEvent', 'mouseReleaseEvent', 'mouseMoveEvent', 'keyPressEvent', 'contextMenuEvent', 'closeEvent', 'selectAll']
QgsAttributeTableView.__signal_arguments__ = {'willShowContextMenu': ['menu: QMenu', 'atIndex: QModelIndex'], 'columnResized': ['column: int', 'width: int'], 'zoomToFeatureRequested': ['fid: QgsFeatureId']}
QgsAttributeTableView.__signal_arguments__ = {'willShowContextMenu': ['menu: QMenu', 'atIndex: QModelIndex'], 'columnResized': ['column: int', 'width: int'], 'rowHeaderDoubleClicked': ['fid: QgsFeatureId']}
QgsAttributeTableView.__group__ = ['attributetable']
except (NameError, AttributeError):
pass

View File

@ -1,9 +1,9 @@
# The following has been generated automatically from src/gui/attributetable/qgsattributetableview.h
try:
QgsAttributeTableView.__attribute_docs__ = {'willShowContextMenu': 'Emitted in order to provide a hook to add additional* menu entries to\nthe context menu.\n\n:param menu: If additional QMenuItems are added, they will show up in\n the context menu.\n:param atIndex: The QModelIndex, to which the context menu belongs.\n Relative to the source model. In most cases, this will\n be a :py:class:`QgsAttributeTableFilterModel`\n', 'columnResized': 'Emitted when a column in the view has been resized.\n\n:param column: column index (starts at 0)\n:param width: new width in pixel\n', 'finished': '.. deprecated:: 3.40\n\n No longer used.\n', 'zoomToFeatureRequested': 'Emitted when a row header is double-clicked to request zooming to the\nfeature.\n\n:param fid: the feature ID of the double-clicked row\n\n.. versionadded:: 3.46\n'}
QgsAttributeTableView.__attribute_docs__ = {'willShowContextMenu': 'Emitted in order to provide a hook to add additional* menu entries to\nthe context menu.\n\n:param menu: If additional QMenuItems are added, they will show up in\n the context menu.\n:param atIndex: The QModelIndex, to which the context menu belongs.\n Relative to the source model. In most cases, this will\n be a :py:class:`QgsAttributeTableFilterModel`\n', 'columnResized': 'Emitted when a column in the view has been resized.\n\n:param column: column index (starts at 0)\n:param width: new width in pixel\n', 'finished': '.. deprecated:: 3.40\n\n No longer used.\n', 'rowHeaderDoubleClicked': 'Emitted when a row header is double-clicked.\n\n:param fid: the feature ID of the double-clicked row.\n\n.. versionadded:: 4.0\n'}
QgsAttributeTableView.__virtual_methods__ = ['setModel', 'selectRow', '_q_selectRow']
QgsAttributeTableView.__overridden_methods__ = ['eventFilter', 'mousePressEvent', 'mouseReleaseEvent', 'mouseMoveEvent', 'keyPressEvent', 'contextMenuEvent', 'closeEvent', 'selectAll']
QgsAttributeTableView.__signal_arguments__ = {'willShowContextMenu': ['menu: QMenu', 'atIndex: QModelIndex'], 'columnResized': ['column: int', 'width: int'], 'zoomToFeatureRequested': ['fid: QgsFeatureId']}
QgsAttributeTableView.__signal_arguments__ = {'willShowContextMenu': ['menu: QMenu', 'atIndex: QModelIndex'], 'columnResized': ['column: int', 'width: int'], 'rowHeaderDoubleClicked': ['fid: QgsFeatureId']}
QgsAttributeTableView.__group__ = ['attributetable']
except (NameError, AttributeError):
pass

View File

@ -172,14 +172,13 @@ Emitted when a column in the view has been resized.
No longer used.
%End
void zoomToFeatureRequested( QgsFeatureId fid );
void rowHeaderDoubleClicked( QgsFeatureId fid );
%Docstring
Emitted when a row header is double-clicked to request zooming to the
feature.
Emitted when a row header is double-clicked.
:param fid: the feature ID of the double-clicked row
:param fid: the feature ID of the double-clicked row.
.. versionadded:: 3.46
.. versionadded:: 4.0
%End
public slots:

View File

@ -142,7 +142,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
connect( mMainView, &QgsDualView::showContextMenuExternally, this, &QgsAttributeTableDialog::showContextMenu );
// Connect double-click zoom functionality
connect( mMainView->tableView(), &QgsAttributeTableView::zoomToFeatureRequested, this, &QgsAttributeTableDialog::zoomToFeature );
connect( mMainView->tableView(), &QgsAttributeTableView::rowHeaderDoubleClicked, this, &QgsAttributeTableDialog::zoomToFeature );
mActionSelectAll->setShortcuts( QKeySequence::SelectAll );
mActionSelectAll->setShortcutContext( Qt::WidgetWithChildrenShortcut );
@ -830,9 +830,7 @@ void QgsAttributeTableDialog::mActionZoomMapToSelectedRows_triggered()
void QgsAttributeTableDialog::zoomToFeature( QgsFeatureId fid )
{
// Select the feature first, then zoom to it
mLayer->selectByIds( QgsFeatureIds() << fid );
QgisApp::instance()->mapCanvas()->zoomToSelected( mLayer );
QgisApp::instance()->mapCanvas()->zoomToFeatureIds( mLayer, { fid } );
}
void QgsAttributeTableDialog::mActionPanMapToSelectedRows_triggered()

View File

@ -93,7 +93,7 @@ bool QgsAttributeTableView::eventFilter( QObject *object, QEvent *event )
if ( index.isValid() )
{
const QgsFeatureId fid = mFilterModel->rowToId( index );
emit zoomToFeatureRequested( fid );
emit rowHeaderDoubleClicked( fid );
}
}
}

View File

@ -181,11 +181,11 @@ class GUI_EXPORT QgsAttributeTableView : public QgsTableView
Q_DECL_DEPRECATED void finished() SIP_DEPRECATED;
/**
* Emitted when a row header is double-clicked to request zooming to the feature.
* \param fid the feature ID of the double-clicked row
* \since QGIS 3.46
* Emitted when a row header is double-clicked.
* \param fid the feature ID of the double-clicked row.
* \since QGIS 4.0
*/
void zoomToFeatureRequested( QgsFeatureId fid );
void rowHeaderDoubleClicked( QgsFeatureId fid );
public slots:
void repaintRequested( const QModelIndexList &indexes );