Exemplo n.º 1
0
/// undo's the given controller change
bool TextUndoStack::redoControllerChange(TextEditorController *controller)
{
    Q_ASSERT(controller);
    int changeIdx = findRedoIndex( currentIndex(controller), controller);
    Change* changeToRedo = findRedoChange( controller );
    if( changeToRedo && changeToRedo->controllerContext() ) {
        Q_ASSERT( changeToRedo->controllerContext() == controller );
        changeToRedo->execute( documentRef_ );

        // move the pointer to the next
        controllerIndexMap_[controller] = changeIdx+1;
        emit redoExecuted( changeToRedo );
    }
    return false;
}
Exemplo n.º 2
0
/// redo a document change
void TextUndoStack::redoDocumentChange()
{
    // first find the redo operation
    int redoIndex = findRedoIndex( currentIndex(0), 0 );
    Change* redo = findRedoChange(0);
    if( redo ) { ++redoIndex; }

    // first move all controller redo-operation to the given redo found redo location
    QMap<TextEditorController*, int>::iterator itr;
    for( itr = controllerIndexMap_.begin(); itr != controllerIndexMap_.end(); ++itr) {
        TextEditorController* controller = itr.key();
        while( redoControllerChange(controller) ) {};  // undo all controller operations
        itr.value() = redoIndex;    // move the position after the DOC operation
    }

    // is there a document redo? execute it
    if( redo ) {
        redo->execute(documentRef_);
        setChangeIndex(redoIndex);
        emit redoExecuted( redo );
    }
}