18 #ifndef QGSLAYOUTTABLE_H 19 #define QGSLAYOUTTABLE_H 21 #include "qgis_core.h" 78 QColor cellBackgroundColor = QColor( 255, 255, 255, 255 );
86 bool writeXml( QDomElement &styleElem, QDomDocument &doc )
const;
93 bool readXml(
const QDomElement &styleElem );
176 void setCellMargin(
const double margin );
204 void setEmptyTableMessage(
const QString &message );
220 void setShowEmptyRows(
const bool showEmpty );
233 void setHeaderFont(
const QFont &font );
248 void setHeaderFontColor(
const QColor &color );
289 void setContentFont(
const QFont &font );
304 void setContentFontColor(
const QColor &color );
321 void setShowGrid(
const bool showGrid );
337 void setGridStrokeWidth(
const double width );
353 void setGridColor(
const QColor &color );
371 void setHorizontalGrid(
const bool horizontalGrid );
390 void setVerticalGrid(
const bool verticalGrid );
406 void setBackgroundColor(
const QColor &color );
460 virtual QMap<int, QString> headerLabels()
const SIP_SKIP;
474 QSizeF
fixedFrameSize(
const int frameIndex = -1 )
const override;
475 QSizeF
minFrameSize(
const int frameIndex = -1 )
const override;
492 virtual void refreshAttributes();
498 double mCellMargin = 1.0;
507 bool mShowEmptyRows =
false;
513 QColor mHeaderFontColor = Qt::black;
525 QColor mContentFontColor = Qt::black;
528 bool mShowGrid =
true;
531 double mGridStrokeWidth = 0.5;
534 QColor mGridColor = Qt::black;
537 bool mHorizontalGrid =
true;
540 bool mVerticalGrid =
true;
543 QColor mBackgroundColor = Qt::white;
566 virtual bool calculateMaxColumnWidths();
571 virtual bool calculateMaxRowHeights();
586 double totalHeight();
599 int rowsVisible(
double frameHeight,
int firstRow,
bool includeHeader,
bool includeEmptyRows )
const;
610 int rowsVisible(
int frameIndex,
int firstRow,
bool includeEmptyRows )
const;
617 QPair<int, int> rowRange(
const int frameIndex )
const;
628 void drawHorizontalGridLines( QPainter *painter,
int firstRow,
int lastRow,
bool drawHeaderLines )
const;
645 void drawVerticalGridLines( QPainter *painter,
const QMap<int, double> &maxWidthMap,
int firstRow,
int lastRow,
bool hasHeader,
bool mergeCells =
false ) const SIP_SKIP;
650 void recalculateTableSize();
667 bool textRequiresWrapping( const QString &text,
double columnWidth, const QFont &font ) const;
669 QString wrappedText( const QString &value,
double columnWidth, const QFont &font ) const;
677 QColor backgroundColor(
int row,
int column ) const;
679 friend class TestQgsLayoutTable;
683 #endif // QGSLAYOUTTABLE_H 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.
virtual QSizeF totalSize() const =0
Returns the total size of the multiframe's content, in layout units.
void refresh() override
Refreshes the multiframe, causing a recalculation of any property overrides.
QString emptyTableMessage() const
Returns the message for empty tables with no content rows.
QMap< CellStyleGroup, QgsLayoutTableStyle *> mCellStyles
Style odd numbered columns.
virtual QSizeF fixedFrameSize(const int frameIndex=-1) const
Returns the fixed size for a frame, if desired.
QColor contentFontColor() const
Returns the color used to draw text in table body cells.
WrapBehavior
Controls how long strings in the table are handled.
bool horizontalGrid() const
Returns whether the grid's horizontal lines are drawn in the table.
Header uses the same alignment as the column.
QColor gridColor() const
Returns the color used for grid lines in the table.
A class to display a table in the print layout, and allow the table to span over multiple frames...
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores multiframe state within an XML DOM element.
Styling option for a composer table cell.
QVector< QgsLayoutTableColumn *> QgsLayoutTableColumns
List of column definitions for a QgsLayoutTable.
Style even numbered columns.
QString mEmptyTableMessage
String to show in empty tables.
double gridStrokeWidth() const
Returns the width of grid lines in the table in mm.
bool showEmptyRows() const
Returns whether empty rows are drawn in the table.
QFont contentFont() const
Returns the font used to draw text in table body cells.
Stores properties of a column for a QgsLayoutTable.
Abstract base class for layout items with the ability to distribute the content to several frames (Qg...
EmptyTableMode emptyTableBehavior() const
Returns the behavior mode for empty tables.
QFont mHeaderFont
Header font.
WrapBehavior wrapBehavior() const
Returns the wrap behavior for the table, which controls how text within cells is automatically wrappe...
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
QColor headerFontColor() const
Returns the color used to draw header text in the table.
virtual void recalculateFrameSizes()
Recalculates the portion of the multiframe item which is shown in each of its component frames...
QFont mContentFont
Table contents font.
Contains settings and helpers relating to a render of a QgsLayoutItem.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets multiframe state from a DOM element.
double cellMargin() const
Returns the margin distance between cell borders and their contents in mm.
QgsCompositionConverter class converts a QGIS 2.x composition to a QGIS 3.x layout.
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.
virtual void render(QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex)=0
Renders a portion of the multiframe's content into a render context.
QgsLayoutTableContents & contents()
Returns the current contents of the table.
HeaderHAlignment headerHAlignment() const
Returns the horizontal alignment for table headers.
virtual QSizeF minFrameSize(const int frameIndex=-1) const
Returns the minimum size for a frames, if desired.
Headers shown on all frames.
QgsLayoutTableContents mTableContents
Contents to show in table.
QFont headerFont() const
Returns the font used to draw header text in the table.
QColor backgroundColor() const
Returns the color used for the background of the table.
HeaderMode headerMode() const
Returns the display mode for headers in the table.
QMap< int, double > mMaxColumnWidthMap
Map of maximum width for each column.
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.
CellStyleGroup
Row or column groups for cell styling.
QVector< QgsLayoutTableRow > QgsLayoutTableContents
List of QgsLayoutTableRows, representing rows and column cell contents for a QgsLayoutTable.
Hides entire table if empty.
QVector< QVariant > QgsLayoutTableRow
List of QVariants, representing a the contents of a single row in a QgsComposerTable.