当前位置: 首页>>代码示例>>C++>>正文


C++ QTextBlock::userState方法代码示例

本文整理汇总了C++中QTextBlock::userState方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextBlock::userState方法的具体用法?C++ QTextBlock::userState怎么用?C++ QTextBlock::userState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTextBlock的用法示例。


在下文中一共展示了QTextBlock::userState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getActiveStatement

QString QueryPanel::getActiveStatement(int block, int col) {

    int from = 0, to = -1;
    State st;

    QTextBlock b = editor->document()->findBlockByNumber(block);
    int scol = col;
    while(b.isValid()) {
        st.opaque = b.userState();
        if(st.s.col != -1 && st.s.col < scol) {
            from = b.position() + st.s.col + 1;
            break;
        }
        scol = INT_MAX;
        b = b.previous();
    }

    b = editor->document()->findBlockByNumber(block);
    scol = col;
    while(b.isValid()) {
        st.opaque = b.userState();
        if(st.s.col != -1 && st.s.col >= scol) {
            to = b.position() + st.s.col;
            break;
        }
        scol = 0;
        b = b.next();
    }

    QString all = editor->document()->toPlainText();
    if(to < 0)
        to = all.length();
    return all.mid(from,to);;
}
开发者ID:ohwgiles,项目名称:sequeljoe,代码行数:34,代码来源:querypanel.cpp

示例2: reformatBlocks

void DevHighlighter::reformatBlocks(int from, int charsRemoved, int charsAdded)
{
	QTextBlock block = doc->findBlock(from);
	if (!block.isValid())
		return;

	QTextBlock endBlock;
	if (charsAdded > charsRemoved || charsAdded == charsRemoved)
		endBlock = doc->findBlock(from + charsAdded);
	else
		endBlock = block;

	bool forceHighlightOfNextBlock = false;

	while (block.isValid() && (!(endBlock < block) || forceHighlightOfNextBlock) )
	{
		const int stateBeforeHighlight = block.userState();

		reformatBlock(block);

		forceHighlightOfNextBlock = (block.userState() != stateBeforeHighlight);

		block = block.next();
	}

	formatChanges.clear();
}
开发者ID:BackupTheBerlios,项目名称:devqt-svn,代码行数:27,代码来源:devhighlighter.cpp

示例3: _q_reformatBlocks

void QSyntaxHighlighterPrivate::_q_reformatBlocks(int from, int charsRemoved, int charsAdded)
{
    Q_UNUSED(charsRemoved);
    rehighlightPending = false;

    QTextBlock block = doc->findBlock(from);
    if (!block.isValid())
        return;

    int endPosition;
    QTextBlock lastBlock = doc->findBlock(from + charsAdded);
    if (lastBlock.isValid())
        endPosition = lastBlock.position() + lastBlock.length();
    else
        endPosition = doc->docHandle()->length();

    bool forceHighlightOfNextBlock = false;

    while (block.isValid() && (block.position() < endPosition || forceHighlightOfNextBlock)) {
        const int stateBeforeHighlight = block.userState();

        reformatBlock(block);

        forceHighlightOfNextBlock = (block.userState() != stateBeforeHighlight);

        block = block.next();
    }

    formatChanges.clear();
}
开发者ID:Fale,项目名称:qtmoko,代码行数:30,代码来源:qsyntaxhighlighter.cpp

示例4: indentBlock

void Indenter::indentBlock(const QTextBlock &block,
                           const QChar &,
                           const TextEditor::TabSettings &settings,
                           int)
{
    int indent;

    QTextBlock previous = block.previous();
    // Previous line ends on comma, ignore everything and follow the indent
    if (previous.text().endsWith(',')) {
        indent = previous.text().indexOf(QRegularExpression("\\S")) / settings.m_indentSize;
    } else {
        // Use the stored indent plus some bizarre heuristics that even myself remember how it works.
        indent = block.userState() >> 20;
        if (indent < 0) {
            while (indent == -1 && previous.isValid()) {
                indent = previous.userState() >> 20;
                previous = previous.previous();
            }
        }

        if (didBlockStart(block) && indent > 0)
            indent--;
    }

    settings.indentLine(block, indent  * settings.m_indentSize);
}
开发者ID:hugopl,项目名称:RubyCreator,代码行数:27,代码来源:RubyIndenter.cpp

示例5: resetHereDocStates

// Reset the header state of a here-doc to 7
// and the state of its body to 6.
void Highlighter::resetHereDocStates (QTextBlock block)
{
    if (block.userState() == hereDocTempState)
    {
        block.setUserState (hereDocHeaderState);
        block = block.next();
        while (block.isValid() && block.userState() != 0)
        {
            block.setUserState (hereDocBodyState);
            block = block.next();
        }
    }
}
开发者ID:frustreated,项目名称:FeatherPad,代码行数:15,代码来源:highlighter-heredoc.cpp

示例6: braceDepth

int BaseTextDocumentLayout::braceDepth(const QTextBlock &block)
{
    int state = block.userState();
    if (state == -1)
        return 0;
    return state >> 8;
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例7: enforceFormatting

void ScriptFormatter::enforceFormatting( QQuickTextDocument* document ) { //The script doesn't quite look right when loaded from a file, so we call this function.
	
	if( document != nullptr && document != NULL ) {
		for( QTextBlock block = document->textDocument()->firstBlock(); block != document->textDocument()->end(); block = block.next() ) {
			setParagraphType( document, ( ScriptFormatter::paragraphType ) block.userState(), block.position() );
		}
	}
}
开发者ID:TheOpenSourceNinja,项目名称:ScriptDragon,代码行数:8,代码来源:scriptformatter.cpp

示例8: setBraceDepth

void BaseTextDocumentLayout::setBraceDepth(QTextBlock &block, int depth)
{
    int state = block.userState();
    if (state == -1)
        state = 0;
    state = state & 0xff;
    block.setUserState((depth << 8) | state);
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例9: appendFragment

int QTextCopyHelper::appendFragment(int pos, int endPos, int objectIndex)
{
    QTextDocumentPrivate::FragmentIterator fragIt = src->find(pos);
    const QTextFragmentData * const frag = fragIt.value();

    Q_ASSERT(objectIndex == -1
             || (frag->size_array[0] == 1 && src->formatCollection()->format(frag->format).objectIndex() != -1));

    int charFormatIndex;
    if (forceCharFormat)
       charFormatIndex = primaryCharFormatIndex;
    else
       charFormatIndex = convertFormatIndex(frag->format, objectIndex);

    const int inFragmentOffset = qMax(0, pos - fragIt.position());
    int charsToCopy = qMin(int(frag->size_array[0] - inFragmentOffset), endPos - pos);

    QTextBlock nextBlock = src->blocksFind(pos + 1);

    int blockIdx = -2;
    if (nextBlock.position() == pos + 1) {
        blockIdx = convertFormatIndex(nextBlock.blockFormat());
    } else if (pos == 0 && insertPos == 0) {
        dst->setBlockFormat(dst->blocksBegin(), dst->blocksBegin(), convertFormat(src->blocksBegin().blockFormat()).toBlockFormat());
        dst->setCharFormat(-1, 1, convertFormat(src->blocksBegin().charFormat()).toCharFormat());
    }

    QString txtToInsert(originalText.constData() + frag->stringPosition + inFragmentOffset, charsToCopy);
    if (txtToInsert.length() == 1
        && (txtToInsert.at(0) == QChar::ParagraphSeparator
            || txtToInsert.at(0) == QTextBeginningOfFrame
            || txtToInsert.at(0) == QTextEndOfFrame
           )
       ) {
        dst->insertBlock(txtToInsert.at(0), insertPos, blockIdx, charFormatIndex);
        ++insertPos;
    } else {
        if (nextBlock.textList()) {
            QTextBlock dstBlock = dst->blocksFind(insertPos);
            if (!dstBlock.textList()) {
                // insert a new text block with the block and char format from the
                // source block to make sure that the following text fragments
                // end up in a list as they should
                int listBlockFormatIndex = convertFormatIndex(nextBlock.blockFormat());
                int listCharFormatIndex = convertFormatIndex(nextBlock.charFormat());
                dst->insertBlock(insertPos, listBlockFormatIndex, listCharFormatIndex);
                ++insertPos;
            }
        }
        dst->insert(insertPos, txtToInsert, charFormatIndex);
        const int userState = nextBlock.userState();
        if (userState != -1)
            dst->blocksFind(insertPos).setUserState(userState);
        insertPos += txtToInsert.length();
    }

    return charsToCopy;
}
开发者ID:MartinOehler,项目名称:LINBOv2,代码行数:58,代码来源:qtextdocumentfragment.cpp

示例10: prepareForAsyncUse

void AssistInterface::prepareForAsyncUse()
{
    m_text = m_textDocument->toPlainText();
    m_userStates.reserve(m_textDocument->blockCount());
    for (QTextBlock block = m_textDocument->firstBlock(); block.isValid(); block = block.next())
        m_userStates.append(block.userState());
    m_textDocument = 0;
    m_isAsync = true;
}
开发者ID:DuinoDu,项目名称:qt-creator,代码行数:9,代码来源:assistinterface.cpp

示例11: pcChanged

void TextEditor::pcChanged(ParseNode *pc, bool justRolledBack) {
   ParseNode *old = m_pc;
//   cerr << "\tpcChanged id:" << QThread::currentThreadId() << "\n";
   
   if (old == pc)
      return;
   
   m_pc = pc;
//   if (m_program->getStatus() != PAUSED)
//      return;
   
   if (old != NULL) {
      QTextBlock *b = old->getTextBlock();
      int state = b->userState();
      if (state > 0)
         b->setUserState(state & ~B_CURRENT_PC);
   }

   if (m_pc != NULL) {
      QTextBlock *b = m_pc->getTextBlock();

//      cerr << "b: " << b->text().toStdString() << endl;
      int state = b->userState();
      if (state < 0)
         b->setUserState(B_CURRENT_PC);
      else b->setUserState(state | B_CURRENT_PC);
      
      if (!justRolledBack && b != NULL) {
         QTextCursor c = textCursor();

         c.setPosition(b->position());
         setTextCursor(c);
         ensureCursorVisible();
      }
   }
   
   m_parent->updateLineNumbers(0);
   // the 2 can be changed according to preferences later
   // just be sure to also change the fading factors in paintEvent.
   m_program->getLastXInstructions(Options::noPreviousXInstructions(), m_lastInstructions);
   viewport()->update();
}
开发者ID:endrift,项目名称:mipscope,代码行数:42,代码来源:TextEditor.cpp

示例12: previousBlockState

int ExpressionUnderCursor::previousBlockState(const QTextBlock &block)
{
    const QTextBlock prevBlock = block.previous();
    if (prevBlock.isValid()) {
        int state = prevBlock.userState();

        if (state != -1)
            return state;
    }
    return 0;
}
开发者ID:ramons03,项目名称:qt-creator,代码行数:11,代码来源:ExpressionUnderCursor.cpp

示例13: bottomLineStartsInMultilineComment

/*
    Returns true if the start of the bottom line of yyProgram (and
    potentially the whole line) is part of a C-style comment;
    otherwise returns false.
*/
bool LineInfo::bottomLineStartsInMultilineComment()
{
    QTextBlock currentLine = yyProgram.lastBlock().previous();
    QTextBlock previousLine = currentLine.previous();

    int startState = qMax(0, previousLine.userState()) & 0xff;
    if (startState > 0)
        return true;

    return false;
}
开发者ID:AltarBeastiful,项目名称:qt-creator,代码行数:16,代码来源:qmljslineinfo.cpp

示例14: parse

/**
 * Parses a text document and builds the navigation tree for it
 */
void NavigationWidget::parse(QTextDocument *document) {
    const QSignalBlocker blocker(this);
    Q_UNUSED(blocker);

    setDocument(document);
    clear();
    _lastHeadingItemList.clear();

    for (int i = 0; i < document->blockCount(); i++) {
        QTextBlock block = document->findBlockByNumber(i);
        int elementType = block.userState();

        // ignore all non headline types
        if ((elementType < pmh_H1) || (elementType > pmh_H6)) {
            continue;
        }

        QString text = block.text();

        text.remove(QRegularExpression("^#+"))
                .remove(QRegularExpression("#+$"))
                .remove(QRegularExpression("^\\s+"))
                .remove(QRegularExpression("^=+$"))
                .remove(QRegularExpression("^-+$"));

        if (text.isEmpty()) {
            continue;
        }

        QTreeWidgetItem *item = new QTreeWidgetItem();
        item->setText(0, text);
        item->setData(0, Qt::UserRole, block.position());
        item->setToolTip(0, tr("headline %1").arg(elementType - pmh_H1 + 1));

        // attempt to find a suitable parent item for the element type
        QTreeWidgetItem *lastHigherItem = findSuitableParentItem(elementType);

        if (lastHigherItem == NULL) {
            // if there wasn't a last higher level item then add the current
            // item to the top level
            addTopLevelItem(item);
        } else {
            // if there was a last higher level item then add the current
            // item as child of that item
            lastHigherItem->addChild(item);
        }

        _lastHeadingItemList[elementType] = item;
    }

    expandAll();
}
开发者ID:XavierCLL,项目名称:QOwnNotes,代码行数:55,代码来源:navigationwidget.cpp

示例15: previousBlockState

int BackwardsScanner::previousBlockState(const QTextBlock &block)
{
    const QTextBlock prevBlock = block.previous();

    if (prevBlock.isValid()) {
        int state = prevBlock.userState();

        if (state != -1)
            return state;
    }

    return 0;
}
开发者ID:Gardenya,项目名称:qtcreator,代码行数:13,代码来源:BackwardsScanner.cpp


注:本文中的QTextBlock::userState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。