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


C++ QTextCursor::endEditBlock方法代码示例

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


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

示例1: slotPasteAsQuotation

void ComposerTextEdit::slotPasteAsQuotation()
{
    QString text = qApp->clipboard()->text();
    if (text.isEmpty())
        return;

    QStringList lines = text.split(QLatin1Char('\n'));
    for (QStringList::iterator it = lines.begin(); it != lines.end(); ++it) {
        it->remove(QLatin1Char('\r'));
        if (it->startsWith(QLatin1Char('>'))) {
            *it = QLatin1Char('>') + *it;
        } else {
            *it = QLatin1String("> ") + *it;
        }
    }
    text = lines.join(QStringLiteral("\n"));
    if (!text.endsWith(QLatin1Char('\n'))) {
        text += QLatin1Char('\n');
    }

    QTextCursor cursor = textCursor();
    cursor.beginEditBlock();
    cursor.insertBlock();
    cursor.insertText(text);
    cursor.endEditBlock();
    setTextCursor(cursor);
}
开发者ID:ChristopherCotnoir,项目名称:trojita,代码行数:27,代码来源:ComposerTextEdit.cpp

示例2: updatePreview

void CppCodeStylePreferencesWidget::updatePreview()
{
    CppCodeStylePreferences *cppCodeStylePreferences = m_preferences
            ? m_preferences
            : CppToolsSettings::instance()->cppCodeStyle();
    const CppCodeStyleSettings ccss = cppCodeStylePreferences->currentCodeStyleSettings();
    const TabSettings ts = cppCodeStylePreferences->currentTabSettings();
    QtStyleCodeFormatter formatter(ts, ccss);
    foreach (SnippetEditorWidget *preview, m_previews) {
        preview->textDocument()->setTabSettings(ts);
        preview->setCodeStyle(cppCodeStylePreferences);

        QTextDocument *doc = preview->document();
        formatter.invalidateCache(doc);

        QTextBlock block = doc->firstBlock();
        QTextCursor tc = preview->textCursor();
        tc.beginEditBlock();
        while (block.isValid()) {
            preview->textDocument()->indenter()->indentBlock(doc, block, QChar::Null, ts);

            block = block.next();
        }
        applyRefactorings(doc, preview, ccss);
        tc.endEditBlock();
    }
开发者ID:qtproject,项目名称:qt-creator,代码行数:26,代码来源:cppcodestylesettingspage.cpp

示例3: capitalize

bool Highlighter::capitalize( const QTextBlock &block,QTextCursor cursor ){

    QString text=block.text();
    QColor color;

    int i=0,pos=cursor.position();

    cursor.beginEditBlock();

    for(;;){
        QString t=parseToke( text,color );
        if( t.isEmpty() ) break;

        QString kw=keyWords().value( t.toLower() );

        if( !kw.isEmpty() && t!=kw ){
            int i0=block.position()+i;
            int i1=i0+t.length();
            cursor.setPosition( i0 );
            cursor.setPosition( i1,QTextCursor::KeepAnchor );
            cursor.insertText( kw );
        }

        i+=t.length();
    }

    cursor.endEditBlock();

    cursor.setPosition( pos );

    return true;
}
开发者ID:bruZard,项目名称:amigamonkey,代码行数:32,代码来源:codeeditor.cpp

示例4: autoBackspace

bool AutoCompleter::autoBackspace(QTextCursor &cursor)
{
    m_allowSkippingOfBlockEnd = false;

    if (!m_autoParenthesesEnabled)
        return false;

    int pos = cursor.position();
    if (pos == 0)
        return false;
    QTextCursor c = cursor;
    c.setPosition(pos - 1);

    QTextDocument *doc = cursor.document();
    const QChar lookAhead = doc->characterAt(pos);
    const QChar lookBehind = doc->characterAt(pos - 1);
    const QChar lookFurtherBehind = doc->characterAt(pos - 2);

    const QChar character = lookBehind;
    if (character == QLatin1Char('(') || character == QLatin1Char('[')) {
        QTextCursor tmp = cursor;
        TextEditor::TextBlockUserData::findPreviousBlockOpenParenthesis(&tmp);
        int blockStart = tmp.isNull() ? 0 : tmp.position();
        tmp = cursor;
        TextEditor::TextBlockUserData::findNextBlockClosingParenthesis(&tmp);
        int blockEnd = tmp.isNull() ? (cursor.document()->characterCount()-1) : tmp.position();
        QChar openChar = character;
        QChar closeChar = (character == QLatin1Char('(')) ? QLatin1Char(')') : QLatin1Char(']');

        int errors = 0;
        int stillopen = 0;
        countBrackets(cursor, blockStart, blockEnd, openChar, closeChar, &errors, &stillopen);
        int errorsBeforeDeletion = errors + stillopen;
        errors = 0;
        stillopen = 0;
        countBrackets(cursor, blockStart, pos - 1, openChar, closeChar, &errors, &stillopen);
        countBrackets(cursor, pos, blockEnd, openChar, closeChar, &errors, &stillopen);
        int errorsAfterDeletion = errors + stillopen;

        if (errorsAfterDeletion < errorsBeforeDeletion)
            return false; // insertion fixes parentheses or bracket errors, do not auto complete
    }

    // ### this code needs to be generalized
    if    ((lookBehind == QLatin1Char('(') && lookAhead == QLatin1Char(')'))
        || (lookBehind == QLatin1Char('[') && lookAhead == QLatin1Char(']'))
        || (lookBehind == QLatin1Char('"') && lookAhead == QLatin1Char('"')
            && lookFurtherBehind != QLatin1Char('\\'))
        || (lookBehind == QLatin1Char('\'') && lookAhead == QLatin1Char('\'')
            && lookFurtherBehind != QLatin1Char('\\'))) {
        if (! isInComment(c)) {
            cursor.beginEditBlock();
            cursor.deleteChar();
            cursor.deletePreviousChar();
            cursor.endEditBlock();
            return true;
        }
    }
    return false;
}
开发者ID:ProDataLab,项目名称:qt-creator,代码行数:60,代码来源:autocompleter.cpp

示例5: setStyle

//段落标号、编号
void MyChild::setStyle(int style)
{
    QTextCursor cursor = this->textCursor();

    if (style != 0) {
        QTextListFormat::Style stylename = QTextListFormat::ListDisc;

        switch (style) {
            default:
            case 1:
                stylename = QTextListFormat::ListDisc;
                break;
            case 2:
                stylename = QTextListFormat::ListCircle;
                break;
            case 3:
                stylename = QTextListFormat::ListSquare;
                break;
            case 4:
                stylename = QTextListFormat::ListDecimal;
                break;
            case 5:
                stylename = QTextListFormat::ListLowerAlpha;
                break;
            case 6:
                stylename = QTextListFormat::ListUpperAlpha;
                break;
            case 7:
                stylename = QTextListFormat::ListLowerRoman;
                break;
            case 8:
                stylename = QTextListFormat::ListUpperRoman;
                break;
        }

        cursor.beginEditBlock();

        QTextBlockFormat blockFmt = cursor.blockFormat();

        QTextListFormat listFmt;

        if (cursor.currentList()) {
            listFmt = cursor.currentList()->format();
        } else {
            listFmt.setIndent(blockFmt.indent() + 1);
            blockFmt.setIndent(0);
            cursor.setBlockFormat(blockFmt);
        }

        listFmt.setStyle(stylename);

        cursor.createList(listFmt);

        cursor.endEditBlock();
    } else {
        QTextBlockFormat bfmt;
        bfmt.setObjectIndex(-1);
        cursor.mergeBlockFormat(bfmt);
    }
}
开发者ID:Pengfei-Gao,项目名称:develop-reference-data,代码行数:61,代码来源:mychild.cpp

示例6: doTrackBar

void ChatView::doTrackBar()
{
	// save position, because our manipulations could change it
	int scrollbarValue = verticalScrollBar()->value();

	QTextCursor cursor = textCursor();
	cursor.beginEditBlock();
	PsiRichText::Selection selection = PsiRichText::saveSelection(this, cursor);

	//removeTrackBar(cursor);
	if (oldTrackBarPosition) {
		cursor.setPosition(oldTrackBarPosition, QTextCursor::KeepAnchor);
		QTextBlockFormat blockFormat = cursor.blockFormat();
		blockFormat.clearProperty(QTextFormat::BlockTrailingHorizontalRulerWidth);
		cursor.clearSelection();
		cursor.setBlockFormat(blockFormat);
	}

	//addTrackBar(cursor);
	cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
	oldTrackBarPosition = cursor.position();
	QTextBlockFormat blockFormat = cursor.blockFormat();
	blockFormat.setProperty(QTextFormat::BlockTrailingHorizontalRulerWidth, QVariant(true));
	cursor.clearSelection();
	cursor.setBlockFormat(blockFormat);

	PsiRichText::restoreSelection(this, cursor, selection);
	cursor.endEditBlock();
	setTextCursor(cursor);

	verticalScrollBar()->setValue(scrollbarValue);
}
开发者ID:ackbarr,项目名称:psi,代码行数:32,代码来源:chatview_te.cpp

示例7: removeMark

void LrcEditor::removeMark()
{
	QTextCursor cursor = textCursor();
	QString strText = cursor.block().text();

	if (strText.isEmpty())
		return ;

	const QRegExp exp("^\\[\\d+:\\d+\\.\\d+\\]");

	int index = exp.indexIn(strText);
	// no time tags
	if (index == -1)
		return ;

	strText.remove(index, exp.matchedLength());

	cursor.beginEditBlock();

	cursor.select(QTextCursor::LineUnderCursor);
	cursor.removeSelectedText();
	cursor.insertText(strText);

	cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor);

	cursor.endEditBlock();

	setTextCursor(cursor);
}
开发者ID:timxx,项目名称:lyricsx,代码行数:29,代码来源:lrceditor.cpp

示例8: indent

void CppQtStyleIndenter::indent(QTextDocument *doc,
                                const QTextCursor &cursor,
                                const QChar &typedChar,
                                const TextEditor::TabSettings &tabSettings)
{
    if (cursor.hasSelection()) {
        QTextBlock block = doc->findBlock(cursor.selectionStart());
        const QTextBlock end = doc->findBlock(cursor.selectionEnd()).next();

        CppTools::QtStyleCodeFormatter codeFormatter(tabSettings, codeStyleSettings());
        codeFormatter.updateStateUntil(block);

        QTextCursor tc = cursor;
        tc.beginEditBlock();
        do {
            int indent;
            int padding;
            codeFormatter.indentFor(block, &indent, &padding);
            tabSettings.indentLine(block, indent + padding, padding);
            codeFormatter.updateLineStateChange(block);
            block = block.next();
        } while (block.isValid() && block != end);
        tc.endEditBlock();
    } else {
        indentBlock(doc, cursor.block(), typedChar, tabSettings);
    }
}
开发者ID:CNOT,项目名称:julia-studio,代码行数:27,代码来源:cppqtstyleindenter.cpp

示例9: insertCssProperty

void StyleSheetEditorDialog::insertCssProperty(const QString &name, const QString &value)
{
    if (!value.isEmpty()) {
        QTextCursor cursor = m_editor->textCursor();
        if (!name.isEmpty()) {
            cursor.beginEditBlock();
            cursor.removeSelectedText();
            cursor.movePosition(QTextCursor::EndOfLine);

            // Simple check to see if we're in a selector scope
            const QTextDocument *doc = m_editor->document();
            const QTextCursor closing = doc->find(QStringLiteral("}"), cursor, QTextDocument::FindBackward);
            const QTextCursor opening = doc->find(QStringLiteral("{"), cursor, QTextDocument::FindBackward);
            const bool inSelector = !opening.isNull() && (closing.isNull() ||
                                    closing.position() < opening.position());
            QString insertion;
            if (m_editor->textCursor().block().length() != 1)
                insertion += QLatin1Char('\n');
            if (inSelector)
                insertion += QLatin1Char('\t');
            insertion += name;
            insertion += QStringLiteral(": ");
            insertion += value;
            insertion += QLatin1Char(';');
            cursor.insertText(insertion);
            cursor.endEditBlock();
        } else {
            cursor.insertText(value);
        }
    }
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:31,代码来源:stylesheeteditor.cpp

示例10: delete_end_of_word

/**
 * Delete all chars from current cursor position to end of word
 */
void HaiQTextEdit::delete_end_of_word() {
    QTextCursor cursor = textCursor();
    cursor.beginEditBlock();
    cursor.clearSelection();
    cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
    cursor.removeSelectedText();
    cursor.endEditBlock();
}
开发者ID:magland,项目名称:sequencetree5,代码行数:11,代码来源:haiqtextedit.cpp

示例11: moveLineUpDown

void GenericCodeEditor::moveLineUpDown(bool up)
{
    // directly taken from qtcreator
    // Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
    // GNU Lesser General Public License
    QTextCursor cursor = textCursor();
    QTextCursor move = cursor;

    move.setVisualNavigation(false); // this opens folded items instead of destroying them

    move.beginEditBlock();

    bool hasSelection = cursor.hasSelection();

    if (cursor.hasSelection()) {
        move.setPosition(cursor.selectionStart());
        move.movePosition(QTextCursor::StartOfBlock);
        move.setPosition(cursor.selectionEnd(), QTextCursor::KeepAnchor);
        move.movePosition(move.atBlockStart() ? QTextCursor::Left: QTextCursor::EndOfBlock,
                          QTextCursor::KeepAnchor);
    } else {
        move.movePosition(QTextCursor::StartOfBlock);
        move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
    }
    QString text = move.selectedText();

    move.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
    move.removeSelectedText();

    if (up) {
        move.movePosition(QTextCursor::PreviousBlock);
        move.insertBlock();
        move.movePosition(QTextCursor::Left);
    } else {
        move.movePosition(QTextCursor::EndOfBlock);
        if (move.atBlockStart()) { // empty block
            move.movePosition(QTextCursor::NextBlock);
            move.insertBlock();
            move.movePosition(QTextCursor::Left);
        } else {
            move.insertBlock();
        }
    }

    int start = move.position();
    move.clearSelection();
    move.insertText(text);
    int end = move.position();

    if (hasSelection) {
        move.setPosition(start);
        move.setPosition(end, QTextCursor::KeepAnchor);
    }

    move.endEditBlock();

    setTextCursor(move);
}
开发者ID:ARTisERR0R,项目名称:supercollider,代码行数:58,代码来源:editor.cpp

示例12: rehighlight

 inline void rehighlight(QTextCursor &cursor, QTextCursor::MoveOperation operation) {
     inReformatBlocks = true;
     cursor.beginEditBlock();
     int from = cursor.position();
     cursor.movePosition(operation);
     reformatBlocks(from, 0, cursor.position() - from);
     cursor.endEditBlock();
     inReformatBlocks = false;
 }
开发者ID:wpbest,项目名称:copperspice,代码行数:9,代码来源:qsyntaxhighlighter.cpp

示例13: toggleCommentSingleLine

void ScCodeEditor::toggleCommentSingleLine()
{
    QTextCursor cursor = textCursor();
    cursor.beginEditBlock();

    toggleCommentSingleLine( cursor );

    cursor.endEditBlock();
}
开发者ID:vanhuman,项目名称:supercollider-rvh,代码行数:9,代码来源:sc_editor.cpp

示例14: mouseDoubleClickEvent

void PostWindow::mouseDoubleClickEvent(QMouseEvent *e)
{
    QTextCursor cursor = textCursor();
    cursor.beginEditBlock();

    QPlainTextEdit::mouseDoubleClickEvent(e);
    extendSelectionForEnvVar(this, textCursor());

    cursor.endEditBlock();
}
开发者ID:mblewett,项目名称:supercollider,代码行数:10,代码来源:post_window.cpp

示例15: changeFormatType

void CreateBlogMsg::changeFormatType(int styleIndex )
{
    ui.msgEdit->setFocus( Qt::OtherFocusReason );

    QTextCursor cursor = ui.msgEdit->textCursor();
    //QTextBlockFormat bformat = cursor.blockFormat();
    QTextBlockFormat bformat;
    QTextCharFormat cformat;

    switch (styleIndex) {
         default:
            case 0:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 0 ) );
            cformat.setFontWeight( QFont::Normal );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 0 ) );
            break;
        case 1:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 1 ) );
            cformat.setFontWeight( QFont::Bold );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 3 ) );
            break;
        case 2:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 2 ) );
            cformat.setFontWeight( QFont::Bold );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 2 ) );
            break;
        case 3:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 3 ) );
            cformat.setFontWeight( QFont::Bold );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 1 ) );
            break;
        case 4:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 4 ) );
            cformat.setFontWeight( QFont::Bold );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 0 ) );
            break;
        case 5:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 5 ) );
            cformat.setFontWeight( QFont::Bold );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( -1 ) );
            break;
        case 6:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 6 ) );
            cformat.setFontWeight( QFont::Bold );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( -2 ) );
            break;
    }
    //cformat.clearProperty( TextFormat::HasCodeStyle );

    cursor.beginEditBlock();
    cursor.mergeBlockFormat( bformat );
    cursor.select( QTextCursor::BlockUnderCursor );
    cursor.mergeCharFormat( cformat );
    cursor.endEditBlock();
}
开发者ID:boukeversteegh,项目名称:retroshare,代码行数:55,代码来源:CreateBlogMsg.cpp


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