SANKORE-1069

Show Desktop: "Erase all" button isn't work
preferencesAboutTextFull
Anatoly Mihalchenko 12 years ago
parent 3a2dd1685a
commit 869164ca28
  1. 3
      src/adaptors/UBCFFSubsetAdaptor.cpp
  2. 33
      src/adaptors/UBSvgSubsetAdaptor.cpp
  3. 18
      src/board/UBDrawingController.cpp
  4. 10
      src/board/UBDrawingController.h
  5. 7
      src/core/UBApplicationController.cpp
  6. 4
      src/core/UBPersistenceManager.cpp
  7. 2
      src/core/UBPersistenceManager.h
  8. 4
      src/core/UBSceneCache.cpp
  9. 2
      src/core/UBSceneCache.h
  10. 6
      src/desktop/UBDesktopAnnotationController.cpp
  11. 39
      src/domain/UBGraphicsScene.cpp
  12. 8
      src/domain/UBGraphicsScene.h
  13. 19
      src/frameworks/UBCoreGraphicsScene.cpp

@ -1146,8 +1146,7 @@ void UBCFFSubsetAdaptor::UBCFFSubsetReader::repositionSvgItem(QGraphicsItem *ite
bool UBCFFSubsetAdaptor::UBCFFSubsetReader::createNewScene() bool UBCFFSubsetAdaptor::UBCFFSubsetReader::createNewScene()
{ {
mCurrentScene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(mProxy, mProxy->pageCount()); mCurrentScene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(mProxy, mProxy->pageCount(), false);
mCurrentScene->setURStackEnable(false);
mCurrentScene->setSceneRect(mViewBox); mCurrentScene->setSceneRect(mViewBox);
if ((mCurrentScene->sceneRect().topLeft().x() >= 0) || (mCurrentScene->sceneRect().topLeft().y() >= 0)) { if ((mCurrentScene->sceneRect().topLeft().x() >= 0) || (mCurrentScene->sceneRect().topLeft().y() >= 0)) {
mShiftVector = -mViewBox.center(); mShiftVector = -mViewBox.center();

@ -380,7 +380,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
UBGraphicsStroke* annotationGroup = 0; UBGraphicsStroke* annotationGroup = 0;
UBGraphicsStrokesGroup* strokesGroup = 0; UBGraphicsStrokesGroup* strokesGroup = 0;
UBDrawingController* dc = UBDrawingController::drawingController();
while (!mXmlReader.atEnd()) while (!mXmlReader.atEnd())
{ {
@ -395,8 +394,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{ {
if (!mScene) if (!mScene)
{ {
mScene = new UBGraphicsScene(mProxy); mScene = new UBGraphicsScene(mProxy, false);
mScene->setURStackEnable(false);
} }
// introduced in UB 4.2 // introduced in UB 4.2
@ -514,10 +512,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
else else
annotationGroup = new UBGraphicsStroke(); annotationGroup = new UBGraphicsStroke();
if(eDrawingMode_Vector == dc->drawingMode()){
strokesGroup = new UBGraphicsStrokesGroup(); strokesGroup = new UBGraphicsStrokesGroup();
graphicsItemFromSvg(strokesGroup); graphicsItemFromSvg(strokesGroup);
}
QStringRef ubZValue = mXmlReader.attributes().value(mNamespaceUri, "z-value"); QStringRef ubZValue = mXmlReader.attributes().value(mNamespaceUri, "z-value");
@ -561,14 +558,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
polygonItem->setStroke(annotationGroup); polygonItem->setStroke(annotationGroup);
} }
if(eDrawingMode_Vector == dc->drawingMode()){
if(strokesGroup){ if(strokesGroup){
polygonItem->setTransform(strokesGroup->transform()); polygonItem->setTransform(strokesGroup->transform());
strokesGroup->addToGroup(polygonItem); strokesGroup->addToGroup(polygonItem);
polygonItem->setStrokesGroup(strokesGroup); polygonItem->setStrokesGroup(strokesGroup);
}
}else{
mScene->addItem(polygonItem);
} }
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
@ -588,14 +582,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
polygonItem->setStroke(annotationGroup); polygonItem->setStroke(annotationGroup);
} }
if(eDrawingMode_Vector == dc->drawingMode()){
if(strokesGroup){ if(strokesGroup){
polygonItem->setTransform(strokesGroup->transform()); polygonItem->setTransform(strokesGroup->transform());
strokesGroup->addToGroup(polygonItem); strokesGroup->addToGroup(polygonItem);
polygonItem->setStrokesGroup(strokesGroup); polygonItem->setStrokesGroup(strokesGroup);
}
}else{
mScene->addItem(polygonItem);
} }
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
@ -1014,7 +1005,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
delete annotationGroup; delete annotationGroup;
} }
mScene->setURStackEnable(true); mScene->enableUndoRedoStack();
return mScene; return mScene;
} }

@ -47,7 +47,6 @@ UBDrawingController::UBDrawingController(QObject * parent)
, mActiveRuler(NULL) , mActiveRuler(NULL)
, mStylusTool((UBStylusTool::Enum)-1) , mStylusTool((UBStylusTool::Enum)-1)
, mLatestDrawingTool((UBStylusTool::Enum)-1) , mLatestDrawingTool((UBStylusTool::Enum)-1)
, mDrawingMode(DRAWING_MODE)
, mIsDesktopMode(false) , mIsDesktopMode(false)
{ {
connect(UBSettings::settings(), SIGNAL(colorContextChanged()), this, SIGNAL(colorPaletteChanged())); connect(UBSettings::settings(), SIGNAL(colorContextChanged()), this, SIGNAL(colorPaletteChanged()));
@ -110,16 +109,10 @@ void UBDrawingController::setStylusTool(int tool)
mStylusTool = (UBStylusTool::Enum)tool; mStylusTool = (UBStylusTool::Enum)tool;
if(eDrawingMode_Vector == DRAWING_MODE && !mIsDesktopMode){
mDrawingMode = eDrawingMode_Vector;
}
if (mStylusTool == UBStylusTool::Pen) if (mStylusTool == UBStylusTool::Pen)
UBApplication::mainWindow->actionPen->setChecked(true); UBApplication::mainWindow->actionPen->setChecked(true);
else if (mStylusTool == UBStylusTool::Eraser){ else if (mStylusTool == UBStylusTool::Eraser)
UBApplication::mainWindow->actionEraser->setChecked(true); UBApplication::mainWindow->actionEraser->setChecked(true);
mDrawingMode = eDrawingMode_Artistic;
}
else if (mStylusTool == UBStylusTool::Marker) else if (mStylusTool == UBStylusTool::Marker)
UBApplication::mainWindow->actionMarker->setChecked(true); UBApplication::mainWindow->actionMarker->setChecked(true);
else if (mStylusTool == UBStylusTool::Selector) else if (mStylusTool == UBStylusTool::Selector)
@ -407,12 +400,3 @@ void UBDrawingController::captureToolSelected(bool checked)
setStylusTool(UBStylusTool::Capture); setStylusTool(UBStylusTool::Capture);
} }
void UBDrawingController::setDrawingMode(eDrawingMode mode)
{
mDrawingMode = mode;
}
eDrawingMode UBDrawingController::drawingMode()
{
return mDrawingMode;
}

@ -22,13 +22,6 @@
class UBAbstractDrawRuler; class UBAbstractDrawRuler;
typedef enum{
eDrawingMode_Artistic,
eDrawingMode_Vector
}eDrawingMode;
#define DRAWING_MODE eDrawingMode_Vector
class UBDrawingController : public QObject class UBDrawingController : public QObject
{ {
Q_OBJECT; Q_OBJECT;
@ -56,8 +49,6 @@ class UBDrawingController : public QObject
void setPenColor(bool onDarkBackground, const QColor& color, int pIndex); void setPenColor(bool onDarkBackground, const QColor& color, int pIndex);
void setMarkerColor(bool onDarkBackground, const QColor& color, int pIndex); void setMarkerColor(bool onDarkBackground, const QColor& color, int pIndex);
void setMarkerAlpha(qreal alpha); void setMarkerAlpha(qreal alpha);
void setDrawingMode(eDrawingMode mode);
eDrawingMode drawingMode();
UBAbstractDrawRuler* mActiveRuler; UBAbstractDrawRuler* mActiveRuler;
@ -86,7 +77,6 @@ class UBDrawingController : public QObject
private: private:
UBStylusTool::Enum mStylusTool; UBStylusTool::Enum mStylusTool;
UBStylusTool::Enum mLatestDrawingTool; UBStylusTool::Enum mLatestDrawingTool;
eDrawingMode mDrawingMode;
bool mIsDesktopMode; bool mIsDesktopMode;
static UBDrawingController* sDrawingController; static UBDrawingController* sDrawingController;

@ -464,7 +464,6 @@ void UBApplicationController::showDesktop(bool dontSwitchFrontProcess)
} }
UBDrawingController::drawingController()->setInDestopMode(true); UBDrawingController::drawingController()->setInDestopMode(true);
UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Artistic);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
@ -598,12 +597,6 @@ void UBApplicationController::checkUpdateRequest()
void UBApplicationController::hideDesktop() void UBApplicationController::hideDesktop()
{ {
if(UBStylusTool::Eraser != UBDrawingController::drawingController()->stylusTool()){
UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Vector);
}
if (mMainMode == Board) if (mMainMode == Board)
{ {
showBoard(); showBoard();

@ -493,7 +493,7 @@ void UBPersistenceManager::duplicateDocumentScene(UBDocumentProxy* proxy, int in
} }
UBGraphicsScene* UBPersistenceManager::createDocumentSceneAt(UBDocumentProxy* proxy, int index) UBGraphicsScene* UBPersistenceManager::createDocumentSceneAt(UBDocumentProxy* proxy, int index, bool useUndoRedoStack)
{ {
int count = sceneCount(proxy); int count = sceneCount(proxy);
@ -502,7 +502,7 @@ UBGraphicsScene* UBPersistenceManager::createDocumentSceneAt(UBDocumentProxy* pr
mSceneCache.shiftUpScenes(proxy, index, count -1); mSceneCache.shiftUpScenes(proxy, index, count -1);
UBGraphicsScene *newScene = mSceneCache.createScene(proxy, index); UBGraphicsScene *newScene = mSceneCache.createScene(proxy, index, useUndoRedoStack);
newScene->setBackground(UBSettings::settings()->isDarkBackground(), newScene->setBackground(UBSettings::settings()->isDarkBackground(),
UBSettings::settings()->UBSettings::isCrossedBackground()); UBSettings::settings()->UBSettings::isCrossedBackground());

@ -62,7 +62,7 @@ class UBPersistenceManager : public QObject
virtual void persistDocumentScene(UBDocumentProxy* pDocumentProxy, virtual void persistDocumentScene(UBDocumentProxy* pDocumentProxy,
UBGraphicsScene* pScene, const int pSceneIndex); UBGraphicsScene* pScene, const int pSceneIndex);
virtual UBGraphicsScene* createDocumentSceneAt(UBDocumentProxy* pDocumentProxy, int index); virtual UBGraphicsScene* createDocumentSceneAt(UBDocumentProxy* pDocumentProxy, int index, bool useUndoRedoStack = true);
virtual void insertDocumentSceneAt(UBDocumentProxy* pDocumentProxy, UBGraphicsScene* scene, int index); virtual void insertDocumentSceneAt(UBDocumentProxy* pDocumentProxy, UBGraphicsScene* scene, int index);

@ -38,9 +38,9 @@ UBSceneCache::~UBSceneCache()
} }
UBGraphicsScene* UBSceneCache::createScene(UBDocumentProxy* proxy, int pageIndex) UBGraphicsScene* UBSceneCache::createScene(UBDocumentProxy* proxy, int pageIndex, bool useUndoRedoStack)
{ {
UBGraphicsScene* newScene = new UBGraphicsScene(proxy); UBGraphicsScene* newScene = new UBGraphicsScene(proxy, useUndoRedoStack);
insert(proxy, pageIndex, newScene); insert(proxy, pageIndex, newScene);
return newScene; return newScene;

@ -64,7 +64,7 @@ class UBSceneCache : public QHash<UBSceneCacheID, UBGraphicsScene*>
UBSceneCache(); UBSceneCache();
virtual ~UBSceneCache(); virtual ~UBSceneCache();
UBGraphicsScene* createScene(UBDocumentProxy* proxy, int pageIndex); UBGraphicsScene* createScene(UBDocumentProxy* proxy, int pageIndex, bool useUndoRedoStack);
void insert (UBDocumentProxy* proxy, int pageIndex, UBGraphicsScene* scene ); void insert (UBDocumentProxy* proxy, int pageIndex, UBGraphicsScene* scene );

@ -81,7 +81,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent, UB
QString backgroundStyle = "QWidget {background-color: rgba(127, 127, 127, 0)}"; QString backgroundStyle = "QWidget {background-color: rgba(127, 127, 127, 0)}";
mTransparentDrawingView->setStyleSheet(backgroundStyle); mTransparentDrawingView->setStyleSheet(backgroundStyle);
mTransparentDrawingScene = new UBGraphicsScene(0); mTransparentDrawingScene = new UBGraphicsScene(0, false);
mTransparentDrawingView->setScene(mTransparentDrawingScene); mTransparentDrawingView->setScene(mTransparentDrawingScene);
mTransparentDrawingScene->setDrawingMode(true); mTransparentDrawingScene->setDrawingMode(true);
@ -372,10 +372,6 @@ void UBDesktopAnnotationController::goToUniboard()
UBPlatformUtils::setDesktopMode(false); UBPlatformUtils::setDesktopMode(false);
UBDrawingController::drawingController()->setInDestopMode(false); UBDrawingController::drawingController()->setInDestopMode(false);
if(UBStylusTool::Eraser != UBDrawingController::drawingController()->stylusTool()){
UBDrawingController::drawingController()->setDrawingMode(eDrawingMode_Vector);
}
emit restoreUniboard(); emit restoreUniboard();
} }

@ -254,7 +254,7 @@ void UBZLayerController::setLayerType(QGraphicsItem *pItem, itemLayerType::Enum
pItem->setData(UBGraphicsItemData::itemLayerType, QVariant(pNewType)); pItem->setData(UBGraphicsItemData::itemLayerType, QVariant(pNewType));
} }
UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoStack)
: UBCoreGraphicsScene(parent) : UBCoreGraphicsScene(parent)
, mEraser(0) , mEraser(0)
, mPointer(0) , mPointer(0)
@ -271,7 +271,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
, mCurrentStroke(0) , mCurrentStroke(0)
, mShouldUseOMP(true) , mShouldUseOMP(true)
, mItemCount(0) , mItemCount(0)
, enableUndoRedoStack(true) , mUndoRedoStackEnabled(enableUndoRedoStack)
, magniferControlViewWidget(0) , magniferControlViewWidget(0)
, magniferDisplayViewWidget(0) , magniferDisplayViewWidget(0)
, mZLayerController(new UBZLayerController(this)) , mZLayerController(new UBZLayerController(this))
@ -558,7 +558,7 @@ bool UBGraphicsScene::inputDeviceRelease()
if (dc->isDrawingTool() || mDrawWithCompass) if (dc->isDrawingTool() || mDrawWithCompass)
{ {
if(mArcPolygonItem){ if(mArcPolygonItem){
if(eDrawingMode_Vector == dc->drawingMode()){
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup(); UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup();
// Add the arc // Add the arc
@ -580,10 +580,9 @@ bool UBGraphicsScene::inputDeviceRelease()
mAddedItems << pStrokes; mAddedItems << pStrokes;
addItem(pStrokes); addItem(pStrokes);
mDrawWithCompass = false; mDrawWithCompass = false;
}
}else if (mCurrentStroke) }else if (mCurrentStroke)
{ {
if(eDrawingMode_Vector == UBDrawingController::drawingController()->drawingMode()){
UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup(); UBGraphicsStrokesGroup* pStrokes = new UBGraphicsStrokesGroup();
// Remove the strokes that were just drawn here and replace them by a stroke item // Remove the strokes that were just drawn here and replace them by a stroke item
@ -600,7 +599,6 @@ bool UBGraphicsScene::inputDeviceRelease()
mAddedItems.clear(); mAddedItems.clear();
mAddedItems << pStrokes; mAddedItems << pStrokes;
addItem(pStrokes); addItem(pStrokes);
}
if (mCurrentStroke->polygons().empty()){ if (mCurrentStroke->polygons().empty()){
delete mCurrentStroke; delete mCurrentStroke;
@ -612,7 +610,7 @@ bool UBGraphicsScene::inputDeviceRelease()
if (mRemovedItems.size() > 0 || mAddedItems.size() > 0) if (mRemovedItems.size() > 0 || mAddedItems.size() > 0)
{ {
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* udcmd = new UBGraphicsItemUndoCommand(this, mRemovedItems, mAddedItems); //deleted by the undoStack UBGraphicsItemUndoCommand* udcmd = new UBGraphicsItemUndoCommand(this, mRemovedItems, mAddedItems); //deleted by the undoStack
if(UBApplication::undoStack) if(UBApplication::undoStack)
@ -751,10 +749,7 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth,
if (!mCurrentStroke) if (!mCurrentStroke)
mCurrentStroke = new UBGraphicsStroke(); mCurrentStroke = new UBGraphicsStroke();
if (mCurrentStroke) polygonItem->setStroke(mCurrentStroke);
{
polygonItem->setStroke(mCurrentStroke);
}
mPreviousPolygonItems.append(polygonItem); mPreviousPolygonItems.append(polygonItem);
@ -1002,7 +997,7 @@ void UBGraphicsScene::leaveEvent(QEvent * event)
UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const
{ {
UBGraphicsScene* copy = new UBGraphicsScene(this->document()); UBGraphicsScene* copy = new UBGraphicsScene(this->document(), this->mUndoRedoStackEnabled);
copy->setBackground(this->isDarkBackground(), this->isCrossedBackground()); copy->setBackground(this->isDarkBackground(), this->isCrossedBackground());
copy->setSceneRect(this->sceneRect()); copy->setSceneRect(this->sceneRect());
@ -1138,7 +1133,7 @@ void UBGraphicsScene::clearContent(clearCase pCase)
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint // force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
update(sceneRect()); update(sceneRect());
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, QSet<QGraphicsItem*>(), groupsMap); UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, QSet<QGraphicsItem*>(), groupsMap);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
@ -1165,7 +1160,7 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, QGraphi
addItem(pixmapItem); addItem(pixmapItem);
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, replaceFor, pixmapItem); UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, replaceFor, pixmapItem);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }
@ -1192,7 +1187,7 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, QGraphi
void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem) void UBGraphicsScene::textUndoCommandAdded(UBGraphicsTextItem *textItem)
{ {
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsTextItemUndoCommand* uc = new UBGraphicsTextItemUndoCommand(textItem); UBGraphicsTextItemUndoCommand* uc = new UBGraphicsTextItemUndoCommand(textItem);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }
@ -1213,7 +1208,7 @@ UBGraphicsMediaItem* UBGraphicsScene::addMedia(const QUrl& pMediaFileUrl, bool s
mediaItem->show(); mediaItem->show();
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, mediaItem); UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, mediaItem);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }
@ -1296,7 +1291,7 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
// graphicsWidget->widgetWebView()->loadMainHtml(); // graphicsWidget->widgetWebView()->loadMainHtml();
graphicsWidget->setSelected(true); graphicsWidget->setSelected(true);
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget); UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, graphicsWidget);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }
@ -1362,7 +1357,7 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *
groupItem->setVisible(true); groupItem->setVisible(true);
groupItem->setFocus(); groupItem->setFocus();
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemGroupUndoCommand* uc = new UBGraphicsItemGroupUndoCommand(this, groupItem); UBGraphicsItemGroupUndoCommand* uc = new UBGraphicsItemGroupUndoCommand(this, groupItem);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }
@ -1391,7 +1386,7 @@ void UBGraphicsScene::addGroup(UBGraphicsGroupContainerItem *groupItem)
groupItem->setUuid(QUuid::createUuid()); groupItem->setUuid(QUuid::createUuid());
} }
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, groupItem); UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, groupItem);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }
@ -1421,7 +1416,7 @@ UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPoint
addItem(svgItem); addItem(svgItem);
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, svgItem); UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, svgItem);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }
@ -1511,7 +1506,7 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con
textItem->show(); textItem->show();
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem); UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }
@ -1535,7 +1530,7 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const Q
addItem(textItem); addItem(textItem);
textItem->show(); textItem->show();
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (mUndoRedoStackEnabled) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem); UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, 0, textItem);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }

@ -109,10 +109,10 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
}; };
// tmp stub for divide addings scene objects from undo mechanism implementation // tmp stub for divide addings scene objects from undo mechanism implementation
void setURStackEnable(bool set = true) {enableUndoRedoStack = set;} bool isURStackIsEnabled(){ return mUndoRedoStackEnabled;}
bool isURStackIsEnabled(){ return enableUndoRedoStack;} void enableUndoRedoStack(){mUndoRedoStackEnabled = true;}
UBGraphicsScene(UBDocumentProxy *parent); UBGraphicsScene(UBDocumentProxy *parent, bool enableUndoRedoStack = true);
virtual ~UBGraphicsScene(); virtual ~UBGraphicsScene();
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
@ -405,7 +405,7 @@ public slots:
bool mHasCache; bool mHasCache;
// tmp stub for divide addings scene objects from undo mechanism implementation // tmp stub for divide addings scene objects from undo mechanism implementation
bool enableUndoRedoStack; bool mUndoRedoStackEnabled;
UBMagnifier *magniferControlViewWidget; UBMagnifier *magniferControlViewWidget;
UBMagnifier *magniferDisplayViewWidget; UBMagnifier *magniferDisplayViewWidget;

@ -32,23 +32,17 @@ UBCoreGraphicsScene::~UBCoreGraphicsScene()
{ {
//we must delete removed items that are no more in any scene //we must delete removed items that are no more in any scene
//at groups deleting some items can be added to mItemsToDelete, so we need to use iterators. //at groups deleting some items can be added to mItemsToDelete, so we need to use iterators.
if (mItemsToDelete.count()) foreach(QGraphicsItem* item, mItemsToDelete)
{ {
QSet<QGraphicsItem *>::iterator it = mItemsToDelete.begin(); if (item)
QGraphicsItem* item = *it;
do
{ {
item = *it; if (item->scene() == NULL || item->scene() == this)
if (item && (item->scene() == NULL || item->scene() == this))
{ {
mItemsToDelete.remove(*it);
delete item; delete item;
} }
}
it = mItemsToDelete.begin();
}while(mItemsToDelete.count());
} }
mItemsToDelete.clear();
} }
void UBCoreGraphicsScene::addItem(QGraphicsItem* item) void UBCoreGraphicsScene::addItem(QGraphicsItem* item)
@ -84,12 +78,11 @@ bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item)
if(mItemsToDelete.contains(item)) if(mItemsToDelete.contains(item))
{ {
UBGraphicsItem *item_casted = dynamic_cast<UBGraphicsItem *>(item); UBGraphicsItem *item_casted = dynamic_cast<UBGraphicsItem *>(item);
if (0 != item_casted) if (item_casted != NULL)
item_casted->clearSource(); item_casted->clearSource();
mItemsToDelete.remove(item); mItemsToDelete.remove(item);
delete item; delete item;
item = 0;
return true; return true;
} }
else else

Loading…
Cancel
Save