Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-15764

Extend the Undo framework to delete undone commands

    XMLWordPrintable

Details

    Description

      It will be nice to have deleteUndone() (or something like this) method in QUndoStack that'll delete all commands, that are undone there.

      Example of usage:
      I have a model that uses Undo framework for all actions.

      To create new item in this model, user clicks a button. This button causes creation of new item and opens dialogue, where user can change properties of newly created item. Properties are changing using QDataWidgetMapper in this dialogue.

      Meanwhile, following happens in Undo stack:

      • Start macro.
      • Push CreateItemCommand.
      • Push EditItemPropertyCommand.
      • Push EditItemPropertyCommand.
      • Push EditItemPropertyCommand.
      • ...
      • End macro.

      If user presses Ok in dialogue, newly created item just stays there.
      But in case of Cancel... uh... currently, redo() happens. And that stupid unneeded undo command stays in stack. Therefore, it will be nice to have deleteUndone() method, that will delete this thing.

      By the way, there was a way to do same thing in past — http://doc.trolltech.com/qq/qq25-undo.html contains following code:
      if(!m_cachedResult) delete m_stack->command(0);
      Now this causes to segfault.

      This suggested is like QTBUG-7096 somehow, but is much easier to do.

      Sorry for bad English.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              lapidarno Denis Pesotsky
              Votes:
              6 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes