/**
     *\file operationCommand.h
     *
     *\brief 用来实现“撤销/重做”的操作指令,继承自QUndoCommand
     *
     *\author dsc
     */

#ifndef OPERATIONCOMMAND_H
#define OPERATIONCOMMAND_H

#include <QUndoCommand>
#include <QGraphicsScene>

class GraphicsItemGroup;

class AddItemCommand : public QUndoCommand
{
public:
    explicit AddItemCommand(QGraphicsItem* item, QGraphicsScene* graphicsScene, QUndoCommand* parent = 0);
    ~AddItemCommand();

public:
    void undo() override;
    void redo() override;

private:
    QGraphicsItem*    m_pItem;
    QPointF           m_itemPos;
    QGraphicsScene*   m_pGraphicsScene;
};

class DeleteItemCommand : public QUndoCommand
{
public:
    explicit DeleteItemCommand(QGraphicsScene* graphicsScene, QUndoCommand* parent = 0);
    ~DeleteItemCommand();

public:
    void undo() override;
    void redo() override;

private:
    QList<QGraphicsItem*>  m_listItem;
    QGraphicsScene*        m_pGraphicsScene;
};

class CreateItemGoupCommand : public QUndoCommand
{
public:
    explicit CreateItemGoupCommand(GraphicsItemGroup* group, QGraphicsScene* graphicsScene, QUndoCommand* parent = 0);
    ~CreateItemGoupCommand();

public:
    void undo() override;
    void redo() override;

private:
    QGraphicsItemGroup*    m_pGroup;
    QGraphicsScene*        m_pGraphicsScene;
    QList<QGraphicsItem*>  m_listItem;
};

class DestroyItemGoupCommand : public QUndoCommand
{
public:
    explicit DestroyItemGoupCommand(GraphicsItemGroup* group, QGraphicsScene* graphicsScene, QUndoCommand* parent = 0);
    ~DestroyItemGoupCommand();

public:
    void undo() override;
    void redo() override;

private:
    QGraphicsItemGroup*    m_pGroup;
    QGraphicsScene*        m_pGraphicsScene;
    QList<QGraphicsItem*>  m_listItem;
};

#endif
