@@ -38,6 +38,91 @@ class QgsReadWriteContext;
38
38
*/
39
39
class CORE_EXPORT QgsLayoutObject: public QObject, public QgsExpressionContextGenerator
40
40
{
41
+ #ifdef SIP_RUN
42
+ #include < qgslayoutitem.h>
43
+ #include " qgslayoutitemgroup.h"
44
+ #include " qgslayoutitemmap.h"
45
+ #include " qgslayoutitempicture.h"
46
+ #include " qgslayoutitemlabel.h"
47
+ #include " qgslayoutitemlegend.h"
48
+ #include " qgslayoutitempolygon.h"
49
+ #include " qgslayoutitempolyline.h"
50
+ #include " qgslayoutitemscalebar.h"
51
+ #include " qgslayoutframe.h"
52
+ #include " qgslayoutitemshape.h"
53
+ #include " qgslayoutitempage.h"
54
+ #endif
55
+
56
+ #ifdef SIP_RUN
57
+ SIP_CONVERT_TO_SUBCLASS_CODE
58
+ if ( QgsLayoutItem *item = qobject_cast< QgsLayoutItem * >( sipCpp ) )
59
+ {
60
+ // the conversions have to be static, because they're using multiple inheritance
61
+ // (seen in PyQt4 .sip files for some QGraphicsItem classes)
62
+ switch ( item->type () )
63
+ {
64
+ // FREAKKKKIIN IMPORTANT!
65
+ // IF YOU PUT SOMETHING HERE, PUT IT IN QgsLayoutItem CASTING **ALSO**
66
+ // (it's not enough for it to be in only one of the places, as sip inconsistently
67
+ // decides which casting code to perform here)
68
+
69
+ // really, these *should* use the constants from QgsLayoutItemRegistry, but sip doesn't like that!
70
+ case QGraphicsItem::UserType + 101 :
71
+ sipType = sipType_QgsLayoutItemGroup;
72
+ *sipCppRet = static_cast <QgsLayoutItemGroup *>( sipCpp );
73
+ break ;
74
+ case QGraphicsItem::UserType + 102 :
75
+ sipType = sipType_QgsLayoutItemPage;
76
+ *sipCppRet = static_cast <QgsLayoutItemPage *>( sipCpp );
77
+ break ;
78
+ case QGraphicsItem::UserType + 103 :
79
+ sipType = sipType_QgsLayoutItemMap;
80
+ *sipCppRet = static_cast <QgsLayoutItemMap *>( sipCpp );
81
+ break ;
82
+ case QGraphicsItem::UserType + 104 :
83
+ sipType = sipType_QgsLayoutItemPicture;
84
+ *sipCppRet = static_cast <QgsLayoutItemPicture *>( sipCpp );
85
+ break ;
86
+ case QGraphicsItem::UserType + 105 :
87
+ sipType = sipType_QgsLayoutItemLabel;
88
+ *sipCppRet = static_cast <QgsLayoutItemLabel *>( sipCpp );
89
+ break ;
90
+ case QGraphicsItem::UserType + 106 :
91
+ sipType = sipType_QgsLayoutItemLegend;
92
+ *sipCppRet = static_cast <QgsLayoutItemLegend *>( sipCpp );
93
+ break ;
94
+ case QGraphicsItem::UserType + 107 :
95
+ sipType = sipType_QgsLayoutItemShape;
96
+ *sipCppRet = static_cast <QgsLayoutItemShape *>( sipCpp );
97
+ break ;
98
+ case QGraphicsItem::UserType + 108 :
99
+ sipType = sipType_QgsLayoutItemPolygon;
100
+ *sipCppRet = static_cast <QgsLayoutItemPolygon *>( sipCpp );
101
+ break ;
102
+ case QGraphicsItem::UserType + 109 :
103
+ sipType = sipType_QgsLayoutItemPolyline;
104
+ *sipCppRet = static_cast <QgsLayoutItemPolyline *>( sipCpp );
105
+ break ;
106
+ case QGraphicsItem::UserType + 110 :
107
+ sipType = sipType_QgsLayoutItemScaleBar;
108
+ *sipCppRet = static_cast <QgsLayoutItemScaleBar *>( sipCpp );
109
+ break ;
110
+ case QGraphicsItem::UserType + 111 :
111
+ sipType = sipType_QgsLayoutFrame;
112
+ *sipCppRet = static_cast <QgsLayoutFrame *>( sipCpp );
113
+ break ;
114
+
115
+ // did you read that comment above? NO? Go read it now. You're about to break stuff.
116
+
117
+ default :
118
+ sipType = sipType_QgsLayoutItem;
119
+ }
120
+ }
121
+ else
122
+ sipType = NULL ;
123
+ SIP_END
124
+ #endif
125
+
41
126
Q_OBJECT
42
127
public:
43
128
0 commit comments