Skip to content
Permalink
Browse files

Deprecated zoomToLayer method

  • Loading branch information
TurboGraphxBeige authored and nyalldawson committed Jan 1, 2021
1 parent 0874c57 commit 9fee7660fa0f6bf39c42e43a87ef1e0dcfab9013
@@ -2737,7 +2737,7 @@ void QgisApp::createActions()
connect( mActionMeasureArea, &QAction::triggered, this, &QgisApp::measureArea );
connect( mActionMeasureAngle, &QAction::triggered, this, &QgisApp::measureAngle );
connect( mActionZoomFullExtent, &QAction::triggered, this, &QgisApp::zoomFull );
connect( mActionZoomToLayer, &QAction::triggered, this, &QgisApp::zoomToLayerExtent );
connect( mActionZoomToLayers, &QAction::triggered, this, &QgisApp::zoomToLayerExtent );
connect( mActionZoomToSelected, &QAction::triggered, this, &QgisApp::zoomToSelected );
connect( mActionZoomLast, &QAction::triggered, this, &QgisApp::zoomToPrevious );
connect( mActionZoomNext, &QAction::triggered, this, &QgisApp::zoomToNext );
@@ -4100,7 +4100,7 @@ void QgisApp::setTheme( const QString &themeName )
mActionPanToSelected->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionPanToSelected.svg" ) ) );
mActionZoomLast->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomLast.svg" ) ) );
mActionZoomNext->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomNext.svg" ) ) );
mActionZoomToLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomToLayer.svg" ) ) );
mActionZoomToLayers->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomToLayer.svg" ) ) );
mActionZoomActualSize->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomActual.svg" ) ) );
mActionIdentify->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionIdentify.svg" ) ) );
mActionFeatureAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mAction.svg" ) ) );
@@ -12175,7 +12175,7 @@ void QgisApp::legendGroupSetWmsData()

void QgisApp::zoomToLayerExtent()
{
mLayerTreeView->defaultActions()->zoomToLayer( mMapCanvas );
mLayerTreeView->defaultActions()->zoomToLayers( mMapCanvas );
}

void QgisApp::showPluginManager()
mActionIncreaseGamma->setEnabled( false );
mActionDecreaseGamma->setEnabled( false );
mActionZoomActualSize->setEnabled( false );
mActionZoomToLayer->setEnabled( false );
mActionZoomToLayers->setEnabled( false );

enableDigitizeWithCurveAction( false );


mActionLayerProperties->setEnabled( QgsProject::instance()->layerIsEmbedded( layer->id() ).isEmpty() );
mActionAddToOverview->setEnabled( true );
mActionZoomToLayer->setEnabled( true );
mActionZoomToLayers->setEnabled( true );

mActionCopyStyle->setEnabled( true );
mActionPasteStyle->setEnabled( clipboard()->hasFormat( QStringLiteral( QGSCLIPBOARD_STYLE_MIME ) ) );
mActionIncreaseGamma->setEnabled( false );
mActionDecreaseGamma->setEnabled( false );
mActionZoomActualSize->setEnabled( false );
mActionZoomToLayer->setEnabled( isSpatial );
mActionZoomToLayers->setEnabled( isSpatial );
mActionZoomToSelected->setEnabled( isSpatial );
mActionLabeling->setEnabled( isSpatial );
mActionDiagramProperties->setEnabled( isSpatial );
mActionSelectFreehand->setEnabled( false );
mActionSelectRadius->setEnabled( false );
mActionZoomActualSize->setEnabled( true );
mActionZoomToLayer->setEnabled( true );
mActionZoomToLayers->setEnabled( true );
mActionZoomToSelected->setEnabled( false );
mActionOpenTable->setEnabled( false );
mActionSelectAll->setEnabled( false );
mActionSelectFreehand->setEnabled( false );
mActionSelectRadius->setEnabled( false );
mActionZoomActualSize->setEnabled( false );
mActionZoomToLayer->setEnabled( true );
mActionZoomToLayers->setEnabled( true );
mActionZoomToSelected->setEnabled( false );
mActionOpenTable->setEnabled( false );
mActionSelectAll->setEnabled( false );
mActionSelectFreehand->setEnabled( false );
mActionSelectRadius->setEnabled( false );
mActionZoomActualSize->setEnabled( false );
mActionZoomToLayer->setEnabled( true );
mActionZoomToLayers->setEnabled( true );
mActionZoomToSelected->setEnabled( false );
mActionOpenTable->setEnabled( false );
mActionSelectAll->setEnabled( false );
mActionSelectFreehand->setEnabled( false );
mActionSelectRadius->setEnabled( false );
mActionZoomActualSize->setEnabled( false );
mActionZoomToLayer->setEnabled( true );
mActionZoomToLayers->setEnabled( true );
mActionZoomToSelected->setEnabled( false );
mActionOpenTable->setEnabled( false );
mActionSelectAll->setEnabled( false );
@@ -509,7 +509,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QAction *actionMeasure() { return mActionMeasure; }
QAction *actionMeasureArea() { return mActionMeasureArea; }
QAction *actionZoomFullExtent() { return mActionZoomFullExtent; }
QAction *actionZoomToLayer() { return mActionZoomToLayer; }
QAction *actionZoomToLayers() { return mActionZoomToLayers; }
QAction *actionZoomToSelected() { return mActionZoomToSelected; }
QAction *actionZoomLast() { return mActionZoomLast; }
QAction *actionZoomNext() { return mActionZoomNext; }
@@ -700,7 +700,7 @@ QAction *QgisAppInterface::actionFeatureAction() { return qgis->actionFeatureAct
QAction *QgisAppInterface::actionMeasure() { return qgis->actionMeasure(); }
QAction *QgisAppInterface::actionMeasureArea() { return qgis->actionMeasureArea(); }
QAction *QgisAppInterface::actionZoomFullExtent() { return qgis->actionZoomFullExtent(); }
QAction *QgisAppInterface::actionZoomToLayer() { return qgis->actionZoomToLayer(); }
QAction *QgisAppInterface::actionZoomToLayers() { return qgis->actionZoomToLayers(); }
QAction *QgisAppInterface::actionZoomToSelected() { return qgis->actionZoomToSelected(); }
QAction *QgisAppInterface::actionZoomLast() { return qgis->actionZoomLast(); }
QAction *QgisAppInterface::actionZoomNext() { return qgis->actionZoomNext(); }
@@ -231,7 +231,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
QAction *actionMeasure() override;
QAction *actionMeasureArea() override;
QAction *actionZoomFullExtent() override;
QAction *actionZoomToLayer() override;
QAction *actionZoomToLayers() override;
QAction *actionZoomToSelected() override;
QAction *actionZoomLast() override;
QAction *actionZoomNext() override;
@@ -151,9 +151,9 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
if ( layer && layer->isSpatial() )
{

QAction *zoomToLayer = actions->actionZoomToLayer( mCanvas, menu );
zoomToLayer->setEnabled( layer->isValid() );
menu->addAction( zoomToLayer );
QAction *zoomToLayers = actions->actionZoomToLayers( mCanvas, menu );
zoomToLayers->setEnabled( layer->isValid() );
menu->addAction( zoomToLayers );
if ( vlayer )
{
QAction *actionZoomSelected = actions->actionZoomToSelection( mCanvas, menu );
@@ -91,9 +91,20 @@ QAction *QgsLayerTreeViewDefaultActions::actionShowFeatureCount( QObject *parent
QAction *QgsLayerTreeViewDefaultActions::actionZoomToLayer( QgsMapCanvas *canvas, QObject *parent )
{
QAction *a = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomToLayer.svg" ) ),
tr( "&Zoom to Layer(s)" ), parent );
tr( "&Zoom to Layer" ), parent );
a->setData( QVariant::fromValue( reinterpret_cast<void *>( canvas ) ) );
Q_NOWARN_DEPRECATED_PUSH
connect( a, &QAction::triggered, this, static_cast<void ( QgsLayerTreeViewDefaultActions::* )()>( &QgsLayerTreeViewDefaultActions::zoomToLayer ) );
Q_NOWARN_DEPRECATED_POP
return a;
}

QAction *QgsLayerTreeViewDefaultActions::actionZoomToLayers( QgsMapCanvas *canvas, QObject *parent )
{
QAction *a = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomToLayer.svg" ) ),
tr( "&Zoom to Layer(s)" ), parent );
a->setData( QVariant::fromValue( reinterpret_cast<void *>( canvas ) ) );
connect( a, &QAction::triggered, this, static_cast<void ( QgsLayerTreeViewDefaultActions::* )()>( &QgsLayerTreeViewDefaultActions::zoomToLayers ) );
return a;
}

@@ -280,8 +291,18 @@ void QgsLayerTreeViewDefaultActions::showFeatureCount()
l->setCustomProperty( QStringLiteral( "showFeatureCount" ), newValue ? 0 : 1 );
}


void QgsLayerTreeViewDefaultActions::zoomToLayer( QgsMapCanvas *canvas )
{
QgsMapLayer *layer = mView->currentLayer();
if ( !layer )
return;

QList<QgsMapLayer *> layers;
layers << layer;
zoomToLayers( canvas, layers );
}

void QgsLayerTreeViewDefaultActions::zoomToLayers( QgsMapCanvas *canvas )
{
QList<QgsMapLayer *> layers = mView->selectedLayers();
if ( layers.isEmpty() )
@@ -322,6 +343,15 @@ void QgsLayerTreeViewDefaultActions::zoomToLayer()
QApplication::restoreOverrideCursor();
}

void QgsLayerTreeViewDefaultActions::zoomToLayers()
{
QAction *s = qobject_cast<QAction *>( sender() );
QgsMapCanvas *canvas = reinterpret_cast<QgsMapCanvas *>( s->data().value<void *>() );
QApplication::setOverrideCursor( Qt::WaitCursor );
zoomToLayers( canvas );
QApplication::restoreOverrideCursor();
}

void QgsLayerTreeViewDefaultActions::zoomToSelection()
{
QAction *s = qobject_cast<QAction *>( sender() );
@@ -57,7 +57,12 @@ class GUI_EXPORT QgsLayerTreeViewDefaultActions : public QObject
//! Action to check a group and all its parents
QAction *actionCheckAndAllParents( QObject *parent = nullptr );

QAction *actionZoomToLayer( QgsMapCanvas *canvas, QObject *parent = nullptr ) SIP_FACTORY;
/**
* \deprecated since QGIS 3.18, use actionZoomToLayers()
*/
Q_DECL_DEPRECATED QAction *actionZoomToLayer( QgsMapCanvas *canvas, QObject *parent = nullptr ) SIP_FACTORY;

QAction *actionZoomToLayers( QgsMapCanvas *canvas, QObject *parent = nullptr ) SIP_FACTORY;

/**
* Action to zoom to selected features of a vector layer
@@ -96,7 +101,12 @@ class GUI_EXPORT QgsLayerTreeViewDefaultActions : public QObject
*/
QAction *actionMutuallyExclusiveGroup( QObject *parent = nullptr ) SIP_FACTORY;

void zoomToLayer( QgsMapCanvas *canvas );
/**
* \deprecated since QGIS 3.18, use zoomToLayers()
*/
Q_DECL_DEPRECATED void zoomToLayer( QgsMapCanvas *canvas );

void zoomToLayers( QgsMapCanvas *canvas );

/**
* \see zoomToSelection()
@@ -113,7 +123,13 @@ class GUI_EXPORT QgsLayerTreeViewDefaultActions : public QObject
void removeGroupOrLayer();
void renameGroupOrLayer();
void showFeatureCount();
void zoomToLayer();

/**
* \deprecated since QGIS 3.18, use zoomToLayers()
*/
Q_DECL_DEPRECATED void zoomToLayer();

void zoomToLayers();

/**
* Slot to zoom to selected features of a vector layer
@@ -476,7 +476,7 @@ class GUI_EXPORT QgisInterface : public QObject
//! Returns the native zoom full extent action. Call trigger() on it to zoom to the full extent.
virtual QAction *actionZoomFullExtent() = 0;
//! Returns the native zoom to layer action. Call trigger() on it to zoom to the active layer.
virtual QAction *actionZoomToLayer() = 0;
virtual QAction *actionZoomToLayers() = 0;
//! Returns the native zoom to selected action. Call trigger() on it to zoom to the current selection.
virtual QAction *actionZoomToSelected() = 0;
//! Returns the native zoom last action. Call trigger() on it to zoom to last.
@@ -135,7 +135,7 @@
<addaction name="separator"/>
<addaction name="mActionZoomFullExtent"/>
<addaction name="mActionZoomToSelected"/>
<addaction name="mActionZoomToLayer"/>
<addaction name="mActionZoomToLayers"/>
<addaction name="mActionZoomActualSize"/>
<addaction name="mActionZoomLast"/>
<addaction name="mActionZoomNext"/>
@@ -537,7 +537,7 @@
<addaction name="mActionZoomOut"/>
<addaction name="mActionZoomFullExtent"/>
<addaction name="mActionZoomToSelected"/>
<addaction name="mActionZoomToLayer"/>
<addaction name="mActionZoomToLayers"/>
<addaction name="mActionZoomActualSize"/>
<addaction name="mActionZoomLast"/>
<addaction name="mActionZoomNext"/>
@@ -1345,7 +1345,7 @@
<string>Ctrl+Shift+F</string>
</property>
</action>
<action name="mActionZoomToLayer">
<action name="mActionZoomToLayers">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionZoomToLayer.svg</normaloff>:/images/themes/default/mActionZoomToLayer.svg</iconset>

0 comments on commit 9fee766

Please sign in to comment.
You can’t perform that action at this time.