diff --git a/python/core/layout/qgslayoutitem.sip b/python/core/layout/qgslayoutitem.sip index 25316904ae0..dc68b6ef633 100644 --- a/python/core/layout/qgslayoutitem.sip +++ b/python/core/layout/qgslayoutitem.sip @@ -634,7 +634,7 @@ map item after restoration from XML. virtual QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id, QUndoCommand *parent = 0 ) /Factory/; - bool hasFrame() const; + bool frameEnabled() const; %Docstring Returns true if the item includes a frame. @@ -651,7 +651,7 @@ Returns true if the item includes a frame. %Docstring Sets whether this item has a frame drawn around it or not. -.. seealso:: :py:func:`hasFrame()` +.. seealso:: :py:func:`frameEnabled()` .. seealso:: :py:func:`setFrameStrokeWidth()` @@ -675,9 +675,9 @@ Sets the frame stroke ``color``. QColor frameStrokeColor() const; %Docstring -Returns the frame's stroke color. This is only used if hasFrame() returns true. +Returns the frame's stroke color. This is only used if frameEnabled() returns true. -.. seealso:: :py:func:`hasFrame()` +.. seealso:: :py:func:`frameEnabled()` .. seealso:: :py:func:`setFrameStrokeColor()` @@ -701,9 +701,9 @@ Sets the frame stroke ``width``. QgsLayoutMeasurement frameStrokeWidth() const; %Docstring -Returns the frame's stroke width. This is only used if hasFrame() returns true. +Returns the frame's stroke width. This is only used if frameEnabled() returns true. -.. seealso:: :py:func:`hasFrame()` +.. seealso:: :py:func:`frameEnabled()` .. seealso:: :py:func:`setFrameStrokeWidth()` @@ -716,7 +716,7 @@ Returns the frame's stroke width. This is only used if hasFrame() returns true. %Docstring Returns the join style used for drawing the item's frame. -.. seealso:: :py:func:`hasFrame()` +.. seealso:: :py:func:`frameEnabled()` .. seealso:: :py:func:`setFrameJoinStyle()` diff --git a/python/core/layout/qgslayoutitemlegend.sip b/python/core/layout/qgslayoutitemlegend.sip index b55ac052e6d..5fdd550d9b3 100644 --- a/python/core/layout/qgslayoutitemlegend.sip +++ b/python/core/layout/qgslayoutitemlegend.sip @@ -127,7 +127,6 @@ Find out whether legend items are filtered to show just the ones visible in the .. seealso:: :py:func:`setLegendFilterByMapEnabled()` %End - void setLegendFilterOutAtlas( bool doFilter ); %Docstring When set to true, during an atlas rendering, it will filter out legend elements @@ -452,18 +451,18 @@ only drawn if drawRasterStroke() is true. .. seealso:: :py:func:`setRasterStrokeColor()` %End - void setMap( QgsLayoutItemMap *map ); + void setLinkedMap( QgsLayoutItemMap *map ); %Docstring Sets the ``map`` to associate with the legend. -.. seealso:: :py:func:`map()` +.. seealso:: :py:func:`linkedMap()` %End - QgsLayoutItemMap *map() const; + QgsLayoutItemMap *linkedMap() const; %Docstring Returns the associated map. -.. seealso:: :py:func:`setMap()` +.. seealso:: :py:func:`setLinkedMap()` %End void updateLegend(); diff --git a/python/core/layout/qgslayoutitemmapoverview.sip b/python/core/layout/qgslayoutitemmapoverview.sip index 486c0f638c5..93db06098dc 100644 --- a/python/core/layout/qgslayoutitemmapoverview.sip +++ b/python/core/layout/qgslayoutitemmapoverview.sip @@ -141,37 +141,18 @@ Constructor for QgsLayoutItemMapOverview. virtual bool usesAdvancedEffects() const; - void setFrameMapUuid( const QString &uuid ); -%Docstring -Sets overview frame map ``uuid``. Set an empty ``uuid`` to disable -the overview frame. - -.. seealso:: :py:func:`frameMapUuid()` - -.. seealso:: :py:func:`setFrameMap()` -%End - - QString frameMapUuid() const; -%Docstring -Returns the uuid of source map, or an empty string if no map set. - -.. seealso:: :py:func:`setFrameMapUuid()` - -.. seealso:: :py:func:`frameMap()` -%End - - void setFrameMap( QgsLayoutItemMap *map ); + void setLinkedMap( QgsLayoutItemMap *map ); %Docstring Sets the ``map`` to show the overview extent of. -.. seealso:: :py:func:`frameMap()` +.. seealso:: :py:func:`linkedMap()` %End - QgsLayoutItemMap *frameMap(); + QgsLayoutItemMap *linkedMap(); %Docstring Returns the source map to show the overview extent of. -.. seealso:: :py:func:`setFrameMap()` +.. seealso:: :py:func:`setLinkedMap()` %End void setFrameSymbol( QgsFillSymbol *symbol /Transfer/ ); diff --git a/python/core/layout/qgslayoutitempicture.sip b/python/core/layout/qgslayoutitempicture.sip index cda40cc0be9..05c7b0ed029 100644 --- a/python/core/layout/qgslayoutitempicture.sip +++ b/python/core/layout/qgslayoutitempicture.sip @@ -93,36 +93,26 @@ in degrees clockwise. .. seealso:: :py:func:`rotationMap()` %End - void setRotationMap( const QString &uuid ); + void setLinkedMap( QgsLayoutItemMap *map ); %Docstring -Sets the map object for rotation (by ``uuid``). A empty string disables the map -rotation. If this is set then the picture will be rotated by the same +Sets the ``map`` object for rotation. + +If this is set then the picture will be rotated by the same amount as the specified map object. This is useful especially for syncing north arrows with a map item. .. seealso:: :py:func:`setPictureRotation()` -.. seealso:: :py:func:`rotationMap()` +.. seealso:: :py:func:`linkedMap()` %End - QString rotationMap() const; + QgsLayoutItemMap *linkedMap() const; %Docstring -Returns the uuid of the rotation map. An empty string means map rotation is +Returns the linked rotation map, if set. An None means map rotation is disabled. If this is set then the picture is rotated by the same amount as the specified map object. -.. seealso:: :py:func:`setRotationMap()` - -.. seealso:: :py:func:`useRotationMap()` -%End - - bool useRotationMap() const; -%Docstring -True if the picture rotation is matched to a map item. - -.. seealso:: :py:func:`rotationMap()` - -.. seealso:: :py:func:`setRotationMap()` +.. seealso:: :py:func:`setLinkedMap()` %End NorthMode northMode() const; diff --git a/python/core/layout/qgslayoutitemscalebar.sip b/python/core/layout/qgslayoutitemscalebar.sip index 973cc562e2c..f57ea1e600d 100644 --- a/python/core/layout/qgslayoutitemscalebar.sip +++ b/python/core/layout/qgslayoutitemscalebar.sip @@ -336,18 +336,18 @@ Sets the scalebar ``height`` (in millimeters). .. seealso:: :py:func:`height()` %End - void setMap( QgsLayoutItemMap *map ); + void setLinkedMap( QgsLayoutItemMap *map ); %Docstring Sets the ``map`` item linked to the scalebar. -.. seealso:: :py:func:`map()` +.. seealso:: :py:func:`linkedMap()` %End - QgsLayoutItemMap *map() const; + QgsLayoutItemMap *linkedMap() const; %Docstring Returns the map item linked to the scalebar. -.. seealso:: :py:func:`setMap()` +.. seealso:: :py:func:`setLinkedMap()` %End double labelBarSpace() const; diff --git a/src/app/layout/qgslayoutapputils.cpp b/src/app/layout/qgslayoutapputils.cpp index 93eb3102749..c7658b379bc 100644 --- a/src/app/layout/qgslayoutapputils.cpp +++ b/src/app/layout/qgslayoutapputils.cpp @@ -153,7 +153,7 @@ void QgsLayoutAppUtils::registerGuiForKnownItemTypes() } if ( targetMap ) { - legend->setMap( targetMap ); + legend->setLinkedMap( targetMap ); } legend->updateLegend(); @@ -194,7 +194,7 @@ void QgsLayoutAppUtils::registerGuiForKnownItemTypes() } if ( targetMap ) { - scalebar->setMap( targetMap ); + scalebar->setLinkedMap( targetMap ); scalebar->applyDefaultSize( scalebar->guessUnits() ); } } ); diff --git a/src/app/layout/qgslayoutlegendwidget.cpp b/src/app/layout/qgslayoutlegendwidget.cpp index cbf4e74044c..c9bc409bcf3 100644 --- a/src/app/layout/qgslayoutlegendwidget.cpp +++ b/src/app/layout/qgslayoutlegendwidget.cpp @@ -197,7 +197,7 @@ void QgsLayoutLegendWidget::setGuiElements() mFilterLegendByAtlasCheckBox->setChecked( mLegend->legendFilterOutAtlas() ); mWrapCharLineEdit->setText( mLegend->wrapString() ); - QgsLayoutItemMap *map = mLegend->map(); + QgsLayoutItemMap *map = mLegend->linkedMap(); mMapComboBox->setItem( map ); mFontColorButton->setColor( mLegend->fontColor() ); mTitleFontButton->setCurrentFont( mLegend->style( QgsLegendStyle::Title ).font() ); @@ -624,7 +624,7 @@ void QgsLayoutLegendWidget::composerMapChanged( QgsLayoutItem *item ) if ( map ) { mLegend->beginCommand( tr( "Change Legend Map" ) ); - mLegend->setMap( map ); + mLegend->setLinkedMap( map ); mLegend->updateFilterByMap(); mLegend->endCommand(); } diff --git a/src/app/layout/qgslayoutmapwidget.cpp b/src/app/layout/qgslayoutmapwidget.cpp index 8746c344af1..c40ea52e9c6 100644 --- a/src/app/layout/qgslayoutmapwidget.cpp +++ b/src/app/layout/qgslayoutmapwidget.cpp @@ -1470,7 +1470,7 @@ void QgsLayoutMapWidget::setOverviewItems( QgsLayoutItemMapOverview *overview ) mOverviewCheckBox->setChecked( overview->enabled() ); //overview frame - mOverviewFrameMapComboBox->setItem( overview->frameMap() ); + mOverviewFrameMapComboBox->setItem( overview->linkedMap() ); //overview frame blending mode mOverviewBlendModeComboBox->setBlendMode( overview->blendMode() ); @@ -1584,7 +1584,7 @@ void QgsLayoutMapWidget::overviewMapChanged( QgsLayoutItem *item ) return; mMapItem->beginCommand( tr( "Change Overview Map" ) ); - overview->setFrameMapUuid( map->uuid() ); + overview->setLinkedMap( map ); mMapItem->update(); mMapItem->endCommand(); } diff --git a/src/app/layout/qgslayoutpicturewidget.cpp b/src/app/layout/qgslayoutpicturewidget.cpp index 7c125de461a..b712a9e3243 100644 --- a/src/app/layout/qgslayoutpicturewidget.cpp +++ b/src/app/layout/qgslayoutpicturewidget.cpp @@ -314,7 +314,7 @@ void QgsLayoutPictureWidget::mRotationFromComposerMapCheckBox_stateChanged( int mPicture->beginCommand( tr( "Toggle Rotation Sync" ) ); if ( state == Qt::Unchecked ) { - mPicture->setRotationMap( QString() ); + mPicture->setLinkedMap( nullptr ); mPictureRotationSpinBox->setEnabled( true ); mComposerMapComboBox->setEnabled( false ); mNorthTypeComboBox->setEnabled( false ); @@ -323,9 +323,8 @@ void QgsLayoutPictureWidget::mRotationFromComposerMapCheckBox_stateChanged( int } else { - const QgsLayoutItemMap *map = qobject_cast< const QgsLayoutItemMap * >( mComposerMapComboBox->currentItem() ); - QString mapId = map ? map->uuid() : QString(); - mPicture->setRotationMap( mapId ); + QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap * >( mComposerMapComboBox->currentItem() ); + mPicture->setLinkedMap( map ); mPictureRotationSpinBox->setEnabled( false ); mNorthTypeComboBox->setEnabled( true ); mPictureRotationOffsetSpinBox->setEnabled( true ); @@ -355,7 +354,7 @@ void QgsLayoutPictureWidget::mapChanged( QgsLayoutItem *item ) } mPicture->beginCommand( tr( "Change Rotation Map" ) ); - mPicture->setRotationMap( map->uuid() ); + mPicture->setLinkedMap( map ); mPicture->update(); mPicture->endCommand(); } @@ -387,9 +386,9 @@ void QgsLayoutPictureWidget::setGuiElementValues() mPictureLineEdit->setText( mPicture->picturePath() ); mPictureRotationSpinBox->setValue( mPicture->pictureRotation() ); - mComposerMapComboBox->setItem( mPicture->layout()->itemByUuid( mPicture->rotationMap() ) ); + mComposerMapComboBox->setItem( mPicture->linkedMap() ); - if ( mPicture->useRotationMap() ) + if ( mPicture->linkedMap() ) { mRotationFromComposerMapCheckBox->setCheckState( Qt::Checked ); mPictureRotationSpinBox->setEnabled( false ); diff --git a/src/app/layout/qgslayoutscalebarwidget.cpp b/src/app/layout/qgslayoutscalebarwidget.cpp index d98a7b857b5..76ad9c43581 100644 --- a/src/app/layout/qgslayoutscalebarwidget.cpp +++ b/src/app/layout/qgslayoutscalebarwidget.cpp @@ -187,7 +187,7 @@ void QgsLayoutScaleBarWidget::setGuiElements() mFontButton->setCurrentFont( mScalebar->font() ); //map combo box - mMapItemComboBox->setItem( mScalebar->map() ); + mMapItemComboBox->setItem( mScalebar->linkedMap() ); //style... QString style = mScalebar->style(); @@ -674,7 +674,7 @@ void QgsLayoutScaleBarWidget::mapChanged( QgsLayoutItem *item ) //set it to scale bar mScalebar->beginCommand( tr( "Set Scalebar Map" ) ); disconnectUpdateSignal(); - mScalebar->setMap( map ); + mScalebar->setLinkedMap( map ); mScalebar->update(); connectUpdateSignal(); mScalebar->endCommand(); diff --git a/src/core/layout/qgslayoutitem.cpp b/src/core/layout/qgslayoutitem.cpp index 9dade563309..ac3d60158db 100644 --- a/src/core/layout/qgslayoutitem.cpp +++ b/src/core/layout/qgslayoutitem.cpp @@ -871,7 +871,7 @@ bool QgsLayoutItem::requiresRasterization() const double QgsLayoutItem::estimatedFrameBleed() const { - if ( !hasFrame() ) + if ( !frameEnabled() ) { return 0; } diff --git a/src/core/layout/qgslayoutitem.h b/src/core/layout/qgslayoutitem.h index 9ab297d820d..203b20ad883 100644 --- a/src/core/layout/qgslayoutitem.h +++ b/src/core/layout/qgslayoutitem.h @@ -612,11 +612,11 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt * \see frameJoinStyle() * \see frameStrokeColor() */ - bool hasFrame() const { return mFrame; } + bool frameEnabled() const { return mFrame; } /** * Sets whether this item has a frame drawn around it or not. - * \see hasFrame() + * \see frameEnabled() * \see setFrameStrokeWidth() * \see setFrameJoinStyle() * \see setFrameStrokeColor() @@ -633,8 +633,8 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt void setFrameStrokeColor( const QColor &color ); /** - * Returns the frame's stroke color. This is only used if hasFrame() returns true. - * \see hasFrame() + * Returns the frame's stroke color. This is only used if frameEnabled() returns true. + * \see frameEnabled() * \see setFrameStrokeColor() * \see frameJoinStyle() * \see setFrameStrokeColor() @@ -651,8 +651,8 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt virtual void setFrameStrokeWidth( const QgsLayoutMeasurement &width ); /** - * Returns the frame's stroke width. This is only used if hasFrame() returns true. - * \see hasFrame() + * Returns the frame's stroke width. This is only used if frameEnabled() returns true. + * \see frameEnabled() * \see setFrameStrokeWidth() * \see frameJoinStyle() * \see frameStrokeColor() @@ -661,7 +661,7 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt /** * Returns the join style used for drawing the item's frame. - * \see hasFrame() + * \see frameEnabled() * \see setFrameJoinStyle() * \see frameStrokeWidth() * \see frameStrokeColor() diff --git a/src/core/layout/qgslayoutitemlabel.cpp b/src/core/layout/qgslayoutitemlabel.cpp index 1f42fe46192..91788cb9d54 100644 --- a/src/core/layout/qgslayoutitemlabel.cpp +++ b/src/core/layout/qgslayoutitemlabel.cpp @@ -106,7 +106,7 @@ void QgsLayoutItemLabel::draw( QgsRenderContext &context, const QStyleOptionGrap // painter is scaled to dots, so scale back to layout units painter->scale( context.scaleFactor(), context.scaleFactor() ); - double penWidth = hasFrame() ? ( pen().widthF() / 2.0 ) : 0; + double penWidth = frameEnabled() ? ( pen().widthF() / 2.0 ) : 0; double xPenAdjust = mMarginX < 0 ? -penWidth : penWidth; double yPenAdjust = mMarginY < 0 ? -penWidth : penWidth; QRectF painterRect( xPenAdjust + mMarginX, yPenAdjust + mMarginY, rect().width() - 2 * xPenAdjust - 2 * mMarginX, rect().height() - 2 * yPenAdjust - 2 * mMarginY ); @@ -332,7 +332,7 @@ QSizeF QgsLayoutItemLabel::sizeForText() const double textWidth = QgsLayoutUtils::textWidthMM( mFont, currentText() ); double fontHeight = QgsLayoutUtils::fontHeightMM( mFont ); - double penWidth = hasFrame() ? ( pen().widthF() / 2.0 ) : 0; + double penWidth = frameEnabled() ? ( pen().widthF() / 2.0 ) : 0; double width = textWidth + 2 * mMarginX + 2 * penWidth + 1; double height = fontHeight + 2 * mMarginY + 2 * penWidth; @@ -456,7 +456,7 @@ QString QgsLayoutItemLabel::displayName() const QRectF QgsLayoutItemLabel::boundingRect() const { QRectF rectangle = rect(); - double penWidth = hasFrame() ? ( pen().widthF() / 2.0 ) : 0; + double penWidth = frameEnabled() ? ( pen().widthF() / 2.0 ) : 0; rectangle.adjust( -penWidth, -penWidth, penWidth, penWidth ); if ( mMarginX < 0 ) diff --git a/src/core/layout/qgslayoutitemlegend.cpp b/src/core/layout/qgslayoutitemlegend.cpp index 76422ab0044..58b85eb4239 100644 --- a/src/core/layout/qgslayoutitemlegend.cpp +++ b/src/core/layout/qgslayoutitemlegend.cpp @@ -134,7 +134,7 @@ void QgsLayoutItemLegend::finalizeRestoreFromXml() #endif if ( !mMapUuid.isEmpty() ) { - setMap( qobject_cast< QgsLayoutItemMap * >( mLayout->itemByUuid( mMapUuid, true ) ) ); + setLinkedMap( qobject_cast< QgsLayoutItemMap * >( mLayout->itemByUuid( mMapUuid, true ) ) ); } } @@ -638,7 +638,7 @@ QString QgsLayoutItemLegend::displayName() const } } -void QgsLayoutItemLegend::setMap( QgsLayoutItemMap *map ) +void QgsLayoutItemLegend::setLinkedMap( QgsLayoutItemMap *map ) { if ( mMap ) { @@ -663,7 +663,7 @@ void QgsLayoutItemLegend::setMap( QgsLayoutItemMap *map ) void QgsLayoutItemLegend::invalidateCurrentMap() { - setMap( nullptr ); + setLinkedMap( nullptr ); } void QgsLayoutItemLegend::refreshDataDefinedProperty( const QgsLayoutObject::DataDefinedProperty property ) diff --git a/src/core/layout/qgslayoutitemlegend.h b/src/core/layout/qgslayoutitemlegend.h index 37aad384409..0abe9d25728 100644 --- a/src/core/layout/qgslayoutitemlegend.h +++ b/src/core/layout/qgslayoutitemlegend.h @@ -131,14 +131,6 @@ class CORE_EXPORT QgsLayoutItemLegend : public QgsLayoutItem */ bool legendFilterByMapEnabled() const { return mLegendFilterByMap; } -#if 0//TODO - - /** - * Update() overloading. Use it rather than update() - */ - virtual void updateItem() override; -#endif - /** * When set to true, during an atlas rendering, it will filter out legend elements * where features are outside the current atlas feature. @@ -414,15 +406,15 @@ class CORE_EXPORT QgsLayoutItemLegend : public QgsLayoutItem /** * Sets the \a map to associate with the legend. - * \see map() + * \see linkedMap() */ - void setMap( QgsLayoutItemMap *map ); + void setLinkedMap( QgsLayoutItemMap *map ); /** * Returns the associated map. - * \see setMap() + * \see setLinkedMap() */ - QgsLayoutItemMap *map() const { return mMap; } + QgsLayoutItemMap *linkedMap() const { return mMap; } /** * Updates the model and all legend entries. diff --git a/src/core/layout/qgslayoutitemmap.cpp b/src/core/layout/qgslayoutitemmap.cpp index 9a466b869e7..005a97ea609 100644 --- a/src/core/layout/qgslayoutitemmap.cpp +++ b/src/core/layout/qgslayoutitemmap.cpp @@ -938,7 +938,7 @@ int QgsLayoutItemMap::numberExportLayers() const + layersToRender().length() + 1 // for grids, if they exist + 1 // for overviews, if they exist - + ( hasFrame() ? 1 : 0 ); + + ( frameEnabled() ? 1 : 0 ); } void QgsLayoutItemMap::setFrameStrokeWidth( const QgsLayoutMeasurement &width ) @@ -1226,7 +1226,7 @@ void QgsLayoutItemMap::invalidateCache() void QgsLayoutItemMap::updateBoundingRect() { QRectF rectangle = rect(); - double frameExtension = hasFrame() ? pen().widthF() / 2.0 : 0.0; + double frameExtension = frameEnabled() ? pen().widthF() / 2.0 : 0.0; double topExtension = 0.0; double rightExtension = 0.0; @@ -1605,7 +1605,7 @@ QPointF QgsLayoutItemMap::layoutMapPosForItem( const QgsAnnotation *annotation ) void QgsLayoutItemMap::drawMapFrame( QPainter *p ) { - if ( hasFrame() && p ) + if ( frameEnabled() && p ) { p->save(); p->setPen( pen() ); @@ -1649,7 +1649,7 @@ bool QgsLayoutItemMap::shouldDrawPart( QgsLayoutItemMap::PartType part ) const } } - if ( hasFrame() ) + if ( frameEnabled() ) { --idx; if ( Frame == part ) diff --git a/src/core/layout/qgslayoutitemmapgrid.cpp b/src/core/layout/qgslayoutitemmapgrid.cpp index b7a28ec779c..a20f9f3a88f 100644 --- a/src/core/layout/qgslayoutitemmapgrid.cpp +++ b/src/core/layout/qgslayoutitemmapgrid.cpp @@ -1880,7 +1880,7 @@ QgsLayoutItemMapGrid::BorderSide QgsLayoutItemMapGrid::borderForLineCoord( QPoin return QgsLayoutItemMapGrid::Left; } - double tolerance = std::max( mMap->hasFrame() ? mMap->pen().widthF() : 0.0, 1.0 ); + double tolerance = std::max( mMap->frameEnabled() ? mMap->pen().widthF() : 0.0, 1.0 ); //check for corner coordinates if ( ( p.y() <= tolerance && p.x() <= tolerance ) // top left diff --git a/src/core/layout/qgslayoutitemmapoverview.cpp b/src/core/layout/qgslayoutitemmapoverview.cpp index 944bf0587f7..b8df92d3e6c 100644 --- a/src/core/layout/qgslayoutitemmapoverview.cpp +++ b/src/core/layout/qgslayoutitemmapoverview.cpp @@ -46,7 +46,7 @@ void QgsLayoutItemMapOverview::createDefaultFrameSymbol() void QgsLayoutItemMapOverview::draw( QPainter *painter ) { - if ( !mEnabled || mFrameMapId.isEmpty() || !mMap || !mMap->layout() ) + if ( !mEnabled || !mFrameMap || !mMap || !mMap->layout() ) { return; } @@ -55,7 +55,7 @@ void QgsLayoutItemMapOverview::draw( QPainter *painter ) return; } - const QgsLayoutItemMap *overviewFrameMap = frameMap(); + const QgsLayoutItemMap *overviewFrameMap = linkedMap(); if ( !overviewFrameMap ) { return; @@ -155,7 +155,7 @@ bool QgsLayoutItemMapOverview::writeXml( QDomElement &elem, QDomDocument &doc, c //overview map frame QDomElement overviewFrameElem = doc.createElement( QStringLiteral( "ComposerMapOverview" ) ); - overviewFrameElem.setAttribute( QStringLiteral( "frameMap" ), mFrameMapId ); + overviewFrameElem.setAttribute( QStringLiteral( "frameMap" ), mFrameMap ? mFrameMap ->uuid() : QString() ); overviewFrameElem.setAttribute( QStringLiteral( "blendMode" ), QgsPainting::getBlendModeEnum( mBlendMode ) ); overviewFrameElem.setAttribute( QStringLiteral( "inverted" ), mInverted ); overviewFrameElem.setAttribute( QStringLiteral( "centered" ), mCentered ); @@ -198,38 +198,29 @@ bool QgsLayoutItemMapOverview::usesAdvancedEffects() const return mBlendMode != QPainter::CompositionMode_SourceOver; } -void QgsLayoutItemMapOverview::setFrameMapUuid( const QString &mapId ) +void QgsLayoutItemMapOverview::setLinkedMap( QgsLayoutItemMap *map ) { - if ( mFrameMapId == mapId ) + if ( mFrameMap == map ) { //no change return; } //disconnect old map - if ( QgsLayoutItemMap *map = frameMap() ) + if ( mFrameMap ) { - disconnect( map, &QgsLayoutItemMap::extentChanged, this, &QgsLayoutItemMapOverview::overviewExtentChanged ); - disconnect( map, &QgsLayoutItemMap::mapRotationChanged, this, &QgsLayoutItemMapOverview::overviewExtentChanged ); + disconnect( mFrameMap, &QgsLayoutItemMap::extentChanged, this, &QgsLayoutItemMapOverview::overviewExtentChanged ); + disconnect( mFrameMap, &QgsLayoutItemMap::mapRotationChanged, this, &QgsLayoutItemMapOverview::overviewExtentChanged ); } - mFrameMapId = mapId; + mFrameMap = map; //connect to new map signals connectSignals(); mMap->update(); } -void QgsLayoutItemMapOverview::setFrameMap( QgsLayoutItemMap *map ) +QgsLayoutItemMap *QgsLayoutItemMapOverview::linkedMap() { - setFrameMapUuid( map ? map->uuid() : QString() ); -} - -QgsLayoutItemMap *QgsLayoutItemMapOverview::frameMap() -{ - if ( !mFrameMapId.isEmpty() && mMap && mMap->layout() ) - { - return dynamic_cast< QgsLayoutItemMap * >( mMap->layout()->itemByUuid( mFrameMapId ) ); - } - return nullptr; + return mFrameMap; } void QgsLayoutItemMapOverview::connectSignals() @@ -239,10 +230,10 @@ void QgsLayoutItemMapOverview::connectSignals() return; } - if ( QgsLayoutItemMap *map = frameMap() ) + if ( mFrameMap ) { - connect( map, &QgsLayoutItemMap::extentChanged, this, &QgsLayoutItemMapOverview::overviewExtentChanged ); - connect( map, &QgsLayoutItemMap::mapRotationChanged, this, &QgsLayoutItemMapOverview::overviewExtentChanged ); + connect( mFrameMap, &QgsLayoutItemMap::extentChanged, this, &QgsLayoutItemMapOverview::overviewExtentChanged ); + connect( mFrameMap, &QgsLayoutItemMap::mapRotationChanged, this, &QgsLayoutItemMapOverview::overviewExtentChanged ); } } @@ -285,18 +276,10 @@ void QgsLayoutItemMapOverview::overviewExtentChanged() } //if using overview centering, update the map's extent - if ( mMap->layout() && mCentered && !mFrameMapId.isEmpty() ) + if ( mMap->layout() && mCentered && mFrameMap ) { QgsRectangle extent = mMap->extent(); - - QgsLayoutItemMap *overviewFrameMap = frameMap(); - if ( !overviewFrameMap ) - { - //redraw map so that overview gets updated - mMap->update(); - return; - } - QgsRectangle otherExtent = overviewFrameMap->extent(); + QgsRectangle otherExtent = mFrameMap->extent(); QgsPointXY center = otherExtent.center(); QgsRectangle movedExtent( center.x() - extent.width() / 2, diff --git a/src/core/layout/qgslayoutitemmapoverview.h b/src/core/layout/qgslayoutitemmapoverview.h index 0632a9b1ed7..bd76fed57d4 100644 --- a/src/core/layout/qgslayoutitemmapoverview.h +++ b/src/core/layout/qgslayoutitemmapoverview.h @@ -137,32 +137,17 @@ class CORE_EXPORT QgsLayoutItemMapOverview : public QgsLayoutItemMapItem bool readXml( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context ) override; bool usesAdvancedEffects() const override; - /** - * Sets overview frame map \a uuid. Set an empty \a uuid to disable - * the overview frame. - * \see frameMapUuid() - * \see setFrameMap() - */ - void setFrameMapUuid( const QString &uuid ); - - /** - * Returns the uuid of source map, or an empty string if no map set. - * \see setFrameMapUuid() - * \see frameMap() - */ - QString frameMapUuid() const { return mFrameMapId; } - /** * Sets the \a map to show the overview extent of. - * \see frameMap() + * \see linkedMap() */ - void setFrameMap( QgsLayoutItemMap *map ); + void setLinkedMap( QgsLayoutItemMap *map ); /** * Returns the source map to show the overview extent of. - * \see setFrameMap() + * \see setLinkedMap() */ - QgsLayoutItemMap *frameMap(); + QgsLayoutItemMap *linkedMap(); /** * Sets the fill \a symbol used for drawing the overview extent. Ownership @@ -239,8 +224,7 @@ class CORE_EXPORT QgsLayoutItemMapOverview : public QgsLayoutItemMapItem QgsLayoutItemMapOverview() = delete; - //! Uuid of map which displays its extent rectangle into this composer map (overview map functionality). Empty if not present. - QString mFrameMapId; + QPointer< QgsLayoutItemMap > mFrameMap; //! Drawing style for overview farme std::unique_ptr< QgsFillSymbol > mFrameSymbol; diff --git a/src/core/layout/qgslayoutitempicture.cpp b/src/core/layout/qgslayoutitempicture.cpp index e0c65f8c6ef..ad3b5b8c969 100644 --- a/src/core/layout/qgslayoutitempicture.cpp +++ b/src/core/layout/qgslayoutitempicture.cpp @@ -605,30 +605,20 @@ void QgsLayoutItemPicture::setPictureRotation( double rotation ) emit pictureRotationChanged( mPictureRotation ); } -void QgsLayoutItemPicture::setRotationMap( const QString &mapUuid ) +void QgsLayoutItemPicture::setLinkedMap( QgsLayoutItemMap *map ) { - if ( !mLayout ) - { - return; - } - if ( mRotationMap ) { disconnect( mRotationMap, &QgsLayoutItemMap::mapRotationChanged, this, &QgsLayoutItemPicture::updateMapRotation ); disconnect( mRotationMap, &QgsLayoutItemMap::extentChanged, this, &QgsLayoutItemPicture::updateMapRotation ); } - if ( mapUuid.isEmpty() ) //disable rotation from map + if ( !map ) //disable rotation from map { mRotationMap = nullptr; } else { - QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap * >( mLayout->itemByUuid( mapUuid ) ); - if ( !map ) - { - return; - } mPictureRotation = map->mapRotation(); connect( map, &QgsLayoutItemMap::mapRotationChanged, this, &QgsLayoutItemPicture::updateMapRotation ); connect( map, &QgsLayoutItemMap::extentChanged, this, &QgsLayoutItemPicture::updateMapRotation ); @@ -791,14 +781,9 @@ bool QgsLayoutItemPicture::readPropertiesFromElement( const QDomElement &itemEle return true; } -QString QgsLayoutItemPicture::rotationMap() const +QgsLayoutItemMap *QgsLayoutItemPicture::linkedMap() const { - return mRotationMap ? mRotationMap->uuid() : QString(); -} - -bool QgsLayoutItemPicture::useRotationMap() const -{ - return mRotationMap.data(); + return mRotationMap; } void QgsLayoutItemPicture::setNorthMode( QgsLayoutItemPicture::NorthMode mode ) diff --git a/src/core/layout/qgslayoutitempicture.h b/src/core/layout/qgslayoutitempicture.h index 2e8d2c5dcd3..eed74e6defc 100644 --- a/src/core/layout/qgslayoutitempicture.h +++ b/src/core/layout/qgslayoutitempicture.h @@ -107,30 +107,24 @@ class CORE_EXPORT QgsLayoutItemPicture: public QgsLayoutItem double pictureRotation() const { return mPictureRotation; } /** - * Sets the map object for rotation (by \a uuid). A empty string disables the map - * rotation. If this is set then the picture will be rotated by the same + * Sets the \a map object for rotation. + * + * If this is set then the picture will be rotated by the same * amount as the specified map object. This is useful especially for * syncing north arrows with a map item. + * * \see setPictureRotation() - * \see rotationMap() + * \see linkedMap() */ - void setRotationMap( const QString &uuid ); + void setLinkedMap( QgsLayoutItemMap *map ); /** - * Returns the uuid of the rotation map. An empty string means map rotation is + * Returns the linked rotation map, if set. An nullptr means map rotation is * disabled. If this is set then the picture is rotated by the same amount * as the specified map object. - * \see setRotationMap() - * \see useRotationMap() + * \see setLinkedMap() */ - QString rotationMap() const; - - /** - * True if the picture rotation is matched to a map item. - * \see rotationMap() - * \see setRotationMap() - */ - bool useRotationMap() const; + QgsLayoutItemMap *linkedMap() const; /** * Returns the mode used to align the picture to a map's North. diff --git a/src/core/layout/qgslayoutitemscalebar.cpp b/src/core/layout/qgslayoutitemscalebar.cpp index 7e5134b90e5..c2ef2397748 100644 --- a/src/core/layout/qgslayoutitemscalebar.cpp +++ b/src/core/layout/qgslayoutitemscalebar.cpp @@ -156,7 +156,7 @@ void QgsLayoutItemScaleBar::setBoxContentSpace( double space ) refreshItemSize(); } -void QgsLayoutItemScaleBar::setMap( QgsLayoutItemMap *map ) +void QgsLayoutItemScaleBar::setLinkedMap( QgsLayoutItemMap *map ) { disconnectCurrentMap(); diff --git a/src/core/layout/qgslayoutitemscalebar.h b/src/core/layout/qgslayoutitemscalebar.h index 3697b089ef2..0b66ab6dccf 100644 --- a/src/core/layout/qgslayoutitemscalebar.h +++ b/src/core/layout/qgslayoutitemscalebar.h @@ -291,15 +291,15 @@ class CORE_EXPORT QgsLayoutItemScaleBar: public QgsLayoutItem /** * Sets the \a map item linked to the scalebar. - * \see map() + * \see linkedMap() */ - void setMap( QgsLayoutItemMap *map ); + void setLinkedMap( QgsLayoutItemMap *map ); /** * Returns the map item linked to the scalebar. - * \see setMap() + * \see setLinkedMap() */ - QgsLayoutItemMap *map() const { return mMap; } + QgsLayoutItemMap *linkedMap() const { return mMap; } /** * Returns the spacing (in millimeters) between labels and the scalebar. diff --git a/src/core/layout/qgslayoutmultiframe.cpp b/src/core/layout/qgslayoutmultiframe.cpp index 1e5bffa63f2..df8f48e15b1 100644 --- a/src/core/layout/qgslayoutmultiframe.cpp +++ b/src/core/layout/qgslayoutmultiframe.cpp @@ -254,7 +254,7 @@ QgsLayoutFrame *QgsLayoutMultiFrame::createNewFrame( QgsLayoutFrame *currentFram newFrame->setBackgroundColor( currentFrame->backgroundColor() ); newFrame->setBackgroundEnabled( currentFrame->hasBackground() ); newFrame->setBlendMode( currentFrame->blendMode() ); - newFrame->setFrameEnabled( currentFrame->hasFrame() ); + newFrame->setFrameEnabled( currentFrame->frameEnabled() ); newFrame->setFrameStrokeColor( currentFrame->frameStrokeColor() ); newFrame->setFrameJoinStyle( currentFrame->frameJoinStyle() ); newFrame->setFrameStrokeWidth( currentFrame->frameStrokeWidth() ); diff --git a/src/gui/layout/qgslayoutitemwidget.cpp b/src/gui/layout/qgslayoutitemwidget.cpp index f5512d2edb6..1087f1893d0 100644 --- a/src/gui/layout/qgslayoutitemwidget.cpp +++ b/src/gui/layout/qgslayoutitemwidget.cpp @@ -606,7 +606,7 @@ void QgsLayoutItemPropertiesWidget::setValuesForGuiNonPositionElements() mStrokeWidthSpinBox->setValue( mItem->frameStrokeWidth().length() ); mFrameJoinStyleCombo->setPenJoinStyle( mItem->frameJoinStyle() ); mItemIdLineEdit->setText( mItem->id() ); - mFrameGroupBox->setChecked( mItem->hasFrame() ); + mFrameGroupBox->setChecked( mItem->frameEnabled() ); mBackgroundGroupBox->setChecked( mItem->hasBackground() ); mBlendModeCombo->setBlendMode( mItem->blendMode() ); mOpacityWidget->setOpacity( mItem->itemOpacity() ); diff --git a/tests/src/core/testqgslayoutatlas.cpp b/tests/src/core/testqgslayoutatlas.cpp index 6c16151391e..f76ffa91a26 100644 --- a/tests/src/core/testqgslayoutatlas.cpp +++ b/tests/src/core/testqgslayoutatlas.cpp @@ -149,7 +149,7 @@ void TestQgsLayoutAtlas::init() mOverview = new QgsLayoutItemMap( mLayout ); mOverview->attemptSetSceneRect( QRectF( 180, 20, 50, 50 ) ); mOverview->setFrameEnabled( true ); - mOverview->overview()->setFrameMap( mAtlasMap ); + mOverview->overview()->setLinkedMap( mAtlasMap ); mOverview->setLayers( QList() << mVectorLayer ); mLayout->addLayoutItem( mOverview ); mOverview->setExtent( QgsRectangle( 49670.718, 6415139.086, 699672.519, 7065140.887 ) ); diff --git a/tests/src/core/testqgslayoutitem.cpp b/tests/src/core/testqgslayoutitem.cpp index dcb1f9b4c8c..f9a6571d8b8 100644 --- a/tests/src/core/testqgslayoutitem.cpp +++ b/tests/src/core/testqgslayoutitem.cpp @@ -1657,7 +1657,7 @@ void TestQgsLayoutItem::writeReadXmlProperties() QVERIFY( copy->isLocked() ); QCOMPARE( copy->zValue(), 55.0 ); QVERIFY( !copy->isVisible() ); - QVERIFY( copy->hasFrame() ); + QVERIFY( copy->frameEnabled() ); QCOMPARE( copy->frameStrokeColor(), QColor( 100, 150, 200 ) ); QCOMPARE( copy->frameStrokeWidth(), QgsLayoutMeasurement( 5, QgsUnitTypes::LayoutCentimeters ) ); QCOMPARE( copy->frameJoinStyle(), Qt::MiterJoin ); diff --git a/tests/src/core/testqgslayoutmapoverview.cpp b/tests/src/core/testqgslayoutmapoverview.cpp index 67b3167215f..d6ed6e9a394 100644 --- a/tests/src/core/testqgslayoutmapoverview.cpp +++ b/tests/src/core/testqgslayoutmapoverview.cpp @@ -108,22 +108,18 @@ void TestQgsLayoutMapOverview::overviewMap() l.addLayoutItem( overviewMap ); map->setExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in overviewMap->setExtent( QgsRectangle( 0, -256, 256, 0 ) ); - overviewMap->overview()->setFrameMap( map ); + overviewMap->overview()->setLinkedMap( map ); - QCOMPARE( overviewMap->overview()->frameMap(), map ); - QCOMPARE( overviewMap->overview()->frameMapUuid(), map->uuid() ); - overviewMap->overview()->setFrameMap( nullptr ); - QVERIFY( !overviewMap->overview()->frameMap() ); - QVERIFY( overviewMap->overview()->frameMapUuid().isEmpty() ); - overviewMap->overview()->setFrameMapUuid( map->uuid() ); - QCOMPARE( overviewMap->overview()->frameMap(), map ); - QCOMPARE( overviewMap->overview()->frameMapUuid(), map->uuid() ); - overviewMap->overview()->setFrameMapUuid( QString() ); - QVERIFY( !overviewMap->overview()->frameMap() ); - QVERIFY( overviewMap->overview()->frameMapUuid().isEmpty() ); + QCOMPARE( overviewMap->overview()->linkedMap(), map ); + overviewMap->overview()->setLinkedMap( nullptr ); + QVERIFY( !overviewMap->overview()->linkedMap() ); + overviewMap->overview()->setLinkedMap( map ); + QCOMPARE( overviewMap->overview()->linkedMap(), map ); + overviewMap->overview()->setLinkedMap( nullptr ); + QVERIFY( !overviewMap->overview()->linkedMap() ); //render - overviewMap->overview()->setFrameMap( map ); + overviewMap->overview()->setLinkedMap( map ); QgsLayoutChecker checker( QStringLiteral( "composermap_overview" ), &l ); checker.setControlPathPrefix( QStringLiteral( "composer_mapoverview" ) ); @@ -149,7 +145,7 @@ void TestQgsLayoutMapOverview::overviewMapRotated() map->setExtent( QgsRectangle( 96, -144, 160, -112 ) ); //zoom in map->setMapRotation( 30 ); overviewMap->setExtent( QgsRectangle( 0, -256, 256, 0 ) ); - overviewMap->overview()->setFrameMap( map ); + overviewMap->overview()->setLinkedMap( map ); QgsLayoutChecker checker( QStringLiteral( "composermap_overview_rotated" ), &l ); checker.setControlPathPrefix( QStringLiteral( "composer_mapoverview" ) ); @@ -175,7 +171,7 @@ void TestQgsLayoutMapOverview::overviewMapRotated2() map->setExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in overviewMap->setMapRotation( 30 ); overviewMap->setExtent( QgsRectangle( 0, -256, 256, 0 ) ); - overviewMap->overview()->setFrameMap( map ); + overviewMap->overview()->setLinkedMap( map ); QgsLayoutChecker checker( QStringLiteral( "composermap_overview_rotated2" ), &l ); checker.setControlPathPrefix( QStringLiteral( "composer_mapoverview" ) ); @@ -200,7 +196,7 @@ void TestQgsLayoutMapOverview::overviewMapBlending() l.addLayoutItem( overviewMapBlend ); map->setExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in overviewMapBlend->setExtent( QgsRectangle( 0, -256, 256, 0 ) ); - overviewMapBlend->overview()->setFrameMap( map ); + overviewMapBlend->overview()->setLinkedMap( map ); overviewMapBlend->overview()->setBlendMode( QPainter::CompositionMode_Multiply ); QgsLayoutChecker checker( QStringLiteral( "composermap_overview_blending" ), &l ); @@ -227,7 +223,7 @@ void TestQgsLayoutMapOverview::overviewMapInvert() l.addLayoutItem( overviewMapInvert ); map->setExtent( QgsRectangle( 96, -152, 160, -120 ) ); //zoom in overviewMapInvert->setExtent( QgsRectangle( 0, -256, 256, 0 ) ); - overviewMapInvert->overview()->setFrameMap( map ); + overviewMapInvert->overview()->setLinkedMap( map ); overviewMapInvert->overview()->setInverted( true ); QgsLayoutChecker checker( QStringLiteral( "composermap_overview_invert" ), &l ); @@ -254,7 +250,7 @@ void TestQgsLayoutMapOverview::overviewMapCenter() l.addLayoutItem( overviewMapCenter ); map->setExtent( QgsRectangle( 192, -288, 320, -224 ) ); overviewMapCenter->setExtent( QgsRectangle( 0, -256, 256, 0 ) ); - overviewMapCenter->overview()->setFrameMap( map ); + overviewMapCenter->overview()->setLinkedMap( map ); overviewMapCenter->overview()->setCentered( true ); QgsLayoutChecker checker( QStringLiteral( "composermap_overview_center" ), &l ); @@ -285,7 +281,7 @@ void TestQgsLayoutMapOverview::overviewReprojected() map->setExtent( QgsRectangle( 93, -64.245, 120.6, -45 ) ); overviewMap->setExtent( QgsRectangle( 4712502, -7620278, 10872777, -2531356 ) ); - overviewMap->overview()->setFrameMap( map ); + overviewMap->overview()->setLinkedMap( map ); QgsLayoutChecker checker( QStringLiteral( "composermap_overview_reprojected" ), &l ); checker.setControlPathPrefix( QStringLiteral( "composer_mapoverview" ) ); diff --git a/tests/src/core/testqgslayoutscalebar.cpp b/tests/src/core/testqgslayoutscalebar.cpp index f3fd4ea82aa..296ac310fef 100644 --- a/tests/src/core/testqgslayoutscalebar.cpp +++ b/tests/src/core/testqgslayoutscalebar.cpp @@ -112,7 +112,7 @@ void TestQgsLayoutScaleBar::singleBox() QgsLayoutItemScaleBar *scalebar = new QgsLayoutItemScaleBar( &l ); scalebar->attemptSetSceneRect( QRectF( 20, 180, 50, 20 ) ); l.addLayoutItem( scalebar ); - scalebar->setMap( map ); + scalebar->setLinkedMap( map ); scalebar->setFont( QgsFontUtils::getStandardTestFont() ); scalebar->setUnits( QgsUnitTypes::DistanceMeters ); scalebar->setUnitsPerSegment( 2000 ); @@ -140,7 +140,7 @@ void TestQgsLayoutScaleBar::singleBoxAlpha() QgsLayoutItemScaleBar *scalebar = new QgsLayoutItemScaleBar( &l ); scalebar->attemptSetSceneRect( QRectF( 20, 180, 50, 20 ) ); l.addLayoutItem( scalebar ); - scalebar->setMap( map ); + scalebar->setLinkedMap( map ); scalebar->setFont( QgsFontUtils::getStandardTestFont() ); scalebar->setUnits( QgsUnitTypes::DistanceMeters ); scalebar->setUnitsPerSegment( 2000 ); @@ -173,7 +173,7 @@ void TestQgsLayoutScaleBar::doubleBox() QgsLayoutItemScaleBar *scalebar = new QgsLayoutItemScaleBar( &l ); scalebar->attemptSetSceneRect( QRectF( 20, 180, 50, 20 ) ); l.addLayoutItem( scalebar ); - scalebar->setMap( map ); + scalebar->setLinkedMap( map ); scalebar->setFont( QgsFontUtils::getStandardTestFont() ); scalebar->setUnits( QgsUnitTypes::DistanceMeters ); scalebar->setUnitsPerSegment( 2000 ); @@ -207,7 +207,7 @@ void TestQgsLayoutScaleBar::numeric() QgsLayoutItemScaleBar *scalebar = new QgsLayoutItemScaleBar( &l ); scalebar->attemptSetSceneRect( QRectF( 20, 180, 50, 20 ) ); l.addLayoutItem( scalebar ); - scalebar->setMap( map ); + scalebar->setLinkedMap( map ); scalebar->setFont( QgsFontUtils::getStandardTestFont() ); scalebar->setUnits( QgsUnitTypes::DistanceMeters ); scalebar->setUnitsPerSegment( 2000 ); @@ -240,7 +240,7 @@ void TestQgsLayoutScaleBar::tick() QgsLayoutItemScaleBar *scalebar = new QgsLayoutItemScaleBar( &l ); scalebar->attemptSetSceneRect( QRectF( 20, 180, 50, 20 ) ); l.addLayoutItem( scalebar ); - scalebar->setMap( map ); + scalebar->setLinkedMap( map ); scalebar->setFont( QgsFontUtils::getStandardTestFont() ); scalebar->setUnits( QgsUnitTypes::DistanceMeters ); scalebar->setUnitsPerSegment( 2000 ); diff --git a/tests/src/python/test_qgslayoutatlas.py b/tests/src/python/test_qgslayoutatlas.py index 6f60e337862..8a59578d395 100644 --- a/tests/src/python/test_qgslayoutatlas.py +++ b/tests/src/python/test_qgslayoutatlas.py @@ -117,7 +117,7 @@ class TestQgsLayoutAtlas(unittest.TestCase): self.overview = QgsLayoutItemMap(self.layout) self.overview.attemptSetSceneRect(QRectF(180, 20, 50, 50)) self.overview.setFrameEnabled(True) - self.overview.overview().setFrameMap(self.atlas_map) + self.overview.overview().setLinkedMap(self.atlas_map) self.overview.setLayers([mVectorLayer]) self.layout.addLayoutItem(self.overview) nextent = QgsRectangle(49670.718, 6415139.086, 699672.519, 7065140.887) @@ -543,7 +543,7 @@ class TestQgsLayoutAtlas(unittest.TestCase): legend = QgsLayoutItemLegend(self.layout) legend.attemptMove(QgsLayoutPoint(200, 100)) # sets the legend filter parameter - legend.setMap(self.atlas_map) + legend.setLinkedMap(self.atlas_map) legend.setLegendFilterOutAtlas(True) self.layout.addLayoutItem(legend) diff --git a/tests/src/python/test_qgslayoutlegend.py b/tests/src/python/test_qgslayoutlegend.py index 07a006e57dd..a0883a84e05 100644 --- a/tests/src/python/test_qgslayoutlegend.py +++ b/tests/src/python/test_qgslayoutlegend.py @@ -76,7 +76,7 @@ class TestQgsLayoutItemLegend(unittest.TestCase, LayoutItemTestCase): legend.setBackgroundColor(QColor(200, 200, 200)) legend.setTitle('') layout.addLayoutItem(legend) - legend.setMap(map) + legend.setLinkedMap(map) checker = QgsLayoutChecker( 'composer_legend_mapunits', layout) @@ -113,7 +113,7 @@ class TestQgsLayoutItemLegend(unittest.TestCase, LayoutItemTestCase): legend.setTitle('') legend.setLegendFilterByMapEnabled(True) layout.addLayoutItem(legend) - legend.setMap(map) + legend.setLinkedMap(map) map.setExtent(QgsRectangle(-102.51, 41.16, -102.36, 41.30)) @@ -156,7 +156,7 @@ class TestQgsLayoutItemLegend(unittest.TestCase, LayoutItemTestCase): legend.setResizeToContents(False) layout.addLayoutItem(legend) - legend.setMap(map) + legend.setLinkedMap(map) map.setExtent(QgsRectangle(-102.51, 41.16, -102.36, 41.30)) @@ -199,7 +199,7 @@ class TestQgsLayoutItemLegend(unittest.TestCase, LayoutItemTestCase): legend.setResizeToContents(False) layout.addLayoutItem(legend) - legend.setMap(map) + legend.setLinkedMap(map) map.setExtent(QgsRectangle(-102.51, 41.16, -102.36, 41.30)) diff --git a/tests/src/python/test_qgslayoutmap.py b/tests/src/python/test_qgslayoutmap.py index e99cdc00a18..7dcd8ffa7f7 100644 --- a/tests/src/python/test_qgslayoutmap.py +++ b/tests/src/python/test_qgslayoutmap.py @@ -95,7 +95,7 @@ class TestQgsComposerMap(unittest.TestCase, LayoutItemTestCase): self.map.setExtent(myRectangle) myRectangle2 = QgsRectangle(0, -256, 256, 0) overviewMap.setExtent(myRectangle2) - overviewMap.overview().setFrameMap(self.map) + overviewMap.overview().setLinkedMap(self.map) checker = QgsLayoutChecker('composermap_overview', self.layout) checker.setColorTolerance(6) checker.setControlPathPrefix("composer_mapoverview") @@ -115,7 +115,7 @@ class TestQgsComposerMap(unittest.TestCase, LayoutItemTestCase): self.map.setExtent(myRectangle) myRectangle2 = QgsRectangle(0, -256, 256, 0) overviewMap.setExtent(myRectangle2) - overviewMap.overview().setFrameMap(self.map) + overviewMap.overview().setLinkedMap(self.map) overviewMap.overview().setBlendMode(QPainter.CompositionMode_Multiply) checker = QgsLayoutChecker('composermap_overview_blending', self.layout) checker.setControlPathPrefix("composer_mapoverview") @@ -135,7 +135,7 @@ class TestQgsComposerMap(unittest.TestCase, LayoutItemTestCase): self.map.setExtent(myRectangle) myRectangle2 = QgsRectangle(0, -256, 256, 0) overviewMap.setExtent(myRectangle2) - overviewMap.overview().setFrameMap(self.map) + overviewMap.overview().setLinkedMap(self.map) overviewMap.overview().setInverted(True) checker = QgsLayoutChecker('composermap_overview_invert', self.layout) checker.setControlPathPrefix("composer_mapoverview") @@ -155,7 +155,7 @@ class TestQgsComposerMap(unittest.TestCase, LayoutItemTestCase): self.map.setExtent(myRectangle) myRectangle2 = QgsRectangle(0, -256, 256, 0) overviewMap.setExtent(myRectangle2) - overviewMap.overview().setFrameMap(self.map) + overviewMap.overview().setLinkedMap(self.map) overviewMap.overview().setInverted(False) overviewMap.overview().setCentered(True) checker = QgsLayoutChecker('composermap_overview_center', self.layout) diff --git a/tests/src/python/test_qgslayoutpicture.py b/tests/src/python/test_qgslayoutpicture.py index 8fb78e810f7..f57876599d4 100644 --- a/tests/src/python/test_qgslayoutpicture.py +++ b/tests/src/python/test_qgslayoutpicture.py @@ -104,8 +104,8 @@ class TestQgsLayoutPicture(unittest.TestCase, LayoutItemTestCase): picture = QgsLayoutItemPicture(layout) layout.addLayoutItem(picture) - picture.setRotationMap(map.uuid()) - self.assertEqual(picture.rotationMap(), map.uuid()) + picture.setLinkedMap(map) + self.assertEqual(picture.linkedMap(), map) picture.setNorthMode(QgsLayoutItemPicture.GridNorth) map.setMapRotation(45) @@ -129,8 +129,8 @@ class TestQgsLayoutPicture(unittest.TestCase, LayoutItemTestCase): picture = QgsLayoutItemPicture(layout) layout.addLayoutItem(picture) - picture.setRotationMap(map.uuid()) - self.assertEqual(picture.rotationMap(), map.uuid()) + picture.setLinkedMap(map) + self.assertEqual(picture.linkedMap(), map) picture.setNorthMode(QgsLayoutItemPicture.TrueNorth) self.assertAlmostEqual(picture.pictureRotation(), 37.20, 1)