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

void QTextCursor::select ( SelectionType  selection  ) 

Selects text in the document according to the given selection.

Definition at line 1329 of file qtextcursor.cpp.

References clearSelection(), QTextBlock::length(), and movePosition().

Referenced by QSplashScreen::drawContents(), QAccessibleTextEdit::setText(), and TextEdit::textUnderCursor().

{
    if (!d || !d->priv)
        return;

    clearSelection();

    const QTextBlock block = d->block();

    switch (selection) {
        case LineUnderCursor:
            movePosition(StartOfLine);
            movePosition(EndOfLine, KeepAnchor);
            break;
        case WordUnderCursor:
            movePosition(StartOfWord);
            movePosition(EndOfWord, KeepAnchor);
            break;
        case BlockUnderCursor:
            if (block.length() == 1) // no content
                break;
            movePosition(StartOfBlock);
            // also select the paragraph separator
            if (movePosition(PreviousBlock)) {
                movePosition(EndOfBlock);
                movePosition(NextBlock, KeepAnchor);
            }
            movePosition(EndOfBlock, KeepAnchor);
            break;
        case Document:
            movePosition(Start);
            movePosition(End, KeepAnchor);
            break;
    }
}


Generated by  Doxygen 1.6.0   Back to index