[QGIS Commit] r14766 - in trunk/qgis: python/core src/core/composer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Thu Nov 25 16:45:53 EST 2010
Author: wonder
Date: 2010-11-25 13:45:52 -0800 (Thu, 25 Nov 2010)
New Revision: 14766
Modified:
trunk/qgis/python/core/qgscomposeritem.sip
trunk/qgis/python/core/qgscomposerlabel.sip
trunk/qgis/python/core/qgscomposerlegend.sip
trunk/qgis/python/core/qgscomposermap.sip
trunk/qgis/python/core/qgscomposerpicture.sip
trunk/qgis/python/core/qgscomposerscalebar.sip
trunk/qgis/python/core/qgscomposershape.sip
trunk/qgis/python/core/qgspaperitem.sip
trunk/qgis/src/core/composer/qgscomposerarrow.h
trunk/qgis/src/core/composer/qgscomposerattributetable.h
trunk/qgis/src/core/composer/qgscomposeritem.h
trunk/qgis/src/core/composer/qgscomposeritemgroup.h
trunk/qgis/src/core/composer/qgscomposerlabel.h
trunk/qgis/src/core/composer/qgscomposerlegend.h
trunk/qgis/src/core/composer/qgscomposermap.h
trunk/qgis/src/core/composer/qgscomposerpicture.h
trunk/qgis/src/core/composer/qgscomposerscalebar.h
trunk/qgis/src/core/composer/qgscomposershape.h
trunk/qgis/src/core/composer/qgscomposertable.h
trunk/qgis/src/core/composer/qgscomposertexttable.h
trunk/qgis/src/core/composer/qgspaperitem.h
Log:
Proper conversion to subclasses for composer items.
Modified: trunk/qgis/python/core/qgscomposeritem.sip
===================================================================
--- trunk/qgis/python/core/qgscomposeritem.sip 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/python/core/qgscomposeritem.sip 2010-11-25 21:45:52 UTC (rev 14766)
@@ -5,33 +5,104 @@
{
%TypeHeaderCode
#include <qgscomposeritem.h>
+//#include <qgscomposerarrow.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 <qgscomposertable.h>
+//#include <qgscomposerattributetable.h>
+//#include <qgscomposertexttable.h>
%End
%ConvertToSubClassCode
- if (dynamic_cast<QgsComposerLabel*>(sipCpp) != NULL)
- sipClass = sipClass_QgsComposerLabel;
- else if (dynamic_cast<QgsComposerLegend*>(sipCpp) != NULL)
- sipClass = sipClass_QgsComposerLegend;
- else if (dynamic_cast<QgsComposerMap*>(sipCpp) != NULL)
- sipClass = sipClass_QgsComposerMap;
- else if (dynamic_cast<QgsComposerPicture*>(sipCpp) != NULL)
- sipClass = sipClass_QgsComposerPicture;
- else if (dynamic_cast<QgsComposerScaleBar*>(sipCpp) != NULL)
- sipClass = sipClass_QgsComposerScaleBar;
- else if (dynamic_cast<QgsComposerShape*>(sipCpp) != NULL)
- sipClass = sipClass_QgsComposerShape;
- else
- sipClass = 0;
+ // 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::ComposerTable:
+ sipType = sipType_QgsComposerTable;
+ *sipCppRet = static_cast<QgsComposerTable*>(sipCpp);
+ break;
+ case QgsComposerItem::ComposerAttributeTable:
+ sipType = sipType_QgsComposerAttributeTable;
+ *sipCppRet = static_cast<QgsComposerAttributeTable*>(sipCpp);
+ break;
+ case QgsComposerItem::ComposerTextTable:
+ sipType = sipType_QgsComposerTextTable;
+ *sipCppRet = static_cast<QgsComposerTextTable*>(sipCpp);
+ break;*/
+ default:
+ sipType = 0;
+ }
%End
public:
+ enum ItemType
+ {
+ // base class for the items
+ ComposerItem = 65636, /* UserType + 100 ... SIP does not do arithmetic */
+
+ // derived classes
+ ComposerArrow,
+ ComposerItemGroup,
+ ComposerLabel,
+ ComposerLegend,
+ ComposerMap,
+ ComposerPaper, // QgsPaperItem
+ ComposerPicture,
+ ComposerScaleBar,
+ ComposerShape,
+ ComposerTable,
+ ComposerAttributeTable,
+ ComposerTextTable
+ };
+
/**Describes the action (move or resize in different directon) to be done during mouse move*/
enum MouseMoveAction
{
@@ -61,12 +132,15 @@
/**Constructor
@param manageZValue true if the z-Value of this object should be managed by mComposition*/
- QgsComposerItem( QgsComposition* composition, bool manageZValue = true );
+ QgsComposerItem( QgsComposition* composition /TransferThis/, bool manageZValue = true );
/**Constructor with box position and composer object
@param manageZValue true if the z-Value of this object should be managed by mComposition*/
- QgsComposerItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition, bool manageZValue = true );
+ QgsComposerItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition /TransferThis/, bool manageZValue = true );
virtual ~QgsComposerItem();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const;
+
/** \brief Set selected, selected item should be highlighted */
virtual void setSelected( bool s );
Modified: trunk/qgis/python/core/qgscomposerlabel.sip
===================================================================
--- trunk/qgis/python/core/qgscomposerlabel.sip 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/python/core/qgscomposerlabel.sip 2010-11-25 21:45:52 UTC (rev 14766)
@@ -10,6 +10,9 @@
QgsComposerLabel( QgsComposition *composition /TransferThis/);
~QgsComposerLabel();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const;
+
/** \brief Reimplementation of QCanvasItem::paint*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
Modified: trunk/qgis/python/core/qgscomposerlegend.sip
===================================================================
--- trunk/qgis/python/core/qgscomposerlegend.sip 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/python/core/qgscomposerlegend.sip 2010-11-25 21:45:52 UTC (rev 14766)
@@ -11,6 +11,9 @@
QgsComposerLegend( QgsComposition* composition /TransferThis/);
~QgsComposerLegend();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const;
+
/** \brief Reimplementation of QCanvasItem::paint*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
Modified: trunk/qgis/python/core/qgscomposermap.sip
===================================================================
--- trunk/qgis/python/core/qgscomposermap.sip 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/python/core/qgscomposermap.sip 2010-11-25 21:45:52 UTC (rev 14766)
@@ -16,6 +16,9 @@
QgsComposerMap( QgsComposition *composition /TransferThis/ );
~QgsComposerMap();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const;
+
/** \brief Preview style */
enum PreviewMode
{
Modified: trunk/qgis/python/core/qgscomposerpicture.sip
===================================================================
--- trunk/qgis/python/core/qgscomposerpicture.sip 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/python/core/qgscomposerpicture.sip 2010-11-25 21:45:52 UTC (rev 14766)
@@ -12,6 +12,9 @@
QgsComposerPicture( QgsComposition *composition /TransferThis/);
~QgsComposerPicture();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const;
+
/**Reimplementation of QCanvasItem::paint*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
Modified: trunk/qgis/python/core/qgscomposerscalebar.sip
===================================================================
--- trunk/qgis/python/core/qgscomposerscalebar.sip 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/python/core/qgscomposerscalebar.sip 2010-11-25 21:45:52 UTC (rev 14766)
@@ -12,6 +12,9 @@
QgsComposerScaleBar( QgsComposition* composition /TransferThis/);
~QgsComposerScaleBar();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const;
+
/** \brief Reimplementation of QCanvasItem::paint*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
Modified: trunk/qgis/python/core/qgscomposershape.sip
===================================================================
--- trunk/qgis/python/core/qgscomposershape.sip 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/python/core/qgscomposershape.sip 2010-11-25 21:45:52 UTC (rev 14766)
@@ -17,6 +17,9 @@
QgsComposerShape( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition /TransferThis/);
~QgsComposerShape();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const;
+
/** \brief Reimplementation of QCanvasItem::paint - draw on canvas */
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
Modified: trunk/qgis/python/core/qgspaperitem.sip
===================================================================
--- trunk/qgis/python/core/qgspaperitem.sip 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/python/core/qgspaperitem.sip 2010-11-25 21:45:52 UTC (rev 14766)
@@ -6,10 +6,13 @@
#include <qgspaperitem.h>
%End
public:
- QgsPaperItem( QgsComposition* c );
- QgsPaperItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition );
+ QgsPaperItem( QgsComposition* c /TransferThis/ );
+ QgsPaperItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition /TransferThis/ );
~QgsPaperItem();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const;
+
/** \brief Reimplementation of QCanvasItem::paint*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
@@ -26,4 +29,4 @@
private:
QgsPaperItem();
-};
\ No newline at end of file
+};
Modified: trunk/qgis/src/core/composer/qgscomposerarrow.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerarrow.h 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/src/core/composer/qgscomposerarrow.h 2010-11-25 21:45:52 UTC (rev 14766)
@@ -36,6 +36,9 @@
QgsComposerArrow( const QPointF& startPoint, const QPointF& stopPoint, QgsComposition* c );
~QgsComposerArrow();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const { return ComposerArrow; }
+
/** \brief Reimplementation of QCanvasItem::paint - draw on canvas */
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
Modified: trunk/qgis/src/core/composer/qgscomposerattributetable.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerattributetable.h 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/src/core/composer/qgscomposerattributetable.h 2010-11-25 21:45:52 UTC (rev 14766)
@@ -44,6 +44,9 @@
QgsComposerAttributeTable( QgsComposition* composition );
~QgsComposerAttributeTable();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const { return ComposerAttributeTable; }
+
/** \brief Reimplementation of QCanvasItem::paint*/
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
Modified: trunk/qgis/src/core/composer/qgscomposeritem.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposeritem.h 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/src/core/composer/qgscomposeritem.h 2010-11-25 21:45:52 UTC (rev 14766)
@@ -35,6 +35,26 @@
Q_OBJECT
public:
+ enum ItemType
+ {
+ // base class for the items
+ ComposerItem = UserType + 100,
+
+ // derived classes
+ ComposerArrow,
+ ComposerItemGroup,
+ ComposerLabel,
+ ComposerLegend,
+ ComposerMap,
+ ComposerPaper, // QgsPaperItem
+ ComposerPicture,
+ ComposerScaleBar,
+ ComposerShape,
+ ComposerTable,
+ ComposerAttributeTable,
+ ComposerTextTable
+ };
+
/**Describes the action (move or resize in different directon) to be done during mouse move*/
enum MouseMoveAction
{
@@ -77,6 +97,9 @@
QgsComposerItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition, bool manageZValue = true );
virtual ~QgsComposerItem();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const { return ComposerItem; }
+
/** \brief Set selected, selected item should be highlighted */
virtual void setSelected( bool s );
Modified: trunk/qgis/src/core/composer/qgscomposeritemgroup.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposeritemgroup.h 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/src/core/composer/qgscomposeritemgroup.h 2010-11-25 21:45:52 UTC (rev 14766)
@@ -27,6 +27,10 @@
public:
QgsComposerItemGroup( QgsComposition* c );
~QgsComposerItemGroup();
+
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const { return ComposerItemGroup; }
+
/**Adds an item to the group. All the group members are deleted
if the group is deleted*/
void addItem( QgsComposerItem* item );
Modified: trunk/qgis/src/core/composer/qgscomposerlabel.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerlabel.h 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/src/core/composer/qgscomposerlabel.h 2010-11-25 21:45:52 UTC (rev 14766)
@@ -28,6 +28,9 @@
QgsComposerLabel( QgsComposition *composition );
~QgsComposerLabel();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const { return ComposerLabel; }
+
/** \brief Reimplementation of QCanvasItem::paint*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
Modified: trunk/qgis/src/core/composer/qgscomposerlegend.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerlegend.h 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/src/core/composer/qgscomposerlegend.h 2010-11-25 21:45:52 UTC (rev 14766)
@@ -37,6 +37,9 @@
QgsComposerLegend( QgsComposition* composition );
~QgsComposerLegend();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const { return ComposerLegend; }
+
/** \brief Reimplementation of QCanvasItem::paint*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
Modified: trunk/qgis/src/core/composer/qgscomposermap.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposermap.h 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/src/core/composer/qgscomposermap.h 2010-11-25 21:45:52 UTC (rev 14766)
@@ -46,6 +46,9 @@
QgsComposerMap( QgsComposition *composition );
~QgsComposerMap();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const { return ComposerMap; }
+
/** \brief Preview style */
enum PreviewMode
{
Modified: trunk/qgis/src/core/composer/qgscomposerpicture.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerpicture.h 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/src/core/composer/qgscomposerpicture.h 2010-11-25 21:45:52 UTC (rev 14766)
@@ -31,6 +31,9 @@
QgsComposerPicture( QgsComposition *composition );
~QgsComposerPicture();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const { return ComposerPicture; }
+
/**Reimplementation of QCanvasItem::paint*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
Modified: trunk/qgis/src/core/composer/qgscomposerscalebar.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerscalebar.h 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/src/core/composer/qgscomposerscalebar.h 2010-11-25 21:45:52 UTC (rev 14766)
@@ -35,6 +35,9 @@
QgsComposerScaleBar( QgsComposition* composition );
~QgsComposerScaleBar();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const { return ComposerScaleBar; }
+
/** \brief Reimplementation of QCanvasItem::paint*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
Modified: trunk/qgis/src/core/composer/qgscomposershape.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposershape.h 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/src/core/composer/qgscomposershape.h 2010-11-25 21:45:52 UTC (rev 14766)
@@ -37,6 +37,9 @@
QgsComposerShape( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition );
~QgsComposerShape();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const { return ComposerShape; }
+
/** \brief Reimplementation of QCanvasItem::paint - draw on canvas */
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
Modified: trunk/qgis/src/core/composer/qgscomposertable.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposertable.h 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/src/core/composer/qgscomposertable.h 2010-11-25 21:45:52 UTC (rev 14766)
@@ -31,6 +31,9 @@
QgsComposerTable( QgsComposition* composition );
virtual ~QgsComposerTable();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const { return ComposerTable; }
+
/** \brief Reimplementation of QCanvasItem::paint*/
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
Modified: trunk/qgis/src/core/composer/qgscomposertexttable.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposertexttable.h 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/src/core/composer/qgscomposertexttable.h 2010-11-25 21:45:52 UTC (rev 14766)
@@ -27,6 +27,9 @@
QgsComposerTextTable( QgsComposition* c );
~QgsComposerTextTable();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const { return ComposerTextTable; }
+
void setHeaderLabels( const QStringList& l ) { mHeaderLabels = l; }
void addRow( const QStringList& row ) { mRowText.append( row ); }
Modified: trunk/qgis/src/core/composer/qgspaperitem.h
===================================================================
--- trunk/qgis/src/core/composer/qgspaperitem.h 2010-11-25 21:45:30 UTC (rev 14765)
+++ trunk/qgis/src/core/composer/qgspaperitem.h 2010-11-25 21:45:52 UTC (rev 14766)
@@ -29,6 +29,9 @@
QgsPaperItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition );
~QgsPaperItem();
+ /** return correct graphics item type. Added in v1.7 */
+ virtual int type() const { return ComposerPaper; }
+
/** \brief Reimplementation of QCanvasItem::paint*/
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
More information about the QGIS-commit
mailing list