Skip to content

Commit

Permalink
Standardise some layout api method naming/behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 7, 2018
1 parent 71a33e9 commit 53b6706
Show file tree
Hide file tree
Showing 33 changed files with 142 additions and 239 deletions.
14 changes: 7 additions & 7 deletions python/core/layout/qgslayoutitem.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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()`

Expand All @@ -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()`

Expand All @@ -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()`

Expand All @@ -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()`

Expand Down
9 changes: 4 additions & 5 deletions python/core/layout/qgslayoutitemlegend.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
27 changes: 4 additions & 23 deletions python/core/layout/qgslayoutitemmapoverview.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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/ );
Expand Down
26 changes: 8 additions & 18 deletions python/core/layout/qgslayoutitempicture.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions python/core/layout/qgslayoutitemscalebar.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/app/layout/qgslayoutapputils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void QgsLayoutAppUtils::registerGuiForKnownItemTypes()
}
if ( targetMap )
{
legend->setMap( targetMap );
legend->setLinkedMap( targetMap );
}

legend->updateLegend();
Expand Down Expand Up @@ -194,7 +194,7 @@ void QgsLayoutAppUtils::registerGuiForKnownItemTypes()
}
if ( targetMap )
{
scalebar->setMap( targetMap );
scalebar->setLinkedMap( targetMap );
scalebar->applyDefaultSize( scalebar->guessUnits() );
}
} );
Expand Down
4 changes: 2 additions & 2 deletions src/app/layout/qgslayoutlegendwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/layout/qgslayoutmapwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down Expand Up @@ -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();
}
Expand Down
13 changes: 6 additions & 7 deletions src/app/layout/qgslayoutpicturewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions src/app/layout/qgslayoutscalebarwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/core/layout/qgslayoutitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ bool QgsLayoutItem::requiresRasterization() const

double QgsLayoutItem::estimatedFrameBleed() const
{
if ( !hasFrame() )
if ( !frameEnabled() )
{
return 0;
}
Expand Down
14 changes: 7 additions & 7 deletions src/core/layout/qgslayoutitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions src/core/layout/qgslayoutitemlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
Expand Down

0 comments on commit 53b6706

Please sign in to comment.