Commit fa65eafe authored by Claudio Valerio's avatar Claudio Valerio

bugs of persistance of unwanted media on disk. First step fixed the undo manager

parent 000f1a9c
...@@ -1550,11 +1550,11 @@ void UBBoardController::moveSceneToIndex(int source, int target) ...@@ -1550,11 +1550,11 @@ void UBBoardController::moveSceneToIndex(int source, int target)
} }
} }
void UBBoardController::fitUniqIems(const QUndoCommand *parent, QSet<QGraphicsItem*> &itms) void UBBoardController::findUniquesItems(const QUndoCommand *parent, QSet<QGraphicsItem*> &itms)
{ {
if (parent->childCount()) { if (parent->childCount()) {
for (int i = 0; i < parent->childCount(); i++) { for (int i = 0; i < parent->childCount(); i++) {
fitUniqIems(parent->child(i), itms); findUniquesItems(parent->child(i), itms);
} }
} }
...@@ -1563,11 +1563,11 @@ void UBBoardController::fitUniqIems(const QUndoCommand *parent, QSet<QGraphicsIt ...@@ -1563,11 +1563,11 @@ void UBBoardController::fitUniqIems(const QUndoCommand *parent, QSet<QGraphicsIt
return; return;
} }
const UBAbstractUndoCommand *abstractCmd = static_cast<const UBAbstractUndoCommand*>(parent); const UBUndoCommand *undoCmd = static_cast<const UBUndoCommand*>(parent);
if(abstractCmd->getType() != UBAbstractUndoCommand::undotype_GRAPHICITEM) if(undoCmd->getType() != UBUndoType::undotype_GRAPHICITEM)
return; return;
const UBGraphicsItemUndoCommand *cmd = static_cast<const UBGraphicsItemUndoCommand*>(parent); const UBGraphicsItemUndoCommand *cmd = dynamic_cast<const UBGraphicsItemUndoCommand*>(parent);
// go through all added and removed objects, for create list of unique objects // go through all added and removed objects, for create list of unique objects
// grouped items will be deleted by groups, so we don't need do delete that items. // grouped items will be deleted by groups, so we don't need do delete that items.
...@@ -1593,7 +1593,7 @@ void UBBoardController::ClearUndoStack() ...@@ -1593,7 +1593,7 @@ void UBBoardController::ClearUndoStack()
QSet<QGraphicsItem*> uniqueItems; QSet<QGraphicsItem*> uniqueItems;
// go through all stack command // go through all stack command
for (int i = 0; i < UBApplication::undoStack->count(); i++) { for (int i = 0; i < UBApplication::undoStack->count(); i++) {
fitUniqIems(UBApplication::undoStack->command(i), uniqueItems); findUniquesItems(UBApplication::undoStack->command(i), uniqueItems);
} }
// go through all unique items, and check, if they are on scene, or not. // go through all unique items, and check, if they are on scene, or not.
......
...@@ -160,7 +160,7 @@ class UBBoardController : public UBDocumentContainer ...@@ -160,7 +160,7 @@ class UBBoardController : public UBDocumentContainer
void notifyPageChanged(); void notifyPageChanged();
void displayMetaData(QMap<QString, QString> metadatas); void displayMetaData(QMap<QString, QString> metadatas);
void fitUniqIems(const QUndoCommand *parent, QSet<QGraphicsItem *> &itms); void findUniquesItems(const QUndoCommand *parent, QSet<QGraphicsItem *> &itms);
void ClearUndoStack(); void ClearUndoStack();
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0, bool forceReload = false); void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0, bool forceReload = false);
......
...@@ -195,4 +195,13 @@ struct DocumentSizeRatio ...@@ -195,4 +195,13 @@ struct DocumentSizeRatio
}; };
}; };
struct UBUndoType
{
enum Enum
{
undotype_UNKNOWN = 0, undotype_DOCUMENT, undotype_GRAPHICITEMTRANSFORM, undotype_GRAPHICITEM, undotype_GRAPHICTEXTITEM, undotype_PAGESIZE, undotype_GRAPHICSGROUPITEM
};
};
#endif /* UB_H_ */ #endif /* UB_H_ */
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsItemGroupUndoCommand::UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated) : UBGraphicsItemGroupUndoCommand::UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated) : UBUndoCommand()
mScene (pScene), mGroup(pGroupCreated), mFirstRedo(true) , mScene (pScene)
, mGroup(pGroupCreated)
, mFirstRedo(true)
{ {
if (pGroupCreated->childItems().count()) { if (pGroupCreated->childItems().count()) {
foreach (QGraphicsItem *item, pGroupCreated->childItems()) { foreach (QGraphicsItem *item, pGroupCreated->childItems()) {
......
...@@ -25,18 +25,18 @@ ...@@ -25,18 +25,18 @@
#define UBGRAPHICSITEMGROUPUNDOCOMMAND_H #define UBGRAPHICSITEMGROUPUNDOCOMMAND_H
#include <QList> #include <QList>
#include "UBAbstractUndoCommand.h" #include "UBUndoCommand.h"
class UBGraphicsScene; class UBGraphicsScene;
class UBGraphicsGroupContainerItem; class UBGraphicsGroupContainerItem;
class UBGraphicsItemGroupUndoCommand : public UBAbstractUndoCommand class UBGraphicsItemGroupUndoCommand : public UBUndoCommand
{ {
public: public:
UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated); UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated);
virtual ~UBGraphicsItemGroupUndoCommand(); virtual ~UBGraphicsItemGroupUndoCommand();
virtual UndoType getType() { return undotype_GRAPHICSGROUPITEM; } virtual int getType() const { return UBUndoType::undotype_GRAPHICSGROUPITEM; }
protected: protected:
virtual void undo(); virtual void undo();
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
UBGraphicsItemTransformUndoCommand::UBGraphicsItemTransformUndoCommand(QGraphicsItem* pItem, UBGraphicsItemTransformUndoCommand::UBGraphicsItemTransformUndoCommand(QGraphicsItem* pItem,
const QPointF& prevPos, const QTransform& prevTransform, const qreal& prevZValue, const QPointF& prevPos, const QTransform& prevTransform, const qreal& prevZValue,
const QSizeF& prevSize) const QSizeF& prevSize):UBUndoCommand()
{ {
mItem = pItem; mItem = pItem;
mPreviousTransform = prevTransform; mPreviousTransform = prevTransform;
......
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
#include <QtGui> #include <QtGui>
#include "UBResizableGraphicsItem.h" #include "UBResizableGraphicsItem.h"
#include "UBAbstractUndoCommand.h" #include "UBUndoCommand.h"
class UBGraphicsItemTransformUndoCommand : public UBAbstractUndoCommand class UBGraphicsItemTransformUndoCommand : public UBUndoCommand
{ {
public: public:
UBGraphicsItemTransformUndoCommand(QGraphicsItem* pItem, UBGraphicsItemTransformUndoCommand(QGraphicsItem* pItem,
...@@ -40,7 +40,7 @@ class UBGraphicsItemTransformUndoCommand : public UBAbstractUndoCommand ...@@ -40,7 +40,7 @@ class UBGraphicsItemTransformUndoCommand : public UBAbstractUndoCommand
const QSizeF& prevSize = QSizeF()); const QSizeF& prevSize = QSizeF());
virtual ~UBGraphicsItemTransformUndoCommand(); virtual ~UBGraphicsItemTransformUndoCommand();
virtual UndoType getType() { return undotype_GRAPHICITEMTRANSFORM; } virtual int getType() const { return UBUndoType::undotype_GRAPHICITEMTRANSFORM; }
protected: protected:
virtual void undo(); virtual void undo();
......
...@@ -35,9 +35,8 @@ ...@@ -35,9 +35,8 @@
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBGraphicsPolygonItem.h" #include "domain/UBGraphicsPolygonItem.h"
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, const QSet<QGraphicsItem*>& pAddedItems, const GroupDataTable &groupsMap): UBUndoCommand()
const QSet<QGraphicsItem*>& pAddedItems, const GroupDataTable &groupsMap) , mScene(pScene)
: mScene(pScene)
, mRemovedItems(pRemovedItems - pAddedItems) , mRemovedItems(pRemovedItems - pAddedItems)
, mAddedItems(pAddedItems - pRemovedItems) , mAddedItems(pAddedItems - pRemovedItems)
, mExcludedFromGroup(groupsMap) , mExcludedFromGroup(groupsMap)
...@@ -57,9 +56,8 @@ UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, co ...@@ -57,9 +56,8 @@ UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, co
} }
} }
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem, UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem, QGraphicsItem* pAddedItem) : UBUndoCommand()
QGraphicsItem* pAddedItem) : , mScene(pScene)
mScene(pScene)
{ {
if (pRemovedItem) if (pRemovedItem)
......
...@@ -25,14 +25,14 @@ ...@@ -25,14 +25,14 @@
#define UBGRAPHICSITEMUNDOCOMMAND_H_ #define UBGRAPHICSITEMUNDOCOMMAND_H_
#include <QtGui> #include <QtGui>
#include "UBAbstractUndoCommand.h" #include "UBUndoCommand.h"
#include "UBGraphicsGroupContainerItem.h" #include "UBGraphicsGroupContainerItem.h"
class UBGraphicsScene; class UBGraphicsScene;
class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand class UBGraphicsItemUndoCommand : public UBUndoCommand
{ {
public: public:
typedef QMultiMap<UBGraphicsGroupContainerItem*, QUuid> GroupDataTable; typedef QMultiMap<UBGraphicsGroupContainerItem*, QUuid> GroupDataTable;
...@@ -48,7 +48,7 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand ...@@ -48,7 +48,7 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand
QSet<QGraphicsItem*> GetAddedList() const { return mAddedItems; } QSet<QGraphicsItem*> GetAddedList() const { return mAddedItems; }
QSet<QGraphicsItem*> GetRemovedList() const { return mRemovedItems; } QSet<QGraphicsItem*> GetRemovedList() const { return mRemovedItems; }
virtual UndoType getType() { return undotype_GRAPHICITEM; } virtual int getType() const { return UBUndoType::undotype_GRAPHICITEM; }
protected: protected:
virtual void undo(); virtual void undo();
......
...@@ -25,18 +25,18 @@ ...@@ -25,18 +25,18 @@
#define UBGRAPHICSTEXTITEMUNDOCOMMAND_H_ #define UBGRAPHICSTEXTITEMUNDOCOMMAND_H_
#include <QtGui> #include <QtGui>
#include "UBAbstractUndoCommand.h" #include "UBUndoCommand.h"
#include "UBGraphicsTextItem.h" #include "UBGraphicsTextItem.h"
class UBGraphicsTextItemUndoCommand : public UBAbstractUndoCommand class UBGraphicsTextItemUndoCommand : public UBUndoCommand
{ {
public: public:
UBGraphicsTextItemUndoCommand(UBGraphicsTextItem *textItem); UBGraphicsTextItemUndoCommand(UBGraphicsTextItem *textItem);
virtual ~UBGraphicsTextItemUndoCommand(); virtual ~UBGraphicsTextItemUndoCommand();
virtual UndoType getType() { return undotype_GRAPHICTEXTITEM; }; virtual int getType() const { return UBUndoType::undotype_GRAPHICTEXTITEM; };
protected: protected:
virtual void undo(); virtual void undo();
......
...@@ -25,18 +25,18 @@ ...@@ -25,18 +25,18 @@
#define UBPageSizeUndoCommand_H_ #define UBPageSizeUndoCommand_H_
#include <QtGui> #include <QtGui>
#include "UBAbstractUndoCommand.h" #include "UBUndoCommand.h"
class UBGraphicsScene; class UBGraphicsScene;
class UBPageSizeUndoCommand : public UBAbstractUndoCommand class UBPageSizeUndoCommand : public UBUndoCommand
{ {
public: public:
UBPageSizeUndoCommand(UBGraphicsScene* pScene, const QSize& previousSize, const QSize& newSize); UBPageSizeUndoCommand(UBGraphicsScene* pScene, const QSize& previousSize, const QSize& newSize);
virtual ~UBPageSizeUndoCommand(); virtual ~UBPageSizeUndoCommand();
virtual UndoType getType() { return undotype_PAGESIZE; }; virtual int getType() { return UBUndoType::undotype_PAGESIZE; };
protected: protected:
virtual void undo(); virtual void undo();
......
...@@ -21,30 +21,17 @@ ...@@ -21,30 +21,17 @@
#include "UBAbstractUndoCommand.h" #include "UBUndoCommand.h"
#include "core/memcheck.h" #include "core/memcheck.h"
UBAbstractUndoCommand::UBAbstractUndoCommand() UBUndoCommand::UBUndoCommand(QUndoCommand* parent):QUndoCommand(parent)
{ {
// NOOP // NOOP
} }
UBAbstractUndoCommand::~UBAbstractUndoCommand() UBUndoCommand::~UBUndoCommand()
{ {
// NOOP // NOOP
} }
void UBAbstractUndoCommand::undo()
{
// NOOP
}
void UBAbstractUndoCommand::redo()
{
// NOOP
}
//void UBAbstractUndoCommand::UndoType getType(UndoType type);
...@@ -25,30 +25,16 @@ ...@@ -25,30 +25,16 @@
#define UBABSTRACTUNDOCOMMAND_H_ #define UBABSTRACTUNDOCOMMAND_H_
#include <QtGui> #include <QtGui>
#include <core/UB.h>
class UBAbstractUndoCommand : public QUndoCommand class UBUndoCommand : public QUndoCommand
{ {
public: public:
UBAbstractUndoCommand(); UBUndoCommand(QUndoCommand *parent = 0);
~UBAbstractUndoCommand(); ~UBUndoCommand();
enum UndoType virtual int getType() const { return UBUndoType::undotype_UNKNOWN; }
{
undotype_UNKNOWN = 0,
undotype_DOCUMENT = 1,
undotype_GRAPHICITEMTRANSFORM = 2,
undotype_GRAPHICITEM = 3,
undotype_GRAPHICTEXTITEM = 4,
undotype_PAGESIZE = 5,
undotype_GRAPHICSGROUPITEM = 6
};
virtual UndoType getType() const { return undotype_UNKNOWN; }
protected:
virtual void undo();
virtual void redo();
}; };
......
...@@ -14,7 +14,6 @@ HEADERS += src/domain/UBGraphicsScene.h \ ...@@ -14,7 +14,6 @@ HEADERS += src/domain/UBGraphicsScene.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/UBGraphicsGroupContainerItem.h \ src/domain/UBGraphicsGroupContainerItem.h \
src/domain/UBGraphicsGroupContainerItemDelegate.h \ src/domain/UBGraphicsGroupContainerItemDelegate.h \
src/domain/UBGraphicsStrokesGroup.h \ src/domain/UBGraphicsStrokesGroup.h \
...@@ -24,7 +23,8 @@ HEADERS += src/domain/UBGraphicsScene.h \ ...@@ -24,7 +23,8 @@ HEADERS += src/domain/UBGraphicsScene.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 \
src/domain/UBSelectionFrame.h src/domain/UBSelectionFrame.h \
src/domain/UBUndoCommand.h
SOURCES += src/domain/UBGraphicsScene.cpp \ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsItemUndoCommand.cpp \ src/domain/UBGraphicsItemUndoCommand.cpp \
...@@ -42,7 +42,6 @@ SOURCES += src/domain/UBGraphicsScene.cpp \ ...@@ -42,7 +42,6 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBResizableGraphicsItem.cpp \ src/domain/UBResizableGraphicsItem.cpp \
src/domain/UBGraphicsStroke.cpp \ src/domain/UBGraphicsStroke.cpp \
src/domain/UBGraphicsMediaItem.cpp \ src/domain/UBGraphicsMediaItem.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 \
...@@ -52,4 +51,5 @@ SOURCES += src/domain/UBGraphicsScene.cpp \ ...@@ -52,4 +51,5 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsMediaItemDelegate.cpp \ src/domain/UBGraphicsMediaItemDelegate.cpp \
src/domain/UBGraphicsDelegateFrame.cpp \ src/domain/UBGraphicsDelegateFrame.cpp \
src/domain/UBGraphicsWidgetItemDelegate.cpp \ src/domain/UBGraphicsWidgetItemDelegate.cpp \
src/domain/UBSelectionFrame.cpp src/domain/UBSelectionFrame.cpp \
src/domain/UBUndoCommand.cpp
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