Skip to content

Commit

Permalink
Added binding files for composer attribute table
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14770 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Nov 26, 2010
1 parent fe88d72 commit 6568583
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 2 deletions.
2 changes: 2 additions & 0 deletions python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@

%Include qgis.sip
%Include qgsapplication.sip
%Include qgscomposerattributetable.sip
%Include qgscomposeritem.sip
%Include qgscomposerlabel.sip
%Include qgscomposerlegend.sip
%Include qgscomposermap.sip
%Include qgscomposerpicture.sip
%Include qgscomposerscalebar.sip
%Include qgscomposershape.sip
%Include qgscomposertable.sip
%Include qgscomposition.sip
%Include qgslegendmodel.sip
%Include qgspaperitem.sip
Expand Down
44 changes: 44 additions & 0 deletions python/core/qgscomposerattributetable.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/** \ingroup MapComposer
* Attribute table item for map composer.
*/

class QgsComposerAttributeTable: QgsComposerTable
{
%TypeHeaderCode
#include <qgscomposerattributetable.h>
%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<int> displayAttributes() const;
void setDisplayAttributes( const QSet<int>& attr );

QMap<int, QString> fieldAliasMap() const;
void setFieldAliasMap( const QMap<int, QString>& map );

/**Adapts mMaximumNumberOfFeatures depending on the rectangle height*/
void setSceneRect( const QRectF& rectangle );

//void setSortAttributes( const QList<QPair<int, bool> > att );
//QList<QPair<int, bool> > sortAttributes() const;
};
43 changes: 43 additions & 0 deletions python/core/qgscomposertable.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**A class to display feature attributes in the print composer*/
class QgsComposerTable: QgsComposerItem
{
%TypeHeaderCode
#include <qgscomposertable.h>
%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<int, QString> getHeaderLabels() const;
};
2 changes: 2 additions & 0 deletions python/gui/qgscomposerview.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposertable.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class CORE_EXPORT QgsComposerTable: public QgsComposerItem
QColor mGridColor;

/**Retrieves feature attributes*/
virtual bool getFeatureAttributes( QList<QgsAttributeMap>& attributes ) = 0;
virtual QMap<int, QString> getHeaderLabels() const = 0;
virtual bool getFeatureAttributes( QList<QgsAttributeMap>& attributes ) {return false;} //= 0;
virtual QMap<int, QString> getHeaderLabels() const { return QMap<int, QString>(); } //= 0;
/**Calculate the maximum width values of the vector attributes*/
virtual bool calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeList ) const;
/**Adapts the size of the item frame to match the content*/
Expand Down

0 comments on commit 6568583

Please sign in to comment.