mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-18 00:14:20 -05:00
Cleanups
This commit is contained in:
parent
b2af412b06
commit
cf3bee384e
@ -288,11 +288,13 @@ Centers canvas extent to feature ids
|
|||||||
Pan to the selected features of current (vector) layer keeping same extent.
|
Pan to the selected features of current (vector) layer keeping same extent.
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void panToAllSelected( const QList<QgsMapLayer *> *layers );
|
void panToSelected( const QList<QgsMapLayer *> &layers );
|
||||||
%Docstring
|
%Docstring
|
||||||
Pan to the combined extent of the selected features of all provided (vector) layers.
|
Pan to the combined extent of the selected features of all provided (vector) layers.
|
||||||
|
|
||||||
:param layers: A list of layers
|
:param layers: A list of layers
|
||||||
|
|
||||||
|
.. versionadded:: 3.18
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void flashFeatureIds( QgsVectorLayer *layer, const QgsFeatureIds &ids,
|
void flashFeatureIds( QgsVectorLayer *layer, const QgsFeatureIds &ids,
|
||||||
@ -962,11 +964,13 @@ Zoom to the extent of the selected features of provided (vector) layer.
|
|||||||
:param layer: optionally specify different than current layer
|
:param layer: optionally specify different than current layer
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void zoomToAllSelected( const QList<QgsMapLayer *> *layers );
|
void zoomToSelected( const QList<QgsMapLayer *> &layers );
|
||||||
%Docstring
|
%Docstring
|
||||||
Zoom to the combined extent of the selected features of all provided (vector) layers.
|
Zoom to the combined extent of the selected features of all provided (vector) layers.
|
||||||
|
|
||||||
:param layers: A list of layers
|
:param layers: A list of layers
|
||||||
|
|
||||||
|
.. versionadded:: 3.18
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setZoomResolutions( const QList<double> &resolutions );
|
void setZoomResolutions( const QList<double> &resolutions );
|
||||||
|
|||||||
@ -8191,10 +8191,10 @@ void QgisApp::zoomOut()
|
|||||||
|
|
||||||
void QgisApp::zoomToSelected()
|
void QgisApp::zoomToSelected()
|
||||||
{
|
{
|
||||||
QList<QgsMapLayer *> layers = mLayerTreeView->selectedLayers();
|
const QList<QgsMapLayer *> layers = mLayerTreeView->selectedLayers();
|
||||||
|
|
||||||
if ( layers.size() > 1 && !layers.isEmpty() )
|
if ( layers.size() > 1 )
|
||||||
mMapCanvas->zoomToAllSelected( &layers );
|
mMapCanvas->zoomToSelected( layers );
|
||||||
|
|
||||||
else
|
else
|
||||||
mMapCanvas->zoomToSelected();
|
mMapCanvas->zoomToSelected();
|
||||||
@ -8203,11 +8203,10 @@ void QgisApp::zoomToSelected()
|
|||||||
|
|
||||||
void QgisApp::panToSelected()
|
void QgisApp::panToSelected()
|
||||||
{
|
{
|
||||||
QList<QgsMapLayer *> layers = mLayerTreeView->selectedLayers();
|
const QList<QgsMapLayer *> layers = mLayerTreeView->selectedLayers();
|
||||||
|
|
||||||
if ( layers.size() > 1 && !layers.isEmpty() )
|
|
||||||
mMapCanvas->panToAllSelected( &layers );
|
|
||||||
|
|
||||||
|
if ( layers.size() > 1 )
|
||||||
|
mMapCanvas->panToSelected( layers );
|
||||||
else
|
else
|
||||||
mMapCanvas->panToSelected();
|
mMapCanvas->panToSelected();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,23 +156,19 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
|
|||||||
menu->addAction( zoomToLayers );
|
menu->addAction( zoomToLayers );
|
||||||
if ( vlayer )
|
if ( vlayer )
|
||||||
{
|
{
|
||||||
QList<QgsMapLayer *> selectedLayers = mView->selectedLayers();
|
const QList<QgsMapLayer *> selectedLayers = mView->selectedLayers();
|
||||||
bool hasSelectedFeature;
|
bool hasSelectedFeature = false;
|
||||||
for ( int i = 0; i < selectedLayers.size(); ++i )
|
for ( const QgsMapLayer *layer : selectedLayers )
|
||||||
{
|
{
|
||||||
QgsMapLayer *layer = selectedLayers.at( i );
|
|
||||||
|
|
||||||
if ( layer->type() == QgsMapLayerType( 0 ) )
|
if ( const QgsVectorLayer *vLayer = qobject_cast<const QgsVectorLayer *>( layer ) )
|
||||||
{
|
{
|
||||||
QgsVectorLayer *vLayer = qobject_cast<QgsVectorLayer *>( layer );
|
|
||||||
|
|
||||||
if ( !vLayer->selectedFeatureIds().isEmpty() )
|
if ( vLayer->selectedFeatureCount() > 0 )
|
||||||
{
|
{
|
||||||
hasSelectedFeature = true;
|
hasSelectedFeature = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
hasSelectedFeature = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -525,9 +525,9 @@ void QgsMapCanvasDockWidget::showLabels( bool show )
|
|||||||
void QgsMapCanvasDockWidget::autoZoomToSelection( bool autoZoom )
|
void QgsMapCanvasDockWidget::autoZoomToSelection( bool autoZoom )
|
||||||
{
|
{
|
||||||
if ( autoZoom )
|
if ( autoZoom )
|
||||||
connect( mMapCanvas, &QgsMapCanvas::selectionChanged, mMapCanvas, &QgsMapCanvas::zoomToSelected );
|
connect( mMapCanvas, &QgsMapCanvas::selectionChanged, mMapCanvas, qgis::overload<QgsVectorLayer *>::of( &QgsMapCanvas::zoomToSelected ) );
|
||||||
else
|
else
|
||||||
disconnect( mMapCanvas, &QgsMapCanvas::selectionChanged, mMapCanvas, &QgsMapCanvas::zoomToSelected );
|
disconnect( mMapCanvas, &QgsMapCanvas::selectionChanged, mMapCanvas, qgis::overload<QgsVectorLayer *>::of( &QgsMapCanvas::zoomToSelected ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsMapSettingsAction::QgsMapSettingsAction( QWidget *parent )
|
QgsMapSettingsAction::QgsMapSettingsAction( QWidget *parent )
|
||||||
|
|||||||
@ -312,16 +312,12 @@ void QgsLayerTreeViewDefaultActions::zoomToLayers( QgsMapCanvas *canvas )
|
|||||||
|
|
||||||
void QgsLayerTreeViewDefaultActions::zoomToSelection( QgsMapCanvas *canvas )
|
void QgsLayerTreeViewDefaultActions::zoomToSelection( QgsMapCanvas *canvas )
|
||||||
{
|
{
|
||||||
QgsVectorLayer *layer;
|
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( mView->currentLayer() );
|
||||||
|
|
||||||
if ( mView->currentLayer()->type() == QgsMapLayerType( 0 ) )
|
const QList<QgsMapLayer *> layers = mView->selectedLayers();
|
||||||
layer = qobject_cast<QgsVectorLayer *>( mView->currentLayer() );
|
|
||||||
|
|
||||||
QList<QgsMapLayer *> layers = mView->selectedLayers();
|
|
||||||
|
|
||||||
if ( layers.size() > 1 && !layers.isEmpty() )
|
|
||||||
canvas->zoomToAllSelected( &layers );
|
|
||||||
|
|
||||||
|
if ( layers.size() > 1 )
|
||||||
|
canvas->zoomToSelected( layers );
|
||||||
else if ( layers.size() <= 1 && layer )
|
else if ( layers.size() <= 1 && layer )
|
||||||
canvas->zoomToSelected( layer );
|
canvas->zoomToSelected( layer );
|
||||||
|
|
||||||
|
|||||||
@ -1349,19 +1349,16 @@ void QgsMapCanvas::zoomToSelected( QgsVectorLayer *layer )
|
|||||||
zoomToFeatureExtent( rect );
|
zoomToFeatureExtent( rect );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsMapCanvas::zoomToAllSelected( const QList<QgsMapLayer *> *layers )
|
void QgsMapCanvas::zoomToSelected( const QList<QgsMapLayer *> &layers )
|
||||||
{
|
{
|
||||||
QgsVectorLayer *layer;
|
|
||||||
|
|
||||||
QgsRectangle rect;
|
QgsRectangle rect;
|
||||||
rect.setMinimal();
|
rect.setMinimal();
|
||||||
QgsRectangle selectionExtent;
|
QgsRectangle selectionExtent;
|
||||||
selectionExtent.setMinimal();
|
selectionExtent.setMinimal();
|
||||||
|
|
||||||
for ( int i = 0; i < layers->size(); ++i )
|
for ( QgsMapLayer *mapLayer : layers )
|
||||||
{
|
{
|
||||||
if ( layers->at( i )->type() == QgsMapLayerType( 0 ) )
|
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( mapLayer );
|
||||||
layer = qobject_cast<QgsVectorLayer *>( layers->at( i ) );
|
|
||||||
|
|
||||||
if ( !layer || !layer->isSpatial() || layer->selectedFeatureCount() == 0 )
|
if ( !layer || !layer->isSpatial() || layer->selectedFeatureCount() == 0 )
|
||||||
continue;
|
continue;
|
||||||
@ -1539,19 +1536,16 @@ void QgsMapCanvas::panToSelected( QgsVectorLayer *layer )
|
|||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsMapCanvas::panToAllSelected( const QList<QgsMapLayer *> *layers )
|
void QgsMapCanvas::panToSelected( const QList<QgsMapLayer *> &layers )
|
||||||
{
|
{
|
||||||
QgsVectorLayer *layer;
|
|
||||||
|
|
||||||
QgsRectangle rect;
|
QgsRectangle rect;
|
||||||
rect.setMinimal();
|
rect.setMinimal();
|
||||||
QgsRectangle selectionExtent;
|
QgsRectangle selectionExtent;
|
||||||
selectionExtent.setMinimal();
|
selectionExtent.setMinimal();
|
||||||
|
|
||||||
for ( int i = 0; i < layers->size(); ++i )
|
for ( QgsMapLayer *mapLayer : layers )
|
||||||
{
|
{
|
||||||
if ( layers->at( i )->type() == QgsMapLayerType( 0 ) )
|
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( mapLayer );
|
||||||
layer = qobject_cast<QgsVectorLayer *>( layers->at( i ) );
|
|
||||||
|
|
||||||
if ( !layer || !layer->isSpatial() || layer->selectedFeatureCount() == 0 )
|
if ( !layer || !layer->isSpatial() || layer->selectedFeatureCount() == 0 )
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -314,8 +314,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
|
|||||||
/**
|
/**
|
||||||
* Pan to the combined extent of the selected features of all provided (vector) layers.
|
* Pan to the combined extent of the selected features of all provided (vector) layers.
|
||||||
* \param layers A list of layers
|
* \param layers A list of layers
|
||||||
|
* \since QGIS 3.18
|
||||||
*/
|
*/
|
||||||
void panToAllSelected( const QList<QgsMapLayer *> *layers );
|
void panToSelected( const QList<QgsMapLayer *> &layers );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Causes a set of features with matching \a ids from a vector \a layer to flash
|
* Causes a set of features with matching \a ids from a vector \a layer to flash
|
||||||
@ -875,8 +876,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
|
|||||||
/**
|
/**
|
||||||
* Zoom to the combined extent of the selected features of all provided (vector) layers.
|
* Zoom to the combined extent of the selected features of all provided (vector) layers.
|
||||||
* \param layers A list of layers
|
* \param layers A list of layers
|
||||||
|
* \since QGIS 3.18
|
||||||
*/
|
*/
|
||||||
void zoomToAllSelected( const QList<QgsMapLayer *> *layers );
|
void zoomToSelected( const QList<QgsMapLayer *> &layers );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a list of resolutions (map units per pixel) to which to "snap to" when zooming the map
|
* Set a list of resolutions (map units per pixel) to which to "snap to" when zooming the map
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user