Skip to content

Commit 0e3af9c

Browse files
committedFeb 19, 2018
[layouts] Remove use of QStyleOptionGraphicsItem from QgsLayoutItem API
Turns out the useful methods in QStyleOptionGraphicsItem were deprecated in Qt 5.10. To future protect our API this replaces all public use of QStyleOptionGraphicsItem, so that we're free to revise the internals of how we use QStyleOptionGraphicsItem without breaking the public QGIS API.
1 parent 9911209 commit 0e3af9c

Some content is hidden

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

54 files changed

+268
-125
lines changed
 

‎python/core/layout/qgslayoutframe.sip.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Returns whether the frame is empty.
118118

119119
protected:
120120

121-
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
121+
virtual void draw( QgsLayoutItemRenderContext &context );
122122

123123
virtual void drawFrame( QgsRenderContext &context );
124124

‎python/core/layout/qgslayoutitem.sip.in

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,64 @@
99

1010

1111

12+
13+
class QgsLayoutItemRenderContext
14+
{
15+
%Docstring
16+
Contains settings and helpers relating to a render of a QgsLayoutItem.
17+
18+
.. versionadded:: 3.0
19+
%End
20+
21+
%TypeHeaderCode
22+
#include "qgslayoutitem.h"
23+
%End
24+
public:
25+
26+
QgsLayoutItemRenderContext( QgsRenderContext &context, double viewScaleFactor = 1.0 );
27+
%Docstring
28+
Constructor for QgsLayoutItemRenderContext.
29+
30+
The ``renderContext`` parameter specifies a QgsRenderContext for use within
31+
the QgsLayoutItemRenderContext.
32+
33+
The ``viewScaleFactor`` gives the current view zoom (scale factor). It can be
34+
used to scale render graphics so that they always appear a constant size,
35+
regardless of the current view zoom.
36+
%End
37+
38+
39+
40+
QgsRenderContext &renderContext();
41+
%Docstring
42+
Returns a reference to the context's render context.
43+
44+
Note that the context's painter has been scaled so that painter units are pixels.
45+
Use the QgsRenderContext methods to convert from millimeters or other units to the painter's units.
46+
%End
47+
48+
49+
double viewScaleFactor() const;
50+
%Docstring
51+
Returns the current view zoom (scale factor). It can be
52+
used to scale render graphics so that they always appear a constant size,
53+
regardless of the current view zoom.
54+
55+
E.g. a value of 0.5 indicates that the view is zoomed out to 50% size, so rendered
56+
items must be scaled by 200% in order to have a constant visible size. A value
57+
of 2.0 indicates that the view is zoomed in 200%, so rendered items must be
58+
scaled by 50% in order to have a constant visible size.
59+
%End
60+
61+
private:
62+
QgsLayoutItemRenderContext( const QgsLayoutItemRenderContext &rh );
63+
};
64+
65+
1266
class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInterface
1367
{
1468
%Docstring
15-
Base class for graphical items within a QgsLayout.
69+
Base class for graphical items within a :py:class:`QgsLayout`.
1670

1771
.. versionadded:: 3.0
1872
%End
@@ -939,9 +993,10 @@ painter.
939993
:param painter: destination QPainter
940994
%End
941995

942-
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 ) = 0;
996+
virtual void draw( QgsLayoutItemRenderContext &context ) = 0;
943997
%Docstring
944-
Draws the item's contents using the specified render ``context``.
998+
Draws the item's contents using the specified item render ``context``.
999+
9451000
Note that the context's painter has been scaled so that painter units are pixels.
9461001
Use the QgsRenderContext methods to convert from millimeters or other units to the painter's units.
9471002
%End

0 commit comments

Comments
 (0)
Please sign in to comment.