source: trunk/doc/src/frameworks-technologies/qundo.qdoc

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 4.6 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:FDL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in a
14** written agreement between you and Nokia.
15**
16** GNU Free Documentation License
17** Alternatively, this file may be used under the terms of the GNU Free
18** Documentation License version 1.3 as published by the Free Software
19** Foundation and appearing in the file included in the packaging of this
20** file.
21**
22** If you have questions regarding the use of this file, please contact
23** Nokia at qt-info@nokia.com.
24** $QT_END_LICENSE$
25**
26****************************************************************************/
27
28/*!
29 \page qundo.html
30 \title Overview of Qt's Undo Framework
31 \keyword Undo framework
32 \ingroup frameworks-technologies
33
34 \section1 Introduction
35
36 Qt's Undo Framework is an implementation of the Command pattern, for
37 implementing undo/redo functionality in applications.
38
39 The Command pattern is based on the idea that all editing in
40 an application is done by creating instances of command objects.
41 Command objects apply changes to the document and are stored
42 on a command stack. Furthermore, each command knows how to undo its
43 changes to bring the document back to its previous state. As long
44 as the application only uses command objects to change the state of
45 the document, it is possible to undo a sequence of commands by
46 traversing the stack downwards and calling undo
47 on each command in turn. It is also possible to redo a sequence of
48 commands by traversing the stack upwards and calling
49 redo on each command.
50
51 \section1 Classes
52
53 The framework consists of four classes:
54
55 \list
56 \i \l QUndoCommand is the base class of all commands stored on an
57 undo stack. It can apply (redo) or undo a single change in the document.
58 \i \l QUndoStack is a list of QUndoCommand objects. It contains all the
59 commands executed on the document and can roll the document's state
60 backwards or forwards by undoing or redoing them.
61 \i \l QUndoGroup is a group of undo stacks. It is useful when an application
62 contains more than one undo stack, typically one for each opened
63 document. QUndoGroup provides a single pair of undo/redo slots for all
64 the stacks in the group. It forwards undo and redo requests to
65 the active stack, which is the stack associated with the document that
66 is currently being edited by the user.
67 \i \l QUndoView is a widget which shows the contents of an undo stack. Clicking
68 on a command in the view rolls the document's state backwards or
69 forwards to that command.
70 \endlist
71
72 \section1 Concepts
73
74 The following concepts are supported by the framework:
75
76 \list
77 \i \bold{Clean state:} Used to signal when the document enters and leaves a
78 state that has been saved to disk. This is typically used to disable or
79 enable the save actions, and to update the document's title bar.
80 \i \bold{Command compression:} Used to compress sequences of commands into a
81 single command.
82 For example: In a text editor, the commands that insert individual
83 characters into the document can be compressed into a single command that
84 inserts whole sections of text. These bigger changes are more convenient
85 for the user to undo and redo.
86 \i \bold{Command macros:} A sequence of commands, all of which are undone or
87 redone in one step.
88 These simplify the task of writing an application, since a set of simpler
89 commands can be composed into more complex commands. For example, a command
90 that moves a set of selected objects in a document can be created by
91 combining a set of commands, each of which moves a single object.
92 \endlist
93
94 QUndoStack provides convenient undo and redo QAction objects that
95 can be inserted into a menu or a toolbar. The text properties of these
96 actions always reflect what command will be undone or redone when
97 they are triggered. Similarly, QUndoGroup provides undo and redo actions
98 that always behave like the undo and redo actions of the active stack.
99*/
Note: See TracBrowser for help on using the repository browser.