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" ), QLatin1String(
"" ) ) );
138 mContentFont.fromString( itemElem.attribute( QStringLiteral(
"contentFont" ), QLatin1String(
"" ) ) );
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 Q_FOREACH (
const QString &line, multiLineSplit )
902 widths[ row * cols + col ] = currentCellTextWidth;
906 widths[ row * cols + col ] = 0;
915 for (
int col = 0; col < cols; ++col )
917 double maxColWidth = 0;
920 maxColWidth = std::max( widths[ row * cols + col ], maxColWidth );
935 QVector< double > heights( cells );
938 QgsLayoutTableColumns::const_iterator columnIt =
mColumns.constBegin();
940 for ( ; columnIt !=
mColumns.constEnd(); ++columnIt )
948 QgsLayoutTableContents::const_iterator rowIt =
mTableContents.constBegin();
952 QgsLayoutTableRow::const_iterator colIt = rowIt->constBegin();
954 for ( ; colIt != rowIt->constEnd(); ++colIt )
974 double maxRowHeight = 0;
975 for (
int col = 0; col < cols; ++col )
977 maxRowHeight = std::max( heights[ row * cols + col ], maxRowHeight );
998 totalWidth += maxColWidthIt.value();
1018 int rowsAlreadyShown = 0;
1020 int rowsVisibleInLastFrame = 0;
1021 double heightOfLastFrame = 0;
1022 for (
int idx = 0; idx < numberExistingFrames; ++idx )
1026 heightOfLastFrame =
frame( idx )->rect().height();
1027 rowsVisibleInLastFrame =
rowsVisible( heightOfLastFrame, rowsAlreadyShown, hasHeader,
false );
1028 rowsAlreadyShown += rowsVisibleInLastFrame;
1029 height += heightOfLastFrame;
1040 if ( remainingRows <= 0 )
1056 int numberFramesMissing = 0;
1057 while ( remainingRows > 0 )
1059 numberFramesMissing++;
1061 rowsVisibleInLastFrame =
rowsVisible( heightOfLastFrame, rowsAlreadyShown, hasHeader,
false );
1062 if ( rowsVisibleInLastFrame < 1 )
1069 rowsAlreadyShown += rowsVisibleInLastFrame;
1075 height += heightOfLastFrame * numberFramesMissing;
1082 if ( lastRow - firstRow < 1 && !drawHeaderLines )
1089 double currentY = 0;
1090 currentY = halfGridStrokeWidth;
1091 if ( drawHeaderLines )
1093 painter->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF(
mTableSize.width() - halfGridStrokeWidth, currentY ) );
1097 for (
int row = firstRow; row < lastRow; ++row )
1099 painter->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF(
mTableSize.width() - halfGridStrokeWidth, currentY ) );
1104 painter->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF(
mTableSize.width() - halfGridStrokeWidth, currentY ) );
1107 bool QgsLayoutTable::textRequiresWrapping(
const QString &text,
double columnWidth,
const QFont &font )
const 1112 QStringList multiLineSplit = text.split(
'\n' );
1113 double currentTextWidth = 0;
1114 Q_FOREACH (
const QString &line, multiLineSplit )
1119 return ( currentTextWidth > columnWidth );
1122 QString QgsLayoutTable::wrappedText(
const QString &value,
double columnWidth,
const QFont &font )
const 1124 QStringList lines = value.split(
'\n' );
1125 QStringList outLines;
1126 Q_FOREACH (
const QString &line, lines )
1128 if ( textRequiresWrapping( line, columnWidth, font ) )
1131 QStringList words = line.split(
' ' );
1132 QStringList linesToProcess;
1133 QString wordsInCurrentLine;
1134 Q_FOREACH (
const QString &word, words )
1136 if ( textRequiresWrapping( word, columnWidth, font ) )
1139 if ( !wordsInCurrentLine.isEmpty() )
1140 linesToProcess << wordsInCurrentLine;
1141 wordsInCurrentLine.clear();
1142 linesToProcess << word;
1146 if ( !wordsInCurrentLine.isEmpty() )
1147 wordsInCurrentLine.append(
' ' );
1148 wordsInCurrentLine.append( word );
1151 if ( !wordsInCurrentLine.isEmpty() )
1152 linesToProcess << wordsInCurrentLine;
1154 Q_FOREACH (
const QString &line, linesToProcess )
1156 QString remainingText = line;
1157 int lastPos = remainingText.lastIndexOf(
' ' );
1158 while ( lastPos > -1 )
1160 if ( !textRequiresWrapping( remainingText.left( lastPos ), columnWidth, font ) )
1162 outLines << remainingText.left( lastPos );
1163 remainingText = remainingText.mid( lastPos + 1 );
1166 lastPos = remainingText.lastIndexOf(
' ', lastPos - 1 );
1168 outLines << remainingText;
1177 return outLines.join( QStringLiteral(
"\n" ) );
1184 if ( style->enabled && column % 2 == 0 )
1185 color = style->cellBackgroundColor;
1187 if ( style->enabled && column % 2 == 1 )
1188 color = style->cellBackgroundColor;
1190 if ( style->enabled && row % 2 == 0 )
1191 color = style->cellBackgroundColor;
1193 if ( style->enabled && row % 2 == 1 )
1194 color = style->cellBackgroundColor;
1196 if ( style->enabled && column == 0 )
1197 color = style->cellBackgroundColor;
1199 if ( style->enabled && column ==
mColumns.count() - 1 )
1200 color = style->cellBackgroundColor;
1202 if ( style->enabled && row == -1 )
1203 color = style->cellBackgroundColor;
1205 if ( style->enabled && row == 0 )
1206 color = style->cellBackgroundColor;
1209 color = style->cellBackgroundColor;
1217 if ( lastRow - firstRow < 1 && !hasHeader )
1223 double tableHeight = 0;
1229 double headerHeight = tableHeight;
1232 for (
int row = firstRow; row < lastRow; ++row )
1239 double currentX = halfGridStrokeWidth;
1240 painter->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, tableHeight - halfGridStrokeWidth ) );
1242 QMap<int, double>::const_iterator maxColWidthIt = maxWidthMap.constBegin();
1244 for ( ; maxColWidthIt != maxWidthMap.constEnd(); ++maxColWidthIt )
1246 currentX += ( maxColWidthIt.value() + 2 *
mCellMargin );
1247 if ( col == maxWidthMap.size() || !mergeCells )
1249 painter->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, tableHeight - halfGridStrokeWidth ) );
1251 else if ( hasHeader )
1253 painter->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, headerHeight - halfGridStrokeWidth ) );
1272 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 setHorizontalGrid(const bool horizontalGrid)
Sets whether the grid's horizontal lines should be drawn in the table.
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:
Header uses the same alignment as the column.
QgsLayoutTable(QgsLayout *layout)
Constructor for QgsLayoutTable, belonging to the specified layout.
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.
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.
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.
QPair< int, int > rowRange(const int frameIndex) const
Calculates a range of rows which should be visible in a given frame.
Text which doesn't fit inside the cell is wrapped. Note that this only applies to text in columns wit...
void setShowGrid(const bool showGrid)
Sets whether grid lines should be drawn in the table.
QSizeF minFrameSize(const int frameIndex=-1) const override
Returns the minimum size for a frames, if desired.
void recalculateFrameRects()
Forces a recalculation of all the associated frame's scene rectangles.
void setShowEmptyRows(const bool showEmpty)
Sets whether empty rows should be drawn.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
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.
void setVerticalGrid(const bool verticalGrid)
Sets whether the grid's vertical lines should be drawn in the table.
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.
QColor mContentFontColor
Table contents font color.
bool mVerticalGrid
True if grid should be shown.
QColor mHeaderFontColor
Header font color.
void recalculateFrameSizes() override
virtual bool calculateMaxColumnWidths()
Calculates the maximum width of text shown in columns.
void setEmptyTableBehavior(const EmptyTableMode mode)
Sets the behavior mode for empty tables with no content rows.
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.
virtual bool getTableContents(QgsLayoutTableContents &contents)=0
Fetches the contents used for the cells in the table.
void setCellMargin(const double margin)
Sets the margin distance in mm between cell borders and their contents.
bool mShowEmptyRows
True if empty rows should be shown in the table.
void setGridStrokeWidth(const double width)
Sets the width in mm for grid lines 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.
void setHeaderHAlignment(const HeaderHAlignment alignment)
Sets the horizontal alignment for table headers.
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.
void setHeaderMode(const HeaderMode mode)
Sets the display mode for headers in the table.
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.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), const Section section=NoSection) const
Returns the value for setting key.
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.
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.
QgsLayoutTableColumns & columns()
Returns a reference to the list of QgsLayoutTableColumns shown 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.
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.
QSizeF fixedFrameSize(const int frameIndex=-1) const override
Returns the fixed size for a frame, if desired.
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.