commit
a390738e34
@ -0,0 +1,58 @@ |
|||||||
|
#include "UBGraphicsItemGroupUndoCommand.h" |
||||||
|
|
||||||
|
#include "UBGraphicsGroupContainerItem.h" |
||||||
|
#include "UBGraphicsScene.h" |
||||||
|
#include "core/memcheck.h" |
||||||
|
|
||||||
|
|
||||||
|
UBGraphicsItemGroupUndoCommand::UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated) : |
||||||
|
mScene (pScene), mGroup(pGroupCreated), mFirstRedo(true) |
||||||
|
|
||||||
|
{ |
||||||
|
if (pGroupCreated->childItems().count()) { |
||||||
|
foreach (QGraphicsItem *item, pGroupCreated->childItems()) { |
||||||
|
mItems << item; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
UBGraphicsItemGroupUndoCommand::~UBGraphicsItemGroupUndoCommand() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
void UBGraphicsItemGroupUndoCommand::undo() |
||||||
|
{ |
||||||
|
mGroup->destroy(); |
||||||
|
foreach(QGraphicsItem *item, mItems) { |
||||||
|
item->setSelected(true); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UBGraphicsItemGroupUndoCommand::redo() |
||||||
|
{ |
||||||
|
if (mFirstRedo) { |
||||||
|
//Work around. TODO determine why does Qt call the redo function on pushing to undo
|
||||||
|
mFirstRedo = false; |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
foreach (QGraphicsItem *item, mItems) { |
||||||
|
if (item->type() == UBGraphicsGroupContainerItem::Type) { |
||||||
|
QList<QGraphicsItem*> childItems = item->childItems(); |
||||||
|
UBGraphicsGroupContainerItem *currentGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(item); |
||||||
|
if (currentGroup) { |
||||||
|
currentGroup->destroy(); |
||||||
|
} |
||||||
|
foreach (QGraphicsItem *chItem, childItems) { |
||||||
|
mGroup->addToGroup(chItem); |
||||||
|
} |
||||||
|
} else { |
||||||
|
mGroup->addToGroup(item); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
mScene->addItem(mGroup); |
||||||
|
mGroup->setVisible(true); |
||||||
|
mGroup->setFocus(); |
||||||
|
mGroup->setSelected(true); |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
#ifndef UBGRAPHICSITEMGROUPUNDOCOMMAND_H |
||||||
|
#define UBGRAPHICSITEMGROUPUNDOCOMMAND_H |
||||||
|
|
||||||
|
#include <QList> |
||||||
|
#include "UBAbstractUndoCommand.h" |
||||||
|
|
||||||
|
class UBGraphicsScene; |
||||||
|
class UBGraphicsGroupContainerItem; |
||||||
|
|
||||||
|
class UBGraphicsItemGroupUndoCommand : public UBAbstractUndoCommand |
||||||
|
{ |
||||||
|
public: |
||||||
|
UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated); |
||||||
|
virtual ~UBGraphicsItemGroupUndoCommand(); |
||||||
|
|
||||||
|
virtual UndoType getType() { return undotype_GRAPHICSGROUPITEM; } |
||||||
|
|
||||||
|
protected: |
||||||
|
virtual void undo(); |
||||||
|
virtual void redo(); |
||||||
|
|
||||||
|
private: |
||||||
|
UBGraphicsScene *mScene; |
||||||
|
UBGraphicsGroupContainerItem *mGroup; |
||||||
|
QList<QGraphicsItem*> mItems; |
||||||
|
|
||||||
|
bool mFirstRedo; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // UBGRAPHICSITEMGROUPUNDOCOMMAND_H
|
@ -1,61 +1,58 @@ |
|||||||
|
HEADERS += src/domain/UBGraphicsScene.h \ |
||||||
HEADERS += src/domain/UBGraphicsScene.h \ |
src/domain/UBGraphicsItemUndoCommand.h \ |
||||||
src/domain/UBGraphicsItemUndoCommand.h \ |
src/domain/UBGraphicsTextItemUndoCommand.h \ |
||||||
src/domain/UBGraphicsTextItemUndoCommand.h \ |
src/domain/UBGraphicsItemTransformUndoCommand.h \ |
||||||
src/domain/UBGraphicsItemTransformUndoCommand.h \ |
src/domain/UBGraphicsPixmapItem.h \ |
||||||
src/domain/UBGraphicsPixmapItem.h \ |
src/domain/UBDocumentUndoCommand.h \ |
||||||
src/domain/UBDocumentUndoCommand.h \ |
src/domain/UBPageSizeUndoCommand.h \ |
||||||
src/domain/UBPageSizeUndoCommand.h \ |
src/domain/UBGraphicsProxyWidget.h \ |
||||||
src/domain/UBGraphicsProxyWidget.h \ |
src/domain/UBGraphicsWebView.h \ |
||||||
src/domain/UBGraphicsWebView.h \ |
src/domain/UBGraphicsSvgItem.h \ |
||||||
src/domain/UBGraphicsSvgItem.h \ |
src/domain/UBGraphicsPolygonItem.h \ |
||||||
src/domain/UBGraphicsPolygonItem.h \ |
src/domain/UBItem.h \ |
||||||
src/domain/UBItem.h \ |
src/domain/UBGraphicsWidgetItem.h \ |
||||||
src/domain/UBGraphicsWidgetItem.h \ |
src/domain/UBGraphicsPDFItem.h \ |
||||||
src/domain/UBGraphicsPDFItem.h \ |
src/domain/UBGraphicsTextItem.h \ |
||||||
src/domain/UBGraphicsTextItem.h \ |
src/domain/UBResizableGraphicsItem.h \ |
||||||
src/domain/UBResizableGraphicsItem.h \ |
src/domain/UBGraphicsStroke.h \ |
||||||
src/domain/UBGraphicsStroke.h \ |
src/domain/UBGraphicsMediaItem.h \ |
||||||
src/domain/UBGraphicsMediaItem.h \ |
src/domain/UBAbstractUndoCommand.h \ |
||||||
src/domain/UBAbstractUndoCommand.h\ |
src/domain/UBGraphicsGroupContainerItem.h \ |
||||||
src/domain/UBGraphicsGroupContainerItem.h \ |
src/domain/UBGraphicsGroupContainerItemDelegate.h \ |
||||||
src/domain/UBGraphicsGroupContainerItemDelegate.h \ |
src/domain/UBGraphicsStrokesGroup.h \ |
||||||
src/domain/UBGraphicsStrokesGroup.h |
src/domain/UBGraphicsItemGroupUndoCommand.h \ |
||||||
|
src/domain/UBGraphicsItemDelegate.h \ |
||||||
HEADERS += src/domain/UBGraphicsItemDelegate.h \ |
src/domain/UBGraphicsTextItemDelegate.h \ |
||||||
src/domain/UBGraphicsTextItemDelegate.h \ |
src/domain/UBGraphicsDelegateFrame.h \ |
||||||
src/domain/UBGraphicsDelegateFrame.h \ |
src/domain/UBGraphicsWidgetItemDelegate.h \ |
||||||
src/domain/UBGraphicsWidgetItemDelegate.h \ |
src/domain/UBGraphicsMediaItemDelegate.h |
||||||
src/domain/UBGraphicsMediaItemDelegate.h |
|
||||||
|
SOURCES += src/domain/UBGraphicsScene.cpp \ |
||||||
|
src/domain/UBGraphicsItemUndoCommand.cpp \ |
||||||
SOURCES += src/domain/UBGraphicsScene.cpp \ |
src/domain/UBGraphicsTextItemUndoCommand.cpp \ |
||||||
src/domain/UBGraphicsItemUndoCommand.cpp \ |
src/domain/UBGraphicsItemTransformUndoCommand.cpp \ |
||||||
src/domain/UBGraphicsTextItemUndoCommand.cpp \ |
src/domain/UBGraphicsPixmapItem.cpp \ |
||||||
src/domain/UBGraphicsItemTransformUndoCommand.cpp \ |
src/domain/UBDocumentUndoCommand.cpp \ |
||||||
src/domain/UBGraphicsPixmapItem.cpp \ |
src/domain/UBPageSizeUndoCommand.cpp \ |
||||||
src/domain/UBDocumentUndoCommand.cpp \ |
src/domain/UBGraphicsProxyWidget.cpp \ |
||||||
src/domain/UBPageSizeUndoCommand.cpp \ |
src/domain/UBGraphicsWebView.cpp \ |
||||||
src/domain/UBGraphicsProxyWidget.cpp \ |
src/domain/UBGraphicsSvgItem.cpp \ |
||||||
src/domain/UBGraphicsWebView.cpp \ |
src/domain/UBGraphicsPolygonItem.cpp \ |
||||||
src/domain/UBGraphicsSvgItem.cpp \ |
src/domain/UBItem.cpp \ |
||||||
src/domain/UBGraphicsPolygonItem.cpp \ |
src/domain/UBGraphicsVideoItem.cpp \ |
||||||
src/domain/UBItem.cpp \ |
src/domain/UBGraphicsWidgetItem.cpp \ |
||||||
src/domain/UBGraphicsVideoItem.cpp \ |
src/domain/UBGraphicsPDFItem.cpp \ |
||||||
src/domain/UBGraphicsWidgetItem.cpp \ |
src/domain/UBGraphicsTextItem.cpp \ |
||||||
src/domain/UBGraphicsPDFItem.cpp \ |
src/domain/UBResizableGraphicsItem.cpp \ |
||||||
src/domain/UBGraphicsTextItem.cpp \ |
src/domain/UBGraphicsStroke.cpp \ |
||||||
src/domain/UBResizableGraphicsItem.cpp \ |
src/domain/UBGraphicsMediaItem.cpp \ |
||||||
src/domain/UBGraphicsStroke.cpp \ |
src/domain/UBAbstractUndoCommand.cpp \ |
||||||
src/domain/UBGraphicsMediaItem.cpp \ |
src/domain/ubgraphicsgroupcontaineritem.cpp \ |
||||||
src/domain/UBAbstractUndoCommand.cpp \ |
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \ |
||||||
src/domain/ubgraphicsgroupcontaineritem.cpp \ |
src/domain/UBGraphicsStrokesGroup.cpp \ |
||||||
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \ |
src/domain/UBGraphicsItemGroupUndoCommand.cpp \ |
||||||
src/domain/UBGraphicsStrokesGroup.cpp |
src/domain/UBGraphicsItemDelegate.cpp \ |
||||||
|
src/domain/UBGraphicsTextItemDelegate.cpp \ |
||||||
SOURCES += src/domain/UBGraphicsItemDelegate.cpp \ |
src/domain/UBGraphicsMediaItemDelegate.cpp \ |
||||||
src/domain/UBGraphicsTextItemDelegate.cpp \ |
src/domain/UBGraphicsDelegateFrame.cpp \ |
||||||
src/domain/UBGraphicsMediaItemDelegate.cpp \ |
src/domain/UBGraphicsWidgetItemDelegate.cpp |
||||||
src/domain/UBGraphicsDelegateFrame.cpp \ |
|
||||||
src/domain/UBGraphicsWidgetItemDelegate.cpp \ |
|
||||||
|
|
||||||
|
Loading…
Reference in new issue