874 int tableHeaderRowCount = 0;
876 rowNodes.
reserve(
at(tableNodeIdx).children.count());
878 switch (
at(row).
id) {
887 rowNodes += potentialRow;
889 ++tableHeaderRowCount;
898 int effectiveRow = 0;
899 foreach (
int row, rowNodes) {
905 while (colsInRow < rowColSpanForColumn.
size()) {
906 const RowColSpanInfo &spanInfo = rowColSpanForColumn[colsInRow];
908 if (spanInfo.row + spanInfo.rowSpan > effectiveRow) {
909 Q_ASSERT(spanInfo.col == colsInRow);
910 colsInRow += spanInfo.colSpan;
916 const int currentColumn = colsInRow;
919 RowColSpanInfo spanInfo;
920 spanInfo.row = effectiveRow;
921 spanInfo.col = currentColumn;
924 if (spanInfo.colSpan > 1 || spanInfo.rowSpan > 1)
925 rowColSpans.
append(spanInfo);
928 rowColSpanForColumn.
resize(columnWidths.
size());
936 rowColSpanForColumn[i] = spanInfo;
940 table.columns =
qMax(table.columns, colsInRow);
944 table.rows = effectiveRow;
946 table.lastIndent =
indent;
949 if (table.rows == 0 || table.columns == 0)
970 + table.lastIndent * 40
1001 table.isTextFrame =
true;
1005 table.frame = textTable;
1007 for (
int i = 0; i < rowColSpans.
count(); ++i) {
1008 const RowColSpanInfo &nfo = rowColSpans.
at(i);
1009 textTable->
mergeCells(nfo.row, nfo.col, nfo.rowSpan, nfo.colSpan);
1012 table.currentCell = TableCellIterator(textTable);
QTextTable * insertTable(int rows, int cols, const QTextTableFormat &format)
Creates a new table with the given number of rows and columns in the specified format, inserts it at the current cursor position() in the document, and returns the table object.
void setBorderBrush(const QBrush &brush)
Sets the brush used for the frame's border.
QTextFrameFormat::BorderStyle borderStyle
int rightMargin(int i) const
void setBorder(qreal border)
Sets the width (in pixels) of the frame's border.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
void setBorderStyle(BorderStyle style)
Sets the style of the frame's border.
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
Type type() const
Returns the type of this length object.
QTextFrame * insertFrame(const QTextFrameFormat &format)
Inserts a frame with the given format at the current cursor position(), moves the cursor position() i...
Position
This enum describes how a frame is located relative to the surrounding text.
PageBreakFlags pageBreakPolicy() const
Returns the currently set page break policy for the paragraph.
void setWidth(qreal width)
Convenience method that sets the width of the frame's border rectangle's width to the specified fixed...
const QTextHtmlParserNode & at(int i) const
void setCellPadding(qreal padding)
Sets the cell padding for the table.
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
qreal leftMargin() const
Returns the width of the frame's left margin in pixels.
void setBackground(const QBrush &brush)
Sets the brush use to paint the document's background to the brush specified.
QTextTableFormat toTableFormat() const
Returns this format as a table format.
void mergeCells(int row, int col, int numRows, int numCols)
Merges the cell at the specified row and column with the adjacent cells into one cell.
The QVector class is a template class that provides a dynamic array.
Qt::Alignment alignment() const
Returns the paragraph's alignment.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Qt::LayoutDirection layoutDirection() const
Returns the document's layout direction.
void resize(int size)
Sets the size of the vector to size.
void setColumnWidthConstraints(const QVector< QTextLength > &constraints)
Sets the column width constraints for the table.
void setPosition(Position f)
Sets the policy for positioning frames with this frame format.
int leftMargin(int i) const
QTextFrame * currentFrame() const
Returns a pointer to the current frame.
void setTopMargin(qreal margin)
Sets the frame's top margin in pixels.
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false...
QTextCharFormat charFormat
qreal topMargin() const
Returns the width of the frame's top margin in pixels.
qreal bottomMargin() const
Returns the width of the frame's bottom margin in pixels.
void setHeaderRowCount(int count)
Declares the first count rows of the table as table header.
void setPageBreakPolicy(PageBreakFlags flags)
Sets the page break policy for the frame/table to policy.
int bottomMargin(int i) const
QTextBlockFormat blockFormat
void append(const T &t)
Inserts value at the end of the vector.
int topMargin(int i) const
int position() const
Returns the absolute position of the cursor within the document.
QBrush background() const
Returns the brush used to paint the document's background.
Qt::BrushStyle style() const
Returns the brush style.
The QTextTable class represents a table in a QTextDocument.
const T & at(int i) const
Returns the item at index position i in the vector.
void setColumns(int columns)
Sets the number of columns required by the table format.
void setCellSpacing(qreal spacing)
Sets the cell spacing for the table.
void setAlignment(Qt::Alignment alignment)
Sets the table's alignment.
void setLeftMargin(qreal margin)
Sets the frame's left margin in pixels.
void setHeight(qreal height)
Sets the frame's height.
qreal rightMargin() const
Returns the width of the frame's right margin in pixels.
The QTextFrameFormat class provides formatting information for frames in a QTextDocument.
The QTextLength class encapsulates the different types of length used in a QTextDocument.
void setRightMargin(qreal margin)
Sets the frame's right margin in pixels.
qreal value(qreal maximumLength) const
Returns the effective length, constrained by the type of the length object and the specified maximumL...
void setPosition(int pos, MoveMode mode=MoveAnchor)
Moves the cursor to the absolute position in the document specified by pos using a MoveMode specified...
The QTextTableFormat class provides formatting information for tables in a QTextDocument.
void reserve(int size)
Attempts to allocate memory for at least size elements.
void setBottomMargin(qreal margin)
Sets the frame's bottom margin in pixels.
void setLayoutDirection(Qt::LayoutDirection direction)
Sets the document's layout direction to the specified direction.
void setFrameFormat(const QTextFrameFormat &format)
Sets the frame's format.
int size() const
Returns the number of items in the vector.