From 91fa1e0da3db1e1238717511f16390c52ba5008a Mon Sep 17 00:00:00 2001 From: mhugent Date: Fri, 26 Nov 2010 10:30:19 +0000 Subject: [PATCH] Added binding files for composer attribute table git-svn-id: http://svn.osgeo.org/qgis/trunk@14770 c8812cc2-4d05-0410-92ff-de0c093fc19c --- python/core/core.sip | 2 ++ python/core/qgscomposerattributetable.sip | 44 +++++++++++++++++++++++ python/core/qgscomposertable.sip | 43 ++++++++++++++++++++++ python/gui/qgscomposerview.sip | 2 ++ src/core/composer/qgscomposertable.h | 4 +-- 5 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 python/core/qgscomposerattributetable.sip create mode 100644 python/core/qgscomposertable.sip diff --git a/python/core/core.sip b/python/core/core.sip index 4f880f4c75cc..f43a62f5a64f 100644 --- a/python/core/core.sip +++ b/python/core/core.sip @@ -12,6 +12,7 @@ %Include qgis.sip %Include qgsapplication.sip +%Include qgscomposerattributetable.sip %Include qgscomposeritem.sip %Include qgscomposerlabel.sip %Include qgscomposerlegend.sip @@ -19,6 +20,7 @@ %Include qgscomposerpicture.sip %Include qgscomposerscalebar.sip %Include qgscomposershape.sip +%Include qgscomposertable.sip %Include qgscomposition.sip %Include qgslegendmodel.sip %Include qgspaperitem.sip diff --git a/python/core/qgscomposerattributetable.sip b/python/core/qgscomposerattributetable.sip new file mode 100644 index 000000000000..8fae6d79c802 --- /dev/null +++ b/python/core/qgscomposerattributetable.sip @@ -0,0 +1,44 @@ +/** \ingroup MapComposer + * Attribute table item for map composer. + */ + +class QgsComposerAttributeTable: QgsComposerTable +{ +%TypeHeaderCode +#include +%End + + public: + QgsComposerAttributeTable( QgsComposition* composition /TransferThis/ ); + ~QgsComposerAttributeTable(); + + /** \brief Reimplementation of QCanvasItem::paint*/ + virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ); + + bool writeXML( QDomElement& elem, QDomDocument & doc ) const; + bool readXML( const QDomElement& itemElem, const QDomDocument& doc ); + + void setVectorLayer( QgsVectorLayer* vl ); + const QgsVectorLayer* vectorLayer() const; + + void setComposerMap( const QgsComposerMap* map /TransferThis/ ); + const QgsComposerMap* composerMap() const; + + void setMaximumNumberOfFeatures( int nr ); + int maximumNumberOfFeatures() const; + + void setDisplayOnlyVisibleFeatures( bool b ); + bool displayOnlyVisibleFeatures() const; + + QSet displayAttributes() const; + void setDisplayAttributes( const QSet& attr ); + + QMap fieldAliasMap() const; + void setFieldAliasMap( const QMap& map ); + + /**Adapts mMaximumNumberOfFeatures depending on the rectangle height*/ + void setSceneRect( const QRectF& rectangle ); + + //void setSortAttributes( const QList > att ); + //QList > sortAttributes() const; +}; diff --git a/python/core/qgscomposertable.sip b/python/core/qgscomposertable.sip new file mode 100644 index 000000000000..22770500f9c4 --- /dev/null +++ b/python/core/qgscomposertable.sip @@ -0,0 +1,43 @@ +/**A class to display feature attributes in the print composer*/ +class QgsComposerTable: QgsComposerItem +{ +%TypeHeaderCode +#include +%End + + public: + QgsComposerTable( QgsComposition* composition /TransferThis/ ); + virtual ~QgsComposerTable(); + + /** \brief Reimplementation of QCanvasItem::paint*/ + virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ); + + virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const = 0; + virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) = 0; + + void setLineTextDistance( double d ); + double lineTextDistance() const; + + void setHeaderFont( const QFont& f ); + QFont headerFont() const; + + void setContentFont( const QFont& f ); + QFont contentFont() const; + + void setShowGrid( bool show ); + bool showGrid() const; + + void setGridStrokeWidth( double w ); + double gridStrokeWidth() const; + + void setGridColor( const QColor& c ); + QColor gridColor() const; + + /**Adapts the size of the frame to match the content. This is normally done in the paint method, but sometimes \ + it needs to be done before the first render*/ + void adjustFrameToSize(); + + protected: + //virtual bool getFeatureAttributes( QList< QMap< int, QVariant> >& attributes ); + //virtual QMap getHeaderLabels() const; +}; diff --git a/python/gui/qgscomposerview.sip b/python/gui/qgscomposerview.sip index b7dabaaa1df2..a66782af3f38 100644 --- a/python/gui/qgscomposerview.sip +++ b/python/gui/qgscomposerview.sip @@ -62,6 +62,8 @@ class QgsComposerView: QGraphicsView void addComposerPicture( QgsComposerPicture* picture ); /**Adds a composer shape to the graphics scene and advices composer to create a widget for it (through signal)*/ void addComposerShape( QgsComposerShape* shape ); + /**Adds a composer table to the graphics scene and advices composer to create a widget for it (through signal)*/ + void addComposerTable( QgsComposerAttributeTable* table ); /**Returns the composer main window*/ QMainWindow* composerWindow(); diff --git a/src/core/composer/qgscomposertable.h b/src/core/composer/qgscomposertable.h index f6412c6ae07e..daa526d2786e 100644 --- a/src/core/composer/qgscomposertable.h +++ b/src/core/composer/qgscomposertable.h @@ -74,8 +74,8 @@ class CORE_EXPORT QgsComposerTable: public QgsComposerItem QColor mGridColor; /**Retrieves feature attributes*/ - virtual bool getFeatureAttributes( QList& attributes ) = 0; - virtual QMap getHeaderLabels() const = 0; + virtual bool getFeatureAttributes( QList& attributes ) {return false;} //= 0; + virtual QMap getHeaderLabels() const { return QMap(); } //= 0; /**Calculate the maximum width values of the vector attributes*/ virtual bool calculateMaxColumnWidths( QMap& maxWidthMap, const QList& attributeList ) const; /**Adapts the size of the item frame to match the content*/