Skip to content
Permalink
Browse files

Try to fix issues with sip casting collisions between layout and

compositions
  • Loading branch information
nyalldawson committed Dec 4, 2017
1 parent d69290e commit 66b4b45177182cf119b95c4faf497d6814afdb39
@@ -17,148 +17,6 @@ class QgsComposerItem: QgsComposerObject, QGraphicsRectItem

%TypeHeaderCode
#include "qgscomposeritem.h"
#include <qgscomposerarrow.h>
#include <qgscomposerframe.h>
#include <qgscomposeritemgroup.h>
#include <qgscomposerlabel.h>
#include <qgscomposerlegend.h>
#include <qgscomposermap.h>
#include <qgspaperitem.h>
#include <qgscomposerpicture.h>
#include <qgscomposerscalebar.h>
#include <qgscomposershape.h>
#include <qgscomposerpolygon.h>
#include <qgscomposerpolyline.h>
#include <qgscomposertexttable.h>
#include "qgslayoutitemgroup.h"
#include "qgslayoutitemmap.h"
#include "qgslayoutitempicture.h"
#include "qgslayoutitemlabel.h"
#include "qgslayoutitemlegend.h"
#include "qgslayoutitempolygon.h"
#include "qgslayoutitempolyline.h"
#include "qgslayoutitemscalebar.h"
#include "qgslayoutframe.h"
#include "qgslayoutitemshape.h"
#include "qgslayoutitempage.h"
%End
%ConvertToSubClassCode
// the conversions have to be static, because they're using multiple inheritance
// (seen in PyQt4 .sip files for some QGraphicsItem classes)
if ( dynamic_cast< QgsComposerItem * >( sipCpp ) )
{
switch ( sipCpp->type() )
{
case QgsComposerItem::ComposerItem:
sipType = sipType_QgsComposerItem;
*sipCppRet = static_cast<QgsComposerItem *>( sipCpp );
break;
case QgsComposerItem::ComposerArrow:
sipType = sipType_QgsComposerArrow;
*sipCppRet = static_cast<QgsComposerArrow *>( sipCpp );
break;
case QgsComposerItem::ComposerItemGroup:
sipType = sipType_QgsComposerItemGroup;
*sipCppRet = static_cast<QgsComposerItemGroup *>( sipCpp );
break;
case QgsComposerItem::ComposerLabel:
sipType = sipType_QgsComposerLabel;
*sipCppRet = static_cast<QgsComposerLabel *>( sipCpp );
break;
case QgsComposerItem::ComposerLegend:
sipType = sipType_QgsComposerLegend;
*sipCppRet = static_cast<QgsComposerLegend *>( sipCpp );
break;
case QgsComposerItem::ComposerMap:
sipType = sipType_QgsComposerMap;
*sipCppRet = static_cast<QgsComposerMap *>( sipCpp );
break;
case QgsComposerItem::ComposerPaper:
sipType = sipType_QgsPaperItem;
*sipCppRet = static_cast<QgsPaperItem *>( sipCpp );
break;
case QgsComposerItem::ComposerPicture:
sipType = sipType_QgsComposerPicture;
*sipCppRet = static_cast<QgsComposerPicture *>( sipCpp );
break;
case QgsComposerItem::ComposerScaleBar:
sipType = sipType_QgsComposerScaleBar;
*sipCppRet = static_cast<QgsComposerScaleBar *>( sipCpp );
break;
case QgsComposerItem::ComposerShape:
sipType = sipType_QgsComposerShape;
*sipCppRet = static_cast<QgsComposerShape *>( sipCpp );
break;
case QgsComposerItem::ComposerPolygon:
sipType = sipType_QgsComposerPolygon;
*sipCppRet = static_cast<QgsComposerPolygon *>( sipCpp );
break;
case QgsComposerItem::ComposerPolyline:
sipType = sipType_QgsComposerPolyline;
*sipCppRet = static_cast<QgsComposerPolyline *>( sipCpp );
break;
case QgsComposerItem::ComposerFrame:
sipType = sipType_QgsComposerFrame;
*sipCppRet = static_cast<QgsComposerFrame *>( sipCpp );
break;
default:
sipType = 0;
}
}
else
{
switch ( sipCpp->type() )
{
// really, these *should* use the constants from QgsLayoutItemRegistry, but sip doesn't like that!
case QGraphicsItem::UserType + 101:
sipType = sipType_QgsLayoutItemGroup;
*sipCppRet = static_cast<QgsLayoutItemGroup *>( sipCpp );
break;
case QGraphicsItem::UserType + 102:
sipType = sipType_QgsLayoutItemPage;
*sipCppRet = static_cast<QgsLayoutItemPage *>( sipCpp );
break;
case QGraphicsItem::UserType + 103:
sipType = sipType_QgsLayoutItemMap;
*sipCppRet = static_cast<QgsLayoutItemMap *>( sipCpp );
break;
case QGraphicsItem::UserType + 104:
sipType = sipType_QgsLayoutItemPicture;
*sipCppRet = static_cast<QgsLayoutItemPicture *>( sipCpp );
break;
case QGraphicsItem::UserType + 105:
sipType = sipType_QgsLayoutItemLabel;
*sipCppRet = static_cast<QgsLayoutItemLabel *>( sipCpp );
break;
case QGraphicsItem::UserType + 106:
sipType = sipType_QgsLayoutItemLegend;
*sipCppRet = static_cast<QgsLayoutItemLegend *>( sipCpp );
break;
case QGraphicsItem::UserType + 107:
sipType = sipType_QgsLayoutItemShape;
*sipCppRet = static_cast<QgsLayoutItemShape *>( sipCpp );
break;
case QGraphicsItem::UserType + 108:
sipType = sipType_QgsLayoutItemPolygon;
*sipCppRet = static_cast<QgsLayoutItemPolygon *>( sipCpp );
break;
case QGraphicsItem::UserType + 109:
sipType = sipType_QgsLayoutItemPolyline;
*sipCppRet = static_cast<QgsLayoutItemPolyline *>( sipCpp );
break;
case QGraphicsItem::UserType + 110:
sipType = sipType_QgsLayoutItemScaleBar;
*sipCppRet = static_cast<QgsLayoutItemScaleBar *>( sipCpp );
break;
case QGraphicsItem::UserType + 111:
sipType = sipType_QgsLayoutFrame;
*sipCppRet = static_cast<QgsLayoutFrame *>( sipCpp );
break;
default:
sipType = 0;
}
}

%End
public:

@@ -29,12 +29,79 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
#include "qgslayoutframe.h"
#include "qgslayoutitemshape.h"
#include "qgslayoutitempage.h"

#include "qgscomposerarrow.h"
#include "qgscomposeritemgroup.h"
#include "qgscomposerlabel.h"
#include "qgscomposerlegend.h"
#include "qgspaperitem.h"
#include "qgscomposerscalebar.h"
#include "qgscomposershape.h"
#include "qgscomposerpolygon.h"
#include "qgscomposerpolyline.h"


%End
%ConvertToSubClassCode
// the conversions have to be static, because they're using multiple inheritance
// (seen in PyQt4 .sip files for some QGraphicsItem classes)
switch ( sipCpp->type() )
{
case QgsComposerItem::ComposerItem:
sipType = sipType_QgsComposerItem;
*sipCppRet = static_cast<QgsComposerItem *>( sipCpp );
break;
case QgsComposerItem::ComposerArrow:
sipType = sipType_QgsComposerArrow;
*sipCppRet = static_cast<QgsComposerArrow *>( sipCpp );
break;
case QgsComposerItem::ComposerItemGroup:
sipType = sipType_QgsComposerItemGroup;
*sipCppRet = static_cast<QgsComposerItemGroup *>( sipCpp );
break;
case QgsComposerItem::ComposerLabel:
sipType = sipType_QgsComposerLabel;
*sipCppRet = static_cast<QgsComposerLabel *>( sipCpp );
break;
case QgsComposerItem::ComposerLegend:
sipType = sipType_QgsComposerLegend;
*sipCppRet = static_cast<QgsComposerLegend *>( sipCpp );
break;
case QgsComposerItem::ComposerMap:
sipType = sipType_QgsComposerMap;
*sipCppRet = static_cast<QgsComposerMap *>( sipCpp );
break;
case QgsComposerItem::ComposerPaper:
sipType = sipType_QgsPaperItem;
*sipCppRet = static_cast<QgsPaperItem *>( sipCpp );
break;
case QgsComposerItem::ComposerPicture:
sipType = sipType_QgsComposerPicture;
*sipCppRet = static_cast<QgsComposerPicture *>( sipCpp );
break;
case QgsComposerItem::ComposerScaleBar:
sipType = sipType_QgsComposerScaleBar;
*sipCppRet = static_cast<QgsComposerScaleBar *>( sipCpp );
break;
case QgsComposerItem::ComposerShape:
sipType = sipType_QgsComposerShape;
*sipCppRet = static_cast<QgsComposerShape *>( sipCpp );
break;
case QgsComposerItem::ComposerPolygon:
sipType = sipType_QgsComposerPolygon;
*sipCppRet = static_cast<QgsComposerPolygon *>( sipCpp );
break;
case QgsComposerItem::ComposerPolyline:
sipType = sipType_QgsComposerPolyline;
*sipCppRet = static_cast<QgsComposerPolyline *>( sipCpp );
break;
case QgsComposerItem::ComposerFrame:
sipType = sipType_QgsComposerFrame;
*sipCppRet = static_cast<QgsComposerFrame *>( sipCpp );
break;



// really, these *should* use the constants from QgsLayoutItemRegistry, but sip doesn't like that!
case QGraphicsItem::UserType + 101:
sipType = sipType_QgsLayoutItemGroup;
@@ -40,163 +40,13 @@ class QgsComposerEffect;
*/
class CORE_EXPORT QgsComposerItem: public QgsComposerObject, public QGraphicsRectItem
{
#ifdef SIP_RUN
#include <qgscomposerarrow.h>
#include <qgscomposerframe.h>
#include <qgscomposeritemgroup.h>
#include <qgscomposerlabel.h>
#include <qgscomposerlegend.h>
#include <qgscomposermap.h>
#include <qgspaperitem.h>
#include <qgscomposerpicture.h>
#include <qgscomposerscalebar.h>
#include <qgscomposershape.h>
#include <qgscomposerpolygon.h>
#include <qgscomposerpolyline.h>
#include <qgscomposertexttable.h>
#include "qgslayoutitemgroup.h"
#include "qgslayoutitemmap.h"
#include "qgslayoutitempicture.h"
#include "qgslayoutitemlabel.h"
#include "qgslayoutitemlegend.h"
#include "qgslayoutitempolygon.h"
#include "qgslayoutitempolyline.h"
#include "qgslayoutitemscalebar.h"
#include "qgslayoutframe.h"
#include "qgslayoutitemshape.h"
#include "qgslayoutitempage.h"
#endif


#ifdef SIP_RUN
SIP_CONVERT_TO_SUBCLASS_CODE
// the conversions have to be static, because they're using multiple inheritance
// (seen in PyQt4 .sip files for some QGraphicsItem classes)
if ( dynamic_cast< QgsComposerItem * >( sipCpp ) )
{
switch ( sipCpp->type() )
{
case QgsComposerItem::ComposerItem:
sipType = sipType_QgsComposerItem;
*sipCppRet = static_cast<QgsComposerItem *>( sipCpp );
break;
case QgsComposerItem::ComposerArrow:
sipType = sipType_QgsComposerArrow;
*sipCppRet = static_cast<QgsComposerArrow *>( sipCpp );
break;
case QgsComposerItem::ComposerItemGroup:
sipType = sipType_QgsComposerItemGroup;
*sipCppRet = static_cast<QgsComposerItemGroup *>( sipCpp );
break;
case QgsComposerItem::ComposerLabel:
sipType = sipType_QgsComposerLabel;
*sipCppRet = static_cast<QgsComposerLabel *>( sipCpp );
break;
case QgsComposerItem::ComposerLegend:
sipType = sipType_QgsComposerLegend;
*sipCppRet = static_cast<QgsComposerLegend *>( sipCpp );
break;
case QgsComposerItem::ComposerMap:
sipType = sipType_QgsComposerMap;
*sipCppRet = static_cast<QgsComposerMap *>( sipCpp );
break;
case QgsComposerItem::ComposerPaper:
sipType = sipType_QgsPaperItem;
*sipCppRet = static_cast<QgsPaperItem *>( sipCpp );
break;
case QgsComposerItem::ComposerPicture:
sipType = sipType_QgsComposerPicture;
*sipCppRet = static_cast<QgsComposerPicture *>( sipCpp );
break;
case QgsComposerItem::ComposerScaleBar:
sipType = sipType_QgsComposerScaleBar;
*sipCppRet = static_cast<QgsComposerScaleBar *>( sipCpp );
break;
case QgsComposerItem::ComposerShape:
sipType = sipType_QgsComposerShape;
*sipCppRet = static_cast<QgsComposerShape *>( sipCpp );
break;
case QgsComposerItem::ComposerPolygon:
sipType = sipType_QgsComposerPolygon;
*sipCppRet = static_cast<QgsComposerPolygon *>( sipCpp );
break;
case QgsComposerItem::ComposerPolyline:
sipType = sipType_QgsComposerPolyline;
*sipCppRet = static_cast<QgsComposerPolyline *>( sipCpp );
break;
case QgsComposerItem::ComposerFrame:
sipType = sipType_QgsComposerFrame;
*sipCppRet = static_cast<QgsComposerFrame *>( sipCpp );
break;
default:
sipType = 0;
}
}
else
{
switch ( sipCpp->type() )
{
// really, these *should* use the constants from QgsLayoutItemRegistry, but sip doesn't like that!
case QGraphicsItem::UserType + 101:
sipType = sipType_QgsLayoutItemGroup;
*sipCppRet = static_cast<QgsLayoutItemGroup *>( sipCpp );
break;
case QGraphicsItem::UserType + 102:
sipType = sipType_QgsLayoutItemPage;
*sipCppRet = static_cast<QgsLayoutItemPage *>( sipCpp );
break;
case QGraphicsItem::UserType + 103:
sipType = sipType_QgsLayoutItemMap;
*sipCppRet = static_cast<QgsLayoutItemMap *>( sipCpp );
break;
case QGraphicsItem::UserType + 104:
sipType = sipType_QgsLayoutItemPicture;
*sipCppRet = static_cast<QgsLayoutItemPicture *>( sipCpp );
break;
case QGraphicsItem::UserType + 105:
sipType = sipType_QgsLayoutItemLabel;
*sipCppRet = static_cast<QgsLayoutItemLabel *>( sipCpp );
break;
case QGraphicsItem::UserType + 106:
sipType = sipType_QgsLayoutItemLegend;
*sipCppRet = static_cast<QgsLayoutItemLegend *>( sipCpp );
break;
case QGraphicsItem::UserType + 107:
sipType = sipType_QgsLayoutItemShape;
*sipCppRet = static_cast<QgsLayoutItemShape *>( sipCpp );
break;
case QGraphicsItem::UserType + 108:
sipType = sipType_QgsLayoutItemPolygon;
*sipCppRet = static_cast<QgsLayoutItemPolygon *>( sipCpp );
break;
case QGraphicsItem::UserType + 109:
sipType = sipType_QgsLayoutItemPolyline;
*sipCppRet = static_cast<QgsLayoutItemPolyline *>( sipCpp );
break;
case QGraphicsItem::UserType + 110:
sipType = sipType_QgsLayoutItemScaleBar;
*sipCppRet = static_cast<QgsLayoutItemScaleBar *>( sipCpp );
break;
case QGraphicsItem::UserType + 111:
sipType = sipType_QgsLayoutFrame;
*sipCppRet = static_cast<QgsLayoutFrame *>( sipCpp );
break;
default:
sipType = 0;
}
}

SIP_END
#endif


Q_OBJECT
public:

enum ItemType
{
// base class for the items
ComposerItem = UserType + 100,
ComposerItem = UserType + 10000,

// derived classes
ComposerArrow,

0 comments on commit 66b4b45

Please sign in to comment.
You can’t perform that action at this time.