Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qundostack_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QUNDOSTACK_P_H
6#define QUNDOSTACK_P_H
7
8#include <QtGui/private/qtguiglobal_p.h>
9#include <private/qobject_p.h>
10#include <QtCore/qlist.h>
11#include <QtCore/qstring.h>
12#if QT_CONFIG(action)
13# include <QtGui/qaction.h>
14#endif
15
16#include "qundostack.h"
17
19class QUndoCommand;
20class QUndoGroup;
21
22//
23// W A R N I N G
24// -------------
25//
26// This file is not part of the Qt API. It exists purely as an
27// implementation detail. This header file may change from version to
28// version without notice, or even be removed.
29//
30// We mean it.
31//
32
43
44#if QT_CONFIG(undostack)
45
46class QUndoStackPrivate : public QObjectPrivate
47{
48 Q_DECLARE_PUBLIC(QUndoStack)
49public:
50 QUndoStackPrivate() : index(0), clean_index(0), group(nullptr), undo_limit(0) {}
51
52 /*!
53 * \internal
54 * \brief Holds the presentation state for an Undo or Redo command.
55 * This structure serves a change-detection purpose.
56 */
57 struct ActionState
58 {
59 bool enabled = false;
60 QString text;
61
62 bool operator!=(const ActionState &other) const noexcept
63 {
64 return enabled != other.enabled || text != other.text;
65 }
66 };
67
68 QList<QUndoCommand*> command_list;
69 QList<QUndoCommand*> macro_stack;
70 int index;
71 int clean_index;
72 QUndoGroup *group;
73 int undo_limit;
74 ActionState undoActionState;
75 ActionState redoActionState;
76
77 void setIndex(int idx, bool clean);
78 bool checkUndoLimit();
79
80#ifndef QT_NO_ACTION
81 static void setPrefixedText(QAction *action, const QString &prefix, const QString &defaultText, const QString &text);
82#endif
83};
84
85QT_END_NAMESPACE
86#endif // QT_CONFIG(undostack)
87#endif // QUNDOSTACK_P_H
QList< QUndoCommand * > child_list
The QUndoCommand class is the base class of all commands stored on a QUndoStack.
Definition qundostack.h:21
The QUndoGroup class is a group of QUndoStack objects.
Definition qundogroup.h:21
QT_REQUIRE_CONFIG(undogroup)
QT_REQUIRE_CONFIG(thread)