summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmcommandmanager.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit47d455dd55be855e4cc691c32f687f723d9247ee (patch)
tree52e236aaa2576bdb3840ebede26619692fed6d7d /kpovmodeler/pmcommandmanager.h
downloadtdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz
tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kpovmodeler/pmcommandmanager.h')
-rw-r--r--kpovmodeler/pmcommandmanager.h118
1 files changed, 118 insertions, 0 deletions
diff --git a/kpovmodeler/pmcommandmanager.h b/kpovmodeler/pmcommandmanager.h
new file mode 100644
index 00000000..2ef2fbbc
--- /dev/null
+++ b/kpovmodeler/pmcommandmanager.h
@@ -0,0 +1,118 @@
+//-*-C++-*-
+/*
+**************************************************************************
+ description
+ --------------------
+ copyright : (C) 2000-2001 by Andreas Zehender
+ email : zehender@kde.org
+**************************************************************************
+
+**************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+**************************************************************************/
+
+
+#ifndef PMCOMMANDMANAGER_H
+#define PMCOMMANDMANAGER_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "pmcommand.h"
+#include <qptrstack.h>
+#include <qobject.h>
+
+class PMPart;
+
+/**
+ * Manager for PMCommand objects.
+ *
+ * The class PMCommandManager stores stacks of commands for undo/redo
+ * operations.
+ */
+class PMCommandManager : public QObject
+{
+ Q_OBJECT
+public:
+ /**
+ * Creates a new PMCommandManager
+ */
+ PMCommandManager( PMPart* thepart );
+ /**
+ * Deletes the command manager. All commands are deleted as well.
+ */
+ ~PMCommandManager( );
+ /**
+ * Adds the @ref PMCommand to the command stack.
+ * All commands in the m_redoCommands stack are deleted.
+ */
+ void execute( PMCommand* cmd );
+ /**
+ * Moves the last command to the m_redoCommands stack.
+ */
+ void undo( );
+ /**
+ * Moves the last redo command to the command stack.
+ */
+ void redo( );
+ /**
+ * Deletes the commands
+ */
+ void clear( );
+ /**
+ * Returns the maximal number of items that can be undone/redone.
+ */
+ unsigned int maxUndoRedo( ) const { return m_maxUndoRedo; }
+ /**
+ * Sets the maximal number of items that can be undone/redone.
+ */
+ void setMaxUndoRedo( unsigned int n ) { m_maxUndoRedo = n; }
+ /**
+ * Called by an executed command. Will emit objectChanged( )
+ */
+ void cmdObjectChanged( PMObject* obj, const int mode );
+ /**
+ * Called by an executed command. Will emit idChanged( )
+ */
+ void cmdIDChanged( PMObject* obj, const QString& oldID );
+ /**
+ * Returns a pointer to the part. For commands that need to access the
+ * part directly.
+ */
+ PMPart* part( ) const { return m_pPart; }
+signals:
+ /**
+ * emmited, when the undo and redo command texts change
+ */
+ void updateUndoRedo( const QString& undo, const QString& redo );
+ /**
+ * Signal that is emitted when an object is changed.
+ * Mode is a bit combination of @ref PMChange constants.
+ */
+ void objectChanged( PMObject* obj, const int mode, QObject* sender );
+ /**
+ * Signal that is emitted when the id of the object is changed
+ */
+ void idChanged( PMObject* obj, const QString& oldID );
+private:
+ /**
+ * The executed commands.
+ */
+ PMCommandList m_commands;
+ /**
+ * The undone commands.
+ */
+ PMCommandList m_redoCommands;
+ // the maximal number of items that can be undone/redone.
+ unsigned int m_maxUndoRedo;
+ PMObject* m_pLastChangedObject;
+ PMPart* m_pPart;
+};
+
+#endif