Skip to content

Commit

Permalink
Merge pull request #5717 from nyalldawson/layout_next4
Browse files Browse the repository at this point in the history
[layouts] Port/adapt all remaining item types
  • Loading branch information
nyalldawson committed Dec 1, 2017
2 parents c12770d + cc29f0e commit bcc1b91
Show file tree
Hide file tree
Showing 133 changed files with 22,005 additions and 155 deletions.
8 changes: 8 additions & 0 deletions python/core/core_auto.sip
Expand Up @@ -407,8 +407,11 @@
%Include layout/qgslayoutcontext.sip
%Include layout/qgslayouteffect.sip
%Include layout/qgslayoutguidecollection.sip
%Include layout/qgslayoutframe.sip
%Include layout/qgslayoutitem.sip
%Include layout/qgslayoutitemattributetable.sip
%Include layout/qgslayoutitemgroup.sip
%Include layout/qgslayoutitemhtml.sip
%Include layout/qgslayoutitemlabel.sip
%Include layout/qgslayoutitemlegend.sip
%Include layout/qgslayoutitemmap.sip
Expand All @@ -421,10 +424,15 @@
%Include layout/qgslayoutitempolygon.sip
%Include layout/qgslayoutitempolyline.sip
%Include layout/qgslayoutitemregistry.sip
%Include layout/qgslayoutitemscalebar.sip
%Include layout/qgslayoutitemshape.sip
%Include layout/qgslayoutitemtexttable.sip
%Include layout/qgslayoutmodel.sip
%Include layout/qgslayoutmultiframe.sip
%Include layout/qgslayoutpagecollection.sip
%Include layout/qgslayoutobject.sip
%Include layout/qgslayouttable.sip
%Include layout/qgslayouttablecolumn.sip
%Include layout/qgslayoutundostack.sip
%Include symbology/qgscptcityarchive.sip
%Include symbology/qgssvgcache.sip
Expand Down
31 changes: 31 additions & 0 deletions python/core/layout/qgslayout.sip
Expand Up @@ -175,9 +175,18 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
%Docstring
Returns the layout item with matching ``uuid`` unique identifier, or a None
if a matching item could not be found.
.. seealso:: multiFrameByUuid()
:rtype: QgsLayoutItem
%End

QgsLayoutMultiFrame *multiFrameByUuid( const QString &uuid ) const;
%Docstring
Returns the layout multiframe with matching ``uuid`` unique identifier, or a None
if a matching multiframe could not be found.
.. seealso:: itemByUuid()
:rtype: QgsLayoutMultiFrame
%End

QgsLayoutItem *layoutItemAt( QPointF position, const bool ignoreLocked = false ) const;
%Docstring
Returns the topmost layout item at a specified ``position``. Ignores paper items.
Expand Down Expand Up @@ -379,6 +388,28 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
The item will also be deleted.
%End

void addMultiFrame( QgsLayoutMultiFrame *multiFrame /Transfer/ );
%Docstring
Adds a ``multiFrame`` to the layout. The object is owned by the layout until removeMultiFrame() is called.
.. seealso:: removeMultiFrame()
.. seealso:: multiFrames()
%End

void removeMultiFrame( QgsLayoutMultiFrame *multiFrame );
%Docstring
Removes a ``multiFrame`` from the layout (but does not delete it).
.. seealso:: addMultiFrame()
.. seealso:: multiFrames()
%End

QList< QgsLayoutMultiFrame * > multiFrames() const;
%Docstring
Returns a list of multi frames contained in the layout.
.. seealso:: addMultiFrame()
.. seealso:: removeMultiFrame()
:rtype: list of QgsLayoutMultiFrame
%End

QDomElement writeXml( QDomDocument &document, const QgsReadWriteContext &context ) const;
%Docstring
Returns the layout's state encapsulated in a DOM element.
Expand Down
128 changes: 128 additions & 0 deletions python/core/layout/qgslayoutframe.sip
@@ -0,0 +1,128 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutframe.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsLayoutFrame: QgsLayoutItem
{
%Docstring
Base class for frame items, which form a layout multiframe item.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgslayoutframe.h"
%End
public:

QgsLayoutFrame( QgsLayout *layout, QgsLayoutMultiFrame *multiFrame );
%Docstring
Constructor for QgsLayoutFrame, with the specified parent ``layout``
and belonging to a ``multiFrame``.
%End

static QgsLayoutFrame *create( QgsLayout *layout ) /Factory/;
%Docstring
Creates a new QgsLayoutFrame belonging to the specified ``layout``.
:rtype: QgsLayoutFrame
%End

virtual int type() const;

virtual QString stringType() const;

virtual QString uuid() const;


virtual QString displayName() const;


void setContentSection( const QRectF &section );
%Docstring
Sets the visible part of the multiframe's content which is visible within
this frame (relative to the total multiframe extent in layout units).
.. seealso:: extent()
%End

QgsLayoutMultiFrame *multiFrame() const;
%Docstring
Returns the parent multiframe for the frame.
:rtype: QgsLayoutMultiFrame
%End

virtual QgsLayoutSize minimumSize() const;

virtual QgsLayoutSize fixedSize() const;



QRectF extent() const;
%Docstring
Returns the visible portion of the multi frame's content which
is shown in this frame, in layout units.
.. seealso:: setContentSection()
:rtype: QRectF
%End

bool hidePageIfEmpty() const;
%Docstring
Returns whether the page should be hidden (ie, not included in layout exports) if this frame is empty
:return: true if page should be hidden if frame is empty
.. seealso:: setHidePageIfEmpty()
:rtype: bool
%End

void setHidePageIfEmpty( const bool hidePageIfEmpty );
%Docstring
Sets whether the page should be hidden (ie, not included in layout exports) if this frame is empty
\param hidePageIfEmpty set to true if page should be hidden if frame is empty
.. seealso:: hidePageIfEmpty()
%End

bool hideBackgroundIfEmpty() const;
%Docstring
Returns whether the background and frame stroke should be hidden if this frame is empty
:return: true if background and stroke should be hidden if frame is empty
.. seealso:: setHideBackgroundIfEmpty()
:rtype: bool
%End

void setHideBackgroundIfEmpty( const bool hideBackgroundIfEmpty );
%Docstring
Sets whether the background and frame stroke should be hidden if this frame is empty
\param hideBackgroundIfEmpty set to true if background and stroke should be hidden if frame is empty
.. seealso:: hideBackgroundIfEmpty()
%End

bool isEmpty() const;
%Docstring
Returns whether the frame is empty.
.. seealso:: hidePageIfEmpty()
:rtype: bool
%End

virtual QgsExpressionContext createExpressionContext() const;


protected:

virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );

void drawFrame( QgsRenderContext &context );
void drawBackground( QgsRenderContext &context );

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutframe.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
52 changes: 48 additions & 4 deletions python/core/layout/qgslayoutitem.sip
Expand Up @@ -105,6 +105,24 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
UndoLegendGroupFont,
UndoLegendLayerFont,
UndoLegendItemFont,
UndoScaleBarLineWidth,
UndoScaleBarSegmentSize,
UndoScaleBarSegmentsLeft,
UndoScaleBarSegments,
UndoScaleBarHeight,
UndoScaleBarFontColor,
UndoScaleBarFillColor,
UndoScaleBarFillColor2,
UndoScaleBarStrokeColor,
UndoScaleBarUnitText,
UndoScaleBarMapUnitsSegment,
UndoScaleBarLabelBarSize,
UndoScaleBarBoxContentSpace,
UndoArrowStrokeWidth,
UndoArrowHeadWidth,
UndoArrowHeadFillColor,
UndoArrowHeadStrokeColor,

UndoCustomCommand,
};

Expand Down Expand Up @@ -135,7 +153,7 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
:rtype: str
%End

QString uuid() const;
virtual QString uuid() const;
%Docstring
Returns the item identification string. This is a unique random string set for the item
upon creation.
Expand Down Expand Up @@ -262,7 +280,7 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
:rtype: ReferencePoint
%End

QgsLayoutSize fixedSize() const;
virtual QgsLayoutSize fixedSize() const;
%Docstring
Returns the fixed size of the item, if applicable, or an empty size if item can be freely
resized.
Expand Down Expand Up @@ -296,7 +314,7 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
.. seealso:: sizeWithUnits()
%End

virtual void attemptMove( const QgsLayoutPoint &point, bool useReferencePoint = true, bool includesFrame = false );
virtual void attemptMove( const QgsLayoutPoint &point, bool useReferencePoint = true, bool includesFrame = false, int page = -1 );
%Docstring
Attempts to move the item to a specified ``point``.

Expand All @@ -310,6 +328,10 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
If ``includesFrame`` is true, then the position specified by ``point`` represents the
point at which to place the outside of the item's frame.

If ``page`` is not left at the default -1 value, then the position specified by ``point``
refers to the relative position on the corresponding layout ``page`` (where a ``page``
of 0 represents the first page).

Note that the final position of the item may not match the specified target position,
as data defined item position may override the specified value.

Expand All @@ -318,7 +340,6 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
.. seealso:: positionWithUnits()
%End


void attemptSetSceneRect( const QRectF &rect, bool includesFrame = false );
%Docstring
Attempts to update the item's position and size to match the passed ``rect`` in layout
Expand Down Expand Up @@ -347,6 +368,29 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
:rtype: QgsLayoutPoint
%End

int page() const;
%Docstring
Returns the page the item is currently on, with the first page returning 0.
.. seealso:: pagePos()
:rtype: int
%End

QPointF pagePos() const;
%Docstring
Returns the item's position (in layout units) relative to the top left corner of its current page.
.. seealso:: page()
.. seealso:: pagePositionWithUnits()
:rtype: QPointF
%End

QgsLayoutPoint pagePositionWithUnits() const;
%Docstring
Returns the item's position (in item units) relative to the top left corner of its current page.
.. seealso:: page()
.. seealso:: pagePos()
:rtype: QgsLayoutPoint
%End

QgsLayoutSize sizeWithUnits() const;
%Docstring
Returns the item's current size, including units.
Expand Down

0 comments on commit bcc1b91

Please sign in to comment.