From 47d455dd55be855e4cc691c32f687f723d9247ee Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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 --- kpovmodeler/pmdeletecommand.h | 126 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 kpovmodeler/pmdeletecommand.h (limited to 'kpovmodeler/pmdeletecommand.h') 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 : 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 PMDELETECOMMAND_H +#define PMDELETECOMMAND_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "pmcommand.h" +#include + +#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 PMDeleteInfoList; +typedef QPtrListIterator 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 m_dataChanges; +}; + +#endif -- cgit v1.2.1