Skip to content

Commit f84a3bb

Browse files
authored
Merge pull request #4819 from nyalldawson/layout_gui
Layout GUI work (pt 1/?)
2 parents 0639264 + 1c8b17f commit f84a3bb

File tree

63 files changed

+5827
-85
lines changed

Some content is hidden

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

63 files changed

+5827
-85
lines changed

python/core/layout/qgslayout.sip

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class QgsLayout : QGraphicsScene
1919
%End
2020
public:
2121

22+
enum ZValues
23+
{
24+
ZMapTool,
25+
};
26+
2227
QgsLayout();
2328

2429
};

python/core/layout/qgslayoutitemregistry.sip

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@
88

99

1010

11+
1112
class QgsLayoutItemAbstractMetadata
1213
{
1314
%Docstring
1415
Stores metadata about one layout item class.
16+
17+
A companion class, QgsLayoutItemAbstractGuiMetadata, handles the
18+
GUI behavior of QgsLayoutItems.
19+
1520
.. note::
1621

17-
In C++ you can use QgsSymbolLayerMetadata convenience class.
22+
In C++ you can use QgsLayoutItemMetadata convenience class.
1823
.. versionadded:: 3.0
1924
%End
2025

@@ -55,12 +60,6 @@ class QgsLayoutItemAbstractMetadata
5560
:rtype: QgsLayoutItem
5661
%End
5762

58-
virtual QWidget *createItemWidget() /Factory/;
59-
%Docstring
60-
Creates a configuration widget for layout items of this type. Can return None if no configuration GUI is required.
61-
:rtype: QWidget
62-
%End
63-
6463
virtual void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
6564
%Docstring
6665
Resolve paths in the item's ``properties`` (if there are any paths).
@@ -77,7 +76,6 @@ class QgsLayoutItemAbstractMetadata
7776

7877

7978

80-
8179
class QgsLayoutItemRegistry : QObject
8280
{
8381
%Docstring
@@ -86,6 +84,9 @@ class QgsLayoutItemRegistry : QObject
8684
QgsLayoutItemRegistry is not usually directly created, but rather accessed through
8785
QgsApplication.layoutItemRegistry().
8886

87+
A companion class, QgsLayoutItemGuiRegistry, handles the GUI behavior
88+
of layout items.
89+
8990
.. versionadded:: 3.0
9091
%End
9192

@@ -107,14 +108,23 @@ class QgsLayoutItemRegistry : QObject
107108

108109
QgsLayoutItemRegistry( QObject *parent = 0 );
109110
%Docstring
110-
Creates a registry and populates it with standard item types.
111+
Creates a new empty item registry.
111112

112113
QgsLayoutItemRegistry is not usually directly created, but rather accessed through
113114
QgsApplication.layoutItemRegistry().
115+
116+
.. seealso:: populate()
114117
%End
115118

116119
~QgsLayoutItemRegistry();
117120

121+
bool populate();
122+
%Docstring
123+
Populates the registry with standard item types. If called on a non-empty registry
124+
then this will have no effect and will return false.
125+
:rtype: bool
126+
%End
127+
118128

119129
QgsLayoutItemAbstractMetadata *itemMetadata( int type ) const;
120130
%Docstring
@@ -135,12 +145,6 @@ class QgsLayoutItemRegistry : QObject
135145
:rtype: QgsLayoutItem
136146
%End
137147

138-
QWidget *createItemWidget( int type ) const /Factory/;
139-
%Docstring
140-
Creates a new instance of a layout item configuration widget for the specified item ``type``.
141-
:rtype: QWidget
142-
%End
143-
144148
void resolvePaths( int type, QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving ) const;
145149
%Docstring
146150
Resolve paths in properties of a particular symbol layer.
@@ -169,6 +173,7 @@ class QgsLayoutItemRegistry : QObject
169173

170174

171175

176+
172177
/************************************************************************
173178
* This file has been generated automatically from *
174179
* *

python/gui/gui_auto.sip

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
%Include editorwidgets/core/qgseditorwidgetautoconf.sip
4343
%Include layertree/qgslayertreeembeddedconfigwidget.sip
4444
%Include layertree/qgslayertreeembeddedwidgetregistry.sip
45+
%Include layout/qgslayoutviewmouseevent.sip
46+
%Include layout/qgslayoutviewrubberband.sip
4547
%Include locator/qgslocatorcontext.sip
4648
%Include raster/qgsrasterrendererwidget.sip
4749
%Include symbology-ng/qgssymbolwidgetcontext.sip
@@ -275,6 +277,17 @@
275277
%Include layertree/qgslayertreeview.sip
276278
%Include layertree/qgslayertreeviewdefaultactions.sip
277279
%Include layout/qgslayoutdesignerinterface.sip
280+
%Include layout/qgslayoutitemguiregistry.sip
281+
%Include layout/qgslayoutruler.sip
282+
%Include layout/qgslayoutview.sip
283+
%Include layout/qgslayoutviewtool.sip
284+
%Include layout/qgslayoutviewtooladditem.sip
285+
%Include layout/qgslayoutviewtoolpan.sip
286+
%Include layout/qgslayoutviewtoolselect.sip
287+
%Include layout/qgslayoutviewtooltemporarykeypan.sip
288+
%Include layout/qgslayoutviewtooltemporarykeyzoom.sip
289+
%Include layout/qgslayoutviewtooltemporarymousepan.sip
290+
%Include layout/qgslayoutviewtoolzoom.sip
278291
%Include locator/qgslocator.sip
279292
%Include locator/qgslocatorfilter.sip
280293
%Include locator/qgslocatorwidget.sip

python/gui/layout/qgslayoutdesignerinterface.sip

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,18 @@ class QgsLayoutDesignerInterface: QObject
3636
virtual QgsLayout *layout() = 0;
3737
%Docstring
3838
Returns the layout displayed in the designer.
39+
.. seealso:: view()
3940
:rtype: QgsLayout
4041
%End
4142

43+
44+
virtual QgsLayoutView *view() = 0;
45+
%Docstring
46+
Returns the layout view utilized by the designer.
47+
.. seealso:: layout()
48+
:rtype: QgsLayoutView
49+
%End
50+
4251
public slots:
4352

4453
virtual void close() = 0;
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/gui/layout/qgslayoutitemguiregistry.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
class QgsLayoutItemAbstractGuiMetadata
13+
{
14+
%Docstring
15+
Stores GUI metadata about one layout item class.
16+
17+
This is a companion to QgsLayoutItemAbstractMetadata, storing only
18+
the components related to the GUI behavior of a layout item.
19+
20+
.. note::
21+
22+
In C++ you can use QgsLayoutItemGuiMetadata convenience class.
23+
.. versionadded:: 3.0
24+
%End
25+
26+
%TypeHeaderCode
27+
#include "qgslayoutitemguiregistry.h"
28+
%End
29+
public:
30+
31+
QgsLayoutItemAbstractGuiMetadata( int type );
32+
%Docstring
33+
Constructor for QgsLayoutItemAbstractGuiMetadata with the specified class ``type``.
34+
%End
35+
36+
virtual ~QgsLayoutItemAbstractGuiMetadata();
37+
38+
int type() const;
39+
%Docstring
40+
Returns the unique item type code for the layout item class.
41+
:rtype: int
42+
%End
43+
44+
virtual QIcon creationIcon() const;
45+
%Docstring
46+
Returns an icon representing creation of the layout item type.
47+
:rtype: QIcon
48+
%End
49+
50+
virtual QWidget *createItemWidget() /Factory/;
51+
%Docstring
52+
Creates a configuration widget for layout items of this type. Can return None if no configuration GUI is required.
53+
:rtype: QWidget
54+
%End
55+
56+
virtual QgsLayoutViewRubberBand *createRubberBand( QgsLayoutView *view ) /Factory/;
57+
%Docstring
58+
Creates a rubber band for use when creating layout items of this type. Can return None if no rubber band
59+
should be created. The default behavior is to create a rectangular rubber band.
60+
:rtype: QgsLayoutViewRubberBand
61+
%End
62+
63+
};
64+
65+
66+
67+
68+
class QgsLayoutItemGuiRegistry : QObject
69+
{
70+
%Docstring
71+
Registry of available layout item GUI behavior.
72+
73+
QgsLayoutItemGuiRegistry is not usually directly created, but rather accessed through
74+
QgsGui.layoutItemGuiRegistry().
75+
76+
This acts as a companion to QgsLayoutItemRegistry, handling only
77+
the components related to the GUI behavior of layout items.
78+
79+
.. versionadded:: 3.0
80+
%End
81+
82+
%TypeHeaderCode
83+
#include "qgslayoutitemguiregistry.h"
84+
%End
85+
public:
86+
87+
QgsLayoutItemGuiRegistry( QObject *parent = 0 );
88+
%Docstring
89+
Creates a new empty item GUI registry.
90+
91+
QgsLayoutItemGuiRegistry is not usually directly created, but rather accessed through
92+
QgsGui.layoutItemGuiRegistry().
93+
94+
.. seealso:: populate()
95+
%End
96+
97+
~QgsLayoutItemGuiRegistry();
98+
99+
bool populate();
100+
%Docstring
101+
Populates the registry with standard item types. If called on a non-empty registry
102+
then this will have no effect and will return false.
103+
:rtype: bool
104+
%End
105+
106+
107+
QgsLayoutItemAbstractGuiMetadata *itemMetadata( int type ) const;
108+
%Docstring
109+
Returns the metadata for the specified item ``type``. Returns None if
110+
a corresponding type was not found in the registry.
111+
:rtype: QgsLayoutItemAbstractGuiMetadata
112+
%End
113+
114+
bool addLayoutItemGuiMetadata( QgsLayoutItemAbstractGuiMetadata *metadata /Transfer/ );
115+
%Docstring
116+
Registers the gui metadata for a new layout item type. Takes ownership of the metadata instance.
117+
:rtype: bool
118+
%End
119+
120+
QWidget *createItemWidget( int type ) const /Factory/;
121+
%Docstring
122+
Creates a new instance of a layout item configuration widget for the specified item ``type``.
123+
:rtype: QWidget
124+
%End
125+
126+
127+
QList< int > itemTypes() const;
128+
%Docstring
129+
Returns a list of available item types handled by the registry.
130+
:rtype: list of int
131+
%End
132+
133+
signals:
134+
135+
void typeAdded( int type );
136+
%Docstring
137+
Emitted whenever a new item type is added to the registry, with the specified
138+
``type``.
139+
%End
140+
141+
private:
142+
QgsLayoutItemGuiRegistry( const QgsLayoutItemGuiRegistry &rh );
143+
};
144+
145+
146+
147+
148+
/************************************************************************
149+
* This file has been generated automatically from *
150+
* *
151+
* src/gui/layout/qgslayoutitemguiregistry.h *
152+
* *
153+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
154+
************************************************************************/
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/gui/layout/qgslayoutitemregistryguiutils.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
class QgsLayoutItemRegistryGuiUtils
13+
{
14+
%Docstring
15+
A group of static utilities for working with the gui based portions of
16+
QgsLayoutItemRegistry.
17+
18+
This class is designed to allow Python item subclasses to override the
19+
default GUI based QgsLayoutItemAbstractMetadata methods, which
20+
cannot be directly overridden from Python subclasses.
21+
22+
.. versionadded:: 3.0
23+
%End
24+
25+
%TypeHeaderCode
26+
#include "qgslayoutitemregistryguiutils.h"
27+
%End
28+
public:
29+
30+
static void setItemRubberBandPrototype( int type, QgsLayoutViewRubberBand *prototype /Transfer/ );
31+
%Docstring
32+
Sets a ``prototype`` for the rubber bands for the layout item with specified ``type``.
33+
Python subclasses of QgsLayoutItem must call this method to register their prototypes,
34+
as the usual c++ QgsLayoutItemAbstractMetadata are not accessible via the Python bindings.
35+
%End
36+
37+
38+
};
39+
40+
/************************************************************************
41+
* This file has been generated automatically from *
42+
* *
43+
* src/gui/layout/qgslayoutitemregistryguiutils.h *
44+
* *
45+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
46+
************************************************************************/

0 commit comments

Comments
 (0)