Skip to content

Commit dddce25

Browse files
committed
More work on porting multiframe items
1 parent 2cf9911 commit dddce25

19 files changed

+1416
-153
lines changed

python/core/layout/qgslayout.sip

Lines changed: 9 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.

python/core/layout/qgslayoutframe.sip

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,108 @@
99

1010

1111

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+
41+
virtual QString displayName() const;
42+
43+
44+
void setContentSection( const QRectF &section );
45+
%Docstring
46+
Sets the visible part of the multiframe's content which is visible within
47+
this frame (relative to the total multiframe extent in layout units).
48+
.. seealso:: extent()
49+
%End
50+
51+
QgsLayoutMultiFrame *multiFrame() const;
52+
%Docstring
53+
Returns the parent multiframe for the frame.
54+
:rtype: QgsLayoutMultiFrame
55+
%End
56+
57+
58+
QRectF extent() const;
59+
%Docstring
60+
Returns the visible portion of the multi frame's content which
61+
is shown in this frame, in layout units.
62+
.. seealso:: setContentSection()
63+
:rtype: QRectF
64+
%End
65+
66+
bool hidePageIfEmpty() const;
67+
%Docstring
68+
Returns whether the page should be hidden (ie, not included in layout exports) if this frame is empty
69+
:return: true if page should be hidden if frame is empty
70+
.. seealso:: setHidePageIfEmpty()
71+
:rtype: bool
72+
%End
73+
74+
void setHidePageIfEmpty( const bool hidePageIfEmpty );
75+
%Docstring
76+
Sets whether the page should be hidden (ie, not included in layout exports) if this frame is empty
77+
\param hidePageIfEmpty set to true if page should be hidden if frame is empty
78+
.. seealso:: hidePageIfEmpty()
79+
%End
80+
81+
bool hideBackgroundIfEmpty() const;
82+
%Docstring
83+
Returns whether the background and frame stroke should be hidden if this frame is empty
84+
:return: true if background and stroke should be hidden if frame is empty
85+
.. seealso:: setHideBackgroundIfEmpty()
86+
:rtype: bool
87+
%End
88+
89+
void setHideBackgroundIfEmpty( const bool hideBackgroundIfEmpty );
90+
%Docstring
91+
Sets whether the background and frame stroke should be hidden if this frame is empty
92+
\param hideBackgroundIfEmpty set to true if background and stroke should be hidden if frame is empty
93+
.. seealso:: hideBackgroundIfEmpty()
94+
%End
95+
96+
bool isEmpty() const;
97+
%Docstring
98+
Returns whether the frame is empty.
99+
.. seealso:: hidePageIfEmpty()
100+
:rtype: bool
101+
%End
102+
103+
virtual QgsExpressionContext createExpressionContext() const;
104+
105+
106+
protected:
107+
108+
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
109+
110+
void drawFrame( QgsRenderContext &context );
111+
void drawBackground( QgsRenderContext &context );
112+
113+
};
12114

13115
/************************************************************************
14116
* This file has been generated automatically from *

python/core/layout/qgslayoutitemregistry.sip

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,70 @@ class QgsLayoutItemAbstractMetadata
7474

7575

7676

77+
class QgsLayoutMultiFrameAbstractMetadata
78+
{
79+
%Docstring
80+
Stores metadata about one layout multiframe class.
81+
82+
A companion class, QgsLayoutMultiFrameAbstractGuiMetadata, handles the
83+
GUI behavior of QgsLayoutMultiFrames.
84+
85+
.. note::
86+
87+
In C++ you can use QgsLayoutMultiFrameMetadata convenience class.
88+
.. versionadded:: 3.0
89+
%End
90+
91+
%TypeHeaderCode
92+
#include "qgslayoutitemregistry.h"
93+
%End
94+
public:
95+
96+
QgsLayoutMultiFrameAbstractMetadata( int type, const QString &visibleName );
97+
%Docstring
98+
Constructor for QgsLayoutMultiFrameAbstractMetadata with the specified class ``type``
99+
and ``visibleName``.
100+
%End
101+
102+
virtual ~QgsLayoutMultiFrameAbstractMetadata();
103+
104+
int type() const;
105+
%Docstring
106+
Returns the unique item type code for the layout multiframe class.
107+
:rtype: int
108+
%End
109+
110+
virtual QIcon icon() const;
111+
%Docstring
112+
Returns an icon representing the layout multiframe type.
113+
:rtype: QIcon
114+
%End
115+
116+
QString visibleName() const;
117+
%Docstring
118+
Returns a translated, user visible name for the layout multiframe class.
119+
:rtype: str
120+
%End
121+
122+
virtual QgsLayoutMultiFrame *createMultiFrame( QgsLayout *layout ) = 0 /Factory/;
123+
%Docstring
124+
Creates a layout multiframe of this class for a specified ``layout``.
125+
:rtype: QgsLayoutMultiFrame
126+
%End
127+
128+
virtual void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
129+
%Docstring
130+
Resolve paths in the item's ``properties`` (if there are any paths).
131+
When ``saving`` is true, paths are converted from absolute to relative,
132+
when ``saving`` is false, paths are converted from relative to absolute.
133+
This ensures that paths in project files can be relative, but in item
134+
instances the paths are always absolute.
135+
%End
136+
137+
};
138+
139+
140+
77141

78142

79143
class QgsLayoutItemRegistry : QObject
@@ -111,6 +175,9 @@ class QgsLayoutItemRegistry : QObject
111175
LayoutPolyline,
112176
LayoutFrame,
113177

178+
// known
179+
LayoutHtml,
180+
114181
// item
115182
PluginItem,
116183
};
@@ -139,21 +206,46 @@ class QgsLayoutItemRegistry : QObject
139206
%Docstring
140207
Returns the metadata for the specified item ``type``. Returns None if
141208
a corresponding type was not found in the registry.
209+
.. seealso:: multiFrameMetadata()
142210
:rtype: QgsLayoutItemAbstractMetadata
143211
%End
144212

213+
QgsLayoutMultiFrameAbstractMetadata *multiFrameMetadata( int type ) const;
214+
%Docstring
215+
Returns the metadata for the specified multiframe ``type``. Returns None if
216+
a corresponding type was not found in the registry.
217+
.. seealso:: itemMetadata()
218+
:rtype: QgsLayoutMultiFrameAbstractMetadata
219+
%End
220+
145221
bool addLayoutItemType( QgsLayoutItemAbstractMetadata *metadata /Transfer/ );
146222
%Docstring
147223
Registers a new layout item type. Takes ownership of the metadata instance.
224+
.. seealso:: addLayoutMultiFrameType()
225+
:rtype: bool
226+
%End
227+
228+
bool addLayoutMultiFrameType( QgsLayoutMultiFrameAbstractMetadata *metadata /Transfer/ );
229+
%Docstring
230+
Registers a new layout multiframe type. Takes ownership of the metadata instance.
231+
.. seealso:: addLayoutItemType()
148232
:rtype: bool
149233
%End
150234

151235
QgsLayoutItem *createItem( int type, QgsLayout *layout ) const /Factory/;
152236
%Docstring
153237
Creates a new instance of a layout item given the item ``type``, and target ``layout``.
238+
.. seealso:: createMultiFrame()
154239
:rtype: QgsLayoutItem
155240
%End
156241

242+
QgsLayoutMultiFrame *createMultiFrame( int type, QgsLayout *layout ) const /Factory/;
243+
%Docstring
244+
Creates a new instance of a layout multiframe given the multiframe ``type``, and target ``layout``.
245+
.. seealso:: createItem()
246+
:rtype: QgsLayoutMultiFrame
247+
%End
248+
157249
void resolvePaths( int type, QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving ) const;
158250
%Docstring
159251
Resolve paths in properties of a particular symbol layer.
@@ -175,6 +267,12 @@ class QgsLayoutItemRegistry : QObject
175267
``type`` and visible ``name``.
176268
%End
177269

270+
void multiFrameTypeAdded( int type, const QString &name );
271+
%Docstring
272+
Emitted whenever a new multiframe type is added to the registry, with the specified
273+
``type`` and visible ``name``.
274+
%End
275+
178276
private:
179277
QgsLayoutItemRegistry( const QgsLayoutItemRegistry &rh );
180278
};

0 commit comments

Comments
 (0)