diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index f557ff8a..80f91e9d 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -1084,7 +1084,7 @@ QGraphicsItem *UBSvgSubsetAdaptor::UBSvgSubsetReader::readElementFromGroup() { QGraphicsItem *result = 0; - result = mScene->itemByUuid(QUuid(mXmlReader.attributes().value(aId).toString())); + result = mScene->itemForUuid(QUuid(mXmlReader.attributes().value(aId).toString())); mXmlReader.skipCurrentElement(); mXmlReader.readNext(); diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index e83414f7..3a6a2394 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -645,7 +645,7 @@ void UBBoardController::duplicateItem(UBItem *item) { mActiveScene->addItem(gitem); gitem->setPos(itemPos); - mLastCreatedItem = gitem; + mLastCreatedItem = gitem; gitem->setSelected(true); } return; @@ -1132,7 +1132,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri QString destFile; bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(), - "", + sourceUrl.toString(), UBPersistenceManager::videoDirectory, uuid, destFile, @@ -1175,7 +1175,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri QString destFile; bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(selectedDocument(), - "", + sourceUrl.toString(), UBPersistenceManager::audioDirectory, uuid, destFile, diff --git a/src/board/UBFeaturesController.cpp b/src/board/UBFeaturesController.cpp index 6c777e73..a9bbeb08 100644 --- a/src/board/UBFeaturesController.cpp +++ b/src/board/UBFeaturesController.cpp @@ -144,7 +144,7 @@ void UBFeaturesComputingThread::compute(const QList > &pS void UBFeaturesComputingThread::run() { forever { - qDebug() << "Custom thread started execution"; +// qDebug() << "Custom thread started execution"; mMutex.lock(); QList > searchData = mScanningData; @@ -158,17 +158,17 @@ void UBFeaturesComputingThread::run() break; } - QTime curTime = QTime::currentTime(); +// QTime curTime = QTime::currentTime(); int fsCnt = featuresCountAll(searchData); - int msecsto = curTime.msecsTo(QTime::currentTime()); - qDebug() << "time on evaluation" << msecsto; +// int msecsto = curTime.msecsTo(QTime::currentTime()); +// qDebug() << "time on evaluation" << msecsto; emit maxFilesCountEvaluated(fsCnt); emit scanStarted(); - curTime = QTime::currentTime(); +// curTime = QTime::currentTime(); scanAll(searchData, favoriteSet); - qDebug() << "Time on finishing" << curTime.msecsTo(QTime::currentTime()); +// qDebug() << "Time on finishing" << curTime.msecsTo(QTime::currentTime()); emit scanFinished(); mMutex.lock(); @@ -183,7 +183,7 @@ void UBFeaturesComputingThread::run() UBFeaturesComputingThread::~UBFeaturesComputingThread() { - qDebug() << "thread destructor catched"; +// qDebug() << "thread destructor catched"; mMutex.lock(); abort = true; diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 2c025a7c..44c534aa 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -913,6 +913,7 @@ bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy, QString& destinationPath, QByteArray* data) { + Q_ASSERT(path.length()); QFileInfo fi(path); if (!pDocumentProxy || objectUuid.isNull()) @@ -920,6 +921,8 @@ bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy, if (data == NULL && !fi.exists()) return false; + qDebug() << fi.suffix(); + QString fileName = subdir + "/" + objectUuid.toString() + "." + fi.suffix(); destinationPath = pDocumentProxy->persistencePath() + "/" + fileName; diff --git a/src/domain/UBGraphicsDelegateFrame.cpp b/src/domain/UBGraphicsDelegateFrame.cpp index de40ab43..b41e0376 100644 --- a/src/domain/UBGraphicsDelegateFrame.cpp +++ b/src/domain/UBGraphicsDelegateFrame.cpp @@ -286,18 +286,111 @@ bool UBGraphicsDelegateFrame::canResizeBottomRight(qreal width, qreal height, qr return res; } +QPointF UBGraphicsDelegateFrame::getFixedPointFromPos() +{ + QPointF fixedPoint; + if (!moving() && !rotating()) + { + if (resizingTop()) + { + if (mMirrorX && mMirrorY) + { + if ((0 < mAngle) && (mAngle < 90)) + fixedPoint = delegated()->sceneBoundingRect().topLeft(); + else + fixedPoint = delegated()->sceneBoundingRect().topRight(); + } + else + { + if ((0 < mAngle) && (mAngle <= 90)) + fixedPoint = delegated()->sceneBoundingRect().bottomRight(); + else + fixedPoint = delegated()->sceneBoundingRect().bottomLeft(); + } + } + else if (resizingLeft()) + { + if (mMirrorX && mMirrorY) + { + if ((0 < mAngle) && (mAngle < 90)) + fixedPoint = delegated()->sceneBoundingRect().bottomLeft(); + else + fixedPoint = delegated()->sceneBoundingRect().topLeft(); + } + else + { + if ((0 < mAngle) && (mAngle <= 90)) + fixedPoint = delegated()->sceneBoundingRect().topRight(); + else + fixedPoint = delegated()->sceneBoundingRect().bottomRight(); + } + } + } + return fixedPoint; +} + + +QSizeF UBGraphicsDelegateFrame::getResizeVector(qreal moveX, qreal moveY) +{ + qreal dPosX = 0; + qreal dPosY = 0; + + if (resizingTop()) + { + if (mMirrorX && mMirrorY) + dPosY = moveY; + else + dPosY = -moveY; + } + else if (resizingLeft()) + { + if (mMirrorX && mMirrorY) + dPosX = moveX; + else + dPosX = -moveX; + } + + else if (resizingRight()) + dPosX = (mMirrorX) ? -moveX : moveX; + else if (resizingBottom()) + dPosY = mMirrorY ? -moveY : moveY; + + return QSizeF(dPosX, dPosY); +} + +void UBGraphicsDelegateFrame::resizeDelegate(qreal moveX, qreal moveY) +{ + QPointF fixedPoint = getFixedPointFromPos(); + UBResizableGraphicsItem* resizableItem = dynamic_cast(delegated()); + if (resizableItem) + { + QSizeF originalSize = delegated()->boundingRect().size(); + resizableItem->resize(originalSize + getResizeVector(moveX, moveY)); + + if (resizingTop() || resizingLeft() || ((mMirrorX || mMirrorY) && resizingBottomRight())) + { + delegated()->setPos(delegated()->pos()-getFixedPointFromPos()+fixedPoint); + } + } +} + void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { if (None == mCurrentTool) return; - QLineF move(mStartingPoint, event->scenePos()); + QLineF move; + if(rotating() || moving() || mOperationMode == Scaling) + move = QLineF(mStartingPoint, event->scenePos()); + else + move = QLineF(event->lastScenePos(), event->scenePos()); + qreal moveX = move.length() * cos((move.angle() - mAngle) * PI / 180); qreal moveY = -move.length() * sin((move.angle() - mAngle) * PI / 180); qreal width = delegated()->boundingRect().width() * mTotalScaleX; qreal height = delegated()->boundingRect().height() * mTotalScaleY; - if(mOperationMode == Scaling) + if(!rotating()) { mTranslateX = moveX; // Perform the resize @@ -398,44 +491,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } } } - else if (mOperationMode == Resizing || mOperationMode == ResizingHorizontally) - { - mTranslateX = moveX; - UBResizableGraphicsItem* resizableItem = dynamic_cast(delegated()); - - if (resizableItem) - { - QLineF mousePosDelta(delegated()->mapFromScene(event->lastScenePos()) - , delegated()->mapFromScene(event->scenePos())); - QSizeF incVector(0, 0); - - if (resizingBottomRight()) - { - incVector = QSizeF(mousePosDelta.dx(), mousePosDelta.dy()); - } - else if (resizingRight()) - { - incVector = QSizeF(mousePosDelta.dx(), 0); - } - else if (resizingBottom()) - { - incVector = QSizeF(0, mousePosDelta.dy()); - } - else if (resizingLeft()) - { - incVector = QSizeF(- mousePosDelta.dx(), 0); - } - else if (resizingTop()) - { - incVector = QSizeF(0, - mousePosDelta.dy()); - } - - QSizeF newSize = resizableItem->size() + incVector; - - resizableItem->resize(newSize); - } - } - + if (rotating()) { mTranslateX = 0; @@ -483,49 +539,56 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) // we just detects coordinates of corner before and after scaling and then moves object at diff between them. if (resizingBottomRight() && mMirrorX) + { mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomRight()).x() - tr.map(delegated()->boundingRect().bottomRight()).x(); - else - mTranslateX += mInitialTransform.map(delegated()->boundingRect().topLeft()).x() - tr.map(delegated()->boundingRect().topLeft()).x(); - - if (resizingBottomRight() && mMirrorY) mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomRight()).y() - tr.map(delegated()->boundingRect().bottomRight()).y(); + } else + { + mTranslateX += mInitialTransform.map(delegated()->boundingRect().topLeft()).x() - tr.map(delegated()->boundingRect().topLeft()).x(); mTranslateY += mInitialTransform.map(delegated()->boundingRect().topLeft()).y() - tr.map(delegated()->boundingRect().topLeft()).y(); + } + } + else if (resizingTop() || resizingLeft()) + { + QPointF bottomRight = tr.map(delegated()->boundingRect().bottomRight()); + QPointF fixedPoint = mInitialTransform.map(delegated()->boundingRect().bottomRight()); + mTranslateX += fixedPoint.x() - bottomRight.x(); + mTranslateY += fixedPoint.y() - bottomRight.y(); + } - // Update the transform + + if (mOperationMode == Scaling || moving() || rotating()) + { tr = buildTransform(); + delegated()->setTransform(tr); } - else if (resizingTop() || resizingLeft()) + else if (mOperationMode == Resizing) { - if (mOperationMode == Scaling) + if (!moving() && !rotating()) { - QPointF bottomRight = tr.map(delegated()->boundingRect().bottomRight()); - QPointF fixedPoint = mInitialTransform.map(delegated()->boundingRect().bottomRight()); - mTranslateX += fixedPoint.x() - bottomRight.x(); - mTranslateY += fixedPoint.y() - bottomRight.y(); - } - else - { - QLineF vector; - if (resizingLeft()) + if (resizingBottomRight()) { - QPointF topRight1 = mInitialTransform.map(QPointF(delegated()->boundingRect().width() - moveX, 0)); - QPointF topRight2 = mInitialTransform.map(QPointF(delegated()->boundingRect().width(), 0)); - vector.setPoints(topRight1, topRight2); + if (mMirrorX && mMirrorY) + mCurrentTool = ResizeTop; + else + mCurrentTool = ResizeBottom; + + resizeDelegate(moveX, moveY); + + if (mMirrorX && mMirrorY) + mCurrentTool = ResizeLeft; + else + mCurrentTool = ResizeRight; + + resizeDelegate(moveX, moveY); + mCurrentTool = ResizeBottomRight; } else - { - QPointF bottomLeft1 = mInitialTransform.map(QPointF(0, delegated()->boundingRect().height() - moveY)); - QPointF bottomLeft2 = mInitialTransform.map(QPointF(0, delegated()->boundingRect().height())); - vector.setPoints(bottomLeft1, bottomLeft2); - } - mTranslateX = vector.dx(); - mTranslateY = vector.dy(); + resizeDelegate(moveX, moveY); } - tr = buildTransform(); } - delegated()->setTransform(tr); event->accept(); } diff --git a/src/domain/UBGraphicsDelegateFrame.h b/src/domain/UBGraphicsDelegateFrame.h index 142766fe..07166adf 100644 --- a/src/domain/UBGraphicsDelegateFrame.h +++ b/src/domain/UBGraphicsDelegateFrame.h @@ -37,6 +37,9 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject QPainterPath shape() const; virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); + QPointF getFixedPointFromPos(); + QSizeF getResizeVector(qreal moveX, qreal moveY); + void resizeDelegate(qreal moveX, qreal moveY); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); diff --git a/src/domain/UBGraphicsGroupContainerItem.cpp b/src/domain/UBGraphicsGroupContainerItem.cpp index 5f0e85c0..82c03068 100644 --- a/src/domain/UBGraphicsGroupContainerItem.cpp +++ b/src/domain/UBGraphicsGroupContainerItem.cpp @@ -123,6 +123,8 @@ void UBGraphicsGroupContainerItem::removeFromGroup(QGraphicsItem *item) pRemoveFromGroup(item); + item->setFlags(ItemIsSelectable | ItemIsFocusable); + } void UBGraphicsGroupContainerItem::deselectCurrentItem() @@ -211,7 +213,7 @@ void UBGraphicsGroupContainerItem::setUuid(const QUuid &pUuid) setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene } -void UBGraphicsGroupContainerItem::destroy() { +void UBGraphicsGroupContainerItem::destroy(bool canUndo) { foreach (QGraphicsItem *item, childItems()) { pRemoveFromGroup(item); @@ -219,7 +221,7 @@ void UBGraphicsGroupContainerItem::destroy() { item->setFlag(QGraphicsItem::ItemIsFocusable, true); } - remove(); + remove(canUndo); } void UBGraphicsGroupContainerItem::clearSource() diff --git a/src/domain/UBGraphicsGroupContainerItem.h b/src/domain/UBGraphicsGroupContainerItem.h index 6f14204a..82ccc81f 100644 --- a/src/domain/UBGraphicsGroupContainerItem.h +++ b/src/domain/UBGraphicsGroupContainerItem.h @@ -34,7 +34,7 @@ public: } virtual void setUuid(const QUuid &pUuid); - void destroy(); + void destroy(bool canUndo = true); virtual void clearSource(); diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index 45b626ef..0b23509f 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -166,7 +166,8 @@ void UBGraphicsItemDelegate::init() UBGraphicsItemDelegate::~UBGraphicsItemDelegate() { - disconnect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged())); + if (UBApplication::boardController) + disconnect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged())); // do not release mMimeData. // the mMimeData is owned by QDrag since the setMimeData call as specified in the documentation } diff --git a/src/domain/UBGraphicsItemGroupUndoCommand.cpp b/src/domain/UBGraphicsItemGroupUndoCommand.cpp index 9b58dc1d..d087216f 100644 --- a/src/domain/UBGraphicsItemGroupUndoCommand.cpp +++ b/src/domain/UBGraphicsItemGroupUndoCommand.cpp @@ -22,7 +22,7 @@ UBGraphicsItemGroupUndoCommand::~UBGraphicsItemGroupUndoCommand() void UBGraphicsItemGroupUndoCommand::undo() { - mGroup->destroy(); + mGroup->destroy(false); foreach(QGraphicsItem *item, mItems) { item->setSelected(true); } @@ -41,7 +41,7 @@ void UBGraphicsItemGroupUndoCommand::redo() QList childItems = item->childItems(); UBGraphicsGroupContainerItem *currentGroup = dynamic_cast(item); if (currentGroup) { - currentGroup->destroy(); + currentGroup->destroy(false); } foreach (QGraphicsItem *chItem, childItems) { mGroup->addToGroup(chItem); diff --git a/src/domain/UBGraphicsItemUndoCommand.cpp b/src/domain/UBGraphicsItemUndoCommand.cpp index d9961fa0..c8637242 100644 --- a/src/domain/UBGraphicsItemUndoCommand.cpp +++ b/src/domain/UBGraphicsItemUndoCommand.cpp @@ -27,10 +27,11 @@ #include "domain/UBGraphicsGroupContainerItem.h" UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet& pRemovedItems, - const QSet& pAddedItems) + const QSet& pAddedItems, const GroupDataTable &groupsMap) : mScene(pScene) - , mRemovedItems(pRemovedItems - pAddedItems) - , mAddedItems(pAddedItems - pRemovedItems) + , mRemovedItems(pRemovedItems - pAddedItems) + , mAddedItems(pAddedItems - pRemovedItems) + , mExcludedFromGroup(groupsMap) { mFirstRedo = true; @@ -110,6 +111,36 @@ void UBGraphicsItemUndoCommand::undo() } } + QMapIterator curMapElement(mExcludedFromGroup); + UBGraphicsGroupContainerItem *nextGroup = 0; + UBGraphicsGroupContainerItem *previousGroupItem; + bool groupChanged = false; + + while (curMapElement.hasNext()) { + curMapElement.next(); + + groupChanged = previousGroupItem != curMapElement.key(); + //trying to find the group on the scene; + if (!nextGroup || groupChanged) { + UBGraphicsGroupContainerItem *groupCandidate = curMapElement.key(); + if (groupCandidate) { + nextGroup = groupCandidate; + if(!mScene->items().contains(nextGroup)) { + mScene->addItem(nextGroup); + } + nextGroup->setVisible(true); + } + } + + QGraphicsItem *groupedItem = mScene->itemForUuid(curMapElement.value()); + if (groupedItem) { + nextGroup->addToGroup(groupedItem); + } + + previousGroupItem = curMapElement.key(); + UBGraphicsItem::Delegate(nextGroup)->update(); + } + // force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint mScene->update(mScene->sceneRect()); @@ -125,6 +156,35 @@ void UBGraphicsItemUndoCommand::redo() return; } + QMapIterator curMapElement(mExcludedFromGroup); + UBGraphicsGroupContainerItem *nextGroup = 0; + UBGraphicsGroupContainerItem *previousGroupItem; + bool groupChanged = false; + + while (curMapElement.hasNext()) { + curMapElement.next(); + + groupChanged = previousGroupItem != curMapElement.key(); + //trying to find the group on the scene; + if (!nextGroup || groupChanged) { + UBGraphicsGroupContainerItem *groupCandidate = curMapElement.key(); + if (groupCandidate) { + nextGroup = groupCandidate; + } + } + QGraphicsItem *groupedItem = mScene->itemForUuid(curMapElement.value()); + if (groupedItem) { + if (nextGroup->childItems().count() == 1) { + nextGroup->destroy(false); + break; + } + nextGroup->removeFromGroup(groupedItem); + } + + previousGroupItem = curMapElement.key(); + UBGraphicsItem::Delegate(nextGroup)->update(); + } + QSetIterator itRemoved(mRemovedItems); while (itRemoved.hasNext()) { diff --git a/src/domain/UBGraphicsItemUndoCommand.h b/src/domain/UBGraphicsItemUndoCommand.h index 78e7ec9a..fec45d4f 100644 --- a/src/domain/UBGraphicsItemUndoCommand.h +++ b/src/domain/UBGraphicsItemUndoCommand.h @@ -18,6 +18,7 @@ #include #include "UBAbstractUndoCommand.h" +#include "UBGraphicsGroupContainerItem.h" class UBGraphicsScene; @@ -26,8 +27,10 @@ class UBGraphicsScene; class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand { public: + typedef QMultiMap GroupDataTable; + UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet& pRemovedItems, - const QSet& pAddedItems); + const QSet& pAddedItems, const GroupDataTable &groupsMap = GroupDataTable()); UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem, QGraphicsItem* pAddedItem); @@ -47,6 +50,7 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand UBGraphicsScene* mScene; QSet mRemovedItems; QSet mAddedItems; + GroupDataTable mExcludedFromGroup; bool mFirstRedo; }; diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index f244bae8..352d0f2a 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -1067,6 +1067,7 @@ UBItem* UBGraphicsScene::deepCopy() const void UBGraphicsScene::clearContent(clearCase pCase) { QSet removedItems; + UBGraphicsItemUndoCommand::GroupDataTable groupsMap; switch (pCase) { case clearBackground : @@ -1106,8 +1107,14 @@ void UBGraphicsScene::clearContent(clearCase pCase) if(shouldDelete) { if (itemGroup) { itemGroup->removeFromGroup(item); + + groupsMap.insert(itemGroup, UBGraphicsItem::getOwnUuid(item)); if (itemGroup->childItems().count() == 1) { - itemGroup->destroy(); + groupsMap.insert(itemGroup, UBGraphicsItem::getOwnUuid(itemGroup->childItems().first())); + QGraphicsItem *lastItem = itemGroup->childItems().first(); + bool isSelected = itemGroup->isSelected(); + itemGroup->destroy(false); + lastItem->setSelected(isSelected); } itemGroup->Delegate()->update(); } @@ -1123,7 +1130,8 @@ void UBGraphicsScene::clearContent(clearCase pCase) update(sceneRect()); if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented - UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, QSet()); + + UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, QSet(), groupsMap); UBApplication::undoStack->push(uc); } @@ -1442,6 +1450,7 @@ UBGraphicsTextItem* UBGraphicsScene::textForObjectName(const QString& pString, c textItem->setObjectName(objectName); QSizeF size = textItem->size(); textItem->setPos(QPointF(-size.width()/2.0,-size.height()/2.0)); + textItem->setData(UBGraphicsItemData::ItemEditable,QVariant(false)); } textItem->setPlainText(pString); @@ -1571,8 +1580,9 @@ void UBGraphicsScene::removeItem(QGraphicsItem* item) void UBGraphicsScene::removeItems(const QSet& items) { - foreach(QGraphicsItem* item, items) + foreach(QGraphicsItem* item, items) { UBCoreGraphicsScene::removeItem(item); + } mItemCount -= items.size(); @@ -1665,7 +1675,7 @@ QRectF UBGraphicsScene::normalizedSceneRect(qreal ratio) return normalizedRect; } -QGraphicsItem *UBGraphicsScene::itemByUuid(QUuid uuid) +QGraphicsItem *UBGraphicsScene::itemForUuid(QUuid uuid) { QGraphicsItem *result = 0; diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h index 0dedb9c1..3722d8be 100644 --- a/src/domain/UBGraphicsScene.h +++ b/src/domain/UBGraphicsScene.h @@ -174,7 +174,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem QRectF normalizedSceneRect(qreal ratio = -1.0); - QGraphicsItem *itemByUuid(QUuid uuid); + QGraphicsItem *itemForUuid(QUuid uuid); void moveTo(const QPointF& pPoint); void drawLineTo(const QPointF& pEndPoint, const qreal& pWidth, bool bLineStyle); diff --git a/src/domain/UBGraphicsStrokesGroup.cpp b/src/domain/UBGraphicsStrokesGroup.cpp index fad7127c..793459a8 100644 --- a/src/domain/UBGraphicsStrokesGroup.cpp +++ b/src/domain/UBGraphicsStrokesGroup.cpp @@ -5,7 +5,7 @@ #include "core/memcheck.h" UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent) - :UBGraphicsItem(), QGraphicsItemGroup(parent) + :QGraphicsItemGroup(parent), UBGraphicsItem() { setDelegate(new UBGraphicsItemDelegate(this, 0, true, true, false)); Delegate()->init(); diff --git a/src/domain/UBGraphicsTextItem.cpp b/src/domain/UBGraphicsTextItem.cpp index f7812e29..f1ff2855 100644 --- a/src/domain/UBGraphicsTextItem.cpp +++ b/src/domain/UBGraphicsTextItem.cpp @@ -30,9 +30,9 @@ QColor UBGraphicsTextItem::lastUsedTextColor; -UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) - : UBGraphicsItem() - , QGraphicsTextItem(parent) +UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) : + QGraphicsTextItem(parent) + , UBGraphicsItem() , mMultiClickState(0) , mLastMousePressTime(QTime::currentTime()) { diff --git a/src/domain/UBItem.cpp b/src/domain/UBItem.cpp index c9392e2f..11c18d94 100644 --- a/src/domain/UBItem.cpp +++ b/src/domain/UBItem.cpp @@ -66,12 +66,17 @@ bool UBGraphicsItem::isRotatable(QGraphicsItem *item) return item->data(UBGraphicsItemData::ItemRotatable).toBool(); } -void UBGraphicsItem::remove() +QUuid UBGraphicsItem::getOwnUuid(QGraphicsItem *item) { - if (Delegate()) - Delegate()->remove(this); + QString idCandidate = item->data(UBGraphicsItemData::ItemUuid).toString(); + return idCandidate == QUuid().toString() ? QUuid() : QUuid(idCandidate); } +void UBGraphicsItem::remove(bool canUndo) +{ + if (Delegate()) + Delegate()->remove(canUndo); +} UBGraphicsItemDelegate *UBGraphicsItem::Delegate(QGraphicsItem *pItem) { diff --git a/src/domain/UBItem.h b/src/domain/UBItem.h index 99644f77..a74fd0b4 100644 --- a/src/domain/UBItem.h +++ b/src/domain/UBItem.h @@ -104,11 +104,11 @@ public: static void assignZValue(QGraphicsItem*, qreal value); static bool isRotatable(QGraphicsItem *item); static bool isFlippable(QGraphicsItem *item); + static QUuid getOwnUuid(QGraphicsItem *item); static UBGraphicsItemDelegate *Delegate(QGraphicsItem *pItem); - - void remove(); + void remove(bool canUndo = true); virtual void clearSource(){} diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 03e5190d..afb982b5 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -163,7 +163,8 @@ UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget() void UBTeacherGuideEditionWidget::onSliderMoved(int size) { Q_UNUSED(size); - mpAddAMediaItem->setExpanded(true); + if(mpAddAMediaItem) + mpAddAMediaItem->setExpanded(true); } #endif void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event) @@ -491,7 +492,8 @@ UBTeacherGuidePresentationWidget::~UBTeacherGuidePresentationWidget() void UBTeacherGuidePresentationWidget::onSliderMoved(int size) { Q_UNUSED(size); - mpMediaSwitchItem->setExpanded(true); + if(mpMediaSwitchItem) + mpMediaSwitchItem->setExpanded(true); } #endif diff --git a/src/web/UBWebController.cpp b/src/web/UBWebController.cpp index 9ad0861e..e9d55be2 100644 --- a/src/web/UBWebController.cpp +++ b/src/web/UBWebController.cpp @@ -733,8 +733,8 @@ bool UBWebController::isEduMedia(const QUrl& pUrl) void UBWebController::loadUrl(const QUrl& url) { - bool webBrowserAlreadyInstanciated = dynamic_cast(mStackedWidget->widget(WebBrowser)) != NULL; - UBApplication::applicationController->showInternet(); + bool webBrowserAlreadyInstanciated = dynamic_cast(mStackedWidget->widget(WebBrowser)) != NULL; + UBApplication::applicationController->showInternet(); if (UBSettings::settings()->webUseExternalBrowser->get().toBool()) { QDesktopServices::openUrl(url);