diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-10-26 11:36:02 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-10-31 18:55:25 +0000 |
commit | e8bf10fb3aff47ed5dbf32431853194b1f311572 (patch) | |
tree | b4ea27caeb17301f06240c41880de208f0424567 | |
parent | 57c5131233a9d489883783eb14913c7e1189d602 (diff) | |
download | qttools-e8bf10fb3aff47ed5dbf32431853194b1f311572.tar.gz |
Qt Designer: Remove class QDesignerUndoStack
The class emulated setDirty() functionality which was now introduced
to QUndoStack as resetClean().
Change-Id: I11be2f6d746713ae872c8dc8705acc32c88f9ec8
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
5 files changed, 11 insertions, 193 deletions
diff --git a/src/designer/src/components/formeditor/formeditor.pri b/src/designer/src/components/formeditor/formeditor.pri index 6b5156157..7e4afd021 100644 --- a/src/designer/src/components/formeditor/formeditor.pri +++ b/src/designer/src/components/formeditor/formeditor.pri @@ -8,7 +8,6 @@ FORMS += $$PWD/deviceprofiledialog.ui \ $$PWD/templateoptionspage.ui HEADERS += $$PWD/qdesigner_resource.h \ - $$PWD/qdesignerundostack.h \ $$PWD/formwindow.h \ $$PWD/formwindow_widgetstack.h \ $$PWD/formwindow_dnditem.h \ @@ -38,7 +37,6 @@ HEADERS += $$PWD/qdesigner_resource.h \ $$PWD/templateoptionspage.h SOURCES += $$PWD/qdesigner_resource.cpp \ - $$PWD/qdesignerundostack.cpp \ $$PWD/formwindow.cpp \ $$PWD/formwindow_widgetstack.cpp \ $$PWD/formwindow_dnditem.cpp \ diff --git a/src/designer/src/components/formeditor/formwindow.cpp b/src/designer/src/components/formeditor/formwindow.cpp index ba6712103..162f5d0e3 100644 --- a/src/designer/src/components/formeditor/formwindow.cpp +++ b/src/designer/src/components/formeditor/formwindow.cpp @@ -384,7 +384,7 @@ void FormWindow::setCursorToAll(const QCursor &c, QWidget *start) void FormWindow::init() { if (FormWindowManager *manager = qobject_cast<FormWindowManager*> (core()->formWindowManager())) { - manager->undoGroup()->addStack(m_undoStack.qundoStack()); + manager->undoGroup()->addStack(&m_undoStack); } m_blockSelectionChanged = false; @@ -417,9 +417,9 @@ void FormWindow::init() m_mainContainer = 0; m_currentWidget = 0; - connect(&m_undoStack, &QDesignerUndoStack::changed, + connect(&m_undoStack, &QUndoStack::cleanChanged, this, &QDesignerFormWindowInterface::changed); - connect(&m_undoStack, &QDesignerUndoStack::changed, + connect(&m_undoStack, &QUndoStack::cleanChanged, this, &FormWindow::checkSelection); core()->metaDataBase()->add(this); @@ -2439,12 +2439,15 @@ FormWindow *FormWindow::findFormWindow(QWidget *w) bool FormWindow::isDirty() const { - return m_undoStack.isDirty(); + return !m_undoStack.isClean(); } void FormWindow::setDirty(bool dirty) { - m_undoStack.setDirty(dirty); + if (dirty) + m_undoStack.resetClean(); + else + m_undoStack.setClean(); } QWidget *FormWindow::containerAt(const QPoint &pos) @@ -2979,7 +2982,7 @@ QWidget *FormWindow::formContainer() const QUndoStack *FormWindow::commandHistory() const { - return const_cast<QDesignerUndoStack &>(m_undoStack).qundoStack(); + return &const_cast<QUndoStack &>(m_undoStack); } } // namespace diff --git a/src/designer/src/components/formeditor/formwindow.h b/src/designer/src/components/formeditor/formwindow.h index 9fd3e2cd4..c577fe1ab 100644 --- a/src/designer/src/components/formeditor/formwindow.h +++ b/src/designer/src/components/formeditor/formwindow.h @@ -30,10 +30,10 @@ #define FORMWINDOW_H #include "formeditor_global.h" -#include "qdesignerundostack.h" #include <formwindowbase_p.h> // Qt +#include <QtWidgets/QUndoStack> #include <QtCore/QHash> #include <QtCore/QList> #include <QtCore/QMap> @@ -325,7 +325,7 @@ private: QPoint m_startPos; - QDesignerUndoStack m_undoStack; + QUndoStack m_undoStack; QString m_fileName; diff --git a/src/designer/src/components/formeditor/qdesignerundostack.cpp b/src/designer/src/components/formeditor/qdesignerundostack.cpp deleted file mode 100644 index 5e6f13581..000000000 --- a/src/designer/src/components/formeditor/qdesignerundostack.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdesignerundostack.h" - -#include <QtWidgets/QUndoStack> -#include <QtWidgets/QUndoCommand> - -QT_BEGIN_NAMESPACE - -namespace qdesigner_internal { - -QDesignerUndoStack::QDesignerUndoStack(QObject *parent) : - QObject(parent), - m_undoStack(new QUndoStack), - m_fakeDirty(false) -{ - connect(m_undoStack, &QUndoStack::indexChanged, this, &QDesignerUndoStack::changed); -} - -QDesignerUndoStack::~QDesignerUndoStack() -{ // QUndoStack is managed by the QUndoGroup -} - -void QDesignerUndoStack::clear() -{ - m_fakeDirty = false; - m_undoStack->clear(); -} - -void QDesignerUndoStack::push(QUndoCommand * cmd) -{ - m_undoStack->push(cmd); -} - -void QDesignerUndoStack::beginMacro(const QString &text) -{ - m_undoStack->beginMacro(text); -} - -void QDesignerUndoStack::endMacro() -{ - m_undoStack->endMacro(); -} - -int QDesignerUndoStack::index() const -{ - return m_undoStack->index(); -} - -const QUndoStack *QDesignerUndoStack::qundoStack() const -{ - return m_undoStack; -} -QUndoStack *QDesignerUndoStack::qundoStack() -{ - return m_undoStack; -} - -bool QDesignerUndoStack::isDirty() const -{ - return m_fakeDirty || !m_undoStack->isClean(); -} - -void QDesignerUndoStack::setDirty(bool v) -{ - if (isDirty() == v) - return; - if (v) { - m_fakeDirty = true; - emit changed(); - } else { - m_fakeDirty = false; - m_undoStack->setClean(); - } -} - -} // namespace qdesigner_internal - -QT_END_NAMESPACE diff --git a/src/designer/src/components/formeditor/qdesignerundostack.h b/src/designer/src/components/formeditor/qdesignerundostack.h deleted file mode 100644 index 4ecf16cc8..000000000 --- a/src/designer/src/components/formeditor/qdesignerundostack.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDESIGNERUNDOSTACK_H -#define QDESIGNERUNDOSTACK_H - -#include <QtCore/QObject> - -QT_BEGIN_NAMESPACE -class QUndoStack; -class QUndoCommand; - -namespace qdesigner_internal { - -/* QDesignerUndoStack: A QUndoStack extended by a way of setting it to - * "dirty" indepently of commands (by modifications without commands - * such as resizing). Accomplished via bool m_fakeDirty flag. The - * lifecycle of the QUndoStack is managed by the QUndoGroup. */ -class QDesignerUndoStack : public QObject -{ - Q_DISABLE_COPY(QDesignerUndoStack) - Q_OBJECT -public: - explicit QDesignerUndoStack(QObject *parent = 0); - virtual ~QDesignerUndoStack(); - - void clear(); - void push(QUndoCommand * cmd); - void beginMacro(const QString &text); - void endMacro(); - int index() const; - - const QUndoStack *qundoStack() const; - QUndoStack *qundoStack(); - - bool isDirty() const; - -signals: - void changed(); - -public slots: - void setDirty(bool); - -private: - QUndoStack *m_undoStack; - bool m_fakeDirty; -}; - -} // namespace qdesigner_internal - -QT_END_NAMESPACE - -#endif // QDESIGNERUNDOSTACK_H |