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

void Q3TextEdit::removeSelectedText ( int  selNum = 0  )  [virtual, slot, inherited]

Deletes the text of selection selNum (by default, the default selection, 0). If there is no selected text nothing happens.

See also:
selectedText removeSelection()

Definition at line 1810 of file q3textedit.cpp.

References Q3ScrollView::contentsHeight, Q3TextEdit::copyAvailable(), Q3TextEdit::cursor, Q3TextEdit::drawCursor(), Q3TextEdit::ensureCursorVisible(), QWidget::repaint(), Q3ScrollView::repaintContents(), Q3TextEdit::selectionChanged(), QWidget::setCursor(), Q3TextEdit::textChanged(), Q3ScrollView::viewport(), Q3ScrollView::visibleHeight, and Q3ScrollView::visibleWidth.

Referenced by Q3MultiLineEdit::backspace(), Q3TextEdit::clear(), Q3TextEdit::contentsDropEvent(), Q3TextEdit::cut(), Q3TextEdit::del(), Q3TextEdit::doKeyboardAction(), Q3TextEdit::inputMethodEvent(), Q3TextEdit::insert(), Q3TextEdit::keyPressEvent(), Q3TextEdit::pasteSubType(), and Q3TextEdit::removeParagraph().

{
    Q3TextCursor c1 = doc->selectionStartCursor(selNum);
    c1.restoreState();
    Q3TextCursor c2 = doc->selectionEndCursor(selNum);
    c2.restoreState();

    // ### no support for editing tables yet, plus security for broken selections
    if (c1.nestedDepth() || c2.nestedDepth())
        return;

    for (int i = 0; i < (int)doc->numSelections(); ++i) {
        if (i == selNum)
            continue;
        doc->removeSelection(i);
    }

    drawCursor(false);
    if (undoEnabled) {
        checkUndoRedoInfo(UndoRedoInfo::RemoveSelected);
        if (!undoRedoInfo.valid()) {
            doc->selectionStart(selNum, undoRedoInfo.id, undoRedoInfo.index);
            undoRedoInfo.d->text.clear();
        }
        readFormats(c1, c2, undoRedoInfo.d->text, true);
    }

    doc->removeSelectedText(selNum, cursor);
    if (cursor->isValid()) {
        lastFormatted = 0; // make sync a noop
        ensureCursorVisible();
        lastFormatted = cursor->paragraph();
        formatMore();
        repaintContents();
        ensureCursorVisible();
        drawCursor(true);
        clearUndoRedo();
#if defined(Q_WS_WIN)
        // there seems to be a problem with repainting or erasing the area
        // of the scrollview which is not the contents on windows
        if (contentsHeight() < visibleHeight())
            viewport()->repaint(0, contentsHeight(), visibleWidth(), visibleHeight() - contentsHeight());
#endif
#ifndef QT_NO_CURSOR
        viewport()->setCursor(isReadOnly() ? Qt::ArrowCursor : Qt::IBeamCursor);
#endif
    } else {
        lastFormatted = doc->firstParagraph();
        delete cursor;
        cursor = new Q3TextCursor(doc);
        drawCursor(true);
        repaintContents();
    }
    setModified();
    emit textChanged();
    emit selectionChanged();
    emit copyAvailable(doc->hasSelection(Q3TextDocument::Standard));
}


Generated by  Doxygen 1.6.0   Back to index