diff --git a/examples/widgets/doc/src/undoframework.qdoc b/examples/widgets/doc/src/undoframework.qdoc index 881fa452064..b4e6f3685d9 100644 --- a/examples/widgets/doc/src/undoframework.qdoc +++ b/examples/widgets/doc/src/undoframework.qdoc @@ -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 diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 700b06fe11b..efa7b1c41fd 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -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 diff --git a/src/gui/configure.cmake b/src/gui/configure.cmake index 45ca061ed75..eb7d2b5549e 100644 --- a/src/gui/configure.cmake +++ b/src/gui/configure.cmake @@ -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" diff --git a/src/gui/configure.json b/src/gui/configure.json index 500251a2806..cf33408991e 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -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" ] } }, diff --git a/src/widgets/util/qundogroup.cpp b/src/gui/util/qundogroup.cpp similarity index 91% rename from src/widgets/util/qundogroup.cpp rename to src/gui/util/qundogroup.cpp index ae439743bc5..2f4c81b046f 100644 --- a/src/widgets/util/qundogroup.cpp +++ b/src/gui/util/qundogroup.cpp @@ -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 diff --git a/src/widgets/util/qundogroup.h b/src/gui/util/qundogroup.h similarity index 89% rename from src/widgets/util/qundogroup.h rename to src/gui/util/qundogroup.h index 1845f7e0575..ef5b053610f 100644 --- a/src/widgets/util/qundogroup.h +++ b/src/gui/util/qundogroup.h @@ -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 +#include #include #include @@ -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; diff --git a/src/widgets/util/qundostack.cpp b/src/gui/util/qundostack.cpp similarity index 95% rename from src/widgets/util/qundostack.cpp rename to src/gui/util/qundostack.cpp index 8974f11a138..f7b50243890 100644 --- a/src/widgets/util/qundostack.cpp +++ b/src/gui/util/qundostack.cpp @@ -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) diff --git a/src/widgets/util/qundostack.h b/src/gui/util/qundostack.h similarity index 91% rename from src/widgets/util/qundostack.h rename to src/gui/util/qundostack.h index b5716b2e9b9..c137e7d9429 100644 --- a/src/widgets/util/qundostack.h +++ b/src/gui/util/qundostack.h @@ -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 +#include #include #include @@ -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; diff --git a/src/widgets/util/qundostack_p.h b/src/gui/util/qundostack_p.h similarity index 79% rename from src/widgets/util/qundostack_p.h rename to src/gui/util/qundostack_p.h index efe0ceeef86..5f2c438a838 100644 --- a/src/widgets/util/qundostack_p.h +++ b/src/gui/util/qundostack_p.h @@ -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 +#include #include #include #include @@ -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) diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri index d3402133d62..a799c3e591f 100644 --- a/src/gui/util/util.pri +++ b/src/gui/util/util.pri @@ -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 +} diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h index e6b450cdeae..456101c2e79 100644 --- a/src/tools/uic/qclass_lib_map.h +++ b/src/tools/uic/qclass_lib_map.h @@ -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) diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 9730b787bed..8b2f599a604 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -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 diff --git a/src/widgets/configure.cmake b/src/widgets/configure.cmake index 9d79ddb7887..7c8f7128899 100644 --- a/src/widgets/configure.cmake +++ b/src/widgets/configure.cmake @@ -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" diff --git a/src/widgets/configure.json b/src/widgets/configure.json index cab120098ae..6634ca0059a 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -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.", diff --git a/src/widgets/util/qundoview.cpp b/src/widgets/util/qundoview.cpp index a39276a2b8d..a823c005c11 100644 --- a/src/widgets/util/qundoview.cpp +++ b/src/widgets/util/qundoview.cpp @@ -37,12 +37,12 @@ ** ****************************************************************************/ -#include "qundostack.h" #include "qundoview.h" #if QT_CONFIG(undogroup) -#include "qundogroup.h" +#include #endif +#include #include #include #include diff --git a/src/widgets/util/util.pri b/src/widgets/util/util.pri index 363291528ef..2819ac565a3 100644 --- a/src/widgets/util/util.pri +++ b/src/widgets/util/util.pri @@ -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 diff --git a/tests/auto/gui/util/CMakeLists.txt b/tests/auto/gui/util/CMakeLists.txt index 1c4a53265d8..4feae268180 100644 --- a/tests/auto/gui/util/CMakeLists.txt +++ b/tests/auto/gui/util/CMakeLists.txt @@ -10,3 +10,5 @@ add_subdirectory(qshadergraphloader) add_subdirectory(qshadernodes) add_subdirectory(qshadernodesloader) add_subdirectory(qtexturefilereader) +add_subdirectory(qundogroup) +add_subdirectory(qundostack) diff --git a/tests/auto/widgets/util/qundogroup/.gitignore b/tests/auto/gui/util/qundogroup/.gitignore similarity index 100% rename from tests/auto/widgets/util/qundogroup/.gitignore rename to tests/auto/gui/util/qundogroup/.gitignore diff --git a/tests/auto/widgets/util/qundogroup/CMakeLists.txt b/tests/auto/gui/util/qundogroup/CMakeLists.txt similarity index 93% rename from tests/auto/widgets/util/qundogroup/CMakeLists.txt rename to tests/auto/gui/util/qundogroup/CMakeLists.txt index 600a7d7da1f..3325556a3ea 100644 --- a/tests/auto/widgets/util/qundogroup/CMakeLists.txt +++ b/tests/auto/gui/util/qundogroup/CMakeLists.txt @@ -9,5 +9,4 @@ add_qt_test(tst_qundogroup tst_qundogroup.cpp PUBLIC_LIBRARIES Qt::Gui - Qt::Widgets ) diff --git a/tests/auto/widgets/util/qundogroup/qundogroup.pro b/tests/auto/gui/util/qundogroup/qundogroup.pro similarity index 76% rename from tests/auto/widgets/util/qundogroup/qundogroup.pro rename to tests/auto/gui/util/qundogroup/qundogroup.pro index bd8dac197b5..fbae5572073 100644 --- a/tests/auto/widgets/util/qundogroup/qundogroup.pro +++ b/tests/auto/gui/util/qundogroup/qundogroup.pro @@ -1,4 +1,4 @@ CONFIG += testcase -QT += widgets testlib +QT += testlib SOURCES += tst_qundogroup.cpp TARGET = tst_qundogroup diff --git a/tests/auto/widgets/util/qundogroup/testdata/qundogroup.ts b/tests/auto/gui/util/qundogroup/testdata/qundogroup.ts similarity index 100% rename from tests/auto/widgets/util/qundogroup/testdata/qundogroup.ts rename to tests/auto/gui/util/qundogroup/testdata/qundogroup.ts diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp similarity index 98% rename from tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp rename to tests/auto/gui/util/qundogroup/tst_qundogroup.cpp index c1524d870dc..ba238105ec8 100644 --- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp +++ b/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp @@ -359,8 +359,8 @@ static QString glue(const QString &s1, const QString &s2) void tst_QUndoGroup::checkSignals() { QUndoGroup group; - const QScopedPointer undo_action(group.createUndoAction(0, QString("foo"))); - const QScopedPointer redo_action(group.createRedoAction(0, QString("bar"))); + QScopedPointer undo_action(group.createUndoAction(nullptr, QString("foo"))); + QScopedPointer 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 undo_action(group.createUndoAction(0)); - const QScopedPointer redo_action(group.createRedoAction(0)); + QScopedPointer undo_action(group.createUndoAction(nullptr)); + QScopedPointer redo_action(group.createRedoAction(nullptr)); QCOMPARE(undo_action->text(), QString("Undo-default-text")); QCOMPARE(redo_action->text(), QString("Redo-default-text")); diff --git a/tests/auto/widgets/util/qundostack/.gitignore b/tests/auto/gui/util/qundostack/.gitignore similarity index 100% rename from tests/auto/widgets/util/qundostack/.gitignore rename to tests/auto/gui/util/qundostack/.gitignore diff --git a/tests/auto/widgets/util/qundostack/CMakeLists.txt b/tests/auto/gui/util/qundostack/CMakeLists.txt similarity index 93% rename from tests/auto/widgets/util/qundostack/CMakeLists.txt rename to tests/auto/gui/util/qundostack/CMakeLists.txt index 5fc049991f8..d6cf36187ec 100644 --- a/tests/auto/widgets/util/qundostack/CMakeLists.txt +++ b/tests/auto/gui/util/qundostack/CMakeLists.txt @@ -9,5 +9,4 @@ add_qt_test(tst_qundostack tst_qundostack.cpp PUBLIC_LIBRARIES Qt::Gui - Qt::Widgets ) diff --git a/tests/auto/widgets/util/qundostack/qundostack.pro b/tests/auto/gui/util/qundostack/qundostack.pro similarity index 76% rename from tests/auto/widgets/util/qundostack/qundostack.pro rename to tests/auto/gui/util/qundostack/qundostack.pro index 294debb51c8..bbade9635f6 100644 --- a/tests/auto/widgets/util/qundostack/qundostack.pro +++ b/tests/auto/gui/util/qundostack/qundostack.pro @@ -1,4 +1,4 @@ CONFIG += testcase -QT += widgets testlib +QT += gui testlib SOURCES += tst_qundostack.cpp TARGET = tst_qundostack diff --git a/tests/auto/widgets/util/qundostack/testdata/qundostack.ts b/tests/auto/gui/util/qundostack/testdata/qundostack.ts similarity index 100% rename from tests/auto/widgets/util/qundostack/testdata/qundostack.ts rename to tests/auto/gui/util/qundostack/testdata/qundostack.ts diff --git a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp b/tests/auto/gui/util/qundostack/tst_qundostack.cpp similarity index 98% rename from tests/auto/widgets/util/qundostack/tst_qundostack.cpp rename to tests/auto/gui/util/qundostack/tst_qundostack.cpp index f3185086b88..a24798cba7f 100644 --- a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp +++ b/tests/auto/gui/util/qundostack/tst_qundostack.cpp @@ -387,8 +387,8 @@ static void checkState(QSignalSpy &redoTextChangedSpy, void tst_QUndoStack::undoRedo() { QUndoStack stack; - const QScopedPointer undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer redoAction(stack.createRedoAction(0, QString("bar"))); + QScopedPointer undoAction(stack.createUndoAction(nullptr, QString("foo"))); + QScopedPointer 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 undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer redoAction(stack.createRedoAction(0, QString("bar"))); + QScopedPointer undoAction(stack.createUndoAction(nullptr, QString("foo"))); + QScopedPointer 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 undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer redoAction(stack.createRedoAction(0, QString("bar"))); + QScopedPointer undoAction(stack.createUndoAction(nullptr, QString("foo"))); + QScopedPointer 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 undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer redoAction(stack.createRedoAction(0, QString("bar"))); + QScopedPointer undoAction(stack.createUndoAction(nullptr, QString("foo"))); + QScopedPointer 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 undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer redoAction(stack.createRedoAction(0, QString("bar"))); + QScopedPointer undoAction(stack.createUndoAction(nullptr, QString("foo"))); + QScopedPointer 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 undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer redoAction(stack.createRedoAction(0, QString("bar"))); + QScopedPointer undoAction(stack.createUndoAction(nullptr, QString("foo"))); + QScopedPointer 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 undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer redoAction(stack.createRedoAction(0, QString("bar"))); + QScopedPointer undoAction(stack.createUndoAction(nullptr, QString("foo"))); + QScopedPointer 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 undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer redoAction(stack.createRedoAction(0, QString("bar"))); + QScopedPointer undoAction(stack.createUndoAction(nullptr, QString("foo"))); + QScopedPointer 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 undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer redoAction(stack.createRedoAction(0, QString("bar"))); + QScopedPointer undoAction(stack.createUndoAction(nullptr, QString("foo"))); + QScopedPointer 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 undo_action(stack.createUndoAction(0)); - const QScopedPointer redo_action(stack.createRedoAction(0)); + QScopedPointer undo_action(stack.createUndoAction(nullptr)); + QScopedPointer 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 undo_action(stack.createUndoAction(0)); - const QScopedPointer redo_action(stack.createRedoAction(0)); + QScopedPointer undo_action(stack.createUndoAction(nullptr)); + QScopedPointer redo_action(stack.createRedoAction(nullptr)); QUndoCommand *command1 = new IdleCommand(); QUndoCommand *command2 = new IdleCommand(); diff --git a/tests/auto/gui/util/util.pro b/tests/auto/gui/util/util.pro index 961424cc353..7523e01ca4e 100644 --- a/tests/auto/gui/util/util.pro +++ b/tests/auto/gui/util/util.pro @@ -9,4 +9,6 @@ SUBDIRS= \ qshadergraphloader \ qshadernodes \ qshadernodesloader \ - qtexturefilereader + qtexturefilereader \ + qundogroup \ + qundostack diff --git a/tests/auto/widgets/util/CMakeLists.txt b/tests/auto/widgets/util/CMakeLists.txt index 0372282e7b2..20accb31505 100644 --- a/tests/auto/widgets/util/CMakeLists.txt +++ b/tests/auto/widgets/util/CMakeLists.txt @@ -3,5 +3,3 @@ add_subdirectory(qcompleter) add_subdirectory(qscroller) add_subdirectory(qsystemtrayicon) -add_subdirectory(qundogroup) -add_subdirectory(qundostack) diff --git a/tests/auto/widgets/util/util.pro b/tests/auto/widgets/util/util.pro index 33f28450019..66d2a288eed 100644 --- a/tests/auto/widgets/util/util.pro +++ b/tests/auto/widgets/util/util.pro @@ -2,6 +2,4 @@ TEMPLATE=subdirs SUBDIRS=\ qcompleter \ qscroller \ - qsystemtrayicon \ - qundogroup \ - qundostack \ + qsystemtrayicon