本文整理汇总了C++中QTextDocumentPrivate::aboutToRemoveCell方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextDocumentPrivate::aboutToRemoveCell方法的具体用法?C++ QTextDocumentPrivate::aboutToRemoveCell怎么用?C++ QTextDocumentPrivate::aboutToRemoveCell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextDocumentPrivate
的用法示例。
在下文中一共展示了QTextDocumentPrivate::aboutToRemoveCell方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeRows
/*!
\fn void QTextTable::removeRows(int index, int rows)
Removes a number of \a rows starting with the row at the specified \a index.
\sa insertRows(), insertColumns(), resize(), removeColumns(), appendRows(), appendColumns()
*/
void QTextTable::removeRows(int pos, int num)
{
Q_D(QTextTable);
// qDebug() << "-------- removeRows" << pos << num;
if (num <= 0 || pos < 0)
return;
if (d->dirty)
d->update();
if (pos >= d->nRows)
return;
if (pos+num > d->nRows)
num = d->nRows - pos;
QTextDocumentPrivate *p = d->pieceTable;
QTextFormatCollection *collection = p->formatCollection();
p->beginEditBlock();
// delete whole table?
if (pos == 0 && num == d->nRows) {
const int pos = p->fragmentMap().position(d->fragment_start);
p->remove(pos, p->fragmentMap().position(d->fragment_end) - pos + 1);
p->endEditBlock();
return;
}
p->aboutToRemoveCell(cellAt(pos, 0).firstPosition(), cellAt(pos + num - 1, d->nCols - 1).lastPosition());
QList<int> touchedCells;
for (int r = pos; r < pos + num; ++r) {
for (int c = 0; c < d->nCols; ++c) {
int cell = d->grid[r*d->nCols + c];
if (touchedCells.contains(cell))
continue;
touchedCells << cell;
QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
QTextCharFormat fmt = collection->charFormat(it->format);
int span = fmt.tableCellRowSpan();
if (span > 1) {
fmt.setTableCellRowSpan(span - 1);
p->setCharFormat(it.position(), 1, fmt);
} else {
// remove cell
int index = d->cells.indexOf(cell) + 1;
int f_end = index < d->cells.size() ? d->cells.at(index) : d->fragment_end;
p->remove(it.position(), p->fragmentMap().position(f_end) - it.position());
}
}
}
p->endEditBlock();
// qDebug() << "-------- end removeRows" << pos << num;
}
示例2: removeColumns
/*!
\fn void QTextTable::removeColumns(int index, int columns)
Removes a number of \a columns starting with the column at the specified
\a index.
\sa insertRows(), insertColumns(), removeRows(), resize(), appendRows(), appendColumns()
*/
void QTextTable::removeColumns(int pos, int num)
{
Q_D(QTextTable);
// qDebug() << "-------- removeCols" << pos << num;
if (num <= 0 || pos < 0)
return;
if (d->dirty)
d->update();
if (pos >= d->nCols)
return;
if (pos + num > d->nCols)
pos = d->nCols - num;
QTextDocumentPrivate *p = d->pieceTable;
QTextFormatCollection *collection = p->formatCollection();
p->beginEditBlock();
// delete whole table?
if (pos == 0 && num == d->nCols) {
const int pos = p->fragmentMap().position(d->fragment_start);
p->remove(pos, p->fragmentMap().position(d->fragment_end) - pos + 1);
p->endEditBlock();
return;
}
p->aboutToRemoveCell(cellAt(0, pos).firstPosition(), cellAt(d->nRows - 1, pos + num - 1).lastPosition());
QList<int> touchedCells;
for (int r = 0; r < d->nRows; ++r) {
for (int c = pos; c < pos + num; ++c) {
int cell = d->grid[r*d->nCols + c];
QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
QTextCharFormat fmt = collection->charFormat(it->format);
int span = fmt.tableCellColumnSpan();
if (touchedCells.contains(cell) && span <= 1)
continue;
touchedCells << cell;
if (span > 1) {
fmt.setTableCellColumnSpan(span - 1);
p->setCharFormat(it.position(), 1, fmt);
} else {
// remove cell
int index = d->cells.indexOf(cell) + 1;
int f_end = index < d->cells.size() ? d->cells.at(index) : d->fragment_end;
p->remove(it.position(), p->fragmentMap().position(f_end) - it.position());
}
}
}
QTextTableFormat tfmt = format();
tfmt.setColumns(tfmt.columns()-num);
QVector<QTextLength> columnWidths = tfmt.columnWidthConstraints();
if (columnWidths.count() > pos) {
columnWidths.remove(pos, num);
tfmt.setColumnWidthConstraints (columnWidths);
}
QTextObject::setFormat(tfmt);
p->endEditBlock();
// qDebug() << "-------- end removeCols" << pos << num;
}