/*************************************************************************** * * * 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. * * * ***************************************************************************/ /* Author: Christian Hubinger , (C) 2001-2008 */ #ifndef KMFUNDOENGINE_H #define KMFUNDOENGINE_H // qt includes #include "tqdict.h" #include "tqvaluelist.h" #include "tqptrlist.h" #include "tqstring.h" #include "tqobject.h" // project includes #include "kmftransaction.h" #include "netfilterobject.h" // #include "kmfnetwork.h" #include "kmferror.h" namespace KMF { class KMyFirewallInterface; class KMFTransaction; class KMFNetwork; /** @author Christian Hubinger */ class KMFUndoEngine : public TQObject { Q_OBJECT TQ_OBJECT friend class KMFTransaction; friend class KMFNetwork; friend class KMFProtocol; friend class KMFProtocolCategory; friend class KMFProtocolLibrary; //############# Beginn static stuff ############## public: /** return the one and only instance */ static KMFUndoEngine* instance(); private: static KMFUndoEngine* m_instance; //############# End static stuff ############## protected: uint MAX_UNDO; public: ~KMFUndoEngine(); /** Set the numbers of undo/redo steps stored */ void setMaxUndo( uint ); /** Get the numbers of undo/redo steps stored */ uint maxUndo() { return MAX_UNDO; }; /** Start a transaction e.g. collection of changes that will be tracked to allow undo/redo */ void startTransaction( NetfilterObject* /* highestAffectedObject */, const TQString& name ); /** Abort a started transaction */ void abortTransaction(); /** Hold list of available undo transaction objects */ TQValueList< KMFTransaction* >& undoTransactions(); /** Hold list of available redo transaction objects */ TQValueList< KMFTransaction* >& redoTransactions(); /** find the transaction with id in undo/redo lists */ KMFTransaction * findTransction( const TQUuid& id ); /** End a transaction e.g. collection of changes that will be tracked to allow undo/redo */ void endTransaction(); /** Check if we are inside a transaction */ bool inTransaction(); /** store the provided id in the changes list. */ void changed( const TQUuid& id ); /** Remove all stored transacation */ void clearStacks(); /** Check if the doc is saved */ bool isSaved(); void saved(); /** Undo last transaction, return list of affected objects */ TQValueList< NetfilterObject* >& undo(); /** Redo last undo-transaction, return list of affected objects */ TQValueList< NetfilterObject* >& redo(); /** Set the ap instance */ void setKMFInterface( KMyFirewallInterface *app ); /** log message entry */ void log( const TQString&, int kmfErrorType /* = KMFError::NORMAL */, NetfilterObject* /* obj = 0 */ ); // bool preserveObjectUuid() const { // // return m_preserveObjectUuid; // return true; // } protected: KMyFirewallInterface *m_app; private: // TQString m_transactionName; bool m_in_transaction; bool is_saved; // bool m_preserveObjectUuid; TQValueList< KMFTransaction* > m_undo_transactionObjects; TQValueList< KMFTransaction* > m_redo_transactionObjects; // TQValueList m_changed_objects; // NetfilterObject *m_highestAffectedObject; KMFTransaction *m_currentTransaction; private: KMFUndoEngine(); KMFUndoEngine( TQObject*, const char* ); /** Make the loadXML in NEtfilterObject load the uuid from xml */ // void setPreserveObjectUuid( bool onOff ); signals: void sigStackChanged(); void sigLog( const TQString& ); }; } #endif