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 friend bool operator==(const ActionState &lhs, const ActionState &rhs) noexcept
63#ifdef __cpp_impl_three_way_comparison
64 = default;
65#else
66 { return lhs.enabled == rhs.enabled && lhs.text == rhs.text; }
67 friend bool operator!=(const ActionState &lhs, const ActionState &rhs) noexcept
68 { return !(lhs == rhs); }
69#endif
70 // some compiler's reject seed = 0) = delete, overload instead:
71 friend void qHash(const ActionState &key, size_t seed) = delete;
72 friend void qHash(const ActionState &key) = delete;
73 };
74
75 QList<QUndoCommand*> command_list;
76 QList<QUndoCommand*> macro_stack;
77 int index;
78 int clean_index;
79 QUndoGroup *group;
80 int undo_limit;
81 ActionState undoActionState;
82 ActionState redoActionState;
83
84 void setIndex(int idx, bool clean);
85 bool checkUndoLimit();
86
87#ifndef QT_NO_ACTION
88 static void setPrefixedText(QAction *action, const QString &prefix, const QString &defaultText, const QString &text);
89#endif
90};
91
92QT_END_NAMESPACE
93#endif // QT_CONFIG(undostack)
94#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)
Combined button and popup list for selecting options.
QT_REQUIRE_CONFIG(thread)