本文整理汇总了C++中QTextDocumentPrivate::blockMap方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextDocumentPrivate::blockMap方法的具体用法?C++ QTextDocumentPrivate::blockMap怎么用?C++ QTextDocumentPrivate::blockMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextDocumentPrivate
的用法示例。
在下文中一共展示了QTextDocumentPrivate::blockMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: end
/*!
Returns a frame iterator pointing to the end of the table's cell.
\sa begin()
*/
QTextFrame::iterator QTextTableCell::end() const
{
QTextDocumentPrivate *p = table->docHandle();
int b = p->blockMap().findNode(firstPosition());
int e = p->blockMap().findNode(lastPosition()+1);
return QTextFrame::iterator(const_cast<QTextTable *>(table), e, b, e);
}
示例2: splitCell
/*!
\since 4.1
Splits the specified cell at \a row and \a column into an array of multiple
cells with dimensions specified by \a numRows and \a numCols.
\note It is only possible to split cells that span multiple rows or columns, such as rows
that have been merged using mergeCells().
\sa mergeCells()
*/
void QTextTable::splitCell(int row, int column, int numRows, int numCols)
{
Q_D(QTextTable);
if (d->dirty)
d->update();
QTextDocumentPrivate *p = d->pieceTable;
QTextFormatCollection *c = p->formatCollection();
const QTextTableCell cell = cellAt(row, column);
if (!cell.isValid())
return;
row = cell.row();
column = cell.column();
QTextCharFormat fmt = cell.format();
const int rowSpan = fmt.tableCellRowSpan();
const int colSpan = fmt.tableCellColumnSpan();
// nothing to split?
if (numRows > rowSpan || numCols > colSpan)
return;
p->beginEditBlock();
const int origCellPosition = cell.firstPosition() - 1;
QVarLengthArray<int> rowPositions(rowSpan);
rowPositions[0] = cell.lastPosition();
for (int r = row + 1; r < row + rowSpan; ++r) {
// find the cell before which to insert the new cell markers
int gridIndex = r * d->nCols + column;
QVector<int>::iterator it = qUpperBound(d->cellIndices.begin(), d->cellIndices.end(), gridIndex);
int cellIndex = it - d->cellIndices.begin();
int fragment = d->cells.value(cellIndex, d->fragment_end);
rowPositions[r - row] = p->fragmentMap().position(fragment);
}
fmt.setTableCellColumnSpan(1);
fmt.setTableCellRowSpan(1);
const int fmtIndex = c->indexForFormat(fmt);
const int blockIndex = p->blockMap().find(cell.lastPosition())->format;
int insertAdjustement = 0;
for (int i = 0; i < numRows; ++i) {
for (int c = 0; c < colSpan - numCols; ++c)
p->insertBlock(QTextBeginningOfFrame, rowPositions[i] + insertAdjustement + c, blockIndex, fmtIndex);
insertAdjustement += colSpan - numCols;
}
for (int i = numRows; i < rowSpan; ++i) {
for (int c = 0; c < colSpan; ++c)
p->insertBlock(QTextBeginningOfFrame, rowPositions[i] + insertAdjustement + c, blockIndex, fmtIndex);
insertAdjustement += colSpan;
}
fmt.setTableCellRowSpan(numRows);
fmt.setTableCellColumnSpan(numCols);
p->setCharFormat(origCellPosition, 1, fmt);
p->endEditBlock();
}