Skip to content
Permalink
Browse files

Add missing sip casting for layout multiframe objects

  • Loading branch information
nyalldawson committed Jan 22, 2018
1 parent 77b570d commit d9b6c8b5d1d90cd168ff5482f3db526e5e198734
@@ -154,6 +154,10 @@ of layout items.
LayoutGroup,

// known

// WARNING
// values,

LayoutPage,
LayoutMap,
LayoutPicture,
@@ -166,6 +170,10 @@ of layout items.
LayoutFrame,

// known

// WARNING
// values,

LayoutHtml,
LayoutAttributeTable,
LayoutTextTable,
@@ -21,6 +21,38 @@ several frames (QgsLayoutFrame items).

%TypeHeaderCode
#include "qgslayoutmultiframe.h"
#include "qgslayoutitemhtml.h"
#include "qgslayoutitemattributetable.h"
#include "qgslayoutitemtexttable.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 ( QgsLayoutMultiFrame *mf = qobject_cast< QgsLayoutMultiFrame *>( sipCpp ) )
{
switch ( mf->type() )
{
// really, these *should* use the constants from QgsLayoutItemRegistry, but sip doesn't like that!
case QGraphicsItem::UserType + 112:
sipType = sipType_QgsLayoutItemHtml;
*sipCppRet = static_cast<QgsLayoutItemHtml *>( sipCpp );
break;
case QGraphicsItem::UserType + 113:
sipType = sipType_QgsLayoutItemAttributeTable;
*sipCppRet = static_cast<QgsLayoutItemAttributeTable *>( sipCpp );
break;
case QGraphicsItem::UserType + 114:
sipType = sipType_QgsLayoutItemTextTable;
*sipCppRet = static_cast<QgsLayoutItemTextTable *>( sipCpp );
break;
default:
sipType = 0;
}
}
else
{
sipType = 0;
}
%End
public:

@@ -296,6 +296,10 @@ class CORE_EXPORT QgsLayoutItemRegistry : public QObject
LayoutGroup, //!< Grouped item

// known item types

// WARNING!!!! SIP CASTING OF QgsLayoutItem and QgsLayoutMultiFrame DEPENDS on these
// values, and must be updated if any additional types are added

LayoutPage, //!< Page items
LayoutMap, //!< Map item
LayoutPicture, //!< Picture item
@@ -308,12 +312,16 @@ class CORE_EXPORT QgsLayoutItemRegistry : public QObject
LayoutFrame, //!< Frame item, part of a QgsLayoutMultiFrame object

// known multi-frame types

// WARNING!!!! SIP CASTING OF QgsLayoutItem and QgsLayoutMultiFrame DEPENDS on these
// values, and must be updated if any additional types are added

LayoutHtml, //!< Html multiframe item
LayoutAttributeTable, //!< Attribute table
LayoutTextTable, //!< Preset text table

// item types provided by plugins
PluginItem = LayoutTextTable + 1000, //!< Starting point for plugin item types
PluginItem = LayoutTextTable + 10000, //!< Starting point for plugin item types
};

/**
@@ -45,6 +45,44 @@ class QgsRenderContext;

class CORE_EXPORT QgsLayoutMultiFrame: public QgsLayoutObject, public QgsLayoutUndoObjectInterface
{
#ifdef SIP_RUN
#include "qgslayoutitemhtml.h"
#include "qgslayoutitemattributetable.h"
#include "qgslayoutitemtexttable.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 ( QgsLayoutMultiFrame *mf = qobject_cast< QgsLayoutMultiFrame *>( sipCpp ) )
{
switch ( mf->type() )
{
// really, these *should* use the constants from QgsLayoutItemRegistry, but sip doesn't like that!
case QGraphicsItem::UserType + 112:
sipType = sipType_QgsLayoutItemHtml;
*sipCppRet = static_cast<QgsLayoutItemHtml *>( sipCpp );
break;
case QGraphicsItem::UserType + 113:
sipType = sipType_QgsLayoutItemAttributeTable;
*sipCppRet = static_cast<QgsLayoutItemAttributeTable *>( sipCpp );
break;
case QGraphicsItem::UserType + 114:
sipType = sipType_QgsLayoutItemTextTable;
*sipCppRet = static_cast<QgsLayoutItemTextTable *>( sipCpp );
break;
default:
sipType = 0;
}
}
else
{
sipType = 0;
}
SIP_END
#endif

Q_OBJECT

@@ -62,7 +100,7 @@ class CORE_EXPORT QgsLayoutMultiFrame: public QgsLayoutObject, public QgsLayoutU
until the entire multiframe content is visible */
};

//! Multiframe item undo commands, used for collapsing undo commands
//! Multiframe item undo commands, used for collapsing undo commands
enum UndoCommand
{
UndoHtmlBreakDistance, //!< HTML page break distance

0 comments on commit d9b6c8b

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