Skip to content

Commit

Permalink
Merge branch 'master' into fixNoAttributeFormUpdateForRelatedLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Nov 24, 2021
2 parents e244076 + 112754f commit b0f85e0
Show file tree
Hide file tree
Showing 38 changed files with 817 additions and 131 deletions.
50 changes: 50 additions & 0 deletions python/core/auto_generated/layertree/qgslayertreegroup.sip.in
Expand Up @@ -16,6 +16,9 @@ Layer tree group node serves as a container for layers and further groups.

Group names do not need to be unique within one tree nor within one parent.

While a layer tree group is typically used for hierarchical organisation of a :py:class:`QgsProject`,
they can optionally be associated with a :py:class:`QgsGroupLayer` for map rendering purposes.

.. versionadded:: 2.4
%End

Expand Down Expand Up @@ -125,6 +128,8 @@ Find layer node representing the map layer specified by its ID. Searches recursi
Find all layer nodes. Searches recursively the whole sub-tree.
%End



QStringList findLayerIds() const;
%Docstring
Find layer IDs used in all layer nodes. Searches recursively the whole sub-tree.
Expand Down Expand Up @@ -206,6 +211,51 @@ The initial child index determines which child should be initially checked. The
of -1 will determine automatically (either first one currently checked or none)

.. versionadded:: 2.12
%End

QgsGroupLayer *groupLayer();
%Docstring
Returns a reference to the associated group layer, if the layer tree group will be treated
as group layer during map rendering.

.. seealso:: :py:func:`setGroupLayer`

.. seealso:: :py:func:`convertToGroupLayer`

.. versionadded:: 3.24
%End

void setGroupLayer( QgsGroupLayer *layer );
%Docstring
Sets the associated group ``layer``, if the layer tree group will be treated
as group layer during map rendering.

This method does not take ownership of the group layer, and only a weak reference
to the layer is stored.

.. seealso:: :py:func:`groupLayer`

.. seealso:: :py:func:`convertToGroupLayer`

.. versionadded:: 3.24
%End

QgsGroupLayer *convertToGroupLayer( const QgsGroupLayer::LayerOptions &options ) /Factory/;
%Docstring
Converts the group to a :py:class:`QgsGroupLayer`.

This method will convert the layer tree group to an equivalent :py:class:`QgsGroupLayer`, and
return the result. The caller takes ownership of the returned layer, and it is the
caller's responsibility to add the layer to the associated :py:class:`QgsProject`.

If the group is already associated with a group layer (see :py:func:`~QgsLayerTreeGroup.groupLayer`), ``None``
will be returned.

.. seealso:: :py:func:`groupLayer`

.. seealso:: :py:func:`setGroupLayer`

.. versionadded:: 3.24
%End

protected slots:
Expand Down
10 changes: 8 additions & 2 deletions python/core/auto_generated/qgsmapsettings.sip.in
Expand Up @@ -234,23 +234,29 @@ Returns the magnification factor.
.. versionadded:: 2.16
%End

QStringList layerIds() const;
QStringList layerIds( bool expandGroupLayers = false ) const;
%Docstring
Returns the list of layer IDs which will be rendered in the map.

The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top).

Since QGIS 3.24, if the ``expandGroupLayers`` option is ``True`` then group layers will be converted to
all their child layers.

.. seealso:: :py:func:`layers`

.. seealso:: :py:func:`setLayers`
%End

QList<QgsMapLayer *> layers() const;
QList<QgsMapLayer *> layers( bool expandGroupLayers = false ) const;
%Docstring
Returns the list of layers which will be rendered in the map.

The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)

Since QGIS 3.24, if the ``expandGroupLayers`` option is ``True`` then group layers will be converted to
all their child layers.

.. seealso:: :py:func:`setLayers`

.. seealso:: :py:func:`layerIds`
Expand Down
37 changes: 35 additions & 2 deletions python/gui/auto_generated/qgsblendmodecombobox.sip.in
Expand Up @@ -27,12 +27,45 @@ Constructor for QgsBlendModeComboBox

QPainter::CompositionMode blendMode();
%Docstring
Function to read the selected blend mode as QPainter.CompositionMode
Returns the selected blend mode.

.. seealso:: :py:func:`setBlendMode`
%End

void setBlendMode( QPainter::CompositionMode blendMode );
%Docstring
Function to set the selected blend mode from QPainter.CompositionMode
Sets the selected blend mode.

.. seealso:: :py:func:`blendMode`
%End

void setShowClippingModes( bool show );
%Docstring
Sets whether composition modes which cause clipping are shown in the combo box.

By default, these composition modes (such as QPainter.CompositionMode.CompositionMode_DestinationIn )
are not shown in the combo box, as they can only be used with predictable results in a limited
set of circumstances. By setting ``show`` to ``True`` these additional composition modes
will be shown in the combo box.

.. seealso:: :py:func:`showClippingModes`

.. versionadded:: 3.24
%End

bool showClippingModes() const;
%Docstring
Returns ``True`` if composition modes which cause clipping are shown in the combo box.

By default, these composition modes (such as QPainter.CompositionMode.CompositionMode_DestinationIn )
are not shown in the combo box, as they can only be used with predictable results in a limited
set of circumstances.

.. seealso:: :py:func:`setShowClippingModes`

.. versionadded:: 3.24
%End

public slots:

void updateModes();
Expand Down
7 changes: 5 additions & 2 deletions python/gui/auto_generated/qgsmapcanvas.sip.in
Expand Up @@ -460,13 +460,16 @@ layers which may be visible in the canvas, but not associated with a :py:class:`

int layerCount() const;
%Docstring
Returns number of layers on the map
Returns number of layers on the map.
%End

QList<QgsMapLayer *> layers() const;
QList<QgsMapLayer *> layers( bool expandGroupLayers = false ) const;
%Docstring
Returns the list of layers shown within the map canvas.

Since QGIS 3.24, if the ``expandGroupLayers`` option is ``True`` then group layers will be converted to
all their child layers.

.. seealso:: :py:func:`setLayers`
%End

Expand Down
2 changes: 1 addition & 1 deletion src/app/3d/qgs3dmapcanvasdockwidget.cpp
Expand Up @@ -402,7 +402,7 @@ void Qgs3DMapCanvasDockWidget::exportScene()

void Qgs3DMapCanvasDockWidget::onMainCanvasLayersChanged()
{
mCanvas->map()->setLayers( mMainCanvas->layers() );
mCanvas->map()->setLayers( mMainCanvas->layers( true ) );
}

void Qgs3DMapCanvasDockWidget::onMainCanvasColorChanged()
Expand Down
2 changes: 1 addition & 1 deletion src/app/mesh/qgsmaptooleditmeshframe.cpp
Expand Up @@ -709,7 +709,7 @@ static QList<QgsMapToolIdentify::IdentifyResult> searchFeatureOnMap( QgsMapMouse
double x = mapPoint.x(), y = mapPoint.y();
const double sr = QgsMapTool::searchRadiusMU( canvas );

const QList<QgsMapLayer *> layers = canvas->layers();
const QList<QgsMapLayer *> layers = canvas->layers( true );
for ( QgsMapLayer *layer : layers )
{
if ( layer->type() == QgsMapLayerType::VectorLayer )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -13783,7 +13783,7 @@ void QgisApp::new3DMapCanvas()
map->setOrigin( QgsVector3D( fullExtent.center().x(), fullExtent.center().y(), 0 ) );
map->setSelectionColor( mMapCanvas->selectionColor() );
map->setBackgroundColor( mMapCanvas->canvasColor() );
map->setLayers( mMapCanvas->layers() );
map->setLayers( mMapCanvas->layers( true ) );
// map->setTerrainLayers( mMapCanvas->layers() );
map->setTemporalRange( mMapCanvas->temporalRange() );

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsdxfexportdialog.cpp
Expand Up @@ -349,7 +349,7 @@ void QgsVectorLayerAndAttributeModel::applyVisibilityPreset( const QString &name

if ( name.isEmpty() )
{
const auto constLayers = QgisApp::instance()->mapCanvas()->layers();
const auto constLayers = QgisApp::instance()->mapCanvas()->layers( true );
for ( const QgsMapLayer *ml : constLayers )
{
const QgsVectorLayer *vl = qobject_cast<const QgsVectorLayer *>( ml );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolfeatureaction.cpp
Expand Up @@ -63,7 +63,7 @@ void QgsMapToolFeatureAction::canvasReleaseEvent( QgsMapMouseEvent *e )
return;
}

if ( !mCanvas->layers().contains( layer ) )
if ( !mCanvas->layers( true ).contains( layer ) )
{
// do not run actions on hidden layers
return;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolselectionhandler.cpp
Expand Up @@ -255,7 +255,7 @@ void QgsMapToolSelectionHandler::selectPolygonPressEvent( QgsMapMouseEvent *e )
double x = mapPoint.x(), y = mapPoint.y();
const double sr = QgsMapTool::searchRadiusMU( mCanvas );

const QList<QgsMapLayer *> layers = mCanvas->layers();
const QList<QgsMapLayer *> layers = mCanvas->layers( true );
for ( auto layer : layers )
{
if ( layer->type() == QgsMapLayerType::VectorLayer )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolsplitfeatures.cpp
Expand Up @@ -118,7 +118,7 @@ void QgsMapToolSplitFeatures::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
! topologyTestPoints.isEmpty() )
{
//check if we need to add topological points to other layers
const auto layers = canvas()->layers();
const auto layers = canvas()->layers( true );
for ( QgsMapLayer *layer : layers )
{
QgsVectorLayer *vectorLayer = qobject_cast<QgsVectorLayer *>( layer );
Expand Down
10 changes: 5 additions & 5 deletions src/app/vertextool/qgsvertextool.cpp
Expand Up @@ -844,7 +844,7 @@ QgsPointLocator::Match QgsVertexTool::snapToEditableLayer( QgsMapMouseEvent *e )
{
if ( currentVlayer->isEditable() )
{
const auto layers = canvas()->layers();
const auto layers = canvas()->layers( true );
for ( QgsMapLayer *layer : layers )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
Expand Down Expand Up @@ -886,7 +886,7 @@ QgsPointLocator::Match QgsVertexTool::snapToEditableLayer( QgsMapMouseEvent *e )
// if there is no match from the current layer, try to use any editable vector layer
if ( !m.isValid() && mMode == AllLayers )
{
const auto layers = canvas()->layers();
const auto layers = canvas()->layers( true );
for ( QgsMapLayer *layer : layers )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
Expand Down Expand Up @@ -970,7 +970,7 @@ QgsPointLocator::Match QgsVertexTool::snapToPolygonInterior( QgsMapMouseEvent *e
// if there is no match from the current layer, try to use any editable vector layer
if ( !m.isValid() && mMode == AllLayers )
{
const auto layers = canvas()->layers();
const auto layers = canvas()->layers( true );
for ( QgsMapLayer *layer : layers )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
Expand Down Expand Up @@ -1039,7 +1039,7 @@ QSet<QPair<QgsVectorLayer *, QgsFeatureId> > QgsVertexTool::findAllEditableFeatu

if ( mMode == AllLayers )
{
const auto layers = canvas()->layers();
const auto layers = canvas()->layers( true );
for ( QgsMapLayer *layer : layers )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
Expand Down Expand Up @@ -1708,7 +1708,7 @@ void QgsVertexTool::startDragging( QgsMapMouseEvent *e )
QList<QgsVectorLayer *> QgsVertexTool::editableVectorLayers()
{
QList<QgsVectorLayer *> editableLayers;
const auto layers = canvas()->layers();
const auto layers = canvas()->layers( true );
for ( QgsMapLayer *layer : layers )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
Expand Down
4 changes: 2 additions & 2 deletions src/core/expression/qgsexpressioncontextutils.cpp
Expand Up @@ -469,7 +469,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::mapSettingsScope( const Qg

QVariantList layersIds;
QVariantList layers;
const QList<QgsMapLayer *> layersInMap = mapSettings.layers();
const QList<QgsMapLayer *> layersInMap = mapSettings.layers( true );
layersIds.reserve( layersInMap.count() );
layers.reserve( layersInMap.count() );
for ( QgsMapLayer *layer : layersInMap )
Expand All @@ -487,7 +487,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::mapSettingsScope( const Qg
// IMPORTANT: ANY CHANGES HERE ALSO NEED TO BE MADE TO QgsLayoutItemMap::createExpressionContext()
// (rationale is described in QgsLayoutItemMap::createExpressionContext() )

scope->addFunction( QStringLiteral( "is_layer_visible" ), new GetLayerVisibility( mapSettings.layers(), mapSettings.scale() ) );
scope->addFunction( QStringLiteral( "is_layer_visible" ), new GetLayerVisibility( mapSettings.layers( true ), mapSettings.scale() ) );

// IMPORTANT: ANY CHANGES HERE ALSO NEED TO BE MADE TO QgsLayoutItemMap::createExpressionContext()
// (rationale is described in QgsLayoutItemMap::createExpressionContext() )
Expand Down
13 changes: 1 addition & 12 deletions src/core/layertree/qgslayertree.cpp
Expand Up @@ -80,18 +80,7 @@ QList<QgsMapLayer *> QgsLayerTree::layerOrder() const
}
else
{
QList<QgsMapLayer *> layers;
const QList< QgsLayerTreeLayer * > foundLayers = findLayers();
for ( const auto &treeLayer : foundLayers )
{
QgsMapLayer *layer = treeLayer->layer();
if ( !layer || !layer->isSpatial() )
{
continue;
}
layers.append( layer );
}
return layers;
return layerOrderRespectingGroupLayers();
}
}

Expand Down

0 comments on commit b0f85e0

Please sign in to comment.