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

void Q3TextEdit::getSelection ( int *  paraFrom,
int *  indexFrom,
int *  paraTo,
int *  indexTo,
int  selNum = 0 
) const [inherited]

If there is a selection, {*}{paraFrom} is set to the number of the paragraph in which the selection begins and {*}{paraTo} is set to the number of the paragraph in which the selection ends. (They could be the same.) {*}{indexFrom} is set to the index at which the selection begins within {*}{paraFrom}, and {*}{indexTo} is set to the index at which the selection ends within {*}{paraTo}.

If there is no selection, {*}{paraFrom}, {*}{indexFrom}, {*}{paraTo} and {*}{indexTo} are all set to -1.

If paraFrom, indexFrom, paraTo or indexTo is 0 this function does nothing.

The selNum is the number of the selection (multiple selections are supported). It defaults to 0 (the default selection).

See also:
setSelection() selectedText

Definition at line 4028 of file q3textedit.cpp.

Referenced by Q3MultiLineEdit::getMarkedRegion().

{
    if (!paraFrom || !paraTo || !indexFrom || !indexTo)
        return;
#ifdef QT_TEXTEDIT_OPTIMIZATION
    if (d->optimMode) {
        *paraFrom = d->od->selStart.line;
        *paraTo = d->od->selEnd.line;
        *indexFrom = d->od->selStart.index;
        *indexTo = d->od->selEnd.index;
        return;
    }
#endif
    if (!doc->hasSelection(selNum)) {
        *paraFrom = -1;
        *indexFrom = -1;
        *paraTo = -1;
        *indexTo = -1;
        return;
    }

    doc->selectionStart(selNum, *paraFrom, *indexFrom);
    doc->selectionEnd(selNum, *paraTo, *indexTo);
}


Generated by  Doxygen 1.6.0   Back to index