Skip to content

Commit bcc1b91

Browse files
authored
Merge pull request #5717 from nyalldawson/layout_next4
[layouts] Port/adapt all remaining item types
2 parents c12770d + cc29f0e commit bcc1b91

File tree

133 files changed

+22005
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+22005
-155
lines changed

python/core/core_auto.sip

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,11 @@
407407
%Include layout/qgslayoutcontext.sip
408408
%Include layout/qgslayouteffect.sip
409409
%Include layout/qgslayoutguidecollection.sip
410+
%Include layout/qgslayoutframe.sip
410411
%Include layout/qgslayoutitem.sip
412+
%Include layout/qgslayoutitemattributetable.sip
411413
%Include layout/qgslayoutitemgroup.sip
414+
%Include layout/qgslayoutitemhtml.sip
412415
%Include layout/qgslayoutitemlabel.sip
413416
%Include layout/qgslayoutitemlegend.sip
414417
%Include layout/qgslayoutitemmap.sip
@@ -421,10 +424,15 @@
421424
%Include layout/qgslayoutitempolygon.sip
422425
%Include layout/qgslayoutitempolyline.sip
423426
%Include layout/qgslayoutitemregistry.sip
427+
%Include layout/qgslayoutitemscalebar.sip
424428
%Include layout/qgslayoutitemshape.sip
429+
%Include layout/qgslayoutitemtexttable.sip
425430
%Include layout/qgslayoutmodel.sip
431+
%Include layout/qgslayoutmultiframe.sip
426432
%Include layout/qgslayoutpagecollection.sip
427433
%Include layout/qgslayoutobject.sip
434+
%Include layout/qgslayouttable.sip
435+
%Include layout/qgslayouttablecolumn.sip
428436
%Include layout/qgslayoutundostack.sip
429437
%Include symbology/qgscptcityarchive.sip
430438
%Include symbology/qgssvgcache.sip

python/core/layout/qgslayout.sip

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,18 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
175175
%Docstring
176176
Returns the layout item with matching ``uuid`` unique identifier, or a None
177177
if a matching item could not be found.
178+
.. seealso:: multiFrameByUuid()
178179
:rtype: QgsLayoutItem
179180
%End
180181

182+
QgsLayoutMultiFrame *multiFrameByUuid( const QString &uuid ) const;
183+
%Docstring
184+
Returns the layout multiframe with matching ``uuid`` unique identifier, or a None
185+
if a matching multiframe could not be found.
186+
.. seealso:: itemByUuid()
187+
:rtype: QgsLayoutMultiFrame
188+
%End
189+
181190
QgsLayoutItem *layoutItemAt( QPointF position, const bool ignoreLocked = false ) const;
182191
%Docstring
183192
Returns the topmost layout item at a specified ``position``. Ignores paper items.
@@ -379,6 +388,28 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
379388
The item will also be deleted.
380389
%End
381390

391+
void addMultiFrame( QgsLayoutMultiFrame *multiFrame /Transfer/ );
392+
%Docstring
393+
Adds a ``multiFrame`` to the layout. The object is owned by the layout until removeMultiFrame() is called.
394+
.. seealso:: removeMultiFrame()
395+
.. seealso:: multiFrames()
396+
%End
397+
398+
void removeMultiFrame( QgsLayoutMultiFrame *multiFrame );
399+
%Docstring
400+
Removes a ``multiFrame`` from the layout (but does not delete it).
401+
.. seealso:: addMultiFrame()
402+
.. seealso:: multiFrames()
403+
%End
404+
405+
QList< QgsLayoutMultiFrame * > multiFrames() const;
406+
%Docstring
407+
Returns a list of multi frames contained in the layout.
408+
.. seealso:: addMultiFrame()
409+
.. seealso:: removeMultiFrame()
410+
:rtype: list of QgsLayoutMultiFrame
411+
%End
412+
382413
QDomElement writeXml( QDomDocument &document, const QgsReadWriteContext &context ) const;
383414
%Docstring
384415
Returns the layout's state encapsulated in a DOM element.
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/layout/qgslayoutframe.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
class QgsLayoutFrame: QgsLayoutItem
13+
{
14+
%Docstring
15+
Base class for frame items, which form a layout multiframe item.
16+
.. versionadded:: 3.0
17+
%End
18+
19+
%TypeHeaderCode
20+
#include "qgslayoutframe.h"
21+
%End
22+
public:
23+
24+
QgsLayoutFrame( QgsLayout *layout, QgsLayoutMultiFrame *multiFrame );
25+
%Docstring
26+
Constructor for QgsLayoutFrame, with the specified parent ``layout``
27+
and belonging to a ``multiFrame``.
28+
%End
29+
30+
static QgsLayoutFrame *create( QgsLayout *layout ) /Factory/;
31+
%Docstring
32+
Creates a new QgsLayoutFrame belonging to the specified ``layout``.
33+
:rtype: QgsLayoutFrame
34+
%End
35+
36+
virtual int type() const;
37+
38+
virtual QString stringType() const;
39+
40+
virtual QString uuid() const;
41+
42+
43+
virtual QString displayName() const;
44+
45+
46+
void setContentSection( const QRectF &section );
47+
%Docstring
48+
Sets the visible part of the multiframe's content which is visible within
49+
this frame (relative to the total multiframe extent in layout units).
50+
.. seealso:: extent()
51+
%End
52+
53+
QgsLayoutMultiFrame *multiFrame() const;
54+
%Docstring
55+
Returns the parent multiframe for the frame.
56+
:rtype: QgsLayoutMultiFrame
57+
%End
58+
59+
virtual QgsLayoutSize minimumSize() const;
60+
61+
virtual QgsLayoutSize fixedSize() const;
62+
63+
64+
65+
QRectF extent() const;
66+
%Docstring
67+
Returns the visible portion of the multi frame's content which
68+
is shown in this frame, in layout units.
69+
.. seealso:: setContentSection()
70+
:rtype: QRectF
71+
%End
72+
73+
bool hidePageIfEmpty() const;
74+
%Docstring
75+
Returns whether the page should be hidden (ie, not included in layout exports) if this frame is empty
76+
:return: true if page should be hidden if frame is empty
77+
.. seealso:: setHidePageIfEmpty()
78+
:rtype: bool
79+
%End
80+
81+
void setHidePageIfEmpty( const bool hidePageIfEmpty );
82+
%Docstring
83+
Sets whether the page should be hidden (ie, not included in layout exports) if this frame is empty
84+
\param hidePageIfEmpty set to true if page should be hidden if frame is empty
85+
.. seealso:: hidePageIfEmpty()
86+
%End
87+
88+
bool hideBackgroundIfEmpty() const;
89+
%Docstring
90+
Returns whether the background and frame stroke should be hidden if this frame is empty
91+
:return: true if background and stroke should be hidden if frame is empty
92+
.. seealso:: setHideBackgroundIfEmpty()
93+
:rtype: bool
94+
%End
95+
96+
void setHideBackgroundIfEmpty( const bool hideBackgroundIfEmpty );
97+
%Docstring
98+
Sets whether the background and frame stroke should be hidden if this frame is empty
99+
\param hideBackgroundIfEmpty set to true if background and stroke should be hidden if frame is empty
100+
.. seealso:: hideBackgroundIfEmpty()
101+
%End
102+
103+
bool isEmpty() const;
104+
%Docstring
105+
Returns whether the frame is empty.
106+
.. seealso:: hidePageIfEmpty()
107+
:rtype: bool
108+
%End
109+
110+
virtual QgsExpressionContext createExpressionContext() const;
111+
112+
113+
protected:
114+
115+
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
116+
117+
void drawFrame( QgsRenderContext &context );
118+
void drawBackground( QgsRenderContext &context );
119+
120+
};
121+
122+
/************************************************************************
123+
* This file has been generated automatically from *
124+
* *
125+
* src/core/layout/qgslayoutframe.h *
126+
* *
127+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
128+
************************************************************************/

python/core/layout/qgslayoutitem.sip

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,24 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
105105
UndoLegendGroupFont,
106106
UndoLegendLayerFont,
107107
UndoLegendItemFont,
108+
UndoScaleBarLineWidth,
109+
UndoScaleBarSegmentSize,
110+
UndoScaleBarSegmentsLeft,
111+
UndoScaleBarSegments,
112+
UndoScaleBarHeight,
113+
UndoScaleBarFontColor,
114+
UndoScaleBarFillColor,
115+
UndoScaleBarFillColor2,
116+
UndoScaleBarStrokeColor,
117+
UndoScaleBarUnitText,
118+
UndoScaleBarMapUnitsSegment,
119+
UndoScaleBarLabelBarSize,
120+
UndoScaleBarBoxContentSpace,
121+
UndoArrowStrokeWidth,
122+
UndoArrowHeadWidth,
123+
UndoArrowHeadFillColor,
124+
UndoArrowHeadStrokeColor,
125+
108126
UndoCustomCommand,
109127
};
110128

@@ -135,7 +153,7 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
135153
:rtype: str
136154
%End
137155

138-
QString uuid() const;
156+
virtual QString uuid() const;
139157
%Docstring
140158
Returns the item identification string. This is a unique random string set for the item
141159
upon creation.
@@ -262,7 +280,7 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
262280
:rtype: ReferencePoint
263281
%End
264282

265-
QgsLayoutSize fixedSize() const;
283+
virtual QgsLayoutSize fixedSize() const;
266284
%Docstring
267285
Returns the fixed size of the item, if applicable, or an empty size if item can be freely
268286
resized.
@@ -296,7 +314,7 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
296314
.. seealso:: sizeWithUnits()
297315
%End
298316

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

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

331+
If ``page`` is not left at the default -1 value, then the position specified by ``point``
332+
refers to the relative position on the corresponding layout ``page`` (where a ``page``
333+
of 0 represents the first page).
334+
313335
Note that the final position of the item may not match the specified target position,
314336
as data defined item position may override the specified value.
315337

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

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

371+
int page() const;
372+
%Docstring
373+
Returns the page the item is currently on, with the first page returning 0.
374+
.. seealso:: pagePos()
375+
:rtype: int
376+
%End
377+
378+
QPointF pagePos() const;
379+
%Docstring
380+
Returns the item's position (in layout units) relative to the top left corner of its current page.
381+
.. seealso:: page()
382+
.. seealso:: pagePositionWithUnits()
383+
:rtype: QPointF
384+
%End
385+
386+
QgsLayoutPoint pagePositionWithUnits() const;
387+
%Docstring
388+
Returns the item's position (in item units) relative to the top left corner of its current page.
389+
.. seealso:: page()
390+
.. seealso:: pagePos()
391+
:rtype: QgsLayoutPoint
392+
%End
393+
350394
QgsLayoutSize sizeWithUnits() const;
351395
%Docstring
352396
Returns the item's current size, including units.

0 commit comments

Comments
 (0)