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
in the manner shown above. The
\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,
the text of the action will be updated automatically based on the
\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"
)
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_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."
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
SECTION "Widget Support"
LABEL "QWhatsThis"

View File

@ -1821,6 +1821,26 @@
"purpose": "Internal painting support for 64 bit (16 bpc) rasterization.",
"section": "Painting",
"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/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@ -253,6 +253,85 @@ QUndoStack *QUndoGroup::activeStack() const
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.
@ -361,72 +440,6 @@ bool QUndoGroup::isClean() const
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)
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/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@ -40,7 +40,7 @@
#ifndef QUNDOGROUP_H
#define QUNDOGROUP_H
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
@ -52,7 +52,7 @@ class QUndoGroupPrivate;
class QUndoStack;
class QAction;
class Q_WIDGETS_EXPORT QUndoGroup : public QObject
class Q_GUI_EXPORT QUndoGroup : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QUndoGroup)
@ -67,11 +67,10 @@ public:
QUndoStack *activeStack() const;
#ifndef QT_NO_ACTION
QAction *createUndoAction(QObject *parent,
const QString &prefix = QString()) const;
QAction *createRedoAction(QObject *parent,
const QString &prefix = QString()) const;
QAction *createUndoAction(QObject *parent, const QString &prefix = QString()) const;
QAction *createRedoAction(QObject *parent, const QString &prefix = QString()) const;
#endif // QT_NO_ACTION
bool canUndo() const;
bool canRedo() 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/
**
** 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)
{
Q_UNUSED(command);
Q_UNUSED(command)
return false;
}
@ -443,38 +443,6 @@ const QUndoCommand *QUndoCommand::child(int index) const
\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
Sets the current index to \a idx, emitting appropriate signals. If \a clean is true,
makes \a idx the clean index as well.
@ -1066,6 +1034,27 @@ QString QUndoStack::redoText() const
#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.
@ -1082,18 +1071,25 @@ QString QUndoStack::redoText() const
QAction *QUndoStack::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"));
QAction *action = new QAction(parent);
action->setEnabled(canUndo());
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;
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, &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
{
QUndoAction *result = new QUndoAction(prefix, parent);
if (prefix.isEmpty())
result->setTextFormat(tr("Redo %1"), tr("Redo", "Default text for redo action"));
QAction *action = new QAction(parent);
action->setEnabled(canRedo());
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;
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, &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
@ -1383,6 +1386,5 @@ bool QUndoStack::isActive() const
QT_END_NAMESPACE
#include "moc_qundostack.cpp"
#include "moc_qundostack_p.cpp"
#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/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@ -40,7 +40,7 @@
#ifndef QUNDOSTACK_H
#define QUNDOSTACK_H
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
@ -52,7 +52,7 @@ class QAction;
class QUndoCommandPrivate;
class QUndoStackPrivate;
class Q_WIDGETS_EXPORT QUndoCommand
class Q_GUI_EXPORT QUndoCommand
{
QUndoCommandPrivate *d;
@ -84,7 +84,7 @@ private:
#if QT_CONFIG(undostack)
class Q_WIDGETS_EXPORT QUndoStack : public QObject
class Q_GUI_EXPORT QUndoStack : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QUndoStack)
@ -113,10 +113,8 @@ public:
QString text(int idx) const;
#ifndef QT_NO_ACTION
QAction *createUndoAction(QObject *parent,
const QString &prefix = QString()) const;
QAction *createRedoAction(QObject *parent,
const QString &prefix = QString()) const;
QAction *createUndoAction(QObject *parent, const QString &prefix = QString()) const;
QAction *createRedoAction(QObject *parent, const QString &prefix = QString()) const;
#endif // QT_NO_ACTION
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/
**
** 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$
** Commercial License Usage
@ -40,7 +40,7 @@
#ifndef 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 <QtCore/qlist.h>
#include <QtCore/qstring.h>
@ -58,9 +58,9 @@ class QUndoGroup;
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
// file may change from version to version without notice, or even be removed.
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
@ -93,22 +93,11 @@ public:
void setIndex(int idx, bool clean);
bool checkUndoLimit();
};
#ifndef QT_NO_ACTION
class QUndoAction : public QAction
{
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;
static void setPrefixedText(QAction *action, const QString &prefix, const QString &defaultText, const QString &text);
#endif
};
#endif // QT_NO_ACTION
QT_END_NAMESPACE
#endif // QT_CONFIG(undostack)

View File

@ -46,3 +46,16 @@ qtConfig(regularexpression) {
SOURCES += \
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(QScrollerProperties, QtWidgets, qscrollerproperties.h)
QT_CLASS_LIB(QSystemTrayIcon, QtGui, qsystemtrayicon.h)
QT_CLASS_LIB(QUndoGroup, QtWidgets, qundogroup.h)
QT_CLASS_LIB(QUndoCommand, QtWidgets, qundostack.h)
QT_CLASS_LIB(QUndoStack, QtWidgets, qundostack.h)
QT_CLASS_LIB(QUndoGroup, QtGui, qundogroup.h)
QT_CLASS_LIB(QUndoCommand, QtGui, qundostack.h)
QT_CLASS_LIB(QUndoStack, QtGui, qundostack.h)
QT_CLASS_LIB(QUndoView, QtWidgets, qundoview.h)
QT_CLASS_LIB(QAbstractButton, QtWidgets, qabstractbutton.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
)
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
SOURCES
util/qundoview.cpp util/qundoview.h

View File

@ -534,26 +534,6 @@ qt_feature("fscompleter" PUBLIC
CONDITION QT_FEATURE_filesystemmodel AND QT_FEATURE_completer
)
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
SECTION "Utilities"
LABEL "QUndoView"

View File

@ -633,26 +633,6 @@
"condition": "features.filesystemmodel && features.completer",
"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": {
"label": "QUndoView",
"purpose": "Provides a widget which shows the contents of an undo stack.",

View File

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

View File

@ -31,19 +31,6 @@ qtConfig(scroller) {
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) {
HEADERS += util/qundoview.h
SOURCES += util/qundoview.cpp

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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