Commit 30a75c96 authored by Jan Hambrecht's avatar Jan Hambrecht
Browse files

* implement the KoShapeDeleteCommand (not yet tested)

* todo: it needs to be aware of refCounters of the shapes backend when we have them


svn path=/trunk/koffice/; revision=545368
parent 834cd1e7
......@@ -188,3 +188,50 @@ void KoShapeCreateCommand::unexecute () {
QString KoShapeCreateCommand::name () const {
return "Create shape";
}
KoShapeDeleteCommand::KoShapeDeleteCommand( KoShapeControllerInterface *controller, KoShape *shape )
: m_controller( controller )
, m_deleteShapes( false )
{
m_shapes.append( shape );
}
KoShapeDeleteCommand::KoShapeDeleteCommand( KoShapeControllerInterface *controller, const KoSelectionSet &shapes )
: m_controller( controller )
, m_deleteShapes( false )
{
m_shapes = shapes.toList();
}
KoShapeDeleteCommand::~KoShapeDeleteCommand() {
if( ! m_deleteShapes )
return;
foreach (KoShape *shape, m_shapes ) {
delete shape;
}
}
void KoShapeDeleteCommand::execute () {
if( ! m_controller )
return;
foreach (KoShape *shape, m_shapes ) {
m_controller->removeShape( shape );
}
m_deleteShapes = true;
}
void KoShapeDeleteCommand::unexecute () {
if( ! m_controller )
return;
foreach (KoShape *shape, m_shapes ) {
m_controller->addShape( shape );
}
m_deleteShapes = false;
}
QString KoShapeDeleteCommand::name () const {
return "Delete Shapes";
}
......@@ -145,4 +145,29 @@ protected:
bool m_deleteShape;
};
/// The undo / redo command for deleting shapes
class FLAKE_EXPORT KoShapeDeleteCommand : public KCommand {
public:
/**
* Command to delete a single shape by means of a shape controller.
* @param controller the controller to used for deleting.
* @param shape a single shape that should be deleted.
*/
KoShapeDeleteCommand( KoShapeControllerInterface *controller, KoShape *shape );
/**
* Command to delete a set of shapes by means of a shape controller.
* @param controller the controller to used for deleting.
* @param shapes a set of all the shapes that should be deleted.
*/
KoShapeDeleteCommand( KoShapeControllerInterface *controller, const KoSelectionSet &shapes );
virtual ~KoShapeDeleteCommand();
void execute ();
void unexecute ();
virtual QString name () const;
protected:
KoShapeControllerInterface *m_controller;
QList<KoShape*> m_shapes;
bool m_deleteShapes;
};
#endif
* Add Commands
* KoShapeDelete
Have a bool in this command to see if on destructor we did an execute/unexecute
last and thus need to delete the KoShape.
last and thus need to delete the KoShape. -> done
Note that we want a refCounter in the model-backend of the Shape. (picture/text)
* add a ShearingStrategy
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment