QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Public Types | Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
QgsComposerTableV2 Class Referenceabstract

A class to display a table in the print composer, and allow the table to span over multiple frames. More...

#include <qgscomposertablev2.h>

Inheritance diagram for QgsComposerTableV2:
Inheritance graph
[legend]

Public Types

enum  CellStyleGroup {
  OddColumns, EvenColumns, OddRows, EvenRows,
  FirstColumn, LastColumn, HeaderRow, FirstRow,
  LastRow
}
 Row or column groups for cell styling. More...
 
enum  EmptyTableMode { HeadersOnly = 0, HideTable, ShowMessage }
 Controls how empty tables are displayed. More...
 
enum  HeaderHAlignment { FollowColumn, HeaderLeft, HeaderCenter, HeaderRight }
 Controls how headers are horizontally aligned in a table. More...
 
enum  HeaderMode { FirstFrame = 0, AllFrames, NoHeaders }
 Controls where headers are shown in the table. More...
 
enum  WrapBehaviour { TruncateText = 0, WrapText }
 Controls how long strings in the table are handled. More...
 
- Public Types inherited from QgsComposerMultiFrame
enum  ResizeMode { UseExistingFrames = 0, ExtendToNextPage, RepeatOnEveryPage, RepeatUntilFinished }
 Specifies the behaviour for creating new frames to fit the multiframe's content. More...
 
- 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,
  MapLayers, MapStylePreset, 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 Slots

void recalculateFrameSizes () override
 
virtual void refreshAttributes ()
 Refreshes the contents shown in the table by querying for new data. More...
 
- Public Slots inherited from QgsComposerMultiFrame
void recalculateFrameRects ()
 Forces a recalculation of all the associated frame's scene rectangles. More...
 
virtual void recalculateFrameSizes ()
 Recalculates the portion of the multiframe item which is shown in each of it's component frames. More...
 
void update ()
 Forces a redraw of all child frames. More...
 
- Public Slots inherited from QgsComposerObject
virtual void refreshDataDefinedProperty (const DataDefinedProperty property=AllProperties, const QgsExpressionContext *context=nullptr)
 Refreshes a data defined property for the item by reevaluating the property's value and redrawing the item with this new value. More...
 
virtual void repaint ()
 Triggers a redraw for the item. More...
 

Public Member Functions

 QgsComposerTableV2 (QgsComposition *composition, bool createUndoCommands)
 
 QgsComposerTableV2 ()
 
virtual ~QgsComposerTableV2 ()
 
QColor backgroundColor () const
 Returns the color used for the background of the table. More...
 
double cellMargin () const
 Returns the margin distance between cell borders and their contents. More...
 
const QgsComposerTableStylecellStyle (CellStyleGroup group) const
 Returns the cell style for a cell group. More...
 
QgsComposerTableColumnscolumns ()
 Returns a pointer to the list of QgsComposerTableColumns shown in the table. More...
 
QFont contentFont () const
 Returns the font used to draw text in table body cells. More...
 
QColor contentFontColor () const
 Returns the color used to draw text in table body cells. More...
 
QgsComposerTableContentscontents ()
 Returns the current contents of the table. More...
 
EmptyTableMode emptyTableBehaviour () const
 Returns the behaviour mode for empty tables. More...
 
QString emptyTableMessage () const
 Returns the message for empty tables with no content rows. More...
 
virtual QSizeF fixedFrameSize (const int frameIndex=-1) const override
 Returns the fixed size for a frame, if desired. More...
 
virtual bool getTableContents (QgsComposerTableContents &contents)=0
 Fetches the contents used for the cells in the table. More...
 
QColor gridColor () const
 Returns the color used for grid lines in the table. More...
 
double gridStrokeWidth () const
 Returns the width of grid lines in the table. More...
 
QFont headerFont () const
 Returns the font used to draw header text in the table. More...
 
QColor headerFontColor () const
 Returns the color used to draw header text in the table. More...
 
HeaderHAlignment headerHAlignment () const
 Returns the horizontal alignment for table headers. More...
 
virtual QMap< int, QStringheaderLabels () const
 Returns the text used in the column headers for the table. More...
 
HeaderMode headerMode () const
 Returns the display mode for headers in the table. More...
 
virtual QSizeF minFrameSize (const int frameIndex=-1) const override
 Returns the minimum size for a frames, if desired. More...
 
virtual bool readXML (const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false) override
 Reads multiframe state information from a DOM element. More...
 
virtual void render (QPainter *p, const QRectF &renderExtent, const int frameIndex) override
 Renders a portion of the multiframe's content into a painter. More...
 
void setBackgroundColor (const QColor &color)
 Sets color used for background of table. More...
 
void setCellMargin (const double margin)
 Sets the margin distance between cell borders and their contents. More...
 
void setCellStyle (CellStyleGroup group, const QgsComposerTableStyle &style)
 Sets the cell style for a cell group. More...
 
void setColumns (const QgsComposerTableColumns &columns)
 Replaces the columns in the table with a specified list of QgsComposerTableColumns. More...
 
void setContentFont (const QFont &font)
 Sets the font used to draw text in table body cells. More...
 
void setContentFontColor (const QColor &color)
 Sets the color used to draw text in table body cells. More...
 
void setEmptyTableBehaviour (const EmptyTableMode mode)
 Sets the behaviour for empty tables with no content rows. More...
 
void setEmptyTableMessage (const QString &message)
 Sets the message for empty tables with no content rows. More...
 
void setGridColor (const QColor &color)
 Sets color used for grid lines in the table. More...
 
void setGridStrokeWidth (const double width)
 Sets the width for grid lines in the table. More...
 
void setHeaderFont (const QFont &font)
 Sets the font used to draw header text in the table. More...
 
void setHeaderFontColor (const QColor &color)
 Sets the color used to draw header text in the table. More...
 
void setHeaderHAlignment (const HeaderHAlignment alignment)
 Sets the horizontal alignment for table headers. More...
 
void setHeaderMode (const HeaderMode mode)
 Sets the display mode for headers in the table. More...
 
void setShowEmptyRows (const bool showEmpty)
 Sets whether empty rows should be drawn. More...
 
void setShowGrid (const bool showGrid)
 Sets whether grid lines should be drawn in the table. More...
 
void setWrapBehaviour (WrapBehaviour behaviour)
 Sets the wrap behaviour for the table, which controls how text within cells is automatically wrapped. More...
 
bool showEmptyRows () const
 Returns whether empty rows are drawn in the table. More...
 
bool showGrid () const
 Returns whether grid lines are drawn in the table. More...
 
virtual QSizeF totalSize () const override
 Returns the total size of the multiframe's content. More...
 
WrapBehaviour wrapBehaviour () const
 Returns the wrap behaviour for the table, which controls how text within cells is automatically wrapped. More...
 
virtual bool writeXML (QDomElement &elem, QDomDocument &doc, bool ignoreFrames=false) const override
 Stores state information about multiframe in DOM element. More...
 
- Public Member Functions inherited from QgsComposerMultiFrame
 QgsComposerMultiFrame (QgsComposition *c, bool createUndoCommands)
 Construct a new multiframe item. More...
 
virtual ~QgsComposerMultiFrame ()
 
bool _readXML (const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false)
 Restores state information about base multiframe object from a DOM element. More...
 
bool _writeXML (QDomElement &elem, QDomDocument &doc, bool ignoreFrames=false) const
 Stores state information about base multiframe object in DOM element. More...
 
virtual void addFrame (QgsComposerFrame *frame, bool recalcFrameSizes=true)=0
 Adds a frame to the multiframe. More...
 
QgsCompositioncomposition ()
 Returns the parent composition for the multiframe. More...
 
QgsComposerFramecreateNewFrame (QgsComposerFrame *currentFrame, QPointF pos, QSizeF size)
 Creates a new frame and adds it to the multi frame and composition. More...
 
bool createUndoCommands () const
 Returns whether undo commands should be created for interactions with the multiframe. More...
 
void deleteFrames ()
 Removes and deletes all child frames. More...
 
virtual QString displayName () const
 Get multiframe display name. More...
 
virtual double findNearbyPageBreak (double yPos)
 Finds the optimal position to break a frame at. More...
 
QgsComposerFrameframe (int i) const
 Returns a child frame from the multiframe. More...
 
int frameCount () const
 Returns the number of frames associated with this multiframe. More...
 
int frameIndex (QgsComposerFrame *frame) const
 Returns the index of a frame within the multiframe. More...
 
void removeFrame (int i, const bool removeEmptyPages=false)
 Removes a frame from the multiframe. More...
 
virtual Q_DECL_DEPRECATED void render (QPainter *p, const QRectF &renderExtent)
 Renders a portion of the multiframe's content into a painter. More...
 
ResizeMode resizeMode () const
 Returns the resize mode for the multiframe. More...
 
void setCreateUndoCommands (bool enabled)
 Sets whether undo commands should be created for interactions with the multiframe. More...
 
void setResizeMode (ResizeMode mode)
 Sets the resize mode for the multiframe, and recalculates frame sizes to match. More...
 
- Public Member Functions inherited from QgsComposerObject
 QgsComposerObject (QgsComposition *composition)
 Constructor. More...
 
virtual ~QgsComposerObject ()
 
const QgsCompositioncomposition () const
 Returns the composition the item is attached to. More...
 
QgsCompositioncomposition ()
 
virtual QgsExpressionContextcreateExpressionContext () const
 Creates an expression context relating to the objects' current state. More...
 
QStringList customProperties () const
 Return list of keys stored in custom properties for the object. More...
 
QVariant customProperty (const QString &key, const QVariant &defaultValue=QVariant()) const
 Read a custom property from the object. More...
 
QgsDataDefineddataDefinedProperty (const DataDefinedProperty property) const
 Returns a reference to the data defined settings for one of the item's data defined properties. More...
 
virtual bool readXML (const QDomElement &itemElem, const QDomDocument &doc)
 Sets item state from DOM element. More...
 
void removeCustomProperty (const QString &key)
 Remove a custom property from the object. More...
 
void setCustomProperty (const QString &key, const QVariant &value)
 Set a custom property for the object. More...
 
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. More...
 
virtual bool writeXML (QDomElement &elem, QDomDocument &doc) const
 Stores item state in DOM element. More...
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual ~QObject ()
 
bool blockSignals (bool block)
 
QObjectchild (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArraydynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObjectparent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThreadthread () const
 

Protected Member Functions

virtual bool calculateMaxColumnWidths ()
 Calculates the maximum width of text shown in columns. More...
 
virtual bool calculateMaxRowHeights ()
 Calculates the maximum height of text shown in rows. More...
 
bool contentsContainsRow (const QgsComposerTableContents &contents, const QgsComposerTableRow &row) const
 Checks whether a table contents contains a given row. More...
 
void drawHorizontalGridLines (QPainter *painter, int firstRow, int lastRow, bool drawHeaderLines) const
 Draws the horizontal grid lines for the table. More...
 
Q_DECL_DEPRECATED void drawHorizontalGridLines (QPainter *painter, const int rows, const bool drawHeaderLines) const
 Draws the horizontal grid lines for the table. More...
 
void drawVerticalGridLines (QPainter *painter, const QMap< int, double > &maxWidthMap, int firstRow, int lastRow, bool hasHeader, bool mergeCells=false) const
 Draws the vertical grid lines for the table. More...
 
Q_DECL_DEPRECATED 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. More...
 
void recalculateTableSize ()
 Recalculates and updates the size of the table and all table frames. More...
 
QPair< int, int > rowRange (const int frameIndex) const
 Calculates a range of rows which should be visible in a given frame. More...
 
Q_DECL_DEPRECATED 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. More...
 
int rowsVisible (double frameHeight, int firstRow, bool includeHeader, bool includeEmptyRows) const
 Calculates how many content rows would be visible within a frame of the specified height. More...
 
int rowsVisible (int frameIndex, int firstRow, bool includeEmptyRows) const
 Calculates how many content rows are visible within a given frame. More...
 
Q_DECL_DEPRECATED int rowsVisible (const int frameIndex) const
 Calculates how many content rows are visible within a given frame. More...
 
Q_DECL_DEPRECATED int rowsVisible (const double frameHeight, const bool includeHeader) const
 Calculates how many content rows would be visible within a specified height. More...
 
double totalHeight ()
 Returns total height of table contents. More...
 
double totalWidth ()
 Returns total width of table contents. More...
 
- Protected Member Functions inherited from QgsComposerObject
bool dataDefinedEvaluate (const QgsComposerObject::DataDefinedProperty property, QVariant &expressionValue, const QgsExpressionContext &context=QgsExpressionContext()) const
 Evaluate a data defined property and return the calculated value. More...
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObjectsender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Protected Attributes

QColor mBackgroundColor
 Color for table background. More...
 
double mCellMargin
 Margin between cell borders and cell text. More...
 
QMap< CellStyleGroup, QgsComposerTableStyle *> mCellStyles
 
QgsComposerTableColumns mColumns
 Columns to show in table. More...
 
QFont mContentFont
 Table contents font. More...
 
QColor mContentFontColor
 Table contents font color. More...
 
QString mEmptyTableMessage
 String to show in empty tables. More...
 
EmptyTableMode mEmptyTableMode
 Behaviour for empty tables. More...
 
QColor mGridColor
 Color for grid lines. More...
 
double mGridStrokeWidth
 Width of grid lines. More...
 
QFont mHeaderFont
 Header font. More...
 
QColor mHeaderFontColor
 Header font color. More...
 
HeaderHAlignment mHeaderHAlignment
 Alignment for table headers. More...
 
HeaderMode mHeaderMode
 Header display mode. More...
 
QMap< int, double > mMaxColumnWidthMap
 Map of maximum width for each column. More...
 
QMap< int, double > mMaxRowHeightMap
 Map of maximum height for each row. More...
 
bool mShowEmptyRows
 True if empty rows should be shown in the table. More...
 
bool mShowGrid
 True if grid should be shown. More...
 
QgsComposerTableContents mTableContents
 Contents to show in table. More...
 
QSizeF mTableSize
 
WrapBehaviour mWrapBehaviour
 
- Protected Attributes inherited from QgsComposerMultiFrame
bool mCreateUndoCommands
 True: creates QgsMultiFrameCommands on internal changes (e.g. More...
 
QList< QgsComposerFrame * > mFrameItems
 
ResizeMode mResizeMode
 
- Protected Attributes inherited from QgsComposerObject
QgsCompositionmComposition
 
QgsObjectCustomProperties mCustomProperties
 Custom properties for object. More...
 
QMap< QgsComposerObject::DataDefinedProperty, QStringmDataDefinedNames
 Map of data defined properties for the item to string name to use when exporting item to xml. More...
 

Friends

class TestQgsComposerTableV2
 

Additional Inherited Members

- Signals inherited from QgsComposerMultiFrame
void changed ()
 Emitted when the properties of a multi frame have changed, and the GUI item widget must be updated. More...
 
void contentsChanged ()
 Emitted when the contents of the multi frame have changed and the frames must be redrawn. More...
 
- Signals inherited from QgsComposerObject
void itemChanged ()
 Emitted when the item changes. More...
 
- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Protected Slots inherited from QgsComposerMultiFrame
void handleFrameRemoval (QgsComposerItem *item)
 Called before a frame is going to be removed. More...
 
void handlePageChange ()
 Adapts to changed number of composition pages if resize type is RepeatOnEveryPage. More...
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

A class to display a table in the print composer, and allow the table to span over multiple frames.

Note
added in QGIS 2.5

Definition at line 90 of file qgscomposertablev2.h.

Member Enumeration Documentation

◆ CellStyleGroup

Row or column groups for cell styling.

Enumerator
OddColumns 

Style odd numbered columns

EvenColumns 

Style even numbered columns

OddRows 

Style odd numbered rows

EvenRows 

Style even numbered rows

FirstColumn 

Style first column only

LastColumn 

Style last column only

HeaderRow 

Style header row

FirstRow 

Style first row only

LastRow 

Style last row only

Definition at line 134 of file qgscomposertablev2.h.

◆ EmptyTableMode

Controls how empty tables are displayed.

Enumerator
HeadersOnly 

show header rows only

HideTable 

hides entire table if empty

ShowMessage 

shows preset message instead of table contents

Definition at line 117 of file qgscomposertablev2.h.

◆ HeaderHAlignment

Controls how headers are horizontally aligned in a table.

Enumerator
FollowColumn 

header uses the same alignment as the column

HeaderLeft 

align headers left

HeaderCenter 

align headers to center

HeaderRight 

align headers right

Definition at line 98 of file qgscomposertablev2.h.

◆ HeaderMode

Controls where headers are shown in the table.

Enumerator
FirstFrame 

header shown on first frame only

AllFrames 

headers shown on all frames

NoHeaders 

no headers shown for table

Definition at line 108 of file qgscomposertablev2.h.

◆ WrapBehaviour

Controls how long strings in the table are handled.

Enumerator
TruncateText 

text which doesn't fit inside the cell is truncated

WrapText 

text which doesn't fit inside the cell is wrapped. Note that this only applies to text in columns with a fixed width.

Definition at line 126 of file qgscomposertablev2.h.

Constructor & Destructor Documentation

◆ QgsComposerTableV2() [1/2]

QgsComposerTableV2::QgsComposerTableV2 ( QgsComposition composition,
bool  createUndoCommands 
)

Definition at line 49 of file qgscomposertablev2.cpp.

◆ QgsComposerTableV2() [2/2]

QgsComposerTableV2::QgsComposerTableV2 ( )

Definition at line 82 of file qgscomposertablev2.cpp.

◆ ~QgsComposerTableV2()

QgsComposerTableV2::~QgsComposerTableV2 ( )
virtual

Definition at line 100 of file qgscomposertablev2.cpp.

Member Function Documentation

◆ backgroundColor()

QColor QgsComposerTableV2::backgroundColor ( ) const
inline

Returns the color used for the background of the table.

Returns
table background color
See also
setBackgroundColor
gridColor

Definition at line 353 of file qgscomposertablev2.h.

◆ calculateMaxColumnWidths()

bool QgsComposerTableV2::calculateMaxColumnWidths ( )
protectedvirtual

Calculates the maximum width of text shown in columns.

Definition at line 903 of file qgscomposertablev2.cpp.

◆ calculateMaxRowHeights()

bool QgsComposerTableV2::calculateMaxRowHeights ( )
protectedvirtual

Calculates the maximum height of text shown in rows.

Note
added in QGIS 2.12

Definition at line 978 of file qgscomposertablev2.cpp.

◆ cellMargin()

double QgsComposerTableV2::cellMargin ( ) const
inline

Returns the margin distance between cell borders and their contents.

Returns
margin for cell contents
See also
setCellMargin

Definition at line 162 of file qgscomposertablev2.h.

◆ cellStyle()

const QgsComposerTableStyle * QgsComposerTableV2::cellStyle ( QgsComposerTableV2::CellStyleGroup  group) const

Returns the cell style for a cell group.

Parameters
groupgroup to retrieve style for
See also
setCellStyle()
Note
added in QGIS 2.12

Definition at line 821 of file qgscomposertablev2.cpp.

◆ columns()

QgsComposerTableColumns* QgsComposerTableV2::columns ( )
inline

Returns a pointer to the list of QgsComposerTableColumns shown in the table.

Returns
pointer to list of columns in table
See also
setColumns

Definition at line 375 of file qgscomposertablev2.h.

◆ contentFont()

QFont QgsComposerTableV2::contentFont ( ) const
inline

Returns the font used to draw text in table body cells.

Returns
font for table cells
See also
setContentFont
headerFont

Definition at line 275 of file qgscomposertablev2.h.

◆ contentFontColor()

QColor QgsComposerTableV2::contentFontColor ( ) const
inline

Returns the color used to draw text in table body cells.

Returns
text color for table cells
See also
setContentFontColor
contentFont
headerFontColor

Definition at line 291 of file qgscomposertablev2.h.

◆ contents()

QgsComposerTableContents* QgsComposerTableV2::contents ( )
inline

Returns the current contents of the table.

Excludes header cells.

Returns
table contents

Definition at line 416 of file qgscomposertablev2.h.

◆ contentsContainsRow()

bool QgsComposerTableV2::contentsContainsRow ( const QgsComposerTableContents contents,
const QgsComposerTableRow row 
) const
protected

Checks whether a table contents contains a given row.

Parameters
contentstable contents to check
rowrow to check for
Returns
true if contents contains rows

Definition at line 1321 of file qgscomposertablev2.cpp.

◆ drawHorizontalGridLines() [1/2]

void QgsComposerTableV2::drawHorizontalGridLines ( QPainter painter,
int  firstRow,
int  lastRow,
bool  drawHeaderLines 
) const
protected

Draws the horizontal grid lines for the table.

Parameters
painterdestination painter for grid lines
firstRowindex corresponding to first row shown in frame
lastRowindex corresponding to last row shown in frame. If greater than the number of content rows in the table, then the default row height will be used for the remaining rows.
drawHeaderLinesset to true to include for the table header
See also
drawVerticalGridLines
Note
added in QGIS 2.12

Definition at line 1133 of file qgscomposertablev2.cpp.

◆ drawHorizontalGridLines() [2/2]

void QgsComposerTableV2::drawHorizontalGridLines ( QPainter painter,
const int  rows,
const bool  drawHeaderLines 
) const
protected

Draws the horizontal grid lines for the table.

Parameters
painterdestination painter for grid lines
rowsnumber of rows shown in table
drawHeaderLinesset to true to include for the table header
See also
drawVerticalGridLines
Deprecated:
will be removed in QGIS 3.0

Definition at line 1127 of file qgscomposertablev2.cpp.

◆ drawVerticalGridLines() [1/2]

void QgsComposerTableV2::drawVerticalGridLines ( QPainter painter,
const QMap< int, double > &  maxWidthMap,
int  firstRow,
int  lastRow,
bool  hasHeader,
bool  mergeCells = false 
) const
protected

Draws the vertical grid lines for the table.

Parameters
painterdestination painter for grid lines
maxWidthMapQMap of int to double, where the int contains the column number and the double is the maximum width of text present in the column.
firstRowindex corresponding to first row shown in frame
lastRowindex corresponding to last row shown in frame. If greater than the number of content rows in the table, then the default row height will be used for the remaining rows.
hasHeaderset to true if table frame includes header cells
mergeCellsset to true to merge table content cells
Note
not available in python bindings
See also
drawVerticalGridLines
calculateMaxColumnWidths
Note
not available in python bindings
added in QGIS 2.12

Definition at line 1265 of file qgscomposertablev2.cpp.

◆ drawVerticalGridLines() [2/2]

void QgsComposerTableV2::drawVerticalGridLines ( QPainter painter,
const QMap< int, double > &  maxWidthMap,
const int  numberRows,
const bool  hasHeader,
const bool  mergeCells = false 
) const
protected

Draws the vertical grid lines for the table.

Parameters
painterdestination painter for grid lines
maxWidthMapQMap of int to double, where the int contains the column number and the double is the maximum width of text present in the column.
numberRowsnumber of rows of content in table frame
hasHeaderset to true if table frame includes header cells
mergeCellsset to true to merge table content cells
Note
not available in python bindings
See also
drawVerticalGridLines
calculateMaxColumnWidths
Note
not available in python bindings
Deprecated:
will be removed in QGIS 3.0

Definition at line 1161 of file qgscomposertablev2.cpp.

◆ emptyTableBehaviour()

EmptyTableMode QgsComposerTableV2::emptyTableBehaviour ( ) const
inline

Returns the behaviour mode for empty tables.

This property controls how the table is drawn if it contains no content rows.

Returns
behaviour mode for empty tables
See also
setEmptyTableBehaviour

Definition at line 175 of file qgscomposertablev2.h.

◆ emptyTableMessage()

QString QgsComposerTableV2::emptyTableMessage ( ) const
inline

Returns the message for empty tables with no content rows.

This message is displayed in the table body if the empty table behaviour is set to ShowMessage

Returns
message to show for empty tables
See also
setEmptyTableMessage
emptyTableBehaviour

Definition at line 193 of file qgscomposertablev2.h.

◆ fixedFrameSize()

QSizeF QgsComposerTableV2::fixedFrameSize ( const int  frameIndex = -1) const
overridevirtual

Returns the fixed size for a frame, if desired.

If the fixed frame size changes, the sizes of all frames can be recalculated by calling recalculateFrameRects().

Parameters
frameIndexframe number
Returns
fixed size for frame. If the size has a width or height of 0, then the frame size is not fixed in that direction and frames can have variable width or height accordingly.
Note
added in version 2.5
See also
minFrameSize
recalculateFrameRects

Reimplemented from QgsComposerMultiFrame.

Definition at line 843 of file qgscomposertablev2.cpp.

◆ getTableContents()

virtual bool QgsComposerTableV2::getTableContents ( QgsComposerTableContents contents)
pure virtual

Fetches the contents used for the cells in the table.

Returns
true if table contents were successfully retrieved.
Parameters
contentsQgsComposerTableContents to store retrieved row data in
Note
not available in python bindings

Implemented in QgsComposerAttributeTableV2, and QgsComposerTextTableV2.

◆ gridColor()

QColor QgsComposerTableV2::gridColor ( ) const
inline

Returns the color used for grid lines in the table.

Returns
grid line color
See also
setGridColor
showGrid
gridStrokeWidth

Definition at line 339 of file qgscomposertablev2.h.

◆ gridStrokeWidth()

double QgsComposerTableV2::gridStrokeWidth ( ) const
inline

Returns the width of grid lines in the table.

Returns
grid line width
See also
setGridStrokeWidth
showGrid
gridColor

Definition at line 323 of file qgscomposertablev2.h.

◆ headerFont()

QFont QgsComposerTableV2::headerFont ( ) const
inline

Returns the font used to draw header text in the table.

Returns
font for header cells
See also
setHeaderFont
contentFont

Definition at line 219 of file qgscomposertablev2.h.

◆ headerFontColor()

QColor QgsComposerTableV2::headerFontColor ( ) const
inline

Returns the color used to draw header text in the table.

Returns
color for header text
See also
setHeaderFontColor
headerFont
contentFontColor

Definition at line 235 of file qgscomposertablev2.h.

◆ headerHAlignment()

HeaderHAlignment QgsComposerTableV2::headerHAlignment ( ) const
inline

Returns the horizontal alignment for table headers.

Returns
Horizontal alignment for table header cells
See also
setHeaderHAlignment

Definition at line 247 of file qgscomposertablev2.h.

◆ headerLabels()

QMap< int, QString > QgsComposerTableV2::headerLabels ( ) const
virtual

Returns the text used in the column headers for the table.

Returns
QMap of int to QString, where the int is the column index (starting at 0), and the string is the text to use for the column's header
Note
not available in python bindings

Definition at line 829 of file qgscomposertablev2.cpp.

◆ headerMode()

HeaderMode QgsComposerTableV2::headerMode ( ) const
inline

Returns the display mode for headers in the table.

This property controls if and where headers are shown in the table.

Returns
display mode for headers
See also
setHeaderMode

Definition at line 261 of file qgscomposertablev2.h.

◆ minFrameSize()

QSizeF QgsComposerTableV2::minFrameSize ( const int  frameIndex = -1) const
overridevirtual

Returns the minimum size for a frames, if desired.

If the minimum size changes, the sizes of all frames can be recalculated by calling recalculateFrameRects().

Parameters
frameIndexframe number
Returns
minimum size for frame. If the size has a width or height of 0, then the frame size has no minimum in that direction.
Note
added in version 2.5
See also
fixedFrameSize
recalculateFrameRects

Reimplemented from QgsComposerMultiFrame.

Definition at line 849 of file qgscomposertablev2.cpp.

◆ readXML()

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

Reads multiframe state information from a DOM element.

Implementations of readXML should also call the _readXML method to restore general multiframe properties.

Parameters
itemElemis DOM element
docis the DOM document
ignoreFramesset to false to avoid read state information about child frames from DOM
See also
_readXML

Implements QgsComposerMultiFrame.

Reimplemented in QgsComposerAttributeTableV2.

Definition at line 154 of file qgscomposertablev2.cpp.

◆ recalculateFrameSizes

void QgsComposerTableV2::recalculateFrameSizes ( )
overrideslot

Definition at line 874 of file qgscomposertablev2.cpp.

◆ recalculateTableSize()

void QgsComposerTableV2::recalculateTableSize ( )
protected

Recalculates and updates the size of the table and all table frames.

Definition at line 1312 of file qgscomposertablev2.cpp.

◆ refreshAttributes

void QgsComposerTableV2::refreshAttributes ( )
virtualslot

Refreshes the contents shown in the table by querying for new data.

This also causes the column widths and size of the table to change to accommodate the new data.

See also
adjustFrameToSize

Definition at line 861 of file qgscomposertablev2.cpp.

◆ render()

void QgsComposerTableV2::render ( QPainter painter,
const QRectF renderExtent,
const int  frameIndex 
)
overridevirtual

Renders a portion of the multiframe's content into a painter.

Parameters
painterdestination painter
renderExtentvisible extent of content to render into the painter.
frameIndexframe number for content
Note
added in version 2.5

Reimplemented from QgsComposerMultiFrame.

Definition at line 365 of file qgscomposertablev2.cpp.

◆ rowRange() [1/2]

QPair< int, int > QgsComposerTableV2::rowRange ( const int  frameIndex) const
protected

Calculates a range of rows which should be visible in a given frame.

Parameters
frameIndexindex number for frame
Returns
row range
Note
added in QGIS 2.12

Definition at line 333 of file qgscomposertablev2.cpp.

◆ rowRange() [2/2]

QPair< int, int > QgsComposerTableV2::rowRange ( const QRectF extent,
const int  frameIndex 
) const
protected

Calculates a range of rows which should be visible in a given frame extent.

Parameters
extentvisible extent
frameIndexindex number for frame
Returns
row range
Deprecated:
will be removed in QGIS 3.0

Definition at line 358 of file qgscomposertablev2.cpp.

◆ rowsVisible() [1/4]

int QgsComposerTableV2::rowsVisible ( double  frameHeight,
int  firstRow,
bool  includeHeader,
bool  includeEmptyRows 
) const
protected

Calculates how many content rows would be visible within a frame of the specified height.

Parameters
frameHeightheight of frame
firstRowindex of first row visible in frame (where 0 = first row in table)
includeHeaderset to true if frame would include a header row
includeEmptyRowsset to true to also include rows which would be empty in the returned count. For instance, if the frame would include all table content rows and have space left for extra rows then setting this parameter to true would also include a count of these extra blank rows.
Returns
number of visible content rows (excluding header row)
Note
added in QGIS 2.12

Definition at line 278 of file qgscomposertablev2.cpp.

◆ rowsVisible() [2/4]

int QgsComposerTableV2::rowsVisible ( int  frameIndex,
int  firstRow,
bool  includeEmptyRows 
) const
protected

Calculates how many content rows are visible within a given frame.

Parameters
frameIndexindex number for frame
firstRowindex of first row visible in frame (where 0 = first row in table)
includeEmptyRowsset to true to also include rows which would be empty in the returned count. For instance, if the frame would include all table content rows and have space left for extra rows then setting this parameter to true would also include a count of these extra blank rows.
Returns
number of visible content rows (excludes header rows)
Note
added in QGIS 2.12

Definition at line 315 of file qgscomposertablev2.cpp.

◆ rowsVisible() [3/4]

int QgsComposerTableV2::rowsVisible ( const int  frameIndex) const
protected

Calculates how many content rows are visible within a given frame.

Parameters
frameIndexindex number for frame
Returns
number of visible content rows (excludes header rows)
Deprecated:
will be removed in QGIS 3.0

Definition at line 235 of file qgscomposertablev2.cpp.

◆ rowsVisible() [4/4]

int QgsComposerTableV2::rowsVisible ( const double  frameHeight,
const bool  includeHeader 
) const
protected

Calculates how many content rows would be visible within a specified height.

Parameters
frameHeightheight of frame
includeHeaderset to true if frame would include a header row
Returns
number of visible content rows (excluding header row)
Deprecated:
will be removed in QGIS 3.0

Definition at line 255 of file qgscomposertablev2.cpp.

◆ setBackgroundColor()

void QgsComposerTableV2::setBackgroundColor ( const QColor color)

Sets color used for background of table.

Parameters
colortable background color
See also
backgroundColor
setGridColor

Definition at line 778 of file qgscomposertablev2.cpp.

◆ setCellMargin()

void QgsComposerTableV2::setCellMargin ( const double  margin)

Sets the margin distance between cell borders and their contents.

Parameters
marginmargin for cell contents
See also
cellMargin

Definition at line 600 of file qgscomposertablev2.cpp.

◆ setCellStyle()

void QgsComposerTableV2::setCellStyle ( QgsComposerTableV2::CellStyleGroup  group,
const QgsComposerTableStyle style 
)

Sets the cell style for a cell group.

Parameters
groupgroup to set style for
stylenew cell style
See also
cellStyle()
Note
added in QGIS 2.12

Definition at line 813 of file qgscomposertablev2.cpp.

◆ setColumns()

void QgsComposerTableV2::setColumns ( const QgsComposerTableColumns columns)

Replaces the columns in the table with a specified list of QgsComposerTableColumns.

Parameters
columnslist of QgsComposerTableColumns to show in table. Ownership of columns is transferred to the table.
See also
columns

Definition at line 804 of file qgscomposertablev2.cpp.

◆ setContentFont()

void QgsComposerTableV2::setContentFont ( const QFont font)

Sets the font used to draw text in table body cells.

Parameters
fontfont for table cells
See also
contentFont
setHeaderFont

Definition at line 710 of file qgscomposertablev2.cpp.

◆ setContentFontColor()

void QgsComposerTableV2::setContentFontColor ( const QColor color)

Sets the color used to draw text in table body cells.

Parameters
colortable cell text color
See also
contentFontColor
setContentFont
setHeaderFontColor

Definition at line 724 of file qgscomposertablev2.cpp.

◆ setEmptyTableBehaviour()

void QgsComposerTableV2::setEmptyTableBehaviour ( const EmptyTableMode  mode)

Sets the behaviour for empty tables with no content rows.

Parameters
modebehaviour mode for empty tables
See also
emptyTableBehaviour

Definition at line 615 of file qgscomposertablev2.cpp.

◆ setEmptyTableMessage()

void QgsComposerTableV2::setEmptyTableMessage ( const QString message)

Sets the message for empty tables with no content rows.

This message is displayed in the table body if the empty table behaviour is set to ShowMessage

Parameters
messagemessage to show for empty tables
See also
emptyTableMessage
setEmptyTableBehaviour

Definition at line 630 of file qgscomposertablev2.cpp.

◆ setGridColor()

void QgsComposerTableV2::setGridColor ( const QColor color)

Sets color used for grid lines in the table.

Parameters
colorgrid line color
See also
gridColor
setShowGrid
setGridStrokeWidth

Definition at line 765 of file qgscomposertablev2.cpp.

◆ setGridStrokeWidth()

void QgsComposerTableV2::setGridStrokeWidth ( const double  width)

Sets the width for grid lines in the table.

Parameters
widthgrid line width
See also
gridStrokeWidth
setShowGrid
setGridColor

Definition at line 751 of file qgscomposertablev2.cpp.

◆ setHeaderFont()

void QgsComposerTableV2::setHeaderFont ( const QFont font)

Sets the font used to draw header text in the table.

Parameters
fontfont for header cells
See also
headerFont
setContentFont

Definition at line 657 of file qgscomposertablev2.cpp.

◆ setHeaderFontColor()

void QgsComposerTableV2::setHeaderFontColor ( const QColor color)

Sets the color used to draw header text in the table.

Parameters
colorheader text color
See also
headerFontColor
setHeaderFont
setContentFontColor

Definition at line 671 of file qgscomposertablev2.cpp.

◆ setHeaderHAlignment()

void QgsComposerTableV2::setHeaderHAlignment ( const HeaderHAlignment  alignment)

Sets the horizontal alignment for table headers.

Parameters
alignmentHorizontal alignment for table header cells
See also
headerHAlignment

Definition at line 684 of file qgscomposertablev2.cpp.

◆ setHeaderMode()

void QgsComposerTableV2::setHeaderMode ( const HeaderMode  mode)

Sets the display mode for headers in the table.

This property controls if and where headers are shown in the table.

Parameters
modedisplay mode for headers
See also
headerMode

Definition at line 697 of file qgscomposertablev2.cpp.

◆ setShowEmptyRows()

void QgsComposerTableV2::setShowEmptyRows ( const bool  showEmpty)

Sets whether empty rows should be drawn.

Tables default to hiding empty rows.

Parameters
showEmptyset to true to show empty rows in the table
See also
showEmptyRows

Definition at line 645 of file qgscomposertablev2.cpp.

◆ setShowGrid()

void QgsComposerTableV2::setShowGrid ( const bool  showGrid)

Sets whether grid lines should be drawn in the table.

Parameters
showGridset to true to show grid lines
See also
showGrid
setGridStrokeWidth
setGridColor

Definition at line 737 of file qgscomposertablev2.cpp.

◆ setWrapBehaviour()

void QgsComposerTableV2::setWrapBehaviour ( QgsComposerTableV2::WrapBehaviour  behaviour)

Sets the wrap behaviour for the table, which controls how text within cells is automatically wrapped.

Parameters
behaviourwrap behaviour
See also
wrapBehaviour
Note
added in QGIS 2.12

Definition at line 791 of file qgscomposertablev2.cpp.

◆ showEmptyRows()

bool QgsComposerTableV2::showEmptyRows ( ) const
inline

Returns whether empty rows are drawn in the table.

Returns
true if empty rows are drawn
See also
setShowEmptyRows

Definition at line 205 of file qgscomposertablev2.h.

◆ showGrid()

bool QgsComposerTableV2::showGrid ( ) const
inline

Returns whether grid lines are drawn in the table.

Returns
true if grid lines are shown
See also
setShowGrid
gridStrokeWidth
gridColor

Definition at line 307 of file qgscomposertablev2.h.

◆ totalHeight()

double QgsComposerTableV2::totalHeight ( )
protected

Returns total height of table contents.

Returns
total height
See also
totalWidth

Definition at line 1056 of file qgscomposertablev2.cpp.

◆ totalSize()

QSizeF QgsComposerTableV2::totalSize ( ) const
overridevirtual

Returns the total size of the multiframe's content.

Returns
total size required for content

Implements QgsComposerMultiFrame.

Definition at line 230 of file qgscomposertablev2.cpp.

◆ totalWidth()

double QgsComposerTableV2::totalWidth ( )
protected

Returns total width of table contents.

Returns
table width
See also
totalHeight

Definition at line 1035 of file qgscomposertablev2.cpp.

◆ wrapBehaviour()

WrapBehaviour QgsComposerTableV2::wrapBehaviour ( ) const
inline

Returns the wrap behaviour for the table, which controls how text within cells is automatically wrapped.

Returns
current wrap behaviour
See also
setWrapBehaviour
Note
added in QGIS 2.12

Definition at line 369 of file qgscomposertablev2.h.

◆ writeXML()

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

Stores state information about multiframe in DOM element.

Implementations of writeXML should also call the _writeXML method to save general multiframe properties.

Parameters
elemis DOM element
docis the DOM document
ignoreFramesset to false to avoid writing state information about child frames into DOM
See also
_writeXML

Implements QgsComposerMultiFrame.

Reimplemented in QgsComposerAttributeTableV2.

Definition at line 109 of file qgscomposertablev2.cpp.

Friends And Related Function Documentation

◆ TestQgsComposerTableV2

friend class TestQgsComposerTableV2
friend

Definition at line 663 of file qgscomposertablev2.h.

Member Data Documentation

◆ mBackgroundColor

QColor QgsComposerTableV2::mBackgroundColor
protected

Color for table background.

Definition at line 481 of file qgscomposertablev2.h.

◆ mCellMargin

double QgsComposerTableV2::mCellMargin
protected

Margin between cell borders and cell text.

Definition at line 442 of file qgscomposertablev2.h.

◆ mCellStyles

QMap< CellStyleGroup, QgsComposerTableStyle* > QgsComposerTableV2::mCellStyles
protected

Definition at line 499 of file qgscomposertablev2.h.

◆ mColumns

QgsComposerTableColumns QgsComposerTableV2::mColumns
protected

Columns to show in table.

Definition at line 484 of file qgscomposertablev2.h.

◆ mContentFont

QFont QgsComposerTableV2::mContentFont
protected

Table contents font.

Definition at line 466 of file qgscomposertablev2.h.

◆ mContentFontColor

QColor QgsComposerTableV2::mContentFontColor
protected

Table contents font color.

Definition at line 469 of file qgscomposertablev2.h.

◆ mEmptyTableMessage

QString QgsComposerTableV2::mEmptyTableMessage
protected

String to show in empty tables.

Definition at line 448 of file qgscomposertablev2.h.

◆ mEmptyTableMode

EmptyTableMode QgsComposerTableV2::mEmptyTableMode
protected

Behaviour for empty tables.

Definition at line 445 of file qgscomposertablev2.h.

◆ mGridColor

QColor QgsComposerTableV2::mGridColor
protected

Color for grid lines.

Definition at line 478 of file qgscomposertablev2.h.

◆ mGridStrokeWidth

double QgsComposerTableV2::mGridStrokeWidth
protected

Width of grid lines.

Definition at line 475 of file qgscomposertablev2.h.

◆ mHeaderFont

QFont QgsComposerTableV2::mHeaderFont
protected

Header font.

Definition at line 454 of file qgscomposertablev2.h.

◆ mHeaderFontColor

QColor QgsComposerTableV2::mHeaderFontColor
protected

Header font color.

Definition at line 457 of file qgscomposertablev2.h.

◆ mHeaderHAlignment

HeaderHAlignment QgsComposerTableV2::mHeaderHAlignment
protected

Alignment for table headers.

Definition at line 460 of file qgscomposertablev2.h.

◆ mHeaderMode

HeaderMode QgsComposerTableV2::mHeaderMode
protected

Header display mode.

Definition at line 463 of file qgscomposertablev2.h.

◆ mMaxColumnWidthMap

QMap<int, double> QgsComposerTableV2::mMaxColumnWidthMap
protected

Map of maximum width for each column.

Definition at line 490 of file qgscomposertablev2.h.

◆ mMaxRowHeightMap

QMap<int, double> QgsComposerTableV2::mMaxRowHeightMap
protected

Map of maximum height for each row.

Definition at line 493 of file qgscomposertablev2.h.

◆ mShowEmptyRows

bool QgsComposerTableV2::mShowEmptyRows
protected

True if empty rows should be shown in the table.

Definition at line 451 of file qgscomposertablev2.h.

◆ mShowGrid

bool QgsComposerTableV2::mShowGrid
protected

True if grid should be shown.

Definition at line 472 of file qgscomposertablev2.h.

◆ mTableContents

QgsComposerTableContents QgsComposerTableV2::mTableContents
protected

Contents to show in table.

Definition at line 487 of file qgscomposertablev2.h.

◆ mTableSize

QSizeF QgsComposerTableV2::mTableSize
protected

Definition at line 495 of file qgscomposertablev2.h.

◆ mWrapBehaviour

WrapBehaviour QgsComposerTableV2::mWrapBehaviour
protected

Definition at line 497 of file qgscomposertablev2.h.


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