21#include "vreplacingcmd.h"
22#include "vselection.h"
33VReplacingCmd::~VReplacingCmd()
35 delete( m_oldObjects );
36 delete( m_newObjects );
44 bool successful =
false;
55 VObjectListIterator itr( m_oldObjects->objects() );
58 for( ; itr.current(); ++itr )
61 newObject = itr.current()->
clone();
64 if(
visit( *newObject ) )
69 itr.current()->parent()->insertInfrontOf(
70 newObject, itr.current() );
73 m_newObjects->append( newObject );
78 rejects.append( itr.current() );
83 VObjectListIterator jtr( rejects );
84 for( ; jtr.current(); ++jtr )
87 m_oldObjects->take( *jtr.current() );
92 if( m_newObjects->objects().count() == 0 )
96 VObjectListIterator itr( m_oldObjects->objects() );
99 for( ; itr.current(); ++itr )
106 for( itr = m_newObjects->objects(); itr.current(); ++itr )
121 if( m_newObjects->objects().count() == 0 )
125 VObjectListIterator itr( m_oldObjects->objects() );
128 for( ; itr.current(); ++itr )
135 for( itr = m_newObjects->objects(); itr.current(); ++itr )
VDocument * document() const
Returns the document the command works on.
TQString name() const
Returns the name of the command.
VCommand(VDocument *doc, const TQString &name, const TQString &icon="14_action")
Constructs a new command.
All non-visual, static doc info is in here.
VSelection * selection() const
Returns a pointer to the selection.
The base class for all karbon objects.
virtual VObject * clone() const =0
Create an exact copy of this object.
@ deleted
deleted, nearly dead
@ normal
visible, not active
virtual void execute()
Executes the command.
VReplacingCmd(VDocument *doc, const TQString &name)
Make it "abstract".
virtual void unexecute()
Unexecutes the command.
VSelection manages a set of selected vobjects.
void append()
Adds all objects to the selection.
virtual VSelection * clone() const
Create an exact copy of this object.
void take(VObject &object)
Removes the reference to the object, not the object itself.
virtual bool visit(VObject &object)
General visit method.
void setSuccess(bool success=true)
Set the success property.