本文整理汇总了C++中QTextBlock::revision方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextBlock::revision方法的具体用法?C++ QTextBlock::revision怎么用?C++ QTextBlock::revision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextBlock
的用法示例。
在下文中一共展示了QTextBlock::revision方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: formattingRangeStart
int formattingRangeStart(const QTextBlock ¤tBlock,
const QByteArray &buffer,
int documentRevision)
{
QTextBlock prevBlock = currentBlock.previous();
while ((prevBlock.position() > 0 || prevBlock.length() > 0)
&& prevBlock.revision() != documentRevision) {
// Find the first block with not matching revision.
prevBlock = prevBlock.previous();
}
if (prevBlock.revision() == documentRevision)
prevBlock = prevBlock.next();
return Utils::Text::utf8NthLineOffset(prevBlock.document(), buffer, prevBlock.blockNumber() + 1);
}
示例2: updateStateUntil
void CodeFormatter::updateStateUntil(const QTextBlock &endBlock)
{
QStack<State> previousState = initialState();
QTextBlock it = endBlock.document()->firstBlock();
// find the first block that needs recalculation
for (; it.isValid() && it != endBlock; it = it.next()) {
BlockData blockData;
if (!loadBlockData(it, &blockData))
break;
if (blockData.m_blockRevision != it.revision())
break;
if (previousState != blockData.m_beginState)
break;
if (loadLexerState(it) == -1)
break;
previousState = blockData.m_endState;
}
if (it == endBlock)
return;
// update everthing until endBlock
for (; it.isValid() && it != endBlock; it = it.next()) {
recalculateStateAfter(it);
}
// invalidate everything below by marking the state in endBlock as invalid
if (it.isValid()) {
BlockData invalidBlockData;
saveBlockData(&it, invalidBlockData);
}
}
示例3: updateRevisions
void TextDocumentPrivate::updateRevisions()
{
TextDocumentLayout *documentLayout = qobject_cast<TextDocumentLayout*>(m_document.documentLayout());
QTC_ASSERT(documentLayout, return);
int oldLastSaveRevision = documentLayout->lastSaveRevision;
documentLayout->lastSaveRevision = m_document.revision();
if (oldLastSaveRevision != documentLayout->lastSaveRevision) {
for (QTextBlock block = m_document.begin(); block.isValid(); block = block.next()) {
if (block.revision() < 0 || block.revision() != oldLastSaveRevision)
block.setRevision(-documentLayout->lastSaveRevision - 1);
else
block.setRevision(documentLayout->lastSaveRevision);
}
}
}
示例4: saveCurrentState
void CodeFormatter::saveCurrentState(const QTextBlock &block)
{
if (!block.isValid())
return;
BlockData blockData;
blockData.m_blockRevision = block.revision();
blockData.m_beginState = m_beginState;
blockData.m_endState = m_currentState;
blockData.m_indentDepth = m_indentDepth;
QTextBlock saveableBlock(block);
saveBlockData(&saveableBlock, blockData);
}
示例5: saveCurrentState
void GoCodeFormatter::saveCurrentState(const QTextBlock &block)
{
if (!block.isValid())
return;
BlockData blockData;
blockData.revision = block.revision();
blockData.beginState = m_beginState;
blockData.endState = m_currentState;
blockData.indentation = m_indentation;
blockData.padding = m_padding;
QTextBlock saveableBlock(block);
saveBlockData(&saveableBlock, blockData);
}
示例6: updateLineStateChange
void CodeFormatter::updateLineStateChange(const QTextBlock &block)
{
if (!block.isValid())
return;
BlockData blockData;
if (loadBlockData(block, &blockData) && blockData.m_blockRevision == block.revision())
return;
recalculateStateAfter(block);
// invalidate everything below by marking the next block's state as invalid
QTextBlock next = block.next();
if (!next.isValid())
return;
saveBlockData(&next, BlockData());
}
示例7: updateStateUntil
void GoCodeFormatter::updateStateUntil(const QTextBlock &endBlock)
{
QStack<CodeState> previousState = initialState();
QTextBlock it = endBlock.document()->firstBlock();
// find the first block that needs recalculation
while (it.isValid() && it != endBlock) {
BlockData blockData;
if (!loadBlockData(it, &blockData))
break;
if (blockData.revision != it.revision())
break;
if (previousState.isEmpty() || blockData.beginState.isEmpty()
|| previousState != blockData.beginState)
break;
if (TextEditor::TextDocumentLayout::lexerState(endBlock) == -1)
break;
previousState = blockData.endState;
it = it.next();
}
if (it == endBlock) // No need to recalculate
return;
// update everthing until endBlock
while (it.isValid() && it != endBlock) {
recalculateStateAfter(it);
it = it.next();
}
// invalidate everything below by marking the state in endBlock as invalid
if (it.isValid()) {
BlockData invalidBlockData;
saveBlockData(&it, invalidBlockData);
}
}