Move undo framework out of Qt Widgets

- Moves QUndo* classes (except QUndoView) from src/widgets/utils to src/gui/utils
- Moves related auto tests from widgets to gui
- Replaces QUndoAction with lambdas that do text prefixing

[ChangeLog][Undo Framework] QUndo* classes (except QUndoView) were moved from Qt
Widgets to Qt GUI.

Done-with: volker.hilsheimer@qt.io
Fixes: QTBUG-40040
Change-Id: I3bd8d4d32c64f8dee548f62159a1df2126da89d8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Mitch Curtis 2020-03-10 15:40:56 +01:00 committed by Volker Hilsheimer
parent adc1be3c33
commit 3f73995a03
30 changed files with 261 additions and 263 deletions

View File

@ -113,7 +113,7 @@
The \c createActions() function sets up all the examples actions The \c createActions() function sets up all the examples actions
in the manner shown above. The in the manner shown above. The
\l{QUndoStack::}{createUndoAction()} and \l{QUndoStack::}{createUndoAction()} and
\l{QUndoStack::}{createRedoAction()} helps us crate actions that \l{QUndoStack::}{createRedoAction()} methods help us create actions that
are disabled and enabled based on the state of the stack. Also, are disabled and enabled based on the state of the stack. Also,
the text of the action will be updated automatically based on the the text of the action will be updated automatically based on the
\l{QUndoCommand::}{text()} of the undo commands. For the other \l{QUndoCommand::}{text()} of the undo commands. For the other

View File

@ -793,6 +793,15 @@ qt_extend_target(Gui CONDITION NOT GCC OR NOT QT_COMPILER_VERSION_MAJOR STREQUAL
"painting/qdrawhelper.cpp" "painting/qdrawhelper.cpp"
) )
qt_extend_target(Gui CONDITION QT_FEATURE_undocommand
SOURCES
util/qundostack.cpp util/qundostack.h util/qundostack_p.h
)
qt_extend_target(Gui CONDITION QT_FEATURE_undogroup
SOURCES
util/qundogroup.cpp util/qundogroup.h
)
qt_create_tracepoints(Gui qtgui.tracepoints) qt_create_tracepoints(Gui qtgui.tracepoints)
qt_add_docs(Gui qt_add_docs(Gui

View File

@ -1134,6 +1134,26 @@ qt_feature("multiprocess" PRIVATE
PURPOSE "Provides support for detecting the desktop environment, launching external processes and opening URLs." PURPOSE "Provides support for detecting the desktop environment, launching external processes and opening URLs."
CONDITION NOT INTEGRITY AND NOT rtems CONDITION NOT INTEGRITY AND NOT rtems
) )
qt_feature("undocommand" PUBLIC
SECTION "Utilities"
LABEL "QUndoCommand"
PURPOSE "Applies (redo or) undo of a single change in a document."
)
qt_feature_definition("undocommand" "QT_NO_UNDOCOMMAND" NEGATE VALUE "1")
qt_feature("undostack" PUBLIC
SECTION "Utilities"
LABEL "QUndoStack"
PURPOSE "Provides the ability to (redo or) undo a list of changes in a document."
CONDITION QT_FEATURE_undocommand
)
qt_feature_definition("undostack" "QT_NO_UNDOSTACK" NEGATE VALUE "1")
qt_feature("undogroup" PUBLIC
SECTION "Utilities"
LABEL "QUndoGroup"
PURPOSE "Provides the ability to cluster QUndoCommands."
CONDITION QT_FEATURE_undostack
)
qt_feature_definition("undogroup" "QT_NO_UNDOGROUP" NEGATE VALUE "1")
qt_feature("whatsthis" PUBLIC qt_feature("whatsthis" PUBLIC
SECTION "Widget Support" SECTION "Widget Support"
LABEL "QWhatsThis" LABEL "QWhatsThis"

View File

@ -1821,6 +1821,26 @@
"purpose": "Internal painting support for 64 bit (16 bpc) rasterization.", "purpose": "Internal painting support for 64 bit (16 bpc) rasterization.",
"section": "Painting", "section": "Painting",
"output": [ "privateFeature" ] "output": [ "privateFeature" ]
},
"undocommand": {
"label": "QUndoCommand",
"purpose": "Applies (redo or) undo of a single change in a document.",
"section": "Utilities",
"output": [ "publicFeature", "feature" ]
},
"undostack": {
"label": "QUndoStack",
"purpose": "Provides the ability to (redo or) undo a list of changes in a document.",
"section": "Utilities",
"condition": "features.undocommand",
"output": [ "publicFeature", "feature" ]
},
"undogroup": {
"label": "QUndoGroup",
"purpose": "Provides the ability to cluster QUndoCommands.",
"section": "Utilities",
"condition": "features.undostack",
"output": [ "publicFeature", "feature" ]
} }
}, },

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the QtWidgets module of the Qt Toolkit. ** This file is part of the QtWidgets module of the Qt Toolkit.
@ -253,6 +253,85 @@ QUndoStack *QUndoGroup::activeStack() const
return d->active; return d->active;
} }
#ifndef QT_NO_ACTION
/*!
Creates an undo QAction object with parent \a parent.
Triggering this action will cause a call to QUndoStack::undo() on the active stack.
The text of this action will always be the text of the command which will be undone
in the next call to undo(), prefixed by \a prefix. If there is no command available
for undo, if the group is empty or if none of the stacks are active, this action will
be disabled.
If \a prefix is empty, the default template "Undo %1" is used instead of prefix.
Before Qt 4.8, the prefix "Undo" was used by default.
\sa createRedoAction(), canUndo(), QUndoCommand::text()
*/
QAction *QUndoGroup::createUndoAction(QObject *parent, const QString &prefix) const
{
QAction *action = new QAction(parent);
action->setEnabled(canUndo());
QString effectivePrefix = prefix;
QString defaultText;
if (prefix.isEmpty()) {
effectivePrefix = tr("Undo %1");
defaultText = tr("Undo", "Default text for undo action");
}
QUndoStackPrivate::setPrefixedText(action, effectivePrefix, defaultText, undoText());
connect(this, &QUndoGroup::canUndoChanged, action, &QAction::setEnabled);
connect(this, &QUndoGroup::undoTextChanged, action, [=](const QString &text) {
QUndoStackPrivate::setPrefixedText(action, effectivePrefix, defaultText, text);
});
connect(action, &QAction::triggered, this, &QUndoGroup::undo);
return action;
}
/*!
Creates an redo QAction object with parent \a parent.
Triggering this action will cause a call to QUndoStack::redo() on the active stack.
The text of this action will always be the text of the command which will be redone
in the next call to redo(), prefixed by \a prefix. If there is no command available
for redo, if the group is empty or if none of the stacks are active, this action will
be disabled.
If \a prefix is empty, the default template "Redo %1" is used instead of prefix.
Before Qt 4.8, the prefix "Redo" was used by default.
\sa createUndoAction(), canRedo(), QUndoCommand::text()
*/
QAction *QUndoGroup::createRedoAction(QObject *parent, const QString &prefix) const
{
QAction *action = new QAction(parent);
action->setEnabled(canRedo());
QString effectivePrefix = prefix;
QString defaultText;
if (prefix.isEmpty()) {
effectivePrefix = tr("Redo %1");
defaultText = tr("Redo", "Default text for redo action");
}
QUndoStackPrivate::setPrefixedText(action, effectivePrefix, defaultText, redoText());
connect(this, &QUndoGroup::canRedoChanged, action, &QAction::setEnabled);
connect(this, &QUndoGroup::redoTextChanged, action, [=](const QString &text) {
QUndoStackPrivate::setPrefixedText(action, effectivePrefix, defaultText, text);
});
connect(action, &QAction::triggered, this, &QUndoGroup::redo);
return action;
}
#endif // QT_NO_ACTION
/*! /*!
Calls QUndoStack::undo() on the active stack. Calls QUndoStack::undo() on the active stack.
@ -361,72 +440,6 @@ bool QUndoGroup::isClean() const
return d->active == nullptr || d->active->isClean(); return d->active == nullptr || d->active->isClean();
} }
#ifndef QT_NO_ACTION
/*!
Creates an undo QAction object with parent \a parent.
Triggering this action will cause a call to QUndoStack::undo() on the active stack.
The text of this action will always be the text of the command which will be undone
in the next call to undo(), prefixed by \a prefix. If there is no command available
for undo, if the group is empty or if none of the stacks are active, this action will
be disabled.
If \a prefix is empty, the default template "Undo %1" is used instead of prefix.
Before Qt 4.8, the prefix "Undo" was used by default.
\sa createRedoAction(), canUndo(), QUndoCommand::text()
*/
QAction *QUndoGroup::createUndoAction(QObject *parent, const QString &prefix) const
{
QUndoAction *result = new QUndoAction(prefix, parent);
if (prefix.isEmpty())
result->setTextFormat(tr("Undo %1"), tr("Undo", "Default text for undo action"));
result->setEnabled(canUndo());
result->setPrefixedText(undoText());
connect(this, SIGNAL(canUndoChanged(bool)),
result, SLOT(setEnabled(bool)));
connect(this, SIGNAL(undoTextChanged(QString)),
result, SLOT(setPrefixedText(QString)));
connect(result, SIGNAL(triggered()), this, SLOT(undo()));
return result;
}
/*!
Creates an redo QAction object with parent \a parent.
Triggering this action will cause a call to QUndoStack::redo() on the active stack.
The text of this action will always be the text of the command which will be redone
in the next call to redo(), prefixed by \a prefix. If there is no command available
for redo, if the group is empty or if none of the stacks are active, this action will
be disabled.
If \a prefix is empty, the default template "Redo %1" is used instead of prefix.
Before Qt 4.8, the prefix "Redo" was used by default.
\sa createUndoAction(), canRedo(), QUndoCommand::text()
*/
QAction *QUndoGroup::createRedoAction(QObject *parent, const QString &prefix) const
{
QUndoAction *result = new QUndoAction(prefix, parent);
if (prefix.isEmpty())
result->setTextFormat(tr("Redo %1"), tr("Redo", "Default text for redo action"));
result->setEnabled(canRedo());
result->setPrefixedText(redoText());
connect(this, SIGNAL(canRedoChanged(bool)),
result, SLOT(setEnabled(bool)));
connect(this, SIGNAL(redoTextChanged(QString)),
result, SLOT(setPrefixedText(QString)));
connect(result, SIGNAL(triggered()), this, SLOT(redo()));
return result;
}
#endif // QT_NO_ACTION
/*! \fn void QUndoGroup::activeStackChanged(QUndoStack *stack) /*! \fn void QUndoGroup::activeStackChanged(QUndoStack *stack)
This signal is emitted whenever the active stack of the group changes. This can happen This signal is emitted whenever the active stack of the group changes. This can happen

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the QtWidgets module of the Qt Toolkit. ** This file is part of the QtWidgets module of the Qt Toolkit.
@ -40,7 +40,7 @@
#ifndef QUNDOGROUP_H #ifndef QUNDOGROUP_H
#define QUNDOGROUP_H #define QUNDOGROUP_H
#include <QtWidgets/qtwidgetsglobal.h> #include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
@ -52,7 +52,7 @@ class QUndoGroupPrivate;
class QUndoStack; class QUndoStack;
class QAction; class QAction;
class Q_WIDGETS_EXPORT QUndoGroup : public QObject class Q_GUI_EXPORT QUndoGroup : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_DECLARE_PRIVATE(QUndoGroup) Q_DECLARE_PRIVATE(QUndoGroup)
@ -67,11 +67,10 @@ public:
QUndoStack *activeStack() const; QUndoStack *activeStack() const;
#ifndef QT_NO_ACTION #ifndef QT_NO_ACTION
QAction *createUndoAction(QObject *parent, QAction *createUndoAction(QObject *parent, const QString &prefix = QString()) const;
const QString &prefix = QString()) const; QAction *createRedoAction(QObject *parent, const QString &prefix = QString()) const;
QAction *createRedoAction(QObject *parent,
const QString &prefix = QString()) const;
#endif // QT_NO_ACTION #endif // QT_NO_ACTION
bool canUndo() const; bool canUndo() const;
bool canRedo() const; bool canRedo() const;
QString undoText() const; QString undoText() const;

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the QtWidgets module of the Qt Toolkit. ** This file is part of the QtWidgets module of the Qt Toolkit.
@ -215,7 +215,7 @@ int QUndoCommand::id() const
bool QUndoCommand::mergeWith(const QUndoCommand *command) bool QUndoCommand::mergeWith(const QUndoCommand *command)
{ {
Q_UNUSED(command); Q_UNUSED(command)
return false; return false;
} }
@ -443,38 +443,6 @@ const QUndoCommand *QUndoCommand::child(int index) const
\sa QUndoCommand, QUndoView \sa QUndoCommand, QUndoView
*/ */
#if QT_CONFIG(action)
QUndoAction::QUndoAction(const QString &prefix, QObject *parent)
: QAction(parent)
{
m_prefix = prefix;
}
void QUndoAction::setPrefixedText(const QString &text)
{
if (m_defaultText.isEmpty()) {
QString s = m_prefix;
if (!m_prefix.isEmpty() && !text.isEmpty())
s.append(QLatin1Char(' '));
s.append(text);
setText(s);
} else {
if (text.isEmpty())
setText(m_defaultText);
else
setText(m_prefix.arg(text));
}
}
void QUndoAction::setTextFormat(const QString &textFormat, const QString &defaultText)
{
m_prefix = textFormat;
m_defaultText = defaultText;
}
#endif // QT_CONFIG(action)
/*! \internal /*! \internal
Sets the current index to \a idx, emitting appropriate signals. If \a clean is true, Sets the current index to \a idx, emitting appropriate signals. If \a clean is true,
makes \a idx the clean index as well. makes \a idx the clean index as well.
@ -1066,6 +1034,27 @@ QString QUndoStack::redoText() const
#ifndef QT_NO_ACTION #ifndef QT_NO_ACTION
/*!
\internal
Sets the text property of \a action to \a text, applying \a prefix, and falling back to \a defaultText if \a text is empty.
*/
void QUndoStackPrivate::setPrefixedText(QAction *action, const QString &prefix, const QString &defaultText, const QString &text)
{
if (defaultText.isEmpty()) {
QString s = prefix;
if (!prefix.isEmpty() && !text.isEmpty())
s.append(QLatin1Char(' '));
s.append(text);
action->setText(s);
} else {
if (text.isEmpty())
action->setText(defaultText);
else
action->setText(prefix.arg(text));
}
};
/*! /*!
Creates an undo QAction object with the given \a parent. Creates an undo QAction object with the given \a parent.
@ -1082,18 +1071,25 @@ QString QUndoStack::redoText() const
QAction *QUndoStack::createUndoAction(QObject *parent, const QString &prefix) const QAction *QUndoStack::createUndoAction(QObject *parent, const QString &prefix) const
{ {
QUndoAction *result = new QUndoAction(prefix, parent); QAction *action = new QAction(parent);
if (prefix.isEmpty()) action->setEnabled(canUndo());
result->setTextFormat(tr("Undo %1"), tr("Undo", "Default text for undo action"));
result->setEnabled(canUndo()); QString effectivePrefix = prefix;
result->setPrefixedText(undoText()); QString defaultText;
connect(this, SIGNAL(canUndoChanged(bool)), if (prefix.isEmpty()) {
result, SLOT(setEnabled(bool))); effectivePrefix = tr("Undo %1");
connect(this, SIGNAL(undoTextChanged(QString)), defaultText = tr("Undo", "Default text for undo action");
result, SLOT(setPrefixedText(QString))); }
connect(result, SIGNAL(triggered()), this, SLOT(undo()));
return result; QUndoStackPrivate::setPrefixedText(action, effectivePrefix, defaultText, undoText());
connect(this, &QUndoStack::canUndoChanged, action, &QAction::setEnabled);
connect(this, &QUndoStack::undoTextChanged, action, [=](const QString &text) {
QUndoStackPrivate::setPrefixedText(action, effectivePrefix, defaultText, text);
});
connect(action, &QAction::triggered, this, &QUndoStack::undo);
return action;
} }
/*! /*!
@ -1112,18 +1108,25 @@ QAction *QUndoStack::createUndoAction(QObject *parent, const QString &prefix) co
QAction *QUndoStack::createRedoAction(QObject *parent, const QString &prefix) const QAction *QUndoStack::createRedoAction(QObject *parent, const QString &prefix) const
{ {
QUndoAction *result = new QUndoAction(prefix, parent); QAction *action = new QAction(parent);
if (prefix.isEmpty()) action->setEnabled(canRedo());
result->setTextFormat(tr("Redo %1"), tr("Redo", "Default text for redo action"));
result->setEnabled(canRedo()); QString effectivePrefix = prefix;
result->setPrefixedText(redoText()); QString defaultText;
connect(this, SIGNAL(canRedoChanged(bool)), if (prefix.isEmpty()) {
result, SLOT(setEnabled(bool))); effectivePrefix = tr("Redo %1");
connect(this, SIGNAL(redoTextChanged(QString)), defaultText = tr("Redo", "Default text for redo action");
result, SLOT(setPrefixedText(QString))); }
connect(result, SIGNAL(triggered()), this, SLOT(redo()));
return result; QUndoStackPrivate::setPrefixedText(action, effectivePrefix, defaultText, redoText());
connect(this, &QUndoStack::canRedoChanged, action, &QAction::setEnabled);
connect(this, &QUndoStack::redoTextChanged, action, [=](const QString &text) {
QUndoStackPrivate::setPrefixedText(action, effectivePrefix, defaultText, text);
});
connect(action, &QAction::triggered, this, &QUndoStack::redo);
return action;
} }
#endif // QT_NO_ACTION #endif // QT_NO_ACTION
@ -1383,6 +1386,5 @@ bool QUndoStack::isActive() const
QT_END_NAMESPACE QT_END_NAMESPACE
#include "moc_qundostack.cpp" #include "moc_qundostack.cpp"
#include "moc_qundostack_p.cpp"
#endif // QT_CONFIG(undostack) #endif // QT_CONFIG(undostack)

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the QtWidgets module of the Qt Toolkit. ** This file is part of the QtWidgets module of the Qt Toolkit.
@ -40,7 +40,7 @@
#ifndef QUNDOSTACK_H #ifndef QUNDOSTACK_H
#define QUNDOSTACK_H #define QUNDOSTACK_H
#include <QtWidgets/qtwidgetsglobal.h> #include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
@ -52,7 +52,7 @@ class QAction;
class QUndoCommandPrivate; class QUndoCommandPrivate;
class QUndoStackPrivate; class QUndoStackPrivate;
class Q_WIDGETS_EXPORT QUndoCommand class Q_GUI_EXPORT QUndoCommand
{ {
QUndoCommandPrivate *d; QUndoCommandPrivate *d;
@ -84,7 +84,7 @@ private:
#if QT_CONFIG(undostack) #if QT_CONFIG(undostack)
class Q_WIDGETS_EXPORT QUndoStack : public QObject class Q_GUI_EXPORT QUndoStack : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_DECLARE_PRIVATE(QUndoStack) Q_DECLARE_PRIVATE(QUndoStack)
@ -113,10 +113,8 @@ public:
QString text(int idx) const; QString text(int idx) const;
#ifndef QT_NO_ACTION #ifndef QT_NO_ACTION
QAction *createUndoAction(QObject *parent, QAction *createUndoAction(QObject *parent, const QString &prefix = QString()) const;
const QString &prefix = QString()) const; QAction *createRedoAction(QObject *parent, const QString &prefix = QString()) const;
QAction *createRedoAction(QObject *parent,
const QString &prefix = QString()) const;
#endif // QT_NO_ACTION #endif // QT_NO_ACTION
bool isActive() const; bool isActive() const;

View File

@ -1,9 +1,9 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the QtWidgets module of the Qt Toolkit. ** This file is part of the QtGui module of the Qt Toolkit.
** **
** $QT_BEGIN_LICENSE:LGPL$ ** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage ** Commercial License Usage
@ -40,7 +40,7 @@
#ifndef QUNDOSTACK_P_H #ifndef QUNDOSTACK_P_H
#define QUNDOSTACK_P_H #define QUNDOSTACK_P_H
#include <QtWidgets/private/qtwidgetsglobal_p.h> #include <QtGui/private/qtguiglobal_p.h>
#include <private/qobject_p.h> #include <private/qobject_p.h>
#include <QtCore/qlist.h> #include <QtCore/qlist.h>
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
@ -58,9 +58,9 @@ class QUndoGroup;
// W A R N I N G // W A R N I N G
// ------------- // -------------
// //
// This file is not part of the Qt API. It exists for the convenience // This file is not part of the Qt API. It exists purely as an
// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header // implementation detail. This header file may change from version to
// file may change from version to version without notice, or even be removed. // version without notice, or even be removed.
// //
// We mean it. // We mean it.
// //
@ -93,22 +93,11 @@ public:
void setIndex(int idx, bool clean); void setIndex(int idx, bool clean);
bool checkUndoLimit(); bool checkUndoLimit();
};
#ifndef QT_NO_ACTION #ifndef QT_NO_ACTION
class QUndoAction : public QAction static void setPrefixedText(QAction *action, const QString &prefix, const QString &defaultText, const QString &text);
{ #endif
Q_OBJECT
public:
explicit QUndoAction(const QString &prefix, QObject *parent = nullptr);
void setTextFormat(const QString &textFormat, const QString &defaultText);
public Q_SLOTS:
void setPrefixedText(const QString &text);
private:
QString m_prefix;
QString m_defaultText;
}; };
#endif // QT_NO_ACTION
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // QT_CONFIG(undostack) #endif // QT_CONFIG(undostack)

View File

@ -46,3 +46,16 @@ qtConfig(regularexpression) {
SOURCES += \ SOURCES += \
util/qshadergenerator.cpp util/qshadergenerator.cpp
} }
qtConfig(undocommand) {
HEADERS += \
util/qundostack.h \
util/qundostack_p.h
SOURCES += util/qundostack.cpp
}
qtConfig(undogroup) {
HEADERS += util/qundogroup.h
SOURCES += util/qundogroup.cpp
}

View File

@ -878,9 +878,9 @@ QT_CLASS_LIB(QDesktopServices, QtWidgets, qdesktopservices.h)
QT_CLASS_LIB(QScroller, QtWidgets, qscroller.h) QT_CLASS_LIB(QScroller, QtWidgets, qscroller.h)
QT_CLASS_LIB(QScrollerProperties, QtWidgets, qscrollerproperties.h) QT_CLASS_LIB(QScrollerProperties, QtWidgets, qscrollerproperties.h)
QT_CLASS_LIB(QSystemTrayIcon, QtGui, qsystemtrayicon.h) QT_CLASS_LIB(QSystemTrayIcon, QtGui, qsystemtrayicon.h)
QT_CLASS_LIB(QUndoGroup, QtWidgets, qundogroup.h) QT_CLASS_LIB(QUndoGroup, QtGui, qundogroup.h)
QT_CLASS_LIB(QUndoCommand, QtWidgets, qundostack.h) QT_CLASS_LIB(QUndoCommand, QtGui, qundostack.h)
QT_CLASS_LIB(QUndoStack, QtWidgets, qundostack.h) QT_CLASS_LIB(QUndoStack, QtGui, qundostack.h)
QT_CLASS_LIB(QUndoView, QtWidgets, qundoview.h) QT_CLASS_LIB(QUndoView, QtWidgets, qundoview.h)
QT_CLASS_LIB(QAbstractButton, QtWidgets, qabstractbutton.h) QT_CLASS_LIB(QAbstractButton, QtWidgets, qabstractbutton.h)
QT_CLASS_LIB(QAbstractScrollArea, QtWidgets, qabstractscrollarea.h) QT_CLASS_LIB(QAbstractScrollArea, QtWidgets, qabstractscrollarea.h)

View File

@ -796,16 +796,6 @@ qt_extend_target(Widgets CONDITION QT_FEATURE_scroller
util/qscrollerproperties.cpp util/qscrollerproperties.h util/qscrollerproperties_p.h util/qscrollerproperties.cpp util/qscrollerproperties.h util/qscrollerproperties_p.h
) )
qt_extend_target(Widgets CONDITION QT_FEATURE_undocommand
SOURCES
util/qundostack.cpp util/qundostack.h util/qundostack_p.h
)
qt_extend_target(Widgets CONDITION QT_FEATURE_undogroup
SOURCES
util/qundogroup.cpp util/qundogroup.h
)
qt_extend_target(Widgets CONDITION QT_FEATURE_undoview qt_extend_target(Widgets CONDITION QT_FEATURE_undoview
SOURCES SOURCES
util/qundoview.cpp util/qundoview.h util/qundoview.cpp util/qundoview.h

View File

@ -534,26 +534,6 @@ qt_feature("fscompleter" PUBLIC
CONDITION QT_FEATURE_filesystemmodel AND QT_FEATURE_completer CONDITION QT_FEATURE_filesystemmodel AND QT_FEATURE_completer
) )
qt_feature_definition("fscompleter" "QT_NO_FSCOMPLETER" NEGATE VALUE "1") qt_feature_definition("fscompleter" "QT_NO_FSCOMPLETER" NEGATE VALUE "1")
qt_feature("undocommand" PUBLIC
SECTION "Utilities"
LABEL "QUndoCommand"
PURPOSE "Applies (redo or) undo of a single change in a document."
)
qt_feature_definition("undocommand" "QT_NO_UNDOCOMMAND" NEGATE VALUE "1")
qt_feature("undostack" PUBLIC
SECTION "Utilities"
LABEL "QUndoStack"
PURPOSE "Provides the ability to (redo or) undo a list of changes in a document."
CONDITION QT_FEATURE_undocommand
)
qt_feature_definition("undostack" "QT_NO_UNDOSTACK" NEGATE VALUE "1")
qt_feature("undogroup" PUBLIC
SECTION "Utilities"
LABEL "QUndoGroup"
PURPOSE "Provides the ability to cluster QUndoCommands."
CONDITION QT_FEATURE_undostack
)
qt_feature_definition("undogroup" "QT_NO_UNDOGROUP" NEGATE VALUE "1")
qt_feature("undoview" PUBLIC qt_feature("undoview" PUBLIC
SECTION "Utilities" SECTION "Utilities"
LABEL "QUndoView" LABEL "QUndoView"

View File

@ -633,26 +633,6 @@
"condition": "features.filesystemmodel && features.completer", "condition": "features.filesystemmodel && features.completer",
"output": [ "publicFeature", "feature" ] "output": [ "publicFeature", "feature" ]
}, },
"undocommand": {
"label": "QUndoCommand",
"purpose": "Applies (redo or) undo of a single change in a document.",
"section": "Utilities",
"output": [ "publicFeature", "feature" ]
},
"undostack": {
"label": "QUndoStack",
"purpose": "Provides the ability to (redo or) undo a list of changes in a document.",
"section": "Utilities",
"condition": "features.undocommand",
"output": [ "publicFeature", "feature" ]
},
"undogroup": {
"label": "QUndoGroup",
"purpose": "Provides the ability to cluster QUndoCommands.",
"section": "Utilities",
"condition": "features.undostack",
"output": [ "publicFeature", "feature" ]
},
"undoview": { "undoview": {
"label": "QUndoView", "label": "QUndoView",
"purpose": "Provides a widget which shows the contents of an undo stack.", "purpose": "Provides a widget which shows the contents of an undo stack.",

View File

@ -37,12 +37,12 @@
** **
****************************************************************************/ ****************************************************************************/
#include "qundostack.h"
#include "qundoview.h" #include "qundoview.h"
#if QT_CONFIG(undogroup) #if QT_CONFIG(undogroup)
#include "qundogroup.h" #include <QtGui/qundogroup.h>
#endif #endif
#include <QtGui/qundostack.h>
#include <QtCore/qabstractitemmodel.h> #include <QtCore/qabstractitemmodel.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
#include <QtGui/qicon.h> #include <QtGui/qicon.h>

View File

@ -31,19 +31,6 @@ qtConfig(scroller) {
util/qflickgesture.cpp \ util/qflickgesture.cpp \
} }
qtConfig(undocommand) {
HEADERS += \
util/qundostack.h \
util/qundostack_p.h
SOURCES += util/qundostack.cpp
}
qtConfig(undogroup) {
HEADERS += util/qundogroup.h
SOURCES += util/qundogroup.cpp
}
qtConfig(undoview) { qtConfig(undoview) {
HEADERS += util/qundoview.h HEADERS += util/qundoview.h
SOURCES += util/qundoview.cpp SOURCES += util/qundoview.cpp

View File

@ -10,3 +10,5 @@ add_subdirectory(qshadergraphloader)
add_subdirectory(qshadernodes) add_subdirectory(qshadernodes)
add_subdirectory(qshadernodesloader) add_subdirectory(qshadernodesloader)
add_subdirectory(qtexturefilereader) add_subdirectory(qtexturefilereader)
add_subdirectory(qundogroup)
add_subdirectory(qundostack)

View File

@ -9,5 +9,4 @@ add_qt_test(tst_qundogroup
tst_qundogroup.cpp tst_qundogroup.cpp
PUBLIC_LIBRARIES PUBLIC_LIBRARIES
Qt::Gui Qt::Gui
Qt::Widgets
) )

View File

@ -1,4 +1,4 @@
CONFIG += testcase CONFIG += testcase
QT += widgets testlib QT += testlib
SOURCES += tst_qundogroup.cpp SOURCES += tst_qundogroup.cpp
TARGET = tst_qundogroup TARGET = tst_qundogroup

View File

@ -359,8 +359,8 @@ static QString glue(const QString &s1, const QString &s2)
void tst_QUndoGroup::checkSignals() void tst_QUndoGroup::checkSignals()
{ {
QUndoGroup group; QUndoGroup group;
const QScopedPointer<QAction> undo_action(group.createUndoAction(0, QString("foo"))); QScopedPointer<QAction> undo_action(group.createUndoAction(nullptr, QString("foo")));
const QScopedPointer<QAction> redo_action(group.createRedoAction(0, QString("bar"))); QScopedPointer<QAction> redo_action(group.createRedoAction(nullptr, QString("bar")));
QSignalSpy indexChangedSpy(&group, &QUndoGroup::indexChanged); QSignalSpy indexChangedSpy(&group, &QUndoGroup::indexChanged);
QSignalSpy cleanChangedSpy(&group, &QUndoGroup::cleanChanged); QSignalSpy cleanChangedSpy(&group, &QUndoGroup::cleanChanged);
QSignalSpy canUndoChangedSpy(&group, &QUndoGroup::canUndoChanged); QSignalSpy canUndoChangedSpy(&group, &QUndoGroup::canUndoChanged);
@ -608,8 +608,8 @@ void tst_QUndoGroup::commandTextFormat()
qApp->installTranslator(&translator); qApp->installTranslator(&translator);
QUndoGroup group; QUndoGroup group;
const QScopedPointer<QAction> undo_action(group.createUndoAction(0)); QScopedPointer<QAction> undo_action(group.createUndoAction(nullptr));
const QScopedPointer<QAction> redo_action(group.createRedoAction(0)); QScopedPointer<QAction> redo_action(group.createRedoAction(nullptr));
QCOMPARE(undo_action->text(), QString("Undo-default-text")); QCOMPARE(undo_action->text(), QString("Undo-default-text"));
QCOMPARE(redo_action->text(), QString("Redo-default-text")); QCOMPARE(redo_action->text(), QString("Redo-default-text"));

View File

@ -9,5 +9,4 @@ add_qt_test(tst_qundostack
tst_qundostack.cpp tst_qundostack.cpp
PUBLIC_LIBRARIES PUBLIC_LIBRARIES
Qt::Gui Qt::Gui
Qt::Widgets
) )

View File

@ -1,4 +1,4 @@
CONFIG += testcase CONFIG += testcase
QT += widgets testlib QT += gui testlib
SOURCES += tst_qundostack.cpp SOURCES += tst_qundostack.cpp
TARGET = tst_qundostack TARGET = tst_qundostack

View File

@ -387,8 +387,8 @@ static void checkState(QSignalSpy &redoTextChangedSpy,
void tst_QUndoStack::undoRedo() void tst_QUndoStack::undoRedo()
{ {
QUndoStack stack; QUndoStack stack;
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); QScopedPointer<QAction> undoAction(stack.createUndoAction(nullptr, QString("foo")));
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); QScopedPointer<QAction> redoAction(stack.createRedoAction(nullptr, QString("bar")));
QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
@ -748,8 +748,8 @@ void tst_QUndoStack::undoRedo()
void tst_QUndoStack::setIndex() void tst_QUndoStack::setIndex()
{ {
QUndoStack stack; QUndoStack stack;
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); QScopedPointer<QAction> undoAction(stack.createUndoAction(nullptr, QString("foo")));
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); QScopedPointer<QAction> redoAction(stack.createRedoAction(nullptr, QString("bar")));
QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
@ -1012,8 +1012,8 @@ void tst_QUndoStack::setIndex()
void tst_QUndoStack::setClean() void tst_QUndoStack::setClean()
{ {
QUndoStack stack; QUndoStack stack;
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); QScopedPointer<QAction> undoAction(stack.createUndoAction(nullptr, QString("foo")));
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); QScopedPointer<QAction> redoAction(stack.createRedoAction(nullptr, QString("bar")));
QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
@ -1409,8 +1409,8 @@ void tst_QUndoStack::setClean()
void tst_QUndoStack::clear() void tst_QUndoStack::clear()
{ {
QUndoStack stack; QUndoStack stack;
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); QScopedPointer<QAction> undoAction(stack.createUndoAction(nullptr, QString("foo")));
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); QScopedPointer<QAction> redoAction(stack.createRedoAction(nullptr, QString("bar")));
QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
@ -1607,8 +1607,8 @@ void tst_QUndoStack::clear()
void tst_QUndoStack::childCommand() void tst_QUndoStack::childCommand()
{ {
QUndoStack stack; QUndoStack stack;
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); QScopedPointer<QAction> undoAction(stack.createUndoAction(nullptr, QString("foo")));
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); QScopedPointer<QAction> redoAction(stack.createRedoAction(nullptr, QString("bar")));
QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
@ -1717,8 +1717,8 @@ void tst_QUndoStack::childCommand()
void tst_QUndoStack::macroBeginEnd() void tst_QUndoStack::macroBeginEnd()
{ {
QUndoStack stack; QUndoStack stack;
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); QScopedPointer<QAction> undoAction(stack.createUndoAction(nullptr, QString("foo")));
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); QScopedPointer<QAction> redoAction(stack.createRedoAction(nullptr, QString("bar")));
QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
@ -2184,8 +2184,8 @@ void tst_QUndoStack::macroBeginEnd()
void tst_QUndoStack::compression() void tst_QUndoStack::compression()
{ {
QUndoStack stack; QUndoStack stack;
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); QScopedPointer<QAction> undoAction(stack.createUndoAction(nullptr, QString("foo")));
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); QScopedPointer<QAction> redoAction(stack.createRedoAction(nullptr, QString("bar")));
QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
@ -2626,8 +2626,8 @@ void tst_QUndoStack::compression()
void tst_QUndoStack::obsolete() void tst_QUndoStack::obsolete()
{ {
QUndoStack stack; QUndoStack stack;
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); QScopedPointer<QAction> undoAction(stack.createUndoAction(nullptr, QString("foo")));
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); QScopedPointer<QAction> redoAction(stack.createRedoAction(nullptr, QString("bar")));
QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
@ -3331,8 +3331,8 @@ void tst_QUndoStack::obsolete()
void tst_QUndoStack::undoLimit() void tst_QUndoStack::undoLimit()
{ {
QUndoStack stack; QUndoStack stack;
const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); QScopedPointer<QAction> undoAction(stack.createUndoAction(nullptr, QString("foo")));
const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); QScopedPointer<QAction> redoAction(stack.createRedoAction(nullptr, QString("bar")));
QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged);
QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged);
QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged);
@ -3872,8 +3872,8 @@ void tst_QUndoStack::commandTextFormat()
qApp->installTranslator(&translator); qApp->installTranslator(&translator);
QUndoStack stack; QUndoStack stack;
const QScopedPointer<QAction> undo_action(stack.createUndoAction(0)); QScopedPointer<QAction> undo_action(stack.createUndoAction(nullptr));
const QScopedPointer<QAction> redo_action(stack.createRedoAction(0)); QScopedPointer<QAction> redo_action(stack.createRedoAction(nullptr));
QCOMPARE(undo_action->text(), QString("Undo-default-text")); QCOMPARE(undo_action->text(), QString("Undo-default-text"));
QCOMPARE(redo_action->text(), QString("Redo-default-text")); QCOMPARE(redo_action->text(), QString("Redo-default-text"));
@ -3900,8 +3900,8 @@ void tst_QUndoStack::commandTextFormat()
void tst_QUndoStack::separateUndoText() void tst_QUndoStack::separateUndoText()
{ {
QUndoStack stack; QUndoStack stack;
const QScopedPointer<QAction> undo_action(stack.createUndoAction(0)); QScopedPointer<QAction> undo_action(stack.createUndoAction(nullptr));
const QScopedPointer<QAction> redo_action(stack.createRedoAction(0)); QScopedPointer<QAction> redo_action(stack.createRedoAction(nullptr));
QUndoCommand *command1 = new IdleCommand(); QUndoCommand *command1 = new IdleCommand();
QUndoCommand *command2 = new IdleCommand(); QUndoCommand *command2 = new IdleCommand();

View File

@ -9,4 +9,6 @@ SUBDIRS= \
qshadergraphloader \ qshadergraphloader \
qshadernodes \ qshadernodes \
qshadernodesloader \ qshadernodesloader \
qtexturefilereader qtexturefilereader \
qundogroup \
qundostack

View File

@ -3,5 +3,3 @@
add_subdirectory(qcompleter) add_subdirectory(qcompleter)
add_subdirectory(qscroller) add_subdirectory(qscroller)
add_subdirectory(qsystemtrayicon) add_subdirectory(qsystemtrayicon)
add_subdirectory(qundogroup)
add_subdirectory(qundostack)

View File

@ -2,6 +2,4 @@ TEMPLATE=subdirs
SUBDIRS=\ SUBDIRS=\
qcompleter \ qcompleter \
qscroller \ qscroller \
qsystemtrayicon \ qsystemtrayicon
qundogroup \
qundostack \