diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 47d455dd55be855e4cc691c32f687f723d9247ee (patch) | |
tree | 52e236aaa2576bdb3840ebede26619692fed6d7d /kpovmodeler/pmdeletecommand.h | |
download | tdegraphics-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/pmdeletecommand.h')
-rw-r--r-- | kpovmodeler/pmdeletecommand.h | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/kpovmodeler/pmdeletecommand.h b/kpovmodeler/pmdeletecommand.h new file mode 100644 index 00000000..ff67c0bc --- /dev/null +++ b/kpovmodeler/pmdeletecommand.h @@ -0,0 +1,126 @@ +//-*-C++-*- +/* +************************************************************************** + description + -------------------- + copyright : (C) 2000-2001 by Andreas Zehender + email : [email protected] +************************************************************************** + +************************************************************************** +* * +* 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 PMDELETECOMMAND_H +#define PMDELETECOMMAND_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "pmcommand.h" +#include <qstring.h> + +#include "pmobject.h" + +class PMMemento; + +/** + * Class that stores undo information for the @ref PMDeleteCommand + */ +class PMDeleteInfo +{ +public: + /** + * Creates undo information for the object deletedObject. + * The object has to have a parent! + */ + PMDeleteInfo( PMObject* deletedObject ) + { + m_pDeletedObject = deletedObject; + m_pParent = deletedObject->parent( ); + m_pPrevSibling = deletedObject->prevSibling( ); + m_insertError = false; + } + /** + * Deletes the object. The object deletedObject will not be deleted! + */ + ~PMDeleteInfo( ) { }; + /** + * Returns a pointer to the deleted object + */ + PMObject* deletedObject( ) const { return m_pDeletedObject; } + /** + * Returns a pointer to the parent of the deleted object + */ + PMObject* parent( ) const { return m_pParent; } + /** + * Returns the previous sibling of the deleted object + */ + PMObject* prevSibling( ) const { return m_pPrevSibling; } + /** + * Returns true if this object could not be inserted in a move command + */ + bool insertError( ) const { return m_insertError; } + /** + * Sets the insert error flag + */ + void setInsertError( ) { m_insertError = true; } +private: + PMObject* m_pDeletedObject; + PMObject* m_pParent; + PMObject* m_pPrevSibling; + bool m_insertError; +}; + +typedef QPtrList<PMDeleteInfo> PMDeleteInfoList; +typedef QPtrListIterator<PMDeleteInfo> PMDeleteInfoListIterator; + +/** + * Command class for removing PMObjects + */ +class PMDeleteCommand : public PMCommand +{ +public: + /** + * Delete Command that removes the object obj. + */ + PMDeleteCommand( PMObject* obj ); + /** + * Command that deletes a list of PMObjects. The list has to be sorted! + */ + PMDeleteCommand( const PMObjectList& list ); + /** + * Deletes the command. The deleted object will be deleted, if removed + */ + virtual ~PMDeleteCommand( ); + + /** */ + virtual int errorFlags( PMPart* ); + +protected: + /** + * Executes the command and stores undo information + */ + virtual void execute( PMCommandManager* theManager ); + /** + * Undo the command + */ + virtual void undo( PMCommandManager* theManager ); + +private: + PMDeleteInfoList m_infoList; + bool m_executed, m_firstExecution; + PMObjectList m_links; + PMObjectList m_linkedDeclares; + bool m_linksCreated; + QPtrList<PMMemento> m_dataChanges; +}; + +#endif |