mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 04:51:52 +00:00
Added: #1450 Added multiple undo stacks per context.
This commit is contained in:
parent
5bbff4201d
commit
ed26ebc3ec
5 changed files with 37 additions and 4 deletions
|
@ -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<IContext *>(obj);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue