本文整理汇总了C++中qtextframe::iterator::atEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::atEnd方法的具体用法?C++ iterator::atEnd怎么用?C++ iterator::atEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtextframe::iterator
的用法示例。
在下文中一共展示了iterator::atEnd方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rowCount
int TextDocumentStructureModel::rowCount(const QModelIndex &index) const
{
kDebug(32500) << "-------------------------- index:"<<index<<m_textDocument;
if (! m_textDocument) {
return 0;
}
if (! index.isValid()) {
// one root frame
return 1;
}
Q_ASSERT(index.internalId() < uint(m_nodeDataTable.count()));
const NodeData &nodeData = m_nodeDataTable.at(index.internalId());
if (nodeData.type == NodeData::Frame) {
QTextFrame* frame = nodeData.frame;
// count frames and blocks
int count = 0;
for (QTextFrame::iterator iterator = frame->begin(); !iterator.atEnd(); ++iterator) {
++count;
}
return count;
}
// should be a block then, no childs for now
return 0;
}
示例2: processFrame
void XmlWriter::processFrame(QDomElement &parent, QTextFrame *frame)
{
QDomElement frameElement = document->createElement("frame");
frameElement.setAttribute("begin", frame->firstPosition());
frameElement.setAttribute("end", frame->lastPosition());
parent.appendChild(frameElement);
//! [0]
QTextFrame::iterator it;
for (it = frame->begin(); !(it.atEnd()); ++it) {
QTextFrame *childFrame = it.currentFrame();
QTextBlock childBlock = it.currentBlock();
if (childFrame) {
QTextTable *childTable = qobject_cast<QTextTable*>(childFrame);
if (childTable)
processTable(frameElement, childTable);
else
processFrame(frameElement, childFrame);
} else if (childBlock.isValid())
//! [0] //! [1]
processBlock(frameElement, childBlock);
}
//! [1]
}
示例3: writeFrame
void QTextOdfWriter::writeFrame(QXmlStreamWriter &writer, const QTextFrame *frame)
{
Q_ASSERT(frame);
const QTextTable *table = qobject_cast<const QTextTable*> (frame);
if (table) { // Start a table.
writer.writeStartElement(tableNS, QString::fromLatin1("table"));
writer.writeEmptyElement(tableNS, QString::fromLatin1("table-column"));
writer.writeAttribute(tableNS, QString::fromLatin1("number-columns-repeated"), QString::number(table->columns()));
} else if (frame->document() && frame->document()->rootFrame() != frame) { // start a section
writer.writeStartElement(textNS, QString::fromLatin1("section"));
}
QTextFrame::iterator iterator = frame->begin();
QTextFrame *child = 0;
int tableRow = -1;
while (! iterator.atEnd()) {
if (iterator.currentFrame() && child != iterator.currentFrame())
writeFrame(writer, iterator.currentFrame());
else { // no frame, its a block
QTextBlock block = iterator.currentBlock();
if (table) {
QTextTableCell cell = table->cellAt(block.position());
if (tableRow < cell.row()) {
if (tableRow >= 0)
writer.writeEndElement(); // close table row
tableRow = cell.row();
writer.writeStartElement(tableNS, QString::fromLatin1("table-row"));
}
writer.writeStartElement(tableNS, QString::fromLatin1("table-cell"));
if (cell.columnSpan() > 1)
writer.writeAttribute(tableNS, QString::fromLatin1("number-columns-spanned"), QString::number(cell.columnSpan()));
if (cell.rowSpan() > 1)
writer.writeAttribute(tableNS, QString::fromLatin1("number-rows-spanned"), QString::number(cell.rowSpan()));
if (cell.format().isTableCellFormat()) {
writer.writeAttribute(tableNS, QString::fromLatin1("style-name"), QString::fromLatin1("T%1").arg(cell.tableCellFormatIndex()));
}
}
writeBlock(writer, block);
if (table)
writer.writeEndElement(); // table-cell
}
child = iterator.currentFrame();
++iterator;
}
if (tableRow >= 0)
writer.writeEndElement(); // close table-row
if (table || (frame->document() && frame->document()->rootFrame() != frame))
writer.writeEndElement(); // close table or section element
}
示例4: addTextDocument
void QSGTextNode::addTextDocument(const QPointF &position, QTextDocument *textDocument, const QColor &color,
QSGText::TextStyle style, const QColor &styleColor)
{
Q_UNUSED(position)
QTextFrame *textFrame = textDocument->rootFrame();
QPointF p = textDocument->documentLayout()->frameBoundingRect(textFrame).topLeft();
QTextFrame::iterator it = textFrame->begin();
while (!it.atEnd()) {
addTextBlock(p, textDocument, it.currentBlock(), color, style, styleColor);
++it;
}
}
示例5: showTextFrame
// 遍历框架
void MainWindow::showTextFrame()
{
QTextDocument *document = ui->textEdit->document();
QTextFrame *frame = document->rootFrame();
// 建立QTextFrame类的迭代器
QTextFrame::iterator it;
for (it = frame->begin(); !(it.atEnd()); ++it) {
// 获取当前框架的指针
QTextFrame *childFrame = it.currentFrame();
// 获取当前文本块
QTextBlock childBlock = it.currentBlock();
if (childFrame)
qDebug() << "frame";
else if (childBlock.isValid())
qDebug() << "block:" << childBlock.text();
}
}
示例6: parent
QModelIndex TextDocumentStructureModel::parent(const QModelIndex &index) const
{
kDebug(32500) << "-------------------------- index:"<<index<<m_textDocument;
if (! m_textDocument || ! index.isValid()) {
return QModelIndex();
}
Q_ASSERT(index.internalId() < uint(m_nodeDataTable.count()));
const NodeData &nodeData = m_nodeDataTable.at(index.internalId());
QTextFrame* parentFrame;
if (nodeData.type == NodeData::Frame) {
parentFrame = nodeData.frame->parentFrame();
} else {
QTextBlock block = m_textDocument->findBlockByNumber(nodeData.blockNumber);
Q_ASSERT(block.isValid());
// QTextBlock's API has no option to query the parentframe, so get it via a cursor
QTextCursor cursor(block);
parentFrame = cursor.currentFrame();
}
if (! parentFrame) {
return QModelIndex();
}
QTextFrame* grandParentFrame = parentFrame->parentFrame();
// parent is root frame?
if (! grandParentFrame) {
Q_ASSERT(parentFrame == m_textDocument->rootFrame());
return createIndex(0, 0, static_cast<quintptr>(0));
}
// find position of parentFrame
bool posFound = false;
int row = 0;
for (QTextFrame::iterator iterator = grandParentFrame->begin(); !iterator.atEnd(); ++iterator) {
if (iterator.currentFrame() == parentFrame) {
posFound = true;
break;
}
++row;
}
Q_ASSERT(posFound);Q_UNUSED(posFound);
return createIndex(row, 0, frameIndex(parentFrame));
}
示例7: 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);
}
示例8: index
QModelIndex TextDocumentStructureModel::index(int row, int column, const QModelIndex &parentIndex) const
{
kDebug(32500) << "-------------------------- row:" << row << "column:"<<column << "index:"<<parentIndex<<m_textDocument;
if (! m_textDocument) {
return QModelIndex();
}
if (! parentIndex.isValid()) {
return createIndex(row, column, static_cast<quintptr>(0));
}
Q_ASSERT(parentIndex.internalId() < uint(m_nodeDataTable.count()));
const NodeData &nodeData = m_nodeDataTable.at(parentIndex.internalId());
// can be only frame for now
Q_ASSERT(nodeData.type == NodeData::Frame);
QTextFrame* parentFrame = nodeData.frame;
int index = -1;
int count = 0;
for (QTextFrame::iterator iterator = parentFrame->begin(); !iterator.atEnd(); ++iterator) {
if (count == row) {
QTextFrame *frame = iterator.currentFrame();
if (frame) {
index = frameIndex(frame);
break;
} else {
QTextBlock block = iterator.currentBlock();
if (block.isValid()) {
index = blockIndex(block);
break;
}
}
}
++count;
}
Q_ASSERT(index != -1);
return createIndex(row, column, index);
}
示例9: showTable
void MainWindow::showTable()
{
QTextCursor cursor = editor->textCursor();
QTextTable *table = cursor.currentTable();
if (!table)
return;
QTableWidget *tableWidget = new QTableWidget(table->rows(), table->columns());
//! [9]
for (int row = 0; row < table->rows(); ++row) {
for (int column = 0; column < table->columns(); ++column) {
QTextTableCell tableCell = table->cellAt(row, column);
//! [9]
QTextFrame::iterator it;
QString text;
for (it = tableCell.begin(); !(it.atEnd()); ++it) {
QTextBlock childBlock = it.currentBlock();
if (childBlock.isValid())
text += childBlock.text();
}
QTableWidgetItem *newItem = new QTableWidgetItem(text);
tableWidget->setItem(row, column, newItem);
/*
//! [10]
processTableCell(tableCell);
//! [10]
*/
//! [11]
}
//! [11] //! [12]
}
//! [12]
tableWidget->setWindowTitle(tr("Table Contents"));
tableWidget->show();
}
示例10: processFrame
QString TextDocumentSerializer::processFrame(QTextFrame *frame)
{
QString text;
QTextFrame::iterator it = frame->begin();
while(!it.atEnd()){
QTextFrame *childFrame = it.currentFrame();
QTextBlock childBlock = it.currentBlock();
if(childFrame)
text += processFrame(childFrame);
else if(childBlock.isValid()){
if(childBlock.textList())
text = removeTrailingLineBreaks(text);
text += processBlock(childBlock, it);
}
++it;
}
text = removeTrailingLineBreaks(text);
return text;
}
示例11: showList
void MainWindow::showList()
{
QTextCursor cursor = editor->textCursor();
QTextFrame *frame = cursor.currentFrame();
if (!frame)
return;
QTreeWidget *treeWidget = new QTreeWidget;
treeWidget->setColumnCount(1);
QStringList headerLabels;
headerLabels << tr("Lists");
treeWidget->setHeaderLabels(headerLabels);
QTreeWidgetItem *parentItem = 0;
QTreeWidgetItem *item;
QTreeWidgetItem *lastItem = 0;
parentItems.clear();
previousItems.clear();
//! [3]
QTextFrame::iterator it;
for (it = frame->begin(); !(it.atEnd()); ++it) {
QTextBlock block = it.currentBlock();
if (block.isValid()) {
QTextList *list = block.textList();
if (list) {
int index = list->itemNumber(block);
//! [3]
if (index == 0) {
parentItems.append(parentItem);
previousItems.append(lastItem);
listStructures.append(list);
parentItem = lastItem;
lastItem = 0;
if (parentItem != 0)
item = new QTreeWidgetItem(parentItem, lastItem);
else
item = new QTreeWidgetItem(treeWidget, lastItem);
} else {
while (parentItem != 0 && listStructures.last() != list) {
listStructures.pop_back();
parentItem = parentItems.takeLast();
lastItem = previousItems.takeLast();
}
if (parentItem != 0)
item = new QTreeWidgetItem(parentItem, lastItem);
else
item = new QTreeWidgetItem(treeWidget, lastItem);
}
item->setText(0, block.text());
lastItem = item;
/*
//! [4]
processListItem(list, index);
//! [4]
*/
//! [5]
}
//! [5] //! [6]
}
//! [6] //! [7]
}
//! [7]
treeWidget->setWindowTitle(tr("List Contents"));
treeWidget->show();
}
示例12: updateNodes
void QQuickTextNode::updateNodes()
{
return;
deleteContent();
if (m_text.isEmpty())
return;
if (m_usePixmapCache) {
// ### gunnar: port properly
// QPixmap pixmap = generatedPixmap();
// if (pixmap.isNull())
// return;
// QSGImageNode *pixmapNode = m_context->createImageNode();
// pixmapNode->setRect(pixmap.rect());
// pixmapNode->setSourceRect(pixmap.rect());
// pixmapNode->setOpacity(m_opacity);
// pixmapNode->setClampToEdge(true);
// pixmapNode->setLinearFiltering(m_linearFiltering);
// appendChildNode(pixmapNode);
} else {
if (m_text.isEmpty())
return;
// Implement styling by drawing text several times at slight shifts. shiftForStyle
// contains the sequence of shifted positions at which to draw the text. All except
// the last will be drawn with styleColor.
QList<QPointF> shiftForStyle;
switch (m_textStyle) {
case OutlineTextStyle:
// ### Should be made faster by implementing outline material
shiftForStyle << QPointF(-1, 0);
shiftForStyle << QPointF(0, -1);
shiftForStyle << QPointF(1, 0);
shiftForStyle << QPointF(0, 1);
break;
case SunkenTextStyle:
shiftForStyle << QPointF(0, -1);
break;
case RaisedTextStyle:
shiftForStyle << QPointF(0, 1);
break;
default:
break;
}
shiftForStyle << QPointF(0, 0); // Regular position
while (!shiftForStyle.isEmpty()) {
QPointF shift = shiftForStyle.takeFirst();
// Use styleColor for all but last shift
if (m_richText) {
QColor overrideColor = shiftForStyle.isEmpty() ? QColor() : m_styleColor;
QTextFrame *textFrame = m_textDocument->rootFrame();
QPointF p = m_textDocument->documentLayout()->frameBoundingRect(textFrame).topLeft();
QTextFrame::iterator it = textFrame->begin();
while (!it.atEnd()) {
addTextBlock(shift + p, it.currentBlock(), overrideColor);
++it;
}
} else {
addTextLayout(shift, m_textLayout, shiftForStyle.isEmpty()
? m_color
: m_styleColor);
}
}
}
}