Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

void QSyntaxHighlighter::setDocument ( QTextDocument doc  ) 

Installs the syntax highlighter on the given QTextDocument doc. A QSyntaxHighlighter can only be used with one document at a time.

Definition at line 368 of file qsyntaxhighlighter.cpp.

References QTextCursor::beginEditBlock(), QObject::connect(), QObject::disconnect(), QTextCursor::endEditBlock(), and QTimer::singleShot.

Referenced by QSyntaxHighlighter(), and ~QSyntaxHighlighter().

{
    Q_D(QSyntaxHighlighter);
    if (d->doc) {
        disconnect(d->doc, SIGNAL(contentsChange(int,int,int)),
                   this, SLOT(_q_reformatBlocks(int,int,int)));

        QTextCursor cursor(d->doc);
        cursor.beginEditBlock();
        for (QTextBlock blk = d->doc->begin(); blk.isValid(); blk = blk.next())
            blk.layout()->clearAdditionalFormats();
        cursor.endEditBlock();
    }
    d->doc = doc;
    if (d->doc) {
        connect(d->doc, SIGNAL(contentsChange(int,int,int)),
                this, SLOT(_q_reformatBlocks(int,int,int)));
        QTimer::singleShot(0, this, SLOT(_q_delayedRehighlight()));
        d->rehighlightPending = true;
    }
}


Generated by  Doxygen 1.6.0   Back to index