summaryrefslogtreecommitdiffstats
path: root/ksysv/ActionList.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
commit37333bf25ad9a4c538250f5af2f9f1d666362883 (patch)
treec45e8df5b9efbffe07eb3d9340df7811c7e16943 /ksysv/ActionList.h
downloadtdeadmin-37333bf25ad9a4c538250f5af2f9f1d666362883.tar.gz
tdeadmin-37333bf25ad9a4c538250f5af2f9f1d666362883.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/kdeadmin@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksysv/ActionList.h')
-rw-r--r--ksysv/ActionList.h131
1 files changed, 131 insertions, 0 deletions
diff --git a/ksysv/ActionList.h b/ksysv/ActionList.h
new file mode 100644
index 0000000..f420b48
--- /dev/null
+++ b/ksysv/ActionList.h
@@ -0,0 +1,131 @@
+/***************************************************************************
+ begin : Sun Oct 3 1999
+ copyright : (C) 1997-99 by Peter Putzer
+ email : putzer@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; version 2. *
+ * *
+ ***************************************************************************/
+
+#ifndef KSV_ACTIONLIST_H
+#define KSV_ACTIONLIST_H
+
+#include <qptrstack.h>
+#include <qobject.h>
+
+class KSVData;
+class KSVDragList;
+
+class KSVAction
+{
+public:
+ KSVAction ();
+ virtual ~KSVAction () = 0;
+
+ virtual void undo () = 0;
+ virtual void redo() = 0;
+
+private:
+ const KSVAction& operator= (const KSVAction&); // undefined
+ KSVAction (const KSVAction&); // undefined
+};
+
+class SimpleAction : public KSVAction
+{
+public:
+ SimpleAction (KSVDragList* source, const KSVData* item);
+ virtual ~SimpleAction();
+
+ inline KSVDragList* source() { return mSource; }
+ inline KSVData* item() { return mItem; }
+
+ virtual void undo() = 0;
+ virtual void redo() = 0;
+
+private:
+ KSVDragList* mSource;
+ KSVData* mItem;
+};
+
+class RemoveAction : public SimpleAction
+{
+public:
+ RemoveAction (KSVDragList* s, const KSVData* i);
+ virtual ~RemoveAction();
+
+ virtual void undo();
+ virtual void redo();
+};
+
+class AddAction : public SimpleAction
+{
+public:
+ AddAction (KSVDragList* s, const KSVData* i);
+ virtual ~AddAction();
+
+ virtual void undo();
+ virtual void redo();
+};
+
+class ChangeAction : public SimpleAction
+{
+public:
+ ChangeAction (KSVDragList* s, const KSVData* oldState, const KSVData* newState);
+ virtual ~ChangeAction();
+
+ virtual void undo();
+ virtual void redo();
+
+ inline KSVData* newState() { return mNew; }
+ inline KSVData* oldState() { return item(); }
+private:
+ KSVData* mNew;
+};
+
+class CompoundAction : public KSVAction
+{
+public:
+ CompoundAction (KSVAction*[], int nr);
+ virtual ~CompoundAction();
+
+ virtual void undo();
+ virtual void redo();
+
+private:
+ KSVAction** mActions;
+ int mCount;
+};
+
+
+
+class ActionList : public QObject, private QPtrStack<KSVAction>
+{
+ Q_OBJECT
+
+public:
+ ActionList (QObject* parent, const char* name);
+ virtual ~ActionList ();
+
+ KSVAction* top () const { return QPtrStack<KSVAction>::top(); }
+
+public slots:
+ void undoLast ();
+ void undoAll ();
+ void redoLast ();
+ void redoAll ();
+ void push (KSVAction*);
+ void clear ();
+
+signals:
+ void undone ();
+ void empty ();
+ void filled ();
+};
+
+#endif
+