Replacement for Qt's Undo Framework

Olivier Goffart ogoffart at kde.org
Tue Apr 26 00:04:40 BST 2011


Le Monday 25 April 2011, Alexander Potashev a écrit :
> Hi,
> 
> The Qt's Undo Framework (QUndoCommand, QUndoStack, QUndoGroup,
> QUndoView) has a few oddities:
> 1. The names of undo actions can only have a predefined prefix
> (https://bugs.kde.org/show_bug.cgi?id=253459),
> 2. You can't use different strings for the name of undo action (Edit
> -> Undo/Redo [some action]) and for the items in the undo history
> (there is such panel, for example, in Step and Krita). The reason for
> having different strings is to make grammatical cases of the names of
> actions consistent with the context (in Russian and a few other
> languages you should put %1 in accusative case in "Undo %1").
> 
> 
> If I'm not mistaken, those problems can't be solved by just deriving
> your own classes from QUndo*, because you need to override methods
> like createUndoAction which are not "virtual" (sure, you can name
> those methods differently, but then other problems may arise).
> 
> The solution is to fork QUndo* classes and fix the problems in the new
> classes, so did I:
> https://github.com/aspotashev/libkundo2
> (the code looks like garbage, I only made it working, but didn't try
> to clean it up)
> 
> 
> At the first glance, the only way to use two strings for every
> UndoCommand is to add yet another argument to the constructor of
> UndoCommand. But then a huge amount of code would need changes, that's
> not very good. Also, most languages don't really need different names
> for undo actions and items in undo history.
> I kept the arguments of UndoCommand() the same, but now if you put
> something like "Create a document|-|creation of a document" as the
> "text" into the constructor (or translate it with a similar string
> with "|-|"), you'll get "Create a document" as the name of an item in
> Undo History panel, and the "Undo ..." menu item will be called "Undo
> creation of a document".
> 
> Screenshots:
> http://ompldr.org/vOGYxaQ -- translation in Lokalize (into Russian)
> http://ompldr.org/vOGYxag -- Step using different translations for
> "Undo ..." command and undo history.
> 
> The patch I used for Step is attached.
> 
> 
> What do you think about inclusion of KUndo*2 into kdelibs?

I have not seen the details about KUndo2 yet,  but what are the reasons that 
keep you from improving QUndo in Qt?  Is there technical reasons? or just 
political issues?

Because this KUndo2 things are just against the others goal:
http://community.kde.org/KDE_Core/QtMerge




More information about the kde-core-devel mailing list