Undo-redo stack used for background objects.

preferencesAboutTextFull
Aleksei Kanash 13 years ago
parent bf43a98282
commit 75ddbf8065
  1. 13
      src/board/UBBoardController.cpp
  2. 14
      src/domain/UBGraphicsItemUndoCommand.cpp
  3. 5
      src/domain/UBGraphicsScene.cpp
  4. 1
      src/domain/UBGraphicsScene.h

@ -855,6 +855,10 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const
void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground)
{
QGraphicsItem *oldBackgroundObject = NULL;
if (isBackground)
oldBackgroundObject = mActiveScene->backgroundObject();
QString mimeType = pContentTypeHeader;
// In some cases "image/jpeg;charset=" is returned by the drag-n-drop. That is
@ -1193,6 +1197,15 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
UBApplication::showMessage(tr("Unknown content type %1").arg(pContentTypeHeader));
qWarning() << "ignoring mime type" << pContentTypeHeader ;
}
if (isBackground && oldBackgroundObject != mActiveScene->backgroundObject())
{
if (mActiveScene->isURStackIsEnabled()) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(mActiveScene, oldBackgroundObject, mActiveScene->backgroundObject());
UBApplication::undoStack->push(uc);
}
}
}

@ -91,9 +91,16 @@ void UBGraphicsItemUndoCommand::undo()
while (itRemoved.hasNext())
{
QGraphicsItem* item = itRemoved.next();
if (item)
{
if (UBItemLayerType::FixedBackground == item->data(UBGraphicsItemData::ItemLayerType))
mScene->setAsBackgroundObject(item);
else
mScene->addItem(item);
UBApplication::boardController->freezeW3CWidget(item, false);
}
}
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
mScene->update(mScene->sceneRect());
@ -123,9 +130,16 @@ void UBGraphicsItemUndoCommand::redo()
while (itAdded.hasNext())
{
QGraphicsItem* item = itAdded.next();
if (item)
{
if (UBItemLayerType::FixedBackground == item->data(UBGraphicsItemData::ItemLayerType))
mScene->setAsBackgroundObject(item);
else
mScene->addItem(item);
UBApplication::boardController->freezeW3CWidget(item, false);
}
}
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2) to trigger repaint
mScene->update(mScene->sceneRect());

@ -1292,6 +1292,11 @@ void UBGraphicsScene::clearBackground()
{
if(mBackgroundObject){
removeItem(mBackgroundObject);
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, mBackgroundObject, NULL);
UBApplication::undoStack->push(uc);
}
mBackgroundObject = 0;
}
update(sceneRect());

@ -102,6 +102,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
// tmp stub for divide addings scene objects from undo mechanism implementation
void setURStackEnable(bool set = true) {enableUndoRedoStack = set;}
bool isURStackIsEnabled(){ return enableUndoRedoStack;}
UBGraphicsScene(UBDocumentProxy *parent);
virtual ~UBGraphicsScene();

Loading…
Cancel
Save