Skip to content

Commit 91fa1e0

Browse files
author
mhugent
committed
Added binding files for composer attribute table
git-svn-id: http://svn.osgeo.org/qgis/trunk@14770 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent ecae309 commit 91fa1e0

File tree

5 files changed

+93
-2
lines changed

5 files changed

+93
-2
lines changed

python/core/core.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212

1313
%Include qgis.sip
1414
%Include qgsapplication.sip
15+
%Include qgscomposerattributetable.sip
1516
%Include qgscomposeritem.sip
1617
%Include qgscomposerlabel.sip
1718
%Include qgscomposerlegend.sip
1819
%Include qgscomposermap.sip
1920
%Include qgscomposerpicture.sip
2021
%Include qgscomposerscalebar.sip
2122
%Include qgscomposershape.sip
23+
%Include qgscomposertable.sip
2224
%Include qgscomposition.sip
2325
%Include qgslegendmodel.sip
2426
%Include qgspaperitem.sip
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/** \ingroup MapComposer
2+
* Attribute table item for map composer.
3+
*/
4+
5+
class QgsComposerAttributeTable: QgsComposerTable
6+
{
7+
%TypeHeaderCode
8+
#include <qgscomposerattributetable.h>
9+
%End
10+
11+
public:
12+
QgsComposerAttributeTable( QgsComposition* composition /TransferThis/ );
13+
~QgsComposerAttributeTable();
14+
15+
/** \brief Reimplementation of QCanvasItem::paint*/
16+
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
17+
18+
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
19+
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
20+
21+
void setVectorLayer( QgsVectorLayer* vl );
22+
const QgsVectorLayer* vectorLayer() const;
23+
24+
void setComposerMap( const QgsComposerMap* map /TransferThis/ );
25+
const QgsComposerMap* composerMap() const;
26+
27+
void setMaximumNumberOfFeatures( int nr );
28+
int maximumNumberOfFeatures() const;
29+
30+
void setDisplayOnlyVisibleFeatures( bool b );
31+
bool displayOnlyVisibleFeatures() const;
32+
33+
QSet<int> displayAttributes() const;
34+
void setDisplayAttributes( const QSet<int>& attr );
35+
36+
QMap<int, QString> fieldAliasMap() const;
37+
void setFieldAliasMap( const QMap<int, QString>& map );
38+
39+
/**Adapts mMaximumNumberOfFeatures depending on the rectangle height*/
40+
void setSceneRect( const QRectF& rectangle );
41+
42+
//void setSortAttributes( const QList<QPair<int, bool> > att );
43+
//QList<QPair<int, bool> > sortAttributes() const;
44+
};

python/core/qgscomposertable.sip

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**A class to display feature attributes in the print composer*/
2+
class QgsComposerTable: QgsComposerItem
3+
{
4+
%TypeHeaderCode
5+
#include <qgscomposertable.h>
6+
%End
7+
8+
public:
9+
QgsComposerTable( QgsComposition* composition /TransferThis/ );
10+
virtual ~QgsComposerTable();
11+
12+
/** \brief Reimplementation of QCanvasItem::paint*/
13+
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
14+
15+
virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const = 0;
16+
virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) = 0;
17+
18+
void setLineTextDistance( double d );
19+
double lineTextDistance() const;
20+
21+
void setHeaderFont( const QFont& f );
22+
QFont headerFont() const;
23+
24+
void setContentFont( const QFont& f );
25+
QFont contentFont() const;
26+
27+
void setShowGrid( bool show );
28+
bool showGrid() const;
29+
30+
void setGridStrokeWidth( double w );
31+
double gridStrokeWidth() const;
32+
33+
void setGridColor( const QColor& c );
34+
QColor gridColor() const;
35+
36+
/**Adapts the size of the frame to match the content. This is normally done in the paint method, but sometimes \
37+
it needs to be done before the first render*/
38+
void adjustFrameToSize();
39+
40+
protected:
41+
//virtual bool getFeatureAttributes( QList< QMap< int, QVariant> >& attributes );
42+
//virtual QMap<int, QString> getHeaderLabels() const;
43+
};

python/gui/qgscomposerview.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class QgsComposerView: QGraphicsView
6262
void addComposerPicture( QgsComposerPicture* picture );
6363
/**Adds a composer shape to the graphics scene and advices composer to create a widget for it (through signal)*/
6464
void addComposerShape( QgsComposerShape* shape );
65+
/**Adds a composer table to the graphics scene and advices composer to create a widget for it (through signal)*/
66+
void addComposerTable( QgsComposerAttributeTable* table );
6567

6668
/**Returns the composer main window*/
6769
QMainWindow* composerWindow();

src/core/composer/qgscomposertable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class CORE_EXPORT QgsComposerTable: public QgsComposerItem
7474
QColor mGridColor;
7575

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

0 commit comments

Comments
 (0)