36 styleElem.setAttribute( QStringLiteral(
"enabled" ),
enabled );
43 enabled = ( styleElem.attribute( QStringLiteral(
"enabled" ), QStringLiteral(
"0" ) ) != QLatin1String(
"0" ) );
57 QString defaultFontString = settings.
value( QStringLiteral(
"LayoutDesigner/defaultFont" ), QVariant(),
QgsSettings::Gui ).toString();
58 if ( !defaultFontString.isEmpty() )
78 elem.setAttribute( QStringLiteral(
"cellMargin" ), QString::number(
mCellMargin ) );
79 elem.setAttribute( QStringLiteral(
"emptyTableMode" ), QString::number( static_cast< int >(
mEmptyTableMode ) ) );
81 elem.setAttribute( QStringLiteral(
"showEmptyRows" ),
mShowEmptyRows );
84 elem.setAttribute( QStringLiteral(
"headerHAlignment" ), QString::number( static_cast< int >(
mHeaderHAlignment ) ) );
85 elem.setAttribute( QStringLiteral(
"headerMode" ), QString::number( static_cast< int >(
mHeaderMode ) ) );
88 elem.setAttribute( QStringLiteral(
"gridStrokeWidth" ), QString::number(
mGridStrokeWidth ) );
90 elem.setAttribute( QStringLiteral(
"horizontalGrid" ),
mHorizontalGrid );
91 elem.setAttribute( QStringLiteral(
"verticalGrid" ),
mVerticalGrid );
92 elem.setAttribute( QStringLiteral(
"showGrid" ),
mShowGrid );
94 elem.setAttribute( QStringLiteral(
"wrapBehavior" ), QString::number( static_cast< int >(
mWrapBehavior ) ) );
97 QDomElement displayColumnsElem = doc.createElement( QStringLiteral(
"displayColumns" ) );
100 QDomElement columnElem = doc.createElement( QStringLiteral(
"column" ) );
101 column->writeXml( columnElem, doc );
102 displayColumnsElem.appendChild( columnElem );
104 elem.appendChild( displayColumnsElem );
107 QDomElement stylesElem = doc.createElement( QStringLiteral(
"cellStyles" ) );
108 QMap< CellStyleGroup, QString >::const_iterator it = mCellStyleNames.constBegin();
109 for ( ; it != mCellStyleNames.constEnd(); ++it )
111 QString styleName = it.value();
112 QDomElement styleElem = doc.createElement( styleName );
117 stylesElem.appendChild( styleElem );
120 elem.appendChild( stylesElem );
127 mEmptyTableMessage = itemElem.attribute( QStringLiteral(
"emptyTableMessage" ), tr(
"No matching records" ) );
128 mShowEmptyRows = itemElem.attribute( QStringLiteral(
"showEmptyRows" ), QStringLiteral(
"0" ) ).toInt();
131 mHeaderFont.fromString( itemElem.attribute( QStringLiteral(
"headerFont" ), QString() ) );
138 mContentFont.fromString( itemElem.attribute( QStringLiteral(
"contentFont" ), QString() ) );
141 mCellMargin = itemElem.attribute( QStringLiteral(
"cellMargin" ), QStringLiteral(
"1.0" ) ).toDouble();
142 mGridStrokeWidth = itemElem.attribute( QStringLiteral(
"gridStrokeWidth" ), QStringLiteral(
"0.5" ) ).toDouble();
143 mHorizontalGrid = itemElem.attribute( QStringLiteral(
"horizontalGrid" ), QStringLiteral(
"1" ) ).toInt();
144 mVerticalGrid = itemElem.attribute( QStringLiteral(
"verticalGrid" ), QStringLiteral(
"1" ) ).toInt();
145 mShowGrid = itemElem.attribute( QStringLiteral(
"showGrid" ), QStringLiteral(
"1" ) ).toInt();
153 QDomNodeList columnsList = itemElem.elementsByTagName( QStringLiteral(
"displayColumns" ) );
154 if ( !columnsList.isEmpty() )
156 QDomElement columnsElem = columnsList.at( 0 ).toElement();
157 QDomNodeList columnEntryList = columnsElem.elementsByTagName( QStringLiteral(
"column" ) );
158 for (
int i = 0; i < columnEntryList.size(); ++i )
160 QDomElement columnElem = columnEntryList.at( i ).toElement();
168 QDomNodeList stylesList = itemElem.elementsByTagName( QStringLiteral(
"cellStyles" ) );
169 if ( !stylesList.isEmpty() )
171 QDomElement stylesElem = stylesList.at( 0 ).toElement();
173 QMap< CellStyleGroup, QString >::const_iterator it = mCellStyleNames.constBegin();
174 for ( ; it != mCellStyleNames.constEnd(); ++it )
176 QString styleName = it.value();
177 QDomNodeList styleList = stylesElem.elementsByTagName( styleName );
178 if ( !styleList.isEmpty() )
180 QDomElement styleElem = styleList.at( 0 ).toElement();
206 double headerHeight = 0;
219 double contentHeight = frameHeight - headerHeight;
223 int currentRow = firstRow;
224 while ( contentHeight > 0 && currentRow <=
mTableContents.count() )
227 contentHeight -= currentRowHeight;
231 if ( includeEmptyRows && contentHeight > 0 )
234 currentRow += std::max( std::floor( contentHeight / rowHeight ), 0.0 );
237 return currentRow - firstRow - 1;
247 QRectF frameExtent =
frame( frameIndex )->
extent();
249 bool includeHeader =
false;
253 includeHeader =
true;
255 return rowsVisible( frameExtent.height(), firstRow, includeHeader, includeEmptyRows );
264 return qMakePair( 0, 0 );
269 int rowsAlreadyShown = 0;
272 rowsAlreadyShown +=
rowsVisible( idx, rowsAlreadyShown,
false );
276 int firstVisible = std::min( rowsAlreadyShown,
mTableContents.length() );
277 int possibleRowsVisible =
rowsVisible( frameIndex, rowsAlreadyShown,
false );
278 int lastVisible = std::min( firstVisible + possibleRowsVisible,
mTableContents.length() );
280 return qMakePair( firstVisible, lastVisible );
292 if ( !
mLayout->renderContext().isPreviewRender() )
300 QPair< int, int > rowsToShow =
rowRange( frameIndex );
314 int numberRowsToDraw = rowsToShow.second - rowsToShow.first;
315 int numberEmptyRows = 0;
318 numberRowsToDraw =
rowsVisible( frameIndex, rowsToShow.first,
true );
319 numberEmptyRows = numberRowsToDraw - rowsToShow.second + rowsToShow.first;
321 bool mergeCells =
false;
336 p->setPen( Qt::SolidLine );
338 double currentX = gridSizeX;
339 double currentY = gridSizeY;
348 p->setPen( Qt::NoPen );
355 Qt::TextFlag textFlag =
static_cast< Qt::TextFlag
>( 0 );
356 if ( column->width() <= 0 )
361 textFlag = Qt::TextDontClip;
367 Qt::AlignmentFlag headerAlign = Qt::AlignLeft;
371 headerAlign = column->hAlignment();
374 headerAlign = Qt::AlignLeft;
377 headerAlign = Qt::AlignHCenter;
380 headerAlign = Qt::AlignRight;
388 currentX += gridSizeX;
392 currentY += cellHeaderHeight;
393 currentY += gridSizeY;
401 for (
int row = rowsToShow.first; row < rowsToShow.second; ++row )
404 currentX = gridSizeX;
415 p->setPen( Qt::NoPen );
417 p->drawRect( QRectF( currentX, currentY,
mMaxColumnWidthMap[col] + 2 * mCellMargin, rowHeight ) );
424 QString str = cellContents.toString();
426 Qt::TextFlag textFlag =
static_cast< Qt::TextFlag
>( 0 );
432 textFlag = Qt::TextDontClip;
434 else if ( textRequiresWrapping( str, column->width(),
mContentFont ) )
436 str = wrappedText( str, column->width(),
mContentFont );
444 currentX += gridSizeX;
447 currentY += rowHeight;
448 currentY += gridSizeY;
452 if ( numberRowsToDraw > rowsDrawn )
455 p->setPen( Qt::NoPen );
458 for (
int row = rowsDrawn; row < numberRowsToDraw; ++row )
460 currentX = gridSizeX;
466 p->drawRect( QRectF( gridSizeX, currentY,
mTableSize.width() - 2 * gridSizeX, cellBodyHeight ) );
482 currentX += gridSizeX;
486 currentY += cellBodyHeight + gridSizeY;
497 gridPen.setJoinStyle( Qt::MiterJoin );
498 p->setPen( gridPen );
513 double messageY = gridSizeY + ( drawHeader ? cellHeaderHeight + gridSizeY : 0 );
514 cell = QRectF( messageX, messageY,
mTableSize.width() - messageX, cellBodyHeight );
781 QMap<int, QString> headers;
783 QgsLayoutTableColumns::const_iterator columnIt =
mColumns.constBegin();
785 for ( ; columnIt !=
mColumns.constEnd(); ++columnIt )
787 headers.insert( col, ( *columnIt )->heading() );
795 Q_UNUSED( frameIndex )
808 return QSizeF( 0, height );
830 void QgsLayoutTable::initStyles()
842 mCellStyleNames.insert(
OddColumns, QStringLiteral(
"oddColumns" ) );
843 mCellStyleNames.insert(
EvenColumns, QStringLiteral(
"evenColumns" ) );
844 mCellStyleNames.insert(
OddRows, QStringLiteral(
"oddRows" ) );
845 mCellStyleNames.insert(
EvenRows, QStringLiteral(
"evenRows" ) );
846 mCellStyleNames.insert(
FirstColumn, QStringLiteral(
"firstColumn" ) );
847 mCellStyleNames.insert(
LastColumn, QStringLiteral(
"lastColumn" ) );
848 mCellStyleNames.insert(
HeaderRow, QStringLiteral(
"headerRow" ) );
849 mCellStyleNames.insert(
FirstRow, QStringLiteral(
"firstRow" ) );
850 mCellStyleNames.insert(
LastRow, QStringLiteral(
"lastRow" ) );
860 QVector< double > widths( cells );
863 QgsLayoutTableColumns::const_iterator columnIt =
mColumns.constBegin();
865 for ( ; columnIt !=
mColumns.constEnd(); ++columnIt )
867 if ( ( *columnIt )->width() > 0 )
870 widths[col] = ( *columnIt )->width();
884 QgsLayoutTableContents::const_iterator rowIt =
mTableContents.constBegin();
885 double currentCellTextWidth;
889 QgsLayoutTableRow::const_iterator colIt = rowIt->constBegin();
891 for ( ; colIt != rowIt->constEnd(); ++colIt )
893 if (
mColumns.at( col )->width() <= 0 )
896 QStringList multiLineSplit = ( *colIt ).toString().split(
'\n' );
897 currentCellTextWidth = 0;
898 const auto constMultiLineSplit = multiLineSplit;
899 for (
const QString &line : constMultiLineSplit )
903 widths[ row * cols + col ] = currentCellTextWidth;
907 widths[ row * cols + col ] = 0;
916 for (
int col = 0; col < cols; ++col )
918 double maxColWidth = 0;
921 maxColWidth = std::max( widths[ row * cols + col ], maxColWidth );
936 QVector< double > heights( cells );
939 QgsLayoutTableColumns::const_iterator columnIt =
mColumns.constBegin();
941 for ( ; columnIt !=
mColumns.constEnd(); ++columnIt )
949 QgsLayoutTableContents::const_iterator rowIt =
mTableContents.constBegin();
953 QgsLayoutTableRow::const_iterator colIt = rowIt->constBegin();
955 for ( ; colIt != rowIt->constEnd(); ++colIt )
975 double maxRowHeight = 0;
976 for (
int col = 0; col < cols; ++col )
978 maxRowHeight = std::max( heights[ row * cols + col ], maxRowHeight );
999 totalWidth += maxColWidthIt.value();
1019 int rowsAlreadyShown = 0;
1021 int rowsVisibleInLastFrame = 0;
1022 double heightOfLastFrame = 0;
1023 for (
int idx = 0; idx < numberExistingFrames; ++idx )
1027 heightOfLastFrame =
frame( idx )->rect().height();
1028 rowsVisibleInLastFrame =
rowsVisible( heightOfLastFrame, rowsAlreadyShown, hasHeader,
false );
1029 rowsAlreadyShown += rowsVisibleInLastFrame;
1030 height += heightOfLastFrame;
1041 if ( remainingRows <= 0 )
1057 int numberFramesMissing = 0;
1058 while ( remainingRows > 0 )
1060 numberFramesMissing++;
1062 rowsVisibleInLastFrame =
rowsVisible( heightOfLastFrame, rowsAlreadyShown, hasHeader,
false );
1063 if ( rowsVisibleInLastFrame < 1 )
1070 rowsAlreadyShown += rowsVisibleInLastFrame;
1076 height += heightOfLastFrame * numberFramesMissing;
1083 if ( lastRow - firstRow < 1 && !drawHeaderLines )
1090 double currentY = 0;
1091 currentY = halfGridStrokeWidth;
1092 if ( drawHeaderLines )
1094 painter->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF(
mTableSize.width() - halfGridStrokeWidth, currentY ) );
1098 for (
int row = firstRow; row < lastRow; ++row )
1100 painter->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF(
mTableSize.width() - halfGridStrokeWidth, currentY ) );
1105 painter->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF(
mTableSize.width() - halfGridStrokeWidth, currentY ) );
1108 bool QgsLayoutTable::textRequiresWrapping(
const QString &text,
double columnWidth,
const QFont &font )
const 1113 QStringList multiLineSplit = text.split(
'\n' );
1114 double currentTextWidth = 0;
1115 const auto constMultiLineSplit = multiLineSplit;
1116 for (
const QString &line : constMultiLineSplit )
1121 return ( currentTextWidth > columnWidth );
1124 QString QgsLayoutTable::wrappedText(
const QString &value,
double columnWidth,
const QFont &font )
const 1126 QStringList lines = value.split(
'\n' );
1127 QStringList outLines;
1128 const auto constLines = lines;
1129 for (
const QString &line : constLines )
1131 if ( textRequiresWrapping( line, columnWidth, font ) )
1134 QStringList words = line.split(
' ' );
1135 QStringList linesToProcess;
1136 QString wordsInCurrentLine;
1137 const auto constWords = words;
1138 for (
const QString &word : constWords )
1140 if ( textRequiresWrapping( word, columnWidth, font ) )
1143 if ( !wordsInCurrentLine.isEmpty() )
1144 linesToProcess << wordsInCurrentLine;
1145 wordsInCurrentLine.clear();
1146 linesToProcess << word;
1150 if ( !wordsInCurrentLine.isEmpty() )
1151 wordsInCurrentLine.append(
' ' );
1152 wordsInCurrentLine.append( word );
1155 if ( !wordsInCurrentLine.isEmpty() )
1156 linesToProcess << wordsInCurrentLine;
1158 const auto constLinesToProcess = linesToProcess;
1159 for (
const QString &line : constLinesToProcess )
1161 QString remainingText = line;
1162 int lastPos = remainingText.lastIndexOf(
' ' );
1163 while ( lastPos > -1 )
1166 if ( !textRequiresWrapping( remainingText, columnWidth, font ) )
1171 if ( !textRequiresWrapping( remainingText.left( lastPos ), columnWidth, font ) )
1173 outLines << remainingText.left( lastPos );
1174 remainingText = remainingText.mid( lastPos + 1 );
1177 lastPos = remainingText.lastIndexOf(
' ', lastPos - 1 );
1179 outLines << remainingText;
1188 return outLines.join( QStringLiteral(
"\n" ) );
1195 if ( style->enabled && column % 2 == 0 )
1196 color = style->cellBackgroundColor;
1198 if ( style->enabled && column % 2 == 1 )
1199 color = style->cellBackgroundColor;
1201 if ( style->enabled && row % 2 == 0 )
1202 color = style->cellBackgroundColor;
1204 if ( style->enabled && row % 2 == 1 )
1205 color = style->cellBackgroundColor;
1207 if ( style->enabled && column == 0 )
1208 color = style->cellBackgroundColor;
1210 if ( style->enabled && column ==
mColumns.count() - 1 )
1211 color = style->cellBackgroundColor;
1213 if ( style->enabled && row == -1 )
1214 color = style->cellBackgroundColor;
1216 if ( style->enabled && row == 0 )
1217 color = style->cellBackgroundColor;
1220 color = style->cellBackgroundColor;
1228 if ( lastRow - firstRow < 1 && !hasHeader )
1234 double tableHeight = 0;
1240 double headerHeight = tableHeight;
1243 for (
int row = firstRow; row < lastRow; ++row )
1250 double currentX = halfGridStrokeWidth;
1251 painter->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, tableHeight - halfGridStrokeWidth ) );
1253 QMap<int, double>::const_iterator maxColWidthIt = maxWidthMap.constBegin();
1255 for ( ; maxColWidthIt != maxWidthMap.constEnd(); ++maxColWidthIt )
1257 currentX += ( maxColWidthIt.value() + 2 *
mCellMargin );
1258 if ( col == maxWidthMap.size() || !mergeCells )
1260 painter->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, tableHeight - halfGridStrokeWidth ) );
1262 else if ( hasHeader )
1264 painter->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, headerHeight - halfGridStrokeWidth ) );
1283 return ( contents.indexOf( row ) >= 0 );
EmptyTableMode
Controls how empty tables are displayed.
The class is used as a container of context for various read/write operations on other objects...
QMap< int, double > mMaxRowHeightMap
Map of maximum height for each row.
void refresh() override
Refreshes the multiframe, causing a recalculation of any property overrides.
void setWrapBehavior(WrapBehavior behavior)
Sets the wrap behavior for the table, which controls how text within cells is automatically wrapped...
virtual bool calculateMaxRowHeights()
Calculates the maximum height of text shown in rows.
QMap< CellStyleGroup, QgsLayoutTableStyle *> mCellStyles
Style odd numbered columns.
~QgsLayoutTable() override
WrapBehavior
Controls how long strings in the table are handled.
static double textWidthMM(const QFont &font, const QString &text)
Calculate a font width in millimeters for a text string, including workarounds for QT font rendering ...
bool horizontalGrid() const
Returns whether the grid's horizontal lines are drawn in the table.
This class is a composition of two QSettings instances:
void setCellMargin(double margin)
Sets the margin distance in mm between cell borders and their contents.
Header uses the same alignment as the column.
QgsLayoutTable(QgsLayout *layout)
Constructor for QgsLayoutTable, belonging to the specified layout.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
int frameIndex(QgsLayoutFrame *frame) const
Returns the index of a frame within the multiframe.
QRectF extent() const
Returns the visible portion of the multi frame's content which is shown in this frame, in layout units.
virtual QMap< int, QString > headerLabels() const
Returns the text used in the column headers for the table.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QgsLayoutSize sizeWithUnits() const
Returns the item's current size, including units.
void setHeaderFontColor(const QColor &color)
Sets the color used to draw header text in the table.
double mCellMargin
Margin between cell borders and cell text.
Styling option for a composer table cell.
bool writeXml(QDomElement &styleElem, QDomDocument &doc) const
Writes the style's properties to XML for storage.
bool writePropertiesToElement(QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context) const override
Stores multiframe state within an XML DOM element.
QVector< QgsLayoutTableColumn *> QgsLayoutTableColumns
List of column definitions for a QgsLayoutTable.
bool readXml(const QDomElement &columnElem)
Reads the column's properties from xml.
void setEmptyTableMessage(const QString &message)
Sets the message for empty tables with no content rows.
WrapBehavior mWrapBehavior
virtual void refreshAttributes()
Refreshes the contents shown in the table by querying for new data.
QSizeF minFrameSize(int frameIndex=-1) const override
Returns the minimum size for a frames, if desired.
void setVerticalGrid(bool verticalGrid)
Sets whether the grid's vertical lines should be drawn in the table.
Text which doesn't fit inside the cell is truncated.
void setCellStyle(CellStyleGroup group, const QgsLayoutTableStyle &style)
Sets the cell style for a cell group.
Style even numbered columns.
void render(QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex) override
Renders a portion of the multiframe's content into a render context.
QString mEmptyTableMessage
String to show in empty tables.
Shows preset message instead of table contents.
int frameCount() const
Returns the number of frames associated with this multiframe.
Text which doesn't fit inside the cell is wrapped. Note that this only applies to text in columns wit...
void recalculateFrameRects()
Forces a recalculation of all the associated frame's scene rectangles.
const QgsLayoutTableStyle * cellStyle(CellStyleGroup group) const
Returns the cell style for a cell group.
double totalHeight()
Returns total height of table contents.
Creates new full page frames on the following page(s) until the entire multiframe content is visible...
Stores properties of a column for a QgsLayoutTable.
QSizeF fixedFrameSize(int frameIndex=-1) const override
Returns the fixed size for a frame, if desired.
Abstract base class for layout items with the ability to distribute the content to several frames (Qg...
QColor mGridColor
Color for grid lines.
static QString encodeColor(const QColor &color)
QSizeF totalSize() const override
Returns the total size of the multiframe's content, in layout units.
bool mShowGrid
True if grid should be shown.
No headers shown for table.
void setHeaderMode(HeaderMode mode)
Sets the display mode for headers in the table.
QColor mContentFontColor
Table contents font color.
bool mVerticalGrid
True if grid should be shown.
QColor mHeaderFontColor
Header font color.
void setHorizontalGrid(bool horizontalGrid)
Sets whether the grid's horizontal lines should be drawn in the table.
void recalculateFrameSizes() override
virtual bool calculateMaxColumnWidths()
Calculates the maximum width of text shown in columns.
void setHeaderHAlignment(HeaderHAlignment alignment)
Sets the horizontal alignment for table headers.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
QColor cellBackgroundColor
Cell background color.
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.
QPointer< QgsLayout > mLayout
static bool setFromXmlChildNode(QFont &font, const QDomElement &element, const QString &childNode)
Sets the properties of a font to match the properties stored in an XML child node.
QColor mBackgroundColor
Color for table background.
void setContentFontColor(const QColor &color)
Sets the color used to draw text in table body cells.
Header shown on first frame only.
bool mHorizontalGrid
True if grid should be shown.
QFont mHeaderFont
Header font.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
void setGridStrokeWidth(double width)
Sets the width in mm for grid lines in the table.
virtual bool getTableContents(QgsLayoutTableContents &contents)=0
Fetches the contents used for the cells in the table.
bool mShowEmptyRows
True if empty rows should be shown in the table.
virtual void recalculateFrameSizes()
Recalculates the portion of the multiframe item which is shown in each of its component frames...
static void drawText(QPainter *painter, QPointF position, const QString &text, const QFont &font, const QColor &color=QColor())
Draws text on a painter at a specific position, taking care of layout specific issues (calculation to...
QFont mContentFont
Table contents font.
Contains settings and helpers relating to a render of a QgsLayoutItem.
QgsLayoutFrame * frame(int index) const
Returns the child frame at a specified index from the multiframe.
double mGridStrokeWidth
Width of grid lines.
bool verticalGrid() const
Returns whether the grid's vertical lines are drawn in the table.
bool showGrid() const
Returns whether grid lines are drawn in the table.
QgsLayoutTableColumns mColumns
Columns to show in table.
void setContentFont(const QFont &font)
Sets the font used to draw text in table body cells.
bool readXml(const QDomElement &styleElem)
Reads the style's properties from XML.
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsLayoutTableContents & contents()
Returns the current contents of the table.
void drawHorizontalGridLines(QPainter *painter, int firstRow, int lastRow, bool drawHeaderLines) const
Draws the horizontal grid lines for the table.
static double fontAscentMM(const QFont &font)
Calculates a font ascent in millimeters, including workarounds for QT font rendering issues...
void update()
Forces a redraw of all child frames.
Headers shown on all frames.
QgsLayoutTableContents mTableContents
Contents to show in table.
void setBackgroundColor(const QColor &color)
Sets the color used for background of table.
QPair< int, int > rowRange(int frameIndex) const
Calculates a range of rows which should be visible in a given frame.
static double textHeightMM(const QFont &font, const QString &text, double multiLineHeight=1.0)
Calculate a font height in millimeters for a text string, including workarounds for QT font rendering...
EmptyTableMode mEmptyTableMode
Behavior for empty tables.
QColor backgroundColor() const
Returns the color used for the background of the table.
double totalWidth()
Returns total width of table contents.
QMap< int, double > mMaxColumnWidthMap
Map of maximum width for each column.
static QDomElement toXmlElement(const QFont &font, QDomDocument &document, const QString &elementName)
Returns a DOM element containing the properties of the font.
void setHeaderFont(const QFont &font)
Sets the font used to draw header text in the table.
bool enabled
Whether the styling option is enabled.
HeaderMode
Controls where headers are shown in the table.
HeaderHAlignment
Controls how headers are horizontally aligned in a table.
Style even numbered rows.
void setEmptyTableBehavior(EmptyTableMode mode)
Sets the behavior mode for empty tables with no content rows.
QgsLayoutTableColumns & columns()
Returns a reference to the list of QgsLayoutTableColumns shown in the table.
void setShowGrid(bool showGrid)
Sets whether grid lines should be drawn in the table.
void setColumns(const QgsLayoutTableColumns &columns)
Replaces the columns in the table with a specified list of QgsLayoutTableColumns. ...
void changed()
Emitted when the object's properties change.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
double height() const
Returns the height of the size.
CellStyleGroup
Row or column groups for cell styling.
HeaderMode mHeaderMode
Header display mode.
void setGridColor(const QColor &color)
Sets the color used for grid lines in the table.
bool contentsContainsRow(const QgsLayoutTableContents &contents, const QgsLayoutTableRow &row) const
Checks whether a table contents contains a given row.
HeaderHAlignment mHeaderHAlignment
Alignment for table headers.
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...
QVector< QgsLayoutTableRow > QgsLayoutTableContents
List of QgsLayoutTableRows, representing rows and column cell contents for a QgsLayoutTable.
void setShowEmptyRows(bool showEmpty)
Sets whether empty rows should be drawn.
static QColor decodeColor(const QString &str)
Hides entire table if empty.
Item representing the paper in a layout.
bool readPropertiesFromElement(const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context) override
Sets multiframe state from a DOM element.
QVector< QVariant > QgsLayoutTableRow
List of QVariants, representing a the contents of a single row in a QgsComposerTable.
void recalculateTableSize()
Recalculates and updates the size of the table and all table frames.