You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdeadmin/ksysv/ActionList.h

133 lines
2.9 KiB

/***************************************************************************
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 <tqptrstack.h>
#include <tqobject.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 TQObject, private TQPtrStack<KSVAction>
{
Q_OBJECT
TQ_OBJECT
public:
ActionList (TQObject* tqparent, const char* name);
virtual ~ActionList ();
KSVAction* top () const { return TQPtrStack<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