mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Fix some clazy/clang warnings in layout
This commit is contained in:
parent
69201021d5
commit
fa68041793
@ -268,7 +268,7 @@ Returns the native units for the layout.
|
||||
.. seealso:: :py:func:`convertToLayoutUnits`
|
||||
%End
|
||||
|
||||
double convertToLayoutUnits( const QgsLayoutMeasurement &measurement ) const;
|
||||
double convertToLayoutUnits( QgsLayoutMeasurement measurement ) const;
|
||||
%Docstring
|
||||
Converts a measurement into the layout's native units.
|
||||
|
||||
@ -312,7 +312,7 @@ Converts a ``length`` measurement from the layout's native units to a specified
|
||||
.. seealso:: :py:func:`units`
|
||||
%End
|
||||
|
||||
QgsLayoutSize convertFromLayoutUnits( const QSizeF &size, QgsUnitTypes::LayoutUnit unit ) const;
|
||||
QgsLayoutSize convertFromLayoutUnits( QSizeF size, QgsUnitTypes::LayoutUnit unit ) const;
|
||||
%Docstring
|
||||
Converts a ``size`` from the layout's native units to a specified target ``unit``.
|
||||
|
||||
@ -323,7 +323,7 @@ Converts a ``size`` from the layout's native units to a specified target ``unit`
|
||||
.. seealso:: :py:func:`units`
|
||||
%End
|
||||
|
||||
QgsLayoutPoint convertFromLayoutUnits( const QPointF &point, QgsUnitTypes::LayoutUnit unit ) const;
|
||||
QgsLayoutPoint convertFromLayoutUnits( QPointF point, QgsUnitTypes::LayoutUnit unit ) const;
|
||||
%Docstring
|
||||
Converts a ``point`` from the layout's native units to a specified target ``unit``.
|
||||
|
||||
|
@ -37,7 +37,7 @@ Constructor for QgsLayoutGridSettings.
|
||||
virtual QgsLayout *layout();
|
||||
|
||||
|
||||
void setResolution( const QgsLayoutMeasurement &resolution );
|
||||
void setResolution( QgsLayoutMeasurement resolution );
|
||||
%Docstring
|
||||
Sets the page/snap grid ``resolution``.
|
||||
|
||||
@ -55,7 +55,7 @@ Returns the page/snap grid resolution.
|
||||
.. seealso:: :py:func:`offset`
|
||||
%End
|
||||
|
||||
void setOffset( QgsLayoutPoint offset );
|
||||
void setOffset( const QgsLayoutPoint &offset );
|
||||
%Docstring
|
||||
Sets the ``offset`` of the page/snap grid.
|
||||
|
||||
|
@ -21,7 +21,7 @@ Contains the configuration for a single snap guide used by a layout.
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsLayoutGuide( Qt::Orientation orientation, const QgsLayoutMeasurement &position, QgsLayoutItemPage *page );
|
||||
QgsLayoutGuide( Qt::Orientation orientation, QgsLayoutMeasurement position, QgsLayoutItemPage *page );
|
||||
%Docstring
|
||||
Constructor for a new guide with the specified ``orientation`` and
|
||||
initial ``position``.
|
||||
@ -67,7 +67,7 @@ of the guide, depending on the guide's orientation().
|
||||
.. seealso:: :py:func:`setPosition`
|
||||
%End
|
||||
|
||||
void setPosition( const QgsLayoutMeasurement &position );
|
||||
void setPosition( QgsLayoutMeasurement position );
|
||||
%Docstring
|
||||
Sets the guide's ``position`` within the page.
|
||||
|
||||
|
@ -382,7 +382,7 @@ content. Derived classes must not override this method, but instead implement
|
||||
the pure virtual method QgsLayoutItem.draw.
|
||||
%End
|
||||
|
||||
void setReferencePoint( const ReferencePoint &point );
|
||||
void setReferencePoint( ReferencePoint point );
|
||||
%Docstring
|
||||
Sets the reference ``point`` for positioning of the layout item. This point is also
|
||||
fixed during resizing of the item, and any size changes will be performed
|
||||
@ -661,7 +661,7 @@ Returns the frame's stroke color. This is only used if frameEnabled() returns tr
|
||||
.. seealso:: :py:func:`setFrameStrokeColor`
|
||||
%End
|
||||
|
||||
virtual void setFrameStrokeWidth( const QgsLayoutMeasurement &width );
|
||||
virtual void setFrameStrokeWidth( QgsLayoutMeasurement width );
|
||||
%Docstring
|
||||
Sets the frame stroke ``width``.
|
||||
|
||||
@ -948,7 +948,7 @@ If ``adjustPosition`` is false, rotation occurs around the item origin.
|
||||
.. seealso:: :py:func:`rotateItem`
|
||||
%End
|
||||
|
||||
virtual void rotateItem( double angle, const QPointF &transformOrigin );
|
||||
virtual void rotateItem( double angle, QPointF transformOrigin );
|
||||
%Docstring
|
||||
Rotates the item by a specified ``angle`` in degrees clockwise around a specified reference point.
|
||||
|
||||
@ -1031,7 +1031,7 @@ resized.
|
||||
.. seealso:: :py:func:`setFixedSize`
|
||||
%End
|
||||
|
||||
virtual QSizeF applyItemSizeConstraint( const QSizeF &targetSize );
|
||||
virtual QSizeF applyItemSizeConstraint( QSizeF targetSize );
|
||||
%Docstring
|
||||
Applies any item-specific size constraint handling to a given ``targetSize`` in layout units.
|
||||
Subclasses can override this method if they need to apply advanced logic regarding item
|
||||
@ -1102,13 +1102,13 @@ after the frame color is set and a later call to update() must be made.
|
||||
Refresh item's blend mode, considering data defined blend mode.
|
||||
%End
|
||||
|
||||
QPointF adjustPointForReferencePosition( const QPointF &point, const QSizeF &size, const ReferencePoint &reference ) const;
|
||||
QPointF adjustPointForReferencePosition( QPointF point, QSizeF size, ReferencePoint reference ) const;
|
||||
%Docstring
|
||||
Adjusts the specified ``point`` at which a ``reference`` position of the item
|
||||
sits and returns the top left corner of the item, if reference point were placed at the specified position.
|
||||
%End
|
||||
|
||||
QPointF positionAtReferencePoint( const ReferencePoint &reference ) const;
|
||||
QPointF positionAtReferencePoint( ReferencePoint reference ) const;
|
||||
%Docstring
|
||||
Returns the current position (in layout units) of a ``reference`` point for the item.
|
||||
%End
|
||||
|
@ -49,7 +49,7 @@ when converting measurements to and from pixels.
|
||||
.. seealso:: :py:func:`setDpi`
|
||||
%End
|
||||
|
||||
QgsLayoutMeasurement convert( const QgsLayoutMeasurement &measurement, QgsUnitTypes::LayoutUnit targetUnits ) const;
|
||||
QgsLayoutMeasurement convert( QgsLayoutMeasurement measurement, QgsUnitTypes::LayoutUnit targetUnits ) const;
|
||||
%Docstring
|
||||
Converts a measurement from one unit to another.
|
||||
|
||||
|
@ -66,7 +66,7 @@ Returns the page number for the specified ``page``, or -1 if the page
|
||||
is not contained in the collection.
|
||||
%End
|
||||
|
||||
QList< QgsLayoutItemPage * > visiblePages( QRectF region ) const;
|
||||
QList< QgsLayoutItemPage * > visiblePages( const QRectF ®ion ) const;
|
||||
%Docstring
|
||||
Returns a list of the pages which are visible within the specified
|
||||
``region`` (in layout coordinates).
|
||||
@ -74,7 +74,7 @@ Returns a list of the pages which are visible within the specified
|
||||
.. seealso:: :py:func:`visiblePageNumbers`
|
||||
%End
|
||||
|
||||
QList< int > visiblePageNumbers( QRectF region ) const;
|
||||
QList< int > visiblePageNumbers( const QRectF ®ion ) const;
|
||||
%Docstring
|
||||
Returns a list of the page numbers which are visible within the specified
|
||||
``region`` (in layout coordinates).
|
||||
|
@ -128,7 +128,7 @@ std::unique_ptr< QgsPrintLayout > QgsCompositionConverter::createLayoutFromCompo
|
||||
// Guides
|
||||
layout->guides().setVisible( composerElement.attribute( QStringLiteral( "guidesVisible" ), QStringLiteral( "1" ) ).toInt() != 0 );
|
||||
|
||||
int printResolution = composerElement.attribute( "printResolution", "300" ).toInt();
|
||||
int printResolution = composerElement.attribute( QStringLiteral( "printResolution" ), QStringLiteral( "300" ) ).toInt();
|
||||
layout->renderContext().setDpi( printResolution );
|
||||
|
||||
// Create pages
|
||||
@ -1563,7 +1563,7 @@ bool QgsCompositionConverter::readXml( QgsLayoutItem *layoutItem, const QDomElem
|
||||
group->addItem( layoutItem );
|
||||
}
|
||||
}
|
||||
layoutItem->mTemplateUuid = itemElem.attribute( "templateUuid" );
|
||||
layoutItem->mTemplateUuid = itemElem.attribute( QStringLiteral( "templateUuid" ) );
|
||||
|
||||
|
||||
QRectF position = itemPosition( layoutItem, itemElem );
|
||||
|
@ -322,7 +322,7 @@ QgsLayoutItem *QgsLayout::layoutItemAt( QPointF position, const QgsLayoutItem *b
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
double QgsLayout::convertToLayoutUnits( const QgsLayoutMeasurement &measurement ) const
|
||||
double QgsLayout::convertToLayoutUnits( QgsLayoutMeasurement measurement ) const
|
||||
{
|
||||
return mRenderContext->measurementConverter().convert( measurement, mUnits ).length();
|
||||
}
|
||||
@ -342,12 +342,12 @@ QgsLayoutMeasurement QgsLayout::convertFromLayoutUnits( const double length, con
|
||||
return mRenderContext->measurementConverter().convert( QgsLayoutMeasurement( length, mUnits ), unit );
|
||||
}
|
||||
|
||||
QgsLayoutSize QgsLayout::convertFromLayoutUnits( const QSizeF &size, const QgsUnitTypes::LayoutUnit unit ) const
|
||||
QgsLayoutSize QgsLayout::convertFromLayoutUnits( QSizeF size, const QgsUnitTypes::LayoutUnit unit ) const
|
||||
{
|
||||
return mRenderContext->measurementConverter().convert( QgsLayoutSize( size.width(), size.height(), mUnits ), unit );
|
||||
}
|
||||
|
||||
QgsLayoutPoint QgsLayout::convertFromLayoutUnits( const QPointF &point, const QgsUnitTypes::LayoutUnit unit ) const
|
||||
QgsLayoutPoint QgsLayout::convertFromLayoutUnits( QPointF point, const QgsUnitTypes::LayoutUnit unit ) const
|
||||
{
|
||||
return mRenderContext->measurementConverter().convert( QgsLayoutPoint( point.x(), point.y(), mUnits ), unit );
|
||||
}
|
||||
@ -839,7 +839,7 @@ bool QgsLayout::readXmlLayoutSettings( const QDomElement &layoutElement, const Q
|
||||
mCustomProperties.readXml( layoutElement );
|
||||
setUnits( QgsUnitTypes::decodeLayoutUnit( layoutElement.attribute( QStringLiteral( "units" ) ) ) );
|
||||
mWorldFileMapId = layoutElement.attribute( QStringLiteral( "worldFileMap" ) );
|
||||
mRenderContext->setDpi( layoutElement.attribute( QStringLiteral( "printResolution" ), "300" ).toDouble() );
|
||||
mRenderContext->setDpi( layoutElement.attribute( QStringLiteral( "printResolution" ), QStringLiteral( "300" ) ).toDouble() );
|
||||
emit changed();
|
||||
|
||||
return true;
|
||||
|
@ -333,7 +333,7 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
|
||||
* \see convertFromLayoutUnits()
|
||||
* \see units()
|
||||
*/
|
||||
double convertToLayoutUnits( const QgsLayoutMeasurement &measurement ) const;
|
||||
double convertToLayoutUnits( QgsLayoutMeasurement measurement ) const;
|
||||
|
||||
/**
|
||||
* Converts a size into the layout's native units.
|
||||
@ -365,7 +365,7 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
|
||||
* \see convertToLayoutUnits()
|
||||
* \see units()
|
||||
*/
|
||||
QgsLayoutSize convertFromLayoutUnits( const QSizeF &size, QgsUnitTypes::LayoutUnit unit ) const;
|
||||
QgsLayoutSize convertFromLayoutUnits( QSizeF size, QgsUnitTypes::LayoutUnit unit ) const;
|
||||
|
||||
/**
|
||||
* Converts a \a point from the layout's native units to a specified target \a unit.
|
||||
@ -373,7 +373,7 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
|
||||
* \see convertToLayoutUnits()
|
||||
* \see units()
|
||||
*/
|
||||
QgsLayoutPoint convertFromLayoutUnits( const QPointF &point, QgsUnitTypes::LayoutUnit unit ) const;
|
||||
QgsLayoutPoint convertFromLayoutUnits( QPointF point, QgsUnitTypes::LayoutUnit unit ) const;
|
||||
|
||||
/**
|
||||
* Returns a reference to the layout's render context, which stores information relating to the
|
||||
|
@ -304,7 +304,7 @@ int QgsLayoutAtlas::updateFeatures()
|
||||
if ( !mFeatureKeys.isEmpty() )
|
||||
{
|
||||
AtlasFeatureSorter sorter( mFeatureKeys, mSortAscending );
|
||||
std::sort( mFeatureIds.begin(), mFeatureIds.end(), sorter );
|
||||
std::sort( mFeatureIds.begin(), mFeatureIds.end(), sorter ); // clazy:exclude=detaching-member
|
||||
}
|
||||
|
||||
emit numberFeaturesChanged( mFeatureIds.size() );
|
||||
|
@ -264,8 +264,8 @@ QImage QgsLayoutExporter::renderRegionToImage( const QRectF ®ion, QSize image
|
||||
QImage image( QSize( width, height ), QImage::Format_ARGB32 );
|
||||
if ( !image.isNull() )
|
||||
{
|
||||
image.setDotsPerMeterX( resolution / 25.4 * 1000 );
|
||||
image.setDotsPerMeterY( resolution / 25.4 * 1000 );
|
||||
image.setDotsPerMeterX( static_cast< int >( std::round( resolution / 25.4 * 1000 ) ) );
|
||||
image.setDotsPerMeterY( static_cast< int>( std::round( resolution / 25.4 * 1000 ) ) );
|
||||
image.fill( Qt::transparent );
|
||||
QPainter imagePainter( &image );
|
||||
renderRegion( &imagePainter, region );
|
||||
@ -807,9 +807,9 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToSvg( const QString &f
|
||||
}
|
||||
|
||||
//width in pixel
|
||||
int width = ( int )( bounds.width() * settings.dpi / inchesToLayoutUnits );
|
||||
int width = static_cast< int >( bounds.width() * settings.dpi / inchesToLayoutUnits );
|
||||
//height in pixel
|
||||
int height = ( int )( bounds.height() * settings.dpi / inchesToLayoutUnits );
|
||||
int height = static_cast< int >( bounds.height() * settings.dpi / inchesToLayoutUnits );
|
||||
if ( width == 0 || height == 0 )
|
||||
{
|
||||
//invalid size, skip this page
|
||||
@ -899,7 +899,7 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToSvg( const QString &f
|
||||
generator.setOutputDevice( &svgBuffer );
|
||||
generator.setSize( QSize( width, height ) );
|
||||
generator.setViewBox( QRect( 0, 0, width, height ) );
|
||||
generator.setResolution( settings.dpi );
|
||||
generator.setResolution( static_cast< int >( std::round( settings.dpi ) ) );
|
||||
|
||||
QPainter p;
|
||||
bool createOk = p.begin( &generator );
|
||||
@ -1024,7 +1024,7 @@ void QgsLayoutExporter::preparePrint( QgsLayout *layout, QPrinter &printer, bool
|
||||
printer.setColorMode( QPrinter::Color );
|
||||
|
||||
//set user-defined resolution
|
||||
printer.setResolution( layout->renderContext().dpi() );
|
||||
printer.setResolution( static_cast< int>( std::round( layout->renderContext().dpi() ) ) );
|
||||
|
||||
if ( setFirstPageSize )
|
||||
{
|
||||
@ -1130,9 +1130,12 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::renderToLayeredSvg( const Svg
|
||||
}
|
||||
|
||||
generator.setOutputDevice( &svgBuffer );
|
||||
generator.setSize( QSize( width, height ) );
|
||||
generator.setViewBox( QRect( 0, 0, width, height ) );
|
||||
generator.setResolution( settings.dpi ); //because the rendering is done in mm, convert the dpi
|
||||
generator.setSize( QSize( static_cast< int >( std::round( width ) ),
|
||||
static_cast< int >( std::round( height ) ) ) );
|
||||
generator.setViewBox( QRect( 0, 0,
|
||||
static_cast< int >( std::round( width ) ),
|
||||
static_cast< int >( std::round( height ) ) ) );
|
||||
generator.setResolution( static_cast< int >( std::round( settings.dpi ) ) ); //because the rendering is done in mm, convert the dpi
|
||||
|
||||
QPainter svgPainter( &generator );
|
||||
if ( settings.cropToContents )
|
||||
@ -1141,9 +1144,9 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::renderToLayeredSvg( const Svg
|
||||
renderPage( &svgPainter, page );
|
||||
}
|
||||
|
||||
// post-process svg output to create groups in a single svg file
|
||||
// we create inkscape layers since it's nice and clean and free
|
||||
// and fully svg compatible
|
||||
// post-process svg output to create groups in a single svg file
|
||||
// we create inkscape layers since it's nice and clean and free
|
||||
// and fully svg compatible
|
||||
{
|
||||
svgBuffer.close();
|
||||
svgBuffer.open( QIODevice::ReadOnly );
|
||||
|
@ -36,14 +36,14 @@ QgsLayout *QgsLayoutGridSettings::layout()
|
||||
return mLayout;
|
||||
}
|
||||
|
||||
void QgsLayoutGridSettings::setResolution( const QgsLayoutMeasurement &resolution )
|
||||
void QgsLayoutGridSettings::setResolution( QgsLayoutMeasurement resolution )
|
||||
{
|
||||
mLayout->undoStack()->beginCommand( this, QObject::tr( "Change Grid Resolution" ), UndoGridResolution );
|
||||
mGridResolution = resolution;
|
||||
mLayout->undoStack()->endCommand();
|
||||
}
|
||||
|
||||
void QgsLayoutGridSettings::setOffset( const QgsLayoutPoint offset )
|
||||
void QgsLayoutGridSettings::setOffset( const QgsLayoutPoint &offset )
|
||||
{
|
||||
mLayout->undoStack()->beginCommand( this, QObject::tr( "Change Grid Offset" ), UndoGridOffset );
|
||||
mGridOffset = offset;
|
||||
|
@ -58,7 +58,7 @@ class CORE_EXPORT QgsLayoutGridSettings : public QgsLayoutSerializableObject
|
||||
* \see resolution()
|
||||
* \see setOffset()
|
||||
*/
|
||||
void setResolution( const QgsLayoutMeasurement &resolution );
|
||||
void setResolution( QgsLayoutMeasurement resolution );
|
||||
|
||||
/**
|
||||
* Returns the page/snap grid resolution.
|
||||
@ -72,7 +72,7 @@ class CORE_EXPORT QgsLayoutGridSettings : public QgsLayoutSerializableObject
|
||||
* \see offset()
|
||||
* \see setResolution()
|
||||
*/
|
||||
void setOffset( QgsLayoutPoint offset );
|
||||
void setOffset( const QgsLayoutPoint &offset );
|
||||
|
||||
/**
|
||||
* Returns the offset of the page/snap grid.
|
||||
|
@ -27,7 +27,7 @@
|
||||
// QgsLayoutGuide
|
||||
//
|
||||
|
||||
QgsLayoutGuide::QgsLayoutGuide( Qt::Orientation orientation, const QgsLayoutMeasurement &position, QgsLayoutItemPage *page )
|
||||
QgsLayoutGuide::QgsLayoutGuide( Qt::Orientation orientation, QgsLayoutMeasurement position, QgsLayoutItemPage *page )
|
||||
: QObject( nullptr )
|
||||
, mOrientation( orientation )
|
||||
, mPosition( position )
|
||||
@ -48,7 +48,7 @@ QgsLayoutMeasurement QgsLayoutGuide::position() const
|
||||
return mPosition;
|
||||
}
|
||||
|
||||
void QgsLayoutGuide::setPosition( const QgsLayoutMeasurement &position )
|
||||
void QgsLayoutGuide::setPosition( QgsLayoutMeasurement position )
|
||||
{
|
||||
mPosition = position;
|
||||
update();
|
||||
@ -299,7 +299,7 @@ bool QgsLayoutGuideCollection::setData( const QModelIndex &index, const QVariant
|
||||
return false;
|
||||
|
||||
QgsLayoutMeasurement m = guide->position();
|
||||
if ( m.length() == newPos )
|
||||
if ( qgsDoubleNear( m.length(), newPos ) )
|
||||
return true;
|
||||
|
||||
m.setLength( newPos );
|
||||
|
@ -54,7 +54,7 @@ class CORE_EXPORT QgsLayoutGuide : public QObject
|
||||
* Adding the guide to a QgsLayoutGuideCollection will automatically set
|
||||
* the corresponding layout for you.
|
||||
*/
|
||||
QgsLayoutGuide( Qt::Orientation orientation, const QgsLayoutMeasurement &position, QgsLayoutItemPage *page );
|
||||
QgsLayoutGuide( Qt::Orientation orientation, QgsLayoutMeasurement position, QgsLayoutItemPage *page );
|
||||
|
||||
~QgsLayoutGuide() override;
|
||||
|
||||
@ -97,7 +97,7 @@ class CORE_EXPORT QgsLayoutGuide : public QObject
|
||||
*
|
||||
* \see position()
|
||||
*/
|
||||
void setPosition( const QgsLayoutMeasurement &position );
|
||||
void setPosition( QgsLayoutMeasurement position );
|
||||
|
||||
/**
|
||||
* Returns the page the guide is contained within.
|
||||
|
@ -362,7 +362,7 @@ void QgsLayoutItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *it
|
||||
}
|
||||
}
|
||||
|
||||
void QgsLayoutItem::setReferencePoint( const QgsLayoutItem::ReferencePoint &point )
|
||||
void QgsLayoutItem::setReferencePoint( const QgsLayoutItem::ReferencePoint point )
|
||||
{
|
||||
if ( point == mReferencePoint )
|
||||
{
|
||||
@ -522,7 +522,7 @@ QgsLayoutPoint QgsLayoutItem::pagePositionWithUnits() const
|
||||
return mLayout->convertFromLayoutUnits( p, mItemPosition.units() );
|
||||
}
|
||||
|
||||
void QgsLayoutItem::setScenePos( const QPointF &destinationPos )
|
||||
void QgsLayoutItem::setScenePos( const QPointF destinationPos )
|
||||
{
|
||||
//since setPos does not account for item rotation, use difference between
|
||||
//current scenePos (which DOES account for rotation) and destination pos
|
||||
@ -570,16 +570,16 @@ bool QgsLayoutItem::writeXml( QDomElement &parentElement, QDomDocument &doc, con
|
||||
element.setAttribute( QStringLiteral( "itemRotation" ), QString::number( mItemRotation ) );
|
||||
element.setAttribute( QStringLiteral( "groupUuid" ), mParentGroupUuid );
|
||||
|
||||
element.setAttribute( "zValue", QString::number( zValue() ) );
|
||||
element.setAttribute( "visibility", isVisible() );
|
||||
element.setAttribute( QStringLiteral( "zValue" ), QString::number( zValue() ) );
|
||||
element.setAttribute( QStringLiteral( "visibility" ), isVisible() );
|
||||
//position lock for mouse moves/resizes
|
||||
if ( mIsLocked )
|
||||
{
|
||||
element.setAttribute( "positionLock", "true" );
|
||||
element.setAttribute( QStringLiteral( "positionLock" ), QStringLiteral( "true" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
element.setAttribute( "positionLock", "false" );
|
||||
element.setAttribute( QStringLiteral( "positionLock" ), QStringLiteral( "false" ) );
|
||||
}
|
||||
|
||||
//frame
|
||||
@ -621,12 +621,12 @@ bool QgsLayoutItem::writeXml( QDomElement &parentElement, QDomDocument &doc, con
|
||||
element.appendChild( bgColorElem );
|
||||
|
||||
//blend mode
|
||||
element.setAttribute( "blendMode", QgsPainting::getBlendModeEnum( mBlendMode ) );
|
||||
element.setAttribute( QStringLiteral( "blendMode" ), QgsPainting::getBlendModeEnum( mBlendMode ) );
|
||||
|
||||
//opacity
|
||||
element.setAttribute( QStringLiteral( "opacity" ), QString::number( mOpacity ) );
|
||||
|
||||
element.setAttribute( "excludeFromExports", mExcludeFromExports );
|
||||
element.setAttribute( QStringLiteral( "excludeFromExports" ), mExcludeFromExports );
|
||||
|
||||
writeObjectPropertiesToElement( element, doc, context );
|
||||
|
||||
@ -661,11 +661,11 @@ bool QgsLayoutItem::readXml( const QDomElement &element, const QDomDocument &doc
|
||||
group->addItem( this );
|
||||
}
|
||||
}
|
||||
mTemplateUuid = element.attribute( "templateUuid" );
|
||||
mTemplateUuid = element.attribute( QStringLiteral( "templateUuid" ) );
|
||||
|
||||
//position lock for mouse moves/resizes
|
||||
QString positionLock = element.attribute( "positionLock" );
|
||||
if ( positionLock.compare( "true", Qt::CaseInsensitive ) == 0 )
|
||||
QString positionLock = element.attribute( QStringLiteral( "positionLock" ) );
|
||||
if ( positionLock.compare( QStringLiteral( "true" ), Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
setLocked( true );
|
||||
}
|
||||
@ -674,8 +674,8 @@ bool QgsLayoutItem::readXml( const QDomElement &element, const QDomDocument &doc
|
||||
setLocked( false );
|
||||
}
|
||||
//visibility
|
||||
setVisibility( element.attribute( "visibility", "1" ) != "0" );
|
||||
setZValue( element.attribute( "zValue" ).toDouble() );
|
||||
setVisibility( element.attribute( QStringLiteral( "visibility" ), QStringLiteral( "1" ) ) != QLatin1String( "0" ) );
|
||||
setZValue( element.attribute( QStringLiteral( "zValue" ) ).toDouble() );
|
||||
|
||||
//frame
|
||||
QString frame = element.attribute( QStringLiteral( "frame" ) );
|
||||
@ -804,7 +804,7 @@ void QgsLayoutItem::setFrameStrokeColor( const QColor &color )
|
||||
emit frameChanged();
|
||||
}
|
||||
|
||||
void QgsLayoutItem::setFrameStrokeWidth( const QgsLayoutMeasurement &width )
|
||||
void QgsLayoutItem::setFrameStrokeWidth( const QgsLayoutMeasurement width )
|
||||
{
|
||||
if ( mFrameWidth == width )
|
||||
{
|
||||
@ -1089,7 +1089,7 @@ void QgsLayoutItem::updateStoredItemPosition()
|
||||
mItemPosition = mLayout->convertFromLayoutUnits( layoutPosReferencePoint, mItemPosition.units() );
|
||||
}
|
||||
|
||||
void QgsLayoutItem::rotateItem( const double angle, const QPointF &transformOrigin )
|
||||
void QgsLayoutItem::rotateItem( const double angle, const QPointF transformOrigin )
|
||||
{
|
||||
double evaluatedAngle = angle + rotation();
|
||||
evaluatedAngle = QgsLayoutUtils::normalizedAngle( evaluatedAngle, true );
|
||||
@ -1184,7 +1184,7 @@ void QgsLayoutItem::setMinimumSize( const QgsLayoutSize &size )
|
||||
refreshItemSize();
|
||||
}
|
||||
|
||||
QSizeF QgsLayoutItem::applyItemSizeConstraint( const QSizeF &targetSize )
|
||||
QSizeF QgsLayoutItem::applyItemSizeConstraint( const QSizeF targetSize )
|
||||
{
|
||||
return targetSize;
|
||||
}
|
||||
@ -1199,7 +1199,7 @@ void QgsLayoutItem::refreshItemPosition()
|
||||
attemptMove( mItemPosition );
|
||||
}
|
||||
|
||||
QPointF QgsLayoutItem::itemPositionAtReferencePoint( const ReferencePoint reference, const QSizeF &size ) const
|
||||
QPointF QgsLayoutItem::itemPositionAtReferencePoint( const ReferencePoint reference, const QSizeF size ) const
|
||||
{
|
||||
switch ( reference )
|
||||
{
|
||||
@ -1226,14 +1226,14 @@ QPointF QgsLayoutItem::itemPositionAtReferencePoint( const ReferencePoint refere
|
||||
return QPointF( 0, 0 );
|
||||
}
|
||||
|
||||
QPointF QgsLayoutItem::adjustPointForReferencePosition( const QPointF &position, const QSizeF &size, const ReferencePoint &reference ) const
|
||||
QPointF QgsLayoutItem::adjustPointForReferencePosition( const QPointF position, const QSizeF size, const ReferencePoint reference ) const
|
||||
{
|
||||
QPointF itemPosition = mapFromScene( position ); //need to map from scene to handle item rotation
|
||||
QPointF adjustedPointInsideItem = itemPosition - itemPositionAtReferencePoint( reference, size );
|
||||
return mapToScene( adjustedPointInsideItem );
|
||||
}
|
||||
|
||||
QPointF QgsLayoutItem::positionAtReferencePoint( const QgsLayoutItem::ReferencePoint &reference ) const
|
||||
QPointF QgsLayoutItem::positionAtReferencePoint( const QgsLayoutItem::ReferencePoint reference ) const
|
||||
{
|
||||
QPointF pointWithinItem = itemPositionAtReferencePoint( reference, rect().size() );
|
||||
return mapToScene( pointWithinItem );
|
||||
@ -1288,7 +1288,7 @@ bool QgsLayoutItem::shouldDrawDebugRect() const
|
||||
return mLayout && mLayout->renderContext().testFlag( QgsLayoutRenderContext::FlagDebug );
|
||||
}
|
||||
|
||||
QSizeF QgsLayoutItem::applyMinimumSize( const QSizeF &targetSize )
|
||||
QSizeF QgsLayoutItem::applyMinimumSize( const QSizeF targetSize )
|
||||
{
|
||||
if ( !mLayout || minimumSize().isEmpty() )
|
||||
{
|
||||
@ -1298,7 +1298,7 @@ QSizeF QgsLayoutItem::applyMinimumSize( const QSizeF &targetSize )
|
||||
return targetSize.expandedTo( minimumSizeLayoutUnits );
|
||||
}
|
||||
|
||||
QSizeF QgsLayoutItem::applyFixedSize( const QSizeF &targetSize )
|
||||
QSizeF QgsLayoutItem::applyFixedSize( const QSizeF targetSize )
|
||||
{
|
||||
if ( !mLayout || fixedSize().isEmpty() )
|
||||
{
|
||||
|
@ -411,7 +411,7 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
|
||||
* so that the position of the reference point within the layout remains unchanged.
|
||||
* \see referencePoint()
|
||||
*/
|
||||
void setReferencePoint( const ReferencePoint &point );
|
||||
void setReferencePoint( ReferencePoint point );
|
||||
|
||||
/**
|
||||
* Returns the reference point for positioning of the layout item. This point is also
|
||||
@ -641,7 +641,7 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
|
||||
* \see setFrameJoinStyle()
|
||||
* \see setFrameStrokeColor()
|
||||
*/
|
||||
virtual void setFrameStrokeWidth( const QgsLayoutMeasurement &width );
|
||||
virtual void setFrameStrokeWidth( QgsLayoutMeasurement width );
|
||||
|
||||
/**
|
||||
* Returns the frame's stroke width. This is only used if frameEnabled() returns true.
|
||||
@ -879,7 +879,7 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
|
||||
* \see setItemRotation()
|
||||
* \see itemRotation()
|
||||
*/
|
||||
virtual void rotateItem( double angle, const QPointF &transformOrigin );
|
||||
virtual void rotateItem( double angle, QPointF transformOrigin );
|
||||
|
||||
signals:
|
||||
|
||||
@ -956,7 +956,7 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
|
||||
* \see setFixedSize()
|
||||
* \see setMinimumSize()
|
||||
*/
|
||||
virtual QSizeF applyItemSizeConstraint( const QSizeF &targetSize );
|
||||
virtual QSizeF applyItemSizeConstraint( QSizeF targetSize );
|
||||
|
||||
/**
|
||||
* Refreshes an item's size by rechecking it against any possible item fixed
|
||||
@ -1016,12 +1016,12 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
|
||||
* Adjusts the specified \a point at which a \a reference position of the item
|
||||
* sits and returns the top left corner of the item, if reference point were placed at the specified position.
|
||||
*/
|
||||
QPointF adjustPointForReferencePosition( const QPointF &point, const QSizeF &size, const ReferencePoint &reference ) const;
|
||||
QPointF adjustPointForReferencePosition( QPointF point, QSizeF size, ReferencePoint reference ) const;
|
||||
|
||||
/**
|
||||
* Returns the current position (in layout units) of a \a reference point for the item.
|
||||
*/
|
||||
QPointF positionAtReferencePoint( const ReferencePoint &reference ) const;
|
||||
QPointF positionAtReferencePoint( ReferencePoint reference ) const;
|
||||
|
||||
/**
|
||||
* Returns the position for the reference point of the item, if the top-left of the item
|
||||
@ -1130,14 +1130,14 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
|
||||
bool shouldDrawAntialiased() const;
|
||||
bool shouldDrawDebugRect() const;
|
||||
|
||||
QSizeF applyMinimumSize( const QSizeF &targetSize );
|
||||
QSizeF applyFixedSize( const QSizeF &targetSize );
|
||||
QSizeF applyMinimumSize( QSizeF targetSize );
|
||||
QSizeF applyFixedSize( QSizeF targetSize );
|
||||
QgsLayoutPoint applyDataDefinedPosition( const QgsLayoutPoint &position );
|
||||
|
||||
double applyDataDefinedRotation( double rotation );
|
||||
void updateStoredItemPosition();
|
||||
QPointF itemPositionAtReferencePoint( ReferencePoint reference, const QSizeF &size ) const;
|
||||
void setScenePos( const QPointF &destinationPos );
|
||||
QPointF itemPositionAtReferencePoint( ReferencePoint reference, QSizeF size ) const;
|
||||
void setScenePos( QPointF destinationPos );
|
||||
bool shouldBlockUndoCommands() const;
|
||||
|
||||
void applyDataDefinedOrientation( double &width, double &height, const QgsExpressionContext &context );
|
||||
|
@ -476,7 +476,7 @@ void QgsLayoutItemLabel::setFrameEnabled( const bool drawFrame )
|
||||
prepareGeometryChange();
|
||||
}
|
||||
|
||||
void QgsLayoutItemLabel::setFrameStrokeWidth( const QgsLayoutMeasurement &strokeWidth )
|
||||
void QgsLayoutItemLabel::setFrameStrokeWidth( const QgsLayoutMeasurement strokeWidth )
|
||||
{
|
||||
QgsLayoutItem::setFrameStrokeWidth( strokeWidth );
|
||||
prepareGeometryChange();
|
||||
|
@ -211,7 +211,7 @@ class CORE_EXPORT QgsLayoutItemLabel: public QgsLayoutItem
|
||||
void setFrameEnabled( bool drawFrame ) override;
|
||||
|
||||
// Reimplemented to call prepareGeometryChange after changing stroke width
|
||||
void setFrameStrokeWidth( const QgsLayoutMeasurement &strokeWidth ) override;
|
||||
void setFrameStrokeWidth( QgsLayoutMeasurement strokeWidth ) override;
|
||||
|
||||
public slots:
|
||||
|
||||
|
@ -748,7 +748,7 @@ void QgsLayoutItemMap::paint( QPainter *painter, const QStyleOptionGraphicsItem
|
||||
}
|
||||
|
||||
QRectF thisPaintRect = rect();
|
||||
if ( thisPaintRect.width() == 0 || thisPaintRect.height() == 0 )
|
||||
if ( qgsDoubleNear( thisPaintRect.width(), 0.0 ) || qgsDoubleNear( thisPaintRect.height(), 0 ) )
|
||||
return;
|
||||
|
||||
//TODO - try to reduce the amount of duplicate code here!
|
||||
@ -936,7 +936,7 @@ int QgsLayoutItemMap::numberExportLayers() const
|
||||
+ ( frameEnabled() ? 1 : 0 );
|
||||
}
|
||||
|
||||
void QgsLayoutItemMap::setFrameStrokeWidth( const QgsLayoutMeasurement &width )
|
||||
void QgsLayoutItemMap::setFrameStrokeWidth( const QgsLayoutMeasurement width )
|
||||
{
|
||||
QgsLayoutItem::setFrameStrokeWidth( width );
|
||||
updateBoundingRect();
|
||||
|
@ -90,7 +90,7 @@ class CORE_EXPORT QgsLayoutItemMap : public QgsLayoutItem
|
||||
// for now, map items behave a bit differently and don't implement draw. TODO - see if we can avoid this
|
||||
void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
|
||||
int numberExportLayers() const override;
|
||||
void setFrameStrokeWidth( const QgsLayoutMeasurement &width ) override;
|
||||
void setFrameStrokeWidth( QgsLayoutMeasurement width ) override;
|
||||
|
||||
/**
|
||||
* Returns the map scale.
|
||||
|
@ -1684,7 +1684,7 @@ int QgsLayoutItemMapGrid::xGridLinesCrsTransform( const QgsRectangle &bbox, cons
|
||||
catch ( QgsCsException &cse )
|
||||
{
|
||||
Q_UNUSED( cse );
|
||||
QgsDebugMsg( QString( "Caught CRS exception %1" ).arg( cse.what() ) );
|
||||
QgsDebugMsg( QStringLiteral( "Caught CRS exception %1" ).arg( cse.what() ) );
|
||||
}
|
||||
|
||||
currentX += step;
|
||||
@ -1760,7 +1760,7 @@ int QgsLayoutItemMapGrid::yGridLinesCrsTransform( const QgsRectangle &bbox, cons
|
||||
catch ( QgsCsException &cse )
|
||||
{
|
||||
Q_UNUSED( cse );
|
||||
QgsDebugMsg( QString( "Caught CRS exception %1" ).arg( cse.what() ) );
|
||||
QgsDebugMsg( QStringLiteral( "Caught CRS exception %1" ).arg( cse.what() ) );
|
||||
}
|
||||
|
||||
currentY += step;
|
||||
@ -2334,7 +2334,7 @@ int QgsLayoutItemMapGrid::crsGridParams( QgsRectangle &crsRect, QgsCoordinateTra
|
||||
catch ( QgsCsException &cse )
|
||||
{
|
||||
Q_UNUSED( cse );
|
||||
QgsDebugMsg( QString( "Caught CRS exception %1" ).arg( cse.what() ) );
|
||||
QgsDebugMsg( QStringLiteral( "Caught CRS exception %1" ).arg( cse.what() ) );
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -181,6 +181,7 @@ QgsLayoutItemMapItem &QgsLayoutItemMapItemStack::operator[]( int idx )
|
||||
QList<QgsLayoutItemMapItem *> QgsLayoutItemMapItemStack::asList() const
|
||||
{
|
||||
QList< QgsLayoutItemMapItem * > list;
|
||||
list.reserve( mItems.size() );
|
||||
for ( QgsLayoutItemMapItem *item : mItems )
|
||||
{
|
||||
list.append( item );
|
||||
|
@ -104,7 +104,7 @@ bool QgsLayoutNodesItem::addNode( QPointF pt,
|
||||
{
|
||||
// get nodes of polyline
|
||||
const QPointF pt1 = mPolygon.at( i );
|
||||
QPointF pt2 = mPolygon.first();
|
||||
QPointF pt2 = mPolygon.at( 0 );
|
||||
if ( ( i + 1 ) != mPolygon.size() )
|
||||
pt2 = mPolygon.at( i + 1 );
|
||||
|
||||
|
@ -203,7 +203,7 @@ void QgsLayoutItemPicture::draw( QgsLayoutItemRenderContext &context )
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QSizeF QgsLayoutItemPicture::applyItemSizeConstraint( const QSizeF &targetSize )
|
||||
QSizeF QgsLayoutItemPicture::applyItemSizeConstraint( const QSizeF targetSize )
|
||||
{
|
||||
QSizeF currentPictureSize = pictureSize();
|
||||
QSizeF newSize = targetSize;
|
||||
@ -347,7 +347,7 @@ void QgsLayoutItemPicture::refreshPicture( const QgsExpressionContext *context )
|
||||
if ( ok )
|
||||
{
|
||||
source = source.trimmed();
|
||||
QgsDebugMsg( QString( "exprVal PictureSource:%1" ).arg( source ) );
|
||||
QgsDebugMsg( QStringLiteral( "exprVal PictureSource:%1" ).arg( source ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -473,7 +473,7 @@ void QgsLayoutItemPicture::updateMapRotation()
|
||||
catch ( QgsException &e )
|
||||
{
|
||||
Q_UNUSED( e );
|
||||
QgsDebugMsg( QString( "Caught exception %1" ).arg( e.what() ) );
|
||||
QgsDebugMsg( QStringLiteral( "Caught exception %1" ).arg( e.what() ) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
/***************************************************************************
|
||||
qgslayoutitempicture.h
|
||||
-------------------
|
||||
begin : October 2017
|
||||
copyright : (C) 2017 by Nyall Dawson
|
||||
email : nyall dot dawson at gmail dot com
|
||||
***************************************************************************/
|
||||
qgslayoutitempicture.h
|
||||
-------------------
|
||||
begin : October 2017
|
||||
copyright : (C) 2017 by Nyall Dawson
|
||||
email : nyall dot dawson at gmail dot com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
@ -268,7 +268,7 @@ class CORE_EXPORT QgsLayoutItemPicture: public QgsLayoutItem
|
||||
protected:
|
||||
|
||||
void draw( QgsLayoutItemRenderContext &context ) override;
|
||||
QSizeF applyItemSizeConstraint( const QSizeF &targetSize ) override;
|
||||
QSizeF applyItemSizeConstraint( QSizeF targetSize ) override;
|
||||
bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
|
||||
bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override;
|
||||
|
||||
|
@ -108,6 +108,7 @@ QList<QgsPrintLayout *> QgsLayoutManager::printLayouts() const
|
||||
{
|
||||
QList<QgsPrintLayout *> result;
|
||||
const QList<QgsMasterLayoutInterface *> _layouts( mLayouts );
|
||||
result.reserve( _layouts.size() );
|
||||
for ( const auto &layout : _layouts )
|
||||
{
|
||||
QgsPrintLayout *_item( dynamic_cast<QgsPrintLayout *>( layout ) );
|
||||
@ -278,6 +279,7 @@ QgsMasterLayoutInterface *QgsLayoutManager::duplicateLayout( const QgsMasterLayo
|
||||
QString QgsLayoutManager::generateUniqueTitle( QgsMasterLayoutInterface::Type type ) const
|
||||
{
|
||||
QStringList names;
|
||||
names.reserve( mLayouts.size() );
|
||||
for ( QgsMasterLayoutInterface *l : mLayouts )
|
||||
{
|
||||
names << l->name();
|
||||
|
@ -40,12 +40,12 @@ QgsLayoutMeasurement QgsLayoutMeasurement::decodeMeasurement( const QString &str
|
||||
return QgsLayoutMeasurement( parts[0].toDouble(), QgsUnitTypes::decodeLayoutUnit( parts[1] ) );
|
||||
}
|
||||
|
||||
bool QgsLayoutMeasurement::operator==( const QgsLayoutMeasurement &other ) const
|
||||
bool QgsLayoutMeasurement::operator==( const QgsLayoutMeasurement other ) const
|
||||
{
|
||||
return other.units() == mUnits && qgsDoubleNear( other.length(), mLength );
|
||||
}
|
||||
|
||||
bool QgsLayoutMeasurement::operator!=( const QgsLayoutMeasurement &other ) const
|
||||
bool QgsLayoutMeasurement::operator!=( const QgsLayoutMeasurement other ) const
|
||||
{
|
||||
return ( ! operator==( other ) );
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ class CORE_EXPORT QgsLayoutMeasurement
|
||||
*/
|
||||
static QgsLayoutMeasurement decodeMeasurement( const QString &string );
|
||||
|
||||
bool operator==( const QgsLayoutMeasurement &other ) const;
|
||||
bool operator!=( const QgsLayoutMeasurement &other ) const;
|
||||
bool operator==( QgsLayoutMeasurement other ) const;
|
||||
bool operator!=( QgsLayoutMeasurement other ) const;
|
||||
|
||||
/**
|
||||
* Adds a scalar value to the measurement.
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "qgslayoutmeasurementconverter.h"
|
||||
|
||||
|
||||
QgsLayoutMeasurement QgsLayoutMeasurementConverter::convert( const QgsLayoutMeasurement &measurement, const QgsUnitTypes::LayoutUnit targetUnits ) const
|
||||
QgsLayoutMeasurement QgsLayoutMeasurementConverter::convert( const QgsLayoutMeasurement measurement, const QgsUnitTypes::LayoutUnit targetUnits ) const
|
||||
{
|
||||
if ( measurement.units() == targetUnits )
|
||||
{
|
||||
@ -131,7 +131,7 @@ QgsLayoutPoint QgsLayoutMeasurementConverter::convert( const QgsLayoutPoint &poi
|
||||
return result;
|
||||
}
|
||||
|
||||
double QgsLayoutMeasurementConverter::convertToMillimeters( const QgsLayoutMeasurement &measurement ) const
|
||||
double QgsLayoutMeasurementConverter::convertToMillimeters( const QgsLayoutMeasurement measurement ) const
|
||||
{
|
||||
switch ( measurement.units() )
|
||||
{
|
||||
@ -157,37 +157,37 @@ double QgsLayoutMeasurementConverter::convertToMillimeters( const QgsLayoutMeasu
|
||||
return measurement.length();
|
||||
}
|
||||
|
||||
double QgsLayoutMeasurementConverter::convertToCentimeters( const QgsLayoutMeasurement &measurement ) const
|
||||
double QgsLayoutMeasurementConverter::convertToCentimeters( const QgsLayoutMeasurement measurement ) const
|
||||
{
|
||||
return convertToMillimeters( measurement ) / 10.0;
|
||||
}
|
||||
|
||||
double QgsLayoutMeasurementConverter::convertToMeters( const QgsLayoutMeasurement &measurement ) const
|
||||
double QgsLayoutMeasurementConverter::convertToMeters( const QgsLayoutMeasurement measurement ) const
|
||||
{
|
||||
return convertToMillimeters( measurement ) / 1000.0;
|
||||
}
|
||||
|
||||
double QgsLayoutMeasurementConverter::convertToInches( const QgsLayoutMeasurement &measurement ) const
|
||||
double QgsLayoutMeasurementConverter::convertToInches( const QgsLayoutMeasurement measurement ) const
|
||||
{
|
||||
return convertToMillimeters( measurement ) / 25.4;
|
||||
}
|
||||
|
||||
double QgsLayoutMeasurementConverter::convertToFeet( const QgsLayoutMeasurement &measurement ) const
|
||||
double QgsLayoutMeasurementConverter::convertToFeet( const QgsLayoutMeasurement measurement ) const
|
||||
{
|
||||
return convertToMillimeters( measurement ) / 304.8;
|
||||
}
|
||||
|
||||
double QgsLayoutMeasurementConverter::convertToPoints( const QgsLayoutMeasurement &measurement ) const
|
||||
double QgsLayoutMeasurementConverter::convertToPoints( const QgsLayoutMeasurement measurement ) const
|
||||
{
|
||||
return convertToMillimeters( measurement ) * 2.83464567;
|
||||
}
|
||||
|
||||
double QgsLayoutMeasurementConverter::convertToPicas( const QgsLayoutMeasurement &measurement ) const
|
||||
double QgsLayoutMeasurementConverter::convertToPicas( const QgsLayoutMeasurement measurement ) const
|
||||
{
|
||||
return convertToMillimeters( measurement ) * 0.236220472;
|
||||
}
|
||||
|
||||
double QgsLayoutMeasurementConverter::convertToPixels( const QgsLayoutMeasurement &measurement ) const
|
||||
double QgsLayoutMeasurementConverter::convertToPixels( const QgsLayoutMeasurement measurement ) const
|
||||
{
|
||||
return convertToMillimeters( measurement ) * mDpi / 25.4;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class CORE_EXPORT QgsLayoutMeasurementConverter
|
||||
* \param targetUnits units to convert measurement into
|
||||
* \returns measurement converted to target units
|
||||
*/
|
||||
QgsLayoutMeasurement convert( const QgsLayoutMeasurement &measurement, QgsUnitTypes::LayoutUnit targetUnits ) const;
|
||||
QgsLayoutMeasurement convert( QgsLayoutMeasurement measurement, QgsUnitTypes::LayoutUnit targetUnits ) const;
|
||||
|
||||
/**
|
||||
* Converts a layout size from one unit to another.
|
||||
@ -88,14 +88,14 @@ class CORE_EXPORT QgsLayoutMeasurementConverter
|
||||
|
||||
double mDpi = 300.0;
|
||||
|
||||
double convertToMillimeters( const QgsLayoutMeasurement &measurement ) const;
|
||||
double convertToCentimeters( const QgsLayoutMeasurement &measurement ) const;
|
||||
double convertToMeters( const QgsLayoutMeasurement &measurement ) const;
|
||||
double convertToInches( const QgsLayoutMeasurement &measurement ) const;
|
||||
double convertToFeet( const QgsLayoutMeasurement &measurement ) const;
|
||||
double convertToPoints( const QgsLayoutMeasurement &measurement ) const;
|
||||
double convertToPicas( const QgsLayoutMeasurement &measurement ) const;
|
||||
double convertToPixels( const QgsLayoutMeasurement &measurement ) const;
|
||||
double convertToMillimeters( QgsLayoutMeasurement measurement ) const;
|
||||
double convertToCentimeters( QgsLayoutMeasurement measurement ) const;
|
||||
double convertToMeters( QgsLayoutMeasurement measurement ) const;
|
||||
double convertToInches( QgsLayoutMeasurement measurement ) const;
|
||||
double convertToFeet( QgsLayoutMeasurement measurement ) const;
|
||||
double convertToPoints( QgsLayoutMeasurement measurement ) const;
|
||||
double convertToPicas( QgsLayoutMeasurement measurement ) const;
|
||||
double convertToPixels( QgsLayoutMeasurement measurement ) const;
|
||||
|
||||
};
|
||||
|
||||
|
@ -457,7 +457,7 @@ int QgsLayoutPageCollection::pageNumber( QgsLayoutItemPage *page ) const
|
||||
return mPages.indexOf( page );
|
||||
}
|
||||
|
||||
QList<QgsLayoutItemPage *> QgsLayoutPageCollection::visiblePages( QRectF region ) const
|
||||
QList<QgsLayoutItemPage *> QgsLayoutPageCollection::visiblePages( const QRectF ®ion ) const
|
||||
{
|
||||
QList<QgsLayoutItemPage *> pages;
|
||||
Q_FOREACH ( QgsLayoutItemPage *page, mPages )
|
||||
@ -468,7 +468,7 @@ QList<QgsLayoutItemPage *> QgsLayoutPageCollection::visiblePages( QRectF region
|
||||
return pages;
|
||||
}
|
||||
|
||||
QList<int> QgsLayoutPageCollection::visiblePageNumbers( QRectF region ) const
|
||||
QList<int> QgsLayoutPageCollection::visiblePageNumbers( const QRectF ®ion ) const
|
||||
{
|
||||
QList< int > pages;
|
||||
int p = 0;
|
||||
@ -504,6 +504,7 @@ QList<QgsLayoutItem *> QgsLayoutPageCollection::itemsOnPage( int page ) const
|
||||
{
|
||||
QList<QgsLayoutItem *> itemList;
|
||||
const QList<QGraphicsItem *> graphicsItemList = mLayout->items();
|
||||
itemList.reserve( graphicsItemList.size() );
|
||||
for ( QGraphicsItem *graphicsItem : graphicsItemList )
|
||||
{
|
||||
QgsLayoutItem *item = dynamic_cast<QgsLayoutItem *>( graphicsItem );
|
||||
@ -588,7 +589,7 @@ void QgsLayoutPageCollection::insertPage( QgsLayoutItemPage *page, int beforePag
|
||||
reflow();
|
||||
|
||||
// bump up stored page numbers to account
|
||||
for ( auto it = mPreviousItemPositions.begin(); it != mPreviousItemPositions.end(); ++it )
|
||||
for ( auto it = mPreviousItemPositions.begin(); it != mPreviousItemPositions.end(); ++it ) // clazy:exclude=detaching-member
|
||||
{
|
||||
if ( it.value().first < beforePage )
|
||||
continue;
|
||||
@ -622,7 +623,7 @@ void QgsLayoutPageCollection::deletePage( int pageNumber )
|
||||
reflow();
|
||||
|
||||
// bump stored page numbers to account
|
||||
for ( auto it = mPreviousItemPositions.begin(); it != mPreviousItemPositions.end(); ++it )
|
||||
for ( auto it = mPreviousItemPositions.begin(); it != mPreviousItemPositions.end(); ++it ) // clazy:exclude=detaching-member
|
||||
{
|
||||
if ( it.value().first <= pageNumber )
|
||||
continue;
|
||||
@ -656,7 +657,7 @@ void QgsLayoutPageCollection::deletePage( QgsLayoutItemPage *page )
|
||||
reflow();
|
||||
|
||||
// bump stored page numbers to account
|
||||
for ( auto it = mPreviousItemPositions.begin(); it != mPreviousItemPositions.end(); ++it )
|
||||
for ( auto it = mPreviousItemPositions.begin(); it != mPreviousItemPositions.end(); ++it ) // clazy:exclude=detaching-member
|
||||
{
|
||||
if ( it.value().first <= pageIndex )
|
||||
continue;
|
||||
|
@ -97,14 +97,14 @@ class CORE_EXPORT QgsLayoutPageCollection : public QObject, public QgsLayoutSeri
|
||||
* \a region (in layout coordinates).
|
||||
* \see visiblePageNumbers()
|
||||
*/
|
||||
QList< QgsLayoutItemPage * > visiblePages( QRectF region ) const;
|
||||
QList< QgsLayoutItemPage * > visiblePages( const QRectF ®ion ) const;
|
||||
|
||||
/**
|
||||
* Returns a list of the page numbers which are visible within the specified
|
||||
* \a region (in layout coordinates).
|
||||
* \see visiblePages()
|
||||
*/
|
||||
QList< int > visiblePageNumbers( QRectF region ) const;
|
||||
QList< int > visiblePageNumbers( const QRectF ®ion ) const;
|
||||
|
||||
/**
|
||||
* Returns whether a given \a page index is empty, ie, it contains no items except for the background
|
||||
|
@ -69,7 +69,7 @@ QgsLayoutPoint QgsLayoutPoint::decodePoint( const QString &string )
|
||||
|
||||
bool QgsLayoutPoint::operator==( const QgsLayoutPoint &other ) const
|
||||
{
|
||||
return other.units() == mUnits && other.x() == mX && other.y() == mY;
|
||||
return other.units() == mUnits && qgsDoubleNear( other.x(), mX ) && qgsDoubleNear( other.y(), mY );
|
||||
}
|
||||
|
||||
bool QgsLayoutPoint::operator!=( const QgsLayoutPoint &other ) const
|
||||
|
@ -73,7 +73,7 @@ QgsRenderContext::Flags QgsLayoutRenderContext::renderContextFlags() const
|
||||
|
||||
void QgsLayoutRenderContext::setDpi( double dpi )
|
||||
{
|
||||
if ( dpi == mMeasurementConverter.dpi() )
|
||||
if ( qgsDoubleNear( dpi, mMeasurementConverter.dpi() ) )
|
||||
return;
|
||||
|
||||
mMeasurementConverter.setDpi( dpi );
|
||||
|
@ -78,5 +78,5 @@ void QgsLayoutReportContext::setPredefinedScales( const QVector<qreal> &scales )
|
||||
{
|
||||
mPredefinedScales = scales;
|
||||
// make sure the list is sorted
|
||||
std::sort( mPredefinedScales.begin(), mPredefinedScales.end() );
|
||||
std::sort( mPredefinedScales.begin(), mPredefinedScales.end() ); // clazy:exclude=detaching-member
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ QgsLayoutSize QgsLayoutSize::decodeSize( const QString &string )
|
||||
|
||||
bool QgsLayoutSize::operator==( const QgsLayoutSize &other ) const
|
||||
{
|
||||
return other.units() == mUnits && other.width() == mWidth && other.height() == mHeight;
|
||||
return other.units() == mUnits && qgsDoubleNear( other.width(), mWidth ) && qgsDoubleNear( other.height(), mHeight );
|
||||
}
|
||||
|
||||
bool QgsLayoutSize::operator!=( const QgsLayoutSize &other ) const
|
||||
|
@ -182,8 +182,8 @@ bool QgsReportSectionFieldGroup::writePropertiesToElement( QDomElement &element,
|
||||
element.setAttribute( QStringLiteral( "headerVisibility" ), static_cast< int >( mHeaderVisibility ) );
|
||||
element.setAttribute( QStringLiteral( "footerVisibility" ), static_cast< int >( mFooterVisibility ) );
|
||||
element.setAttribute( QStringLiteral( "field" ), mField );
|
||||
element.setAttribute( QStringLiteral( "ascending" ), mSortAscending ? "1" : "0" );
|
||||
element.setAttribute( QStringLiteral( "bodyEnabled" ), mBodyEnabled ? "1" : "0" );
|
||||
element.setAttribute( QStringLiteral( "ascending" ), mSortAscending ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
|
||||
element.setAttribute( QStringLiteral( "bodyEnabled" ), mBodyEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
|
||||
if ( mCoverageLayer )
|
||||
{
|
||||
element.setAttribute( QStringLiteral( "coverageLayer" ), mCoverageLayer.layerId );
|
||||
|
@ -81,7 +81,7 @@ bool QgsReportSectionLayout::writePropertiesToElement( QDomElement &element, QDo
|
||||
bodyElement.appendChild( mBody->writeXml( doc, context ) );
|
||||
element.appendChild( bodyElement );
|
||||
}
|
||||
element.setAttribute( QStringLiteral( "bodyEnabled" ), mBodyEnabled ? "1" : "0" );
|
||||
element.setAttribute( QStringLiteral( "bodyEnabled" ), mBodyEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ class TestItem : public QgsLayoutItem
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QSizeF applyItemSizeConstraint( const QSizeF &targetSize ) override
|
||||
QSizeF applyItemSizeConstraint( QSizeF targetSize ) override
|
||||
{
|
||||
if ( !forceResize )
|
||||
return targetSize;
|
||||
|
Loading…
x
Reference in New Issue
Block a user