Skip to content
Permalink
Browse files

Standardise some layout api method naming/behavior

  • Loading branch information
nyalldawson committed Jan 7, 2018
1 parent 71a33e9 commit 53b67069cc16c53ff8b336f65cf461a8b9cc5522
Showing with 142 additions and 239 deletions.
  1. +7 −7 python/core/layout/qgslayoutitem.sip
  2. +4 −5 python/core/layout/qgslayoutitemlegend.sip
  3. +4 −23 python/core/layout/qgslayoutitemmapoverview.sip
  4. +8 −18 python/core/layout/qgslayoutitempicture.sip
  5. +4 −4 python/core/layout/qgslayoutitemscalebar.sip
  6. +2 −2 src/app/layout/qgslayoutapputils.cpp
  7. +2 −2 src/app/layout/qgslayoutlegendwidget.cpp
  8. +2 −2 src/app/layout/qgslayoutmapwidget.cpp
  9. +6 −7 src/app/layout/qgslayoutpicturewidget.cpp
  10. +2 −2 src/app/layout/qgslayoutscalebarwidget.cpp
  11. +1 −1 src/core/layout/qgslayoutitem.cpp
  12. +7 −7 src/core/layout/qgslayoutitem.h
  13. +3 −3 src/core/layout/qgslayoutitemlabel.cpp
  14. +3 −3 src/core/layout/qgslayoutitemlegend.cpp
  15. +4 −12 src/core/layout/qgslayoutitemlegend.h
  16. +4 −4 src/core/layout/qgslayoutitemmap.cpp
  17. +1 −1 src/core/layout/qgslayoutitemmapgrid.cpp
  18. +16 −33 src/core/layout/qgslayoutitemmapoverview.cpp
  19. +5 −21 src/core/layout/qgslayoutitemmapoverview.h
  20. +4 −19 src/core/layout/qgslayoutitempicture.cpp
  21. +9 −15 src/core/layout/qgslayoutitempicture.h
  22. +1 −1 src/core/layout/qgslayoutitemscalebar.cpp
  23. +4 −4 src/core/layout/qgslayoutitemscalebar.h
  24. +1 −1 src/core/layout/qgslayoutmultiframe.cpp
  25. +1 −1 src/gui/layout/qgslayoutitemwidget.cpp
  26. +1 −1 tests/src/core/testqgslayoutatlas.cpp
  27. +1 −1 tests/src/core/testqgslayoutitem.cpp
  28. +16 −20 tests/src/core/testqgslayoutmapoverview.cpp
  29. +5 −5 tests/src/core/testqgslayoutscalebar.cpp
  30. +2 −2 tests/src/python/test_qgslayoutatlas.py
  31. +4 −4 tests/src/python/test_qgslayoutlegend.py
  32. +4 −4 tests/src/python/test_qgslayoutmap.py
  33. +4 −4 tests/src/python/test_qgslayoutpicture.py
@@ -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()`

@@ -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();
@@ -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/ );
@@ -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;
@@ -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;
@@ -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() );
}
} );
@@ -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();
}
@@ -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();
}
@@ -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 );
@@ -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();
@@ -871,7 +871,7 @@ bool QgsLayoutItem::requiresRasterization() const

double QgsLayoutItem::estimatedFrameBleed() const
{
if ( !hasFrame() )
if ( !frameEnabled() )
{
return 0;
}
@@ -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()
@@ -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 )

0 comments on commit 53b6706

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