QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
QgsComposerAttributeTableV2 Class Reference

A table that displays attributes from a vector layer. More...

#include <qgscomposerattributetablev2.h>

Inheritance diagram for QgsComposerAttributeTableV2:
Inheritance graph
[legend]

Public Types

enum  ContentSource { LayerAttributes = 0, AtlasFeature, RelationChildren }
- Public Types inherited from QgsComposerTableV2
enum  EmptyTableMode { HeadersOnly = 0, HideTable, ShowMessage }
enum  HeaderHAlignment { FollowColumn, HeaderLeft, HeaderCenter, HeaderRight }
enum  HeaderMode { FirstFrame = 0, AllFrames, NoHeaders }
- Public Types inherited from QgsComposerMultiFrame
enum  ResizeMode { UseExistingFrames = 0, ExtendToNextPage, RepeatOnEveryPage, RepeatUntilFinished }
- Public Types inherited from QgsComposerObject
enum  DataDefinedProperty {
  NoProperty = 0, AllProperties, TestProperty, PresetPaperSize,
  PaperWidth, PaperHeight, NumPages, PaperOrientation,
  PageNumber, PositionX, PositionY, ItemWidth,
  ItemHeight, ItemRotation, Transparency, BlendMode,
  ExcludeFromExports, MapRotation, MapScale, MapXMin,
  MapYMin, MapXMax, MapYMax, MapAtlasMargin,
  PictureSource, SourceUrl
}
 Data defined properties for different item types. More...
enum  PropertyValueType { EvaluatedValue = 0, OriginalValue }
 Specifies whether the value returned by a function should be the original, user set value, or the current evaluated value for the property. More...

Public Member Functions

 QgsComposerAttributeTableV2 (QgsComposition *composition, bool createUndoCommands)
 ~QgsComposerAttributeTableV2 ()
virtual void addFrame (QgsComposerFrame *frame, bool recalcFrameSizes=true) override
 Adds a frame to the multiframe.
const QgsComposerMapcomposerMap () const
 Returns the composer map whose extents are controlling the features shown in the table.
virtual QString displayName () const override
 Get multiframe display name.
bool displayOnlyVisibleFeatures () const
 Returns true if the table is set to show only features visible on a corresponding composer map item.
QString featureFilter () const
 Returns the current expression used to filter features for the table.
bool filterFeatures () const
 Returns true if a feature filter is active on the attribute table.
bool filterToAtlasFeature () const
 Returns true if the table is set to only show features which intersect the current atlas feature.
bool getTableContents (QgsComposerTableContents &contents) override
 Queries the attribute table's vector layer for attributes to show in the table.
int maximumNumberOfFeatures () const
 Returns the maximum number of features to be shown by the table.
virtual bool readXML (const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false) override
 Reads the properties specific to an attribute table from xml.
QString relationId () const
 Returns the relation id which the table displays child features from.
void resetColumns ()
 Resets the attribute table's columns to match the vector layer's fields.
void setComposerMap (const QgsComposerMap *map)
 Sets the composer map to use to limit the extent of features shown in the attribute table.
void setDisplayAttributes (const QSet< int > &attr, bool refresh=true)
 Sets the attributes to display in the table.
void setDisplayOnlyVisibleFeatures (const bool visibleOnly)
 Sets attribute table to only show features which are visible in a composer map item.
void setFeatureFilter (const QString &expression)
 Sets the expression used for filtering features in the table.
void setFilterFeatures (const bool filter)
 Sets whether the feature filter is active for the attribute table.
void setFilterToAtlasFeature (const bool filterToAtlas)
 Sets attribute table to only show features which intersect the current atlas feature.
void setMaximumNumberOfFeatures (const int features)
 Sets the maximum number of features shown by the table.
void setRelationId (const QString relationId)
 Sets the relation id from which to display child features.
void setSource (const ContentSource source)
 Sets the source for attributes to show in table body.
void setUniqueRowsOnly (const bool uniqueOnly)
 Sets attribute table to only show unique rows.
void setVectorLayer (QgsVectorLayer *layer)
 Sets the vector layer from which to display feature attributes.
QList< QPair< int, bool > > sortAttributes () const
 Returns the attributes used to sort the table's features.
ContentSource source () const
 Returns the source for attributes shown in the table body.
QgsVectorLayersourceLayer ()
 Returns the source layer for the table, considering the table source mode.
bool uniqueRowsOnly () const
 Returns true if the table is set to show only unique rows.
QgsVectorLayervectorLayer () const
 Returns the vector layer the attribute table is currently using.
virtual bool writeXML (QDomElement &elem, QDomDocument &doc, bool ignoreFrames=false) const override
 Writes properties specific to attribute tables.
- Public Member Functions inherited from QgsComposerTableV2
 QgsComposerTableV2 (QgsComposition *composition, bool createUndoCommands)
 QgsComposerTableV2 ()
virtual ~QgsComposerTableV2 ()
QColor backgroundColor () const
 Returns the color used for the background of the table.
double cellMargin () const
 Returns the margin distance between cell borders and their contents.
QgsComposerTableColumnscolumns ()
 Returns a pointer to the list of QgsComposerTableColumns shown in the table.
QFont contentFont () const
 Returns the font used to draw text in table body cells.
QColor contentFontColor () const
 Returns the color used to draw text in table body cells.
QgsComposerTableContentscontents ()
 Returns the current contents of the table.
EmptyTableMode emptyTableBehaviour () const
 Returns the behaviour mode for empty tables.
QString emptyTableMessage () const
 Returns the message for empty tables with no content rows.
virtual QSizeF fixedFrameSize (const int frameIndex=-1) const override
 Returns the fixed size for a frame, if desired.
QColor gridColor () const
 Returns the color used for grid lines in the table.
double gridStrokeWidth () const
 Returns the width of grid lines in the table.
QFont headerFont () const
 Returns the font used to draw header text in the table.
QColor headerFontColor () const
 Returns the color used to draw header text in the table.
HeaderHAlignment headerHAlignment () const
 Returns the horizontal alignment for table headers.
virtual QMap< int, QString > headerLabels () const
 Returns the text used in the column headers for the table.
HeaderMode headerMode () const
 Returns the display mode for headers in the table.
virtual QSizeF minFrameSize (const int frameIndex=-1) const override
 Returns the minimum size for a frames, if desired.
virtual void render (QPainter *p, const QRectF &renderExtent, const int frameIndex) override
 Renders a portion of the multiframe's content into a painter.
void setBackgroundColor (const QColor &color)
 Sets color used for background of table.
void setCellMargin (const double margin)
 Sets the margin distance between cell borders and their contents.
void setColumns (QgsComposerTableColumns columns)
 Replaces the columns in the table with a specified list of QgsComposerTableColumns.
void setContentFont (const QFont &font)
 Sets the font used to draw text in table body cells.
void setContentFontColor (const QColor &color)
 Sets the color used to draw text in table body cells.
void setEmptyTableBehaviour (const EmptyTableMode mode)
 Sets the behaviour for empty tables with no content rows.
void setEmptyTableMessage (const QString message)
 Sets the message for empty tables with no content rows.
void setGridColor (const QColor &color)
 Sets color used for grid lines in the table.
void setGridStrokeWidth (const double width)
 Sets the width for grid lines in the table.
void setHeaderFont (const QFont &font)
 Sets the font used to draw header text in the table.
void setHeaderFontColor (const QColor &color)
 Sets the color used to draw header text in the table.
void setHeaderHAlignment (const HeaderHAlignment alignment)
 Sets the horizontal alignment for table headers.
void setHeaderMode (const HeaderMode mode)
 Sets the display mode for headers in the table.
void setShowEmptyRows (const bool showEmpty)
 Sets whether empty rows should be drawn.
void setShowGrid (const bool showGrid)
 Sets whether grid lines should be drawn in the table.
bool showEmptyRows () const
 Returns whether empty rows are drawn in the table.
bool showGrid () const
 Returns whether grid lines are drawn in the table.
virtual QSizeF totalSize () const override
 Returns the total size of the multiframe's content.
- Public Member Functions inherited from QgsComposerMultiFrame
 QgsComposerMultiFrame (QgsComposition *c, bool createUndoCommands)
 Construct a new multiframe item.
virtual ~QgsComposerMultiFrame ()
bool _readXML (const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false)
 Restores state information about base multiframe object from a DOM element.
bool _writeXML (QDomElement &elem, QDomDocument &doc, bool ignoreFrames=false) const
 Stores state information about base multiframe object in DOM element.
QgsCompositioncomposition ()
 Returns the parent composition for the multiframe.
QgsComposerFramecreateNewFrame (QgsComposerFrame *currentFrame, QPointF pos, QSizeF size)
 Creates a new frame and adds it to the multi frame and composition.
bool createUndoCommands () const
 Returns whether undo commands should be created for interactions with the multiframe.
void deleteFrames ()
 Removes and deletes all child frames.
virtual double findNearbyPageBreak (double yPos)
 Finds the optimal position to break a frame at.
QgsComposerFrameframe (int i) const
 Returns a child frame from the multiframe.
int frameCount () const
 Returns the number of frames associated with this multiframe.
int frameIndex (QgsComposerFrame *frame) const
 Returns the index of a frame within the multiframe.
void removeFrame (int i, const bool removeEmptyPages=false)
 Removes a frame from the multiframe.
virtual Q_DECL_DEPRECATED void render (QPainter *p, const QRectF &renderExtent)
 Renders a portion of the multiframe's content into a painter.
ResizeMode resizeMode () const
 Returns the resize mode for the multiframe.
void setCreateUndoCommands (bool enabled)
 Sets whether undo commands should be created for interactions with the multiframe.
void setResizeMode (ResizeMode mode)
 Sets the resize mode for the multiframe, and recalculates frame sizes to match.
- Public Member Functions inherited from QgsComposerObject
 QgsComposerObject (QgsComposition *composition)
 Constructor.
virtual ~QgsComposerObject ()
const QgsCompositioncomposition () const
 Returns the composition the item is attached to.
QgsDataDefineddataDefinedProperty (const DataDefinedProperty property) const
 Returns a reference to the data defined settings for one of the item's data defined properties.
virtual bool readXML (const QDomElement &itemElem, const QDomDocument &doc)
 Sets item state from DOM element.
void setDataDefinedProperty (const DataDefinedProperty property, const bool active, const bool useExpression, const QString &expression, const QString &field)
 Sets parameters for a data defined property for the item.
virtual bool writeXML (QDomElement &elem, QDomDocument &doc) const
 Stores item state in DOM element.

Additional Inherited Members

- Public Slots inherited from QgsComposerTableV2
void recalculateFrameSizes () override
virtual void refreshAttributes ()
 Refreshes the contents shown in the table by querying for new data.
- Signals inherited from QgsComposerMultiFrame
void changed ()
 Emitted when the properties of a multi frame have changed, and the GUI item widget must be updated.
void contentsChanged ()
 Emitted when the contents of the multi frame have changed and the frames must be redrawn.
- Protected Slots inherited from QgsComposerMultiFrame
void handleFrameRemoval (QgsComposerItem *item)
 Called before a frame is going to be removed.
void handlePageChange ()
 Adapts to changed number of composition pages if resize type is RepeatOnEveryPage.
- Protected Member Functions inherited from QgsComposerTableV2
virtual bool calculateMaxColumnWidths ()
 Calculates the maximum width of text shown in columns.
bool contentsContainsRow (const QgsComposerTableContents &contents, const QgsComposerTableRow &row) const
 Checks whether a table contents contains a given row.
void drawHorizontalGridLines (QPainter *painter, const int rows, const bool drawHeaderLines) const
 Draws the horizontal grid lines for the table.
void drawVerticalGridLines (QPainter *painter, const QMap< int, double > &maxWidthMap, const int numberRows, const bool hasHeader, const bool mergeCells=false) const
 Draws the vertical grid lines for the table.
void recalculateTableSize ()
 Recalculates and updates the size of the table and all table frames.
QPair< int, int > rowRange (const QRectF &extent, const int frameIndex) const
 Calculates a range of rows which should be visible in a given frame extent.
int rowsVisible (const int frameIndex) const
 Calculates how many content rows are visible within a given frame.
int rowsVisible (const double frameHeight, const bool includeHeader) const
 Calculates how many content rows would be visible within a specified height.
double totalHeight () const
 Returns total height of table contents.
double totalWidth ()
 Returns total width of table contents.
- Protected Attributes inherited from QgsComposerTableV2
QColor mBackgroundColor
 Color for table background.
double mCellMargin
 Margin between cell borders and cell text.
QgsComposerTableColumns mColumns
 Columns to show in table.
QFont mContentFont
 Table contents font.
QColor mContentFontColor
 Table contents font color.
QString mEmptyTableMessage
 String to show in empty tables.
EmptyTableMode mEmptyTableMode
 Behaviour for empty tables.
QColor mGridColor
 Color for grid lines.
double mGridStrokeWidth
 Width of grid lines.
QFont mHeaderFont
 Header font.
QColor mHeaderFontColor
 Header font color.
HeaderHAlignment mHeaderHAlignment
 Alignment for table headers.
HeaderMode mHeaderMode
 Header display mode.
QMap< int, double > mMaxColumnWidthMap
 Map of maximum width for each column.
bool mShowEmptyRows
 True if empty rows should be shown in the table.
bool mShowGrid
 True if grid should be shown.
QgsComposerTableContents mTableContents
 Contents to show in table.
QSizeF mTableSize

Detailed Description

A table that displays attributes from a vector layer.

Definition at line 51 of file qgscomposerattributetablev2.h.

Member Enumeration Documentation

Specifies the content source for the attribute table

Enumerator:
LayerAttributes 

table shows attributes from features in a vector layer

AtlasFeature 

table shows attributes from the current atlas feature

RelationChildren 

table shows attributes from related child features

Definition at line 59 of file qgscomposerattributetablev2.h.

Constructor & Destructor Documentation

QgsComposerAttributeTableV2::QgsComposerAttributeTableV2 ( QgsComposition composition,
bool  createUndoCommands 
)

Definition at line 100 of file qgscomposerattributetablev2.cpp.

QgsComposerAttributeTableV2::~QgsComposerAttributeTableV2 ( )

Definition at line 147 of file qgscomposerattributetablev2.cpp.

Member Function Documentation

void QgsComposerAttributeTableV2::addFrame ( QgsComposerFrame frame,
bool  recalcFrameSizes = true 
)
overridevirtual

Adds a frame to the multiframe.

Parameters
frameframe to add
recalcFrameSizesset to true to force recalculation of all existing frame sizes
See Also
removeFrame

Implements QgsComposerMultiFrame.

Definition at line 777 of file qgscomposerattributetablev2.cpp.

const QgsComposerMap* QgsComposerAttributeTableV2::composerMap ( ) const
inline

Returns the composer map whose extents are controlling the features shown in the table.

The extents of the map are only used if displayOnlyVisibleFeatures() is true.

Returns
composer map controlling the attribute table
See Also
setComposerMap
displayOnlyVisibleFeatures

Definition at line 159 of file qgscomposerattributetablev2.h.

QString QgsComposerAttributeTableV2::displayName ( ) const
overridevirtual

Get multiframe display name.

Returns
display name for item
Note
added in version 2.5

Reimplemented from QgsComposerMultiFrame.

Definition at line 151 of file qgscomposerattributetablev2.cpp.

bool QgsComposerAttributeTableV2::displayOnlyVisibleFeatures ( ) const
inline

Returns true if the table is set to show only features visible on a corresponding composer map item.

Returns
true if table only shows visible features
See Also
composerMap
setDisplayOnlyVisibleFeatures

Definition at line 204 of file qgscomposerattributetablev2.h.

QString QgsComposerAttributeTableV2::featureFilter ( ) const
inline

Returns the current expression used to filter features for the table.

The filter is only active if filterFeatures() is true.

Returns
feature filter expression
See Also
setFeatureFilter
filterFeatures

Definition at line 243 of file qgscomposerattributetablev2.h.

bool QgsComposerAttributeTableV2::filterFeatures ( ) const
inline

Returns true if a feature filter is active on the attribute table.

Returns
bool state of the feature filter
See Also
setFilterFeatures
featureFilter

Definition at line 226 of file qgscomposerattributetablev2.h.

bool QgsComposerAttributeTableV2::filterToAtlasFeature ( ) const
inline

Returns true if the table is set to only show features which intersect the current atlas feature.

Returns
true if table only shows features which intersect the atlas feature
See Also
setFilterToAtlasFeature

Definition at line 219 of file qgscomposerattributetablev2.h.

bool QgsComposerAttributeTableV2::getTableContents ( QgsComposerTableContents contents)
overridevirtual

Queries the attribute table's vector layer for attributes to show in the table.

Parameters
contentstable content
Returns
true if attributes were successfully fetched
Note
not available in python bindings

Implements QgsComposerTableV2.

Definition at line 435 of file qgscomposerattributetablev2.cpp.

int QgsComposerAttributeTableV2::maximumNumberOfFeatures ( ) const
inline

Returns the maximum number of features to be shown by the table.

Returns
maximum number of features
See Also
setMaximumNumberOfFeatures

Definition at line 173 of file qgscomposerattributetablev2.h.

bool QgsComposerAttributeTableV2::readXML ( const QDomElement &  itemElem,
const QDomDocument &  doc,
bool  ignoreFrames = false 
)
overridevirtual

Reads the properties specific to an attribute table from xml.

Parameters
itemElema QDomElement holding the attribute table's desired properties.
docQDomDocument for the source xml.
ignoreFramesignore frames
See Also
writeXML

Reimplemented from QgsComposerTableV2.

Definition at line 696 of file qgscomposerattributetablev2.cpp.

QString QgsComposerAttributeTableV2::relationId ( ) const
inline

Returns the relation id which the table displays child features from.

Returns
relation id
See Also
setRelationId
source
Note
only used if table source is set to RelationChildren

Definition at line 135 of file qgscomposerattributetablev2.h.

void QgsComposerAttributeTableV2::resetColumns ( )

Resets the attribute table's columns to match the vector layer's fields.

See Also
setVectorLayer

Definition at line 243 of file qgscomposerattributetablev2.cpp.

void QgsComposerAttributeTableV2::setComposerMap ( const QgsComposerMap map)

Sets the composer map to use to limit the extent of features shown in the attribute table.

This setting only has an effect if setDisplayOnlyVisibleFeatures is set to true. Changing the composer map forces the table to refetch features from its vector layer, and may result in the table changing size to accommodate the new displayed feature attributes.

Parameters
mapQgsComposerMap which drives the extents of the table's features
See Also
composerMap
setDisplayOnlyVisibleFeatures

Definition at line 267 of file qgscomposerattributetablev2.cpp.

void QgsComposerAttributeTableV2::setDisplayAttributes ( const QSet< int > &  attr,
bool  refresh = true 
)

Sets the attributes to display in the table.

Parameters
attrQSet of integer values refering to the attributes from the vector layer to show. Set to an empty QSet to show all feature attributes.
refreshset to true to force the table to refetch features from its vector layer and immediately update the display of the table. This may result in the table changing size to accommodate the new displayed feature attributes.
See Also
displayAttributes

Definition at line 362 of file qgscomposerattributetablev2.cpp.

void QgsComposerAttributeTableV2::setDisplayOnlyVisibleFeatures ( const bool  visibleOnly)

Sets attribute table to only show features which are visible in a composer map item.

Changing this setting forces the table to refetch features from its vector layer, and may result in the table changing size to accommodate the new displayed feature attributes.

Parameters
visibleOnlyset to true to show only visible features
See Also
displayOnlyVisibleFeatures
setComposerMap

Definition at line 314 of file qgscomposerattributetablev2.cpp.

void QgsComposerAttributeTableV2::setFeatureFilter ( const QString &  expression)

Sets the expression used for filtering features in the table.

The filter is only active if filterFeatures() is set to true. Changing this setting forces the table to refetch features from its vector layer, and may result in the table changing size to accommodate the new displayed feature attributes.

Parameters
expressionfilter to use for selecting which features to display in the table
See Also
featureFilter
setFilterFeatures

Definition at line 350 of file qgscomposerattributetablev2.cpp.

void QgsComposerAttributeTableV2::setFilterFeatures ( const bool  filter)

Sets whether the feature filter is active for the attribute table.

Changing this setting forces the table to refetch features from its vector layer, and may result in the table changing size to accommodate the new displayed feature attributes.

Parameters
filterSet to true to enable the feature filter
See Also
filterFeatures
setFeatureFilter

Definition at line 338 of file qgscomposerattributetablev2.cpp.

void QgsComposerAttributeTableV2::setFilterToAtlasFeature ( const bool  filterToAtlas)

Sets attribute table to only show features which intersect the current atlas feature.

Parameters
filterToAtlasset to true to show only features which intersect the atlas feature
See Also
filterToAtlasFeature

Definition at line 326 of file qgscomposerattributetablev2.cpp.

void QgsComposerAttributeTableV2::setMaximumNumberOfFeatures ( const int  features)

Sets the maximum number of features shown by the table.

Changing this setting may result in the attribute table changing its size to accommodate the new number of rows, and requires the table to refetch features from its vector layer.

Parameters
featuresmaximum number of features to show in the table
See Also
maximumNumberOfFeatures

Definition at line 290 of file qgscomposerattributetablev2.cpp.

void QgsComposerAttributeTableV2::setRelationId ( const QString  relationId)

Sets the relation id from which to display child features.

Parameters
relationIdid for relation to display child features from
See Also
relationId
setSource
Note
only used if table source is set to RelationChildren

Definition at line 186 of file qgscomposerattributetablev2.cpp.

void QgsComposerAttributeTableV2::setSource ( const ContentSource  source)

Sets the source for attributes to show in table body.

Parameters
sourcecontent source
See Also
source

Definition at line 792 of file qgscomposerattributetablev2.cpp.

void QgsComposerAttributeTableV2::setUniqueRowsOnly ( const bool  uniqueOnly)

Sets attribute table to only show unique rows.

Parameters
uniqueOnlyset to true to show only unique rows. Duplicate rows will be stripped from the table.
See Also
uniqueRowsOnly

Definition at line 302 of file qgscomposerattributetablev2.cpp.

void QgsComposerAttributeTableV2::setVectorLayer ( QgsVectorLayer layer)

Sets the vector layer from which to display feature attributes.

Parameters
layerVector layer for attribute table
See Also
vectorLayer

Definition at line 156 of file qgscomposerattributetablev2.cpp.

QList< QPair< int, bool > > QgsComposerAttributeTableV2::sortAttributes ( ) const

Returns the attributes used to sort the table's features.

Returns
a QList of integer/bool pairs, where the integer refers to the attribute index and the bool to the sort order for the attribute. If true the attribute is sorted ascending, if false, the attribute is sorted in descending order.
Note
not available in python bindings

Definition at line 634 of file qgscomposerattributetablev2.cpp.

ContentSource QgsComposerAttributeTableV2::source ( ) const
inline

Returns the source for attributes shown in the table body.

Returns
content source
See Also
setSource

Definition at line 99 of file qgscomposerattributetablev2.h.

QgsVectorLayer * QgsComposerAttributeTableV2::sourceLayer ( )

Returns the source layer for the table, considering the table source mode.

Eg, if the table is set to atlas feature mode, then the source layer will be the atlas coverage layer. If the table is set to layer attributes mode, then the source layer will be the user specified vector layer.

Returns
actual source layer

Definition at line 598 of file qgscomposerattributetablev2.cpp.

bool QgsComposerAttributeTableV2::uniqueRowsOnly ( ) const
inline

Returns true if the table is set to show only unique rows.

Returns
true if table only shows unique rows and is stripping out duplicate rows.
See Also
setUniqueRowsOnly

Definition at line 187 of file qgscomposerattributetablev2.h.

QgsVectorLayer* QgsComposerAttributeTableV2::vectorLayer ( ) const
inline

Returns the vector layer the attribute table is currently using.

Returns
attribute table's current vector layer
See Also
setVectorLayer

Definition at line 119 of file qgscomposerattributetablev2.h.

bool QgsComposerAttributeTableV2::writeXML ( QDomElement &  elem,
QDomDocument &  doc,
bool  ignoreFrames = false 
) const
overridevirtual

Writes properties specific to attribute tables.

Parameters
eleman existing QDomElement in which to store the attribute table's properties.
docQDomDocument for the destination xml.
ignoreFramesignore frames
See Also
readXML

Reimplemented from QgsComposerTableV2.

Definition at line 664 of file qgscomposerattributetablev2.cpp.


The documentation for this class was generated from the following files: