From fe25a3332d643273821bcfb298380c749fb56073 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Tue, 13 Mar 2012 02:20:26 +0300 Subject: [PATCH] Added: #1450 Added multiple undo stacks per context. --- .../src/plugins/core/context_manager.cpp | 17 +++++++++++++++++ .../src/plugins/core/context_manager.h | 6 ++++++ .../src/plugins/core/core_constants.h | 2 +- .../src/plugins/core/main_window.cpp | 13 +++++++++++-- .../src/plugins/core/main_window.h | 3 ++- 5 files changed, 37 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.cpp index 68e28429d..d82cdb63b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.cpp @@ -78,6 +78,18 @@ Core::IContext *ContextManager::context(const QString &id) const return 0; } +void ContextManager::registerUndoStack(QUndoStack *stack) +{ + nlassert(stack); + d->m_mainWindow->undoGroup()->addStack(stack); +} + +void ContextManager::unregisterUndoStack(QUndoStack *stack) +{ + nlassert(stack); + d->m_mainWindow->undoGroup()->removeStack(stack); +} + void ContextManager::activateContext(const QString &id) { const int index = indexOf(id); @@ -85,6 +97,11 @@ void ContextManager::activateContext(const QString &id) d->m_tabWidget->setCurrentIndex(index); } +void ContextManager::updateCurrentContext() +{ + d->m_mainWindow->updateContext(currentContext()); +} + void ContextManager::objectAdded(QObject *obj) { IContext *context = qobject_cast(obj); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.h index 7a3658fff..8151648e7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.h @@ -26,6 +26,7 @@ QT_BEGIN_NAMESPACE class QTabWidget; +class QUndoStack; QT_END_NAMESPACE namespace Core @@ -45,12 +46,17 @@ public: Core::IContext *currentContext() const; Core::IContext *context(const QString &id) const; + // temporary solution for multiple undo stacks per context + void registerUndoStack(QUndoStack *stack); + void unregisterUndoStack(QUndoStack *stack); + Q_SIGNALS: // the default argument '=0' is important for connects without the oldContext argument. void currentContextChanged(Core::IContext *context, Core::IContext *oldContext = 0); public Q_SLOTS: void activateContext(const QString &id); + void updateCurrentContext(); private Q_SLOTS: void objectAdded(QObject *obj); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_constants.h index 6eb7d41f4..18f3690a0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/core_constants.h @@ -92,7 +92,7 @@ const char *const SEARCH_PATHS = "SearchPaths"; const char *const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes"; const char *const LEVELDESIGN_PATH = "LevelDesignPath"; const char *const PRIMITIVES_PATH = "PrimitivesPath"; -const char * const ASSETS_PATH = "AssetsPath"; +const char *const ASSETS_PATH = "AssetsPath"; const char *const LIGOCONFIG_FILE = "LigoConfigFile"; const char *const REMAP_EXTENSIONS = "RemapExtensions"; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp index f00075b21..6e409e75d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp @@ -128,6 +128,11 @@ QSettings *MainWindow::settings() const return m_settings; } +QUndoGroup *MainWindow::undoGroup() const +{ + return m_undoGroup; +} + ExtensionSystem::IPluginManager *MainWindow::pluginManager() const { return m_pluginManager; @@ -135,12 +140,16 @@ ExtensionSystem::IPluginManager *MainWindow::pluginManager() const void MainWindow::addContextObject(IContext *context) { - m_undoGroup->addStack(context->undoStack()); + QUndoStack *stack = context->undoStack(); + if (stack) + m_undoGroup->addStack(stack); } void MainWindow::removeContextObject(IContext *context) { - m_undoGroup->removeStack(context->undoStack()); + QUndoStack *stack = context->undoStack(); + if (stack) + m_undoGroup->removeStack(stack); } void MainWindow::open() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h index ae0d0522c..a75126823 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h @@ -52,6 +52,7 @@ public: MenuManager *menuManager() const; ContextManager *contextManager() const; QSettings *settings() const; + QUndoGroup *undoGroup() const; ExtensionSystem::IPluginManager *pluginManager() const; @@ -62,6 +63,7 @@ public Q_SLOTS: bool showOptionsDialog(const QString &group = QString(), const QString &page = QString(), QWidget *parent = 0); + void updateContext(Core::IContext *context); private Q_SLOTS: void open(); @@ -77,7 +79,6 @@ private Q_SLOTS: void gotoPos(); void setFullScreen(bool enabled); void about(); - void updateContext(Core::IContext *context); protected: virtual void closeEvent(QCloseEvent *event);