Sankore-834

preferencesAboutTextFull
Ilia Ryabokon 12 years ago
parent 134746af10
commit 37b0eafa61
  1. 3
      src/domain/UBAbstractUndoCommand.h
  2. 58
      src/domain/UBGraphicsItemGroupUndoCommand.cpp
  3. 30
      src/domain/UBGraphicsItemGroupUndoCommand.h
  4. 2
      src/domain/UBGraphicsItemTransformUndoCommand.h
  5. 9
      src/domain/UBGraphicsItemUndoCommand.cpp
  6. 6
      src/domain/UBGraphicsItemUndoCommand.h
  7. 3
      src/domain/UBGraphicsScene.cpp
  8. 6
      src/domain/domain.pri

@ -32,7 +32,8 @@ class UBAbstractUndoCommand : public QUndoCommand
undotype_GRAPHICITEMTRANSFORM = 2, undotype_GRAPHICITEMTRANSFORM = 2,
undotype_GRAPHICITEM = 3, undotype_GRAPHICITEM = 3,
undotype_GRAPHICTEXTITEM = 4, undotype_GRAPHICTEXTITEM = 4,
undotype_PAGESIZE = 5 undotype_PAGESIZE = 5,
undotype_GRAPHICSGROUPITEM = 6
}; };
virtual UndoType getType() { return undotype_UNKNOWN; } virtual UndoType getType() { return undotype_UNKNOWN; }

@ -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

@ -32,7 +32,7 @@ class UBGraphicsItemTransformUndoCommand : public UBAbstractUndoCommand
const QSizeF& prevSize = QSizeF()); const QSizeF& prevSize = QSizeF());
virtual ~UBGraphicsItemTransformUndoCommand(); virtual ~UBGraphicsItemTransformUndoCommand();
virtual UndoType getType() { return undotype_GRAPHICITEMTRANSFORM; }; virtual UndoType getType() { return undotype_GRAPHICITEMTRANSFORM; }
protected: protected:
virtual void undo(); virtual void undo();

@ -24,6 +24,7 @@
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "core/memcheck.h" #include "core/memcheck.h"
#include "domain/UBGraphicsGroupContainerItem.h"
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems,
const QSet<QGraphicsItem*>& pAddedItems) const QSet<QGraphicsItem*>& pAddedItems)
@ -81,6 +82,14 @@ void UBGraphicsItemUndoCommand::undo()
{ {
QGraphicsItem* item = itAdded.next(); QGraphicsItem* item = itAdded.next();
//if removing group
if (item->type() == UBGraphicsGroupContainerItem::Type) {
UBGraphicsGroupContainerItem *curGroup = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item);
if (curGroup) {
curGroup->destroy();
}
}
UBApplication::boardController->freezeW3CWidget(item, true); UBApplication::boardController->freezeW3CWidget(item, true);
item->setSelected(false); item->setSelected(false);
mScene->removeItem(item); mScene->removeItem(item);

@ -34,10 +34,10 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand
virtual ~UBGraphicsItemUndoCommand(); virtual ~UBGraphicsItemUndoCommand();
QSet<QGraphicsItem*> GetAddedList() { return mAddedItems; }; QSet<QGraphicsItem*> GetAddedList() { return mAddedItems; }
QSet<QGraphicsItem*> GetRemovedList() { return mRemovedItems; }; QSet<QGraphicsItem*> GetRemovedList() { return mRemovedItems; }
virtual UndoType getType() { return undotype_GRAPHICITEM; }; virtual UndoType getType() { return undotype_GRAPHICITEM; }
protected: protected:
virtual void undo(); virtual void undo();

@ -47,6 +47,7 @@
#include "board/UBBoardView.h" #include "board/UBBoardView.h"
#include "UBGraphicsItemUndoCommand.h" #include "UBGraphicsItemUndoCommand.h"
#include "UBGraphicsItemGroupUndoCommand.h"
#include "UBGraphicsTextItemUndoCommand.h" #include "UBGraphicsTextItemUndoCommand.h"
#include "UBGraphicsProxyWidget.h" #include "UBGraphicsProxyWidget.h"
#include "UBGraphicsPixmapItem.h" #include "UBGraphicsPixmapItem.h"
@ -1521,7 +1522,7 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *
groupItem->setFocus(); groupItem->setFocus();
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, groupItem); UBGraphicsItemGroupUndoCommand* uc = new UBGraphicsItemGroupUndoCommand(this, groupItem);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }

@ -20,7 +20,8 @@ HEADERS += src/domain/UBGraphicsScene.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
HEADERS += src/domain/UBGraphicsItemDelegate.h \ HEADERS += src/domain/UBGraphicsItemDelegate.h \
src/domain/UBGraphicsTextItemDelegate.h \ src/domain/UBGraphicsTextItemDelegate.h \
@ -51,7 +52,8 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBAbstractUndoCommand.cpp \ src/domain/UBAbstractUndoCommand.cpp \
src/domain/ubgraphicsgroupcontaineritem.cpp \ src/domain/ubgraphicsgroupcontaineritem.cpp \
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \ src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \
src/domain/UBGraphicsStrokesGroup.cpp src/domain/UBGraphicsStrokesGroup.cpp \
src/domain/UBGraphicsItemGroupUndoCommand.cpp
SOURCES += src/domain/UBGraphicsItemDelegate.cpp \ SOURCES += src/domain/UBGraphicsItemDelegate.cpp \
src/domain/UBGraphicsTextItemDelegate.cpp \ src/domain/UBGraphicsTextItemDelegate.cpp \

Loading…
Cancel
Save