本文整理汇总了C++中QTextTableCell类的典型用法代码示例。如果您正苦于以下问题:C++ QTextTableCell类的具体用法?C++ QTextTableCell怎么用?C++ QTextTableCell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTextTableCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cursor
void
ChatDialog::appendChatMessage(const QString& nick, const QString& text, time_t timestamp)
{
QTextCharFormat nickFormat;
nickFormat.setForeground(Qt::darkGreen);
nickFormat.setFontWeight(QFont::Bold);
nickFormat.setFontUnderline(true);
nickFormat.setUnderlineColor(Qt::gray);
// Print who & when
QTextCursor cursor(ui->textEdit->textCursor());
cursor.movePosition(QTextCursor::End);
QTextTableFormat tableFormat;
tableFormat.setBorder(0);
QTextTable *table = cursor.insertTable(1, 2, tableFormat);
QString from = QString("%1 ").arg(nick);
QTextTableCell fromCell = table->cellAt(0, 0);
fromCell.setFormat(nickFormat);
fromCell.firstCursorPosition().insertText(from);
printTimeInCell(table, timestamp);
// Print what
QTextCursor nextCursor(ui->textEdit->textCursor());
nextCursor.movePosition(QTextCursor::End);
table = nextCursor.insertTable(1, 1, tableFormat);
table->cellAt(0, 0).firstCursorPosition().insertText(text);
// Popup notification
showMessage(from, text);
QScrollBar *bar = ui->textEdit->verticalScrollBar();
bar->setValue(bar->maximum());
}
示例2: printDeckListNode
void DeckListModel::printDeckListNode(QTextCursor *cursor, InnerDecklistNode *node)
{
static const int totalColumns = 3;
if (node->height() == 1) {
QTextBlockFormat blockFormat;
QTextCharFormat charFormat;
charFormat.setFontPointSize(11);
charFormat.setFontWeight(QFont::Bold);
cursor->insertBlock(blockFormat, charFormat);
cursor->insertText(QString("%1: %2").arg(node->getVisibleName()).arg(node->recursiveCount(true)));
QTextTableFormat tableFormat;
tableFormat.setCellPadding(0);
tableFormat.setCellSpacing(0);
tableFormat.setBorder(0);
QTextTable *table = cursor->insertTable(node->size() + 1, 2, tableFormat);
for (int i = 0; i < node->size(); i++) {
AbstractDecklistCardNode *card = dynamic_cast<AbstractDecklistCardNode *>(node->at(i));
QTextCharFormat cellCharFormat;
cellCharFormat.setFontPointSize(9);
QTextTableCell cell = table->cellAt(i, 0);
cell.setFormat(cellCharFormat);
QTextCursor cellCursor = cell.firstCursorPosition();
cellCursor.insertText(QString("%1 ").arg(card->getNumber()));
cell = table->cellAt(i, 1);
cell.setFormat(cellCharFormat);
cellCursor = cell.firstCursorPosition();
cellCursor.insertText(card->getName());
}
} else if (node->height() == 2) {
QTextBlockFormat blockFormat;
QTextCharFormat charFormat;
charFormat.setFontPointSize(14);
charFormat.setFontWeight(QFont::Bold);
cursor->insertBlock(blockFormat, charFormat);
cursor->insertText(QString("%1: %2").arg(node->getVisibleName()).arg(node->recursiveCount(true)));
QTextTableFormat tableFormat;
tableFormat.setCellPadding(10);
tableFormat.setCellSpacing(0);
tableFormat.setBorder(0);
QVector<QTextLength> constraints;
for (int i = 0; i < totalColumns; i++)
constraints << QTextLength(QTextLength::PercentageLength, 100.0 / totalColumns);
tableFormat.setColumnWidthConstraints(constraints);
QTextTable *table = cursor->insertTable(1, totalColumns, tableFormat);
for (int i = 0; i < node->size(); i++) {
QTextCursor cellCursor = table->cellAt(0, (i * totalColumns) / node->size()).lastCursorPosition();
printDeckListNode(&cellCursor, dynamic_cast<InnerDecklistNode *>(node->at(i)));
}
}
cursor->movePosition(QTextCursor::End);
}
示例3:
FrameIterator::FrameIterator(const QTextTableCell &cell)
{
Q_ASSERT(cell.isValid());
it = cell.begin();
currentTableIterator = 0;
currentSubFrameIterator = 0;
lineTextStart = -1;
endNoteIndex = 0;
}
示例4: featureUpdate
void MessageAction::featureUpdate()
{
QTextTableCell cell = textTable->cellAt(0,3);
QTextTableCellFormat format;
if (!isProcessed)
format.setBackground(QColor(Qt::red));
else
format.setBackground(QColor(Qt::white));
cell.setFormat(format);
}
示例5: fillCategoryTableLine
void PrintDialog::fillCategoryTableLine( QTextTable * table, const unsigned int & row,
const QString & position, const QString & lastname,
const QString & firstname, const QString & time)
{
int realRow = row + 1;
table->insertRows ( realRow, 1 );
QTextCharFormat cellFormat;
cellFormat.setFontPointSize(10.0);
if(row%2)
cellFormat.setBackground(QBrush(QColor(240,240,240)));
QTextTableCell cell = table->cellAt(realRow, 0);
QTextCursor cursor = cell.firstCursorPosition();
cell.setFormat(cellFormat);
cursor.insertText(position);
cell = table->cellAt(realRow, 1);
cursor = cell.firstCursorPosition();
cell.setFormat(cellFormat);
cursor.insertText(lastname);
cell = table->cellAt(realRow, 2);
cursor = cell.firstCursorPosition();
cell.setFormat(cellFormat);
cursor.insertText(firstname);
cell = table->cellAt(realRow, 3);
cursor = cell.firstCursorPosition();
cell.setFormat(cellFormat);
cursor.insertText(time);
}
示例6: hitTestIterated
int KTextDocumentLayout::hitTestIterated(QTextFrame::iterator begin, QTextFrame::iterator end, const QPointF &point, Qt::HitTestAccuracy accuracy) const
{
int position = -1;
QTextFrame::iterator it = begin;
for (it = begin; it != end; ++it) {
QTextBlock block = it.currentBlock();
QTextTable *table = qobject_cast<QTextTable*>(it.currentFrame());
QTextFrame *subFrame = it.currentFrame();
if (table) {
QTextTableCell cell = m_state->hitTestTable(table, point);
if (cell.isValid()) {
position = hitTestIterated(cell.begin(), cell.end(), point,
accuracy);
if (position == -1)
position = cell.lastPosition();
return position;
}
continue;
} else if (subFrame) {
position = hitTestIterated(subFrame->begin(), subFrame->end(), point, accuracy);
if (position != -1)
return position;
continue;
} else {
if (!block.isValid())
continue;
}
// kDebug(32500) <<"hitTest[" << point.x() <<"," << point.y() <<"]";
QTextLayout *layout = block.layout();
if (point.y() > layout->boundingRect().bottom()) {
// just skip this block. position = block.position() + block.length() - 1;
continue;
}
for (int i = 0; i < layout->lineCount(); i++) {
QTextLine line = layout->lineAt(i);
// kDebug(32500) <<" + line[" << line.textStart() <<"]:" << line.y() <<"-" << line.height();
if (point.y() > line.y() + line.height()) {
position = line.textStart() + line.textLength();
continue;
}
if (accuracy == Qt::ExactHit && point.y() < line.y()) // between lines
return -1;
if (accuracy == Qt::ExactHit && // left or right of line
(point.x() < line.x() || point.x() > line.x() + line.width()))
return -1;
if (point.x() > line.width() && layout->textOption().textDirection() == Qt::RightToLeft) {
// totally right of RTL text means the position is the start of the text.
return block.position() + line.textStart();
}
return block.position() + line.xToCursor(point.x());
}
}
return -1;
}
示例7:
void
ChatDialog::printTimeInCell(QTextTable *table, time_t timestamp)
{
QTextCharFormat timeFormat;
timeFormat.setForeground(Qt::gray);
timeFormat.setFontUnderline(true);
timeFormat.setUnderlineColor(Qt::gray);
QTextTableCell timeCell = table->cellAt(0, 1);
timeCell.setFormat(timeFormat);
timeCell.firstCursorPosition().insertText(formatTime(timestamp));
}
示例8: WARNING
void TextEditWidget::sl_InsertColumnAction_Triggered() {
QTextTable* table = textField->textCursor().currentTable();
if (!table) {
WARNING("Wrong button state");
return;
}
QTextTableCell currentCell = table->cellAt(textField->textCursor());
table->insertColumns(currentCell.column() + 1, 1);
QTextTableCell cell = table->cellAt(0, currentCell.column() + 1);
textField->setTextCursor(cell.firstCursorPosition());
}
示例9: rowEnd
/*!
\fn QTextCursor QTextTable::rowStart(const QTextCursor &cursor) const
Returns a cursor pointing to the start of the row that contains the
given \a cursor.
\sa rowEnd()
*/
QTextCursor QTextTable::rowStart(const QTextCursor &c) const
{
Q_D(const QTextTable);
QTextTableCell cell = cellAt(c);
if (!cell.isValid())
return QTextCursor();
int row = cell.row();
QTextDocumentPrivate *p = d->pieceTable;
QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), d->grid[row*d->nCols]);
return QTextCursor(p, it.position());
}
示例10: fillTable
void TextDocumentModel::fillTable(QTextTable *table, QStandardItem *parent)
{
for (int row = 0; row < table->rows(); ++row) {
for (int col = 0; col < table->columns(); ++col) {
QTextTableCell cell = table->cellAt(row, col);
auto *item = new QStandardItem;
item->setText(tr("Cell %1x%2").arg(row).arg(col));
appendRow(parent, item, cell.format());
for (auto it = cell.begin(); it != cell.end(); ++it)
fillFrameIterator(it, item);
}
}
}
示例11: rowStart
/*!
\fn QTextCursor QTextTable::rowEnd(const QTextCursor &cursor) const
Returns a cursor pointing to the end of the row that contains the given
\a cursor.
\sa rowStart()
*/
QTextCursor QTextTable::rowEnd(const QTextCursor &c) const
{
Q_D(const QTextTable);
QTextTableCell cell = cellAt(c);
if (!cell.isValid())
return QTextCursor();
int row = cell.row() + 1;
int fragment = row < d->nRows ? d->grid[row*d->nCols] : d->fragment_end;
QTextDocumentPrivate *p = d->pieceTable;
QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), fragment);
return QTextCursor(p, it.position() - 1);
}
示例12: QRectF
QRectF KoTextLayoutTableArea::selectionBoundingBox(QTextCursor &cursor) const
{
int lastRow = d->endOfArea->row;
if (d->lastRowHasSomething == false) {
--lastRow;
}
if (lastRow < d->startOfArea->row) {
return QRectF(); // empty
}
int firstRow = qMax(d->startOfArea->row, d->headerRows);
QTextTableCell startTableCell = d->table->cellAt(cursor.selectionStart());
QTextTableCell endTableCell = d->table->cellAt(cursor.selectionEnd());
if (startTableCell == endTableCell) {
if (startTableCell.row() < d->startOfArea->row || startTableCell.row() > lastRow) {
return QRectF(); // cell is not in this area
}
KoTextLayoutArea *area = d->cellAreas[startTableCell.row()][startTableCell.column()];
Q_ASSERT(area);
return area->selectionBoundingBox(cursor);
} else {
int selectionRow;
int selectionColumn;
int selectionRowSpan;
int selectionColumnSpan;
cursor.selectedTableCells(&selectionRow, &selectionRowSpan, &selectionColumn, &selectionColumnSpan);
qreal top, bottom;
if (selectionRow < d->headerRows) {
top = d->headerRowPositions[selectionRow] + d->headerOffsetY;
} else {
top = d->rowPositions[qMin(qMax(firstRow, selectionRow), lastRow)];
}
if (selectionRow + selectionRowSpan < d->headerRows) {
bottom = d->headerRowPositions[selectionRow + selectionRowSpan] + d->headerOffsetY;
} else {
bottom = d->rowPositions[d->headerRows] + d->headerOffsetY;
if (selectionRow + selectionRowSpan >= firstRow) {
bottom = d->rowPositions[qMin(selectionRow + selectionRowSpan, lastRow + 1)];
}
}
return QRectF(d->columnPositions[selectionColumn], top,
d->columnPositions[selectionColumn + selectionColumnSpan] - d->columnPositions[selectionColumn], bottom - top);
}
}
示例13: processTableCell
void XmlWriter::processTableCell(QDomElement &parent, const QTextTableCell &cell)
{
QDomElement element = document->createElement("cell");
element.setAttribute("row", cell.row());
element.setAttribute("column", cell.column());
QTextFrame::iterator it;
for (it = cell.begin(); !(it.atEnd()); ++it) {
QTextFrame *childFrame = it.currentFrame();
QTextBlock childBlock = it.currentBlock();
if (childFrame)
processFrame(element, childFrame);
else if (childBlock.isValid())
processBlock(element, childBlock);
}
parent.appendChild(element);
}
示例14: appendMessage
void ChatView::appendMessage(const QString &sender, const QString &message)
{
QTextCursor cellCursor = table->cellAt(table->rows() - 1, 0).lastCursorPosition();
cellCursor.insertText(QDateTime::currentDateTime().toString("[hh:mm]"));
QTextTableCell senderCell = table->cellAt(table->rows() - 1, 1);
QTextCharFormat senderFormat;
if (sender == ownName) {
senderFormat.setFontWeight(QFont::Bold);
senderFormat.setForeground(Qt::red);
} else
senderFormat.setForeground(Qt::blue);
senderCell.setFormat(senderFormat);
cellCursor = senderCell.lastCursorPosition();
cellCursor.insertText(sender);
QTextTableCell messageCell = table->cellAt(table->rows() - 1, 2);
QTextCharFormat messageFormat;
if (sender.isEmpty())
messageFormat.setForeground(Qt::darkGreen);
messageCell.setFormat(messageFormat);
cellCursor = messageCell.lastCursorPosition();
cellCursor.insertText(message);
table->appendRows(1);
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
}
示例15: redo
void InsertTableColumnCommand::redo()
{
KoTableColumnAndRowStyleManager carsManager = KoTableColumnAndRowStyleManager::getManager(m_table);
if (!m_first) {
carsManager.insertColumns(m_column, 1, m_style);
KUndo2Command::redo();
} else {
m_first = false;
QTextTableCell cell = m_table->cellAt(*m_textEditor->cursor());
m_column = cell.column() + (m_right ? 1 : 0);
m_style = carsManager.columnStyle(cell.column());
m_table->insertColumns(m_column, 1);
carsManager.insertColumns(m_column, 1, m_style);
if (m_right && m_column == m_table->columns()-1) {
// Copy the cell style. for the bottomright cell which Qt doesn't
QTextTableCell cell = m_table->cellAt(m_table->rows()-1, m_column - 1);
QTextCharFormat format = cell.format();
cell = m_table->cellAt(m_table->rows()-1, m_column);
cell.setFormat(format);
}
if (m_changeId) {
for (int i=0; i < m_table->rows(); i++) {
QTextTableCellFormat cellFormat = m_table->cellAt(i, m_column).format().toTableCellFormat();
cellFormat.setProperty(KoCharacterStyle::ChangeTrackerId, m_changeId);
m_table->cellAt(i, m_column).setFormat(cellFormat);
}
}
}
}